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>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>com.github.stefvanschie.inventoryframework</pattern>
<shadedPattern>com.massivecraft.factions.shade.stefvanschie.inventoryframework</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>com.massivecraft.factions.shade.org.bstats</shadedPattern>

View File

@ -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);
}
}
}));
}
}

View File

@ -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;
}

View File

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