Prevent players from entering a negative value for xp
This commit is contained in:
parent
e3e95341ce
commit
0324458efb
|
|
@ -44,6 +44,11 @@ public class XPCheque extends SubCommand {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((xpValue <= 0)) {
|
||||||
|
commandSender.sendMiniMessage(Messages.XP_CHEQUE.NEGATIVE, null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int totalExperience = player.getTotalExperience();
|
int totalExperience = player.getTotalExperience();
|
||||||
if (totalExperience < xpValue) {
|
if (totalExperience < xpValue) {
|
||||||
commandSender.sendMiniMessage(Messages.XP_CHEQUE.NOT_ENOUGH_XP, Placeholder.parsed("xp", String.valueOf(totalExperience)));
|
commandSender.sendMiniMessage(Messages.XP_CHEQUE.NOT_ENOUGH_XP, Placeholder.parsed("xp", String.valueOf(totalExperience)));
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ public class Messages extends AbstractConfig {
|
||||||
private static final String prefix = "pu-command.xp-cheque.";
|
private static final String prefix = "pu-command.xp-cheque.";
|
||||||
|
|
||||||
public static String FAILED_STORAGE = "<red>Unable to create custom item for xp cheque</red>";
|
public static String FAILED_STORAGE = "<red>Unable to create custom item for xp cheque</red>";
|
||||||
|
public static String NEGATIVE = "<red>You cannot enter a negative value for xp.</red>";
|
||||||
public static String NOT_ENOUGH_XP = "<red>Not enough xp, you have <xp></red>";
|
public static String NOT_ENOUGH_XP = "<red>Not enough xp, you have <xp></red>";
|
||||||
public static String NOT_HOLDING_BOTTLE = "<red>You need to hold an empty glass bottle while executing this command</red>";
|
public static String NOT_HOLDING_BOTTLE = "<red>You need to hold an empty glass bottle while executing this command</red>";
|
||||||
public static String DISPLAY_NAME = "<yellow>Xp bottle containing <xp> xp</yellow>";
|
public static String DISPLAY_NAME = "<yellow>Xp bottle containing <xp> xp</yellow>";
|
||||||
|
|
@ -74,6 +75,7 @@ public class Messages extends AbstractConfig {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static void load() {
|
private static void load() {
|
||||||
FAILED_STORAGE = config.getString(prefix, "failed-storage", FAILED_STORAGE);
|
FAILED_STORAGE = config.getString(prefix, "failed-storage", FAILED_STORAGE);
|
||||||
|
NEGATIVE = config.getString(prefix, "negative", NEGATIVE);
|
||||||
NOT_ENOUGH_XP = config.getString(prefix, "not-enough-xp", NOT_ENOUGH_XP);
|
NOT_ENOUGH_XP = config.getString(prefix, "not-enough-xp", NOT_ENOUGH_XP);
|
||||||
NOT_HOLDING_BOTTLE = config.getString(prefix, "not-holding-bottle", NOT_HOLDING_BOTTLE);
|
NOT_HOLDING_BOTTLE = config.getString(prefix, "not-holding-bottle", NOT_HOLDING_BOTTLE);
|
||||||
DISPLAY_NAME = config.getString(prefix, "display-name", DISPLAY_NAME);
|
DISPLAY_NAME = config.getString(prefix, "display-name", DISPLAY_NAME);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user