mirror of
https://github.com/filoghost/ChestCommands.git
synced 2024-11-30 05:53:27 +01:00
Add LEVELS cost to icons.
This commit is contained in:
parent
387baf5ab6
commit
a0e721815d
@ -1,6 +1,6 @@
|
|||||||
name: ChestCommands
|
name: ChestCommands
|
||||||
main: com.gmail.filoghost.chestcommands.ChestCommands
|
main: com.gmail.filoghost.chestcommands.ChestCommands
|
||||||
version: 3.0.6
|
version: 3.0.7
|
||||||
softdepend: [Vault, BarAPI, PlayerPoints]
|
softdepend: [Vault, BarAPI, PlayerPoints]
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
|
@ -10,6 +10,7 @@ public class Lang extends SpecialConfig {
|
|||||||
public String no_required_item = "&cYou must have &e{amount}x {material} &c(ID: {id}, data value: {datavalue}) for this.";
|
public String no_required_item = "&cYou must have &e{amount}x {material} &c(ID: {id}, data value: {datavalue}) for this.";
|
||||||
public String no_money = "&cYou need {money}$ for this.";
|
public String no_money = "&cYou need {money}$ for this.";
|
||||||
public String no_points = "&cYou need {points} player points for this.";
|
public String no_points = "&cYou need {points} player points for this.";
|
||||||
|
public String no_exp = "&cYou need {levels} XP levels for this.";
|
||||||
public String menu_not_found = "&cMenu not found! Please inform the staff.";
|
public String menu_not_found = "&cMenu not found! Please inform the staff.";
|
||||||
public String open_menu = "&aOpening the menu \"{menu}\".";
|
public String open_menu = "&aOpening the menu \"{menu}\".";
|
||||||
public String open_menu_others = "&aOpening the menu \"{menu}\" to {player}.";
|
public String open_menu_others = "&aOpening the menu \"{menu}\" to {player}.";
|
||||||
|
@ -23,6 +23,7 @@ public class ExtendedIcon extends Icon {
|
|||||||
|
|
||||||
private double moneyPrice;
|
private double moneyPrice;
|
||||||
private int playerPointsPrice;
|
private int playerPointsPrice;
|
||||||
|
private int expLevelsPrice;
|
||||||
private RequiredItem requiredItem;
|
private RequiredItem requiredItem;
|
||||||
|
|
||||||
public ExtendedIcon() {
|
public ExtendedIcon() {
|
||||||
@ -105,6 +106,14 @@ public class ExtendedIcon extends Icon {
|
|||||||
this.playerPointsPrice = playerPointsPrice;
|
this.playerPointsPrice = playerPointsPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getExpLevelsPrice() {
|
||||||
|
return expLevelsPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpLevelsPrice(int expLevelsPrice) {
|
||||||
|
this.expLevelsPrice = expLevelsPrice;
|
||||||
|
}
|
||||||
|
|
||||||
public RequiredItem getRequiredItem() {
|
public RequiredItem getRequiredItem() {
|
||||||
return requiredItem;
|
return requiredItem;
|
||||||
}
|
}
|
||||||
@ -152,6 +161,13 @@ public class ExtendedIcon extends Icon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (expLevelsPrice > 0) {
|
||||||
|
if (player.getLevel() < expLevelsPrice) {
|
||||||
|
player.sendMessage(ChestCommands.getLang().no_exp.replace("{levels}", Integer.toString(expLevelsPrice)));
|
||||||
|
return closeOnClick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (requiredItem != null) {
|
if (requiredItem != null) {
|
||||||
|
|
||||||
if (!requiredItem.hasItem(player)) {
|
if (!requiredItem.hasItem(player)) {
|
||||||
@ -181,6 +197,10 @@ public class ExtendedIcon extends Icon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (expLevelsPrice > 0) {
|
||||||
|
player.setLevel(player.getLevel() - expLevelsPrice);
|
||||||
|
}
|
||||||
|
|
||||||
if (requiredItem != null) {
|
if (requiredItem != null) {
|
||||||
requiredItem.takeItem(player);
|
requiredItem.takeItem(player);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ public class IconSerializer {
|
|||||||
COMMAND = "COMMAND",
|
COMMAND = "COMMAND",
|
||||||
PRICE = "PRICE",
|
PRICE = "PRICE",
|
||||||
POINTS = "POINTS",
|
POINTS = "POINTS",
|
||||||
|
EXP_LEVELS = "LEVELS",
|
||||||
REQUIRED_ITEM = "REQUIRED-ITEM",
|
REQUIRED_ITEM = "REQUIRED-ITEM",
|
||||||
PERMISSION = "PERMISSION",
|
PERMISSION = "PERMISSION",
|
||||||
PERMISSION_MESSAGE = "PERMISSION-MESSAGE",
|
PERMISSION_MESSAGE = "PERMISSION-MESSAGE",
|
||||||
@ -133,6 +134,13 @@ public class IconSerializer {
|
|||||||
errorLogger.addError("The icon \"" + iconName + "\" in the menu \"" + menuFileName + "\" has negative POINTS: " + price);
|
errorLogger.addError("The icon \"" + iconName + "\" in the menu \"" + menuFileName + "\" has negative POINTS: " + price);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int levels = section.getInt(Nodes.EXP_LEVELS);
|
||||||
|
if (levels > 0) {
|
||||||
|
icon.setExpLevelsPrice(points);
|
||||||
|
} else if (levels < 0) {
|
||||||
|
errorLogger.addError("The icon \"" + iconName + "\" in the menu \"" + menuFileName + "\" has negative LEVELS: " + price);
|
||||||
|
}
|
||||||
|
|
||||||
if (section.isSet(Nodes.REQUIRED_ITEM)) {
|
if (section.isSet(Nodes.REQUIRED_ITEM)) {
|
||||||
try {
|
try {
|
||||||
ItemStackReader itemReader = new ItemStackReader(section.getString(Nodes.REQUIRED_ITEM), true);
|
ItemStackReader itemReader = new ItemStackReader(section.getString(Nodes.REQUIRED_ITEM), true);
|
||||||
|
Loading…
Reference in New Issue
Block a user