Added a new F Upgrade type!

This commit is contained in:
DroppingAnvil 2019-09-15 17:08:36 -05:00
parent f78290b63d
commit 26010c6ba2
6 changed files with 122 additions and 14 deletions

View File

@ -23,6 +23,10 @@ import java.util.concurrent.ConcurrentHashMap;
public interface Faction extends EconomyParticipator { public interface Faction extends EconomyParticipator {
double getReinforcedArmor();
void setReinforcedArmor(double percent);
int getWarpsLimit(); int getWarpsLimit();
void setWarpsLimit(int limit); void setWarpsLimit(int limit);

View File

@ -45,6 +45,7 @@ public class FUpgradesGUI implements Listener {
List<Integer> increaseSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.DamageIncrease.IncreaseItem.slots"); List<Integer> increaseSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.DamageIncrease.IncreaseItem.slots");
List<Integer> tntSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.TNT.TntItem.slots"); List<Integer> tntSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.TNT.TntItem.slots");
List<Integer> warpSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Warps.WarpItem.slots"); List<Integer> warpSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Warps.WarpItem.slots");
List<Integer> armorSlots = FactionsPlugin.getInstance().getConfig().getIntegerList("fupgrades.MainMenu.Armor.ArmorItem.slots");
for (Integer cropSlot : cropSlots) if (cropSlot != -1) inventory.setItem(cropSlot, items[2]); for (Integer cropSlot : cropSlots) if (cropSlot != -1) inventory.setItem(cropSlot, items[2]);
@ -68,6 +69,8 @@ public class FUpgradesGUI implements Listener {
for(Integer warpSlot : warpSlots) if(warpSlot != -1) inventory.setItem(warpSlot, items[10]); for(Integer warpSlot : warpSlots) if(warpSlot != -1) inventory.setItem(warpSlot, items[10]);
for(Integer armorSlot : armorSlots) if(armorSlot != -1) inventory.setItem(armorSlot, items[11]);
fme.getPlayer().openInventory(inventory); fme.getPlayer().openInventory(inventory);
} }
@ -91,6 +94,7 @@ public class FUpgradesGUI implements Listener {
ItemStack increaseItem = items[8]; ItemStack increaseItem = items[8];
ItemStack tntItem = items[9]; ItemStack tntItem = items[9];
ItemStack warpItem = items[10]; ItemStack warpItem = items[10];
ItemStack armorItem = items[11];
if (e.getCurrentItem().equals(cropItem)) { if (e.getCurrentItem().equals(cropItem)) {
int cropLevel = fme.getFaction().getUpgrade(UpgradeType.CROP); int cropLevel = fme.getFaction().getUpgrade(UpgradeType.CROP);
@ -186,6 +190,24 @@ public class FUpgradesGUI implements Listener {
break; break;
} }
} }
} else if (e.getCurrentItem().equals(armorItem)) {
int armorLevel = fme.getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR);
switch (armorLevel) {
case 3:
return;
case 2: {
if (upgradeItem(fme, UpgradeType.REINFORCEDARMOR, 3, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Cost.level-3")))
break;
}
case 1: {
if (upgradeItem(fme, UpgradeType.REINFORCEDARMOR, 2, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Cost.level-2")))
break;
}
case 0: {
if (upgradeItem(fme, UpgradeType.REINFORCEDARMOR, 1, FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Cost.level-1")))
break;
}
}
} else if (e.getCurrentItem().equals(memberItem)) { } else if (e.getCurrentItem().equals(memberItem)) {
int memberLevel = fme.getFaction().getUpgrade(UpgradeType.MEMBERS) + 1; int memberLevel = fme.getFaction().getUpgrade(UpgradeType.MEMBERS) + 1;
if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.Members.Cost.level-" + memberLevel)) { if (!FactionsPlugin.getInstance().getConfig().isSet("fupgrades.MainMenu.Members.Cost.level-" + memberLevel)) {
@ -580,7 +602,34 @@ public class FUpgradesGUI implements Listener {
warpItem.setAmount(warpLevel); warpItem.setAmount(warpLevel);
} }
return new ItemStack[]{expItem, spawnerItem, cropItem, chestItem, powerItem, redItem, memberItem, reduceItem, increaseItem, tntItem, warpItem}; Material armorMaterial = Material.getMaterial(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Armor.ArmorItem.Type"));
int armorAmt = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.ArmorItem.Amount");
short armorData = Short.parseShort(FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.ArmorItem.Damage") + "");
String armorName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Armor.ArmorItem.Name"));
List<String> armorLore = FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().getConfig().getStringList("fupgrades.MainMenu.Armor.ArmorItem.Lore"));
int armorLevel = fme.getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR);
for (int i = 0; i <= armorLore.size() - 1; i++) {
String line = armorLore.get(i);
line = line.replace("{level}", armorLevel + "");
armorLore.set(i, line);
}
ItemStack armorItem = FactionsPlugin.getInstance().createItem(armorMaterial, armorAmt, armorData, armorName, armorLore);
armorItem.getItemMeta().setLore(armorLore);
if (armorLevel >= 1) {
ItemMeta itemMeta = armorItem.getItemMeta();
if (!FactionsPlugin.getInstance().mc17) {
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
armorItem.setItemMeta(itemMeta);
armorItem.setAmount(armorLevel);
}
return new ItemStack[]{expItem, spawnerItem, cropItem, chestItem, powerItem, redItem, memberItem, reduceItem, increaseItem, tntItem, warpItem, armorItem};
} }
private void updateTntBanks(Faction faction) { private void updateTntBanks(Faction faction) {

View File

@ -12,7 +12,8 @@ public enum UpgradeType {
TNT("TNT"), TNT("TNT"),
WARP("Warps"), WARP("Warps"),
DAMAGEINCREASE("DamageIncrease"), DAMAGEINCREASE("DamageIncrease"),
DAMAGEDECREASE("DamageDecrease"); DAMAGEDECREASE("DamageDecrease"),
REINFORCEDARMOR("ReinforcedArmor");
private String id; private String id;

View File

@ -15,6 +15,7 @@ import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.SpawnerSpawnEvent; import org.bukkit.event.entity.SpawnerSpawnEvent;
import org.bukkit.event.player.PlayerItemDamageEvent;
import org.bukkit.material.Crops; import org.bukkit.material.Crops;
import java.util.List; import java.util.List;
@ -171,4 +172,18 @@ public class UpgradesListener implements Listener {
e.setDamage(damage + damage / 100.0 * increase); e.setDamage(damage + damage / 100.0 * increase);
} }
} }
@EventHandler
public void onArmorDamage(PlayerItemDamageEvent e) {
if (FPlayers.getInstance().getByPlayer(e.getPlayer()) == null) {
return;
}
System.out.print(e.getItem().toString());
if (e.getItem().getType().toString().contains("LEGGINGS") || e.getItem().getType().toString().contains("CHESTPLATE") || e.getItem().getType().toString().contains("HELMET") || e.getItem().getType().toString().contains("BOOTS")) {
int lvl = FPlayers.getInstance().getByPlayer(e.getPlayer()).getFaction().getUpgrade(UpgradeType.REINFORCEDARMOR);
double drop = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Armor.Armor-HP-Drop.level-" + lvl);
int newDamage = (int) Math.round(e.getDamage() - e.getDamage() * drop);
System.out.print(newDamage);
e.setDamage(newDamage);
}
}
} }

View File

@ -82,6 +82,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
private boolean weeWoo; private boolean weeWoo;
private int tntBankSize; private int tntBankSize;
private int warpLimit; private int warpLimit;
private double reinforcedArmor;
// -------------------------------------------- // // -------------------------------------------- //
@ -481,6 +482,12 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
tntBankSize = newLimit; tntBankSize = newLimit;
} }
@Override
public double getReinforcedArmor() { return this.reinforcedArmor; }
@Override
public void setReinforcedArmor(double newPercent) { reinforcedArmor = newPercent; }
@Override @Override
public ItemStack getBanner() { public ItemStack getBanner() {
if (bannerSerialized == null) { if (bannerSerialized == null) {

View File

@ -875,7 +875,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 18 - 31
EXP: EXP:
EXP-Boost: EXP-Boost:
level-1: 1.5 level-1: 1.5
@ -906,7 +906,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 20 - 32
Power: Power:
Power-Boost: Power-Boost:
level-1: 100.0 level-1: 100.0
@ -938,7 +938,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 4 - 22
Redstone: Redstone:
Cost: 1000000 Cost: 1000000
RedstoneItem: RedstoneItem:
@ -955,7 +955,7 @@ fupgrades:
- '&7 - Cost: $1,000,000' - '&7 - Cost: $1,000,000'
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 26 - 23
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!
@ -987,7 +987,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 24 - 30
DamageReduct: DamageReduct:
DamageReductPercent: DamageReductPercent:
level-1: 3 level-1: 3
@ -999,7 +999,7 @@ fupgrades:
level-3: 6000000 level-3: 6000000
ReduceItem: ReduceItem:
Name: '&c&lDamage Reduction Upgrade' Name: '&c&lDamage Reduction Upgrade'
Type: DIAMOND_CHESTPLATE Type: GOLD_CHESTPLATE
Amount: 1 Amount: 1
Damage: 0 Damage: 0
Lore: Lore:
@ -1019,7 +1019,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 0 - 7
DamageIncrease: DamageIncrease:
DamageIncreasePercent: DamageIncreasePercent:
level-1: 3 level-1: 3
@ -1051,7 +1051,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 8 - 1
TNT: TNT:
tnt-limit: tnt-limit:
level-1: 500000 level-1: 500000
@ -1083,7 +1083,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 36 - 21
Warps: Warps:
warp-limit: warp-limit:
level-1: 3 level-1: 3
@ -1115,7 +1115,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 44 - 24
Chest: Chest:
Chest-Size: Chest-Size:
# This is rows # This is rows
@ -1147,7 +1147,7 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 40 - 20
Members: Members:
Members-Limit: Members-Limit:
level-1: 30 level-1: 30
@ -1178,7 +1178,39 @@ fupgrades:
- '' - ''
- '&e&lClick to &nUnlock' - '&e&lClick to &nUnlock'
slots: slots:
- 22 - 40
Armor:
Armor-HP-Drop:
# HP Drop is in percent so .10 would mean it would drop 10% of the damage to the armor
level-1: .10
level-2: .15
level-3: .20
Cost:
level-1: 1000000
level-2: 2000000
level-3: 3000000
ArmorItem:
Name: '&c&lReinforced Armor Upgrade'
Type: DIAMOND_CHESTPLATE
Amount: 1
Damage: 0
Lore:
- '&7Decreases damage to armor.'
- ''
- '&c&lTier'
- '&f&l* &7Current Level: &3{level}/3'
- ''
- '&c&lPerks'
- '&f&l* &7Level 1 - &f10% Reduction'
- '&7 - Cost: $1,000,000'
- '&f&l* &7Level 2 - &f15% Reduction'
- '&7 - Cost: $2,000,000'
- '&f&l* &7Level 3 - &f20% Reduction'
- '&7 - Cost: $3,000,000'
- ''
- '&e&lClick to &nUnlock'
slots:
- 4
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #