add placeholders for confirmation message
This commit is contained in:
@@ -38,7 +38,7 @@ public class Rank {
|
||||
Set<Requirement> requirements = new HashSet<>();
|
||||
BinaryOperator<Boolean> reducer = null;
|
||||
ConfigurationSection requirementsSection = section.getConfigurationSection("requirements");
|
||||
if(requirementsSection != null) {
|
||||
if (requirementsSection != null) {
|
||||
for (Map.Entry<String, Object> entry : requirementsSection.getValues(false).entrySet()) {
|
||||
String name = entry.getKey();
|
||||
String value = String.valueOf(entry.getValue());
|
||||
@@ -91,7 +91,7 @@ public class Rank {
|
||||
public boolean isInRank(Player player) {
|
||||
String[] groups = plugin.getPermissions().getPlayerGroups(player);
|
||||
for (String group : groups) {
|
||||
if(group.equalsIgnoreCase(rank)) {
|
||||
if (group.equalsIgnoreCase(rank)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -103,8 +103,8 @@ public class Rank {
|
||||
}
|
||||
|
||||
public Requirement getRequirement(String name) {
|
||||
for(Requirement requirement : requirements) {
|
||||
if(requirement.getName().equalsIgnoreCase(name)) {
|
||||
for (Requirement requirement : requirements) {
|
||||
if (requirement.getName().equalsIgnoreCase(name)) {
|
||||
return requirement;
|
||||
}
|
||||
}
|
||||
@@ -112,8 +112,8 @@ public class Rank {
|
||||
}
|
||||
|
||||
public void applyRequirements(Player player) {
|
||||
for(Requirement requirement : requirements) {
|
||||
if(requirement instanceof DeductibleRequirement) {
|
||||
for (Requirement requirement : requirements) {
|
||||
if (requirement instanceof DeductibleRequirement) {
|
||||
((DeductibleRequirement) requirement).apply(player);
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class Rank {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(!(o instanceof Rank)) {
|
||||
if (!(o instanceof Rank)) {
|
||||
return false;
|
||||
}
|
||||
return ((Rank) o).name.equals(name);
|
||||
|
||||
@@ -25,10 +25,10 @@ public class Rankups {
|
||||
|
||||
public Rank getFirstRank() {
|
||||
OUTER:
|
||||
for(Rank rank : ranks) {
|
||||
for (Rank rank : ranks) {
|
||||
// see if anything ranks up to this
|
||||
for(Rank rank0 : ranks) {
|
||||
if(!rank0.isLastRank() && rank0.getNext().equals(rank.getName())) {
|
||||
for (Rank rank0 : ranks) {
|
||||
if (!rank0.isLastRank() && rank0.getNext().equals(rank.getName())) {
|
||||
continue OUTER;
|
||||
}
|
||||
}
|
||||
@@ -39,8 +39,8 @@ public class Rankups {
|
||||
}
|
||||
|
||||
public Rank getRank(String name) {
|
||||
for(Rank rank : ranks) {
|
||||
if(rank.getName().equalsIgnoreCase(name)) {
|
||||
for (Rank rank : ranks) {
|
||||
if (rank.getName().equalsIgnoreCase(name)) {
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
@@ -55,11 +55,11 @@ public class Rankups {
|
||||
}
|
||||
|
||||
public Rank nextRank(Rank rank) {
|
||||
if(rank.isLastRank()) {
|
||||
if (rank.isLastRank()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for(Rank nextRank : ranks) {
|
||||
for (Rank nextRank : ranks) {
|
||||
if (rank.getNext().equalsIgnoreCase(nextRank.getName())) {
|
||||
return nextRank;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public abstract class DeductibleRequirement extends Requirement {
|
||||
* For money, this could be taking money away from the player.
|
||||
* You can assume that <code>Requirement#check(Player)</code> has been called,
|
||||
* and has returned true immediately prior to this.
|
||||
*
|
||||
* @param player the player to take from
|
||||
*/
|
||||
public abstract void apply(Player player);
|
||||
|
||||
@@ -15,9 +15,9 @@ public class GroupRequirement extends Requirement {
|
||||
@Override
|
||||
public boolean check(Player player) {
|
||||
OUTER:
|
||||
for(String requiredGroup : getValueString().split(" ")) {
|
||||
for(String group : plugin.getPermissions().getPlayerGroups(player)) {
|
||||
if(group.equalsIgnoreCase(requiredGroup)) {
|
||||
for (String requiredGroup : getValueString().split(" ")) {
|
||||
for (String group : plugin.getPermissions().getPlayerGroups(player)) {
|
||||
if (group.equalsIgnoreCase(requiredGroup)) {
|
||||
continue OUTER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class PlaytimeMinutesRequirement extends Requirement {
|
||||
super(plugin, name);
|
||||
try {
|
||||
playOneTick = Statistic.valueOf("PLAY_ONE_MINUTE");
|
||||
} catch(IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
// statistic was changed in 1.13.
|
||||
playOneTick = Statistic.valueOf("PLAY_ONE_TICK");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package sh.okx.rankup.ranks.requirements;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.Player;
|
||||
import sh.okx.rankup.Rankup;
|
||||
|
||||
@@ -43,6 +42,7 @@ public abstract class Requirement implements Cloneable {
|
||||
|
||||
/**
|
||||
* Check if a player meets this requirement
|
||||
*
|
||||
* @param player the player to check
|
||||
* @return true if they meet the requirement, false otherwise
|
||||
*/
|
||||
@@ -51,11 +51,13 @@ public abstract class Requirement implements Cloneable {
|
||||
/**
|
||||
* Get the remaining amount needed for <code>Requirement#check(Player)</code> to yield true.
|
||||
* This is not required and is only used in placeholders.
|
||||
*
|
||||
* @param player the player to find the remaining amount of
|
||||
* @return the remaining amount needed. Should be non-negative.
|
||||
*/
|
||||
public double getRemaining(Player player) {
|
||||
return getValueDouble();
|
||||
}
|
||||
|
||||
public abstract Requirement clone();
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ public class RequirementRegistry {
|
||||
}
|
||||
|
||||
public Requirement newRequirement(String name, String value) {
|
||||
for(Requirement requirement : requirements) {
|
||||
if(requirement.getName().equalsIgnoreCase(name)) {
|
||||
for (Requirement requirement : requirements) {
|
||||
if (requirement.getName().equalsIgnoreCase(name)) {
|
||||
Requirement newRequirement = requirement.clone();
|
||||
newRequirement.setValue(value);
|
||||
return newRequirement;
|
||||
|
||||
Reference in New Issue
Block a user