Using this libraries to calculate the rank with customizable method!
This plugin is for developer use only. If you want to try the calculation with normalized data, you can check out this.
About Maven
<repository>
<id>xuan</id>
<url>http://xuan.nctu.me:8081/repository/Maven/</url>
</repository>
<dependency>
<groupId>com.ericlam.mc</groupId>
<artifactId>RankingLib</artifactId>
<version>1.0.0</version>
</dependency>
Example
The implementation example is in here.
Tutorial
First, hooking the RankingLib.jar into your project.
And then you would like to call the API as below
RankLibAPI api = RankingLib.getRankAPI();
In general, RankingLib has provided two default calculators inside(z_score and min max, both are normalization) . However, if you wish to create your own calculation method, you can create as below
For example, I wanna create a calculation method named "z-score"
api.registerCalculator("z-score", (playerData, ladderRanks, arrayData) -> {
double v = playerData.getScore();
double result = AdvMath.round(2, (v - arrayData.getMean()) / arrayData.getSd());
int minScore = (int) -Math.floor((int) (ladderRanks.size() / 2));
int scoreIndex = ((int) result) - minScore;
if (scoreIndex < 0) {
return ladderRanks.get(0);
} else if (scoreIndex > ladderRanks.size()) {
return ladderRanks.get(ladderRanks.size() - 1);
}
RankDataImpl rank = (RankDataImpl) ladderRanks.get(scoreIndex);
rank.setnScore(result);
rank.setOrigScore(v);
return rank;
});
After that, you need to call a factory and put all of your player data and rank data to build the RankDataManager:
RankDataManager manager = api.getFactory().addPlayers(dataList).registerRanks(rankData).build();
dataList = List<PlayerData>
rankData = TreeSet<RankData>
These two need to create by your own.
You may need to register the saving mechanic if you want to save the player data.
To do calculate, you would like to use the method as below:
manager.doCalculate("z-score").whenComplete((map, ex) -> {
if (ex != null) {
ex.printStackTrace();
}
});
Then the result has generated.
You can use other method to do what you want!
Check out the other method in RankDataManager from here
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta