Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/com/gmail/mezymc/stats/StatsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,6 @@ public Set<LeaderBoard> getLeaderBoards(){
return leaderBoards;
}

public YamlConfiguration getConfig(){ return cfg; }

}
16 changes: 16 additions & 0 deletions src/main/java/com/gmail/mezymc/stats/StatsPlayer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.gmail.mezymc.stats;

import org.bukkit.configuration.file.YamlConfiguration;

import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -31,6 +33,20 @@ void setGameModeStats(GameMode gameMode, Map<StatType, Integer> stats){
gameModeStats.put(gameMode.getKey(), stats);
}

public int getGameModePoints(GameMode gameMode){
YamlConfiguration cfg = StatsManager.getStatsManager().getConfig();
int kills = getGameModeStats(GameMode.DEFAULT).getOrDefault(StatType.KILL, -1);
int wins = getGameModeStats(GameMode.DEFAULT).getOrDefault(StatType.WIN, -1);
int points = 0;
if (kills > 0){
points += kills * cfg.getInt("points.kill-points");
}
if (wins > 0){
points += wins * cfg.getInt("points.win-points");
}
return points;
}

public Map<StatType, Integer> getGameModeStats(GameMode gameMode){
return gameModeStats.get(gameMode.getKey());
}
Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ leaderboards-sample:
world: world
x: 0
y: 50
z: 0
z: 0

# The equivalent of your stats in points
points:
# how many points does a kill gives ?
kill-points: 1
# how many points does a win gives ?
win-points: 10