update to alpha.7

This commit is contained in:
okx-code
2018-08-23 21:29:53 +01:00
parent 32dc06cf62
commit 703342024d
14 changed files with 120 additions and 106 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ public class Rank {
if(requirementsSection != null) {
for (Map.Entry<String, Object> entry : requirementsSection.getValues(false).entrySet()) {
String name = entry.getKey();
double amount = Double.parseDouble(String.valueOf(entry.getValue()));
double amount = Double.parseDouble(String.valueOf(entry.getValue()).replace(",", ""));
Requirement requirement = plugin.getRequirementRegistry().newRequirement(name, amount);
if (requirement == null) {
@@ -1,37 +0,0 @@
package sh.okx.rankup.ranks.requirements;
import org.bukkit.Statistic;
import org.bukkit.entity.Player;
import sh.okx.rankup.Rankup;
public class PlaytimeHoursRequirement extends Requirement {
private static final int TICKS_PER_HOUR = 20 * 60 * 60;
public PlaytimeHoursRequirement(Rankup plugin, String name) {
super(plugin, name);
}
protected PlaytimeHoursRequirement(Requirement clone) {
super(clone);
}
@Override
public boolean check(Player player) {
return player.getStatistic(Statistic.PLAY_ONE_MINUTE) * TICKS_PER_HOUR >= amount;
}
@Override
public void apply(Player player) {
// well, we can't really take hours of playtime away, can we?
}
@Override
public double getRemaining(Player player) {
return amount - (player.getStatistic(Statistic.PLAY_ONE_MINUTE) * TICKS_PER_HOUR);
}
@Override
public Requirement clone() {
return new PlaytimeHoursRequirement(this);
}
}
@@ -0,0 +1,45 @@
package sh.okx.rankup.ranks.requirements;
import org.bukkit.Statistic;
import org.bukkit.entity.Player;
import sh.okx.rankup.Rankup;
public class PlaytimeMinutesRequirement extends Requirement {
private static final int TICKS_PER_MINUTE = 20 * 60;
private Statistic playOneTick;
public PlaytimeMinutesRequirement(Rankup plugin, String name) {
super(plugin, name);
try {
playOneTick = Statistic.valueOf("PLAY_ONE_MINUTE");
} catch(IllegalArgumentException e) {
// statistic was changed in 1.13.
playOneTick = Statistic.valueOf("PLAY_ONE_TICK");
}
}
protected PlaytimeMinutesRequirement(PlaytimeMinutesRequirement clone) {
super(clone);
this.playOneTick = clone.playOneTick;
}
@Override
public boolean check(Player player) {
return player.getStatistic(playOneTick) * TICKS_PER_MINUTE >= amount;
}
@Override
public void apply(Player player) {
// well, we can't really take hours of playtime away, can we?
}
@Override
public double getRemaining(Player player) {
return amount - (player.getStatistic(playOneTick) * TICKS_PER_MINUTE);
}
@Override
public Requirement clone() {
return new PlaytimeMinutesRequirement(this);
}
}