Create As Many Levels to Upgrades As You Would Like Now, Properly Relocating InventoryFramework
This commit is contained in:
@@ -28,42 +28,35 @@ public class FUpgradeFrame {
|
||||
public FUpgradeFrame(Faction f) {
|
||||
this.gui = new Gui(FactionsPlugin.getInstance(),
|
||||
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Rows", 5),
|
||||
ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(FactionsPlugin.getInstance().getConfig()
|
||||
.getString("fupgrades.MainMenu.Title")).replace("{faction}", f.getTag())));
|
||||
ChatColor.translateAlternateColorCodes('&', FactionsPlugin.getInstance().getConfig()
|
||||
.getString("fupgrades.MainMenu.Title").replace("{faction}", f.getTag())));
|
||||
}
|
||||
|
||||
public void buildGUI(FPlayer fplayer) {
|
||||
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
|
||||
List<GuiItem> GUIItems = new ArrayList<>();
|
||||
ItemStack dummy = buildDummyItem();
|
||||
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x)
|
||||
GUIItems.add(new GuiItem(dummy, (e) -> e.setCancelled(true)));
|
||||
|
||||
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
|
||||
for (UpgradeType value : UpgradeType.values()) {
|
||||
if (value.getSlot() != -1) {
|
||||
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), (e) -> {
|
||||
GUIItems.set(value.getSlot(), new GuiItem(value.buildAsset(fplayer.getFaction()), e -> {
|
||||
e.setCancelled(true);
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
||||
if (fme.getFaction().getUpgrade(value) != value.getMaxLevel()) {
|
||||
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1));
|
||||
if (fme.getFaction().getUpgrade(value) == value.getMaxLevel()) return;
|
||||
int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1));
|
||||
if (fme.hasMoney(cost)) {
|
||||
fme.takeMoney(cost);
|
||||
if (value == UpgradeType.CHEST)
|
||||
updateChests(fme.getFaction());
|
||||
if (value == UpgradeType.CHEST) updateChests(fme.getFaction());
|
||||
|
||||
if (value == UpgradeType.POWER)
|
||||
updateFactionPowerBoost(fme.getFaction());
|
||||
if (value == UpgradeType.POWER) updateFactionPowerBoost(fme.getFaction());
|
||||
|
||||
if (value == UpgradeType.TNT)
|
||||
updateTNT(fme.getFaction());
|
||||
if (value == UpgradeType.TNT) updateTNT(fme.getFaction());
|
||||
|
||||
if (value == UpgradeType.WARP)
|
||||
updateWarps(fme.getFaction());
|
||||
if (value == UpgradeType.WARP) updateWarps(fme.getFaction());
|
||||
|
||||
fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1);
|
||||
this.buildGUI(fme);
|
||||
buildGUI(fme);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,18 +22,18 @@ public enum UpgradeType {
|
||||
* @author Illyria Team
|
||||
*/
|
||||
|
||||
CHEST("Chest", 3),
|
||||
SPAWNER("Spawners", 3),
|
||||
EXP("EXP", 3),
|
||||
CROP("Crops", 3),
|
||||
POWER("Power", 3),
|
||||
REDSTONE("Redstone", 1),
|
||||
MEMBERS("Members", 3),
|
||||
TNT("TNT", 3),
|
||||
WARP("Warps", 3),
|
||||
DAMAGEINCREASE("DamageIncrease", 3),
|
||||
DAMAGEDECREASE("DamageReduct", 3),
|
||||
REINFORCEDARMOR("Armor", 3);
|
||||
CHEST("Chest", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Max-Level")),
|
||||
SPAWNER("Spawners", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Max-Level")),
|
||||
EXP("EXP", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.Max-Level")),
|
||||
CROP("Crops", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Max-Level")),
|
||||
POWER("Power", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.Max-Level")),
|
||||
REDSTONE("Redstone", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Max-Level")),
|
||||
MEMBERS("Members", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.Max-Level")),
|
||||
TNT("TNT", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.Max-Level")),
|
||||
WARP("Warps", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.Max-Level")),
|
||||
DAMAGEINCREASE("DamageIncrease", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.Max-Level")),
|
||||
DAMAGEDECREASE("DamageReduct", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.Max-Level")),
|
||||
REINFORCEDARMOR("Armor", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Max-Level"));
|
||||
|
||||
private String id;
|
||||
private int maxLevel;
|
||||
@@ -86,7 +86,6 @@ public enum UpgradeType {
|
||||
private ItemStack updateLevelStatus(ItemStack item, int level) {
|
||||
if (level >= 1) {
|
||||
item.setAmount(level);
|
||||
enchant(item);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user