diff --git a/.gitignore b/.gitignore index bc3284d2..be2ef05a 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ hs_err_pid* # JDT-specific (Eclipse Java Development Tools) .classpath /target/ + +*.iml diff --git a/pom.xml b/pom.xml index 9804f3f8..3deb6d95 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.2.13 + 2.2.14 jar clean install @@ -138,12 +138,6 @@ 1.7 provided - - com.github.OmerBenGera - WildStackerAPI - b15 - provided - com.songoda ultimatestacker diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java index 53efdc30..551e91fb 100644 --- a/src/main/java/com/songoda/skyblock/SkyBlock.java +++ b/src/main/java/com/songoda/skyblock/SkyBlock.java @@ -186,7 +186,6 @@ public class SkyBlock extends SongodaPlugin { pluginManager.registerEvents(new FallBreak(this), this); if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this); - if (pluginManager.isPluginEnabled("WildStacker")) pluginManager.registerEvents(new WildStacker(this), this); if (pluginManager.isPluginEnabled("UltimateStacker")) pluginManager.registerEvents(new UltimateStacker(this), this); diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java index 58893a2e..2233bef2 100644 --- a/src/main/java/com/songoda/skyblock/bank/BankManager.java +++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java @@ -19,7 +19,7 @@ public class BankManager { public static BankManager getInstance() {return instance == null ? instance = new BankManager() : instance;} - public HashMap> log; + private HashMap> log; public FileConfiguration lang; @@ -35,12 +35,10 @@ public class BankManager { if (log.containsKey(player.getUniqueId())&&log.get(player.getUniqueId())!=null&&!log.get(player.getUniqueId()).isEmpty()) { List lore = new ArrayList<>(); List transactions = log.get(player.getUniqueId()); - int count = 1; - while (count <= 10) { - if (transactions.size()-count < 0) { break; } - Transaction t = transactions.get(transactions.size()-count); - lore.add("#" + count + " " + t.timestamp.toString() +" " + t.player.getPlayer().getDisplayName() + " " + t.action.name().toLowerCase() + " " + EconomyManager.formatEconomy(t.ammount)); - count++; + int size = transactions.size()>10 ? 10 : transactions.size(); + for (int i = 0;i t = new ArrayList<>(); t.add(transaction); log.put(p.getUniqueId(),t); } - SkyBlock.getInstance().getPlayerDataManager().getPlayerData().get(p.getUniqueId()).getTransactions().add(transaction); - } private void loadTransactions() { @@ -70,8 +66,9 @@ public class BankManager { public List getBalanceLore(Player player) { List result = new ArrayList<>(); - result.add("Some error occured while loading your balance"); + result.add("Some error occurred while loading your balance!"); Island island = SkyBlock.getInstance().getIslandManager().getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); + result.add("If this is null then its a easy to fix bug: "+island.toString()); if (island != null) { result.clear(); result.add(player.getDisplayName()+"'s balance is "+EconomyManager.formatEconomy(EconomyManager.getBalance(Bukkit.getOfflinePlayer(player.getUniqueId())))); diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java index 4e4e9814..14d51502 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java +++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java @@ -121,7 +121,7 @@ public class AdminBank extends SubCommand { @Override public String getName() { - return "adminbank"; + return "bank"; } @Override diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java index cafffe02..b0c4bd3a 100644 --- a/src/main/java/com/songoda/skyblock/island/IslandManager.java +++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java @@ -532,6 +532,7 @@ public class IslandManager { if ((amt = data.getIslandDeletionCount()) >= highest) return false; data.setIslandDeletionCount(amt + 1); + data.deleteTransactions(); } } } diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java index ecda1a27..2d8ee400 100644 --- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java +++ b/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java @@ -3,21 +3,16 @@ package com.songoda.skyblock.levelling.rework; import java.io.File; import java.util.ArrayList; import java.util.EnumMap; -import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.Set; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.skyblock.utils.version.CompatibleSpawners; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.CreatureSpawner; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; @@ -31,7 +26,6 @@ import com.songoda.skyblock.levelling.rework.calculator.Calculator; import com.songoda.skyblock.levelling.rework.calculator.CalculatorRegistry; import com.songoda.skyblock.levelling.rework.calculator.impl.EpicSpawnerCalculator; import com.songoda.skyblock.levelling.rework.calculator.impl.UltimateStackerCalculator; -import com.songoda.skyblock.levelling.rework.calculator.impl.WildStackerCalculator; import com.songoda.skyblock.message.MessageManager; import com.songoda.skyblock.stackable.StackableManager; @@ -152,7 +146,6 @@ public final class IslandLevelManager { if (pm.isPluginEnabled("EpicSpawners")) CalculatorRegistry.registerCalculator(new EpicSpawnerCalculator(), spawner); if (pm.isPluginEnabled("UltimateStacker")) CalculatorRegistry.registerCalculator(new UltimateStackerCalculator(), spawner); - if (pm.isPluginEnabled("WildStacker")) CalculatorRegistry.registerCalculator(new WildStackerCalculator(), spawner); } private static final AmountMaterialPair EMPTY = new AmountMaterialPair(null, 0); diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/impl/WildStackerCalculator.java b/src/main/java/com/songoda/skyblock/levelling/rework/calculator/impl/WildStackerCalculator.java deleted file mode 100644 index f8c06501..00000000 --- a/src/main/java/com/songoda/skyblock/levelling/rework/calculator/impl/WildStackerCalculator.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.songoda.skyblock.levelling.rework.calculator.impl; - -import org.bukkit.block.CreatureSpawner; - -import com.bgsoftware.wildstacker.api.WildStackerAPI; -import com.bgsoftware.wildstacker.api.objects.StackedSpawner; -import com.songoda.skyblock.levelling.rework.calculator.SpawnerCalculator; - -public class WildStackerCalculator implements SpawnerCalculator { - - @Override - public long getSpawnerAmount(CreatureSpawner spawner) { - final StackedSpawner stacked = WildStackerAPI.getStackedSpawner(spawner); - return stacked == null ? 0 : stacked.getStackAmount(); - } - -} diff --git a/src/main/java/com/songoda/skyblock/listeners/WildStacker.java b/src/main/java/com/songoda/skyblock/listeners/WildStacker.java deleted file mode 100644 index 35522a60..00000000 --- a/src/main/java/com/songoda/skyblock/listeners/WildStacker.java +++ /dev/null @@ -1,236 +0,0 @@ -package com.songoda.skyblock.listeners; - -import com.bgsoftware.wildstacker.api.events.*; -import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.config.FileManager; -import com.songoda.skyblock.island.Island; -import com.songoda.skyblock.island.IslandLevel; -import com.songoda.skyblock.island.IslandManager; - -import com.songoda.skyblock.utils.version.CompatibleSpawners; -import com.songoda.skyblock.utils.version.NMSUtil; -import com.songoda.skyblock.world.WorldManager; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.entity.EntityType; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.io.File; - -public class WildStacker implements Listener { - - private final SkyBlock skyblock; - - public WildStacker(SkyBlock skyblock) { - this.skyblock = skyblock; - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onBarrelPlace(BarrelPlaceEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - - Location location = event.getBarrel().getLocation(); - if (!worldManager.isIslandWorld(location.getWorld())) return; - - Island island = islandManager.getIslandAtLocation(location); - - Material material = event.getBarrel().getType(); - - if (NMSUtil.getVersionNumber() > 12 && material.name().startsWith("LEGACY_")) { - material = Material.matchMaterial(material.name().replace("LEGACY_", "")); - } - - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Block.Level.Enable")) { - CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(material); - - if (materials != null) { - IslandLevel level = island.getLevel(); - - long materialAmount = 0; - if (level.hasMaterial(materials.name())) { - materialAmount = level.getMaterialAmount(materials.name()); - } - - level.setMaterialAmount(materials.name(), materialAmount + event.getBarrel().getStackAmount() - 1); // -1 because the Interact handler will always add +1 - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onBarrelStack(BarrelStackEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - - Location location = event.getBarrel().getLocation(); - if (!worldManager.isIslandWorld(location.getWorld())) return; - - Island island = islandManager.getIslandAtLocation(location); - - Material material = event.getBarrel().getType(); - - if (NMSUtil.getVersionNumber() > 12 && material.name().startsWith("LEGACY_")) { - material = Material.matchMaterial(material.name().replace("LEGACY_", "")); - } - - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Block.Level.Enable")) { - CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(material); - - if (materials != null) { - IslandLevel level = island.getLevel(); - - long materialAmount = 0; - if (level.hasMaterial(materials.name())) { - materialAmount = level.getMaterialAmount(materials.name()); - } - - level.setMaterialAmount(materials.name(), materialAmount + event.getTarget().getStackAmount() - 1); // -1 because the Interact handler will always add +1 - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onBarrelUnstack(BarrelUnstackEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - - Location location = event.getBarrel().getLocation(); - if (!worldManager.isIslandWorld(location.getWorld())) return; - - Island island = islandManager.getIslandAtLocation(location); - - Material material = event.getBarrel().getType(); - - if (NMSUtil.getVersionNumber() > 12 && material.name().startsWith("LEGACY_")) { - material = Material.matchMaterial(material.name().replace("LEGACY_", "")); - } - - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Block.Level.Enable")) { - CompatibleMaterial materials = CompatibleMaterial.getBlockMaterial(material); - - if (materials != null) { - IslandLevel level = island.getLevel(); - - if (level.hasMaterial(materials.name())) { - long materialAmount = level.getMaterialAmount(materials.name()); - - if (materialAmount - event.getAmount() <= 0) { - level.removeMaterial(materials.name()); - } else { - level.setMaterialAmount(materials.name(), materialAmount - event.getAmount()); - } - } - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onSpawnerPlace(SpawnerPlaceEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - - Location location = event.getSpawner().getLocation(); - if (!worldManager.isIslandWorld(location.getWorld())) return; - - Island island = islandManager.getIslandAtLocation(location); - - EntityType spawnerType = event.getSpawner().getSpawnedType(); - - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Block.Level.Enable")) { - CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType); - - if (materials != null) { - IslandLevel level = island.getLevel(); - - long materialAmount = 0; - if (level.hasMaterial(materials.name())) { - materialAmount = level.getMaterialAmount(materials.name()); - } - - level.setMaterialAmount(materials.name(), materialAmount + event.getSpawner().getStackAmount()); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onSpawnerStack(SpawnerStackEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - - Location location = event.getSpawner().getLocation(); - if (!worldManager.isIslandWorld(location.getWorld())) return; - - Island island = islandManager.getIslandAtLocation(location); - - EntityType spawnerType = event.getSpawner().getSpawnedType(); - - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Block.Level.Enable")) { - CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType); - - if (materials != null) { - IslandLevel level = island.getLevel(); - - long materialAmount = 0; - if (level.hasMaterial(materials.name())) { - materialAmount = level.getMaterialAmount(materials.name()); - } - - level.setMaterialAmount(materials.name(), materialAmount + event.getTarget().getStackAmount()); - } - } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onSpawnerUnstack(SpawnerUnstackEvent event) { - IslandManager islandManager = skyblock.getIslandManager(); - WorldManager worldManager = skyblock.getWorldManager(); - - Location location = event.getSpawner().getLocation(); - if (!worldManager.isIslandWorld(location.getWorld())) return; - - Island island = islandManager.getIslandAtLocation(location); - - EntityType spawnerType = event.getSpawner().getSpawnedType(); - - FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")); - FileConfiguration configLoad = config.getFileConfiguration(); - - if (configLoad.getBoolean("Island.Block.Level.Enable")) { - CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType); - - if (materials != null) { - IslandLevel level = island.getLevel(); - - if (level.hasMaterial(materials.name())) { - long materialAmount = level.getMaterialAmount(materials.name()); - - if (materialAmount - event.getAmount() <= 0) { - level.removeMaterial(materials.name()); - } else { - level.setMaterialAmount(materials.name(), materialAmount - event.getAmount()); - } - } - } - } - } - -} diff --git a/src/main/java/com/songoda/skyblock/menus/Bank.java b/src/main/java/com/songoda/skyblock/menus/Bank.java index 330209d5..36ea737f 100644 --- a/src/main/java/com/songoda/skyblock/menus/Bank.java +++ b/src/main/java/com/songoda/skyblock/menus/Bank.java @@ -146,7 +146,7 @@ public class Bank { } public void open(Player player) { - Island island = null; + Island island; island = islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java index 8873695a..48bd289b 100644 --- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java +++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java @@ -229,18 +229,34 @@ public class PlayerData { this.viewer = viewer; } + public void deleteTransactions() { + Config config = getConfig(); + FileConfiguration configLoad = config.getFileConfiguration(); + configLoad.set("Bank.Transactions",null); + configLoad.set("Bank.Transactions.Size",0); + try { + configLoad.save(config.getFile()); + } catch (IOException e) { + e.printStackTrace(); + } + } + public void save() { transactions = BankManager.getInstance().getTransactionList(getPlayer()); Config config = getConfig(); FileConfiguration configLoad = config.getFileConfiguration(); configLoad.set("Statistics.Island.Playtime", getPlaytime()); - configLoad.set("Bank.Transactions.Size",transactions.size()); - for (int i = 0;i]' Short02: - Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [Player] []' + Message: '&bSkyBlock &8| &cError&8: &eInvalid: /island admin bank [] [Player]' NullIsland: Message: '&bSkyBlock &8| &cError&8: &eYou are not on an island, please specify a Player or move to an island. Or maybe you are on nullisland?' ByConsole: @@ -160,7 +160,7 @@ Command: Balance: Message: ' %player% have %bal%.' Info: - Message: '&bSkyBlock &8| &cError&8: /island admin bank [Player] []' + Message: '&bSkyBlock &8| &cError&8: /island admin bank [] [Player]' SuccesWithdraw: Message: 'Succesfully removed %ammount% from %player%''s island' SuccesDeposit: