Create As Many Levels to Upgrades As You Would Like Now, Properly Relocating InventoryFramework

This commit is contained in:
Driftay 2020-04-06 11:26:48 -04:00
parent 0c5cc3a978
commit 23320db201
4 changed files with 41 additions and 33 deletions

View File

@ -41,6 +41,10 @@
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<relocations> <relocations>
<relocation>
<pattern>com.github.stefvanschie.inventoryframework</pattern>
<shadedPattern>com.massivecraft.factions.shade.stefvanschie.inventoryframework</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>org.bstats</pattern> <pattern>org.bstats</pattern>
<shadedPattern>com.massivecraft.factions.shade.org.bstats</shadedPattern> <shadedPattern>com.massivecraft.factions.shade.org.bstats</shadedPattern>

View File

@ -28,42 +28,35 @@ public class FUpgradeFrame {
public FUpgradeFrame(Faction f) { public FUpgradeFrame(Faction f) {
this.gui = new Gui(FactionsPlugin.getInstance(), this.gui = new Gui(FactionsPlugin.getInstance(),
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Rows", 5), FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Rows", 5),
ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(FactionsPlugin.getInstance().getConfig() ChatColor.translateAlternateColorCodes('&', FactionsPlugin.getInstance().getConfig()
.getString("fupgrades.MainMenu.Title")).replace("{faction}", f.getTag()))); .getString("fupgrades.MainMenu.Title").replace("{faction}", f.getTag())));
} }
public void buildGUI(FPlayer fplayer) { public void buildGUI(FPlayer fplayer) {
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows()); PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>(); List<GuiItem> GUIItems = new ArrayList<>();
ItemStack dummy = buildDummyItem(); ItemStack dummy = buildDummyItem();
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x) for (int x = 0; x <= this.gui.getRows() * 9 - 1; ++x) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
GUIItems.add(new GuiItem(dummy, (e) -> e.setCancelled(true)));
for (UpgradeType value : UpgradeType.values()) { for (UpgradeType value : UpgradeType.values()) {
if (value.getSlot() != -1) { 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); e.setCancelled(true);
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked()); FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
if (fme.getFaction().getUpgrade(value) != value.getMaxLevel()) { 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)); int cost = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu." + value.toString() + ".Cost.level-" + (fme.getFaction().getUpgrade(value) + 1));
if (fme.hasMoney(cost)) { if (fme.hasMoney(cost)) {
fme.takeMoney(cost); fme.takeMoney(cost);
if (value == UpgradeType.CHEST) if (value == UpgradeType.CHEST) updateChests(fme.getFaction());
updateChests(fme.getFaction());
if (value == UpgradeType.POWER) if (value == UpgradeType.POWER) updateFactionPowerBoost(fme.getFaction());
updateFactionPowerBoost(fme.getFaction());
if (value == UpgradeType.TNT) if (value == UpgradeType.TNT) updateTNT(fme.getFaction());
updateTNT(fme.getFaction());
if (value == UpgradeType.WARP) if (value == UpgradeType.WARP) updateWarps(fme.getFaction());
updateWarps(fme.getFaction());
fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1); fme.getFaction().setUpgrade(value, fme.getFaction().getUpgrade(value) + 1);
this.buildGUI(fme); buildGUI(fme);
} }
}
})); }));
} }
} }

View File

@ -22,18 +22,18 @@ public enum UpgradeType {
* @author Illyria Team * @author Illyria Team
*/ */
CHEST("Chest", 3), CHEST("Chest", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Max-Level")),
SPAWNER("Spawners", 3), SPAWNER("Spawners", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Spawners.Max-Level")),
EXP("EXP", 3), EXP("EXP", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.EXP.Max-Level")),
CROP("Crops", 3), CROP("Crops", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Crops.Max-Level")),
POWER("Power", 3), POWER("Power", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Power.Max-Level")),
REDSTONE("Redstone", 1), REDSTONE("Redstone", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Redstone.Max-Level")),
MEMBERS("Members", 3), MEMBERS("Members", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Members.Max-Level")),
TNT("TNT", 3), TNT("TNT", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.TNT.Max-Level")),
WARP("Warps", 3), WARP("Warps", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Warps.Max-Level")),
DAMAGEINCREASE("DamageIncrease", 3), DAMAGEINCREASE("DamageIncrease", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageIncrease.Max-Level")),
DAMAGEDECREASE("DamageReduct", 3), DAMAGEDECREASE("DamageReduct", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.DamageReduct.Max-Level")),
REINFORCEDARMOR("Armor", 3); REINFORCEDARMOR("Armor", FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Armor.Max-Level"));
private String id; private String id;
private int maxLevel; private int maxLevel;
@ -86,7 +86,6 @@ public enum UpgradeType {
private ItemStack updateLevelStatus(ItemStack item, int level) { private ItemStack updateLevelStatus(ItemStack item, int level) {
if (level >= 1) { if (level >= 1) {
item.setAmount(level); item.setAmount(level);
enchant(item);
} }
return item; return item;
} }

View File

@ -954,6 +954,7 @@ fupgrades:
Lore: Lore:
- ' ' - ' '
Crops: Crops:
Max-Level: 4
Crop-Boost: Crop-Boost:
level-1: 10 level-1: 10
level-2: 20 level-2: 20
@ -969,7 +970,7 @@ fupgrades:
Lore: Lore:
- '&7&oIncrease growth &c&ospeed&7&o of crops in &c&oclaims.' - '&7&oIncrease growth &c&ospeed&7&o of crops in &c&oclaims.'
- '&7&oChance to Grow Two Levels.' - '&7&oChance to Grow Two Levels.'
- 'Current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
- '' - ''
- '&c&lChances' - '&c&lChances'
- '&4&l* &cLevel 1: &f10% Chance' - '&4&l* &cLevel 1: &f10% Chance'
@ -984,6 +985,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 31 Slot: 31
EXP: EXP:
Max-Level: 3
EXP-Boost: EXP-Boost:
level-1: 1.5 level-1: 1.5
level-2: 2.0 level-2: 2.0
@ -1013,6 +1015,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 32 Slot: 32
Power: Power:
Max-Level: 3
Power-Boost: Power-Boost:
level-1: 100.0 level-1: 100.0
level-2: 200.0 level-2: 200.0
@ -1028,7 +1031,7 @@ fupgrades:
Lore: Lore:
- '&a&oIncrease&7&o the amount of &c&opower' - '&a&oIncrease&7&o the amount of &c&opower'
- '&7&oyour &a&ofaction has&7&o.' - '&7&oyour &a&ofaction has&7&o.'
- 'Current level is &e&l&o{level}' - '&7&oYour current level is &e&l&o{level}'
- '' - ''
- '&c&lIncreased Faction Power' - '&c&lIncreased Faction Power'
- '&4&l* &cLevel 1: &f100' - '&4&l* &cLevel 1: &f100'
@ -1043,6 +1046,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 22 Slot: 22
Redstone: Redstone:
Max-Level: 1
Cost: Cost:
level-1: 1000000 level-1: 1000000
DisplayItem: DisplayItem:
@ -1058,6 +1062,7 @@ fupgrades:
- '&7&o(( Tip: &f&oLeft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oLeft-click&7&o to &c&oupgrade&7&o ))'
Slot: 23 Slot: 23
Spawners: Spawners:
Max-Level: 3
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!
level-1: 0.10 level-1: 0.10
@ -1088,6 +1093,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 30 Slot: 30
DamageReduct: DamageReduct:
Max-Level: 3
DamageReductPercent: DamageReductPercent:
level-1: 3 level-1: 3
level-2: 5 level-2: 5
@ -1117,6 +1123,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 7 Slot: 7
DamageIncrease: DamageIncrease:
Max-Level: 3
DamageIncreasePercent: DamageIncreasePercent:
level-1: 3 level-1: 3
level-2: 5 level-2: 5
@ -1146,6 +1153,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 1 Slot: 1
TNT: TNT:
Max-Level: 3
tnt-limit: tnt-limit:
level-1: 500000 level-1: 500000
level-2: 1000000 level-2: 1000000
@ -1175,6 +1183,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 21 Slot: 21
Warps: Warps:
Max-Level: 3
warp-limit: warp-limit:
level-1: 3 level-1: 3
level-2: 4 level-2: 4
@ -1204,6 +1213,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 24 Slot: 24
Chest: Chest:
Max-Level: 3
Chest-Size: Chest-Size:
# This is rows # This is rows
level-1: 2 level-1: 2
@ -1234,6 +1244,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 20 Slot: 20
Members: Members:
Max-Level: 3
Members-Limit: Members-Limit:
level-1: 30 level-1: 30
level-2: 35 level-2: 35
@ -1263,6 +1274,7 @@ fupgrades:
- '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))' - '&7&o(( Tip: &f&oleft-click&7&o to &c&oupgrade&7&o ))'
Slot: 40 Slot: 40
Armor: Armor:
Max-Level: 3
Armor-HP-Drop: Armor-HP-Drop:
# HP Drop is in percent so .10 would mean it would drop 10% of the damage to the armor # HP Drop is in percent so .10 would mean it would drop 10% of the damage to the armor
level-1: .10 level-1: .10