Added alot

This commit is contained in:
Driftay 2019-05-14 09:27:57 -04:00
parent 4681974fee
commit a25ba5e71c
7 changed files with 472 additions and 244 deletions

View File

@ -19,10 +19,7 @@ import com.massivecraft.factions.zcore.MPlugin;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.fupgrades.CropUpgrades; import com.massivecraft.factions.zcore.fupgrades.*;
import com.massivecraft.factions.zcore.fupgrades.EXPUpgrade;
import com.massivecraft.factions.zcore.fupgrades.FUpgradesGUI;
import com.massivecraft.factions.zcore.fupgrades.SpawnerUpgrades;
import com.massivecraft.factions.zcore.util.TextUtil; import com.massivecraft.factions.zcore.util.TextUtil;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
@ -232,6 +229,7 @@ public class SavageFactions extends MPlugin {
new FUpgradesGUI(), new FUpgradesGUI(),
new EXPUpgrade(), new EXPUpgrade(),
new CropUpgrades(), new CropUpgrades(),
new RedstoneUpgrade(),
new SpawnerUpgrades(), new SpawnerUpgrades(),
}; };

View File

@ -12,7 +12,7 @@ public class CmdUpgrades extends FCommand {
this.aliases.add("upgrade"); this.aliases.add("upgrade");
//this.requiredArgs.add(""); //this.requiredArgs.add("");
this.optionalArgs.put("mobs/crops/exp", ""); this.optionalArgs.put("mobs/crops/exp/power", "");
this.permission = Permission.UPGRADES.node; this.permission = Permission.UPGRADES.node;
this.disableOnLock = true; this.disableOnLock = true;

View File

@ -20,278 +20,386 @@ import java.util.List;
public class FUpgradesGUI implements Listener { public class FUpgradesGUI implements Listener {
public void openMainMenu(FPlayer fme) { public void openMainMenu(FPlayer fme) {
Inventory inventory = Bukkit.createInventory(null, 27, SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", fme.getFaction().getTag()))); Inventory inventory = Bukkit.createInventory(null, 45, SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", fme.getFaction().getTag())));
List<Integer> dummySlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.DummyItem.slots"); List<Integer> dummySlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.DummyItem.slots");
Material dummyMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.DummyItem.Type")); Material dummyMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.DummyItem.Type"));
int dummyAmount = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.DummyItem.Amount"); int dummyAmount = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.DummyItem.Amount");
short dummyData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.DummyItem.Damage") + ""); short dummyData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.DummyItem.Damage") + "");
ItemStack dummyItem = SavageFactions.plugin.createItem(dummyMaterial, ItemStack dummyItem = SavageFactions.plugin.createItem(dummyMaterial,
dummyAmount, dummyAmount,
dummyData, dummyData,
SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.DummyItem.Name")), SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.DummyItem.Name")),
SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.DummyItem.Lore"))); SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.DummyItem.Lore")));
for (int i = 0; i <= dummySlots.size() - 1; i++) { for (int i = 0; i <= dummySlots.size() - 1; i++) {
inventory.setItem(dummySlots.get(i), dummyItem); inventory.setItem(dummySlots.get(i), dummyItem);
} }
ItemStack[] items = buildItems(fme); ItemStack[] items = buildItems(fme);
List<Integer> cropSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Crops.CropItem.slots"); List<Integer> cropSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Crops.CropItem.slots");
List<Integer> spawnerSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Spawners.SpawnerItem.slots"); List<Integer> spawnerSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Spawners.SpawnerItem.slots");
List<Integer> expSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.EXP.EXPItem.slots"); List<Integer> expSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.EXP.EXPItem.slots");
List<Integer> chestSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Chest.ChestItem.slots"); List<Integer> chestSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Chest.ChestItem.slots");
List<Integer> powerSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Power.PowerItem.slots");
List<Integer> redSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Redstone.RedstoneItem.slots");
for (int i = 0; i < cropSlots.size(); i++) for (int i = 0; i < cropSlots.size(); i++)
if (cropSlots.get(i) != -1) inventory.setItem(cropSlots.get(i), items[2]); if (cropSlots.get(i) != -1) inventory.setItem(cropSlots.get(i), items[2]);
for (int i = 0; i < spawnerSlots.size(); i++) for (int i = 0; i < spawnerSlots.size(); i++)
if (spawnerSlots.get(i) != -1) inventory.setItem(spawnerSlots.get(i), items[1]); if (spawnerSlots.get(i) != -1) inventory.setItem(spawnerSlots.get(i), items[1]);
for (int i = 0; i < expSlots.size(); i++) for (int i = 0; i < expSlots.size(); i++)
if (expSlots.get(i) != -1) inventory.setItem(expSlots.get(i), items[0]); if (expSlots.get(i) != -1) inventory.setItem(expSlots.get(i), items[0]);
for (int i = 0; i < chestSlots.size(); i++) for (int i = 0; i < chestSlots.size(); i++)
if (chestSlots.get(i) != -1) inventory.setItem(chestSlots.get(i), items[3]); if (chestSlots.get(i) != -1) inventory.setItem(chestSlots.get(i), items[3]);
fme.getPlayer().openInventory(inventory); for (int i = 0; i < powerSlots.size(); i++)
} if (powerSlots.get(i) != -1) inventory.setItem(powerSlots.get(i), items[4]);
@EventHandler for (int i = 0; i < redSlots.size(); i++)
public void onClick(InventoryClickEvent e) { if (redSlots.get(i) != -1) inventory.setItem(redSlots.get(i), items[5]);
if (e.getClickedInventory() == null || e.getCurrentItem() == null || e.getCurrentItem().getItemMeta() == null || e.getCursor() == null)
return;
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked()); fme.getPlayer().openInventory(inventory);
if (e.getClickedInventory().getTitle().equalsIgnoreCase(SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", fme.getFaction().getTag())))) { }
e.setCancelled(true);
ItemStack[] items = buildItems(fme);
ItemStack cropItem = items[2];
ItemStack expItem = items[0];
ItemStack chestitem = items[3];
ItemStack spawnerItem = items[1];
if (e.getCurrentItem().equals(cropItem)) { @EventHandler
int cropLevel = fme.getFaction().getUpgrade(Upgrade.CROP); public void onClick(InventoryClickEvent e) {
if (e.getClickedInventory() == null || e.getCurrentItem() == null || e.getCurrentItem().getItemMeta() == null || e.getCursor() == null)
return;
switch (cropLevel) { FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
case 3: if (e.getClickedInventory().getTitle().equalsIgnoreCase(SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", fme.getFaction().getTag())))) {
return; e.setCancelled(true);
case 2: ItemStack[] items = buildItems(fme);
upgradeItem(fme, Upgrade.CROP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3")); ItemStack cropItem = items[2];
break; ItemStack expItem = items[0];
case 1: ItemStack chestitem = items[3];
upgradeItem(fme, Upgrade.CROP, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-2")); ItemStack spawnerItem = items[1];
break; ItemStack powerItem = items[4];
case 0: ItemStack redItem = items[5];
upgradeItem(fme, Upgrade.CROP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-1"));
break;
}
} else if (e.getCurrentItem().equals(spawnerItem)) {
int spawnerLevel = fme.getFaction().getUpgrade(Upgrade.SPAWNER);
switch (spawnerLevel) { if (e.getCurrentItem().equals(cropItem)) {
case 3: int cropLevel = fme.getFaction().getUpgrade(Upgrade.CROP);
return; switch (cropLevel) {
case 2: case 3:
upgradeItem(fme, Upgrade.SPAWNER, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3")); return;
break; case 2:
case 1: upgradeItem(fme, Upgrade.CROP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-3"));
upgradeItem(fme, Upgrade.SPAWNER, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-2")); break;
break; case 1:
case 0: upgradeItem(fme, Upgrade.CROP, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-2"));
upgradeItem(fme, Upgrade.SPAWNER, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-1")); break;
break; case 0:
} upgradeItem(fme, Upgrade.CROP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.Cost.level-1"));
} else if (e.getCurrentItem().equals(expItem)) { break;
int expLevel = fme.getFaction().getUpgrade(Upgrade.EXP); }
} else if (e.getCurrentItem().equals(powerItem)) {
int powerLevel = fme.getFaction().getUpgrade(Upgrade.POWER);
switch (powerLevel) {
case 3:
return;
case 2:
upgradeItem(fme, Upgrade.POWER, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Power.Cost.level-3"));
updatePower(fme.getFaction());
break;
case 1:
upgradeItem(fme, Upgrade.POWER, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Power.Cost.level-2"));
updatePower(fme.getFaction());
break;
case 0:
upgradeItem(fme, Upgrade.POWER, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Power.Cost.level-1"));
updatePower(fme.getFaction());
break;
}
} else if (e.getCurrentItem().equals(spawnerItem)) {
int spawnerLevel = fme.getFaction().getUpgrade(Upgrade.SPAWNER);
switch (spawnerLevel) {
case 3:
return;
case 2:
upgradeItem(fme, Upgrade.SPAWNER, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-3"));
break;
case 1:
upgradeItem(fme, Upgrade.SPAWNER, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-2"));
break;
case 0:
upgradeItem(fme, Upgrade.SPAWNER, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.Cost.level-1"));
break;
}
} else if (e.getCurrentItem().equals(expItem)) {
int expLevel = fme.getFaction().getUpgrade(Upgrade.EXP);
switch (expLevel) { switch (expLevel) {
case 3: case 3:
return; return;
case 2: case 2:
upgradeItem(fme, Upgrade.EXP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3")); upgradeItem(fme, Upgrade.EXP, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-3"));
break; break;
case 1: case 1:
upgradeItem(fme, Upgrade.EXP, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-2")); upgradeItem(fme, Upgrade.EXP, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-2"));
break; break;
case 0: case 0:
upgradeItem(fme, Upgrade.EXP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-1")); upgradeItem(fme, Upgrade.EXP, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.Cost.level-1"));
break; break;
} }
} else if (e.getCurrentItem().equals(chestitem)) { } else if (e.getCurrentItem().equals(redItem)) {
int chestLevel = fme.getFaction().getUpgrade(Upgrade.CHEST); int redLevel = fme.getFaction().getUpgrade(Upgrade.REDSTONE);
switch (redLevel) {
case 1:
return;
case 0:
upgradeItem(fme, Upgrade.REDSTONE, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Redstone.Cost"));
break;
}
} else if (e.getCurrentItem().equals(chestitem)) {
int chestLevel = fme.getFaction().getUpgrade(Upgrade.CHEST);
switch (chestLevel) {
case 3:
return;
case 2: {
if (upgradeItem(fme, Upgrade.CHEST, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3")))
updateChests(fme.getFaction());
break;
}
case 1: {
if (upgradeItem(fme, Upgrade.CHEST, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2")))
updateChests(fme.getFaction());
break;
}
case 0: {
if (upgradeItem(fme, Upgrade.CHEST, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-1")))
updateChests(fme.getFaction());
break;
}
}
}
}
}
switch (chestLevel) { private void updateChests(Faction faction) {
case 3: String invName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fchest.Inventory-Title"));
return;
case 2: {
if (upgradeItem(fme, Upgrade.CHEST, 3, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-3")))
updateChests(fme.getFaction());
break;
}
case 1: {
if (upgradeItem(fme, Upgrade.CHEST, 2, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-2")))
updateChests(fme.getFaction());
break;
}
case 0: {
if (upgradeItem(fme, Upgrade.CHEST, 1, SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Cost.level-1")))
updateChests(fme.getFaction());
break;
}
}
}
}
}
private void updateChests(Faction faction) { for (Player player : faction.getOnlinePlayers()) {
String invName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fchest.Inventory-Title")); if (player.getInventory().getTitle() != null && player.getInventory().getTitle().equalsIgnoreCase(invName))
player.closeInventory();
}
for (Player player : faction.getOnlinePlayers()) { int level = faction.getUpgrade(Upgrade.CHEST);
if (player.getInventory().getTitle() != null && player.getInventory().getTitle().equalsIgnoreCase(invName)) int size = 1;
player.closeInventory();
}
int level = faction.getUpgrade(Upgrade.CHEST); switch (level) {
int size = 1; case 1:
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1");
break;
case 2:
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2");
break;
case 3:
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3");
break;
}
faction.setChestSize(size * 9);
}
switch (level) { private void updatePower(Faction faction) {
case 1: int level = faction.getUpgrade(Upgrade.POWER);
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-1"); double power = 0.0;
break;
case 2:
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-2");
break;
case 3:
size = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3");
break;
}
faction.setChestSize(size * 9);
}
private ItemStack[] buildItems(FPlayer fme) { switch (level) {
Material expMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Type")); case 1:
int expAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Amount"); power = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Power.Power-Boost.level-1");
short expData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Damage") + ""); break;
String expName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Name")); case 2:
List<String> expLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.EXP.EXPItem.Lore")); power = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Power.Power-Boost.level-2");
int expLevel = fme.getFaction().getUpgrade(Upgrade.EXP); break;
case 3:
power = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Power.Power-Boost.level-3");
break;
}
faction.setPowerBoost(power);
}
for (int i = 0; i <= expLore.size() - 1; i++) @SuppressWarnings("Duplicates")
expLore.set(i, expLore.get(i).replace("{level}", expLevel + "")); private ItemStack[] buildItems(FPlayer fme) {
Material expMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Type"));
int expAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Amount");
short expData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.EXP.EXPItem.Damage") + "");
String expName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.EXP.EXPItem.Name"));
List<String> expLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.EXP.EXPItem.Lore"));
int expLevel = fme.getFaction().getUpgrade(Upgrade.EXP);
ItemStack expItem = SavageFactions.plugin.createItem(expMaterial, expAmt, expData, expName, expLore); for (int i = 0; i <= expLore.size() - 1; i++)
expLore.set(i, expLore.get(i).replace("{level}", expLevel + ""));
if (expLevel >= 1) { ItemStack expItem = SavageFactions.plugin.createItem(expMaterial, expAmt, expData, expName, expLore);
ItemMeta itemMeta = expItem.getItemMeta();
if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
expItem.setItemMeta(itemMeta); if (expLevel >= 1) {
expItem.setAmount(expLevel); ItemMeta itemMeta = expItem.getItemMeta();
} if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
Material spawnerMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Type")); expItem.setItemMeta(itemMeta);
int spawnerAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Amount"); expItem.setAmount(expLevel);
short spawnerData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Damage") + ""); }
String spawnerName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Name"));
List<String> spawnerLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Spawners.SpawnerItem.Lore"));
List<Integer> spawnerSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Spawners.SpawnerItem.slots"); Material spawnerMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Type"));
int spawnerLevel = fme.getFaction().getUpgrade(Upgrade.SPAWNER); int spawnerAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Amount");
short spawnerData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Spawners.SpawnerItem.Damage") + "");
String spawnerName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Spawners.SpawnerItem.Name"));
List<String> spawnerLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Spawners.SpawnerItem.Lore"));
for (int i = 0; i <= spawnerLore.size() - 1; i++) { List<Integer> spawnerSlots = SavageFactions.plugin.getConfig().getIntegerList("fupgrades.MainMenu.Spawners.SpawnerItem.slots");
spawnerLore.set(i, spawnerLore.get(i).replace("{level}", spawnerLevel + "")); int spawnerLevel = fme.getFaction().getUpgrade(Upgrade.SPAWNER);
}
Material cropMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Type")); for (int i = 0; i <= spawnerLore.size() - 1; i++) {
int cropAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Amount"); spawnerLore.set(i, spawnerLore.get(i).replace("{level}", spawnerLevel + ""));
short cropData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Damage") + ""); }
String cropName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Name"));
List<String> cropLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Crops.CropItem.Lore"));
int cropLevel = fme.getFaction().getUpgrade(Upgrade.CROP);
for (int i = 0; i <= cropLore.size() - 1; i++) { Material cropMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Type"));
String line = cropLore.get(i); int cropAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Amount");
line = line.replace("{level}", cropLevel + ""); short cropData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Crops.CropItem.Damage") + "");
cropLore.set(i, line); String cropName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Crops.CropItem.Name"));
} List<String> cropLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Crops.CropItem.Lore"));
int cropLevel = fme.getFaction().getUpgrade(Upgrade.CROP);
ItemStack cropItem = SavageFactions.plugin.createItem(cropMaterial, cropAmt, cropData, cropName, cropLore); for (int i = 0; i <= cropLore.size() - 1; i++) {
cropItem.getItemMeta().setLore(cropLore); String line = cropLore.get(i);
line = line.replace("{level}", cropLevel + "");
cropLore.set(i, line);
}
if (cropLevel >= 1) { ItemStack cropItem = SavageFactions.plugin.createItem(cropMaterial, cropAmt, cropData, cropName, cropLore);
ItemMeta itemMeta = cropItem.getItemMeta(); cropItem.getItemMeta().setLore(cropLore);
if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
cropItem.setItemMeta(itemMeta);
cropItem.setAmount(cropLevel); if (cropLevel >= 1) {
} ItemMeta itemMeta = cropItem.getItemMeta();
if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
cropItem.setItemMeta(itemMeta);
ItemStack spawnerItem = SavageFactions.plugin.createItem(spawnerMaterial, spawnerAmt, spawnerData, spawnerName, spawnerLore); cropItem.setAmount(cropLevel);
spawnerItem.getItemMeta().setLore(spawnerLore); }
if (spawnerLevel >= 1) {
ItemMeta itemMeta = spawnerItem.getItemMeta();
if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
spawnerItem.setItemMeta(itemMeta); ItemStack spawnerItem = SavageFactions.plugin.createItem(spawnerMaterial, spawnerAmt, spawnerData, spawnerName, spawnerLore);
spawnerItem.setAmount(spawnerLevel); spawnerItem.getItemMeta().setLore(spawnerLore);
} if (spawnerLevel >= 1) {
ItemMeta itemMeta = spawnerItem.getItemMeta();
if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
Material chestMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Type")); spawnerItem.setItemMeta(itemMeta);
int chesttAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Amount"); spawnerItem.setAmount(spawnerLevel);
short chestData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Damage") + ""); }
String chestName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Name", "&e&lUpgrade Chest Size"));
List<String> chestLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Chest.ChestItem.Lore"));
int chestlevel = fme.getFaction().getUpgrade(Upgrade.CHEST);
for (int i = 0; i <= chestLore.size() - 1; i++) { Material chestMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Type"));
String line = chestLore.get(i); int chesttAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Amount");
line = line.replace("{level}", chestlevel + ""); short chestData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Chest.ChestItem.Damage") + "");
chestLore.set(i, line); String chestName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Chest.ChestItem.Name", "&e&lUpgrade Chest Size"));
} List<String> chestLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Chest.ChestItem.Lore"));
int chestlevel = fme.getFaction().getUpgrade(Upgrade.CHEST);
ItemStack chestItem = SavageFactions.plugin.createItem(chestMaterial, chesttAmt, chestData, chestName, chestLore); for (int i = 0; i <= chestLore.size() - 1; i++) {
String line = chestLore.get(i);
line = line.replace("{level}", chestlevel + "");
chestLore.set(i, line);
}
if (chestlevel >= 1) { ItemStack chestItem = SavageFactions.plugin.createItem(chestMaterial, chesttAmt, chestData, chestName, chestLore);
ItemMeta itemMeta = chestItem.getItemMeta();
if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
chestItem.setItemMeta(itemMeta); if (chestlevel >= 1) {
chestItem.setAmount(chestlevel); ItemMeta itemMeta = chestItem.getItemMeta();
} if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
ItemStack[] items = {expItem, spawnerItem, cropItem, chestItem}; chestItem.setItemMeta(itemMeta);
return items; chestItem.setAmount(chestlevel);
} }
private boolean hasMoney(FPlayer fme, int amt) { Material powerMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Power.PowerItem.Type"));
return fme.hasMoney(amt); int powerAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Power.PowerItem.Amount");
} short powerData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Power.PowerItem.Damage") + "");
String powerName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Power.PowerItem.Name"));
List<String> powerLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Power.PowerItem.Lore"));
int powerLevel = fme.getFaction().getUpgrade(Upgrade.POWER);
private void takeMoney(FPlayer fme, int amt) { for (int i = 0; i <= powerLore.size() - 1; i++) {
fme.takeMoney(amt); String line = powerLore.get(i);
} line = line.replace("{level}", powerLevel + "");
powerLore.set(i, line);
}
private boolean upgradeItem(FPlayer fme, Upgrade upgrade, int level, int cost) { ItemStack powerItem = SavageFactions.plugin.createItem(powerMaterial, powerAmt, powerData, powerName, powerLore);
if (hasMoney(fme, cost)) { powerItem.getItemMeta().setLore(powerLore);
takeMoney(fme, cost);
fme.getFaction().setUpgrade(upgrade, level); if (powerLevel >= 1) {
fme.getPlayer().closeInventory(); ItemMeta itemMeta = powerItem.getItemMeta();
return true; if (!SavageFactions.plugin.mc17) {
} itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
return false; }
} itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
powerItem.setItemMeta(itemMeta);
powerItem.setAmount(powerLevel);
}
Material redMaterial = Material.getMaterial(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Redstone.RedstoneItem.Type"));
int redAmt = SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Redstone.RedstoneItem.Amount");
short redData = Short.parseShort(SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Redstone.RedstoneItem.Damage") + "");
String redName = SavageFactions.plugin.color(SavageFactions.plugin.getConfig().getString("fupgrades.MainMenu.Redstone.RedstoneItem.Name"));
List<String> redLore = SavageFactions.plugin.colorList(SavageFactions.plugin.getConfig().getStringList("fupgrades.MainMenu.Redstone.RedstoneItem.Lore"));
int redLevel = fme.getFaction().getUpgrade(Upgrade.REDSTONE);
for (int i = 0; i <= redLore.size() - 1; i++) {
String line = redLore.get(i);
line = line.replace("{level}", redLevel + "");
redLore.set(i, line);
}
ItemStack redItem = SavageFactions.plugin.createItem(redMaterial, redAmt, redData, redName, redLore);
redItem.getItemMeta().setLore(redLore);
if (redLevel >= 1) {
ItemMeta itemMeta = redItem.getItemMeta();
if (!SavageFactions.plugin.mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
redItem.setItemMeta(itemMeta);
redItem.setAmount(redLevel);
}
ItemStack[] items = {expItem, spawnerItem, cropItem, chestItem, powerItem, redItem};
return items;
}
private boolean hasMoney(FPlayer fme, int amt) {
return fme.hasMoney(amt);
}
private void takeMoney(FPlayer fme, int amt) {
fme.takeMoney(amt);
}
private boolean upgradeItem(FPlayer fme, Upgrade upgrade, int level, int cost) {
if (hasMoney(fme, cost)) {
takeMoney(fme, cost);
fme.getFaction().setUpgrade(upgrade, level);
fme.getPlayer().closeInventory();
return true;
}
return false;
}
} }

View File

@ -0,0 +1,36 @@
package com.massivecraft.factions.zcore.fupgrades;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SavageFactions;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
import java.util.List;
public class RedstoneUpgrade implements Listener {
@EventHandler
public void onWaterRedstone(BlockFromToEvent e) {
List<String> unbreakable = SavageFactions.plugin.getConfig().getStringList("no-water-destroy.Item-List");
String block = e.getToBlock().getType().toString();
FLocation floc = new FLocation(e.getToBlock().getLocation());
Faction factionAtLoc = Board.getInstance().getFactionAt(floc);
if (!factionAtLoc.isWilderness()) {
int level = factionAtLoc.getUpgrade(Upgrade.REDSTONE);
if (level != 0) {
switch (level) {
case 1:
SavageFactions.plugin.getConfig().getInt("fupgrades.MainMenu.Redstone.Cost");
break;
}
if (unbreakable.contains(block)) {
e.setCancelled(true);
}
}
}
}
}

View File

@ -2,7 +2,7 @@ package com.massivecraft.factions.zcore.fupgrades;
public enum Upgrade { public enum Upgrade {
CHEST("Chest"), SPAWNER("Spawner"), EXP("Exp"), CROP("Crop"); CHEST("Chest"), SPAWNER("Spawner"), EXP("Exp"), CROP("Crop"), POWER("Power"), REDSTONE("Redstone");
private String id; private String id;

View File

@ -27,6 +27,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -1214,12 +1215,18 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
} }
public String commas(final double amount) {
final DecimalFormat formatter = new DecimalFormat("#,###.00");
final String number = formatter.format(amount);
return number;
}
@Override @Override
public void takeMoney(int amt) { public void takeMoney(int amt) {
if (hasMoney(amt)) { if (hasMoney(amt)) {
Economy econ = SavageFactions.plugin.getEcon(); Economy econ = SavageFactions.plugin.getEcon();
econ.withdrawPlayer(getPlayer(), amt); econ.withdrawPlayer(getPlayer(), amt);
sendMessage(TL.GENERIC_MONEYTAKE.toString().replace("{amount}", amt + "")); sendMessage(TL.GENERIC_MONEYTAKE.toString().replace("{amount}", commas(amt)));
} }
} }
} }

View File

@ -807,7 +807,7 @@ fupgrades:
Damage: 7 Damage: 7
Lore: Lore:
- '' - ''
rows: 3 rows: 5
slots: slots:
- 0 - 0
- 1 - 1
@ -836,6 +836,24 @@ fupgrades:
- 24 - 24
- 25 - 25
- 26 - 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
Crops: Crops:
Crop-Boost: Crop-Boost:
level-1: 10 level-1: 10
@ -867,7 +885,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 10 - 18
EXP: EXP:
EXP-Boost: EXP-Boost:
level-1: 1.5 level-1: 1.5
@ -898,7 +916,56 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 13 - 20
Power:
Power-Boost:
level-1: 100.0
level-2: 200.0
level-3: 300.0
Cost:
level-1: 1000000
level-2: 2000000
level-3: 3000000
PowerItem:
Name: '&e&lFaction Power'
Type: DIAMOND_SWORD
Amount: 1
Damage: 0
Lore:
- '&7&o(Increase the amount of power'
- '&7&oyour faction has)'
- ''
- '&e&lTier'
- '&f&l* &7Current Level: &3{level}/3'
- ''
- '&e&lPerks'
- '&f&l* &7Level 1 - &f100 Increased Faction Power'
- '&7 - Cost: $1,000,000'
- '&f&l* &7Level 2 - &f200 Increased Faction Power'
- '&7 - Cost: $2,000,000'
- '&f&l* &7Level 3 - &f300 Increased Faction Power'
- '&7 - Cost: $3,000,000'
- ''
- '&e&lClick to &nUnlock'
slots:
- 4
Redstone:
Cost: 1000000
RedstoneItem:
Name: '&e&lUnbreakable Redstone'
Type: REDSTONE
Amount: 1
Damage: 0
Lore:
- '&7&o(Prevents water from being'
- '&7&oable to break redstone)'
- ''
- '&f&l* &7Current Level: &3{level}/1'
- ''
- '&7 - Cost: $1,000,000'
- '&e&lClick to &nUnlock'
slots:
- 26
Spawners: Spawners:
Spawner-Boost: Spawner-Boost:
# This is a Percentage so .10 means 10% lowered spawner delay! # This is a Percentage so .10 means 10% lowered spawner delay!
@ -930,7 +997,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 16 - 24
Chest: Chest:
Chest-Size: Chest-Size:
# This is rows # This is rows
@ -962,7 +1029,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 22 - 40
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
@ -1010,6 +1077,18 @@ see-chunk:
particles: true particles: true
interval: 5 interval: 5
no-water-destroy:
Item-List:
- 'REDSTONE_COMPARATOR'
- 'REDSTONE_COMPARATOR_OFF'
- 'REDSTONE_COMPARATOR_ON'
- 'REDSTONE_TORCH_OFF'
- 'REDSTONE_TORCH_ON'
- 'REDSTONE_WIRE'
- 'DIODE'
- 'DIODE_BLOCK_OFF'
- 'DIODE_BLOCK_ON'
- 'REDSTONE'
Tntfill: Tntfill:
enabled: true enabled: true