diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
deleted file mode 100644
index a5497da3..00000000
--- a/.gitlab-ci.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-stages:
- - build
-
-variables:
- name: "FabledSkyblock"
- path: "/builds/$CI_PROJECT_PATH"
- version: "2.1.1"
-
-build:
- stage: build
- image: maven:3.5.3-jdk-8
- script:
- - find $path/ -type f -name "*.xml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- - find $path/ -type f -name "*.yml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- - mvn clean package
- - find $path/ -depth -path '*original*' -delete
- - mv $path/target/*.jar $path/
- artifacts:
- name: $name-$version
- paths:
- - "$path/*.jar"
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index c02f0ac5..b2f1d8de 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -3,8 +3,9 @@
4.0.0
com.songoda
skyblock
- maven-version-number
+ 2.1.1
+ clean install
true
@@ -13,6 +14,28 @@
FabledSkyblock-${project.version}
+
+ com.google.code.maven-replacer-plugin
+ replacer
+ 1.5.3
+
+
+ prepare-package
+
+ replace
+
+
+
+
+ ${project.build.directory}/classes/plugin.yml
+
+
+ maven-version-number
+ ${project.version}
+
+
+
+
maven-compiler-plugin
3.8.0
diff --git a/pom.xml b/pom.xml
index c81db186..a34ee6ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,8 +5,9 @@
4.0.0
com.songoda
skyblock
- maven-version-number
+ 2.1.2
+ clean install
FabledSkyblock-${project.version}
@@ -15,6 +16,28 @@
+
+ com.google.code.maven-replacer-plugin
+ replacer
+ 1.5.3
+
+
+ prepare-package
+
+ replace
+
+
+
+
+ ${project.build.directory}/classes/plugin.yml
+
+
+ maven-version-number
+ ${project.version}
+
+
+
+
maven-compiler-plugin
3.8.0
@@ -23,18 +46,46 @@
1.8
+
+ org.apache.maven.plugins
maven-shade-plugin
- 3.2.1
+ 3.1.0
+ shaded
package
shade
+
+ false
+ false
+ true
+
+
+ com.songoda:SongodaCore
+
+
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+
+ com.songoda.core
+ ${project.groupId}.skyblock.core
+
+
+
-
@@ -76,8 +127,26 @@
org.spigotmc
- spigot-api
- 1.15.1-R0.1-SNAPSHOT
+ spigot
+ 1.15
+ provided
+
+
+ com.github.MilkBowl
+ VaultAPI
+ 1.7
+ provided
+
+
+ com.github.OmerBenGera
+ WildStackerAPI
+ b15
+ provided
+
+
+ com.songoda
+ ultimatestacker
+ 1.3.1
provided
@@ -97,18 +166,6 @@
2.9.2
provided
-
- com.github.MilkBowl
- VaultAPI
- 1.7
- provided
-
-
- net.tnemc
- Reserve
- 0.1.3.0
- provided
-
me.robin
leaderheads
@@ -127,52 +184,16 @@
1.4.2
provided
-
- com.songoda
- ultimatestacker
- 1.3.1
- provided
-
-
- com.github.OmerBenGera
- WildStackerAPI
- b15
- provided
-
com.sk89q
worldedit
7.0.0
provided
-
- com.mojang
- authlib
- 1.5.3
- provided
-
-
- org.json
- json
- 20190722
- compile
-
com.songoda
- songodaupdater
- 1
- compile
-
-
- org.apache.commons
- commons-lang3
- 3.0
- compile
-
-
- commons-io
- commons-io
- 2.5
+ SongodaCore
+ LATEST
compile
diff --git a/skyblock.iml b/skyblock.iml
new file mode 100644
index 00000000..cf679a34
--- /dev/null
+++ b/skyblock.iml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java
index 8e985680..67316dfd 100644
--- a/src/main/java/com/songoda/skyblock/SkyBlock.java
+++ b/src/main/java/com/songoda/skyblock/SkyBlock.java
@@ -1,15 +1,10 @@
package com.songoda.skyblock;
-import java.io.File;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.event.HandlerList;
-import org.bukkit.generator.ChunkGenerator;
-import org.bukkit.plugin.PluginManager;
-import org.bukkit.plugin.java.JavaPlugin;
-
+import com.songoda.core.SongodaCore;
+import com.songoda.core.SongodaPlugin;
+import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.configuration.Config;
+import com.songoda.core.hooks.EconomyManager;
import com.songoda.skyblock.api.SkyBlockAPI;
import com.songoda.skyblock.ban.BanManager;
import com.songoda.skyblock.biome.BiomeManager;
@@ -18,7 +13,6 @@ import com.songoda.skyblock.command.commands.SkyBlockCommand;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.confirmation.ConfirmationTask;
import com.songoda.skyblock.cooldown.CooldownManager;
-import com.songoda.skyblock.economy.EconomyManager;
import com.songoda.skyblock.generator.GeneratorManager;
import com.songoda.skyblock.hologram.HologramManager;
import com.songoda.skyblock.invite.InviteManager;
@@ -26,27 +20,7 @@ import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.leaderboard.LeaderboardManager;
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
import com.songoda.skyblock.limit.LimitationInstanceHandler;
-import com.songoda.skyblock.listeners.Block;
-import com.songoda.skyblock.listeners.Bucket;
-import com.songoda.skyblock.listeners.Chat;
-import com.songoda.skyblock.listeners.Death;
-import com.songoda.skyblock.listeners.Entity;
-import com.songoda.skyblock.listeners.EpicSpawners;
-import com.songoda.skyblock.listeners.Food;
-import com.songoda.skyblock.listeners.Grow;
-import com.songoda.skyblock.listeners.Interact;
-import com.songoda.skyblock.listeners.Inventory;
-import com.songoda.skyblock.listeners.Item;
-import com.songoda.skyblock.listeners.Join;
-import com.songoda.skyblock.listeners.Move;
-import com.songoda.skyblock.listeners.Portal;
-import com.songoda.skyblock.listeners.Projectile;
-import com.songoda.skyblock.listeners.Quit;
-import com.songoda.skyblock.listeners.Respawn;
-import com.songoda.skyblock.listeners.Spawner;
-import com.songoda.skyblock.listeners.Teleport;
-import com.songoda.skyblock.listeners.UltimateStacker;
-import com.songoda.skyblock.listeners.WildStacker;
+import com.songoda.skyblock.listeners.*;
import com.songoda.skyblock.localization.LocalizationManager;
import com.songoda.skyblock.menus.Rollback;
import com.songoda.skyblock.menus.admin.Creator;
@@ -62,17 +36,23 @@ import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.structure.StructureManager;
import com.songoda.skyblock.upgrade.UpgradeManager;
import com.songoda.skyblock.usercache.UserCacheManager;
-import com.songoda.skyblock.utils.Metrics;
import com.songoda.skyblock.visit.VisitManager;
import com.songoda.skyblock.visit.VisitTask;
import com.songoda.skyblock.world.WorldManager;
import com.songoda.skyblock.world.generator.VoidGenerator;
-import com.songoda.update.Plugin;
-import com.songoda.update.SongodaUpdate;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.event.HandlerList;
+import org.bukkit.generator.ChunkGenerator;
+import org.bukkit.plugin.PluginManager;
-public class SkyBlock extends JavaPlugin {
+import java.io.File;
+import java.util.List;
- private static SkyBlock instance;
+public class SkyBlock extends SongodaPlugin {
+
+ private static SkyBlock INSTANCE;
private FileManager fileManager;
private WorldManager worldManager;
@@ -95,30 +75,31 @@ public class SkyBlock extends JavaPlugin {
private LeaderboardManager leaderboardManager;
private PlaceholderManager placeholderManager;
private MessageManager messageManager;
- private EconomyManager economyManager;
private HologramManager hologramManager;
private LimitationInstanceHandler limitationHandler;
private LocalizationManager localizationManager;
public static SkyBlock getInstance() {
- return instance;
+ return INSTANCE;
}
@Override
- public void onEnable() {
- ConsoleCommandSender console = Bukkit.getConsoleSender();
- console.sendMessage(formatText("&a============================="));
- console.sendMessage(formatText("&7FabledSkyBlock " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
- console.sendMessage(formatText("&7Action: &aEnabling&7..."));
- console.sendMessage(formatText("&a============================="));
+ public void onPluginLoad() {
+ INSTANCE = this;
+ }
- instance = this;
+ @Override
+ public void onPluginEnable() {
+ // Run Songoda Updater
+ SongodaCore.registerPlugin(this, 17, CompatibleMaterial.GRASS_BLOCK);
+
+ // Load Economy
+ EconomyManager.load();
fileManager = new FileManager(this);
localizationManager = new LocalizationManager();
worldManager = new WorldManager(this);
userCacheManager = new UserCacheManager(this);
- economyManager = new EconomyManager();
visitManager = new VisitManager(this);
banManager = new BanManager(this);
islandManager = new IslandManager(this);
@@ -181,7 +162,8 @@ public class SkyBlock extends JavaPlugin {
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);
+ if (pluginManager.isPluginEnabled("UltimateStacker"))
+ pluginManager.registerEvents(new UltimateStacker(this), this);
pluginManager.registerEvents(new Rollback(), this);
pluginManager.registerEvents(new Levelling(), this);
@@ -190,18 +172,11 @@ public class SkyBlock extends JavaPlugin {
this.getCommand("skyblock").setExecutor(new SkyBlockCommand());
- // bStats Metrics
- new Metrics(this);
-
- // Songoda Updater
- Plugin plugin = new Plugin(this, 17);
- SongodaUpdate.load(plugin);
-
- SkyBlockAPI.setImplementation(instance);
+ SkyBlockAPI.setImplementation(INSTANCE);
}
@Override
- public void onDisable() {
+ public void onPluginDisable() {
ConsoleCommandSender console = Bukkit.getConsoleSender();
console.sendMessage(formatText("&a============================="));
console.sendMessage(formatText("&7FabledSkyBlock " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
@@ -239,6 +214,16 @@ public class SkyBlock extends JavaPlugin {
HandlerList.unregisterAll(this);
}
+ @Override
+ public void onConfigReload() {
+
+ }
+
+ @Override
+ public List getExtraConfig() {
+ return null;
+ }
+
private String formatText(String string) {
return ChatColor.translateAlternateColorCodes('&', string);
}
@@ -331,10 +316,6 @@ public class SkyBlock extends JavaPlugin {
return messageManager;
}
- public EconomyManager getEconomyManager() {
- return economyManager;
- }
-
public HologramManager getHologramManager() {
return hologramManager;
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/StructureCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/StructureCommand.java
index f0ae346f..25ef4c90 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/StructureCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/StructureCommand.java
@@ -1,14 +1,21 @@
package com.songoda.skyblock.command.commands.admin;
+import com.google.gson.Gson;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.ChatComponent;
+import com.songoda.skyblock.utils.Compression;
+import com.songoda.skyblock.utils.structure.Storage;
+import com.songoda.skyblock.utils.structure.Structure;
import com.songoda.skyblock.utils.structure.StructureUtil;
import com.songoda.skyblock.utils.version.Sounds;
import com.songoda.skyblock.utils.world.LocationUtil;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@@ -19,7 +26,6 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-import java.io.File;
import java.util.logging.Level;
public class StructureCommand extends SubCommand {
@@ -82,6 +88,22 @@ public class StructureCommand extends SubCommand {
ChatColor.translateAlternateColorCodes('&', configLoad.getString(
"Command.Island.Admin.Structure.Save.Info.Message")))
.create())).getTextComponent());
+ player.spigot()
+ .sendMessage(
+ new ChatComponent(
+ prefix.replace("%info",
+ ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ "Command.Island.Admin.Structure.Convert.Info.Message")))
+ + "/island admin structure convert"
+ + suffix.replace("%info", ChatColor.translateAlternateColorCodes(
+ '&',
+ configLoad.getString(
+ "Command.Island.Admin.Structure.Save.Convert.Message"))),
+ false, null, null,
+ new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(
+ ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ "Command.Island.Admin.Structure.Convert.Info.Message")))
+ .create())).getTextComponent());
} else {
messageManager.sendMessage(player, helpLines);
}
@@ -176,6 +198,49 @@ public class StructureCommand extends SubCommand {
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
}
+ } else if (args[0].equalsIgnoreCase("convert")) {
+ if (args.length == 2) {
+ File structureFile = new File(new File(skyblock.getDataFolder().toString() + "/structures"), args[1]);
+ if (!structureFile.exists()) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.Admin.Structure.Convert.Invalid.Message")
+ .replace("%name", args[1]));
+ soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
+ return;
+ }
+ byte[] content = new byte[(int) structureFile.length()];
+ try {
+ FileInputStream fileInputStream = new FileInputStream(structureFile);
+ fileInputStream.read(content);
+ fileInputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ FileOutputStream fileOutputStream = new FileOutputStream(structureFile, false);
+ fileOutputStream.write(Base64.getEncoder().encode(Compression.decompress(content).getBytes()));
+ fileOutputStream.flush();
+ fileOutputStream.close();
+ } catch (IOException e) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.Admin.Structure.Convert.Converted.Failed.Message")
+ .replace("%name", args[1]));
+ soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
+ e.printStackTrace();
+ }
+
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.Admin.Structure.Convert.Converted.Successful.Message")
+ .replace("%name", args[1]));
+ soundManager.playSound(player, Sounds.VILLAGER_YES.bukkitSound(), 1.0F, 1.0F);
+
+ } else {
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.Admin.Structure.Convert.Invalid.Message"));
+ soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
+ }
+
return;
}
@@ -206,6 +271,7 @@ public class StructureCommand extends SubCommand {
@Override
public String[] getArguments() {
- return new String[]{"tool", "save"};
+ return new String[]{"tool", "save", "convert"};
}
+
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java
index 1ef57c86..b4e078c3 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/BankCommand.java
@@ -1,9 +1,10 @@
package com.songoda.skyblock.command.commands.island;
+import com.songoda.core.hooks.EconomyManager;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
-import com.songoda.skyblock.economy.EconomyManager;
+import com.songoda.skyblock.utils.VaultPermissions;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
@@ -22,7 +23,6 @@ public class BankCommand extends SubCommand {
@Override
public void onCommandByPlayer(Player player, String[] args) {
MessageManager messageManager = skyblock.getMessageManager();
- EconomyManager economyManager = skyblock.getEconomyManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
@@ -100,12 +100,12 @@ public class BankCommand extends SubCommand {
return;
}
- if (!economyManager.hasBalance(player, amt)) {
+ if (!EconomyManager.hasBalance(player, amt)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
}
- economyManager.withdraw(player, amt);
+ EconomyManager.withdrawBalance(player, amt);
island.addToBank(amt);
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Deposit.Message").replace(
"%amount%", NumberUtil.formatNumberByDecimal(amt)));
@@ -149,7 +149,7 @@ public class BankCommand extends SubCommand {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Short2.Message"));
return;
}
- economyManager.deposit(player, amt);
+ EconomyManager.deposit(player, amt);
island.removeFromBank(amt);
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Withdraw.Message").replace(
"%amount%", NumberUtil.formatNumberByDecimal(amt)));
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java
index 0ec12f61..0c8e159c 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/ConfirmCommand.java
@@ -1,11 +1,12 @@
package com.songoda.skyblock.command.commands.island;
+import com.songoda.core.hooks.EconomyManager;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.confirmation.Confirmation;
import com.songoda.skyblock.cooldown.CooldownType;
-import com.songoda.skyblock.economy.EconomyManager;
+import com.songoda.skyblock.utils.VaultPermissions;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
@@ -35,7 +36,6 @@ public class ConfirmCommand extends SubCommand {
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
StructureManager structureManager = skyblock.getStructureManager();
MessageManager messageManager = skyblock.getMessageManager();
- EconomyManager economyManager = skyblock.getEconomyManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
@@ -127,15 +127,15 @@ public class ConfirmCommand extends SubCommand {
return;
}
- if (economyManager.isEconomy() && island.getStructure() != null
+ if (EconomyManager.isEnabled() && island.getStructure() != null
&& !island.getStructure().isEmpty()
&& structureManager.containsStructure(island.getStructure())) {
Structure structure = structureManager.getStructure(island.getStructure());
double deletionCost = structure.getDeletionCost();
if (deletionCost != 0.0D) {
- if (economyManager.hasBalance(player, deletionCost)) {
- economyManager.withdraw(player, deletionCost);
+ if (EconomyManager.hasBalance(player, deletionCost)) {
+ EconomyManager.withdrawBalance(player, deletionCost);
} else {
messageManager.sendMessage(player,
configLoad.getString(
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java
index 14899945..ed45705e 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/UnlockCommand.java
@@ -1,9 +1,10 @@
package com.songoda.skyblock.command.commands.island;
+import com.songoda.core.hooks.EconomyManager;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
-import com.songoda.skyblock.economy.EconomyManager;
+import com.songoda.skyblock.utils.VaultPermissions;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandWorld;
@@ -23,7 +24,6 @@ public class UnlockCommand extends SubCommand {
@Override
public void onCommandByPlayer(Player player, String[] args) {
MessageManager messageManager = skyblock.getMessageManager();
- EconomyManager economyManager = skyblock.getEconomyManager();
IslandManager islandManager = skyblock.getIslandManager();
SoundManager soundManager = skyblock.getSoundManager();
FileManager fileManager = skyblock.getFileManager();
@@ -69,7 +69,7 @@ public class UnlockCommand extends SubCommand {
double price = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"))
.getFileConfiguration().getDouble("Island.World." + islandWorld.name() + ".UnlockPrice");
- if (!economyManager.hasBalance(player, price)) {
+ if (!EconomyManager.hasBalance(player, price)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Money.Message").replace(
"%cost%", NumberUtil.formatNumberByDecimal(price)));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
@@ -77,7 +77,7 @@ public class UnlockCommand extends SubCommand {
}
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
- economyManager.withdraw(player, price);
+ EconomyManager.withdrawBalance(player, price);
islandManager.unlockIslandWorld(island, islandWorld);
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java
index b3b0ec65..2713e6e8 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java
@@ -1,5 +1,6 @@
package com.songoda.skyblock.command.commands.island;
+import com.songoda.core.hooks.EconomyManager;
import com.songoda.skyblock.command.SubCommand;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.menus.Upgrade;
@@ -27,7 +28,7 @@ public class UpgradeCommand extends SubCommand {
configLoad.getString("Command.Island.Upgrade.Owner.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
- if (!skyblock.getEconomyManager().isEconomy()) {
+ if (!EconomyManager.isEnabled()) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Upgrade.Disabled.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
return;
diff --git a/src/main/java/com/songoda/skyblock/economy/EconomyManager.java b/src/main/java/com/songoda/skyblock/economy/EconomyManager.java
deleted file mode 100644
index cfa9443e..00000000
--- a/src/main/java/com/songoda/skyblock/economy/EconomyManager.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package com.songoda.skyblock.economy;
-
-import java.math.BigDecimal;
-
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.RegisteredServiceProvider;
-
-import com.songoda.skyblock.api.event.player.PlayerWithdrawMoneyEvent;
-
-import net.milkbowl.vault.economy.Economy;
-import net.milkbowl.vault.permission.Permission;
-import net.tnemc.core.Reserve;
-import net.tnemc.core.economy.EconomyAPI;
-
-public class EconomyManager {
-
- // Vault
- private Economy vaultEconomy = null;
- private Permission vaultPermission = null;
-
- // Reserve
- private EconomyAPI reserveEconomy = null;
- // private PermissionsAPI reservePermission = null;
-
- public EconomyManager() {
- setup();
- }
-
- public void setup() {
- if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) {
- RegisteredServiceProvider economyRsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
-
- if (economyRsp != null) this.vaultEconomy = economyRsp.getProvider();
-
- RegisteredServiceProvider permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
- if (permissionRsp != null) this.vaultPermission = permissionRsp.getProvider();
- } else if (Bukkit.getServer().getPluginManager().getPlugin("Reserve") != null) {
- if (Reserve.instance().economyProvided()) this.reserveEconomy = Reserve.instance().economy();
-
- // if (Reserve.instance().permissionsProvided())
- // this.reservePermission = Reserve.instance().permissions();
- }
- }
-
- public double getBalance(Player player) {
- if (this.vaultEconomy != null) return this.vaultEconomy.getBalance(player);
-
- if (this.reserveEconomy != null) return this.reserveEconomy.getHoldings(player.getUniqueId()).doubleValue();
-
- return 0;
- }
-
- public boolean hasBalance(Player player, double money) {
- return this.getBalance(player) >= money;
- }
-
- public void withdraw(Player player, double money) {
- if (this.vaultEconomy != null) this.vaultEconomy.withdrawPlayer(player, money);
- else if (this.reserveEconomy != null) this.reserveEconomy.removeHoldings(player.getUniqueId(), new BigDecimal(money));
-
- Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
- }
-
- public void deposit(Player player, double money) {
- if (this.vaultEconomy != null) this.vaultEconomy.depositPlayer(player, money);
- else if (this.reserveEconomy != null) this.reserveEconomy.addHoldings(player.getUniqueId(), new BigDecimal(money));
-
- Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
- }
-
- public boolean hasPermission(String world, OfflinePlayer offlinePlayer, String perm) {
- if (this.vaultPermission != null) return this.vaultPermission.playerHas(world, offlinePlayer, perm);
-
- // if (this.reservePermission != null) {
- // // TODO
- // }
-
- return false;
- }
-
- public boolean isEconomy() {
- return this.vaultEconomy != null || this.reserveEconomy != null;
- }
-
- public boolean isPermission() {
- return this.vaultPermission != null/* || this.reservePermission != null */;
- }
-}
diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java
index c3a357ed..6d918782 100644
--- a/src/main/java/com/songoda/skyblock/island/IslandManager.java
+++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java
@@ -1,38 +1,8 @@
package com.songoda.skyblock.island;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.ChunkSnapshot;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.World;
-import org.bukkit.block.Biome;
-import org.bukkit.block.Block;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.IllegalPluginAccessException;
-
import com.google.common.base.Preconditions;
import com.songoda.skyblock.SkyBlock;
-import com.songoda.skyblock.api.event.island.IslandCreateEvent;
-import com.songoda.skyblock.api.event.island.IslandDeleteEvent;
-import com.songoda.skyblock.api.event.island.IslandLoadEvent;
-import com.songoda.skyblock.api.event.island.IslandOwnershipTransferEvent;
-import com.songoda.skyblock.api.event.island.IslandUnloadEvent;
+import com.songoda.skyblock.api.event.island.*;
import com.songoda.skyblock.ban.BanManager;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
@@ -64,6 +34,18 @@ import com.songoda.skyblock.utils.world.WorldBorder;
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
import com.songoda.skyblock.visit.VisitManager;
import com.songoda.skyblock.world.WorldManager;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+import org.bukkit.*;
+import org.bukkit.block.Biome;
+import org.bukkit.block.Block;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.IllegalPluginAccessException;
public class IslandManager {
@@ -203,25 +185,24 @@ public class IslandManager {
if (!banManager.hasIsland(island.getOwnerUUID())) banManager.createIsland(island.getOwnerUUID());
- Bukkit.getServer().getScheduler().runTaskAsynchronously(skyblock, () -> {
- Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
+ if (PlayerUtil.getNumberFromPermission(player, "fabledskyblock.size", false, 0) > 0 || player.hasPermission("fabledskyblock.*")) {
+ Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml"));
+ FileConfiguration configLoad = config.getFileConfiguration();
- int minimumSize = configLoad.getInt("Island.Size.Minimum");
- int maximumSize = configLoad.getInt("Island.Size.Maximum");
+ int minimumSize = configLoad.getInt("Island.Size.Minimum");
+ int maximumSize = configLoad.getInt("Island.Size.Maximum");
- if (minimumSize < 0 || minimumSize > 1000) {
- minimumSize = 50;
- }
+ if (minimumSize < 0 || minimumSize > 1000) {
+ minimumSize = 50;
+ }
- if (maximumSize < 0 || maximumSize > 1000) {
- maximumSize = 100;
- }
+ if (maximumSize < 0 || maximumSize > 1000) {
+ maximumSize = 100;
+ }
- for (int i = maximumSize; i > minimumSize; i--) {
- if (player.hasPermission("fabledskyblock.size." + i) || player.hasPermission("fabledskyblock.*")) {
+ for (int i = maximumSize; i > minimumSize; i--) {
island.setSize(i);
- break;
}
}
});
diff --git a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java
index 2cda71d8..aadfa975 100644
--- a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java
+++ b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java
@@ -1,22 +1,19 @@
package com.songoda.skyblock.leaderboard;
import com.songoda.skyblock.SkyBlock;
-import com.songoda.skyblock.economy.EconomyManager;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.leaderboard.leaderheads.TopBank;
import com.songoda.skyblock.leaderboard.leaderheads.TopLevel;
import com.songoda.skyblock.leaderboard.leaderheads.TopVotes;
+import com.songoda.skyblock.utils.VaultPermissions;
import com.songoda.skyblock.visit.Visit;
import com.songoda.skyblock.visit.VisitManager;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
+import org.bukkit.OfflinePlayer;
import java.io.File;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
public class LeaderboardManager {
@@ -35,7 +32,6 @@ public class LeaderboardManager {
}
public void resetLeaderboard() {
- EconomyManager economyManager = skyblock.getEconomyManager();
VisitManager visitManager = skyblock.getVisitManager();
WorldManager worldManager = skyblock.getWorldManager();
@@ -50,8 +46,8 @@ public class LeaderboardManager {
boolean enableExemptions = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
.getBoolean("Island.Leaderboard.Exemptions.Enable");
- for (UUID ownerUUID : visitManager.getIslands().keySet()) {
- if (enableExemptions && economyManager.hasPermission(worldManager.getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(ownerUUID), "fabledskyblock.top.exempt"))
+ for (UUID ownerUUID : new LinkedHashSet<>(visitManager.getIslands().keySet())) {
+ if (enableExemptions && VaultPermissions.hasPermission(worldManager.getWorld(IslandWorld.Normal).getName(), Bukkit.getOfflinePlayer(ownerUUID), "fabledskyblock.top.exempt"))
continue;
Visit visit = visitManager.getIslands().get(ownerUUID);
@@ -82,36 +78,36 @@ public class LeaderboardManager {
}
}
- public int getPlayerIslandLeaderboardPosition(Player player, Leaderboard.Type type) {
+ public int getPlayerIslandLeaderboardPosition(OfflinePlayer offlinePlayer, Leaderboard.Type type) {
VisitManager visitManager = skyblock.getVisitManager();
visitManager.loadIslands();
List leaderboardPlayers = new ArrayList<>(visitManager.getIslands().size());
switch (type) {
- case Level:
- for (UUID ownerUUID : visitManager.getIslands().keySet()) {
- Visit visit = visitManager.getIslands().get(ownerUUID);
- leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
- }
- break;
- case Bank:
- for (UUID ownerUUID : visitManager.getIslands().keySet()) {
- Visit visit = visitManager.getIslands().get(ownerUUID);
- leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, (long) visit.getBankBalance()));
- }
- case Votes:
- for (UUID ownerUUID : visitManager.getIslands().keySet()) {
- Visit visit = visitManager.getIslands().get(ownerUUID);
- leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size()));
- }
- break;
+ case Level:
+ for (UUID ownerUUID : visitManager.getIslands().keySet()) {
+ Visit visit = visitManager.getIslands().get(ownerUUID);
+ leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getLevel().getLevel()));
+ }
+ break;
+ case Bank:
+ for (UUID ownerUUID : visitManager.getIslands().keySet()) {
+ Visit visit = visitManager.getIslands().get(ownerUUID);
+ leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, (long) visit.getBankBalance()));
+ }
+ case Votes:
+ for (UUID ownerUUID : visitManager.getIslands().keySet()) {
+ Visit visit = visitManager.getIslands().get(ownerUUID);
+ leaderboardPlayers.add(new LeaderboardPlayer(ownerUUID, visit.getVoters().size()));
+ }
+ break;
}
leaderboardPlayers.sort(Comparator.comparingLong(LeaderboardPlayer::getValue).reversed());
for (int i = 0; i < leaderboardPlayers.size(); i++) {
- if (leaderboardPlayers.get(i).getUUID().equals(player.getUniqueId())) {
+ if (leaderboardPlayers.get(i).getUUID().equals(offlinePlayer.getUniqueId())) {
return i + 1;
}
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java
index 3458ce02..cd5e2e8b 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Interact.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java
@@ -47,6 +47,9 @@ import com.songoda.skyblock.utils.version.Materials;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.version.Sounds;
import com.songoda.skyblock.world.WorldManager;
+import org.bukkit.permissions.Permission;
+import org.bukkit.permissions.PermissionAttachment;
+import org.bukkit.permissions.PermissionAttachmentInfo;
public class Interact implements Listener {
@@ -57,7 +60,7 @@ public class Interact implements Listener {
}
@SuppressWarnings("deprecation")
- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
org.bukkit.block.Block block = event.getClickedBlock();
@@ -83,7 +86,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "DragonEggUse")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -92,7 +96,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Beacon")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -101,7 +106,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -110,7 +116,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Place") || !islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -123,7 +130,8 @@ public class Interact implements Listener {
if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -141,16 +149,19 @@ public class Interact implements Listener {
heldType = Materials.AIR;
}
- if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType && !player.isSneaking() && islandManager.hasPermission(player, block.getLocation(), "Place")
- && (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission")
- || player.hasPermission("fabledskyblock.stackable"))) {
+ if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType && !player.isSneaking() && islandManager
+ .hasPermission(player, block.getLocation(), "Place")
+ && (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission")
+ || player.hasPermission("fabledskyblock.stackable"))) {
if (NMSUtil.getVersionNumber() > 8) {
- if (event.getHand() == EquipmentSlot.OFF_HAND) return;
+ if (event.getHand() == EquipmentSlot.OFF_HAND) {
+ return;
+ }
}
if (levellingManager.isScanning(island)) {
skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
event.setCancelled(true);
return;
}
@@ -162,7 +173,8 @@ public class Interact implements Listener {
if (limits.isBlockLimitExceeded(player, block, limit)) {
Materials material = Materials.getMaterials(block.getType(), block.getData());
- skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
+ skyblock.getMessageManager().sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
@@ -174,33 +186,68 @@ public class Interact implements Listener {
Stackable stackable = stackableManager.getStack(location, blockType);
int itemAmount = event.getItem().getAmount();
- if (stackable == null) {
- stackableManager.addStack(stackable = new Stackable(location, blockType));
- stackable.setSize(itemAmount + 1);
- } else {
- stackable.setSize(stackable.getSize() + itemAmount);
- }
-
- event.setCancelled(true);
- InventoryUtil.takeItem(player, itemAmount);
-
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
- if (!configLoad.getBoolean("Island.Block.Level.Enable")) return;
+ if (configLoad.getBoolean("Island.Stackable.Limit.Enable")) {
+ // Add block to stackable
+ Materials material = Materials.getMaterials(block.getType(), block.getData());
+ int maxStackSize = getStackLimit(player, material);
- Materials materials = Materials.getMaterials(block.getType(), block.getData());
+ if (stackable == null) {
+ stackableManager.addStack(stackable = new Stackable(location, blockType, maxStackSize));
+ stackable.setSize(itemAmount + 1);
+ if(stackable.isMaxSize()){
+ stackable.setSize(stackable.getMaxSize());
+ event.setCancelled(true);
+ return;
+ }
+ } else {
+ stackable.setMaxSize(maxStackSize);
+ stackable.setSize(stackable.getSize() + itemAmount);
+ if(stackable.isMaxSize()){
+ System.out.println(stackable.getMaxSize() + ":" + stackable.getSize());
+ stackable.setSize(stackable.getMaxSize());
+ event.setCancelled(true);
+ return;
+ }
+ }
- if (materials == null) return;
- long materialAmount = 0;
- IslandLevel level = island.getLevel();
+ // Disables interaction
+ event.setCancelled(true);
- if (level.hasMaterial(materials.name())) {
- materialAmount = level.getMaterialAmount(materials.name());
+ } else {
+ if (stackable == null) {
+ stackableManager.addStack(stackable = new Stackable(location, blockType));
+ stackable.setSize(itemAmount + 1);
+ } else {
+ stackable.setSize(stackable.getSize() + itemAmount);
+ }
+
+ event.setCancelled(true);
}
- level.setMaterialAmount(materials.name(), materialAmount + itemAmount);
+ InventoryUtil.takeItem(player, itemAmount);
+
+ if (!configLoad.getBoolean("Island.Block.Level.Enable")) {
+ return;
+ }
+
+ long materialAmmount = 0;
+ IslandLevel level = island.getLevel();
+ Materials material = Materials.getMaterials(block.getType(), block.getData());
+
+ if (material == null) {
+ return;
+ }
+
+ if (level.hasMaterial(material.name())) {
+ materialAmmount = level.getMaterialAmount(material.name());
+ }
+
+ level.setMaterialAmount(material.name(), materialAmmount + itemAmount);
return;
+
}
// Check if the clicked block is outside of the border.
@@ -222,7 +269,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -231,289 +279,302 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Anvil")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
- } else if (block.getType() == Materials.LEGACY_BED_BLOCK.parseMaterial() || block.getType() == Materials.WHITE_BED.parseMaterial() || block.getType() == Materials.ORANGE_BED.parseMaterial()
- || block.getType() == Materials.MAGENTA_BED.parseMaterial() || block.getType() == Materials.LIGHT_BLUE_BED.parseMaterial() || block.getType() == Materials.YELLOW_BED.parseMaterial()
- || block.getType() == Materials.LIME_BED.parseMaterial() || block.getType() == Materials.PINK_BED.parseMaterial() || block.getType() == Materials.GRAY_BED.parseMaterial()
- || block.getType() == Materials.LIGHT_GRAY_BED.parseMaterial() || block.getType() == Materials.CYAN_BED.parseMaterial() || block.getType() == Materials.CYAN_BED.parseMaterial()
- || block.getType() == Materials.PURPLE_BED.parseMaterial() || block.getType() == Materials.BLUE_BED.parseMaterial() || block.getType() == Materials.BROWN_BED.parseMaterial()
- || block.getType() == Materials.GREEN_BED.parseMaterial() || block.getType() == Materials.RED_BED.parseMaterial() || block.getType() == Materials.BLACK_BED.parseMaterial()) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Bed")) {
- event.setCancelled(true);
+ } else if (block.getType() == Materials.LEGACY_BED_BLOCK.parseMaterial() || block.getType() == Materials.WHITE_BED.parseMaterial() || block.getType() == Materials.ORANGE_BED
+ .parseMaterial()
+ || block.getType() == Materials.MAGENTA_BED.parseMaterial() || block.getType() == Materials.LIGHT_BLUE_BED.parseMaterial() || block.getType() == Materials.YELLOW_BED.parseMaterial()
+ || block.getType() == Materials.LIME_BED.parseMaterial() || block.getType() == Materials.PINK_BED.parseMaterial() || block.getType() == Materials.GRAY_BED.parseMaterial()
+ || block.getType() == Materials.LIGHT_GRAY_BED.parseMaterial() || block.getType() == Materials.CYAN_BED.parseMaterial() || block.getType() == Materials.CYAN_BED.parseMaterial()
+ || block.getType() == Materials.PURPLE_BED.parseMaterial() || block.getType() == Materials.BLUE_BED.parseMaterial() || block.getType() == Materials.BROWN_BED.parseMaterial()
+ || block.getType() == Materials.GREEN_BED.parseMaterial() || block.getType() == Materials.RED_BED.parseMaterial() || block.getType() == Materials.BLACK_BED.parseMaterial()) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Bed")) {
+ event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
- return;
+ return;
+ }
+ } else if (block.getType() == Material.BREWING_STAND) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Brewing")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || (NMSUtil.getVersionNumber() > 9 && (block.getType() == Materials.SHULKER_BOX.parseMaterial()
+ || block.getType() == Materials.BLACK_SHULKER_BOX.parseMaterial() || block.getType() == Materials.BLUE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.BROWN_SHULKER_BOX
+ .parseMaterial()
+ || block.getType() == Materials.CYAN_SHULKER_BOX.parseMaterial() || block.getType() == Materials.GRAY_SHULKER_BOX.parseMaterial() || block.getType() == Materials.GREEN_SHULKER_BOX
+ .parseMaterial()
+ || block.getType() == Materials.LIGHT_BLUE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.LIGHT_GRAY_SHULKER_BOX.parseMaterial()
+ || block.getType() == Materials.LIME_SHULKER_BOX.parseMaterial()
+ || block.getType() == Materials.MAGENTA_SHULKER_BOX.parseMaterial() || block.getType() == Materials.ORANGE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.PINK_SHULKER_BOX
+ .parseMaterial()
+ || block.getType() == Materials.PURPLE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.RED_SHULKER_BOX.parseMaterial() || block.getType() == Materials.WHITE_SHULKER_BOX
+ .parseMaterial()
+ || block.getType() == Materials.YELLOW_SHULKER_BOX.parseMaterial()))) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Materials.CRAFTING_TABLE.parseMaterial()) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Workbench")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Material.BIRCH_DOOR || block.getType() == Material.ACACIA_DOOR || block.getType() == Material.DARK_OAK_DOOR || block.getType() == Material.JUNGLE_DOOR
+ || block.getType() == Material.SPRUCE_DOOR || block.getType() == Materials.LEGACY_WOODEN_DOOR.parseMaterial() || block.getType() == Materials.OAK_DOOR.parseMaterial()) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Door")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Materials.ENCHANTING_TABLE.parseMaterial()) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Enchant")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Material.FURNACE || block.getType() == Materials.LEGACY_BURNING_FURNACE.parseMaterial()) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Furnace")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Material.STONE_BUTTON || block.getType() == Materials.OAK_BUTTON.parseMaterial() || block.getType() == Materials.SPRUCE_BUTTON.parseMaterial()
+ || block.getType() == Materials.BIRCH_BUTTON.parseMaterial() || block.getType() == Materials.JUNGLE_BUTTON.parseMaterial() || block.getType() == Materials.ACACIA_BUTTON.parseMaterial()
+ || block.getType() == Materials.DARK_OAK_BUTTON.parseMaterial() || block.getType() == Materials.LEVER.parseMaterial()) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Material.JUKEBOX) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Jukebox")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Materials.OAK_TRAPDOOR.parseMaterial() || block.getType() == Materials.SPRUCE_TRAPDOOR.parseMaterial() || block.getType() == Materials.BIRCH_TRAPDOOR
+ .parseMaterial()
+ || block.getType() == Materials.JUNGLE_TRAPDOOR.parseMaterial() || block.getType() == Materials.ACACIA_TRAPDOOR.parseMaterial() || block.getType() == Materials.DARK_OAK_TRAPDOOR
+ .parseMaterial()
+ || block.getType() == Material.NOTE_BLOCK || block.getType() == Material.HOPPER || block.getType() == Materials.COMPARATOR.parseMaterial()
+ || block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_OFF.parseMaterial() || block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_ON.parseMaterial()
+ || block.getType() == Materials.REPEATER.parseMaterial() || block.getType() == Materials.LEGACY_DIODE_BLOCK_OFF.parseMaterial()
+ || block.getType() == Materials.LEGACY_DIODE_BLOCK_ON.parseMaterial()) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Materials.OAK_FENCE_GATE.parseMaterial() || block.getType() == Material.ACACIA_FENCE_GATE || block.getType() == Material.BIRCH_FENCE_GATE
+ || block.getType() == Material.DARK_OAK_FENCE_GATE || block.getType() == Material.JUNGLE_FENCE_GATE || block.getType() == Material.SPRUCE_FENCE_GATE) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Gate")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Material.DROPPER || block.getType() == Material.DISPENSER) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "DropperDispenser")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Material.TNT) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Materials.LEGACY_CAKE_BLOCK.getPostMaterial()) {
+ if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, block.getLocation(), "Cake")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if (block.getType() == Material.HOPPER) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Hopper")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+
+ return;
+ }
+ } else if ((player.getGameMode() == GameMode.SURVIVAL) && (block.getType() == Material.OBSIDIAN) && (event.getItem() != null) && (event.getItem().getType() != Material.AIR)
+ && (event.getItem().getType() == Material.BUCKET)) {
+ if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable")
+ && islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
+ int NMSVersion = NMSUtil.getVersionNumber();
+ boolean isInventoryFull = false;
+
+ if (NMSVersion > 8) {
+ isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 5, 1, Material.BUCKET);
+ } else {
+ isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 0, 1, Material.BUCKET);
+ }
+
+ soundManager.playSound(block.getLocation(), Sounds.FIZZ.bukkitSound(), 1.0F, 1.0F);
+
+ InventoryUtil.removeItem(player.getInventory(), 1, false, Material.BUCKET);
+ block.setType(Material.AIR);
+
+ if (isInventoryFull) {
+ player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(Material.LAVA_BUCKET));
+ } else {
+ if (NMSVersion > 8) {
+ isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 5, 1, Material.LAVA_BUCKET);
+ } else {
+ isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 0, 1, Material.LAVA_BUCKET);
}
- } else
- if (block.getType() == Material.BREWING_STAND) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Brewing")) {
- event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ if (isInventoryFull) {
+ player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(Material.LAVA_BUCKET));
+ } else {
+ player.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET));
+ }
+ }
+ event.setCancelled(true);
+
+ return;
+ }
+ } else if (block.getType() == Materials.END_PORTAL_FRAME.parseMaterial()) {
+ if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
+ && islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
+
+ if (NMSUtil.getVersionNumber() > 8 && event.getHand() == EquipmentSlot.OFF_HAND) {
return;
}
- } else if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || (NMSUtil.getVersionNumber() > 9 && (block.getType() == Materials.SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.BLACK_SHULKER_BOX.parseMaterial() || block.getType() == Materials.BLUE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.BROWN_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.CYAN_SHULKER_BOX.parseMaterial() || block.getType() == Materials.GRAY_SHULKER_BOX.parseMaterial() || block.getType() == Materials.GREEN_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.LIGHT_BLUE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.LIGHT_GRAY_SHULKER_BOX.parseMaterial() || block.getType() == Materials.LIME_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.MAGENTA_SHULKER_BOX.parseMaterial() || block.getType() == Materials.ORANGE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.PINK_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.PURPLE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.RED_SHULKER_BOX.parseMaterial() || block.getType() == Materials.WHITE_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.YELLOW_SHULKER_BOX.parseMaterial()))) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
- event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
-
- return;
- }
- } else
- if (block.getType() == Materials.CRAFTING_TABLE.parseMaterial()) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Workbench")) {
+ if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
+ if (com.songoda.epicanchors.EpicAnchors.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
event.setCancelled(true);
-
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
-
return;
}
- } else if (block.getType() == Material.BIRCH_DOOR || block.getType() == Material.ACACIA_DOOR || block.getType() == Material.DARK_OAK_DOOR || block.getType() == Material.JUNGLE_DOOR
- || block.getType() == Material.SPRUCE_DOOR || block.getType() == Materials.LEGACY_WOODEN_DOOR.parseMaterial() || block.getType() == Materials.OAK_DOOR.parseMaterial()) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Door")) {
- event.setCancelled(true);
+ }
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ ItemStack is = event.getPlayer().getItemInHand();
+ boolean hasEye = ((block.getData() >> 2) & 1) == 1;
- return;
- }
- } else
- if (block.getType() == Materials.ENCHANTING_TABLE.parseMaterial()) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Enchant")) {
- event.setCancelled(true);
+ if (is == null || is.getType() == Material.AIR) {
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ int size = 1;
- return;
+ if (stackableManager != null && stackableManager.isStacked(block.getLocation())) {
+ Stackable stackable = stackableManager.getStack(block.getLocation(), Materials.END_PORTAL_FRAME);
+ stackable.takeOne();
+
+ if (stackable.getSize() <= 1) {
+ stackableManager.removeStack(stackable);
}
- } else if (block.getType() == Material.FURNACE || block.getType() == Materials.LEGACY_BURNING_FURNACE.parseMaterial()) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Furnace")) {
- event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ size = stackable.getSize();
+ } else {
+ block.setType(Material.AIR);
+ }
- return;
- }
- } else if (block.getType() == Material.STONE_BUTTON || block.getType() == Materials.OAK_BUTTON.parseMaterial() || block.getType() == Materials.SPRUCE_BUTTON.parseMaterial()
- || block.getType() == Materials.BIRCH_BUTTON.parseMaterial() || block.getType() == Materials.JUNGLE_BUTTON.parseMaterial() || block.getType() == Materials.ACACIA_BUTTON.parseMaterial()
- || block.getType() == Materials.DARK_OAK_BUTTON.parseMaterial() || block.getType() == Materials.LEVER.parseMaterial()) {
- if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) {
- event.setCancelled(true);
+ player.getInventory().addItem(new ItemStack(Materials.END_PORTAL_FRAME.parseMaterial(), 1));
+ if (hasEye && size == 1) {
+ player.getInventory().addItem(new ItemStack(Materials.ENDER_EYE.parseMaterial(), 1));
+ }
+ player.updateInventory();
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
+ FileConfiguration configLoad = config.getFileConfiguration();
- return;
- }
- } else
- if (block.getType() == Material.JUKEBOX) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Jukebox")) {
- event.setCancelled(true);
+ if (configLoad.getBoolean("Island.Block.Level.Enable")) {
+ Materials materials = Materials.END_PORTAL_FRAME;
+ IslandLevel level = island.getLevel();
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ if (level.hasMaterial(materials.name())) {
+ long materialAmount = level.getMaterialAmount(materials.name());
- return;
+ if (materialAmount - 1 <= 0) {
+ level.removeMaterial(materials.name());
+ } else {
+ level.setMaterialAmount(materials.name(), materialAmount - 1);
}
- } else if (block.getType() == Materials.OAK_TRAPDOOR.parseMaterial() || block.getType() == Materials.SPRUCE_TRAPDOOR.parseMaterial() || block.getType() == Materials.BIRCH_TRAPDOOR.parseMaterial()
- || block.getType() == Materials.JUNGLE_TRAPDOOR.parseMaterial() || block.getType() == Materials.ACACIA_TRAPDOOR.parseMaterial() || block.getType() == Materials.DARK_OAK_TRAPDOOR.parseMaterial()
- || block.getType() == Material.NOTE_BLOCK || block.getType() == Material.HOPPER || block.getType() == Materials.COMPARATOR.parseMaterial()
- || block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_OFF.parseMaterial() || block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_ON.parseMaterial()
- || block.getType() == Materials.REPEATER.parseMaterial() || block.getType() == Materials.LEGACY_DIODE_BLOCK_OFF.parseMaterial()
- || block.getType() == Materials.LEGACY_DIODE_BLOCK_ON.parseMaterial()) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
- event.setCancelled(true);
+ }
+ }
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 10.0F, 10.0F);
- return;
- }
- } else
- if (block.getType() == Materials.OAK_FENCE_GATE.parseMaterial() || block.getType() == Material.ACACIA_FENCE_GATE || block.getType() == Material.BIRCH_FENCE_GATE
- || block.getType() == Material.DARK_OAK_FENCE_GATE || block.getType() == Material.JUNGLE_FENCE_GATE || block.getType() == Material.SPRUCE_FENCE_GATE) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Gate")) {
- event.setCancelled(true);
-
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
-
- return;
- }
- } else
- if (block.getType() == Material.DROPPER || block.getType() == Material.DISPENSER) {
- if (!islandManager.hasPermission(player, block.getLocation(), "DropperDispenser")) {
- event.setCancelled(true);
-
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
-
- return;
- }
- } else if (block.getType() == Material.TNT) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
- event.setCancelled(true);
-
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
-
- return;
- }
- } else if (block.getType() == Materials.LEGACY_CAKE_BLOCK.getPostMaterial()) {
- if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, block.getLocation(), "Cake")) {
- event.setCancelled(true);
-
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
-
- return;
- }
- } else if (block.getType() == Material.HOPPER) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Hopper")) {
- event.setCancelled(true);
-
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
-
- return;
- }
- } else if ((player.getGameMode() == GameMode.SURVIVAL) && (block.getType() == Material.OBSIDIAN) && (event.getItem() != null) && (event.getItem().getType() != Material.AIR)
- && (event.getItem().getType() == Material.BUCKET)) {
- if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable")
- && islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
- int NMSVersion = NMSUtil.getVersionNumber();
- boolean isInventoryFull = false;
-
- if (NMSVersion > 8) {
- isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 5, 1, Material.BUCKET);
- } else {
- isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 0, 1, Material.BUCKET);
- }
-
- soundManager.playSound(block.getLocation(), Sounds.FIZZ.bukkitSound(), 1.0F, 1.0F);
-
- InventoryUtil.removeItem(player.getInventory(), 1, false, Material.BUCKET);
- block.setType(Material.AIR);
-
- if (isInventoryFull) {
- player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(Material.LAVA_BUCKET));
- } else {
- if (NMSVersion > 8) {
- isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 5, 1, Material.LAVA_BUCKET);
- } else {
- isInventoryFull = InventoryUtil.isInventoryFull(player.getInventory(), 0, 1, Material.LAVA_BUCKET);
- }
-
- if (isInventoryFull) {
- player.getWorld().dropItemNaturally(player.getLocation(), new ItemStack(Material.LAVA_BUCKET));
- } else {
- player.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET));
- }
- }
-
- event.setCancelled(true);
-
- return;
- }
- } else
- if (block.getType() == Materials.END_PORTAL_FRAME.parseMaterial()) {
- if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
- && islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
-
- if (NMSUtil.getVersionNumber() > 8 && event.getHand() == EquipmentSlot.OFF_HAND) return;
-
- if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
- if (com.songoda.epicanchors.EpicAnchors.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
- event.setCancelled(true);
- return;
- }
- }
-
- ItemStack is = event.getPlayer().getItemInHand();
- boolean hasEye = ((block.getData() >> 2) & 1) == 1;
-
- if (is == null || is.getType() == Material.AIR) {
-
- int size = 1;
-
- if (stackableManager != null && stackableManager.isStacked(block.getLocation())) {
- Stackable stackable = stackableManager.getStack(block.getLocation(), Materials.END_PORTAL_FRAME);
- stackable.takeOne();
-
- if (stackable.getSize() <= 1) {
- stackableManager.removeStack(stackable);
- }
-
- size = stackable.getSize();
- } else {
- block.setType(Material.AIR);
- }
-
- player.getInventory().addItem(new ItemStack(Materials.END_PORTAL_FRAME.parseMaterial(), 1));
- if (hasEye && size == 1) player.getInventory().addItem(new ItemStack(Materials.ENDER_EYE.parseMaterial(), 1));
- player.updateInventory();
-
- FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
-
- if (configLoad.getBoolean("Island.Block.Level.Enable")) {
- Materials materials = Materials.END_PORTAL_FRAME;
- IslandLevel level = island.getLevel();
-
- if (level.hasMaterial(materials.name())) {
- long materialAmount = level.getMaterialAmount(materials.name());
-
- if (materialAmount - 1 <= 0) {
- level.removeMaterial(materials.name());
- } else {
- level.setMaterialAmount(materials.name(), materialAmount - 1);
- }
- }
- }
-
- soundManager.playSound(player, Sounds.CHICKEN_EGG_POP.bukkitSound(), 10.0F, 10.0F);
-
- event.setCancelled(true);
- return;
- }
- }
- }
+ event.setCancelled(true);
+ return;
+ }
+ }
+ }
if ((event.getItem() != null) && (event.getItem().getType() != Material.AIR) && !event.isCancelled()) {
if (event.getItem().getType() == Material.BUCKET || event.getItem().getType() == Material.WATER_BUCKET || event.getItem().getType() == Material.LAVA_BUCKET) {
if (!islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
player.updateInventory();
@@ -523,7 +584,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "WaterCollection")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
player.updateInventory();
@@ -533,7 +595,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "SpawnEgg")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
player.updateInventory();
@@ -542,7 +605,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "EntityPlacement")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
player.updateInventory();
@@ -555,7 +619,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Fire")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -566,28 +631,46 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
- } else if (block.getType() == Materials.STONE_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.OAK_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.SPRUCE_PRESSURE_PLATE.parseMaterial()
- || block.getType() == Materials.BIRCH_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.JUNGLE_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.ACACIA_PRESSURE_PLATE.parseMaterial()
- || block.getType() == Materials.DARK_OAK_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.LIGHT_WEIGHTED_PRESSURE_PLATE.parseMaterial()
- || block.getType() == Materials.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {
- if (!islandManager.hasPermission(player, block.getLocation(), "PressurePlate")) {
- event.setCancelled(true);
- }
- } else
- if (block.getType() == Material.TRIPWIRE) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
- event.setCancelled(true);
-
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
- }
+ } else if (block.getType() == Materials.STONE_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.OAK_PRESSURE_PLATE.parseMaterial()
+ || block.getType() == Materials.SPRUCE_PRESSURE_PLATE.parseMaterial()
+ || block.getType() == Materials.BIRCH_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.JUNGLE_PRESSURE_PLATE.parseMaterial()
+ || block.getType() == Materials.ACACIA_PRESSURE_PLATE.parseMaterial()
+ || block.getType() == Materials.DARK_OAK_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.LIGHT_WEIGHTED_PRESSURE_PLATE.parseMaterial()
+ || block.getType() == Materials.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "PressurePlate")) {
+ event.setCancelled(true);
}
+ } else if (block.getType() == Material.TRIPWIRE) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
+ event.setCancelled(true);
+
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ }
+ }
}
}
+ private int getStackLimit(Player player, Materials materials) {
+ String maxSizePermission = "fabledskyblock.stackable." + materials.name().toLowerCase() + ".maxsize.";
+ System.out.println(maxSizePermission);
+
+ for (PermissionAttachmentInfo attachmentInfo : player.getEffectivePermissions()) {
+ if (attachmentInfo.getPermission().startsWith(maxSizePermission)) {
+ String permission = attachmentInfo.getPermission();
+ int i = Integer.parseInt(permission.substring(permission.lastIndexOf(".") + 1));
+ System.out.println(i);
+ return i;
+ }
+ }
+ return 5000;
+ }
+
@EventHandler
public void onPlayerInteractStructure(PlayerInteractEvent event) {
Player player = event.getPlayer();
@@ -600,30 +683,36 @@ public class Interact implements Listener {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
ItemStack structureTool = StructureUtil.getTool();
- if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName().equals(structureTool.getItemMeta().getDisplayName()))) {
- if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*")) {
+ if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName()
+ .equals(structureTool.getItemMeta().getDisplayName()))) {
+ if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player
+ .hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*")) {
event.setCancelled(true);
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(1, event.getClickedBlock().getLocation());
messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message").replace("%position", "1"));
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message")
+ .replace("%position", "1"));
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
}
}
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
ItemStack structureTool = StructureUtil.getTool();
- if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName().equals(structureTool.getItemMeta().getDisplayName()))) {
- if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*")) {
+ if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName()
+ .equals(structureTool.getItemMeta().getDisplayName()))) {
+ if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player
+ .hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*")) {
event.setCancelled(true);
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(2, event.getClickedBlock().getLocation());
messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message").replace("%position", "2"));
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message")
+ .replace("%position", "2"));
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -651,7 +740,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Leash")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -667,7 +757,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, horse.getLocation(), "HorseInventory")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -676,7 +767,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, horse.getLocation(), "MobRiding")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -686,7 +778,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "MobRiding")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -695,13 +788,15 @@ public class Interact implements Listener {
} else if (entity.getType().equals(EntityType.SHEEP)) {
if (!islandManager.hasPermission(player, entity.getLocation(), "EntityPlacement")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else if (entity.getType().equals(EntityType.ITEM_FRAME)) {
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "Storage")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else if (entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
@@ -709,7 +804,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Milking")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -719,7 +815,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Trading")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -728,7 +825,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Storage")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -737,7 +835,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "MinecartBoat")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -746,7 +845,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Hopper")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -754,8 +854,9 @@ public class Interact implements Listener {
}
if (entity.getType() == EntityType.HORSE) {
- if (!(is.getType() == Material.GOLDEN_APPLE || is.getType() == Material.GOLDEN_CARROT || is.getType() == Material.SUGAR || is.getType() == Material.WHEAT || is.getType() == Material.APPLE
- || is.getType() == Material.HAY_BLOCK)) {
+ if (!(is.getType() == Material.GOLDEN_APPLE || is.getType() == Material.GOLDEN_CARROT || is.getType() == Material.SUGAR || is.getType() == Material.WHEAT
+ || is.getType() == Material.APPLE
+ || is.getType() == Material.HAY_BLOCK)) {
return;
}
} else if (entity.getType() == EntityType.SHEEP || entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
@@ -777,14 +878,15 @@ public class Interact implements Listener {
}
}
} else if (entity.getType() == EntityType.WOLF) {
- if (!(is.getType() == Material.BONE || is.getType() == Materials.PORKCHOP.parseMaterial() || is.getType() == Materials.BEEF.parseMaterial() || is.getType() == Materials.CHICKEN.parseMaterial()
- || is.getType() == Material.RABBIT || is.getType() == Material.MUTTON || is.getType() == Material.ROTTEN_FLESH || is.getType() == Materials.COOKED_PORKCHOP.parseMaterial()
- || is.getType() == Material.COOKED_BEEF || is.getType() == Material.COOKED_CHICKEN || is.getType() == Material.COOKED_RABBIT || is.getType() == Material.COOKED_MUTTON)) {
+ if (!(is.getType() == Material.BONE || is.getType() == Materials.PORKCHOP.parseMaterial() || is.getType() == Materials.BEEF.parseMaterial() || is.getType() == Materials.CHICKEN
+ .parseMaterial()
+ || is.getType() == Material.RABBIT || is.getType() == Material.MUTTON || is.getType() == Material.ROTTEN_FLESH || is.getType() == Materials.COOKED_PORKCHOP.parseMaterial()
+ || is.getType() == Material.COOKED_BEEF || is.getType() == Material.COOKED_CHICKEN || is.getType() == Material.COOKED_RABBIT || is.getType() == Material.COOKED_MUTTON)) {
return;
}
} else if (entity.getType() == EntityType.OCELOT) {
if (!(is.getType() == Materials.COD.parseMaterial() || is.getType() == Materials.SALMON.parseMaterial() || is.getType() == Materials.TROPICAL_FISH.parseMaterial()
- || is.getType() == Materials.PUFFERFISH.parseMaterial())) {
+ || is.getType() == Materials.PUFFERFISH.parseMaterial())) {
return;
}
} else if (entity.getType() == EntityType.RABBIT) {
@@ -818,7 +920,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "AnimalBreeding")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -826,28 +929,34 @@ public class Interact implements Listener {
@EventHandler
public void onPlayerDamageVehicle(VehicleDamageEvent event) {
- if (!(event.getAttacker() instanceof Player)) return;
+ if (!(event.getAttacker() instanceof Player)) {
+ return;
+ }
Player player = (Player) event.getAttacker();
if (!skyblock.getIslandManager().hasPermission(player, event.getVehicle().getLocation(), "MobHurting")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager()
+ .sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@EventHandler
public void onPlayerDestroyVehicle(VehicleDestroyEvent event) {
- if (!(event.getAttacker() instanceof Player)) return;
+ if (!(event.getAttacker() instanceof Player)) {
+ return;
+ }
Player player = (Player) event.getAttacker();
if (!skyblock.getIslandManager().hasPermission(player, event.getVehicle().getLocation(), "MobHurting")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager()
+ .sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -864,13 +973,16 @@ public class Interact implements Listener {
Player player = event.getPlayer();
org.bukkit.entity.Entity entity = event.getRightClicked();
- if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld())) return;
+ if (!skyblock.getWorldManager().isIslandWorld(entity.getWorld())) {
+ return;
+ }
if (entity instanceof ArmorStand) {
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "ArmorStandUse")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
diff --git a/src/main/java/com/songoda/skyblock/menus/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/Upgrade.java
index 8fda10de..560e272b 100644
--- a/src/main/java/com/songoda/skyblock/menus/Upgrade.java
+++ b/src/main/java/com/songoda/skyblock/menus/Upgrade.java
@@ -1,10 +1,11 @@
package com.songoda.skyblock.menus;
+import com.songoda.core.hooks.EconomyManager;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.api.event.island.IslandUpgradeEvent;
import com.songoda.skyblock.api.utils.APIUtil;
import com.songoda.skyblock.config.FileManager;
-import com.songoda.skyblock.economy.EconomyManager;
+import com.songoda.skyblock.utils.VaultPermissions;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.message.MessageManager;
@@ -51,7 +52,6 @@ public class Upgrade {
SkyBlock skyblock = SkyBlock.getInstance();
PlayerDataManager playerDataManager = skyblock.getPlayerDataManager();
- EconomyManager economyManager = skyblock.getEconomyManager();
MessageManager messageManager = skyblock.getMessageManager();
UpgradeManager upgradeManager = skyblock.getUpgradeManager();
IslandManager islandManager = skyblock.getIslandManager();
@@ -61,7 +61,7 @@ public class Upgrade {
FileConfiguration configLoad = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"))
.getFileConfiguration();
- if (!economyManager.isEconomy()) {
+ if (!EconomyManager.isEnabled()) {
messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Disabled.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
@@ -72,7 +72,7 @@ public class Upgrade {
Island island = islandManager.getIsland(player);
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
- if (!economyManager.isEconomy()) {
+ if (!EconomyManager.isEnabled()) {
messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Disabled.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
@@ -118,13 +118,13 @@ public class Upgrade {
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) {
com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
messageManager.sendMessage(player,
configLoad.getString("Island.Upgrade.Bought.Message")
.replace("%upgrade", is.getItemMeta().getDisplayName()));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
- economyManager.withdraw(player, upgrade.getCost());
+ EconomyManager.withdrawBalance(player, upgrade.getCost());
island.setUpgrade(player,
com.songoda.skyblock.upgrade.Upgrade.Type.Speed, true);
@@ -173,13 +173,13 @@ public class Upgrade {
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) {
com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
messageManager.sendMessage(player,
configLoad.getString("Island.Upgrade.Bought.Message")
.replace("%upgrade", is.getItemMeta().getDisplayName()));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
- economyManager.withdraw(player, upgrade.getCost());
+ EconomyManager.withdrawBalance(player, upgrade.getCost());
island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Jump,
true);
@@ -223,13 +223,13 @@ public class Upgrade {
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) {
com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
messageManager.sendMessage(player,
configLoad.getString("Island.Upgrade.Bought.Message")
.replace("%upgrade", is.getItemMeta().getDisplayName()));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
- economyManager.withdraw(player, upgrade.getCost());
+ EconomyManager.withdrawBalance(player, upgrade.getCost());
island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Crop,
true);
@@ -274,13 +274,13 @@ public class Upgrade {
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) {
com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
messageManager.sendMessage(player,
configLoad.getString("Island.Upgrade.Bought.Message")
.replace("%upgrade", is.getItemMeta().getDisplayName()));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
- economyManager.withdraw(player, upgrade.getCost());
+ EconomyManager.withdrawBalance(player, upgrade.getCost());
island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Fly,
true);
@@ -326,13 +326,13 @@ public class Upgrade {
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) {
com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
messageManager.sendMessage(player,
configLoad.getString("Island.Upgrade.Bought.Message")
.replace("%upgrade", is.getItemMeta().getDisplayName()));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
- economyManager.withdraw(player, upgrade.getCost());
+ EconomyManager.withdrawBalance(player, upgrade.getCost());
island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Drops,
true);
@@ -370,14 +370,14 @@ public class Upgrade {
.replace("%tier", "" + tier)))) {
if (upgrade.getValue() > island.getSize()
&& upgrade.getValue() != island.getSize()) {
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
messageManager.sendMessage(player,
configLoad.getString("Island.Upgrade.Bought.Message").replace(
"%upgrade", is.getItemMeta().getDisplayName()));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F,
1.0F);
- economyManager.withdraw(player, upgrade.getCost());
+ EconomyManager.withdrawBalance(player, upgrade.getCost());
island.setSize(upgrade.getValue());
islandManager.updateBorder(island);
@@ -431,13 +431,13 @@ public class Upgrade {
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) {
com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
messageManager.sendMessage(player,
configLoad.getString("Island.Upgrade.Bought.Message")
.replace("%upgrade", is.getItemMeta().getDisplayName()));
soundManager.playSound(player, Sounds.LEVEL_UP.bukkitSound(), 1.0F, 1.0F);
- economyManager.withdraw(player, upgrade.getCost());
+ EconomyManager.withdrawBalance(player, upgrade.getCost());
island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner,
true);
@@ -499,7 +499,7 @@ public class Upgrade {
getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Speed))},
null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0);
} else {
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
nInv.addItem(nInv.createItem(potion,
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")),
@@ -550,7 +550,7 @@ public class Upgrade {
getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Jump))},
null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 1);
} else {
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
nInv.addItem(nInv.createItem(potion,
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Jump.Displayname")),
@@ -586,7 +586,7 @@ public class Upgrade {
getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Crop))},
null, null), 3);
} else {
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
nInv.addItem(nInv.createItem(Materials.WHEAT_SEEDS.parseItem(),
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Crop.Displayname")),
@@ -622,7 +622,7 @@ public class Upgrade {
getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Fly))},
null, null), 4);
} else {
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER),
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Fly.Displayname")),
@@ -658,7 +658,7 @@ public class Upgrade {
getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Drops))},
null, null), 5);
} else {
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE),
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Drops.Displayname")),
@@ -703,7 +703,7 @@ public class Upgrade {
new Placeholder("%size", "" + upgrade.getValue())},
null, null), 7);
} else {
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
nInv.addItem(
nInv.createItem(new ItemStack(Material.BEACON),
ChatColor.translateAlternateColorCodes('&',
@@ -754,7 +754,7 @@ public class Upgrade {
getStatus(island, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner))},
null, null), 8);
} else {
- if (economyManager.hasBalance(player, upgrade.getCost())) {
+ if (EconomyManager.hasBalance(player, upgrade.getCost())) {
nInv.addItem(nInv.createItem(Materials.SPAWNER.parseItem(),
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname")),
diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java
index 8e3cc588..7ab1079f 100644
--- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java
+++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java
@@ -63,11 +63,11 @@ public class PlayerDataManager {
Method getProfileMethod = entityPlayer.getClass().getMethod("getProfile");
GameProfile gameProfile = (GameProfile) getProfileMethod.invoke(entityPlayer);
Property property = gameProfile.getProperties().get("textures").iterator().next();
- playerTexture = new String[] { property.getSignature(), property.getValue() };
+ playerTexture = new String[]{property.getSignature(), property.getValue()};
} catch (Exception e) {
- playerTexture = new String[] {
+ playerTexture = new String[]{
"K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVsATJfwsAIZGS+9OZ5T2HB0tWBoxRvZNi73Vr+syRdvTLUWPusVXIg+2fhXmQoaNEtnQvQVGQpjdQP0TkZtYG8PbvRxE6Z75ddq+DVx/65OSNHLWIB/D+Rg4vINh4ukXNYttn9QvauDHh1aW7/IkIb1Bc0tLcQyqxZQ3mdglxJfgIerqnlA++Lt7TxaLdag4y1NhdZyd3OhklF5B0+B9zw/qP8QCzsZU7VzJIcds1+wDWKiMUO7+60OSrIwgE9FPamxOQDFoDvz5BOULQEeNx7iFMB+eBYsapCXpZx0zf1bduppBUbbVC9wVhto/J4tc0iNyUq06/esHUUB5MHzdJ0Y6IZJAD/xIw15OLCUH2ntvs8V9/cy5/n8u3JqPUM2zhUGeQ2p9FubUGk4Q928L56l3omRpKV+5QYTrvF+AxFkuj2hcfGQG3VE2iYZO6omXe7nRPpbJlHkMKhE8Xvd1HP4PKpgivSkHBoZ92QEUAmRzZydJkp8CNomQrZJf+MtPiNsl/Q5RQM+8CQThg3+4uWptUfP5dDFWOgTnMdA0nIODyrjpp+bvIJnsohraIKJ7ZDnj4tIp4ObTNKDFC/8j8JHz4VCrtr45mbnzvB2DcK8EIB3JYT7ElJTHnc5BKMyLy5SKzuw=",
- "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19" };
+ "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19"};
}
configLoad.set("Texture.Signature", playerTexture[0]);
@@ -154,7 +154,8 @@ public class PlayerDataManager {
if (banManager.hasIsland(island.getOwnerUUID()) && fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")
&& banManager.getIsland(island.getOwnerUUID()).isBanned(player.getUniqueId())) {
- if (messageManager != null) messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Island.Message").replace("%player", targetPlayerName));
+ if (messageManager != null)
+ messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Island.Message").replace("%player", targetPlayerName));
} else {
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
PlayerData playerData = getPlayerData(player);
@@ -215,7 +216,8 @@ public class PlayerDataManager {
return;
} else {
- if (messageManager != null) messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName));
+ if (messageManager != null)
+ messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName));
}
}
@@ -242,7 +244,8 @@ public class PlayerDataManager {
if (banManager.hasIsland(visitIslandList) && fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")
&& banManager.getIsland(visitIslandList).isBanned(player.getUniqueId())) {
- if (messageManager != null) messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Island.Message").replace("%player", targetPlayerName));
+ if (messageManager != null)
+ messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Island.Message").replace("%player", targetPlayerName));
} else {
org.bukkit.OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(visitIslandList);
@@ -274,7 +277,8 @@ public class PlayerDataManager {
return;
} else {
islandManager.unloadIsland(island, Bukkit.getServer().getOfflinePlayer(visitIslandList));
- if (messageManager != null) messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName));
+ if (messageManager != null)
+ messageManager.sendMessage(player, configLoad.getString("Island.Visit.Closed.Island.Message").replace("%player", targetPlayerName));
}
}
}
diff --git a/src/main/java/com/songoda/skyblock/stackable/Stackable.java b/src/main/java/com/songoda/skyblock/stackable/Stackable.java
index 3c55c7f7..5821eb4f 100644
--- a/src/main/java/com/songoda/skyblock/stackable/Stackable.java
+++ b/src/main/java/com/songoda/skyblock/stackable/Stackable.java
@@ -27,6 +27,7 @@ public class Stackable {
private Materials material;
private int size = 2;
private ArmorStand display;
+ private int maxSize;
public Stackable(Location location, Materials material) {
this.uuid = UUID.randomUUID();
@@ -37,6 +38,16 @@ public class Stackable {
this.save();
}
+ public Stackable(Location location, Materials material, int maxSize) {
+ this.uuid = UUID.randomUUID();
+ this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
+ this.material = material;
+ this.maxSize = maxSize;
+ this.updateDisplay();
+ SkyBlock.getInstance().getSoundManager().playSound(location, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
+ this.save();
+ }
+
public Stackable(UUID uuid, Location location, Materials material, int size) {
this.uuid = uuid;
this.location = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
@@ -76,6 +87,14 @@ public class Stackable {
this.save();
}
+ public int getMaxSize() {
+ return maxSize;
+ }
+
+ public void setMaxSize(int maxSize) {
+ this.maxSize = maxSize;
+ }
+
public void addOne() {
this.size++;
this.updateDisplay();
@@ -90,6 +109,10 @@ public class Stackable {
this.save();
}
+ public boolean isMaxSize(){
+ return size > maxSize;
+ }
+
private void updateDisplay() {
// The chunk needs to be loaded otherwise the getNearbyEntities() in
// removeDisplay() won't find anything
diff --git a/src/main/java/com/songoda/skyblock/utils/Metrics.java b/src/main/java/com/songoda/skyblock/utils/Metrics.java
deleted file mode 100644
index e317c89f..00000000
--- a/src/main/java/com/songoda/skyblock/utils/Metrics.java
+++ /dev/null
@@ -1,1033 +0,0 @@
-package com.songoda.skyblock.utils;
-
-import org.bukkit.Bukkit;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.plugin.ServicePriority;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.json.JSONArray;
-import org.json.JSONObject;
-
-import javax.net.ssl.HttpsURLConnection;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.UUID;
-import java.util.logging.Level;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * bStats collects some data for plugin authors.
- *
- * Check out https://bStats.org/ to learn more about bStats!
- */
-public class Metrics {
-
- static {
- // Maven's Relocate is clever and changes strings, too. So we have to use this
- // little "trick" ... :D
- final String defaultPackage = new String(new byte[] { 'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's' });
- final String examplePackage = new String(new byte[] { 'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e' });
- // We want to make sure nobody just copy & pastes the example and use the wrong
- // package names
- if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
- throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
- }
- }
-
- // The version of this bStats class
- public static final int B_STATS_VERSION = 1;
-
- // The url to which the data is sent
- private static final String URL = "https://bStats.org/submitData/bukkit";
-
- // Should failed requests be logged?
- private static boolean logFailedRequests;
-
- // The uuid of the server
- private static String serverUUID;
-
- // The plugin
- private final JavaPlugin plugin;
-
- // A list with all custom charts
- private final List charts = new ArrayList<>();
-
- /**
- * Class constructor.
- *
- * @param plugin The plugin which stats should be submitted.
- */
- public Metrics(JavaPlugin plugin) {
- if (plugin == null) {
- throw new IllegalArgumentException("Plugin cannot be null!");
- }
- this.plugin = plugin;
-
- // Get the config file
- File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
- File configFile = new File(bStatsFolder, "config.yml");
- YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
-
- // Check if the config file exists
- if (!config.isSet("serverUuid")) {
-
- // Add default values
- config.addDefault("enabled", true);
- // Every server gets it's unique random id.
- config.addDefault("serverUuid", UUID.randomUUID().toString());
- // Should failed request be logged?
- config.addDefault("logFailedRequests", false);
-
- // Inform the server owners about bStats
- config.options().header("bStats collects some data for plugin authors like how many servers are using their plugins.\n" + "To honor their work, you should not disable it.\n"
- + "This has nearly no effect on the server performance!\n" + "Check out https://bStats.org/ to learn more :)").copyDefaults(true);
- try {
- config.save(configFile);
- } catch (IOException ignored) {
- }
- }
-
- // Load the data
- serverUUID = config.getString("serverUuid");
- logFailedRequests = config.getBoolean("logFailedRequests", false);
- if (config.getBoolean("enabled", true)) {
- boolean found = false;
- // Search for all other bStats Metrics classes to see if we are the first one
- for (Class> service : Bukkit.getServicesManager().getKnownServices()) {
- try {
- service.getField("B_STATS_VERSION"); // Our identifier :)
- found = true; // We aren't the first
- break;
- } catch (NoSuchFieldException ignored) {
- }
- }
- // Register our service
- Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
- if (!found) {
- // We are the first!
- startSubmitting();
- }
- }
- }
-
- /**
- * Adds a custom chart.
- *
- * @param chart The chart to add.
- */
- public void addCustomChart(CustomChart chart) {
- if (chart == null) {
- throw new IllegalArgumentException("Chart cannot be null!");
- }
- charts.add(chart);
- }
-
- /**
- * Starts the Scheduler which submits our data every 30 minutes.
- */
- private void startSubmitting() {
- final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- if (!plugin.isEnabled()) { // Plugin was disabled
- timer.cancel();
- return;
- }
- // Nevertheless we want our code to run in the Bukkit main thread, so we have to
- // use the Bukkit scheduler
- // Don't be afraid! The connection to the bStats server is still async, only the
- // stats collection is sync ;)
- Bukkit.getScheduler().runTask(plugin, new Runnable() {
- @Override
- public void run() {
- submitData();
- }
- });
- }
- }, 1000 * 60 * 5, 1000 * 60 * 30);
- // Submit the data every 30 minutes, first time after 5 minutes to give other
- // plugins enough time to start
- // WARNING: Changing the frequency has no effect but your plugin WILL be
- // blocked/deleted!
- // WARNING: Just don't do it!
- }
-
- /**
- * Gets the plugin specific data. This method is called using Reflection.
- *
- * @return The plugin specific data.
- */
- public JSONObject getPluginData() {
- JSONObject data = new JSONObject();
-
- String pluginName = plugin.getDescription().getName();
- String pluginVersion = plugin.getDescription().getVersion();
-
- data.put("pluginName", pluginName); // Append the name of the plugin
- data.put("pluginVersion", pluginVersion); // Append the version of the plugin
- JSONArray customCharts = new JSONArray();
- for (CustomChart customChart : charts) {
- // Add the data of the custom charts
- JSONObject chart = customChart.getRequestJsonObject();
- if (chart == null) { // If the chart is null, we skip it
- continue;
- }
- customCharts.put(chart);
- }
- data.put("customCharts", customCharts);
-
- return data;
- }
-
- /**
- * Gets the server specific data.
- *
- * @return The server specific data.
- */
- private JSONObject getServerData() {
- // Minecraft specific data
- int playerAmount = Bukkit.getOnlinePlayers().size();
- int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
- String bukkitVersion = org.bukkit.Bukkit.getVersion();
- bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);
-
- // OS/Java specific data
- String javaVersion = System.getProperty("java.version");
- String osName = System.getProperty("os.name");
- String osArch = System.getProperty("os.arch");
- String osVersion = System.getProperty("os.version");
- int coreCount = Runtime.getRuntime().availableProcessors();
-
- JSONObject data = new JSONObject();
-
- data.put("serverUUID", serverUUID);
-
- data.put("playerAmount", playerAmount);
- data.put("onlineMode", onlineMode);
- data.put("bukkitVersion", bukkitVersion);
-
- data.put("javaVersion", javaVersion);
- data.put("osName", osName);
- data.put("osArch", osArch);
- data.put("osVersion", osVersion);
- data.put("coreCount", coreCount);
-
- return data;
- }
-
- /**
- * Collects the data and sends it afterwards.
- */
- private void submitData() {
- final JSONObject data = getServerData();
-
- JSONArray pluginData = new JSONArray();
- // Search for all other bStats Metrics classes to get their plugin data
- for (Class> service : Bukkit.getServicesManager().getKnownServices()) {
- try {
- service.getField("B_STATS_VERSION"); // Our identifier :)
- } catch (NoSuchFieldException ignored) {
- continue; // Continue "searching"
- }
- // Found one!
- try {
- pluginData.put(service.getMethod("getPluginData").invoke(Bukkit.getServicesManager().load(service)));
- } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
- }
- }
-
- data.put("plugins", pluginData);
-
- // Create a new thread for the connection to the bStats server
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- // Send the data
- sendData(data);
- } catch (Exception e) {
- // Something went wrong! :(
- if (logFailedRequests) {
- plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
- }
- }
- }
- }).start();
- }
-
- /**
- * Sends the data to the bStats server.
- *
- * @param data The data to send.
- * @throws Exception If the request failed.
- */
- private static void sendData(JSONObject data) throws Exception {
- if (data == null) {
- throw new IllegalArgumentException("Data cannot be null!");
- }
- if (Bukkit.isPrimaryThread()) {
- throw new IllegalAccessException("This method must not be called from the main thread!");
- }
- HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
-
- // Compress the data to save bandwidth
- byte[] compressedData = compress(data.toString());
-
- // Add headers
- connection.setRequestMethod("POST");
- connection.addRequestProperty("Accept", "application/json");
- connection.addRequestProperty("Connection", "close");
- connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
- connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
- connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
- connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
-
- // Send data
- connection.setDoOutput(true);
- DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
- outputStream.write(compressedData);
- outputStream.flush();
- outputStream.close();
-
- connection.getInputStream().close(); // We don't care about the response - Just send our data :)
- }
-
- /**
- * Gzips the given String.
- *
- * @param str The string to gzip.
- * @return The gzipped String.
- * @throws IOException If the compression failed.
- */
- private static byte[] compress(final String str) throws IOException {
- if (str == null) {
- return null;
- }
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
- gzip.write(str.getBytes("UTF-8"));
- gzip.close();
- return outputStream.toByteArray();
- }
-
- /**
- * Represents a custom chart.
- */
- public static abstract class CustomChart {
-
- // The id of the chart
- protected final String chartId;
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- public CustomChart(String chartId) {
- if (chartId == null || chartId.isEmpty()) {
- throw new IllegalArgumentException("ChartId cannot be null or empty!");
- }
- this.chartId = chartId;
- }
-
- protected JSONObject getRequestJsonObject() {
- JSONObject chart = new JSONObject();
- chart.put("chartId", chartId);
- try {
- JSONObject data = getChartData();
- if (data == null) {
- // If the data is null we don't send the chart.
- return null;
- }
- chart.put("data", data);
- } catch (Throwable t) {
- if (logFailedRequests) {
- Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
- }
- return null;
- }
- return chart;
- }
-
- protected abstract JSONObject getChartData();
-
- }
-
- /**
- * Represents a custom simple pie.
- */
- public static abstract class SimplePie extends CustomChart {
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- public SimplePie(String chartId) {
- super(chartId);
- }
-
- /**
- * Gets the value of the pie.
- *
- * @return The value of the pie.
- */
- public abstract String getValue();
-
- @Override
- protected JSONObject getChartData() {
- JSONObject data = new JSONObject();
- String value = getValue();
- if (value == null || value.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- data.put("value", value);
- return data;
- }
- }
-
- /**
- * Represents a custom advanced pie.
- */
- public static abstract class AdvancedPie extends CustomChart {
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- public AdvancedPie(String chartId) {
- super(chartId);
- }
-
- /**
- * Gets the values of the pie.
- *
- * @param valueMap Just an empty map. The only reason it exists is to make your
- * life easier. You don't have to create a map yourself!
- * @return The values of the pie.
- */
- public abstract HashMap getValues(HashMap valueMap);
-
- @Override
- protected JSONObject getChartData() {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
- HashMap map = getValues(new HashMap());
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- boolean allSkipped = true;
- for (Map.Entry entry : map.entrySet()) {
- if (entry.getValue() == 0) {
- continue; // Skip this invalid
- }
- allSkipped = false;
- values.put(entry.getKey(), entry.getValue());
- }
- if (allSkipped) {
- // Null = skip the chart
- return null;
- }
- data.put("values", values);
- return data;
- }
- }
-
- /**
- * Represents a custom single line chart.
- */
- public static abstract class SingleLineChart extends CustomChart {
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- public SingleLineChart(String chartId) {
- super(chartId);
- }
-
- /**
- * Gets the value of the chart.
- *
- * @return The value of the chart.
- */
- public abstract int getValue();
-
- @Override
- protected JSONObject getChartData() {
- JSONObject data = new JSONObject();
- int value = getValue();
- if (value == 0) {
- // Null = skip the chart
- return null;
- }
- data.put("value", value);
- return data;
- }
-
- }
-
- /**
- * Represents a custom multi line chart.
- */
- public static abstract class MultiLineChart extends CustomChart {
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- public MultiLineChart(String chartId) {
- super(chartId);
- }
-
- /**
- * Gets the values of the chart.
- *
- * @param valueMap Just an empty map. The only reason it exists is to make your
- * life easier. You don't have to create a map yourself!
- * @return The values of the chart.
- */
- public abstract HashMap getValues(HashMap valueMap);
-
- @Override
- protected JSONObject getChartData() {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
- HashMap map = getValues(new HashMap());
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- boolean allSkipped = true;
- for (Map.Entry entry : map.entrySet()) {
- if (entry.getValue() == 0) {
- continue; // Skip this invalid
- }
- allSkipped = false;
- values.put(entry.getKey(), entry.getValue());
- }
- if (allSkipped) {
- // Null = skip the chart
- return null;
- }
- data.put("values", values);
- return data;
- }
-
- }
-
- /**
- * Represents a custom simple bar chart.
- */
- public static abstract class SimpleBarChart extends CustomChart {
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- public SimpleBarChart(String chartId) {
- super(chartId);
- }
-
- /**
- * Gets the value of the chart.
- *
- * @param valueMap Just an empty map. The only reason it exists is to make your
- * life easier. You don't have to create a map yourself!
- * @return The value of the chart.
- */
- public abstract HashMap getValues(HashMap valueMap);
-
- @Override
- protected JSONObject getChartData() {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
- HashMap map = getValues(new HashMap());
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- for (Map.Entry entry : map.entrySet()) {
- JSONArray categoryValues = new JSONArray();
- categoryValues.put(entry.getValue());
- values.put(entry.getKey(), categoryValues);
- }
- data.put("values", values);
- return data;
- }
-
- }
-
- /**
- * Represents a custom advanced bar chart.
- */
- public static abstract class AdvancedBarChart extends CustomChart {
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- public AdvancedBarChart(String chartId) {
- super(chartId);
- }
-
- /**
- * Gets the value of the chart.
- *
- * @param valueMap Just an empty map. The only reason it exists is to make your
- * life easier. You don't have to create a map yourself!
- * @return The value of the chart.
- */
- public abstract HashMap getValues(HashMap valueMap);
-
- @Override
- protected JSONObject getChartData() {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
- HashMap map = getValues(new HashMap());
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- boolean allSkipped = true;
- for (Map.Entry entry : map.entrySet()) {
- if (entry.getValue().length == 0) {
- continue; // Skip this invalid
- }
- allSkipped = false;
- JSONArray categoryValues = new JSONArray();
- for (int categoryValue : entry.getValue()) {
- categoryValues.put(categoryValue);
- }
- values.put(entry.getKey(), categoryValues);
- }
- if (allSkipped) {
- // Null = skip the chart
- return null;
- }
- data.put("values", values);
- return data;
- }
-
- }
-
- /**
- * Represents a custom simple map chart.
- */
- public static abstract class SimpleMapChart extends CustomChart {
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- public SimpleMapChart(String chartId) {
- super(chartId);
- }
-
- /**
- * Gets the value of the chart.
- *
- * @return The value of the chart.
- */
- public abstract Country getValue();
-
- @Override
- protected JSONObject getChartData() {
- JSONObject data = new JSONObject();
- Country value = getValue();
-
- if (value == null) {
- // Null = skip the chart
- return null;
- }
- data.put("value", value.getCountryIsoTag());
- return data;
- }
-
- }
-
- /**
- * Represents a custom advanced map chart.
- */
- public static abstract class AdvancedMapChart extends CustomChart {
-
- /**
- * Class constructor.
- *
- * @param chartId The id of the chart.
- */
- public AdvancedMapChart(String chartId) {
- super(chartId);
- }
-
- /**
- * Gets the value of the chart.
- *
- * @param valueMap Just an empty map. The only reason it exists is to make your
- * life easier. You don't have to create a map yourself!
- * @return The value of the chart.
- */
- public abstract HashMap getValues(HashMap valueMap);
-
- @Override
- protected JSONObject getChartData() {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
- HashMap map = getValues(new HashMap());
- if (map == null || map.isEmpty()) {
- // Null = skip the chart
- return null;
- }
- boolean allSkipped = true;
- for (Map.Entry entry : map.entrySet()) {
- if (entry.getValue() == 0) {
- continue; // Skip this invalid
- }
- allSkipped = false;
- values.put(entry.getKey().getCountryIsoTag(), entry.getValue());
- }
- if (allSkipped) {
- // Null = skip the chart
- return null;
- }
- data.put("values", values);
- return data;
- }
-
- }
-
- /**
- * A enum which is used for custom maps.
- */
- public enum Country {
-
- /**
- * bStats will use the country of the server.
- */
- AUTO_DETECT("AUTO", "Auto Detected"),
-
- ANDORRA("AD", "Andorra"),
- UNITED_ARAB_EMIRATES("AE", "United Arab Emirates"),
- AFGHANISTAN("AF", "Afghanistan"),
- ANTIGUA_AND_BARBUDA("AG", "Antigua and Barbuda"),
- ANGUILLA("AI", "Anguilla"),
- ALBANIA("AL", "Albania"),
- ARMENIA("AM", "Armenia"),
- NETHERLANDS_ANTILLES("AN", "Netherlands Antilles"),
- ANGOLA("AO", "Angola"),
- ANTARCTICA("AQ", "Antarctica"),
- ARGENTINA("AR", "Argentina"),
- AMERICAN_SAMOA("AS", "American Samoa"),
- AUSTRIA("AT", "Austria"),
- AUSTRALIA("AU", "Australia"),
- ARUBA("AW", "Aruba"),
- ALAND_ISLANDS("AX", "�land Islands"),
- AZERBAIJAN("AZ", "Azerbaijan"),
- BOSNIA_AND_HERZEGOVINA("BA", "Bosnia and Herzegovina"),
- BARBADOS("BB", "Barbados"),
- BANGLADESH("BD", "Bangladesh"),
- BELGIUM("BE", "Belgium"),
- BURKINA_FASO("BF", "Burkina Faso"),
- BULGARIA("BG", "Bulgaria"),
- BAHRAIN("BH", "Bahrain"),
- BURUNDI("BI", "Burundi"),
- BENIN("BJ", "Benin"),
- SAINT_BARTHELEMY("BL", "Saint Barth�lemy"),
- BERMUDA("BM", "Bermuda"),
- BRUNEI("BN", "Brunei"),
- BOLIVIA("BO", "Bolivia"),
- BONAIRE_SINT_EUSTATIUS_AND_SABA("BQ", "Bonaire, Sint Eustatius and Saba"),
- BRAZIL("BR", "Brazil"),
- BAHAMAS("BS", "Bahamas"),
- BHUTAN("BT", "Bhutan"),
- BOUVET_ISLAND("BV", "Bouvet Island"),
- BOTSWANA("BW", "Botswana"),
- BELARUS("BY", "Belarus"),
- BELIZE("BZ", "Belize"),
- CANADA("CA", "Canada"),
- COCOS_ISLANDS("CC", "Cocos Islands"),
- THE_DEMOCRATIC_REPUBLIC_OF_CONGO("CD", "The Democratic Republic Of Congo"),
- CENTRAL_AFRICAN_REPUBLIC("CF", "Central African Republic"),
- CONGO("CG", "Congo"),
- SWITZERLAND("CH", "Switzerland"),
- COTE_D_IVOIRE("CI", "C�te d'Ivoire"),
- COOK_ISLANDS("CK", "Cook Islands"),
- CHILE("CL", "Chile"),
- CAMEROON("CM", "Cameroon"),
- CHINA("CN", "China"),
- COLOMBIA("CO", "Colombia"),
- COSTA_RICA("CR", "Costa Rica"),
- CUBA("CU", "Cuba"),
- CAPE_VERDE("CV", "Cape Verde"),
- CURACAO("CW", "Cura�ao"),
- CHRISTMAS_ISLAND("CX", "Christmas Island"),
- CYPRUS("CY", "Cyprus"),
- CZECH_REPUBLIC("CZ", "Czech Republic"),
- GERMANY("DE", "Germany"),
- DJIBOUTI("DJ", "Djibouti"),
- DENMARK("DK", "Denmark"),
- DOMINICA("DM", "Dominica"),
- DOMINICAN_REPUBLIC("DO", "Dominican Republic"),
- ALGERIA("DZ", "Algeria"),
- ECUADOR("EC", "Ecuador"),
- ESTONIA("EE", "Estonia"),
- EGYPT("EG", "Egypt"),
- WESTERN_SAHARA("EH", "Western Sahara"),
- ERITREA("ER", "Eritrea"),
- SPAIN("ES", "Spain"),
- ETHIOPIA("ET", "Ethiopia"),
- FINLAND("FI", "Finland"),
- FIJI("FJ", "Fiji"),
- FALKLAND_ISLANDS("FK", "Falkland Islands"),
- MICRONESIA("FM", "Micronesia"),
- FAROE_ISLANDS("FO", "Faroe Islands"),
- FRANCE("FR", "France"),
- GABON("GA", "Gabon"),
- UNITED_KINGDOM("GB", "United Kingdom"),
- GRENADA("GD", "Grenada"),
- GEORGIA("GE", "Georgia"),
- FRENCH_GUIANA("GF", "French Guiana"),
- GUERNSEY("GG", "Guernsey"),
- GHANA("GH", "Ghana"),
- GIBRALTAR("GI", "Gibraltar"),
- GREENLAND("GL", "Greenland"),
- GAMBIA("GM", "Gambia"),
- GUINEA("GN", "Guinea"),
- GUADELOUPE("GP", "Guadeloupe"),
- EQUATORIAL_GUINEA("GQ", "Equatorial Guinea"),
- GREECE("GR", "Greece"),
- SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS("GS", "South Georgia And The South Sandwich Islands"),
- GUATEMALA("GT", "Guatemala"),
- GUAM("GU", "Guam"),
- GUINEA_BISSAU("GW", "Guinea-Bissau"),
- GUYANA("GY", "Guyana"),
- HONG_KONG("HK", "Hong Kong"),
- HEARD_ISLAND_AND_MCDONALD_ISLANDS("HM", "Heard Island And McDonald Islands"),
- HONDURAS("HN", "Honduras"),
- CROATIA("HR", "Croatia"),
- HAITI("HT", "Haiti"),
- HUNGARY("HU", "Hungary"),
- INDONESIA("ID", "Indonesia"),
- IRELAND("IE", "Ireland"),
- ISRAEL("IL", "Israel"),
- ISLE_OF_MAN("IM", "Isle Of Man"),
- INDIA("IN", "India"),
- BRITISH_INDIAN_OCEAN_TERRITORY("IO", "British Indian Ocean Territory"),
- IRAQ("IQ", "Iraq"),
- IRAN("IR", "Iran"),
- ICELAND("IS", "Iceland"),
- ITALY("IT", "Italy"),
- JERSEY("JE", "Jersey"),
- JAMAICA("JM", "Jamaica"),
- JORDAN("JO", "Jordan"),
- JAPAN("JP", "Japan"),
- KENYA("KE", "Kenya"),
- KYRGYZSTAN("KG", "Kyrgyzstan"),
- CAMBODIA("KH", "Cambodia"),
- KIRIBATI("KI", "Kiribati"),
- COMOROS("KM", "Comoros"),
- SAINT_KITTS_AND_NEVIS("KN", "Saint Kitts And Nevis"),
- NORTH_KOREA("KP", "North Korea"),
- SOUTH_KOREA("KR", "South Korea"),
- KUWAIT("KW", "Kuwait"),
- CAYMAN_ISLANDS("KY", "Cayman Islands"),
- KAZAKHSTAN("KZ", "Kazakhstan"),
- LAOS("LA", "Laos"),
- LEBANON("LB", "Lebanon"),
- SAINT_LUCIA("LC", "Saint Lucia"),
- LIECHTENSTEIN("LI", "Liechtenstein"),
- SRI_LANKA("LK", "Sri Lanka"),
- LIBERIA("LR", "Liberia"),
- LESOTHO("LS", "Lesotho"),
- LITHUANIA("LT", "Lithuania"),
- LUXEMBOURG("LU", "Luxembourg"),
- LATVIA("LV", "Latvia"),
- LIBYA("LY", "Libya"),
- MOROCCO("MA", "Morocco"),
- MONACO("MC", "Monaco"),
- MOLDOVA("MD", "Moldova"),
- MONTENEGRO("ME", "Montenegro"),
- SAINT_MARTIN("MF", "Saint Martin"),
- MADAGASCAR("MG", "Madagascar"),
- MARSHALL_ISLANDS("MH", "Marshall Islands"),
- MACEDONIA("MK", "Macedonia"),
- MALI("ML", "Mali"),
- MYANMAR("MM", "Myanmar"),
- MONGOLIA("MN", "Mongolia"),
- MACAO("MO", "Macao"),
- NORTHERN_MARIANA_ISLANDS("MP", "Northern Mariana Islands"),
- MARTINIQUE("MQ", "Martinique"),
- MAURITANIA("MR", "Mauritania"),
- MONTSERRAT("MS", "Montserrat"),
- MALTA("MT", "Malta"),
- MAURITIUS("MU", "Mauritius"),
- MALDIVES("MV", "Maldives"),
- MALAWI("MW", "Malawi"),
- MEXICO("MX", "Mexico"),
- MALAYSIA("MY", "Malaysia"),
- MOZAMBIQUE("MZ", "Mozambique"),
- NAMIBIA("NA", "Namibia"),
- NEW_CALEDONIA("NC", "New Caledonia"),
- NIGER("NE", "Niger"),
- NORFOLK_ISLAND("NF", "Norfolk Island"),
- NIGERIA("NG", "Nigeria"),
- NICARAGUA("NI", "Nicaragua"),
- NETHERLANDS("NL", "Netherlands"),
- NORWAY("NO", "Norway"),
- NEPAL("NP", "Nepal"),
- NAURU("NR", "Nauru"),
- NIUE("NU", "Niue"),
- NEW_ZEALAND("NZ", "New Zealand"),
- OMAN("OM", "Oman"),
- PANAMA("PA", "Panama"),
- PERU("PE", "Peru"),
- FRENCH_POLYNESIA("PF", "French Polynesia"),
- PAPUA_NEW_GUINEA("PG", "Papua New Guinea"),
- PHILIPPINES("PH", "Philippines"),
- PAKISTAN("PK", "Pakistan"),
- POLAND("PL", "Poland"),
- SAINT_PIERRE_AND_MIQUELON("PM", "Saint Pierre And Miquelon"),
- PITCAIRN("PN", "Pitcairn"),
- PUERTO_RICO("PR", "Puerto Rico"),
- PALESTINE("PS", "Palestine"),
- PORTUGAL("PT", "Portugal"),
- PALAU("PW", "Palau"),
- PARAGUAY("PY", "Paraguay"),
- QATAR("QA", "Qatar"),
- REUNION("RE", "Reunion"),
- ROMANIA("RO", "Romania"),
- SERBIA("RS", "Serbia"),
- RUSSIA("RU", "Russia"),
- RWANDA("RW", "Rwanda"),
- SAUDI_ARABIA("SA", "Saudi Arabia"),
- SOLOMON_ISLANDS("SB", "Solomon Islands"),
- SEYCHELLES("SC", "Seychelles"),
- SUDAN("SD", "Sudan"),
- SWEDEN("SE", "Sweden"),
- SINGAPORE("SG", "Singapore"),
- SAINT_HELENA("SH", "Saint Helena"),
- SLOVENIA("SI", "Slovenia"),
- SVALBARD_AND_JAN_MAYEN("SJ", "Svalbard And Jan Mayen"),
- SLOVAKIA("SK", "Slovakia"),
- SIERRA_LEONE("SL", "Sierra Leone"),
- SAN_MARINO("SM", "San Marino"),
- SENEGAL("SN", "Senegal"),
- SOMALIA("SO", "Somalia"),
- SURINAME("SR", "Suriname"),
- SOUTH_SUDAN("SS", "South Sudan"),
- SAO_TOME_AND_PRINCIPE("ST", "Sao Tome And Principe"),
- EL_SALVADOR("SV", "El Salvador"),
- SINT_MAARTEN_DUTCH_PART("SX", "Sint Maarten (Dutch part)"),
- SYRIA("SY", "Syria"),
- SWAZILAND("SZ", "Swaziland"),
- TURKS_AND_CAICOS_ISLANDS("TC", "Turks And Caicos Islands"),
- CHAD("TD", "Chad"),
- FRENCH_SOUTHERN_TERRITORIES("TF", "French Southern Territories"),
- TOGO("TG", "Togo"),
- THAILAND("TH", "Thailand"),
- TAJIKISTAN("TJ", "Tajikistan"),
- TOKELAU("TK", "Tokelau"),
- TIMOR_LESTE("TL", "Timor-Leste"),
- TURKMENISTAN("TM", "Turkmenistan"),
- TUNISIA("TN", "Tunisia"),
- TONGA("TO", "Tonga"),
- TURKEY("TR", "Turkey"),
- TRINIDAD_AND_TOBAGO("TT", "Trinidad and Tobago"),
- TUVALU("TV", "Tuvalu"),
- TAIWAN("TW", "Taiwan"),
- TANZANIA("TZ", "Tanzania"),
- UKRAINE("UA", "Ukraine"),
- UGANDA("UG", "Uganda"),
- UNITED_STATES_MINOR_OUTLYING_ISLANDS("UM", "United States Minor Outlying Islands"),
- UNITED_STATES("US", "United States"),
- URUGUAY("UY", "Uruguay"),
- UZBEKISTAN("UZ", "Uzbekistan"),
- VATICAN("VA", "Vatican"),
- SAINT_VINCENT_AND_THE_GRENADINES("VC", "Saint Vincent And The Grenadines"),
- VENEZUELA("VE", "Venezuela"),
- BRITISH_VIRGIN_ISLANDS("VG", "British Virgin Islands"),
- U_S__VIRGIN_ISLANDS("VI", "U.S. Virgin Islands"),
- VIETNAM("VN", "Vietnam"),
- VANUATU("VU", "Vanuatu"),
- WALLIS_AND_FUTUNA("WF", "Wallis And Futuna"),
- SAMOA("WS", "Samoa"),
- YEMEN("YE", "Yemen"),
- MAYOTTE("YT", "Mayotte"),
- SOUTH_AFRICA("ZA", "South Africa"),
- ZAMBIA("ZM", "Zambia"),
- ZIMBABWE("ZW", "Zimbabwe");
-
- private String isoTag;
- private String name;
-
- Country(String isoTag, String name) {
- this.isoTag = isoTag;
- this.name = name;
- }
-
- /**
- * Gets the name of the country.
- *
- * @return The name of the country.
- */
- public String getCountryName() {
- return name;
- }
-
- /**
- * Gets the iso tag of the country.
- *
- * @return The iso tag of the country.
- */
- public String getCountryIsoTag() {
- return isoTag;
- }
-
- /**
- * Gets a country by it's iso tag.
- *
- * @param isoTag The iso tag of the county.
- * @return The country with the given iso tag or null
if unknown.
- */
- public static Country byIsoTag(String isoTag) {
- for (Country country : Country.values()) {
- if (country.getCountryIsoTag().equals(isoTag)) {
- return country;
- }
- }
- return null;
- }
-
- /**
- * Gets a country by a locale.
- *
- * @param locale The locale.
- * @return The country from the giben locale or null
if unknown
- * country or if the locale does not contain a country.
- */
- public static Country byLocale(Locale locale) {
- return byIsoTag(locale.getCountry());
- }
-
- }
-
-}
diff --git a/src/main/java/com/songoda/skyblock/utils/StringUtil.java b/src/main/java/com/songoda/skyblock/utils/StringUtil.java
index 6590f449..7f3671a3 100644
--- a/src/main/java/com/songoda/skyblock/utils/StringUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/StringUtil.java
@@ -22,6 +22,17 @@ public final class StringUtil {
return stringBuilder.toString();
}
+ public static String capitalizeWord(String str){
+ String words[]=str.split("\\s");
+ String capitalizeWord="";
+ for(String w:words){
+ String first=w.substring(0,1);
+ String afterfirst=w.substring(1);
+ capitalizeWord+=first.toUpperCase()+afterfirst+" ";
+ }
+ return capitalizeWord.trim();
+ }
+
public static String color(String input) {
return input == null ? null : ChatColor.translateAlternateColorCodes('&', input);
}
diff --git a/src/main/java/com/songoda/skyblock/utils/VaultPermissions.java b/src/main/java/com/songoda/skyblock/utils/VaultPermissions.java
new file mode 100644
index 00000000..53c4ab94
--- /dev/null
+++ b/src/main/java/com/songoda/skyblock/utils/VaultPermissions.java
@@ -0,0 +1,24 @@
+package com.songoda.skyblock.utils;
+
+import net.milkbowl.vault.permission.Permission;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.plugin.RegisteredServiceProvider;
+
+public class VaultPermissions {
+
+ // Vault
+ private static Permission vaultPermission = null;
+
+ static {
+ if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) {
+ RegisteredServiceProvider permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
+ if (permissionRsp != null) vaultPermission = permissionRsp.getProvider();
+ }
+ }
+
+ public static boolean hasPermission(String world, OfflinePlayer offlinePlayer, String perm) {
+ if (vaultPermission != null) return vaultPermission.playerHas(world, offlinePlayer, perm);
+ return false;
+ }
+}
diff --git a/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java b/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java
index a3928653..41d64b6c 100644
--- a/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java
@@ -6,6 +6,7 @@ import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
+import com.songoda.skyblock.utils.Compression;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.utils.world.block.BlockData;
@@ -14,6 +15,8 @@ import com.songoda.skyblock.utils.world.block.BlockUtil;
import com.songoda.skyblock.utils.world.entity.EntityData;
import com.songoda.skyblock.utils.world.entity.EntityUtil;
+import java.io.FileInputStream;
+import java.util.Base64;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -29,7 +32,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.logging.Level;
@@ -103,24 +105,37 @@ public final class StructureUtil {
}
public static Structure loadStructure(File configFile) throws IOException {
- String base64 = getBase64String(configFile);
-
- if (base64 == null) {
- base64 = getBase64String(new File(SkyBlock.getInstance().getDataFolder() + "/" + "structures", "default.structure"));
- SkyBlock.getInstance().getLogger().log(Level.SEVERE, "Unable to load structure '" + configFile.getAbsolutePath() + "' using default instead.");
- }
-
- if (base64 == null) {
- throw new IllegalArgumentException("Couldn't load the default structure file.");
- }
+ byte[] content = new byte[(int) configFile.length()];
+ FileInputStream fileInputStream = new FileInputStream(configFile);
+ fileInputStream.read(content);
+ fileInputStream.close();
Storage storage;
- try {
- storage = new Gson().fromJson(new String(Base64.getDecoder().decode(base64.getBytes(StandardCharsets.UTF_8))), Storage.class);
- } catch (JsonSyntaxException e) {
- e.printStackTrace();
- return null;
+ if (!org.bukkit.craftbukkit.libs.org.apache.commons.codec.binary.Base64.isBase64(content)) {
+ try {
+ storage = new Gson().fromJson(Compression.decompress(content), Storage.class);
+ } catch (JsonSyntaxException e) {
+ e.printStackTrace();
+ return null;
+ }
+ } else {
+ String base64 = getBase64String(configFile);
+
+ if (base64 == null) {
+ base64 = getBase64String(new File(SkyBlock.getInstance().getDataFolder() + "/" + "structures", "default.structure"));
+ SkyBlock.getInstance().getLogger().log(Level.SEVERE, "Unable to load structure '" + configFile.getAbsolutePath() + "' using default instead.");
+ }
+
+ if (base64 == null) {
+ throw new IllegalArgumentException("Couldn't load the default structure file.");
+ }
+ try {
+ storage = new Gson().fromJson(new String(Base64.getDecoder().decode(base64.getBytes(StandardCharsets.UTF_8))), Storage.class);
+ } catch (JsonSyntaxException e) {
+ e.printStackTrace();
+ return null;
+ }
}
return new Structure(storage, configFile.getName());
diff --git a/src/main/java/com/songoda/skyblock/utils/version/SBiome.java b/src/main/java/com/songoda/skyblock/utils/version/SBiome.java
index 9b748ffe..85551e74 100644
--- a/src/main/java/com/songoda/skyblock/utils/version/SBiome.java
+++ b/src/main/java/com/songoda/skyblock/utils/version/SBiome.java
@@ -1,6 +1,6 @@
package com.songoda.skyblock.utils.version;
-import org.apache.commons.lang3.text.WordUtils;
+import com.songoda.skyblock.utils.StringUtil;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack;
@@ -96,7 +96,7 @@ public enum SBiome {
public String getFormattedBiomeName() {
if (!this.isAvailable())
return null;
- return WordUtils.capitalizeFully(this.getBiome().name().replaceAll("_", " "));
+ return StringUtil.capitalizeWord(this.getBiome().name().replaceAll("_", " "));
}
/**
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 740ccf21..a555f17d 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -291,3 +291,5 @@ Island:
Enable: true
# fabledskyblock.stackables
RequirePermission: false
+ Limit:
+ Enable: false
diff --git a/src/main/resources/language.yml b/src/main/resources/language.yml
index 72d3742d..93563d20 100644
--- a/src/main/resources/language.yml
+++ b/src/main/resources/language.yml
@@ -226,6 +226,16 @@ Command:
Message: '&bSkyBlock &8| &cError&8: &eBoth selected positions have to be in the same World.'
Info:
Message: '&f&oCreate Structures for Islands.'
+ Convert:
+ Info:
+ Message: '&f&oConverts old Structure files.'
+ Invalid:
+ Message: '&bSkyBlock &8| &aInfo&8: &eThe Structure with the name ''&d%name&e'' was not found!'
+ Converted:
+ Successful:
+ Message: '&bSkyBlock &8| &aInfo&8: &eThe Structure with the name ''&d%name&e'' has been converted!'
+ Failed:
+ Message: '&bSkyBlock &8| &cError&8: &eAn error occurred when trying to convert the Structure.'
SetSize:
Set:
Message: '&bSkyBlock &8| &aInfo&8: &eYou have set &d%player''s &eIsland size to &d%size&e.'
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 9a4c6596..c50f8a86 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: FabledSkyBlock
main: com.songoda.skyblock.SkyBlock
-version: @version@
+version: maven-version-number
api-version: 1.13
description: A unique SkyBlock plugin
author: Songoda