diff --git a/pom.xml b/pom.xml
index ac1dd1ce..a441a2f9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
com.songoda
skyblock
- 2.3.7
+ 2.3.9
jar
UTF-8
diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java
index 63230c14..d9002ab0 100644
--- a/src/main/java/com/songoda/skyblock/SkyBlock.java
+++ b/src/main/java/com/songoda/skyblock/SkyBlock.java
@@ -52,6 +52,7 @@ import net.coreprotect.CoreProtectAPI;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
+import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.HandlerList;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
@@ -107,6 +108,22 @@ public class SkyBlock extends SongodaPlugin {
return INSTANCE;
}
+ // Add ymlFiles to cache
+ private FileConfiguration biomes;
+ private FileConfiguration challenges;
+ private FileConfiguration config;
+ private FileConfiguration generators;
+ private FileConfiguration language;
+ private FileConfiguration levelling;
+ private FileConfiguration limits;
+ private FileConfiguration menus;
+ private FileConfiguration placeholders;
+ private FileConfiguration rewards;
+ private FileConfiguration scoreboard;
+ private FileConfiguration settings;
+ private FileConfiguration stackables;
+ private FileConfiguration upgrades;
+
@Override
public void onPluginLoad() {
INSTANCE = this;
@@ -143,6 +160,12 @@ public class SkyBlock extends SongodaPlugin {
com.songoda.core.hooks.HologramManager.load(this);
fileManager = new FileManager(this);
+
+ if (!loadConfigs()) {
+ this.getServer().getPluginManager().disablePlugin(this);
+ return;
+ }
+
permissionManager = new PermissionManager(this);
localizationManager = new LocalizationManager();
worldManager = new WorldManager(this);
@@ -163,11 +186,12 @@ public class SkyBlock extends SongodaPlugin {
structureManager = new StructureManager(this);
soundManager = new SoundManager(this);
- if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Generator.Enable")) {
+
+ if (this.config.getBoolean("Island.Generator.Enable")) {
generatorManager = new GeneratorManager(this);
}
- if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.Enable")) {
+ if (this.config.getBoolean("Island.Stackable.Enable")) {
stackableManager = new StackableManager(this);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> stackableManager.loadSavedStackables(), 5L);
}
@@ -184,8 +208,15 @@ public class SkyBlock extends SongodaPlugin {
bankManager = new BankManager(this);
- new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
- new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
+
+ if (this.config.getBoolean("Island.Task.PlaytimeTask")) {
+ new PlaytimeTask(playerDataManager, islandManager).runTaskTimerAsynchronously(this, 0L, 20L);
+ }
+
+ if (this.config.getBoolean("Island.Task.VisitTask")) {
+ new VisitTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
+ }
+
new ConfirmationTask(playerDataManager).runTaskTimerAsynchronously(this, 0L, 20L);
// Start Tasks
@@ -234,7 +265,7 @@ public class SkyBlock extends SongodaPlugin {
this.vaultPermission = getServer().getServicesManager().getRegistration(Permission.class).getProvider();
}
- switch (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getString("Economy.Manager", "Default")) {
+ switch (this.config.getString("Economy.Manager", "Default")) {
case "Vault":
getEconomyManager().setEconomy("Vault");
break;
@@ -244,6 +275,8 @@ public class SkyBlock extends SongodaPlugin {
case "Reserve":
getEconomyManager().setEconomy("Reserve");
break;
+ default:
+ this.getLogger().warning("EconomyManager is default");
}
this.coreProtectAPI = loadCoreProtect();
@@ -253,59 +286,43 @@ public class SkyBlock extends SongodaPlugin {
@Override
public void onPluginDisable() {
- if (this.userCacheManager != null) {
+ if (this.userCacheManager != null)
this.userCacheManager.onDisable();
- }
-
- if (this.scoreboardManager != null) {
+ if (this.scoreboardManager != null)
this.scoreboardManager.disable();
- }
-
- if (this.islandManager != null) {
+ if (this.islandManager != null)
this.islandManager.onDisable();
- }
-
- if (this.visitManager != null) {
+ if (this.visitManager != null)
this.visitManager.onDisable();
- }
-
- if (this.banManager != null) {
+ if (this.banManager != null)
this.banManager.onDisable();
- }
-
- if (this.playerDataManager != null) {
+ if (this.playerDataManager != null)
this.playerDataManager.onDisable();
- }
-
- if (this.cooldownManager != null) {
+ if (this.cooldownManager != null)
this.cooldownManager.onDisable();
- }
-
- if (this.hologramTask != null) {
+ if (this.hologramTask != null)
this.hologramTask.onDisable();
- }
-
- if (this.mobNetherWaterTask != null) {
+ if (this.mobNetherWaterTask != null)
this.mobNetherWaterTask.onDisable();
- }
-
- if (this.fabledChallenge != null) {
+ if (this.fabledChallenge != null)
this.fabledChallenge.onDisable();
- }
HandlerList.unregisterAll(this);
}
+ @Override
+ public void onDataLoad() {
+ }
+
private CoreProtectAPI loadCoreProtect() {
Plugin plugin = getServer().getPluginManager().getPlugin("CoreProtect");
if (plugin != null) { // Check before loading classes
if (plugin instanceof CoreProtect) { // Check that CoreProtect is loaded
CoreProtectAPI CoreProtect = ((CoreProtect) plugin).getAPI();
- if (CoreProtect.isEnabled()) { // Check that the API is enabled
- if (CoreProtect.APIVersion() >= 6) { // Check that a compatible version of the API is loaded
- return CoreProtect;
- }
+ // Check that the API is enabled and Check that a compatible version of the API is loaded
+ if (CoreProtect.isEnabled() && CoreProtect.APIVersion() >= 6) {
+ return CoreProtect;
}
}
}
@@ -314,7 +331,8 @@ public class SkyBlock extends SongodaPlugin {
@Override
public void onConfigReload() {
-
+ if (!loadConfigs()) this.getLogger().warning("Config are not reload !");
+ else this.getLogger().info("Configurations Loaded !");
}
@Override
@@ -322,7 +340,32 @@ public class SkyBlock extends SongodaPlugin {
return null;
}
- private String formatText(String string) {
+
+ private boolean loadConfigs() {
+ try {
+ biomes = this.getFileManager().getConfig(new File(this.getDataFolder(),"biomes.yml")).getFileConfiguration();
+ challenges = this.getFileManager().getConfig(new File(this.getDataFolder(),"challenges.yml")).getFileConfiguration();
+ config = this.getFileManager().getConfig(new File(this.getDataFolder(),"config.yml")).getFileConfiguration();
+ generators = this.getFileManager().getConfig(new File(this.getDataFolder(),"generators.yml")).getFileConfiguration();
+ language = this.getFileManager().getConfig(new File(this.getDataFolder(),"language.yml")).getFileConfiguration();
+ levelling = this.getFileManager().getConfig(new File(this.getDataFolder(),"levelling.yml")).getFileConfiguration();
+ limits = this.getFileManager().getConfig(new File(this.getDataFolder(),"limits.yml")).getFileConfiguration();
+ menus = this.getFileManager().getConfig(new File(this.getDataFolder(),"menus.yml")).getFileConfiguration();
+ placeholders = this.getFileManager().getConfig(new File(this.getDataFolder(),"placeholders.yml")).getFileConfiguration();
+ rewards = this.getFileManager().getConfig(new File(this.getDataFolder(),"rewards.yml")).getFileConfiguration();
+ scoreboard = this.getFileManager().getConfig(new File(this.getDataFolder(),"scoreboard.yml")).getFileConfiguration();
+ settings = this.getFileManager().getConfig(new File(this.getDataFolder(),"settings.yml")).getFileConfiguration();
+ stackables = this.getFileManager().getConfig(new File(this.getDataFolder(),"stackables.yml")).getFileConfiguration();
+ upgrades = this.getFileManager().getConfig(new File(this.getDataFolder(),"upgrades.yml")).getFileConfiguration();
+ return true;
+ }
+ catch (Exception exception) {
+ exception.printStackTrace();
+ return false;
+ }
+ }
+
+ public String formatText(String string) {
return ChatColor.translateAlternateColorCodes('&', string);
}
@@ -478,4 +521,34 @@ public class SkyBlock extends SongodaPlugin {
public EconomyManager getEconomyManager() {
return economyManager;
}
+
+
+ public FileConfiguration getBiomes() { return biomes; }
+
+ public FileConfiguration getChallenges() { return challenges; }
+
+ public FileConfiguration getConfiguration() { return config; }
+
+ public FileConfiguration getGenerators() { return generators; }
+
+ public FileConfiguration getLanguage() { return language; }
+
+ public FileConfiguration getLevelling() { return levelling; }
+
+ public FileConfiguration getLimits() { return limits; }
+
+ public FileConfiguration getMenus() { return menus; }
+
+ public FileConfiguration getPlaceholders() { return placeholders; }
+
+ public FileConfiguration getRewards() { return rewards; }
+
+ public FileConfiguration getSettings() { return settings; }
+
+ public FileConfiguration getStackables() { return stackables; }
+
+ public FileConfiguration getUpgrades() { return upgrades; }
+
+ public FileConfiguration getScoreboard() { return scoreboard; }
+
}
diff --git a/src/main/java/com/songoda/skyblock/api/bank/TransactionLog.java b/src/main/java/com/songoda/skyblock/api/bank/TransactionLog.java
index e2c261fa..6837c2ea 100644
--- a/src/main/java/com/songoda/skyblock/api/bank/TransactionLog.java
+++ b/src/main/java/com/songoda/skyblock/api/bank/TransactionLog.java
@@ -4,6 +4,7 @@ import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.bank.BankManager;
import com.songoda.skyblock.bank.Transaction;
import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
import java.util.List;
import java.util.UUID;
@@ -15,6 +16,8 @@ public class TransactionLog {
}
public List getLogForPlayer(UUID uuid) {
- return getImplementation().getTransactionList(Bukkit.getPlayer(uuid));
+ Player player = Bukkit.getPlayer(uuid);
+ if (player == null) return null;
+ return getImplementation().getTransactionList(player);
}
}
diff --git a/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java
index b6ebdf0a..a4f3b641 100644
--- a/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java
+++ b/src/main/java/com/songoda/skyblock/api/biome/BiomeManager.java
@@ -1,6 +1,7 @@
package com.songoda.skyblock.api.biome;
import com.google.common.base.Preconditions;
+import com.songoda.core.compatibility.CompatibleBiome;
import com.songoda.skyblock.api.island.Island;
import com.songoda.skyblock.island.IslandWorld;
import org.bukkit.block.Biome;
@@ -20,6 +21,6 @@ public class BiomeManager {
Preconditions.checkArgument(island != null, "Cannot set biome to null island");
Preconditions.checkArgument(biome != null, "Cannot set biome to null biome");
- this.biomeManager.setBiome(island.getIsland(), IslandWorld.Normal, biome, null);
+ this.biomeManager.setBiome(island.getIsland(), IslandWorld.Normal, CompatibleBiome.getBiome(biome), null);
}
}
diff --git a/src/main/java/com/songoda/skyblock/api/event/island/IslandUpgradeEvent.java b/src/main/java/com/songoda/skyblock/api/event/island/IslandUpgradeEvent.java
index 0d2e465d..0d2140e6 100644
--- a/src/main/java/com/songoda/skyblock/api/event/island/IslandUpgradeEvent.java
+++ b/src/main/java/com/songoda/skyblock/api/event/island/IslandUpgradeEvent.java
@@ -10,7 +10,7 @@ public class IslandUpgradeEvent extends IslandEvent {
private static final HandlerList HANDLERS = new HandlerList();
private final Player player;
- private IslandUpgrade upgrade;
+ private final IslandUpgrade upgrade;
public IslandUpgradeEvent(Island island, Player player, IslandUpgrade upgrade) {
super(island);
diff --git a/src/main/java/com/songoda/skyblock/api/event/island/IslandWeatherChangeEvent.java b/src/main/java/com/songoda/skyblock/api/event/island/IslandWeatherChangeEvent.java
index 3c116335..a419cbb8 100644
--- a/src/main/java/com/songoda/skyblock/api/event/island/IslandWeatherChangeEvent.java
+++ b/src/main/java/com/songoda/skyblock/api/event/island/IslandWeatherChangeEvent.java
@@ -8,8 +8,8 @@ public class IslandWeatherChangeEvent extends IslandEvent {
private static final HandlerList HANDLERS = new HandlerList();
private final boolean sync;
- private WeatherType weather;
- private int time;
+ private final WeatherType weather;
+ private final int time;
public IslandWeatherChangeEvent(Island island, WeatherType weather, int time, boolean sync) {
super(island);
diff --git a/src/main/java/com/songoda/skyblock/api/event/player/PlayerIslandChatSwitchEvent.java b/src/main/java/com/songoda/skyblock/api/event/player/PlayerIslandChatSwitchEvent.java
index 44040c93..edc03e42 100644
--- a/src/main/java/com/songoda/skyblock/api/event/player/PlayerIslandChatSwitchEvent.java
+++ b/src/main/java/com/songoda/skyblock/api/event/player/PlayerIslandChatSwitchEvent.java
@@ -8,7 +8,7 @@ public class PlayerIslandChatSwitchEvent extends PlayerEvent {
private static final HandlerList HANDLERS = new HandlerList();
- private boolean chat;
+ private final boolean chat;
public PlayerIslandChatSwitchEvent(Player player, Island island, boolean chat) {
super(player, island);
diff --git a/src/main/java/com/songoda/skyblock/api/event/player/PlayerVoteEvent.java b/src/main/java/com/songoda/skyblock/api/event/player/PlayerVoteEvent.java
index 34a983de..f924b990 100644
--- a/src/main/java/com/songoda/skyblock/api/event/player/PlayerVoteEvent.java
+++ b/src/main/java/com/songoda/skyblock/api/event/player/PlayerVoteEvent.java
@@ -9,7 +9,7 @@ public class PlayerVoteEvent extends PlayerEvent implements Cancellable {
private boolean cancelled = false;
- private static HandlerList HANDLERS = new HandlerList();
+ private static final HandlerList HANDLERS = new HandlerList();
public PlayerVoteEvent(Player player, Island island) {
super(player, island);
diff --git a/src/main/java/com/songoda/skyblock/api/event/player/PlayerVoteRemoveEvent.java b/src/main/java/com/songoda/skyblock/api/event/player/PlayerVoteRemoveEvent.java
index ba06c409..b448adc3 100644
--- a/src/main/java/com/songoda/skyblock/api/event/player/PlayerVoteRemoveEvent.java
+++ b/src/main/java/com/songoda/skyblock/api/event/player/PlayerVoteRemoveEvent.java
@@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
public class PlayerVoteRemoveEvent extends PlayerEvent {
- private static HandlerList HANDLERS = new HandlerList();
+ private static final HandlerList HANDLERS = new HandlerList();
public PlayerVoteRemoveEvent(Player player, Island island) {
super(player, island);
diff --git a/src/main/java/com/songoda/skyblock/api/event/player/PlayerWithdrawMoneyEvent.java b/src/main/java/com/songoda/skyblock/api/event/player/PlayerWithdrawMoneyEvent.java
index 1fc13892..a6a93e53 100644
--- a/src/main/java/com/songoda/skyblock/api/event/player/PlayerWithdrawMoneyEvent.java
+++ b/src/main/java/com/songoda/skyblock/api/event/player/PlayerWithdrawMoneyEvent.java
@@ -8,8 +8,8 @@ public class PlayerWithdrawMoneyEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
- private Player player;
- private double money;
+ private final Player player;
+ private final double money;
public PlayerWithdrawMoneyEvent(Player player, double money) {
this.player = player;
diff --git a/src/main/java/com/songoda/skyblock/api/invite/IslandInvitation.java b/src/main/java/com/songoda/skyblock/api/invite/IslandInvitation.java
index bd030c41..ee4522eb 100644
--- a/src/main/java/com/songoda/skyblock/api/invite/IslandInvitation.java
+++ b/src/main/java/com/songoda/skyblock/api/invite/IslandInvitation.java
@@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
public class IslandInvitation {
private final Player invited, inviter;
- private int time;
+ private final int time;
public IslandInvitation(Player invited, Player inviter, int time) {
this.invited = invited;
diff --git a/src/main/java/com/songoda/skyblock/api/island/Island.java b/src/main/java/com/songoda/skyblock/api/island/Island.java
index 86bd6849..99ca4d4d 100644
--- a/src/main/java/com/songoda/skyblock/api/island/Island.java
+++ b/src/main/java/com/songoda/skyblock/api/island/Island.java
@@ -499,9 +499,7 @@ public class Island {
if (!(object instanceof Island))
return false;
Island other = (Island) object;
- if (!other.getIslandUUID().equals(getIslandUUID()))
- return false;
- return true;
- }
+ return other.getIslandUUID().equals(getIslandUUID());
+ }
}
diff --git a/src/main/java/com/songoda/skyblock/api/island/IslandLocation.java b/src/main/java/com/songoda/skyblock/api/island/IslandLocation.java
index 8ba3386f..cf4b4566 100644
--- a/src/main/java/com/songoda/skyblock/api/island/IslandLocation.java
+++ b/src/main/java/com/songoda/skyblock/api/island/IslandLocation.java
@@ -5,9 +5,9 @@ import org.bukkit.World;
public class IslandLocation {
- private IslandEnvironment environment;
- private IslandWorld world;
- private Location location;
+ private final IslandEnvironment environment;
+ private final IslandWorld world;
+ private final Location location;
public IslandLocation(IslandEnvironment environment, IslandWorld world, Location location) {
this.environment = environment;
diff --git a/src/main/java/com/songoda/skyblock/api/structure/StructureManager.java b/src/main/java/com/songoda/skyblock/api/structure/StructureManager.java
index 08a0acd3..d08311df 100644
--- a/src/main/java/com/songoda/skyblock/api/structure/StructureManager.java
+++ b/src/main/java/com/songoda/skyblock/api/structure/StructureManager.java
@@ -29,12 +29,6 @@ public class StructureManager {
* @return A List of Structures for an Island
*/
public List getStructures() {
- List structures = new ArrayList<>();
-
- for (Structure structureList : structureManager.getStructures()) {
- structures.add(structureList);
- }
-
- return structures;
+ return new ArrayList<>(structureManager.getStructures());
}
}
diff --git a/src/main/java/com/songoda/skyblock/ban/Ban.java b/src/main/java/com/songoda/skyblock/ban/Ban.java
index 1aa19075..49a3c766 100644
--- a/src/main/java/com/songoda/skyblock/ban/Ban.java
+++ b/src/main/java/com/songoda/skyblock/ban/Ban.java
@@ -62,15 +62,12 @@ public class Ban {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> Bukkit.getServer().getPluginManager().callEvent(islandBanEvent));
if (!islandBanEvent.isCancelled()) {
- List islandBans = new ArrayList<>();
FileConfiguration configLoad = plugin.getFileManager()
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/ban-data"),
FastUUID.toString(islandOwnerUUID) + ".yml"))
.getFileConfiguration();
- for (String islandBanList : configLoad.getStringList("Bans")) {
- islandBans.add(islandBanList);
- }
+ List islandBans = new ArrayList<>(configLoad.getStringList("Bans"));
islandBans.add(banned.toString());
configLoad.set("Bans", islandBans);
diff --git a/src/main/java/com/songoda/skyblock/ban/BanManager.java b/src/main/java/com/songoda/skyblock/ban/BanManager.java
index 53046e40..d2c8bb04 100644
--- a/src/main/java/com/songoda/skyblock/ban/BanManager.java
+++ b/src/main/java/com/songoda/skyblock/ban/BanManager.java
@@ -21,7 +21,7 @@ import java.util.UUID;
public class BanManager {
private final SkyBlock plugin;
- private Map banStorage = new HashMap<>();
+ private final Map banStorage = new HashMap<>();
public BanManager(SkyBlock plugin) {
this.plugin = plugin;
@@ -40,7 +40,7 @@ public class BanManager {
public void loadIslands() {
FileManager fileManager = plugin.getFileManager();
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (!this.plugin.getConfiguration()
.getBoolean("Island.Visitor.Unload")) {
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
@@ -76,10 +76,8 @@ public class BanManager {
public void removeVisitor(Island island) {
MessageManager messageManager = plugin.getMessageManager();
SoundManager soundManager = plugin.getSoundManager();
- FileManager fileManager = plugin.getFileManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = this.plugin.getLanguage();
for (UUID visitorList : plugin.getIslandManager().getVisitorsAtIsland(island)) {
Player targetPlayer = Bukkit.getServer().getPlayer(visitorList);
diff --git a/src/main/java/com/songoda/skyblock/bank/BankManager.java b/src/main/java/com/songoda/skyblock/bank/BankManager.java
index b4309e51..a2687c18 100644
--- a/src/main/java/com/songoda/skyblock/bank/BankManager.java
+++ b/src/main/java/com/songoda/skyblock/bank/BankManager.java
@@ -20,8 +20,7 @@ public class BankManager {
public BankManager(SkyBlock plugin) {
this.plugin = plugin;
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
- lang = config.getFileConfiguration();
+ lang = this.plugin.getLanguage();
log = new HashMap<>();
loadTransactions();
}
@@ -107,7 +106,7 @@ public class BankManager {
}
// If decimals aren't allowed, check for them
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
int intAmt = (int) amt;
if (intAmt != amt) {
return BankResponse.DECIMALS_NOT_ALLOWED;
@@ -135,7 +134,6 @@ public class BankManager {
public BankResponse withdraw(Player player, Island island, double amt, boolean admin) {
Economy economy = plugin.getEconomyManager().getEconomy();
- FileManager fileManager = plugin.getFileManager();
// Make sure the amount is positive
if (amt <= 0) {
@@ -143,7 +141,7 @@ public class BankManager {
}
// If decimals aren't allowed, check for them
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
int intAmt = (int) amt;
if (intAmt != amt) {
return BankResponse.DECIMALS_NOT_ALLOWED;
diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java
index 7313d840..4a270b1f 100644
--- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java
+++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java
@@ -1,5 +1,6 @@
package com.songoda.skyblock.biome;
+import com.songoda.core.compatibility.CompatibleBiome;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.blockscanner.ChunkLoader;
@@ -21,8 +22,6 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
public class BiomeManager {
-
- final ServerVersion ASYNC_OBFUSCATOR_VERSION = ServerVersion.V1_9;
private final SkyBlock plugin;
private final List updatingIslands;
@@ -32,7 +31,7 @@ public class BiomeManager {
public BiomeManager(SkyBlock plugin) {
this.plugin = plugin;
this.updatingIslands = new ArrayList<>();
- this.language = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration();
+ this.language = SkyBlock.getInstance().getLanguage();
this.runEveryX = language.getInt("Command.Island.Biome.Progress.Display-Every-X-Updates");
}
@@ -48,7 +47,7 @@ public class BiomeManager {
updatingIslands.remove(island);
}
- public void setBiome(Island island, IslandWorld world, Biome biome, CompleteTask task) {
+ public void setBiome(Island island, IslandWorld world, CompatibleBiome biome, CompleteTask task) {
addUpdatingIsland(island);
if (island.getLocation(world, IslandEnvironment.Island) == null) return;
@@ -59,17 +58,13 @@ public class BiomeManager {
ChunkLoader.startChunkLoadingPerChunk(island, world, plugin.isPaperAsync(), (futureChunk) -> {
Chunk chunk = futureChunk.join();
- if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)){ // TODO Should be 1.15 but it works fine there
- setChunkBiome3D(biome, chunk);
- } else {
- try {
- setChunkBiome2D(biome, chunk);
- } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
- e.printStackTrace();
- }
+ try {
+ if (chunk != null)
+ biome.setBiome(chunk);
+ } catch (IllegalAccessException | InvocationTargetException e) {
+ e.printStackTrace();
}
- updateBiomePacket(island, chunk);
-
+
progress.getAndIncrement();
if(language.getBoolean("Command.Island.Biome.Progress.Should-Display-Message") &&
@@ -94,61 +89,6 @@ public class BiomeManager {
}));
}
- private void setChunkBiome2D(Biome biome, Chunk chunk) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
- for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){
- for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){
- World.class.getMethod("setBiome", int.class, int.class, Biome.class).invoke(chunk.getWorld(), x, z, biome);
- }
- }
- }
-
- // Do not use - Too laggy
- private void setChunkBiome3D(Biome biome, Chunk chunk) {
- for(int x = chunk.getX() << 4; x < (chunk.getX()<< 4)+16; x++){
- for(int z = chunk.getZ() << 4; z < (chunk.getZ()<< 4)+16; z++){
- for(int y = 0; y < chunk.getWorld().getMaxHeight(); ++y) {
- chunk.getWorld().setBiome(x, y, z, biome);
- }
- }
- }
- }
-
-
-
- private void updateBiomePacket(Island island, Chunk chunk) {
- Class> packetPlayOutMapChunkClass;
- Class> chunkClass;
-
- packetPlayOutMapChunkClass = NMSUtil.getNMSClass("PacketPlayOutMapChunk");
- chunkClass = NMSUtil.getNMSClass("Chunk");
-
- for (Player player : plugin.getIslandManager().getPlayersAtIsland(island, IslandWorld.Normal)) {
- try {
- if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
- if(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)) {
- NMSUtil.sendPacket(player,
- packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class, boolean.class).newInstance(player
- .getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk),
- 65535, true));
- } else {
- NMSUtil.sendPacket(player,
- packetPlayOutMapChunkClass.getConstructor(chunkClass, int.class).newInstance(player
- .getLocation().getChunk().getClass().getMethod("getHandle").invoke(chunk),
- 65535));
- }
- } else {
- NMSUtil.sendPacket(player,
- packetPlayOutMapChunkClass.getConstructor(chunkClass, boolean.class, int.class)
- .newInstance(player.getLocation().getChunk().getClass().getMethod("getHandle")
- .invoke(chunk), true, 20));
- }
- } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
- | InvocationTargetException | NoSuchMethodException | SecurityException e) {
- e.printStackTrace();
- }
- }
- }
-
public interface CompleteTask {
void onCompleteUpdate();
}
diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java
index 38efd626..c9c08f0f 100644
--- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java
+++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java
@@ -77,7 +77,7 @@ public final class BlockScanner extends BukkitRunnable {
this.completedNum = new AtomicInteger();
this.island = island;
- FileConfiguration config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")).getFileConfiguration();
+ FileConfiguration config = SkyBlock.getInstance().getConfiguration();
int threadCount = 0;
diff --git a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java
index 01316250..760445ec 100644
--- a/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java
+++ b/src/main/java/com/songoda/skyblock/blockscanner/ChunkLoader.java
@@ -38,9 +38,7 @@ public class ChunkLoader extends BukkitRunnable {
boolean chunkForChunk,
ChunkForChunkScannerTask chunkTask,
CompleteTask complete) {
- chunkPerTick = SkyBlock.getInstance().getFileManager()
- .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
- .getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
+ chunkPerTick = SkyBlock.getInstance().getConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
this.completeTask = complete;
this.chunkTask = chunkTask;
@@ -78,9 +76,7 @@ public class ChunkLoader extends BukkitRunnable {
boolean chunkForChunk,
ChunkScannerTask generalTask,
CompleteTask complete) {
- chunkPerTick = SkyBlock.getInstance().getFileManager()
- .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
- .getFileConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
+ chunkPerTick = SkyBlock.getInstance().getConfiguration().getInt("Island.Performance.ChunkPerTick", 25);
this.completeTask = complete;
this.generalTask = generalTask;
diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java
index 527e18ea..41451417 100644
--- a/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java
+++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Challenge.java
@@ -2,11 +2,15 @@ package com.songoda.skyblock.challenge.challenge;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.hooks.economies.Economy;
+import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.bank.BankManager;
+import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import org.bukkit.Bukkit;
import org.bukkit.Material;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -17,9 +21,7 @@ import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
import java.util.regex.Pattern;
public class Challenge {
@@ -117,6 +119,63 @@ public class Challenge {
}
public enum Type {
+
+ CHALLENGE {
+
+ @Override
+ public Object convert(String value) throws IllegalArgumentException {
+ if (value == null || "".equalsIgnoreCase(value)) {
+ throw new IllegalArgumentException("Value is empty or null");
+ }
+ String[] test = value.split("\\.");
+ if (test.length != 6) {
+ throw new IllegalArgumentException("Your config is not good, correct syntax : CHALLENGE:category.[id_category].challenges.[id_challenges].count.[count_times]");
+ }
+ List integerList = new ArrayList();
+
+ Arrays.stream(test).filter(condition -> !condition.equalsIgnoreCase("category") && !condition.equalsIgnoreCase("challenges") && !condition.equalsIgnoreCase("count")).forEachOrdered(condition -> {
+ try {
+ integerList.add(Integer.parseInt(condition));
+ } catch (NumberFormatException ex) {
+ throw new IllegalArgumentException(
+ "\"" + condition + "\" isn't a valid number (value = \"" + value + "\")");
+ }
+ });
+ return integerList;
+ }
+
+ @Override
+ public boolean has(Player p, Object obj){
+ List is = (List) obj;
+ SkyBlock instance = SkyBlock.getInstance();
+ FileManager.Config config = instance.getFileManager().getConfig(new File(new File(instance.getDataFolder(), "challenge-data"), p.getUniqueId().toString() + ".yml"));
+ FileConfiguration fileConfig = config.getFileConfiguration();
+ ConfigurationSection section = fileConfig.getConfigurationSection("challenges");
+ for (String k : (section != null) ? section.getKeys(false) : new HashSet()) {
+ int id = fileConfig.getInt("challenges." + k + ".id");
+ if (is.get(0) == id) {
+ ChallengeCategory cc = SkyBlock.getInstance().getFabledChallenge().getChallengeManager().getChallenge(id);
+ if (cc != null) {
+ ConfigurationSection section2 = fileConfig.getConfigurationSection("challenges." + k + ".challenges");
+ if (section2 != null && !section2.getKeys(false).isEmpty() && section2.getKeys(false).stream().map(d -> "challenges." + k + ".challenges." + d).anyMatch(key -> is.get(1) == fileConfig.getInt(key + ".id") && fileConfig.getInt(key + ".count") >= is.get(2))) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void executeRequire(Player p, Object obj) {
+ // Nothing
+ }
+
+ @Override
+ public void executeReward(Player p, Object obj) {
+ // Nothing
+ }
+ },
ITEM {
// An item
@@ -131,7 +190,7 @@ public class Challenge {
// The id
String id = index == -1 ? value : value.substring(0, index);
// Check if it's a Minecraft item
- Material m = CompatibleMaterial.getMaterial(id).getMaterial();
+ CompatibleMaterial m = CompatibleMaterial.getMaterial(id);
//Material m = Material.matchMaterial(id);
if (m == null)
throw new IllegalArgumentException(
@@ -146,68 +205,58 @@ public class Challenge {
"\"" + strAmount + "\" isn't a correct number (value = \"" + value + "\")");
}
}
- return new ItemStack(m, amount);
+ ItemStack item = m.getItem();
+ item.setAmount(amount);
+ return item;
}
@Override
public boolean has(Player p, Object obj) {
- boolean ignoreLore = SkyBlock.getInstance().getFileManager()
- .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
+ boolean ignoreLore = SkyBlock.getInstance().getConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
if(obj instanceof ItemStack){
// Check if player has specific item in his inventory
ItemStack is = (ItemStack) obj;
if(ignoreLore){
- return p.getInventory().contains(is.getType(), is.getAmount());
+ return p.getInventory().contains(is, is.getAmount());
}
- return p.getInventory().containsAtLeast(new ItemStack(is.getType()), is.getAmount());
+ return p.getInventory().containsAtLeast(is, is.getAmount());
}
return false;
}
- @Override
- public void executeRequire(Player p, Object obj) {
- boolean ignoreLore = SkyBlock.getInstance().getFileManager()
- .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Challenge.IgnoreItemLore", false);
-
- if(obj instanceof ItemStack){
- // Remove specific item in player's inventory
- ItemStack is = (ItemStack) obj;
- int toRemove = is.getAmount();
- for(ItemStack jis : p.getInventory().getContents()) {
- if(jis != null) {
- boolean isItem;
- if(ignoreLore){
- isItem = jis.getType().equals(is.getType());
- } else {
- isItem = jis.isSimilar(is);
- }
-
- if(isItem) {
- if(jis.getAmount() <= toRemove) {
- toRemove -= jis.getAmount();
- p.getInventory().removeItem(jis);
- } else {
- jis.setAmount(jis.getAmount() - toRemove);
- toRemove = 0;
- }
- }
- if(toRemove <= 0) {
- p.updateInventory();
- break;
- }
- }
- }
- }
- }
+
+ @Override
+ public void executeRequire(Player p, Object obj) {
+ boolean ignoreLore = SkyBlock.getInstance().getConfig().getBoolean("Island.Challenge.IgnoreItemLore", false);
+
+ if (obj instanceof ItemStack) {
+ // Remove specific item in player's inventory
+ ItemStack is = (ItemStack) obj;
+ int toRemove = is.getAmount();
+ for (ItemStack jis : p.getInventory().getContents()) {
+ if (jis == null) continue;
+ if (ignoreLore ? ItemUtils.isSimilarMaterial(is, jis) : jis.isSimilar(is)) {
+ if (jis.getAmount() <= toRemove) {
+ toRemove -= jis.getAmount();
+ p.getInventory().removeItem(jis);
+ } else {
+ jis.setAmount(jis.getAmount() - toRemove);
+ toRemove = 0;
+ }
+ }
+ if (toRemove <= 0) {
+ p.updateInventory();
+ break;
+ }
+ }
+ }
+ }
@Override
public void executeReward(Player p, Object obj) {
// Give specific item to player
ItemStack is = (ItemStack) obj;
- HashMap rest = p.getInventory()
- .addItem(new ItemStack(is.getType(), is.getAmount()));
+ HashMap rest = p.getInventory().addItem(is.clone());
for (ItemStack restIs : rest.values())
p.getWorld().dropItem(p.getLocation(), restIs);
}
@@ -338,7 +387,7 @@ public class Challenge {
},
POTION {
- private Pattern space = Pattern.compile(" ");
+ private final Pattern space = Pattern.compile(" ");
@Override
public Peer> convert(String value) throws IllegalArgumentException {
diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java
index 8507ac82..a179dd99 100644
--- a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java
+++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java
@@ -12,9 +12,9 @@ import java.util.List;
import java.util.Set;
public class ChallengeCategory {
- private int id;
- private String name;
- private HashMap challenges;
+ private final int id;
+ private final String name;
+ private final HashMap challenges;
public ChallengeCategory(int id, String name, FileConfiguration config) {
this.id = id;
diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeManager.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeManager.java
index c317b002..e967631b 100644
--- a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeManager.java
+++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeManager.java
@@ -12,8 +12,8 @@ import java.util.HashMap;
import java.util.logging.Level;
public class ChallengeManager {
- private SkyBlock plugin;
- private HashMap categories;
+ private final SkyBlock plugin;
+ private final HashMap categories;
public ChallengeManager(SkyBlock plugin) {
this.plugin = plugin;
@@ -22,15 +22,14 @@ public class ChallengeManager {
}
private void loadChallenges() {
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "challenges.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = this.plugin.getChallenges();
try {
ConfigurationSection section = configLoad.getConfigurationSection("challenges");
if (section != null) {
for (String k : section.getKeys(false)) {
int id = configLoad.getInt("challenges." + k + ".id");
- String name = ChatColor.translateAlternateColorCodes('&', configLoad.getString("challenges." + k + ".name"));
+ String name = plugin.formatText(configLoad.getString("challenges." + k + ".name"));
ChallengeCategory cc = new ChallengeCategory(id, name, configLoad);
categories.put(id, cc);
}
diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java
index 42522b60..5f438924 100644
--- a/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java
+++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ItemChallenge.java
@@ -14,14 +14,14 @@ import java.util.UUID;
public class ItemChallenge {
private Challenge challenge;
- private boolean show;
- private int row;
- private int col;
- private CompatibleMaterial type;
- private int amount;
- private List lore;
+ private final boolean show;
+ private final int row;
+ private final int col;
+ private final CompatibleMaterial type;
+ private final int amount;
+ private final List lore;
- private String itemTitle;
+ private final String itemTitle;
public ItemChallenge(boolean show, int row, int col, CompatibleMaterial type, int amount, List lore) {
this.show = show;
@@ -30,17 +30,12 @@ public class ItemChallenge {
this.type = type;
this.amount = amount;
this.lore = lore;
-
- FileManager.Config langConfig = SkyBlock.getInstance().getFileManager()
- .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"));
- FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
+ FileConfiguration langConfigLoad = SkyBlock.getInstance().getLanguage();
itemTitle = langConfigLoad.getString("Challenge.Inventory.Item.Title");
}
public ItemStack createItem(UUID player, int amount) {
- FileManager.Config langConfig = SkyBlock.getInstance().getFileManager()
- .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"));
- FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
+ FileConfiguration langConfigLoad = SkyBlock.getInstance().getLanguage();
ItemStack is = type.getItem();
is.setAmount(this.amount);
@@ -53,9 +48,8 @@ public class ItemChallenge {
} else {
maxAmount = String.valueOf(challenge.getMaxTimes());
}
- im.setDisplayName(ChatColor.translateAlternateColorCodes('&',
- itemTitle.replace("%challenge", challenge.getName()).replace("%amount", Integer.toString(amount))
- .replace("%max", maxAmount)));
+ im.setDisplayName(SkyBlock.getInstance().formatText( challenge.getName()).replace("%amount", Integer.toString(amount))
+ .replace("%max", maxAmount));
im.setLore(lore);
is.setItemMeta(im);
}
diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/Peer.java b/src/main/java/com/songoda/skyblock/challenge/challenge/Peer.java
index 06178bf8..ee5fa7d9 100644
--- a/src/main/java/com/songoda/skyblock/challenge/challenge/Peer.java
+++ b/src/main/java/com/songoda/skyblock/challenge/challenge/Peer.java
@@ -1,8 +1,8 @@
package com.songoda.skyblock.challenge.challenge;
public class Peer {
- private E key;
- private F value;
+ private final E key;
+ private final F value;
public Peer(E key, F value) {
this.key = key;
diff --git a/src/main/java/com/songoda/skyblock/challenge/defaultinv/DefaultInventory.java b/src/main/java/com/songoda/skyblock/challenge/defaultinv/DefaultInventory.java
index 1ddd0681..8ca0082f 100644
--- a/src/main/java/com/songoda/skyblock/challenge/defaultinv/DefaultInventory.java
+++ b/src/main/java/com/songoda/skyblock/challenge/defaultinv/DefaultInventory.java
@@ -17,12 +17,11 @@ import java.util.List;
public class DefaultInventory {
private final Item defaultItem = new Item(new ItemStack(Material.AIR));
- private int size;
- private Item[][] items;
+ private final int size;
+ private final Item[][] items;
public DefaultInventory(SkyBlock plugin) {
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "challenges.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getChallenges();
size = configLoad.getInt("inventory.size");
items = new Item[9][size];
ConfigurationSection section = configLoad.getConfigurationSection("inventory.items");
@@ -35,7 +34,7 @@ public class DefaultInventory {
int col = configLoad.getInt(k + ".col");
String strItem = configLoad.getString(k + ".item");
int amount = configLoad.getInt(k + ".amount");
- String name = ChatColor.translateAlternateColorCodes('&', configLoad.getString(k + ".name"));
+ String name = plugin.formatText(configLoad.getString(k + ".name"));
List lore = toColor(configLoad.getStringList(k + ".lore"));
int redirect = configLoad.getInt(k + ".redirect");
CompatibleMaterial material = CompatibleMaterial.getMaterial(strItem);
diff --git a/src/main/java/com/songoda/skyblock/challenge/defaultinv/Item.java b/src/main/java/com/songoda/skyblock/challenge/defaultinv/Item.java
index 212dbf88..dc10692d 100644
--- a/src/main/java/com/songoda/skyblock/challenge/defaultinv/Item.java
+++ b/src/main/java/com/songoda/skyblock/challenge/defaultinv/Item.java
@@ -3,8 +3,8 @@ package com.songoda.skyblock.challenge.defaultinv;
import org.bukkit.inventory.ItemStack;
public class Item {
- private ItemStack itemStack;
- private int redirect;
+ private final ItemStack itemStack;
+ private final int redirect;
public Item(ItemStack itemStack) {
this(itemStack, 0);
diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/ClickableItem.java b/src/main/java/com/songoda/skyblock/challenge/inventory/ClickableItem.java
index dbdd18a8..f6e66345 100644
--- a/src/main/java/com/songoda/skyblock/challenge/inventory/ClickableItem.java
+++ b/src/main/java/com/songoda/skyblock/challenge/inventory/ClickableItem.java
@@ -9,8 +9,8 @@ import org.bukkit.inventory.ItemStack;
import java.util.function.Consumer;
public class ClickableItem {
- private ItemStack item;
- private Consumer event;
+ private final ItemStack item;
+ private final Consumer event;
private ClickableItem(ItemStack item, Consumer event) {
this.item = item;
diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/Inventory.java b/src/main/java/com/songoda/skyblock/challenge/inventory/Inventory.java
index 8c746935..60f88074 100644
--- a/src/main/java/com/songoda/skyblock/challenge/inventory/Inventory.java
+++ b/src/main/java/com/songoda/skyblock/challenge/inventory/Inventory.java
@@ -14,14 +14,14 @@ import java.util.function.Consumer;
public class Inventory {
public static final String TICK = "tick";
- private HashMap values;
- private Player player;
- private InventoryProvider inventoryProvider;
- private int size;
+ private final HashMap values;
+ private final Player player;
+ private final InventoryProvider inventoryProvider;
+ private final int size;
- private List excluseCases;
- private ClickableItem[] items;
- private org.bukkit.inventory.Inventory bukkitInventory;
+ private final List excluseCases;
+ private final ClickableItem[] items;
+ private final org.bukkit.inventory.Inventory bukkitInventory;
public Inventory(Player player, InventoryProvider inventoryProvider, Consumer params) {
this.values = new HashMap<>();
diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryManager.java b/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryManager.java
index 3f59d5dc..7d98956f 100644
--- a/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryManager.java
+++ b/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryManager.java
@@ -20,9 +20,8 @@ import java.util.UUID;
import java.util.function.Consumer;
public class InventoryManager implements Listener {
- private SkyBlock plugin;
- private HashMap inventories;
- private int task;
+ private final SkyBlock plugin;
+ private final HashMap inventories;
public InventoryManager(SkyBlock plugin) {
this.plugin = plugin;
@@ -31,7 +30,7 @@ public class InventoryManager implements Listener {
public void init() {
Bukkit.getPluginManager().registerEvents(this, plugin);
- task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
+ int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
if (inventories.size() == 0)
return;
for (Inventory inv : inventories.values()) {
diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryProvider.java b/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryProvider.java
index a8140100..d9685260 100644
--- a/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryProvider.java
+++ b/src/main/java/com/songoda/skyblock/challenge/inventory/InventoryProvider.java
@@ -10,18 +10,18 @@ import java.util.List;
public interface InventoryProvider {
- public String title(Inventory inv);
+ String title(Inventory inv);
- public int rows(Inventory inv);
+ int rows(Inventory inv);
- public void init(Inventory inv);
+ void init(Inventory inv);
- public void update(Inventory inv);
+ void update(Inventory inv);
- public default List excluseCases(Inventory inv) {
+ default List excluseCases(Inventory inv) {
return new ArrayList<>();
}
- public default void onClose(InventoryCloseEvent e, Inventory inv) {
+ default void onClose(InventoryCloseEvent e, Inventory inv) {
}
}
diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java b/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java
index 5bc8e7de..13bd7f2a 100644
--- a/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java
+++ b/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java
@@ -24,7 +24,7 @@ import java.util.logging.Level;
public class ChallengeInventory implements InventoryProvider {
public static final String CATEGORY = "ChallengeCategory";
- private FabledChallenge fc;
+ private final FabledChallenge fc;
public ChallengeInventory(FabledChallenge fc) {
this.fc = fc;
diff --git a/src/main/java/com/songoda/skyblock/challenge/player/PlayerChallenge.java b/src/main/java/com/songoda/skyblock/challenge/player/PlayerChallenge.java
index 10786162..1ffd940d 100644
--- a/src/main/java/com/songoda/skyblock/challenge/player/PlayerChallenge.java
+++ b/src/main/java/com/songoda/skyblock/challenge/player/PlayerChallenge.java
@@ -6,8 +6,8 @@ import java.util.HashMap;
import java.util.UUID;
public class PlayerChallenge {
- private UUID uuid;
- private HashMap challenges;
+ private final UUID uuid;
+ private final HashMap challenges;
public PlayerChallenge(UUID uuid, HashMap challenges) {
this.uuid = uuid;
diff --git a/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java b/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java
index 387ea423..29480815 100644
--- a/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java
+++ b/src/main/java/com/songoda/skyblock/challenge/player/PlayerManager.java
@@ -13,6 +13,7 @@ import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.io.File;
@@ -23,9 +24,9 @@ import java.util.Set;
import java.util.UUID;
public class PlayerManager {
- private SkyBlock plugin;
- private HashMap> islands;
- private File playersDirectory;
+ private final SkyBlock plugin;
+ private final HashMap> islands;
+ private final File playersDirectory;
public PlayerManager(SkyBlock plugin) {
this.plugin = plugin;
@@ -35,14 +36,12 @@ public class PlayerManager {
playersDirectory.mkdirs();
Bukkit.getScheduler().runTask(plugin, () -> {
- for(Player p : Bukkit.getServer().getOnlinePlayers()){
- loadPlayer(p.getUniqueId());
- }
+ Bukkit.getServer().getOnlinePlayers().stream().map(Entity::getUniqueId).forEach(this::loadPlayer);
});
}
public HashMap getPlayer(UUID uuid) {
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", false)) {
OfflinePlayer player = Bukkit.getPlayer(uuid);
if(player == null) {
@@ -63,7 +62,7 @@ public class PlayerManager {
* The uuid of specific player
*/
public void loadPlayer(UUID uuid) {
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
@@ -104,7 +103,7 @@ public class PlayerManager {
* The uuid of specific player
*/
public void unloadPlayer(UUID uuid) {
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", false)) {
OfflinePlayer player = Bukkit.getPlayer(uuid);
if(player == null) {
@@ -138,7 +137,7 @@ public class PlayerManager {
if (c == null)
return false;
UUID uuid = p.getUniqueId();
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
@@ -174,7 +173,7 @@ public class PlayerManager {
if (!canDoChallenge(p, c))
return false;
UUID uuid = p.getUniqueId();
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
@@ -193,10 +192,8 @@ public class PlayerManager {
peer.getKey().executeReward(p, peer.getValue());
}
// Ok, send message
- String broadcast = ChatColor.translateAlternateColorCodes('&',
- SkyBlock.getInstance().getFileManager()
- .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Challenge.Broadcast"));
+ SkyBlock instance = SkyBlock.getInstance();
+ String broadcast = instance.formatText(instance.getLanguage().getString("Challenge.Broadcast"));
if (c.isShowInChat())
Bukkit.broadcastMessage(broadcast.replace("%player", p.getName()).replace("%challenge", c.getName())
.replace("%amount", Integer.toString(count + 1))
@@ -205,7 +202,7 @@ public class PlayerManager {
}
public void addChallenge(UUID uuid, Challenge c) {
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
@@ -244,7 +241,7 @@ public class PlayerManager {
if (challenges != null) {
return challenges.getOrDefault(c, 0);
} else {
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)) {
Island is = plugin.getIslandManager().getIsland(Bukkit.getOfflinePlayer(uuid));
if(is != null){
diff --git a/src/main/java/com/songoda/skyblock/command/CommandManager.java b/src/main/java/com/songoda/skyblock/command/CommandManager.java
index 83755b72..90c1e599 100644
--- a/src/main/java/com/songoda/skyblock/command/CommandManager.java
+++ b/src/main/java/com/songoda/skyblock/command/CommandManager.java
@@ -38,11 +38,14 @@ public class CommandManager implements CommandExecutor, TabCompleter {
public CommandManager(SkyBlock plugin) {
this.plugin = plugin;
-
- plugin.getCommand("island").setExecutor(this);
- plugin.getCommand("island").setTabCompleter(this);
- registerSubCommands();
+ PluginCommand islandCMD = plugin.getCommand("island");
+ if (islandCMD != null) {
+ islandCMD.setExecutor(this);
+ islandCMD.setTabCompleter(this);
+ registerSubCommands();
+ }
+
}
public void registerSubCommands() {
@@ -127,13 +130,9 @@ public class CommandManager implements CommandExecutor, TabCompleter {
if (command.getName().equalsIgnoreCase("island")) {
MessageManager messageManager = plugin.getMessageManager();
SoundManager soundManager = plugin.getSoundManager();
- FileManager fileManager = plugin.getFileManager();
- Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration languageConfigLoad = languageConfig.getFileConfiguration();
-
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration mainConfig = config.getFileConfiguration();
+ FileConfiguration languageConfigLoad = plugin.getLanguage();
+ FileConfiguration mainConfig = plugin.getConfiguration();
Player player = null;
@@ -189,7 +188,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
if (args.length == 2) {
if (args[1].matches("[0-9]+")) {
- page = Integer.valueOf(args[1]);
+ page = Integer.parseInt(args[1]);
} else {
messageManager.sendMessage(player,
languageConfigLoad.getString("Command.Island.Help.Integer.Message"));
@@ -221,13 +220,12 @@ public class CommandManager implements CommandExecutor, TabCompleter {
int page = -1;
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Command.Help.List")) {
+ if (!this.plugin.getConfiguration().getBoolean("Command.Help.List")) {
page = 1;
if (args.length == 3) {
if (args[2].matches("[0-9]+")) {
- page = Integer.valueOf(args[2]);
+ page = Integer.parseInt(args[2]);
} else {
messageManager.sendMessage(player,
languageConfigLoad.getString("Command.Island.Help.Integer.Message"));
@@ -493,8 +491,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
player.spigot()
.sendMessage(
new ChatComponent(
- ChatColor.translateAlternateColorCodes(
- '&', configLoad.getString("Command.Island.Help.Word.Next")),
+ plugin.formatText(configLoad.getString("Command.Island.Help.Word.Next")),
false, null,
new ClickEvent(ClickEvent.Action.RUN_COMMAND,
"/island " + subCommandText + "help " + (page + 1)),
@@ -503,8 +500,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
player.spigot()
.sendMessage(
new ChatComponent(
- ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Command.Island.Help.Word.Previous")),
+ plugin.formatText(configLoad.getString("Command.Island.Help.Word.Previous")),
false, null,
new ClickEvent(ClickEvent.Action.RUN_COMMAND,
"/island " + subCommandText + "help " + (page - 1)),
diff --git a/src/main/java/com/songoda/skyblock/command/SubCommand.java b/src/main/java/com/songoda/skyblock/command/SubCommand.java
index 0c4315ae..7389270b 100644
--- a/src/main/java/com/songoda/skyblock/command/SubCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/SubCommand.java
@@ -15,7 +15,7 @@ public abstract class SubCommand {
public SubCommand() {
this.plugin = SkyBlock.getInstance();
- this.info = ChatColor.translateAlternateColorCodes('&', this.plugin.getFileManager().getConfig(new File(this.plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString(this.getInfoMessagePath()));
+ this.info = this.plugin.formatText(this.plugin.getLanguage().getString(this.getInfoMessagePath()));
}
public abstract void onCommandByPlayer(Player player, String[] args);
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java
index 90798d3e..e5914acf 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/AdminBank.java
@@ -36,7 +36,7 @@ public class AdminBank extends SubCommand {
Island island = islandManager.getIslandAtLocation(player.getLocation());
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.Bank.Enable")) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1f, 1f);
return;
@@ -60,7 +60,7 @@ public class AdminBank extends SubCommand {
return;
case "deposit":
if (args.length >= 3) {
- islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
+ islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
@@ -68,7 +68,7 @@ public class AdminBank extends SubCommand {
return;
case "withdraw":
if (args.length >= 3) {
- islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
+ islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
@@ -122,7 +122,7 @@ public class AdminBank extends SubCommand {
return;
case "deposit":
if (args.length >= 3) {
- islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
+ islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).addToBank(Double.parseDouble(args[2]));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesDeposit.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
@@ -130,7 +130,7 @@ public class AdminBank extends SubCommand {
return;
case "withdraw":
if (args.length >= 3) {
- islandManager.getIslandByPlayer(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
+ islandManager.getIslandByOwner(Bukkit.getOfflinePlayer(Bukkit.getPlayer(args[1]).getUniqueId())).removeFromBank(Double.parseDouble(args[2]));
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.SuccesWithdraw.Message").replace("%player%",args[1]).replace("%ammount%",economy.formatEconomy(Double.parseDouble(args[2]))));
}else {
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Bank.ByConsole.Message"));
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java
index 6f68d294..5b8a72af 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ChatSpyCommand.java
@@ -52,7 +52,7 @@ public class ChatSpyCommand extends SubCommand {
case "add":
if(args.length == 2){
OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]);
- Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer());
+ Island island = islandManager.getIslandByOwner(offlinePlayer.getBukkitOfflinePlayer());
if(island != null) {
playerData.addChatSpyIsland(island);
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Add.Message")
@@ -68,7 +68,7 @@ public class ChatSpyCommand extends SubCommand {
case "remove":
if(args.length == 2){
OfflinePlayer offlinePlayer = new OfflinePlayer(args[1]);
- Island island = islandManager.getIslandByPlayer(offlinePlayer.getBukkitOfflinePlayer());
+ Island island = islandManager.getIslandByOwner(offlinePlayer.getBukkitOfflinePlayer());
if(island != null) {
playerData.removeChatSpyIsland(island);
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Admin.ChatSpy.Remove.Message")
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java
index c42d9856..613f51b3 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetBiomeCommand.java
@@ -92,7 +92,7 @@ public class SetBiomeCommand extends SubCommand {
} else {
if (islandManager.containsIsland(islandOwnerUUID)) {
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
- biomeManager.setBiome(island, world, biome.getBiome(), null);
+ biomeManager.setBiome(island, world, biome, null);
if(world.equals(IslandWorld.Normal)) {
island.setBiome(biome.getBiome());
}
@@ -106,7 +106,7 @@ public class SetBiomeCommand extends SubCommand {
} else {
CompatibleBiome finalBiome = biome;
IslandWorld finalWorld = world;
- biomeManager.setBiome(island, world, biome.getBiome(), () -> {
+ biomeManager.setBiome(island, world, biome, () -> {
if(finalWorld.equals(IslandWorld.Normal)) {
island.setBiome(finalBiome.getBiome());
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java
index cab10967..897c4e40 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetMaxMembers.java
@@ -79,8 +79,7 @@ public class SetMaxMembers extends SubCommand {
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
island.setMaxMembers(maxMembers);
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.WorldBorder.Enable")
+ if (this.plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable")
&& island.isBorder()) {
islandManager.updateBorder(island);
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java
index 06f43459..814e02c6 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetSizeCommand.java
@@ -79,8 +79,7 @@ public class SetSizeCommand extends SubCommand {
.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
island.setSize(size);
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.WorldBorder.Enable")
+ if (this.plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable")
&& island.isBorder()) {
islandManager.updateBorder(island);
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java
index 2e64c606..d8f374b7 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java
@@ -98,7 +98,7 @@ public class AcceptCommand extends SubCommand {
island.save();
if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()
- + 1) >= island.getMaxMembers()) {
+ + 1) >= island.getMaxMembers(player)) {
Map invites = inviteManager.getInvites();
for (UUID inviteList : invites.keySet()) {
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java
index 68abb0b8..c107ec90 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/BanCommand.java
@@ -41,7 +41,7 @@ public class BanCommand extends SubCommand {
if (island == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Ban.Owner.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
+ } else if (this.plugin.getConfiguration().getBoolean("Island.Visitor.Banning")) {
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|| (island.hasRole(IslandRole.Operator, player.getUniqueId()) && permissionManager.hasPermission(island, "Ban", IslandRole.Operator))) {
Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
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 d511d7b2..f82c0e2e 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
@@ -27,7 +27,7 @@ public class BankCommand extends SubCommand {
Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.Bank.Enable")) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Bank.Disabled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/BorderCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/BorderCommand.java
index 8c12e8c9..10074873 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/BorderCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/BorderCommand.java
@@ -38,7 +38,7 @@ public class BorderCommand extends SubCommand {
} else if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
&& permissionManager.hasPermission(island, "Border", IslandRole.Operator))
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.WorldBorder.Enable")) {
Border.getInstance().open(player);
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_OPEN.getSound(), 1.0F, 1.0F);
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ChallengeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ChallengeCommand.java
index bc4a42b4..1b065cca 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/ChallengeCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/ChallengeCommand.java
@@ -30,14 +30,14 @@ public class ChallengeCommand extends SubCommand {
FileConfiguration langConfigLoad = langConfig.getFileConfiguration();
// Not loaded
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (!this.plugin.getConfiguration()
.getBoolean("Island.Challenge.Enable")) {
messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.Disabled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
}
if (args.length == 0) {
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland")){
if(islandManager.getIsland(player) == null){
messageManager.sendMessage(player, langConfigLoad.getString("Command.Island.Challenge.NoIsland.Message"));
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 33d50114..ca89f26b 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
@@ -136,7 +136,7 @@ public class ConfirmCommand extends SubCommand {
return;
}
- if (economy.isEnabled() && island.getStructure() != null
+ if (economy != null && economy.isEnabled() && island.getStructure() != null
&& !island.getStructure().isEmpty()
&& structureManager.containsStructure(island.getStructure())) {
Structure structure = structureManager.getStructure(island.getStructure());
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java
index f9d894cb..ac821d1e 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/CoopCommand.java
@@ -39,7 +39,7 @@ public class CoopCommand extends SubCommand {
if (island == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Coop.Owner.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ } else if (this.plugin.getConfiguration()
.getBoolean("Island.Coop.Enable")) {
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java
index 361e743a..5b51b78c 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/InviteCommand.java
@@ -50,7 +50,7 @@ public class InviteCommand extends SubCommand {
Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
if ((island.getRole(IslandRole.Member).size() + island.getRole(IslandRole.Operator).size()
- + 1) >= island.getMaxMembers()) {
+ + 1) >= island.getMaxMembers(player)) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Invite.Capacity.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/LeaderboardCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/LeaderboardCommand.java
index 85f64c1c..a7bbe450 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/LeaderboardCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/LeaderboardCommand.java
@@ -28,7 +28,7 @@ public class LeaderboardCommand extends SubCommand {
if (playerDataManager.hasPlayerData(player)) {
if (args.length == 0) {
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Visitor.Vote")) {
playerDataManager.getPlayerData(player)
.setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Browse));
@@ -46,7 +46,7 @@ public class LeaderboardCommand extends SubCommand {
playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Bank));
break;
case "votes":
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
+ if (this.plugin.getConfiguration().getBoolean("Island.Visitor.Vote")) {
playerDataManager.getPlayerData(player).setViewer(new Leaderboard.Viewer(Leaderboard.Viewer.Type.Votes));
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Leaderboard.Disabled.Message"));
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java
index aaef16e0..9d9d65ec 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/OwnerCommand.java
@@ -126,8 +126,7 @@ public class OwnerCommand extends SubCommand {
return;
} else {
- int confirmationTime = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getInt("Island.Confirmation.Timeout");
+ int confirmationTime = this.plugin.getConfiguration().getInt("Island.Confirmation.Timeout");
playerData.setOwnership(targetPlayerUUID);
playerData.setConfirmation(Confirmation.Ownership);
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/SetSpawnCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/SetSpawnCommand.java
index 92678833..bb402ce1 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/SetSpawnCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/SetSpawnCommand.java
@@ -34,105 +34,16 @@ public class SetSpawnCommand extends SubCommand {
messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Owner.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
- IslandEnvironment environment;
-
if (args[0].equalsIgnoreCase("Main")) {
- environment = IslandEnvironment.Main;
+ setIslandSpawn(IslandEnvironment.Main, island, islandManager, player, configLoad, fileManager, messageManager, soundManager);
} else if (args[0].equalsIgnoreCase("Visitor")) {
- environment = IslandEnvironment.Visitor;
+ setIslandSpawn(IslandEnvironment.Visitor, island, islandManager, player, configLoad, fileManager, messageManager, soundManager);
+ } else if (args[0].equalsIgnoreCase("All")){
+ setIslandSpawn(IslandEnvironment.Main, island, islandManager, player, configLoad, fileManager, messageManager, soundManager);
+ setIslandSpawn(IslandEnvironment.Visitor, island, islandManager, player, configLoad, fileManager, messageManager, soundManager);
} else {
messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Spawn.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
-
- return;
- }
-
- if (island.hasRole(IslandRole.Operator, player.getUniqueId())
- || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
- if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
- && (plugin.getPermissionManager().hasPermission(island,
- environment.name() + "Spawn", IslandRole.Operator)))
- || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
- if (islandManager.isPlayerAtIsland(island, player)) {
- IslandWorld world = plugin.getWorldManager().getIslandWorld(player.getWorld());
- Location location = player.getLocation();
-
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
-
- CompatibleMaterial toCompare = CompatibleMaterial.getMaterial(location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType());
-
- if(toCompare == CompatibleMaterial.AIR
- || toCompare == CompatibleMaterial.MOVING_PISTON
- || toCompare == CompatibleMaterial.ICE
- || toCompare == CompatibleMaterial.PISTON_HEAD) {
-
- messageManager.sendMessage(player,
- configLoad.getString("Command.Island.SetSpawn.Protection.Block.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
-
- return;
- } else if (!player.getLocation().clone().subtract(0, 0.1, 0).getBlock().getType().isSolid()) {
- messageManager.sendMessage(player,
- configLoad.getString("Command.Island.SetSpawn.Protection.Ground.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
-
- return;
- } else if (location.getBlock().isLiquid()
- || location.clone().add(0.0D, 1.0D, 0.0D).getBlock().isLiquid()) {
- messageManager.sendMessage(player,
- configLoad.getString("Command.Island.SetSpawn.Protection.Liquid.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
-
- return;
- } else if (CompatibleMaterial.getMaterial(location.getBlock().getType()) == CompatibleMaterial.NETHER_PORTAL
- || CompatibleMaterial.getMaterial(location.clone().add(0.0D, 1.0D, 0.0D).getBlock()
- .getType()) == CompatibleMaterial.NETHER_PORTAL) {
- messageManager.sendMessage(player,
- configLoad.getString("Command.Island.SetSpawn.Protection.Portal.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
-
- return;
- } else {
- CompatibleMaterial type = CompatibleMaterial.getMaterial(location.getBlock().getType());
- if (type.isSolid() && type.isOccluding()) {
- location.getBlock().breakNaturally();
- }
-
- CompatibleMaterial typeBelow = CompatibleMaterial.getMaterial(location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType());
- if (typeBelow.isSolid() && type.isOccluding()) {
- location.clone().add(0.0D, 1.0D, 0.0D).getBlock().breakNaturally();
- }
-
- islandManager.removeSpawnProtection(island.getLocation(world, environment));
- }
- }
-
- Location newSpawnLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
- island.setLocation(world, environment, newSpawnLocation);
-
- messageManager.sendMessage(player,
- configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn",
- environment.name().toLowerCase()));
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
-
- return;
- }
-
- messageManager.sendMessage(player,
- configLoad.getString("Command.Island.SetSpawn.Island.Message").replace("%spawn",
- environment.name().toLowerCase()));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else {
- messageManager.sendMessage(player,
- configLoad.getString("Command.Island.SetSpawn.Permission.Message").replace("%spawn",
- environment.name().toLowerCase()));
- soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
- }
- } else {
- messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Role.Message")
- .replace("%spawn", environment.name().toLowerCase()));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
}
}
} else {
@@ -163,6 +74,97 @@ public class SetSpawnCommand extends SubCommand {
@Override
public String[] getArguments() {
- return new String[]{"main", "visitor"};
+ return new String[]{ "main", "visitor" , "all"};
+ }
+
+
+ private void setIslandSpawn(IslandEnvironment environment, Island island, IslandManager islandManager, Player player, FileConfiguration configLoad, FileManager fileManager, MessageManager messageManager, SoundManager soundManager) {
+ if (island.hasRole(IslandRole.Operator, player.getUniqueId())
+ || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
+ if ((island.hasRole(IslandRole.Operator, player.getUniqueId())
+ && (plugin.getPermissionManager().hasPermission(island,
+ environment.name() + "Spawn", IslandRole.Operator)))
+ || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
+ if (islandManager.isPlayerAtIsland(island, player)) {
+ IslandWorld world = plugin.getWorldManager().getIslandWorld(player.getWorld());
+ Location location = player.getLocation();
+
+ if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
+ .getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
+
+ CompatibleMaterial toCompare = CompatibleMaterial.getMaterial(location.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType());
+
+ if(toCompare == CompatibleMaterial.AIR
+ || toCompare == CompatibleMaterial.MOVING_PISTON
+ || toCompare == CompatibleMaterial.ICE
+ || toCompare == CompatibleMaterial.PISTON_HEAD) {
+
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.SetSpawn.Protection.Block.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+
+ return;
+ } else if (!player.getLocation().clone().subtract(0, 0.1, 0).getBlock().getType().isSolid()) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.SetSpawn.Protection.Ground.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+
+ return;
+ } else if (location.getBlock().isLiquid()
+ || location.clone().add(0.0D, 1.0D, 0.0D).getBlock().isLiquid()) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.SetSpawn.Protection.Liquid.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+
+ return;
+ } else if (CompatibleMaterial.getMaterial(location.getBlock().getType()) == CompatibleMaterial.NETHER_PORTAL
+ || CompatibleMaterial.getMaterial(location.clone().add(0.0D, 1.0D, 0.0D).getBlock()
+ .getType()) == CompatibleMaterial.NETHER_PORTAL) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.SetSpawn.Protection.Portal.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+
+ return;
+ } else {
+ CompatibleMaterial type = CompatibleMaterial.getMaterial(location.getBlock().getType());
+ if (type.isSolid() && type.isOccluding()) {
+ location.getBlock().breakNaturally();
+ }
+
+ CompatibleMaterial typeBelow = CompatibleMaterial.getMaterial(location.clone().add(0.0D, 1.0D, 0.0D).getBlock().getType());
+ if (typeBelow.isSolid() && type.isOccluding()) {
+ location.clone().add(0.0D, 1.0D, 0.0D).getBlock().breakNaturally();
+ }
+
+ islandManager.removeSpawnProtection(island.getLocation(world, environment));
+ }
+ }
+
+ Location newSpawnLocation = new Location(location.getWorld(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
+ island.setLocation(world, environment, newSpawnLocation);
+
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.SetSpawn.Set.Message").replace("%spawn",
+ environment.name().toLowerCase()));
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
+
+ return;
+ }
+
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.SetSpawn.Island.Message").replace("%spawn",
+ environment.name().toLowerCase()));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ } else {
+ messageManager.sendMessage(player,
+ configLoad.getString("Command.Island.SetSpawn.Permission.Message").replace("%spawn",
+ environment.name().toLowerCase()));
+ soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
+ }
+ } else {
+ messageManager.sendMessage(player, configLoad.getString("Command.Island.SetSpawn.Role.Message")
+ .replace("%spawn", environment.name().toLowerCase()));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ }
}
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java
index edd311e4..488ee8f2 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/TeleportCommand.java
@@ -7,13 +7,15 @@ import com.songoda.skyblock.island.*;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
-import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.visit.Visit;
import com.songoda.skyblock.visit.VisitManager;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.block.data.Waterlogged;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@@ -35,25 +37,22 @@ public class TeleportCommand extends SubCommand {
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
- Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
- UUID islandOwnerUUID;
- String targetPlayerName;
+ OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(args[0]);
+ Island island = islandManager.getIsland(offlinePlayer);
+ if (island == null) {
+ messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Island.None.Message", "Command.Island.Teleport.Island.None.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- if (targetPlayer == null) {
- OfflinePlayer targetOfflinePlayer = new OfflinePlayer(args[0]);
- islandOwnerUUID = targetOfflinePlayer.getOwner();
- targetPlayerName = targetOfflinePlayer.getName();
- } else {
- islandOwnerUUID = playerDataManager.getPlayerData(targetPlayer).getOwner();
- targetPlayerName = targetPlayer.getName();
+ return;
}
-
+ UUID islandOwnerUUID = island.getOwnerUUID();
if (islandOwnerUUID == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Island.None.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
- } else if (!islandOwnerUUID.equals(playerDataManager.getPlayerData(player).getOwner())) {
+ }
+ else if (!islandOwnerUUID.equals(playerDataManager.getPlayerData(player).getOwner())) {
if (visitManager.hasIsland(islandOwnerUUID)) {
Visit visit = visitManager.getIsland(islandOwnerUUID);
boolean isCoopPlayer = false;
@@ -63,24 +62,29 @@ public class TeleportCommand extends SubCommand {
if (islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isCoopPlayer(player.getUniqueId())) {
isCoopPlayer = true;
}
+
if (visit.getStatus().equals(IslandStatus.WHITELISTED) && islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)).isPlayerWhitelisted(player.getUniqueId())) {
isWhitelistedPlayer = true;
}
+
}
+
+
if (visit.getStatus().equals(IslandStatus.OPEN) ||
isCoopPlayer ||
isWhitelistedPlayer ||
player.hasPermission("fabledskyblock.bypass") ||
player.hasPermission("fabledskyblock.bypass.*") ||
player.hasPermission("fabledskyblock.*")) {
+
if (!islandManager.containsIsland(islandOwnerUUID)) {
islandManager.loadIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID));
}
islandManager.visitIsland(player, islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(islandOwnerUUID)));
- messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Other.Message").replace("%player", targetPlayerName));
+ messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Other.Message").replace("%player", args[0]));
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
return;
@@ -107,12 +111,11 @@ public class TeleportCommand extends SubCommand {
Island island = islandManager.getIsland(player);
if (island == null) {
- messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Owner.Message"));
+ messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Owner.Message", "Command.Island.Teleport.Owner.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
- messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Yourself.Message"));
+ messageManager.sendMessage(player, configLoad.getString("Command.Island.Teleport.Teleported.Yourself.Message", "Command.Island.Teleport.Teleported.Yourself.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
-
Bukkit.getServer().getScheduler().runTask(plugin, () -> {
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
PaperLib.getChunkAtAsync(loc).thenRun((() -> {
@@ -127,6 +130,7 @@ public class TeleportCommand extends SubCommand {
player.setFallDistance(0.0F);
}
});
+
}
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UnbanCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UnbanCommand.java
index 7da0f85f..61628b41 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/UnbanCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/UnbanCommand.java
@@ -37,7 +37,7 @@ public class UnbanCommand extends SubCommand {
if (island == null) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unban.Owner.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ } else if (this.plugin.getConfiguration()
.getBoolean("Island.Visitor.Banning")) {
if (island.hasRole(IslandRole.Owner, player.getUniqueId())
|| (island.hasRole(IslandRole.Operator, player.getUniqueId())
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 b488951f..11e5781b 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
@@ -45,7 +45,7 @@ public class UnlockCommand extends SubCommand {
return;
}
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World." + type + ".Enable")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.World." + type + ".Enable")) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Unlock.Disabled.Message").replace("%type%", type));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java
index ecda0037..7ae02baa 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java
@@ -37,7 +37,7 @@ public class ValueCommand extends SubCommand {
if (materials != null && levellingManager.hasWorth(materials)) {
double worth = levellingManager.getWorth(materials);
- double level = worth / (double) fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Levelling.Division");
+ double level = worth / (double) this.plugin.getConfiguration().getInt("Island.Levelling.Division");
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Value.Value.Message").replace("%material", WordUtils.capitalizeFully(materials.name().toLowerCase().replace("_", " ")))
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java
index d25c3781..a160ecb8 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/VoteCommand.java
@@ -40,7 +40,7 @@ public class VoteCommand extends SubCommand {
FileConfiguration configLoad = config.getFileConfiguration();
if (args.length == 1) {
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (!this.plugin.getConfiguration()
.getBoolean("Island.Visitor.Vote")) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Vote.Disabled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
diff --git a/src/main/java/com/songoda/skyblock/config/FileChecker.java b/src/main/java/com/songoda/skyblock/config/FileChecker.java
index 4aee9545..e4226bfe 100644
--- a/src/main/java/com/songoda/skyblock/config/FileChecker.java
+++ b/src/main/java/com/songoda/skyblock/config/FileChecker.java
@@ -15,7 +15,7 @@ public class FileChecker {
private final FileManager fileManager;
- private Map loadedFiles;
+ private final Map loadedFiles;
public FileChecker(SkyBlock plugin, FileManager fileManager, String configurationFileName, boolean applyComments) {
this.fileManager = fileManager;
@@ -87,10 +87,10 @@ public class FileChecker {
public static class File {
- private java.io.File configFile;
+ private final java.io.File configFile;
private FileConfiguration configLoad;
- private HashMap configKeys;
+ private final HashMap configKeys;
public File(FileManager fileManager, java.io.File configFile, FileConfiguration configLoad) {
this.configFile = configFile;
diff --git a/src/main/java/com/songoda/skyblock/config/FileManager.java b/src/main/java/com/songoda/skyblock/config/FileManager.java
index f974181e..4bc38b01 100644
--- a/src/main/java/com/songoda/skyblock/config/FileManager.java
+++ b/src/main/java/com/songoda/skyblock/config/FileManager.java
@@ -333,7 +333,7 @@ public class FileManager {
public static class Config {
- private File configFile;
+ private final File configFile;
private FileConfiguration configLoad;
public Config(FileManager fileManager, java.io.File configPath) {
diff --git a/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java b/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java
index 87a045ea..62dcbbb9 100644
--- a/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java
+++ b/src/main/java/com/songoda/skyblock/cooldown/CooldownManager.java
@@ -18,7 +18,7 @@ public class CooldownManager {
private final SkyBlock plugin;
- private Map> cooldownStorage = new EnumMap<>(CooldownType.class);
+ private final Map> cooldownStorage = new EnumMap<>(CooldownType.class);
public CooldownManager(SkyBlock plugin) {
this.plugin = plugin;
@@ -95,7 +95,7 @@ public class CooldownManager {
int time = 0;
if (cooldownType == CooldownType.Biome || cooldownType == CooldownType.Creation || cooldownType == CooldownType.Deletion) {
- time = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ time = this.plugin.getConfiguration()
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
Config config = fileManager
@@ -111,7 +111,7 @@ public class CooldownManager {
e.printStackTrace();
}
} else if (cooldownType == CooldownType.Levelling || cooldownType == CooldownType.Ownership) {
- time = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ time = this.plugin.getConfiguration()
.getInt("Island." + cooldownType.name() + ".Cooldown.Time");
Config config = plugin.getFileManager()
diff --git a/src/main/java/com/songoda/skyblock/cooldown/CooldownTask.java b/src/main/java/com/songoda/skyblock/cooldown/CooldownTask.java
index d589492c..a06734e8 100644
--- a/src/main/java/com/songoda/skyblock/cooldown/CooldownTask.java
+++ b/src/main/java/com/songoda/skyblock/cooldown/CooldownTask.java
@@ -20,8 +20,7 @@ public class CooldownTask extends BukkitRunnable {
if (cooldownPlayers == null) return;
- for (int i = 0; i < cooldownPlayers.size(); i++) {
- CooldownPlayer cooldownPlayer = cooldownPlayers.get(i);
+ for (CooldownPlayer cooldownPlayer : cooldownPlayers) {
Cooldown cooldown = cooldownPlayer.getCooldown();
cooldown.setTime(cooldown.getTime() - 1);
diff --git a/src/main/java/com/songoda/skyblock/economy/EconomyManager.java b/src/main/java/com/songoda/skyblock/economy/EconomyManager.java
index 19ab1107..24da2374 100644
--- a/src/main/java/com/songoda/skyblock/economy/EconomyManager.java
+++ b/src/main/java/com/songoda/skyblock/economy/EconomyManager.java
@@ -15,16 +15,14 @@ public class EconomyManager extends Manager {
economy = com.songoda.core.hooks.EconomyManager.getEconomy();
}
- public boolean setEconomy(String economyString) {
+ public void setEconomy(String economyString) {
Hook hook = com.songoda.core.hooks.EconomyManager.getManager().getHook(economyString);
if(hook != null &&
hook.isEnabled() &&
hook instanceof Economy &&
!hook.equals(com.songoda.core.hooks.EconomyManager.getManager().getCurrentHook())) {
this.economy = (Economy) hook;
- return true;
}
- return false;
}
public Economy getEconomy() {
diff --git a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java
index 793e97d8..3f350403 100644
--- a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java
+++ b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java
@@ -30,8 +30,7 @@ public class GeneratorManager {
}
public void registerGenerators() {
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "generators.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = this.plugin.getGenerators();
if (configLoad.getString("Generators") == null)
return;
diff --git a/src/main/java/com/songoda/skyblock/generator/GeneratorMaterial.java b/src/main/java/com/songoda/skyblock/generator/GeneratorMaterial.java
index cf2215da..ccc342fc 100644
--- a/src/main/java/com/songoda/skyblock/generator/GeneratorMaterial.java
+++ b/src/main/java/com/songoda/skyblock/generator/GeneratorMaterial.java
@@ -4,7 +4,7 @@ import com.songoda.core.compatibility.CompatibleMaterial;
public class GeneratorMaterial {
- private CompatibleMaterial materials;
+ private final CompatibleMaterial materials;
private double chance;
public GeneratorMaterial(CompatibleMaterial materials, double chance) {
diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java
index 162f756b..0c0c9f70 100644
--- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java
+++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBank.java
@@ -24,12 +24,11 @@ public class GuiBank extends Gui {
public GuiBank(SkyBlock plugin, Island island, Gui returnGui, boolean admin) {
super(2, returnGui);
- this.plugin = plugin;;
+ this.plugin = plugin;
this.soundManager = plugin.getSoundManager();
this.island = island;
this.admin = admin;
- this.languageLoad = plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
+ this.languageLoad = this.plugin.getLanguage();
if(island != null) {
setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
setTitle(TextUtils.formatText(languageLoad.getString("Menu.Bank.Title")));
diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java
index 617c0017..dc220321 100644
--- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java
+++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankSelector.java
@@ -42,8 +42,7 @@ public class GuiBankSelector extends Gui {
this.island = island;
this.returnGui = returnGui;
this.admin = admin;
- this.languageLoad = plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
+ this.languageLoad = this.plugin.getLanguage();
setDefaultItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem());
setTitle(TextUtils.formatText(languageLoad.getString("Menu.Input.Title")));
paint();
@@ -92,14 +91,14 @@ public class GuiBankSelector extends Gui {
switch(type){
case DEPOSIT:
amount = economy.getBalance(event.player);
- if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
amount = Math.floor(amount);
}
response = bankManager.deposit(event.player, island, amount, admin);
break;
case WITHDRAW:
amount = island.getBankBalance();
- if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.Bank.AllowDecimals")) {
amount = Math.floor(amount);
}
response = bankManager.withdraw(event.player, island, amount, admin);
diff --git a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java
index b5c419f1..89521316 100644
--- a/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java
+++ b/src/main/java/com/songoda/skyblock/gui/bank/GuiBankTransaction.java
@@ -21,11 +21,8 @@ import java.util.ArrayList;
import java.util.List;
public class GuiBankTransaction extends Gui {
- private final SkyBlock plugin;
- private final BankManager bankManager;
private final SoundManager soundManager;
private final FileConfiguration languageLoad;
- private final FileManager.Config config;
private final Gui returnGui;
private final int transactions;
private final List transactionList;
@@ -33,17 +30,13 @@ public class GuiBankTransaction extends Gui {
public GuiBankTransaction(SkyBlock plugin, Island island, Gui returnGui, boolean admin) {
super(returnGui);
- this.plugin = plugin;
- this.bankManager = plugin.getBankManager();
+ BankManager bankManager = plugin.getBankManager();
this.soundManager = plugin.getSoundManager();
this.transactionList = bankManager.getTransactions(island.getOwnerUUID());
this.transactions = this.transactionList.size();
this.returnGui = returnGui;
this.admin = admin;
- this.languageLoad = plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
- this.config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
-
+ this.languageLoad = plugin.getLanguage();
if(transactions == 0){
setRows(2);
} else if(transactions > 4*9){
diff --git a/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java b/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java
index 070d5a30..debc6904 100644
--- a/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java
+++ b/src/main/java/com/songoda/skyblock/gui/biome/BiomeIcon.java
@@ -22,8 +22,7 @@ public class BiomeIcon {
public BiomeIcon(SkyBlock plugin, CompatibleBiome biome){
this.biome = biome;
- FileConfiguration biomeConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(),"biomes.yml")).getFileConfiguration();
-
+ FileConfiguration biomeConfig = plugin.getBiomes();
CompatibleMaterial tempMat = CompatibleMaterial.getMaterial(biomeConfig.getString("Biomes." + biome.name() + ".DisplayItem.Material"));
if(tempMat == null){
tempMat = CompatibleMaterial.STONE;
diff --git a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java
index ffea945f..d44c5100 100644
--- a/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java
+++ b/src/main/java/com/songoda/skyblock/gui/biome/GuiBiome.java
@@ -33,11 +33,8 @@ public class GuiBiome extends Gui {
private final SkyBlock plugin;
private final Island island;
private final FileConfiguration languageLoad;
- private final FileConfiguration config;
- private final Gui returnGui;
private final Player player;
private final IslandWorld world;
- private final boolean admin;
public GuiBiome(SkyBlock plugin, Player player, Island island, IslandWorld world, Gui returnGui, boolean admin) {
super(6, returnGui);
@@ -45,9 +42,7 @@ public class GuiBiome extends Gui {
this.island = island;
this.world = world;
this.player = player;
- this.returnGui = returnGui;
- this.admin = admin;
- this.config = plugin.getFileManager()
+ FileConfiguration config = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
this.languageLoad = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
@@ -189,7 +184,7 @@ public class GuiBiome extends Gui {
}
cooldownManager.createPlayer(CooldownType.Biome, player);
Bukkit.getScheduler().runTask(plugin, () -> {
- biomeManager.setBiome(island, IslandWorld.Normal, icon.biome.getBiome(), () -> {
+ biomeManager.setBiome(island, IslandWorld.Normal, icon.biome, () -> {
if(languageLoad.getBoolean("Command.Island.Biome.Completed.Should-Display-Message")){
messageManager.sendMessage(player, languageLoad.getString("Command.Island.Biome.Completed.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F);
diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java
index fd5e6303..7311d538 100644
--- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java
+++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissions.java
@@ -48,7 +48,7 @@ public class GuiPermissions extends Gui {
this.returnGui = returnGui;
this.languageLoad = plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
- this.configLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
+ this.configLoad = this.plugin.getConfiguration();
setTitle(TextUtils.formatText(languageLoad.getString("Menu.Settings." + role.name() + ".Title")));
setDefaultItem(null);
paint();
diff --git a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java
index a8e75ff6..caabc0b9 100644
--- a/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java
+++ b/src/main/java/com/songoda/skyblock/gui/permissions/GuiPermissionsSelector.java
@@ -51,7 +51,7 @@ public class GuiPermissionsSelector extends Gui {
new GuiAdminPermissions(plugin, IslandRole.Operator, this) :
new GuiPermissions(plugin, player, island, IslandRole.Operator, this)));
- boolean isCoop = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ boolean isCoop = plugin.getConfiguration()
.getBoolean("Island.Coop.Enable");
setButton(0, GuiUtils.createButtonItem(CompatibleMaterial.OAK_FENCE_GATE,
diff --git a/src/main/java/com/songoda/skyblock/hologram/Hologram.java b/src/main/java/com/songoda/skyblock/hologram/Hologram.java
index 090c060e..b6e42ffa 100644
--- a/src/main/java/com/songoda/skyblock/hologram/Hologram.java
+++ b/src/main/java/com/songoda/skyblock/hologram/Hologram.java
@@ -9,8 +9,8 @@ import java.util.List;
public class Hologram {
- private HologramType type;
- private Location location;
+ private final HologramType type;
+ private final Location location;
public Hologram(HologramType type, Location location, List lines) {
this.type = type;
diff --git a/src/main/java/com/songoda/skyblock/invite/Invite.java b/src/main/java/com/songoda/skyblock/invite/Invite.java
index be7e66be..0b8bdea9 100644
--- a/src/main/java/com/songoda/skyblock/invite/Invite.java
+++ b/src/main/java/com/songoda/skyblock/invite/Invite.java
@@ -6,10 +6,10 @@ import java.util.UUID;
public class Invite {
- private UUID playerUUID;
- private UUID senderUUID;
+ private final UUID playerUUID;
+ private final UUID senderUUID;
private UUID islandOwnerUUID;
- private String senderName;
+ private final String senderName;
private int time;
public Invite(Player player, Player sender, UUID islandOwnerUUID, int time) {
diff --git a/src/main/java/com/songoda/skyblock/invite/InviteManager.java b/src/main/java/com/songoda/skyblock/invite/InviteManager.java
index ed62949c..a6652b27 100644
--- a/src/main/java/com/songoda/skyblock/invite/InviteManager.java
+++ b/src/main/java/com/songoda/skyblock/invite/InviteManager.java
@@ -9,7 +9,7 @@ import java.util.UUID;
public class InviteManager {
- private Map inviteStorage = new HashMap<>();
+ private final Map inviteStorage = new HashMap<>();
public InviteManager(SkyBlock plugin) {
new InviteTask(this, plugin).runTaskTimerAsynchronously(plugin, 0L, 20L);
diff --git a/src/main/java/com/songoda/skyblock/invite/InviteTask.java b/src/main/java/com/songoda/skyblock/invite/InviteTask.java
index 3ebafda2..83602474 100644
--- a/src/main/java/com/songoda/skyblock/invite/InviteTask.java
+++ b/src/main/java/com/songoda/skyblock/invite/InviteTask.java
@@ -32,8 +32,7 @@ public class InviteTask extends BukkitRunnable {
MessageManager messageManager = plugin.getMessageManager();
SoundManager soundManager = plugin.getSoundManager();
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = this.plugin.getLanguage();
for (Player all : Bukkit.getOnlinePlayers()) {
if (inviteManager.hasInvite(all.getUniqueId())) {
diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java
index e720c460..70407542 100644
--- a/src/main/java/com/songoda/skyblock/island/Island.java
+++ b/src/main/java/com/songoda/skyblock/island/Island.java
@@ -60,10 +60,8 @@ public class Island {
this.islandUUID = UUID.randomUUID();
this.ownerUUID = player.getUniqueId();
- this.size = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
- .getInt("Island.Size.Minimum");
- this.maxMembers = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
- .getInt("Island.Member.Capacity", 3);
+ this.size = this.plugin.getConfiguration().getInt("Island.Size.Minimum");
+ this.maxMembers = this.plugin.getConfiguration().getInt("Island.Member.Capacity", 3);
if (this.size > 1000) {
this.size = 50;
@@ -72,8 +70,7 @@ public class Island {
if (player.isOnline()) {
int customSize = PlayerUtils.getNumberFromPermission(player.getPlayer(), "fabledskyblock.size", 0);
if (customSize > 0 || player.getPlayer().hasPermission("fabledskyblock.*")) {
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = this.plugin.getConfiguration();
int minimumSize = configLoad.getInt("Island.Size.Minimum");
int maximumSize = configLoad.getInt("Island.Size.Maximum");
@@ -101,10 +98,8 @@ public class Island {
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
Config config = fileManager.getConfig(new File(configFile, ownerUUID + ".yml"));
- Config defaultSettingsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "settings.yml"));
- Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration mainConfigLoad = mainConfig.getFileConfiguration();
+ FileConfiguration mainConfigLoad = this.plugin.getConfiguration();
if (fileManager.isFileExist(new File(configFile, ownerUUID + ".yml"))) {
FileConfiguration configLoad = config.getFileConfiguration();
@@ -136,7 +131,7 @@ public class Island {
}
if (configLoad.getString("Border") == null) {
- configLoad.set("Border.Enable", mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Default", false));
+ configLoad.set("Border.Enable", mainConfigLoad.getBoolean("Island.WorldBorder.Default", false));
configLoad.set("Border.Color", WorldBorder.Color.Blue.name());
}
@@ -192,7 +187,7 @@ public class Island {
if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration()
.getString("Settings." + roleList.name() + "." + permission.getName()) == null) {
permissions.add(
- new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration()
+ new IslandPermission(permission, this.plugin.getSettings()
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
} else {
permissions.add(new IslandPermission(permission, settingsDataConfig.getFileConfiguration()
@@ -234,7 +229,7 @@ public class Island {
configLoad.set("UUID", islandUUID.toString());
configLoad.set("Visitor.Status", mainConfigLoad.getString("Island.Visitor.Status").toUpperCase());
- configLoad.set("Border.Enable", mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Default", false));
+ configLoad.set("Border.Enable", mainConfigLoad.getBoolean("Island.WorldBorder.Default", false));
configLoad.set("Border.Color", WorldBorder.Color.Blue.name());
configLoad.set("Biome.Type", mainConfigLoad.getString("Island.Biome.Default.Type").toUpperCase());
configLoad.set("Weather.Synchronised", mainConfigLoad.getBoolean("Island.Weather.Default.Synchronised")); // TODO: Synchronized
@@ -249,7 +244,7 @@ public class Island {
for (BasicPermission permission : allPermissions) {
permissions.add(
- new IslandPermission(permission, defaultSettingsConfig.getFileConfiguration()
+ new IslandPermission(permission, this.plugin.getSettings()
.getBoolean("Settings." + roleList.name() + "." + permission.getName(), true)));
}
@@ -311,10 +306,15 @@ public class Island {
.getFileConfiguration().getString("Ownership.Original"));
}
- public int getMaxMembers() {
- return maxMembers;
+ public int getMaxMembers(Player player) {
+ try {
+ return PlayerUtils.getNumberFromPermission(Objects.requireNonNull(player.getPlayer()), "fabledskyblock.members", maxMembers);
+ } catch (Exception ignored) {
+ return maxMembers;
+ }
}
+
public void setMaxMembers(int maxMembers) {
if (maxMembers > 100000 || maxMembers < 0) {
maxMembers = 2;
@@ -912,8 +912,7 @@ public class Island {
e.printStackTrace();
}
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
- .getBoolean("Island.Coop.Unload")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.Coop.Unload")) {
config = fileManager
.getConfig(new File(plugin.getDataFolder().toString() + "/coop-data", ownerUUID.toString() + ".yml"));
configLoad = config.getFileConfiguration();
@@ -941,8 +940,7 @@ public class Island {
FileManager fileManager = plugin.getFileManager();
SoundManager soundManager = plugin.getSoundManager();
MessageManager messageManager = plugin.getMessageManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = this.plugin.getConfiguration();
Config islandData = fileManager
.getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"),
ownerUUID.toString() + ".yml"));
@@ -955,9 +953,9 @@ public class Island {
unlocked = true;
}
- if (!unlocked) {
+ if (!unlocked && player != null) {
messageManager.sendMessage(player,
- fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration()
+ this.plugin.getLanguage()
.getString("Island.Unlock." + type.name() + ".Message").replace(
"%cost%", NumberUtil.formatNumberByDecimal(price)));
@@ -1005,4 +1003,10 @@ public class Island {
this.removeWhitelistedPlayer(player.getUniqueId());
}
+ @Override
+ public String toString() {
+ return "Island{" +
+ "ownerUUID=" + ownerUUID +
+ '}';
+ }
}
diff --git a/src/main/java/com/songoda/skyblock/island/IslandLevel.java b/src/main/java/com/songoda/skyblock/island/IslandLevel.java
index a054f6af..268a2d50 100644
--- a/src/main/java/com/songoda/skyblock/island/IslandLevel.java
+++ b/src/main/java/com/songoda/skyblock/island/IslandLevel.java
@@ -65,8 +65,7 @@ public class IslandLevel {
}
public long getPoints() {
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "levelling.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = this.plugin.getLevelling();
ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials");
@@ -104,9 +103,8 @@ public class IslandLevel {
break;
}
}
-
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "levelling.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+
+ FileConfiguration configLoad = this.plugin.getLevelling();
ConfigurationSection materialSection = configLoad.getConfigurationSection("Materials");
@@ -131,14 +129,14 @@ public class IslandLevel {
}
public long getLevel() {
- long division = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Division");
+ long division = this.plugin.getConfiguration().getLong("Island.Levelling.Division");
if (division == 0) {
division = 1;
}
long points = getPoints();
- long subtract = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getLong("Island.Levelling.Subtract");
+ long subtract = this.plugin.getConfiguration().getLong("Island.Levelling.Subtract");
if(points >= subtract){
points -= subtract;
} else {
@@ -156,8 +154,8 @@ public class IslandLevel {
if (level <= highestLevel)
return;
- final FileConfiguration language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
- final FileConfiguration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
+ final FileConfiguration language = this.plugin.getLanguage();
+ final FileConfiguration config = this.plugin.getConfiguration();
OfflinePlayer owner = Bukkit.getOfflinePlayer(ownerUUID);
diff --git a/src/main/java/com/songoda/skyblock/island/IslandLocation.java b/src/main/java/com/songoda/skyblock/island/IslandLocation.java
index 510ba4e3..d7892932 100644
--- a/src/main/java/com/songoda/skyblock/island/IslandLocation.java
+++ b/src/main/java/com/songoda/skyblock/island/IslandLocation.java
@@ -5,8 +5,8 @@ import org.bukkit.Location;
public class IslandLocation {
- private IslandWorld world;
- private IslandEnvironment environment;
+ private final IslandWorld world;
+ private final IslandEnvironment environment;
private double x;
private double y;
diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java
index 7692cd62..ab9261b2 100644
--- a/src/main/java/com/songoda/skyblock/island/IslandManager.java
+++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java
@@ -47,7 +47,6 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.*;
-import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
@@ -80,17 +79,14 @@ public class IslandManager {
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "worlds.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
- offset = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getInt("Island.Creation.Distance", 1200);
+ offset = plugin.getConfiguration().getInt("Island.Creation.Distance", 1200);
for (IslandWorld worldList : IslandWorld.values()) {
ConfigurationSection configSection = configLoad.getConfigurationSection("World." + worldList.name() + ".nextAvailableLocation");
islandPositions.add(new IslandPosition(worldList, configSection.getDouble("x"), configSection.getDouble("z")));
}
- for (Player all : Bukkit.getOnlinePlayers()) {
- loadIsland(all);
- }
+ Bukkit.getOnlinePlayers().forEach(this::loadIsland);
for (Island island : getIslands().values()) {
if (island.isAlwaysLoaded())
loadIslandAtLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Island));
@@ -144,10 +140,9 @@ public class IslandManager {
if (islandPositionList.getWorld() == world) {
Config config_world = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "worlds.yml"));
- Config config_config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
FileConfiguration configLoad_world = config_world.getFileConfiguration();
- FileConfiguration configLoad_config = config_config.getFileConfiguration();
+ FileConfiguration configLoad_config = plugin.getConfiguration();
int x = (int) configLoad_world.get("World." + world.name() + ".nextAvailableLocation.island_number");
int islandHeight = configLoad_config.getInt("Island.World." + world.name() + ".IslandSpawnHeight", 72);
while (true) {
@@ -215,13 +210,13 @@ public class IslandManager {
final int highest = PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.create", true, 2);
if ((amt = data.getIslandCreationCount()) >= highest) {
- plugin.getMessageManager().sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.MaxCreationMessage"));
+ plugin.getLanguage().getString("Island.Creator.Error.MaxCreationMessage");
return false;
}
}
if (fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml")).getFileConfiguration().getString("Location.Spawn") == null) {
- plugin.getMessageManager().sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.Message"));
+ plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.Creator.Error.Message"));
plugin.getSoundManager().playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return false;
@@ -247,8 +242,7 @@ public class IslandManager {
if (!banManager.hasIsland(island.getOwnerUUID())) banManager.createIsland(island.getOwnerUUID());
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = this.plugin.getConfiguration();
if (configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable") && !player.hasPermission("fabledskyblock.bypass.cooldown") && !player.hasPermission("fabledskyblock.bypass.*")
&& !player.hasPermission("fabledskyblock.*"))
@@ -271,17 +265,17 @@ public class IslandManager {
player.setFallDistance(0.0F);
}, configLoad.getInt("Island.Creation.TeleportTimeout") * 20);
- String biomeName = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Biome.Default.Type").toUpperCase();
+ String biomeName = this.plugin.getConfiguration().getString("Island.Biome.Default.Type").toUpperCase();
CompatibleBiome cBiome;
try {
cBiome = CompatibleBiome.valueOf(biomeName);
} catch (Exception ex) {
cBiome = CompatibleBiome.PLAINS;
}
- Biome biome = cBiome.getBiome();
+ final CompatibleBiome compatibleBiome = cBiome;
Bukkit.getServer().getScheduler().runTaskLater(plugin, () ->
- plugin.getBiomeManager().setBiome(island, IslandWorld.Normal, biome, () -> {
+ plugin.getBiomeManager().setBiome(island, IslandWorld.Normal, compatibleBiome, () -> {
if (structure.getCommands() != null) {
for (String commandList : structure.getCommands()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName()));
@@ -300,17 +294,15 @@ public class IslandManager {
FileManager fileManager = plugin.getFileManager();
PlayerData data = plugin.getPlayerDataManager().getPlayerData(player);
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLang = config.getFileConfiguration();
- config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configMain = config.getFileConfiguration();
+ FileConfiguration configLang = plugin.getLanguage();
+ FileConfiguration configMain = plugin.getConfiguration();
if (data != null) {
final int highest = PlayerUtil.getNumberFromPermission(player, "fabledskyblock.limit.create", true, 2);
if ((data.getIslandCreationCount()) >= highest) {
- plugin.getMessageManager().sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Creator.Error.MaxCreationMessage"));
+ plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.Creator.Error.MaxCreationMessage"));
return false;
}
@@ -427,8 +419,7 @@ public class IslandManager {
level.save();
level.setOwnerUUID(player.getUniqueId());
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Ownership.Password.Reset")) {
island.setPassword(null);
@@ -465,7 +456,7 @@ public class IslandManager {
fileManager.unloadConfig(newIslandDataFile);
oldIslandDataFile.renameTo(newIslandDataFile);
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)){
File oldChallengeDataFile = new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), uuid2.toString() + ".yml");
File newChallengeDataFile = new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), player.getUniqueId().toString() + ".yml");
@@ -555,7 +546,11 @@ public class IslandManager {
}
}
- startDeletion(island, worldManager);
+ FileConfiguration configLoad = plugin.getConfiguration();
+
+ if (configLoad.getBoolean("Island.Deletion.DeleteIsland", true)) {
+ startDeletion(island, worldManager);
+ }
plugin.getVisitManager().deleteIsland(island.getOwnerUUID());
plugin.getBanManager().deleteIsland(island.getOwnerUUID());
@@ -565,9 +560,6 @@ public class IslandManager {
cooldownManager.removeCooldownPlayer(CooldownType.Levelling, offlinePlayer);
cooldownManager.removeCooldownPlayer(CooldownType.Ownership, offlinePlayer);
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
-
boolean cooldownCreationEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Creation.Enable");
boolean cooldownDeletionEnabled = configLoad.getBoolean("Island.Creation.Cooldown.Deletion.Enable");
@@ -621,7 +613,7 @@ public class IslandManager {
fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/level-data"), island.getOwnerUUID().toString() + ".yml"));
fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID().toString() + ".yml"));
fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID().toString() + ".yml"));
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)){
fileManager.deleteConfig(new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID().toString() + ".yml"));
}
@@ -663,7 +655,7 @@ public class IslandManager {
fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/level-data", FastUUID.toString(uuid) + ".yml"));
fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/setting-data", FastUUID.toString(uuid) + ".yml"));
fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/visit-data", FastUUID.toString(uuid) + ".yml"));
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)){
fileManager.deleteConfig(new File(plugin.getDataFolder().toString() + "/challenge-data", FastUUID.toString(uuid) + ".yml"));
}
@@ -742,14 +734,14 @@ public class IslandManager {
try {
UUID islandOwnerUUID = FastUUID.parseUUID(file.getName().split("\\.")[0]);
- Island island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID));
+ Island island = getIslandByOwner(Bukkit.getOfflinePlayer(islandOwnerUUID));
if(island != null) {
island.setSize(island.getSize() + diff);
island.save();
} else {
loadIsland(file);
- island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID));
+ island = getIslandByOwner(Bukkit.getOfflinePlayer(islandOwnerUUID));
island.setSize(island.getSize() + diff);
island.save();
@@ -779,14 +771,14 @@ public class IslandManager {
try {
UUID islandOwnerUUID = FastUUID.parseUUID(file.getName().split("\\.")[0]);
- Island island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID));
+ Island island = getIslandByOwner(Bukkit.getOfflinePlayer(islandOwnerUUID));
if(island != null) {
island.setSize(size);
island.save();
} else {
loadIsland(file);
- island = getIslandByPlayer(Bukkit.getOfflinePlayer(islandOwnerUUID));
+ island = getIslandByOwner(Bukkit.getOfflinePlayer(islandOwnerUUID));
island.setSize(size);
island.save();
@@ -929,9 +921,6 @@ public class IslandManager {
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
FileManager fileManager = plugin.getFileManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
-
if (island.isDeleted()) return;
island.save();
@@ -958,7 +947,7 @@ public class IslandManager {
return;
}
- unloadIsland = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Unload");
+ unloadIsland = this.plugin.getConfiguration().getBoolean("Island.Visitor.Unload");
if (unloadIsland) {
VisitManager visitManager = plugin.getVisitManager();
@@ -985,7 +974,7 @@ public class IslandManager {
fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/setting-data"), island.getOwnerUUID() + ".yml"));
fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), island.getOwnerUUID() + ".yml"));
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", true)){
fileManager.unloadConfig(new File(new File(plugin.getDataFolder().toString() + "/challenge-data"), island.getOwnerUUID() + ".yml"));
}
@@ -1059,7 +1048,7 @@ public class IslandManager {
}
}
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
+ if (this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) {
Bukkit.getServer().getScheduler().runTask(plugin, () -> islandLocation.clone().subtract(0.0D, 1.0D, 0.0D).getBlock().setType(Material.STONE));
}
@@ -1116,7 +1105,7 @@ public class IslandManager {
pasteStructure(island, islandWorld);
// Recalculate island level after 5 seconds
- if (fileManager.getConfig(new File(this.plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) {
+ if (plugin.getConfiguration().getBoolean("Island.Levelling.ScanAutomatically")) {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> plugin.getLevellingManager().startScan(null, island), 100L);
}
}
@@ -1137,8 +1126,7 @@ public class IslandManager {
boolean unlocked = configLoadIslandData.getBoolean("Unlocked." + islandWorld.name());
if (!unlocked) {
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
double price = configLoad.getDouble("Island.World." + islandWorld.name() + ".UnlockPrice");
if (price == -1) unlocked = true;
}
@@ -1168,10 +1156,7 @@ public class IslandManager {
public void visitIsland(Player player, Island island) {
ScoreboardManager scoreboardManager = plugin.getScoreboardManager();
- FileManager fileManager = plugin.getFileManager();
-
- Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = languageConfig.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
@@ -1181,9 +1166,7 @@ public class IslandManager {
player.setFallDistance(0.0F);
}
} else {
- player.sendMessage(ChatColor.translateAlternateColorCodes('&',
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Island.Teleport.Unsafe.Message")));
+ player.sendMessage(plugin.formatText(plugin.getLanguage().getString("Island.Teleport.Unsafe.Message")));
}
} else {
int islandVisitors = getVisitorsAtIsland(island).size();
@@ -1201,8 +1184,7 @@ public class IslandManager {
}
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor);
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
- if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
+ if(plugin.getConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
Location safeLoc = LocationUtil.getSafeLocation(loc);
if (safeLoc != null) {
loc = safeLoc;
@@ -1215,9 +1197,7 @@ public class IslandManager {
player.setFallDistance(0.0F);
}
} else {
- player.sendMessage(ChatColor.translateAlternateColorCodes('&',
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message")));
+ player.sendMessage(plugin.formatText(plugin.getLanguage().getString("Command.Island.Teleport.Unsafe.Message")));
}
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
@@ -1225,7 +1205,7 @@ public class IslandManager {
List islandWelcomeMessage = island.getMessage(IslandMessage.Welcome);
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Welcome.Enable") && islandWelcomeMessage.size() != 0) {
+ if (this.plugin.getConfiguration().getBoolean("Island.Visitor.Welcome.Enable") && islandWelcomeMessage.size() != 0) {
for (String islandWelcomeMessageList : islandWelcomeMessage) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', islandWelcomeMessageList));
}
@@ -1237,9 +1217,7 @@ public class IslandManager {
public void closeIsland(Island island) {
MessageManager messageManager = plugin.getMessageManager();
-
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
island.setStatus(IslandStatus.CLOSED);
@@ -1264,9 +1242,7 @@ public class IslandManager {
public void whitelistIsland(Island island) {
MessageManager messageManager = plugin.getMessageManager();
-
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
island.setStatus(IslandStatus.WHITELISTED);
@@ -1461,8 +1437,7 @@ public class IslandManager {
Island island = getIslandAtLocation(player.getLocation());
if (island != null) {
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (!island.isWeatherSynchronized()) {
player.setPlayerTime(island.getTime(), configLoad.getBoolean("Island.Weather.Time.Cycle"));
@@ -1556,8 +1531,7 @@ public class IslandManager {
MessageManager messageManager = plugin.getMessageManager();
SoundManager soundManager = plugin.getSoundManager();
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
boolean coopPlayers = island.hasPermission(IslandRole.Operator, plugin.getPermissionManager().getPermission("CoopPlayers"));
@@ -1595,8 +1569,7 @@ public class IslandManager {
}
public int getIslandSafeLevel(Island island) {
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
int safeLevel = 0;
@@ -1620,7 +1593,7 @@ public class IslandManager {
WorldManager worldManager = plugin.getWorldManager();
if (island.isBorder()) {
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
+ if (this.plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable")) {
double increment = island.getSize() % 2 != 0 ? 0.5d : 0.0d;
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
@@ -1716,7 +1689,7 @@ public class IslandManager {
return false;
}
- public Island getIslandByPlayer(org.bukkit.OfflinePlayer player) {
+ public Island getIslandByOwner(org.bukkit.OfflinePlayer player) {
if (islandStorage.containsKey(player.getUniqueId())) {
return islandStorage.get(player.getUniqueId());
}
diff --git a/src/main/java/com/songoda/skyblock/island/IslandPosition.java b/src/main/java/com/songoda/skyblock/island/IslandPosition.java
index ce67ed2c..7439f15c 100644
--- a/src/main/java/com/songoda/skyblock/island/IslandPosition.java
+++ b/src/main/java/com/songoda/skyblock/island/IslandPosition.java
@@ -2,7 +2,7 @@ package com.songoda.skyblock.island;
public class IslandPosition {
- private IslandWorld world;
+ private final IslandWorld world;
private double x;
private double z;
diff --git a/src/main/java/com/songoda/skyblock/island/reward/RewardManager.java b/src/main/java/com/songoda/skyblock/island/reward/RewardManager.java
index 241e5343..66375178 100644
--- a/src/main/java/com/songoda/skyblock/island/reward/RewardManager.java
+++ b/src/main/java/com/songoda/skyblock/island/reward/RewardManager.java
@@ -21,8 +21,7 @@ public class RewardManager {
}
public void loadRewards() {
- final Config config = skyBlock.getFileManager().getConfig(new File(skyBlock.getDataFolder(), "rewards.yml"));
- final FileConfiguration configLoad = config.getFileConfiguration();
+ final FileConfiguration configLoad = skyBlock.getRewards();
this.registeredRewards.clear();
this.repeatRewards.clear();
@@ -59,7 +58,7 @@ public class RewardManager {
}
private LevelReward loadReward(String path) {
- final FileConfiguration config = skyBlock.getFileManager().getConfig(new File(skyBlock.getDataFolder(), "rewards.yml")).getFileConfiguration();
+ final FileConfiguration config = this.skyBlock.getRewards();
ConfigurationSection section = config.getConfigurationSection(path);
diff --git a/src/main/java/com/songoda/skyblock/leaderboard/Leaderboard.java b/src/main/java/com/songoda/skyblock/leaderboard/Leaderboard.java
index c51f3480..9ed1fe4b 100644
--- a/src/main/java/com/songoda/skyblock/leaderboard/Leaderboard.java
+++ b/src/main/java/com/songoda/skyblock/leaderboard/Leaderboard.java
@@ -5,8 +5,8 @@ import com.songoda.skyblock.visit.Visit;
public class Leaderboard {
private final Visit visit;
- private Type type;
- private int position;
+ private final Type type;
+ private final int position;
public Leaderboard(Type type, Visit visit, int position) {
this.type = type;
diff --git a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java
index 4ad7b286..c0fafa72 100644
--- a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java
+++ b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardManager.java
@@ -19,13 +19,13 @@ public class LeaderboardManager {
private final SkyBlock plugin;
- private List leaderboardStorage = new ArrayList<>();
+ private final List leaderboardStorage = new ArrayList<>();
public LeaderboardManager(SkyBlock plugin) {
this.plugin = plugin;
new LeaderboardTask(plugin).runTaskTimerAsynchronously(plugin, 0L,
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getInt("Island.Leaderboard.Reset.Time") * 20);
+ this.plugin.getConfiguration().getInt("Island.Leaderboard.Reset.Time") * 20);
resetLeaderboard();
setupLeaderHeads();
@@ -43,7 +43,7 @@ public class LeaderboardManager {
List islandBanks = new ArrayList<>(arraySize);
List islandVotes = new ArrayList<>(arraySize);
- boolean enableExemptions = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ boolean enableExemptions = this.plugin.getConfiguration()
.getBoolean("Island.Leaderboard.Exemptions.Enable");
for (UUID ownerUUID : new LinkedHashSet<>(visitManager.getIslands().keySet())) {
diff --git a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardPlayer.java b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardPlayer.java
index 72167f25..986f2f38 100644
--- a/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardPlayer.java
+++ b/src/main/java/com/songoda/skyblock/leaderboard/LeaderboardPlayer.java
@@ -4,8 +4,8 @@ import java.util.UUID;
public class LeaderboardPlayer {
- private UUID uuid;
- private long value;
+ private final UUID uuid;
+ private final long value;
public LeaderboardPlayer(UUID uuid, long value) {
this.uuid = uuid;
diff --git a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopLevel.java b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopLevel.java
index e4f14baa..e8c1e9fb 100644
--- a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopLevel.java
+++ b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopLevel.java
@@ -28,8 +28,7 @@ public class TopLevel extends DataCollector {
List leaderboards = plugin.getLeaderboardManager().getLeaderboard(Leaderboard.Type.Level);
Map topLevels = new HashMap<>(leaderboards.size());
- for (int i = 0; i < leaderboards.size(); i++) {
- Leaderboard leaderboard = leaderboards.get(i);
+ for (Leaderboard leaderboard : leaderboards) {
Visit visit = leaderboard.getVisit();
topLevels.put(visit.getOwnerUUID(), (double) visit.getLevel().getLevel());
}
diff --git a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopVotes.java b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopVotes.java
index f2a27e40..af9d7357 100644
--- a/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopVotes.java
+++ b/src/main/java/com/songoda/skyblock/leaderboard/leaderheads/TopVotes.java
@@ -30,9 +30,8 @@ public class TopVotes extends DataCollector {
List leaderboards = plugin.getLeaderboardManager().getLeaderboard(Type.Votes);
Map topLevels = new HashMap<>(leaderboards.size());
-
- for (int i = 0; i < leaderboards.size(); i++) {
- Leaderboard leaderboard = leaderboards.get(i);
+
+ for (Leaderboard leaderboard : leaderboards) {
Visit visit = leaderboard.getVisit();
topLevels.put(visit.getOwnerUUID(), (double) visit.getVoters().size());
}
diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java
index 2899e42d..3af0b66f 100644
--- a/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java
+++ b/src/main/java/com/songoda/skyblock/levelling/IslandLevelManager.java
@@ -6,6 +6,7 @@ import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.blockscanner.BlockInfo;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandLevel;
+import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.levelling.amount.AmountMaterialPair;
import com.songoda.skyblock.levelling.calculator.Calculator;
import com.songoda.skyblock.levelling.calculator.CalculatorRegistry;
@@ -21,6 +22,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
@@ -29,8 +31,8 @@ import java.util.*;
import java.util.Map.Entry;
public final class IslandLevelManager {
-
- private final Map inScan;
+
+ private final Map inScan;
private final Map worth;
private final Map cachedPairs;
private final SkyBlock plugin;
@@ -44,7 +46,7 @@ public final class IslandLevelManager {
reloadWorth();
}
- public void startScan(Player attemptScanner, Island island){
+ public void startScan(Player attemptScanner, Island island) {
if (!Bukkit.isPrimaryThread()) {
Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> startScan(attemptScanner, island));
return;
@@ -52,7 +54,7 @@ public final class IslandLevelManager {
if (island == null) throw new IllegalArgumentException("island cannot be null");
- Configuration config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration();
+ Configuration config = SkyBlock.getInstance().getLanguage();
MessageManager messageManager = SkyBlock.getInstance().getMessageManager();
if (inScan.containsKey(island)) {
@@ -70,7 +72,17 @@ public final class IslandLevelManager {
messageManager.sendMessage(attemptScanner, config.getString("Command.Island.Level.Scanning.Started.Message"));
}
- inScan.put(island, new IslandScan(plugin, island).start());
+ QueuedIslandScan queuedIslandScan = new QueuedIslandScan(plugin, island);
+
+ queuedIslandScan.addToScan(IslandWorld.Normal);
+ if (island.isRegionUnlocked(null, IslandWorld.Nether))
+ queuedIslandScan.addToScan(IslandWorld.Nether);
+ if (island.isRegionUnlocked(null, IslandWorld.End))
+ queuedIslandScan.addToScan(IslandWorld.End);
+
+ queuedIslandScan.scan();
+
+ inScan.put(island, queuedIslandScan);
}
public boolean isScanning(Island island) {
@@ -79,17 +91,18 @@ public final class IslandLevelManager {
void stopScan(Island island) {
- final IslandScan scan = inScan.get(island);
+ final QueuedIslandScan queuedIslandScan = inScan.get(island);
- if (scan == null) return;
+ if (queuedIslandScan == null) return;
- inScan.remove(island);
+ if (!queuedIslandScan.scan())
+ inScan.remove(island);
}
public void reloadWorth() {
worth.clear();
- final Configuration config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "levelling.yml")).getFileConfiguration();
+ final Configuration config = SkyBlock.getInstance().getLevelling();
final ConfigurationSection materialSection = config.getConfigurationSection("Materials");
if (materialSection == null) return;
@@ -102,7 +115,7 @@ public final class IslandLevelManager {
if (material == null) continue;
- worth.put(material, current.getDouble("Points"));
+ worth.put(material, current.getDouble("Points", 0.0));
}
}
@@ -141,8 +154,10 @@ public final class IslandLevelManager {
final CompatibleMaterial spawner = CompatibleMaterial.SPAWNER;
final PluginManager pm = Bukkit.getPluginManager();
- if (pm.isPluginEnabled("EpicSpawners")) CalculatorRegistry.registerCalculator(new EpicSpawnerCalculator(), spawner);
- if (pm.isPluginEnabled("UltimateStacker")) CalculatorRegistry.registerCalculator(new UltimateStackerCalculator(), spawner);
+ if (pm.isPluginEnabled("EpicSpawners"))
+ CalculatorRegistry.registerCalculator(new EpicSpawnerCalculator(), spawner);
+ if (pm.isPluginEnabled("UltimateStacker"))
+ CalculatorRegistry.registerCalculator(new UltimateStackerCalculator(), spawner);
}
private static final AmountMaterialPair EMPTY = new AmountMaterialPair(null, 0);
@@ -206,7 +221,7 @@ public final class IslandLevelManager {
return new AmountMaterialPair(compMaterial, amount + stackSize);
}
-
+
public void updateLevel(Island island, Location location) {
// Fix a bug in Paper 1.8.8 when using ViaVersion on a 1.12.2 client.
// BUG: Player can infinitely increase their level by placing a block at their
@@ -218,7 +233,7 @@ public final class IslandLevelManager {
// placed.
// This shouldn't cause any issues besides the task number being increased
// insanely fast.
- if(ServerVersion.isServerVersion(ServerVersion.V1_8)){
+ if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
Bukkit.getScheduler().runTask(plugin, () -> {
updateLevelLocation(island, location);
});
@@ -226,11 +241,11 @@ public final class IslandLevelManager {
updateLevelLocation(island, location);
}
}
-
+
private void updateLevelLocation(Island island, Location location) {
Block block = location.getBlock();
CompatibleMaterial material = null;
- if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
+ if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
switch (block.getType().toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@@ -238,30 +253,30 @@ public final class IslandLevelManager {
break;
}
}
- if(material == null) {
+ if (material == null) {
material = CompatibleMaterial.getMaterial(block);
}
-
+
if (material == null || material == CompatibleMaterial.AIR) return;
-
+
if (material == CompatibleMaterial.SPAWNER) {
if (Bukkit.getPluginManager().isPluginEnabled("EpicSpawners") ||
Bukkit.getPluginManager().isPluginEnabled("UltimateStacker") ||
Bukkit.getPluginManager().isPluginEnabled("WildStacker"))
return;
-
+
CompatibleSpawners spawner = CompatibleSpawners.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
-
+
if (spawner != null)
material = CompatibleMaterial.getBlockMaterial(spawner.getMaterial());
}
-
+
long materialAmount = 0;
IslandLevel level = island.getLevel();
-
+
if (level.hasMaterial(material.name()))
materialAmount = level.getMaterialAmount(material.name());
-
+
level.setMaterialAmount(material.name(), materialAmount + 1);
}
}
diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java
index 9f8f84cb..c9b683fb 100644
--- a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java
+++ b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java
@@ -28,10 +28,10 @@ import java.util.Map.Entry;
public final class IslandScan extends BukkitRunnable {
- private static final NumberFormat FORMATTER = NumberFormat.getInstance();
private final Set doubleBlocks;
private final Island island;
+ private final IslandWorld world;
private final Map amounts;
private final Configuration language;
private final int runEveryX;
@@ -41,12 +41,13 @@ public final class IslandScan extends BukkitRunnable {
private int blocksSize;
private Queue blocks;
- public IslandScan(SkyBlock plugin, Island island) {
+ public IslandScan(SkyBlock plugin, Island island, IslandWorld world) {
if (island == null) throw new IllegalArgumentException("island cannot be null");
this.plugin = plugin;
this.island = island;
+ this.world = world;
this.amounts = new EnumMap<>(CompatibleMaterial.class);
- this.language = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration();
+ this.language = this.plugin.getLanguage();
this.runEveryX = language.getInt("Command.Island.Level.Scanning.Progress.Display-Every-X-Scan");
this.doubleBlocks = new HashSet<>();
}
@@ -54,7 +55,7 @@ public final class IslandScan extends BukkitRunnable {
public IslandScan start() {
final SkyBlock plugin = SkyBlock.getInstance();
- final FileConfiguration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
+ final FileConfiguration config = this.plugin.getConfiguration();
final FileConfiguration islandData = plugin.getFileManager().getConfig(new File(new File(plugin.getDataFolder().toString() + "/island-data"), this.island.getOwnerUUID().toString() + ".yml")).getFileConfiguration();
final boolean hasNether = config.getBoolean("Island.World.Nether.Enable") && islandData.getBoolean("Unlocked.Nether", false);
@@ -65,64 +66,29 @@ public final class IslandScan extends BukkitRunnable {
if (plugin.isPaperAsync()) {
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
- initScan(plugin, hasNether, hasEnd, snapshots);
+ initScan(plugin);
});
} else {
- initScan(plugin, hasNether, hasEnd, snapshots);
+ initScan(plugin);
}
return this;
}
- private void initScan(SkyBlock plugin, boolean hasNether, boolean hasEnd, Map> snapshots) {
- populate(snapshots, IslandWorld.Normal, plugin.isPaperAsync(), () -> {
+ private void initScan(SkyBlock plugin) {
- if (hasNether) {
- populate(snapshots, IslandWorld.Nether, plugin.isPaperAsync(), () -> {
- if (hasEnd) {
- populate(snapshots, IslandWorld.End, plugin.isPaperAsync(), () -> {
- BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> {
- this.blocks = blocks;
- this.blocksSize = blocks.size();
- this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
- });
- });
- } else {
- BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> {
- this.blocks = blocks;
- this.blocksSize = blocks.size();
- this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
- });
- }
- });
- } else {
- BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> {
- this.blocks = blocks;
- this.blocksSize = blocks.size();
- this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
- });
- }
+ final Map> snapshots = new HashMap<>(3);
+
+ populate(snapshots, plugin.isPaperAsync(), () -> {
+ BlockScanner.startScanner(snapshots, island, true, true, true, false, (blocks) -> {
+ this.blocks = blocks;
+ this.blocksSize = blocks.size();
+ this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
+ });
});
}
- private void finalizeBlocks() {
-
- final Map materials = new HashMap<>(amounts.size());
-
- for (Entry entry : amounts.entrySet()) {
- materials.put(entry.getKey().name(), entry.getValue().getAmount());
- }
-
- final IslandLevel level = island.getLevel();
-
- level.setMaterials(materials);
- level.setLastCalculatedLevel(level.getLevel());
- level.setLastCalculatedPoints(level.getPoints());
-
- Bukkit.getServer().getPluginManager().callEvent(new IslandLevelChangeEvent(island.getAPIWrapper(), island.getAPIWrapper().getLevel()));
- }
-
private int executions;
@Override
@@ -159,54 +125,22 @@ public final class IslandScan extends BukkitRunnable {
totalScanned += scanned;
if (blocks.isEmpty()) {
- finalizeBlocks();
cancel();
SkyBlock.getInstance().getLevellingManager().stopScan(island);
}
-
- Bukkit.getScheduler().runTask(plugin, () -> {
- if (language.getBoolean("Command.Island.Level.Scanning.Progress.Should-Display-Message") && executions == 1 || totalScanned == blocksSize || executions % runEveryX == 0) {
-
- double percent = ((double) totalScanned / (double) blocksSize) * 100;
-
- if(Double.isNaN(percent)) {
- percent = 0d;
- }
-
- String message = language.getString("Command.Island.Level.Scanning.Progress.Message");
- message = message.replace("%current_scanned_blocks%", String.valueOf(totalScanned));
- message = message.replace("%max_blocks%", String.valueOf(blocksSize));
- message = message.replace("%percent_whole%", String.valueOf((int) percent));
- message = message.replace("%percent%", FORMATTER.format(percent));
-
- final boolean displayComplete = totalScanned == blocksSize && language.getBoolean("Command.Island.Level.Scanning.Finished.Should-Display-Message");
- final MessageManager messageManager = SkyBlock.getInstance().getMessageManager();
-
- for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) {
-
- messageManager.sendMessage(player, message);
- if (displayComplete)
- messageManager.sendMessage(player, language.getString("Command.Island.Level.Scanning.Finished.Message"));
-
- // Check for level ups
- island.getLevel().checkLevelUp();
- }
- }
- });
}
- private void populate(Map> snapshots, IslandWorld world, boolean paper, PopulateTask task) {
+ private void populate(Map> snapshots, boolean paper, PopulateTask task) {
final SkyBlock plugin = SkyBlock.getInstance();
-
List positions = new LinkedList<>();
-
- ChunkLoader.startChunkLoadingPerChunk(island, IslandWorld.Normal, paper, (chunkCompletableFuture) ->
- positions.add(chunkCompletableFuture.join().getChunkSnapshot()),
+
+ ChunkLoader.startChunkLoadingPerChunk(island, world, paper, (chunkCompletableFuture) ->
+ positions.add(chunkCompletableFuture.join().getChunkSnapshot()),
value -> {
- snapshots.put(plugin.getWorldManager().getWorld(world), positions);
- task.onComplete();
- });
+ snapshots.put(plugin.getWorldManager().getWorld(world), positions);
+ task.onComplete();
+ });
}
private interface PopulateTask {
@@ -217,4 +151,19 @@ public final class IslandScan extends BukkitRunnable {
return doubleBlocks;
}
+ public Map getAmounts() {
+ return Collections.unmodifiableMap(amounts);
+ }
+
+ public int getTotalScanned() {
+ return totalScanned;
+ }
+
+ public int getBlocksSize() {
+ return blocksSize;
+ }
+
+ public int getExecutions() {
+ return executions;
+ }
}
diff --git a/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java b/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java
index 693f1c03..513acdfe 100644
--- a/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java
+++ b/src/main/java/com/songoda/skyblock/levelling/LevellingMaterial.java
@@ -7,7 +7,7 @@ import org.bukkit.inventory.ItemStack;
public final class LevellingMaterial {
- private CompatibleMaterial materials;
+ private final CompatibleMaterial materials;
private double points;
public LevellingMaterial(CompatibleMaterial materials, double points) {
diff --git a/src/main/java/com/songoda/skyblock/levelling/QueuedIslandScan.java b/src/main/java/com/songoda/skyblock/levelling/QueuedIslandScan.java
new file mode 100644
index 00000000..77f4793d
--- /dev/null
+++ b/src/main/java/com/songoda/skyblock/levelling/QueuedIslandScan.java
@@ -0,0 +1,112 @@
+package com.songoda.skyblock.levelling;
+
+import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.skyblock.SkyBlock;
+import com.songoda.skyblock.api.event.island.IslandLevelChangeEvent;
+import com.songoda.skyblock.island.Island;
+import com.songoda.skyblock.island.IslandLevel;
+import com.songoda.skyblock.island.IslandWorld;
+import com.songoda.skyblock.levelling.amount.BlockAmount;
+import com.songoda.skyblock.message.MessageManager;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.Configuration;
+import org.bukkit.entity.Player;
+
+import java.io.File;
+import java.text.NumberFormat;
+import java.util.*;
+
+public class QueuedIslandScan {
+
+ private final SkyBlock plugin;
+ private final Island island;
+ private IslandScan currentScan = null;
+ private final Queue toScan = new LinkedList<>();
+
+ private static final NumberFormat FORMATTER = NumberFormat.getInstance();
+ private final Configuration language;
+
+ private int executions;
+ private final int runEveryX;
+ private final Map amounts = new EnumMap<>(CompatibleMaterial.class);
+ private int totalScanned;
+ private int blocksSize;
+
+ public QueuedIslandScan(SkyBlock plugin, Island island) {
+ this.plugin = plugin;
+ this.island = island;
+ this.language = plugin.getLanguage();
+ this.runEveryX = language.getInt("Command.Island.Level.Scanning.Progress.Display-Every-X-Scan");
+ }
+
+ public void addToScan(IslandWorld world) {
+ toScan.add(world);
+ }
+
+ public void update() {
+ this.executions += currentScan.getExecutions();
+ this.totalScanned += currentScan.getTotalScanned();
+ this.blocksSize += currentScan.getBlocksSize();
+ this.amounts.putAll(currentScan.getAmounts());
+ }
+
+ public boolean scan() {
+ if (currentScan != null)
+ update();
+
+ if (toScan.isEmpty()) {
+ finalize();
+ return false;
+ }
+ IslandWorld world = toScan.poll();
+ currentScan = new IslandScan(plugin, island, world).start();
+ return true;
+ }
+
+ public void finalize() {
+
+ final Map materials = new HashMap<>(amounts.size());
+
+ for (Map.Entry entry : amounts.entrySet()) {
+ materials.put(entry.getKey().name(), entry.getValue().getAmount());
+ }
+
+ final IslandLevel level = island.getLevel();
+
+ level.setMaterials(materials);
+ level.setLastCalculatedLevel(level.getLevel());
+ level.setLastCalculatedPoints(level.getPoints());
+
+ Bukkit.getServer().getPluginManager().callEvent(new IslandLevelChangeEvent(island.getAPIWrapper(), island.getAPIWrapper().getLevel()));
+
+ Bukkit.getScheduler().runTask(plugin, () -> {
+ if (language.getBoolean("Command.Island.Level.Scanning.Progress.Should-Display-Message") && executions == 1 || totalScanned == blocksSize || executions % runEveryX == 0) {
+
+ double percent = ((double) totalScanned / (double) blocksSize) * 100;
+
+ if (Double.isNaN(percent)) {
+ percent = 0d;
+ }
+
+ String message = language.getString("Command.Island.Level.Scanning.Progress.Message");
+ message = message.replace("%current_scanned_blocks%", String.valueOf(totalScanned));
+ message = message.replace("%max_blocks%", String.valueOf(blocksSize));
+ message = message.replace("%percent_whole%", String.valueOf((int) percent));
+ message = message.replace("%percent%", FORMATTER.format(percent));
+
+ final boolean displayComplete = totalScanned == blocksSize && language.getBoolean("Command.Island.Level.Scanning.Finished.Should-Display-Message");
+ final MessageManager messageManager = SkyBlock.getInstance().getMessageManager();
+
+ for (Player player : SkyBlock.getInstance().getIslandManager().getPlayersAtIsland(island)) {
+
+ messageManager.sendMessage(player, message);
+ if (displayComplete)
+ messageManager.sendMessage(player, language.getString("Command.Island.Level.Scanning.Finished.Message"));
+
+ // Check for level ups
+ island.getLevel().checkLevelUp();
+ }
+ }
+ });
+ }
+}
diff --git a/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java b/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java
index d28e3d50..c6409faf 100644
--- a/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java
+++ b/src/main/java/com/songoda/skyblock/limit/LimitationInstanceHandler.java
@@ -39,10 +39,9 @@ public final class LimitationInstanceHandler {
public void reloadAll() {
final SkyBlock plugin = SkyBlock.getInstance();
- final Configuration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "limits.yml")).getFileConfiguration();
+ final Configuration config = plugin.getLimits();
- loadChunks = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Limits.LoadChunks");
+ loadChunks = plugin.getConfiguration().getBoolean("Island.Limits.LoadChunks");
for (Limitation limit : instances.values()) {
limit.reload(config.getConfigurationSection(limit.getSectionName()));
diff --git a/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java b/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java
index 756b3870..fc4472da 100644
--- a/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java
+++ b/src/main/java/com/songoda/skyblock/limit/impl/BlockLimitation.java
@@ -50,7 +50,7 @@ public final class BlockLimitation extends EnumLimitation {
if (type == null)
throw new IllegalArgumentException("Unable to parse Materials from '" + enumName + "' in the Section '" + loadFrom.getCurrentPath() + "'");
-
+
getMap().put(type, loadFrom.getLong(key));
}
@@ -67,7 +67,7 @@ public final class BlockLimitation extends EnumLimitation {
if (player.hasPermission("fabledskyblock.limit.block.*")) return -1;
CompatibleMaterial material = null;
- if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
+ if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
switch (type.toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@@ -75,7 +75,7 @@ public final class BlockLimitation extends EnumLimitation {
break;
}
}
- if(material == null) {
+ if (material == null) {
material = CompatibleMaterial.getMaterial(type);
}
@@ -87,21 +87,21 @@ public final class BlockLimitation extends EnumLimitation {
}
public boolean isBlockLimitExceeded(Block block, long limit) {
- return this.isBlockLimitExceeded(block.getType(), block.getLocation(), limit);
+ return this.isBlockLimitExceeded(CompatibleMaterial.getMaterial(block), block.getLocation(), limit);
}
- public boolean isBlockLimitExceeded(Material type, Location loc, long limit) {
+ public boolean isBlockLimitExceeded(CompatibleMaterial type, Location loc, long limit) {
if (limit == -1) return false;
final IslandManager islandManager = SkyBlock.getInstance().getIslandManager();
final Island island = islandManager.getIslandAtLocation(loc);
final long totalPlaced;
- if (type == CompatibleMaterial.SPAWNER.getBlockMaterial()) {
+ if (type == CompatibleMaterial.SPAWNER) {
totalPlaced = island.getLevel().getMaterials().entrySet().stream().filter(x -> x.getKey().contains("SPAWNER")).mapToLong(Map.Entry::getValue).sum();
} else {
CompatibleMaterial material = null;
- if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
+ if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
switch (type.toString().toUpperCase()) {
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
@@ -109,9 +109,7 @@ public final class BlockLimitation extends EnumLimitation {
break;
}
}
- if(material == null) {
- material = CompatibleMaterial.getMaterial(type);
- }
+ if (material == null) material = type;
totalPlaced = island.getLevel().getMaterialAmount(material.name());
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java
index 67709274..df91c62b 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Block.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Block.java
@@ -115,8 +115,7 @@ public class Block implements Listener {
stackableManager.removeStack(stackable);
}
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
if (material != null) {
@@ -138,8 +137,7 @@ public class Block implements Listener {
}
}
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
@@ -147,7 +145,7 @@ public class Block implements Listener {
|| LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
if (configLoad.getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
- plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Break.Message"));
+ plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.SpawnProtection.Break.Message"));
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
}
}
@@ -238,13 +236,12 @@ public class Block implements Listener {
if (islandLevelManager.isScanning(island)) {
plugin.getMessageManager().sendMessage(player,
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
+ plugin.getLanguage().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
event.setCancelled(true);
return;
}
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
if(!player.hasPermission("fabledskyblock.bypass.netherplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.Nether)){
@@ -252,8 +249,7 @@ public class Block implements Listener {
for(String s : configLoad.getConfigurationSection("Island.Restrict.NetherBlocks").getKeys(false)){
if(s.equalsIgnoreCase(block.getType().toString())){
if(configLoad.getBoolean("Island.Restrict.NetherBlocks." + s, false)){
- plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Island.Unlock.NetherBlocksPlace.Message")));
+ plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getLanguage().getString("Island.Unlock.NetherBlocksPlace.Message")));
event.setCancelled(true);
}
}
@@ -266,8 +262,7 @@ public class Block implements Listener {
for(String s : configLoad.getConfigurationSection("Island.Restrict.EndBlocks").getKeys(false)){
if(s.equalsIgnoreCase(block.getType().toString())){
if(configLoad.getBoolean("Island.Restrict.EndBlocks." + s)){
- plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Island.Unlock.EndBlocksPlace.Message")));
+ plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getLanguage().getString("Island.Unlock.EndBlocksPlace.Message")));
event.setCancelled(true);
}
}
@@ -298,7 +293,7 @@ public class Block implements Listener {
}
if (isObstructing) {
- plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Place.Message"));
+ plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.SpawnProtection.Place.Message"));
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setCancelled(true);
@@ -310,7 +305,9 @@ public class Block implements Listener {
long limit = limits.getBlockLimit(player, block.getType());
- if (limits.isBlockLimitExceeded(block, limit)) {
+ ItemStack item = event.getItemInHand();
+
+ if (limits.isBlockLimitExceeded(block, limit) && CompatibleMaterial.getMaterial(item) != CompatibleMaterial.ENDER_EYE) {
CompatibleMaterial material = null;
if(ServerVersion.isServerVersion(ServerVersion.V1_8)) {
switch (block.getType().toString().toUpperCase()) {
@@ -324,7 +321,7 @@ public class Block implements Listener {
material = CompatibleMaterial.getMaterial(block);
}
- plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
+ plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.Limit.Block.Exceeded.Message")
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
@@ -337,8 +334,7 @@ public class Block implements Listener {
if (event.getBlock().getType() == CompatibleMaterial.END_PORTAL_FRAME.getMaterial()
&& event.getPlayer().getItemInHand().getType() == CompatibleMaterial.ENDER_EYE.getMaterial()) return;
- islandLevelManager.updateLevel(island, blockLoc);
-
+ // Not util used 2 islandLevelManager if condition is true
// Sponge level dupe fix
if(ServerVersion.isServerVersionBelow(ServerVersion.V1_13) &&
block.getType().equals(CompatibleMaterial.SPONGE.getBlockMaterial())) {
@@ -359,6 +355,8 @@ public class Block implements Listener {
}
}
});
+ } else {
+ islandLevelManager.updateLevel(island, blockLoc);
}
}
@@ -374,8 +372,7 @@ public class Block implements Listener {
Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation());
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (island == null) return;
@@ -548,8 +545,7 @@ public class Block implements Listener {
Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation());
if (island == null) return;
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (performStackCheck(event.getBlock(), event.getBlocks(), event.getDirection())) {
event.setCancelled(true);
@@ -587,7 +583,7 @@ public class Block implements Listener {
}
}
- if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Piston.Connected.Extend")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.Block.Piston.Connected.Extend")) {
if (block.getType() == CompatibleMaterial.PISTON.getMaterial() || block.getType() == CompatibleMaterial.STICKY_PISTON.getMaterial()) {
event.setCancelled(true);
return;
@@ -646,8 +642,7 @@ public class Block implements Listener {
Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation());
if (island == null) return;
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (performStackCheck(event.getBlock(), event.getBlocks(), event.getDirection())) {
event.setCancelled(true);
@@ -676,7 +671,7 @@ public class Block implements Listener {
return;
}
- if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Piston.Connected.Retract")) {
+ if (!this.plugin.getConfiguration().getBoolean("Island.Block.Piston.Connected.Retract")) {
if (block.getType() == CompatibleMaterial.PISTON.getMaterial() || block.getType() == CompatibleMaterial.STICKY_PISTON.getMaterial()) {
event.setCancelled(true);
return;
@@ -691,7 +686,7 @@ public class Block implements Listener {
WorldManager worldManager = plugin.getWorldManager();
IslandLevelManager islandLevelManager = plugin.getLevellingManager();
- FileConfiguration config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
+ FileConfiguration config = this.plugin.getConfiguration();
if (!worldManager.isIslandWorld(block.getWorld())) return;
@@ -710,7 +705,7 @@ public class Block implements Listener {
// Check spawn block protection
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
+ if (this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;
}
@@ -775,7 +770,8 @@ public class Block implements Listener {
if(onlineOwner.hasPermission(generator.getPermission())) {
applyGenerator(event.getBlock().getWorld(), block, worldManager, islandLevelManager, island, state, generatorManager, generator);
}
- } else {
+ }
+ else {
event.setCancelled(true);
org.bukkit.World finalWorld = event.getBlock().getWorld();
this.generatorWaitingLocs.add(LocationUtil.toBlockLocation(block.getLocation().clone()));
@@ -851,7 +847,7 @@ public class Block implements Listener {
@EventHandler
public void onPortalCreate(PortalCreateEvent event) {
- if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
+ if (!this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection"))
return;
WorldManager worldManager = plugin.getWorldManager();
@@ -913,7 +909,7 @@ public class Block implements Listener {
@EventHandler
public void onDispenserDispenseBlock(BlockDispenseEvent event) {
- if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
+ if (!this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection"))
return;
WorldManager worldManager = plugin.getWorldManager();
@@ -932,4 +928,46 @@ public class Block implements Listener {
event.setCancelled(true);
}
+ @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
+ public void onLiquidDestroyBlock(BlockFromToEvent event) {
+ if (!plugin.getWorldManager().isIslandWorld(event.getBlock().getWorld()))
+ return;
+
+ IslandManager islandManager = plugin.getIslandManager();
+ Island island = islandManager.getIslandAtLocation(event.getBlock().getLocation());
+ if (island == null)
+ return;
+
+ CompatibleMaterial destmaterial = CompatibleMaterial.getMaterial(event.getToBlock());
+ if (destmaterial == CompatibleMaterial.AIR)
+ return;
+ if (ServerVersion.isServerVersion(ServerVersion.V1_8)) {
+ switch (event.getToBlock().getType().toString().toUpperCase()) {
+ case "DIODE_BLOCK_OFF":
+ case "DIODE_BLOCK_ON":
+ destmaterial = CompatibleMaterial.REPEATER;
+ break;
+ }
+ }
+
+ CompatibleMaterial srcmaterial = CompatibleMaterial.getMaterial(event.getBlock());
+ if (srcmaterial != CompatibleMaterial.WATER
+ && srcmaterial != CompatibleMaterial.LAVA)
+ return;
+
+ FileConfiguration configLoad = plugin.getConfiguration();
+ if (!configLoad.getBoolean("Island.Block.Level.Enable"))
+ return;
+
+ IslandLevel level = island.getLevel();
+ if (level.hasMaterial(destmaterial.name())) {
+ long materialAmount = level.getMaterialAmount(destmaterial.name());
+
+ if (materialAmount - 1 <= 0) {
+ level.removeMaterial(destmaterial.name());
+ } else {
+ level.setMaterialAmount(destmaterial.name(), materialAmount - 1);
+ }
+ }
+ }
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Bucket.java b/src/main/java/com/songoda/skyblock/listeners/Bucket.java
index 40045fe0..a1a2abfc 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Bucket.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Bucket.java
@@ -59,7 +59,7 @@ public class Bucket implements Listener {
return;
}
- if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection"))
+ if (!this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection"))
return;
Island island = islandManager.getIslandAtLocation(block.getLocation());
@@ -72,8 +72,7 @@ public class Bucket implements Listener {
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
event.setCancelled(true);
plugin.getMessageManager().sendMessage(player,
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Island.SpawnProtection.Place.Message"));
+ plugin.getLanguage().getString("Island.SpawnProtection.Place.Message"));
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
}
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Chat.java b/src/main/java/com/songoda/skyblock/listeners/Chat.java
index 9cb2e19b..05b753d7 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Chat.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Chat.java
@@ -49,9 +49,7 @@ public class Chat implements Listener {
if (playerData.isChat() && island != null) {
event.setCancelled(true);
-
- Config language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration languageLoad = language.getFileConfiguration();
+ FileConfiguration languageLoad = plugin.getLanguage();
PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, island.getAPIWrapper(),
event.getMessage(), languageLoad.getString("Island.Chat.Format.Message"));
@@ -65,13 +63,11 @@ public class Chat implements Listener {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
MessageManager messageManager = plugin.getMessageManager();
IslandManager islandManager = plugin.getIslandManager();
- FileManager fileManager = plugin.getFileManager();
Island island = event.getIsland().getIsland();
Player player = event.getPlayer();
-
- Config language = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration languageLoad = language.getFileConfiguration();
+
+ FileConfiguration languageLoad = plugin.getLanguage();
String islandRole = null;
@@ -110,7 +106,7 @@ public class Chat implements Listener {
}
}
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
+ if (this.plugin.getConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
messageManager.sendMessage(Bukkit.getConsoleSender(), event.getFormat().replace("%role", islandRole).replace("%player", player.getName())
.replace("%message", event.getMessage()));
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Death.java b/src/main/java/com/songoda/skyblock/listeners/Death.java
index 05c1f34f..b3f602ec 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Death.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Death.java
@@ -25,8 +25,7 @@ public class Death implements Listener {
Player player = event.getEntity();
if (plugin.getWorldManager().isIslandWorld(player.getWorld())) {
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
boolean keepInventory = false;
diff --git a/src/main/java/com/songoda/skyblock/listeners/Entity.java b/src/main/java/com/songoda/skyblock/listeners/Entity.java
index c8dacaa5..9060d7d7 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Entity.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Entity.java
@@ -64,8 +64,7 @@ public class Entity implements Listener {
if(event.getEntity() instanceof Blaze){
WorldManager worldManager = plugin.getWorldManager();
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Nether.BlazeImmuneToWaterInNether", false) &&
worldManager.getIslandWorld(event.getEntity().getWorld()).equals(IslandWorld.Nether) &&
@@ -92,8 +91,7 @@ public class Entity implements Listener {
@EventHandler(ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
IslandManager islandManager = plugin.getIslandManager();
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
org.bukkit.entity.Entity victim = event.getEntity();
Island island = islandManager.getIslandAtLocation(victim.getLocation());
@@ -103,9 +101,10 @@ public class Entity implements Listener {
if(attacker instanceof Projectile && ((Projectile) attacker).getShooter() instanceof org.bukkit.entity.Entity) {
attacker = (org.bukkit.entity.Entity) ((Projectile) attacker).getShooter();
}
-
+
+ // Rework with better config
if(victim instanceof Player && attacker instanceof Player) { // PVP
- if(configLoad.getBoolean("Island.PvP.Enable")) {
+ if (configLoad.getBoolean("Island.Entity_Damage.PVP")) {
if(plugin.getPermissionManager()
.processPermission(event, (Player) attacker, island)) {
plugin.getPermissionManager()
@@ -114,15 +113,26 @@ public class Entity implements Listener {
} else {
event.setCancelled(true);
}
- } else if(victim instanceof Player) { // EVP
- plugin.getPermissionManager()
- .processPermission(event, (Player) victim, island, true);
- } else if(attacker instanceof Player) { // PVE
- plugin.getPermissionManager()
- .processPermission(event, (Player) attacker, island);
- } else { // EVE
- plugin.getPermissionManager()
- .processPermission(event, island);
+ }
+ else if(victim instanceof Player) { // EVP
+ if (configLoad.getBoolean("Island.Entity_Damage.EVP")) {
+ plugin.getPermissionManager()
+ .processPermission(event, (Player) victim, island, true);
+ }
+
+ }
+ else if(attacker instanceof Player) { // PVE
+ if (configLoad.getBoolean("Island.Entity_Damage.PVE")) {
+ plugin.getPermissionManager()
+ .processPermission(event, (Player) attacker, island);
+ }
+
+ }
+ else { // EVE
+ if (configLoad.getBoolean("Island.Entity_Damage.PVE")) {
+ plugin.getPermissionManager()
+ .processPermission(event, island);
+ }
}
// Fix a bug in minecraft where arrows with flame still apply fire ticks even if
@@ -278,8 +288,7 @@ public class Entity implements Listener {
if (event.isCancelled()) return;
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
@@ -290,7 +299,7 @@ public class Entity implements Listener {
if ((LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone().subtract(0, 1, 0))
|| LocationUtil.isLocationLocation(block.getLocation(),
island.getLocation(world, IslandEnvironment.Visitor).clone().subtract(0, 1, 0)))
- && plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ && this.plugin.getConfiguration()
.getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;
@@ -323,8 +332,7 @@ public class Entity implements Listener {
if (entity instanceof FallingBlock) return;
// Check entities interacting with spawn
- if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) && plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
+ if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world) && plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;
}
@@ -333,7 +341,7 @@ public class Entity implements Listener {
plugin.getPermissionManager().processPermission(event, null, island);
- if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (!this.plugin.getConfiguration()
.getBoolean("Island.Block.Level.Enable"))
return;
@@ -342,7 +350,6 @@ public class Entity implements Listener {
if (event.getTo() != Material.AIR) {
materials = CompatibleMaterial.getBlockMaterial(event.getTo());
- ;
if (materials != null) {
long materialAmount = 0;
@@ -379,8 +386,7 @@ public class Entity implements Listener {
while (it.hasNext()){
removed = false;
org.bukkit.block.Block block = it.next();
- if (SkyBlock.getInstance().getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
- .getBoolean("Island.Spawn.Protection")) {
+ if (SkyBlock.getInstance().getConfiguration().getBoolean("Island.Spawn.Protection")) {
IslandWorld world = worldManager.getIslandWorld(event.getEntity().getWorld());
if (LocationUtil.isLocationLocation(block.getLocation(),
island.getLocation(world, IslandEnvironment.Main).clone().subtract(0.0D, 1.0D, 0.0D))) {
@@ -408,8 +414,7 @@ public class Entity implements Listener {
stackableManager.removeStack(stackable);
}
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
removeBlockFromLevel(island, block);
@@ -425,7 +430,7 @@ public class Entity implements Listener {
}
}
}
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Block.Level.Enable")) {
if(!removed){
removeBlockFromLevel(island, block);
@@ -573,9 +578,7 @@ public class Entity implements Listener {
EntityType type = entity.getType();
if (limits.isBeingTracked(type)) {
- FileManager fileManager = plugin.getFileManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
boolean isSplit = event.getSpawnReason().equals(SpawnReason.SLIME_SPLIT);
boolean splitBypass = configLoad.getBoolean("Island.Challenge.PerIsland", true);
diff --git a/src/main/java/com/songoda/skyblock/listeners/EpicSpawners.java b/src/main/java/com/songoda/skyblock/listeners/EpicSpawners.java
index e6d55d84..02456ab2 100644
--- a/src/main/java/com/songoda/skyblock/listeners/EpicSpawners.java
+++ b/src/main/java/com/songoda/skyblock/listeners/EpicSpawners.java
@@ -42,8 +42,7 @@ public class EpicSpawners implements Listener {
int amount = event.getSpawner().getFirstStack().getStackSize();
EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType();
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType);
@@ -77,8 +76,7 @@ public class EpicSpawners implements Listener {
int amount = event.getStackSize() - event.getOldStackSize();
EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType();
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType);
@@ -112,8 +110,7 @@ public class EpicSpawners implements Listener {
int amount = event.getSpawner().getFirstStack().getStackSize();
EntityType spawnerType = event.getSpawner().getCreatureSpawner().getSpawnedType();
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleSpawners materials = CompatibleSpawners.getSpawner(spawnerType);
diff --git a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java
index a46d2391..c4575977 100644
--- a/src/main/java/com/songoda/skyblock/listeners/FallBreak.java
+++ b/src/main/java/com/songoda/skyblock/listeners/FallBreak.java
@@ -37,8 +37,7 @@ public class FallBreak implements Listener {
int counter = 0;
IslandManager islandManager = plugin.getIslandManager();
WorldManager worldManager = plugin.getWorldManager();
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
Iterator iterator = fallingBlocks.iterator();
while(iterator.hasNext()) {
FallingBlock ent = iterator.next();
@@ -88,7 +87,7 @@ public class FallBreak implements Listener {
WorldManager worldManager = plugin.getWorldManager();
if (worldManager.isIslandWorld(event.getEntity().getLocation().getWorld())) {
if (!event.getTo().equals(CompatibleMaterial.AIR.getMaterial())){
- fallingBlocks.remove((FallingBlock) event.getEntity());
+ fallingBlocks.remove(event.getEntity());
} else if(!event.isCancelled()) {
fallingBlocks.add((FallingBlock) event.getEntity());
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Grow.java b/src/main/java/com/songoda/skyblock/listeners/Grow.java
index 75b78988..71c66cb7 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Grow.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Grow.java
@@ -68,7 +68,6 @@ public class Grow implements Listener {
// The structure is growing from one island to another.
if (!origin.getIslandUUID().equals(growingTo.getIslandUUID())) {
it.remove();
- continue;
}
}
}
@@ -86,7 +85,7 @@ public class Grow implements Listener {
// Check spawn block protection
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
if (LocationUtil.isLocationAffectingIslandSpawn(block.getLocation(), island, world)) {
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) {
+ if (this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
return;
}
@@ -155,7 +154,7 @@ public class Grow implements Listener {
*/
@EventHandler(ignoreCancelled = true)
public void onStructureCreate(StructureGrowEvent event) {
- if (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Spawn.Protection")) return;
+ if (!this.plugin.getConfiguration().getBoolean("Island.Spawn.Protection")) return;
List blocks = event.getBlocks();
if (blocks.isEmpty()) return;
diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java
index a932f5e3..b21d2f4e 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Interact.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java
@@ -79,7 +79,7 @@ public class Interact implements Listener {
if (levellingManager.isScanning(island)) {
plugin.getMessageManager().sendMessage(player,
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
+ plugin.getLanguage().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
event.setCancelled(true);
return;
}
@@ -97,7 +97,7 @@ public class Interact implements Listener {
}
if (isObstructing) {
- plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Place.Message"));
+ plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.SpawnProtection.Place.Message"));
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setCancelled(true);
@@ -109,10 +109,10 @@ public class Interact implements Listener {
long limit = limits.getBlockLimit(player, Material.WATER);
- if (limits.isBlockLimitExceeded(event.getItem().getType(), block.getLocation(), limit)) {
+ if (limits.isBlockLimitExceeded(CompatibleMaterial.getMaterial(event.getItem()), block.getLocation(), limit)) {
CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getItem().getType());
- plugin.getMessageManager().sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
+ plugin.getMessageManager().sendMessage(player, plugin.getLanguage().getString("Island.Limit.Block.Exceeded.Message")
.replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
@@ -178,7 +178,7 @@ public class Interact implements Listener {
if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType
&& !player.isSneaking() && plugin.getPermissionManager().hasPermission(player, island, "Place")
- && (!plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission")
+ && (!this.plugin.getConfiguration().getBoolean("Island.Stackable.RequirePermission")
|| player.hasPermission("fabledskyblock.stackable"))) {
if (levellingManager.isScanning(island)) {
diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java
index 2827312d..dc915121 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Join.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Join.java
@@ -42,7 +42,6 @@ public class Join implements Listener {
UserCacheManager userCacheManager = plugin.getUserCacheManager();
CooldownManager cooldownManager = plugin.getCooldownManager();
IslandManager islandManager = plugin.getIslandManager();
- FileManager fileManager = plugin.getFileManager();
Player player = event.getPlayer();
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
@@ -53,9 +52,8 @@ public class Join implements Listener {
islandManager.loadIsland(player);
Island island = islandManager.getIsland(player);
boolean teleportedToIsland = false;
-
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Join.Spawn")) {
LocationUtil.teleportPlayerToSpawn(player);
diff --git a/src/main/java/com/songoda/skyblock/listeners/Move.java b/src/main/java/com/songoda/skyblock/listeners/Move.java
index 0348cc11..12765466 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Move.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Move.java
@@ -63,9 +63,8 @@ public class Move implements Listener {
IslandWorld world = worldManager.getIslandWorld(player.getWorld());
if (world == IslandWorld.Nether || world == IslandWorld.End) {
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.World." + world.name() + ".Enable")) {
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ if (!this.plugin.getConfiguration().getBoolean("Island.World." + world.name() + ".Enable")) {
+ FileConfiguration configLoad = plugin.getLanguage();
messageManager.sendMessage(player, configLoad.getString("Island.World.Message").replace(configLoad.getString("Island.World.Word." + world.name()), world.name()));
@@ -96,8 +95,7 @@ public class Move implements Listener {
if (island != null) {
if (islandManager.isLocationAtIsland(island, to)) {
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
boolean keepItemsOnDeath;
@@ -132,9 +130,7 @@ public class Move implements Listener {
player.setFoodLevel(20);
- for (PotionEffect potionEffect : player.getActivePotionEffects()) {
- player.removePotionEffect(potionEffect.getType());
- }
+ player.getActivePotionEffects().stream().map(PotionEffect::getType).forEach(player::removePotionEffect);
}
player.setFallDistance(0.0F);
@@ -151,15 +147,14 @@ public class Move implements Listener {
} else {
if(!islandManager.isLocationAtIsland(island, to)) {
teleportPlayerToIslandSpawn(player, world, island);
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
}
- messageManager.sendMessage(player, plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration()
+ messageManager.sendMessage(player, plugin.getLanguage()
.getString("Island.WorldBorder.Outside.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
}
@@ -191,7 +186,7 @@ public class Move implements Listener {
LocationUtil.teleportPlayerToSpawn(player);
messageManager.sendMessage(player,
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message"));
+ plugin.getLanguage().getString("Island.WorldBorder.Disappeared.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
});
});
@@ -203,8 +198,7 @@ public class Move implements Listener {
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId())
|| island.hasRole(IslandRole.Owner, player.getUniqueId())) {
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
- if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
+ if(plugin.getConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Main));
if (safeLoc != null) {
loc = safeLoc;
@@ -213,15 +207,13 @@ public class Move implements Listener {
} else {
loc = island.getLocation(world, IslandEnvironment.Main);
- if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Teleport.RemoveWater", false)) {
+ if(plugin.getConfiguration().getBoolean("Island.Teleport.RemoveWater", false)) {
LocationUtil.removeWaterFromLoc(loc);
}
}
} else {
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
- if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
+ if(plugin.getConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor));
if (safeLoc != null) {
loc = safeLoc;
@@ -236,9 +228,7 @@ public class Move implements Listener {
PaperLib.teleportAsync(player, finalLoc);
} else {
LocationUtil.teleportPlayerToSpawn(player);
- player.sendMessage(ChatColor.translateAlternateColorCodes('&',
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Command.Island.Teleport.Unsafe.Message")));
+ player.sendMessage(plugin.formatText(plugin.getLanguage().getString("Command.Island.Teleport.Unsafe.Message")));
}
}
@@ -249,9 +239,7 @@ public class Move implements Listener {
private void teleportPlayerToIslandSpawn(Player player, SoundManager soundManager, Island island) {
teleportPlayerToIslandSpawn(player, island);
- FileManager fileManager = plugin.getFileManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
@@ -264,7 +252,7 @@ public class Move implements Listener {
final Player player = e.getPlayer();
final WorldManager worldManager = plugin.getWorldManager();
if(e.getTo() != null && e.getTo().getWorld() != null){
- if(!e.isAsynchronous()){
+ if(Bukkit.isPrimaryThread()){
e.getTo().getWorld().loadChunk(e.getTo().getChunk()); // Is that needed?
}
if(worldManager.isIslandWorld(e.getTo().getWorld())
@@ -272,8 +260,7 @@ public class Move implements Listener {
if(plugin.getIslandManager().getIslandAtLocation(e.getTo()) == null){
e.setCancelled(true);
plugin.getMessageManager().sendMessage(player,
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Island.WorldBorder.Disappeared.Message"));
+ plugin.getLanguage().getString("Island.WorldBorder.Disappeared.Message"));
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
}
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Piston.java b/src/main/java/com/songoda/skyblock/listeners/Piston.java
index 9a994997..a54a9194 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Piston.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Piston.java
@@ -38,8 +38,7 @@ public class Piston implements Listener {
if (island == null || CompatibleMaterial.DRAGON_EGG != CompatibleMaterial.getMaterial(block)) return;
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (!configLoad.getBoolean("Island.Block.Level.Enable")) return;
diff --git a/src/main/java/com/songoda/skyblock/listeners/Portal.java b/src/main/java/com/songoda/skyblock/listeners/Portal.java
index 812d8d20..d49ffc0d 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Portal.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Portal.java
@@ -34,7 +34,7 @@ public class Portal implements Listener {
private final SkyBlock plugin;
- private Map tickCounter = new HashMap<>();
+ private final Map tickCounter = new HashMap<>();
public Portal(SkyBlock plugin) {
this.plugin = plugin;
@@ -70,7 +70,6 @@ public class Portal implements Listener {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
WorldManager worldManager = plugin.getWorldManager();
- FileManager fileManager = plugin.getFileManager();
if (!worldManager.isIslandWorld(player.getWorld())) return;
@@ -78,8 +77,7 @@ public class Portal implements Listener {
if (island == null) return;
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
IslandEnvironment spawnEnvironment;
switch (island.getRole(player)) {
@@ -108,7 +106,7 @@ public class Portal implements Listener {
tick.setLast(System.currentTimeMillis());
}
if (tick.getTick() >= 100) {
- messageManager.sendMessage(player, fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Portal.Stuck.Message"));
+ messageManager.sendMessage(player, plugin.getLanguage().getString("Island.Portal.Stuck.Message"));
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
LocationUtil.teleportPlayerToSpawn(player);
return;
@@ -163,8 +161,7 @@ public class Portal implements Listener {
IslandWorld toWorldF = toWorld;
Bukkit.getScheduler().runTaskLater(plugin, () -> {
Location loc = island.getLocation(toWorldF, spawnEnvironment);
- if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
+ if(plugin.getConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
Location safeLoc = LocationUtil.getSafeLocation(loc);
if (safeLoc != null) {
loc = safeLoc;
diff --git a/src/main/java/com/songoda/skyblock/listeners/Quit.java b/src/main/java/com/songoda/skyblock/listeners/Quit.java
index afc40f31..d821925b 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Quit.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Quit.java
@@ -75,9 +75,7 @@ public class Quit implements Listener {
if (targetPlayerData.isChat()) {
targetPlayerData.setChat(false);
messageManager.sendMessage(targetPlayer,
- plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Island.Chat.Untoggled.Message"));
+ plugin.getLanguage().getString("Island.Chat.Untoggled.Message"));
}
}
}
@@ -100,28 +98,19 @@ public class Quit implements Listener {
playerDataManager.unloadPlayerData(player);
boolean offline = true;
- if(island != null && plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if(island != null && this.plugin.getConfiguration()
.getBoolean("Island.Challenge.PerIsland", false)){
if(island.getRole(IslandRole.Member) != null){
- for(UUID uuid : island.getRole(IslandRole.Member)){
- if(Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline()){
- offline = false;
- }
- }
+ offline = island.getRole(IslandRole.Member).stream().noneMatch(uuid -> Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline());
}
if(offline && island.getRole(IslandRole.Operator) != null){
- for(UUID uuid : island.getRole(IslandRole.Operator)){
- if(Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline()){
- offline = false;
- }
+ if (island.getRole(IslandRole.Operator).stream().anyMatch(uuid -> Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline())) {
+ offline = false;
}
}
- if(offline && island.getRole(IslandRole.Owner) != null){
- for(UUID uuid : island.getRole(IslandRole.Owner)){
- if(Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline()){
- offline = false;
- }
- }
+ if (offline && island.getRole(IslandRole.Owner) != null &&
+ island.getRole(IslandRole.Owner).stream().anyMatch(uuid -> Bukkit.getPlayer(uuid) != null && !Bukkit.getPlayer(uuid).isOnline())) {
+ offline = false;
}
}
@@ -130,7 +119,7 @@ public class Quit implements Listener {
}
for (Island islandList : islandManager.getCoopIslands(player)) {
- if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (this.plugin.getConfiguration()
.getBoolean("Island.Coop.Unload") || islandList.getCoopType(player.getUniqueId()) == IslandCoop.TEMP) {
islandList.removeCoopPlayer(player.getUniqueId());
}
@@ -153,8 +142,7 @@ public class Quit implements Listener {
if (targetPlayer != null) {
messageManager.sendMessage(targetPlayer,
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration()
+ plugin.getLanguage()
.getString("Command.Island.Invite.Invited.Sender.Disconnected.Message")
.replace("%player", player.getName()));
plugin.getSoundManager().playSound(targetPlayer, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
diff --git a/src/main/java/com/songoda/skyblock/listeners/Respawn.java b/src/main/java/com/songoda/skyblock/listeners/Respawn.java
index 8ca34dee..262aaadd 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Respawn.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Respawn.java
@@ -34,8 +34,7 @@ public class Respawn implements Listener {
FileManager fileManager = plugin.getFileManager();
if (worldManager.isIslandWorld(player.getWorld())) {
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Death.Respawn.Island")) {
Location playerLocation = player.getLocation();
@@ -63,7 +62,7 @@ public class Respawn implements Listener {
}
}
- config = fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml"));
+ Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "locations.yml"));
if (config.getFileConfiguration().getString("Location.Spawn") == null) {
Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: A spawn point hasn't been set.");
diff --git a/src/main/java/com/songoda/skyblock/listeners/Spawner.java b/src/main/java/com/songoda/skyblock/listeners/Spawner.java
index 3c05ed9b..f7114324 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Spawner.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Spawner.java
@@ -95,8 +95,6 @@ public class Spawner implements Listener {
spawner.update();
}
-
- return;
}
}
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java
index a7d5a5df..59ed8f00 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java
@@ -50,10 +50,8 @@ public class Teleport implements Listener {
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
WorldManager worldManager = plugin.getWorldManager();
- FileManager fileManager = plugin.getFileManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
if(worldManager.isIslandWorld(event.getFrom().getWorld()) || worldManager.isIslandWorld(event.getTo().getWorld())) {
Bukkit.getScheduler().runTaskLater(plugin, () -> islandManager.updateFlight(player), 1L);
@@ -107,7 +105,7 @@ public class Teleport implements Listener {
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
- } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning") && island.getBan().isBanned(player.getUniqueId())) {
+ } else if (this.plugin.getConfiguration().getBoolean("Island.Visitor.Banning") && island.getBan().isBanned(player.getUniqueId())) {
event.setCancelled(true);
messageManager.sendMessage(player, configLoad.getString("Island.Visit.Banned.Teleport.Message"));
@@ -135,7 +133,7 @@ public class Teleport implements Listener {
if (worldManager.getIslandWorld(event.getTo().getWorld()) == IslandWorld.Normal) {
if (!island.isWeatherSynchronized()) {
- player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
+ player.setPlayerTime(island.getTime(), this.plugin.getConfiguration().getBoolean("Island.Weather.Time.Cycle"));
player.setPlayerWeather(island.getWeather());
}
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/UltimateStacker.java b/src/main/java/com/songoda/skyblock/listeners/UltimateStacker.java
index bca32ed9..9b57e743 100644
--- a/src/main/java/com/songoda/skyblock/listeners/UltimateStacker.java
+++ b/src/main/java/com/songoda/skyblock/listeners/UltimateStacker.java
@@ -36,8 +36,7 @@ public class UltimateStacker implements Listener {
Island island = islandManager.getIslandAtLocation(location);
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleSpawners materials = CompatibleSpawners.getSpawner(event.getSpawnerType());
@@ -65,8 +64,7 @@ public class UltimateStacker implements Listener {
Island island = islandManager.getIslandAtLocation(location);
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Island.Block.Level.Enable")) {
CompatibleSpawners materials = CompatibleSpawners.getSpawner(event.getSpawnerType());
diff --git a/src/main/java/com/songoda/skyblock/listeners/World.java b/src/main/java/com/songoda/skyblock/listeners/World.java
index e082cb94..a9b3648d 100644
--- a/src/main/java/com/songoda/skyblock/listeners/World.java
+++ b/src/main/java/com/songoda/skyblock/listeners/World.java
@@ -34,12 +34,12 @@ public class World implements Listener {
break;
case NETHER:
if(!to.getBlock().getBiome().equals(CompatibleBiome.NETHER_WASTES.getBiome())) {
- biomeManager.setBiome(island, IslandWorld.Nether, CompatibleBiome.NETHER_WASTES.getBiome(), null);
+ biomeManager.setBiome(island, IslandWorld.Nether, CompatibleBiome.NETHER_WASTES, null);
}
break;
case THE_END:
if(!to.getBlock().getBiome().equals(CompatibleBiome.THE_END.getBiome())) {
- biomeManager.setBiome(island, IslandWorld.End, CompatibleBiome.THE_END.getBiome(), null);
+ biomeManager.setBiome(island, IslandWorld.End, CompatibleBiome.THE_END, null);
}
break;
}
diff --git a/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java b/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java
index 82c86615..bd4be3f4 100644
--- a/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java
+++ b/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java
@@ -18,7 +18,7 @@ public final class LocalizationManager {
private final Localization> def = new BlankLocalization("", Object.class);
- private Map, Localization>> map;
+ private final Map, Localization>> map;
public LocalizationManager() {
this.map = new HashMap<>();
@@ -36,17 +36,15 @@ public final class LocalizationManager {
final SkyBlock inst = SkyBlock.getInstance();
- toUse.reload(inst.getFileManager().getConfig(new File(inst.getDataFolder(), "language.yml")).getFileConfiguration().getConfigurationSection(toUse.getKeysPath()));
+ toUse.reload(inst.getLanguage().getConfigurationSection(toUse.getKeysPath()));
}
public void reloadAll() {
final SkyBlock inst = SkyBlock.getInstance();
- final Configuration config = inst.getFileManager().getConfig(new File(inst.getDataFolder(), "language.yml")).getFileConfiguration();
+ final Configuration config = inst.getLanguage();
- for (Localization> locale : Sets.newHashSet(map.values())) {
- locale.reload(config.getConfigurationSection(locale.getKeysPath()));
- }
+ Sets.newHashSet(map.values()).forEach(locale -> locale.reload(config.getConfigurationSection(locale.getKeysPath())));
}
diff --git a/src/main/java/com/songoda/skyblock/manager/Manager.java b/src/main/java/com/songoda/skyblock/manager/Manager.java
index e11d1a05..44d7f0cd 100644
--- a/src/main/java/com/songoda/skyblock/manager/Manager.java
+++ b/src/main/java/com/songoda/skyblock/manager/Manager.java
@@ -14,13 +14,13 @@ public abstract class Manager {
/**
* Reloads the Manager's settings
*/
- public void reload() {};
-
+ public void reload() {}
+
/**
* Cleans up the Manager's resources
*/
- public void disable() {};
-
+ public void disable() {}
+
public void triggerPlayerLogin(Player player) {}
public void triggerPlayerLogout(Player player) {}
diff --git a/src/main/java/com/songoda/skyblock/menus/Bans.java b/src/main/java/com/songoda/skyblock/menus/Bans.java
index 295b5e7c..7f004008 100644
--- a/src/main/java/com/songoda/skyblock/menus/Bans.java
+++ b/src/main/java/com/songoda/skyblock/menus/Bans.java
@@ -54,8 +54,7 @@ public class Bans {
PlayerData playerData = playerDataManager.getPlayerData(player);
Island island = plugin.getIslandManager().getIsland(player);
- Config languageConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = languageConfig.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (playerDataManager.hasPlayerData(player)) {
@@ -68,8 +67,7 @@ public class Bans {
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
- } else if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
+ } else if (!plugin.getConfiguration().getBoolean("Island.Visitor.Banning")) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Bans.Disabled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
@@ -80,18 +78,18 @@ public class Bans {
ItemStack is = event.getItem();
if ((is.getType() == CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getMaterial()) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Bans.Item.Barrier.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
} else if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Bans.Item.Exit.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Bans.Item.Information.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@@ -118,21 +116,21 @@ public class Bans {
gui.open();
}, 1L);
} else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Bans.Item.Nothing.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
- if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ if (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Bans.Item.Previous.Displayname")))) {
playerData1.setPage(MenuType.BANS, playerData1.getPage(MenuType.BANS) - 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L);
- } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
- '&', configLoad.getString("Menu.Bans.Item.Next.Displayname")))) {
+ } else if (is.getItemMeta().getDisplayName().equals(plugin.formatText(
+ configLoad.getString("Menu.Bans.Item.Next.Displayname")))) {
playerData1.setPage(MenuType.BANS, playerData1.getPage(MenuType.BANS) + 1);
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
@@ -223,7 +221,7 @@ public class Bans {
nInv.addItem(
nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Bans.Item.Ban.Displayname")
.replace("%player", targetPlayerName == null ? "" : targetPlayerName)),
configLoad.getStringList("Menu.Bans.Item.Ban.Lore"), null, null, null),
@@ -232,10 +230,10 @@ public class Bans {
}
}
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Bans.Title")));
+ nInv.setTitle(plugin.formatText(configLoad.getString("Menu.Bans.Title")));
nInv.setRows(6);
- Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open());
+ Bukkit.getServer().getScheduler().runTask(plugin, nInv::open);
}
}
}
diff --git a/src/main/java/com/songoda/skyblock/menus/Biome.java b/src/main/java/com/songoda/skyblock/menus/Biome.java
index 2ba6b24d..5ad1ec9e 100644
--- a/src/main/java/com/songoda/skyblock/menus/Biome.java
+++ b/src/main/java/com/songoda/skyblock/menus/Biome.java
@@ -1,5 +1,6 @@
package com.songoda.skyblock.menus;
+import com.songoda.core.compatibility.CompatibleBiome;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.skyblock.SkyBlock;
@@ -52,7 +53,7 @@ public class Biome {
SoundManager soundManager = plugin.getSoundManager();
if (playerDataManager.hasPlayerData(player)) {
- FileConfiguration langConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
+ FileConfiguration langConfig = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
Island island = islandManager.getIsland(player);
@@ -135,7 +136,7 @@ public class Biome {
SBiome selectedBiomeType = SBiome.getFromGuiIcon(is.getType(), is.getData().getData());
cooldownManager.createPlayer(CooldownType.Biome, player);
- biomeManager.setBiome(island,IslandWorld.Normal, selectedBiomeType.getBiome(), null);
+ biomeManager.setBiome(island,IslandWorld.Normal, CompatibleBiome.getBiome(selectedBiomeType.getBiome()), null);
island.setBiome(selectedBiomeType.getBiome());
island.save();
@@ -166,12 +167,11 @@ public class Biome {
0, 8);
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
- ChatColor.translateAlternateColorCodes('&',
- langConfig.getString("Menu.Biome.Item.Barrier.Displayname")),
+ plugin.formatText(langConfig.getString("Menu.Biome.Item.Barrier.Displayname")),
null, null, null, null),
9, 10, 11, 12, 13, 14, 15, 16, 17);
- FileConfiguration settings = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
+ FileConfiguration settings = plugin.getConfiguration();
boolean allowNetherBiome = settings.getBoolean("Island.Biome.AllowOtherWorldlyBiomes.Nether");
boolean allowEndBiome = settings.getBoolean("Island.Biome.AllowOtherWorldlyBiomes.End");
diff --git a/src/main/java/com/songoda/skyblock/menus/Border.java b/src/main/java/com/songoda/skyblock/menus/Border.java
index e940bc5a..d9f231a0 100644
--- a/src/main/java/com/songoda/skyblock/menus/Border.java
+++ b/src/main/java/com/songoda/skyblock/menus/Border.java
@@ -42,8 +42,7 @@ public class Border {
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
Island island = islandManager.getIsland(player);
@@ -61,8 +60,7 @@ public class Border {
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return;
- } else if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
+ } else if (!plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable")) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Border.Disabled.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
@@ -78,11 +76,7 @@ public class Border {
} else if ((is.getType() == Material.TRIPWIRE_HOOK) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Border.Item.Toggle.Displayname"))))) {
- if (island.isBorder()) {
- island.setBorder(false);
- } else {
- island.setBorder(true);
- }
+ island.setBorder(!island.isBorder());
islandManager.updateBorder(island);
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
diff --git a/src/main/java/com/songoda/skyblock/menus/ControlPanel.java b/src/main/java/com/songoda/skyblock/menus/ControlPanel.java
index 554d0285..1976b5c4 100644
--- a/src/main/java/com/songoda/skyblock/menus/ControlPanel.java
+++ b/src/main/java/com/songoda/skyblock/menus/ControlPanel.java
@@ -36,7 +36,7 @@ public final class ControlPanel {
executors.put(RegistryKey.fromLanguageFile("Menu.ControlPanel.Item.Lock.Displayname", CompatibleMaterial.IRON_DOOR), (inst, player, e) -> {
- final Island island = SkyBlock.getInstance().getIslandManager().getIsland((Player) player);
+ final Island island = SkyBlock.getInstance().getIslandManager().getIsland(player);
switch (island.getStatus()) {
case OPEN:
@@ -90,8 +90,7 @@ public final class ControlPanel {
public void open(Player player) {
SkyBlock plugin = SkyBlock.getInstance();
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
MenuClickRegistry.getInstance().dispatch(player, event);
diff --git a/src/main/java/com/songoda/skyblock/menus/Creator.java b/src/main/java/com/songoda/skyblock/menus/Creator.java
index 91dfb31c..3c9fd6b5 100644
--- a/src/main/java/com/songoda/skyblock/menus/Creator.java
+++ b/src/main/java/com/songoda/skyblock/menus/Creator.java
@@ -45,8 +45,7 @@ public class Creator {
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
List availableStructures = new ArrayList<>();
@@ -158,28 +157,27 @@ public class Creator {
event.setWillDestroy(false);
return;
- } else if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable")
+ } else if (plugin.getConfiguration().getBoolean("Island.Creation.Cooldown.Creation.Enable")
&& cooldownManager.hasPlayer(CooldownType.Creation, player)) {
CooldownPlayer cooldownPlayer = cooldownManager
.getCooldownPlayer(CooldownType.Creation, player);
Cooldown cooldown = cooldownPlayer.getCooldown();
if (cooldown.getTime() < 60) {
- messageManager.sendMessage(player, config.getFileConfiguration()
+ messageManager.sendMessage(player, configLoad
.getString("Island.Creator.Selector.Cooldown.Message")
.replace("%time", cooldown.getTime() + " "
- + config.getFileConfiguration().getString(
+ + configLoad.getString(
"Island.Creator.Selector.Cooldown.Word.Second")));
} else {
long[] durationTime = NumberUtil.getDuration(cooldown.getTime());
- messageManager.sendMessage(player, config.getFileConfiguration()
+ messageManager.sendMessage(player, configLoad
.getString("Island.Creator.Selector.Cooldown.Message")
.replace("%time", durationTime[2] + " "
- + config.getFileConfiguration().getString(
+ + configLoad.getString(
"Island.Creator.Selector.Cooldown.Word.Minute")
+ " " + durationTime[3] + " "
- + config.getFileConfiguration().getString(
+ + configLoad.getString(
"Island.Creator.Selector.Cooldown.Word.Second")));
}
diff --git a/src/main/java/com/songoda/skyblock/menus/Information.java b/src/main/java/com/songoda/skyblock/menus/Information.java
index 6bb30373..7d316ebc 100644
--- a/src/main/java/com/songoda/skyblock/menus/Information.java
+++ b/src/main/java/com/songoda/skyblock/menus/Information.java
@@ -64,8 +64,7 @@ public class Information {
islandManager.loadIsland(targetOfflinePlayer);
}
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
Island island = islandManager.getIsland(Bukkit.getServer().getOfflinePlayer(viewer.getOwner()));
if (island == null) {
@@ -119,12 +118,12 @@ public class Information {
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(
- ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ plugin.formatText(configLoad.getString(
"Menu.Information.Categories.Item.Exit.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
} else if ((is.getType() == CompatibleMaterial.ITEM_FRAME.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(
- ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ plugin.formatText(configLoad.getString(
"Menu.Information.Categories.Item.Members.Displayname"))))) {
playerData13.setViewer(new Viewer(
((Viewer) playerData13.getViewer()).getOwner(),
@@ -136,7 +135,7 @@ public class Information {
} else if ((is.getType() == CompatibleMaterial.MAP.getMaterial())
&& (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(
- ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ plugin.formatText(configLoad.getString(
"Menu.Information.Categories.Item.Information.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F);
@@ -144,7 +143,7 @@ public class Information {
event.setWillDestroy(false);
} else if ((is.getType() == CompatibleMaterial.PAINTING.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(
- ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ plugin.formatText(configLoad.getString(
"Menu.Information.Categories.Item.Visitors.Displayname"))))) {
playerData13.setViewer(new Viewer(
((Viewer) playerData13.getViewer()).getOwner(),
@@ -169,7 +168,6 @@ public class Information {
configLoad.getStringList("Menu.Information.Categories.Item.Visitors.Lore"), null, null,
null), 3);
- Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
List itemLore = new ArrayList<>();
String safety = "";
@@ -180,8 +178,8 @@ public class Information {
safety = configLoad.getString("Menu.Information.Categories.Item.Information.Vote.Word.Safe");
}
- if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) {
+ if (plugin.getConfiguration().getBoolean("Island.Visitor.Vote")) {
+ if (plugin.getConfiguration().getBoolean("Island.Visitor.Signature.Enable")) {
for (String itemLoreList : configLoad.getStringList(
"Menu.Information.Categories.Item.Information.Vote.Enabled.Signature.Enabled.Lore")) {
if (itemLoreList.contains("%signature")) {
@@ -191,9 +189,7 @@ public class Information {
itemLore.add(configLoad.getString(
"Menu.Information.Categories.Item.Information.Vote.Word.Empty"));
} else {
- for (String signatureList : islandSignature) {
- itemLore.add(signatureList);
- }
+ itemLore.addAll(islandSignature);
}
} else {
itemLore.add(itemLoreList);
@@ -214,13 +210,13 @@ public class Information {
new Placeholder("%players",
"" + islandManager.getPlayersAtIsland(island).size()),
new Placeholder("%player_capacity",
- "" + mainConfig.getFileConfiguration()
+ "" + plugin.getConfiguration()
.getInt("Island.Visitor.Capacity")),
new Placeholder("%owner", islandOwnerName),
new Placeholder("%safety", safety)},
null, null), 2);
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable")) {
+ if (plugin.getConfiguration().getBoolean("Island.Visitor.Signature.Enable")) {
for (String itemLoreList : configLoad.getStringList(
"Menu.Information.Categories.Item.Information.Vote.Disabled.Signature.Enabled.Lore")) {
if (itemLoreList.contains("%signature")) {
@@ -252,14 +248,14 @@ public class Information {
new Placeholder("%players",
"" + islandManager.getPlayersAtIsland(island).size()),
new Placeholder("%player_capacity",
- "" + mainConfig.getFileConfiguration()
+ "" + plugin.getConfiguration()
.getInt("Island.Visitor.Capacity")),
new Placeholder("%owner", islandOwnerName),
new Placeholder("%safety", safety)},
null, null), 2);
}
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
+ nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Information.Categories.Title")));
nInv.setType(InventoryType.HOPPER);
@@ -347,7 +343,7 @@ public class Information {
new Placeholder("%island_members",
"" + (islandMembers.size() + islandOperators.size() + 1)),
new Placeholder("%island_capacity", // %island_capacity
- "" + island.getMaxMembers()),
+ "" + island.getMaxMembers(player)),
new Placeholder("%members", "" + islandMembers.size()),
new Placeholder("%operators", "" + islandOperators.size())},
null, null),
@@ -568,8 +564,8 @@ public class Information {
public static class Viewer {
- private UUID islandOwnerUUID;
- private Type type;
+ private final UUID islandOwnerUUID;
+ private final Type type;
public Viewer(UUID islandOwnerUUID, Type type) {
this.islandOwnerUUID = islandOwnerUUID;
diff --git a/src/main/java/com/songoda/skyblock/menus/InputMethodSelectlistener.java b/src/main/java/com/songoda/skyblock/menus/InputMethodSelectlistener.java
index 7a8b3a4f..b2a908ae 100644
--- a/src/main/java/com/songoda/skyblock/menus/InputMethodSelectlistener.java
+++ b/src/main/java/com/songoda/skyblock/menus/InputMethodSelectlistener.java
@@ -2,9 +2,9 @@ package com.songoda.skyblock.menus;
public interface InputMethodSelectlistener {
- public void choose(InputMethod inputMethod);
+ void choose(InputMethod inputMethod);
- public enum InputMethod {
+ enum InputMethod {
ALL,
CUSTOM,
CANCELED
diff --git a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java
index 9ee9519a..7f08f48e 100644
--- a/src/main/java/com/songoda/skyblock/menus/Leaderboard.java
+++ b/src/main/java/com/songoda/skyblock/menus/Leaderboard.java
@@ -42,24 +42,22 @@ public class Leaderboard {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
SoundManager soundManager = plugin.getSoundManager();
- FileManager fileManager = plugin.getFileManager();
if (playerDataManager.hasPlayerData(player)) {
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
Viewer viewer = (Viewer) playerDataManager.getPlayerData(player).getViewer();
+ nInventoryUtil nInv;
if (viewer.getType() == Viewer.Type.Browse) {
- nInventoryUtil nInv = new nInventoryUtil(player, event -> {
+ nInv = new nInventoryUtil(player, event -> {
if (playerDataManager.hasPlayerData(player)) {
ItemStack is = event.getItem();
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name()
- + ".Item.Exit.Displayname"))))) {
+ .equals(plugin.formatText(configLoad.getString("Menu.Leaderboard." + Viewer.Type.Browse.name()
+ + ".Item.Exit.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
return;
@@ -109,7 +107,7 @@ public class Leaderboard {
null),
1);
- if(fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Bank.Enable")){
+ if(plugin.getConfiguration().getBoolean("Island.Bank.Enable")){
nInv.addItem(
nInv.createItem(new ItemStack(Material.GOLD_INGOT), configLoad
.getString(
@@ -135,26 +133,23 @@ public class Leaderboard {
null),
3);
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
+ nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Leaderboard." + viewer.getType().name() + ".Title")));
nInv.setType(InventoryType.HOPPER);
- Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open());
} else {
- nInventoryUtil nInv = new nInventoryUtil(player, event -> {
+ nInv = new nInventoryUtil(player, event -> {
if (playerDataManager.hasPlayerData(player)) {
ItemStack is = event.getItem();
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())) {
- if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ if (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Exit.Displayname")))) {
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
} else if (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .equals(plugin.formatText(configLoad
.getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname")))) {
- if (plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
+ if (plugin.getConfiguration().getBoolean("Island.Visitor.Vote")) {
playerDataManager.getPlayerData(player)
.setViewer(new Viewer(Viewer.Type.Browse));
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
@@ -219,7 +214,7 @@ public class Leaderboard {
}
});
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (plugin.getConfiguration()
.getBoolean("Island.Visitor.Vote")) {
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Return.Displayname"), null, null,
@@ -234,8 +229,7 @@ public class Leaderboard {
.getLeaderboardManager().getLeaderboard(
com.songoda.skyblock.leaderboard.Leaderboard.Type.valueOf(viewer.getType().name()));
- for (int i = 0; i < leaderboardIslands.size(); i++) {
- com.songoda.skyblock.leaderboard.Leaderboard leaderboard = leaderboardIslands.get(i);
+ for (com.songoda.skyblock.leaderboard.Leaderboard leaderboard : leaderboardIslands) {
Visit visit = leaderboard.getVisit();
int itemSlot = 0;
@@ -290,9 +284,7 @@ public class Leaderboard {
itemLore.add(
configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Word.Empty"));
} else {
- for (String signatureList : visit.getSiganture()) {
- itemLore.add(signatureList);
- }
+ itemLore.addAll(visit.getSiganture());
}
} else {
itemLore.add(itemLoreList);
@@ -332,19 +324,18 @@ public class Leaderboard {
}
}
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard",
- viewer.getType().name())));
+ nInv.setTitle(plugin.formatText(configLoad.getString("Menu.Leaderboard.Leaderboard.Title").replace("%leaderboard",
+ viewer.getType().name())));
nInv.setRows(6);
- Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open());
}
+ Bukkit.getServer().getScheduler().runTask(plugin, nInv::open);
}
}
public static class Viewer {
- private Type type;
+ private final Type type;
public Viewer(Type type) {
this.type = type;
diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java
index b0c8722d..a1c0956a 100644
--- a/src/main/java/com/songoda/skyblock/menus/Levelling.java
+++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java
@@ -65,7 +65,7 @@ public class Levelling {
return;
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (islandManager.getIsland(player) == null) {
@@ -175,16 +175,13 @@ public class Levelling {
List testIslandMaterialKeysOrdered = testIslandMaterials.keySet().stream().sorted().collect(Collectors.toList());
LinkedHashMap islandMaterials = new LinkedHashMap<>();
- Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "levelling.yml"));
- Config settingsConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
-
// Filter out ItemStacks that can't be displayed in the inventory
Inventory testInventory = Bukkit.createInventory(null, 9);
for (String materialName : testIslandMaterialKeysOrdered) {
- if (mainConfig.getFileConfiguration().getString("Materials." + materialName + ".Points") == null ||
- !settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") &&
- mainConfig.getFileConfiguration().getInt("Materials." + materialName + ".Points") <= 0)
+ if (plugin.getLevelling().getString("Materials." + materialName + ".Points") == null ||
+ !plugin.getConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") &&
+ plugin.getLevelling().getInt("Materials." + materialName + ".Points") <= 0)
continue;
long value = testIslandMaterials.get(materialName);
@@ -249,17 +246,17 @@ public class Levelling {
long materialAmount = islandMaterials.get(material);
- if (mainConfig.getFileConfiguration().getString("Materials." + material + ".Points") == null)
+ if (plugin.getLevelling().getString("Materials." + material + ".Points") == null)
break;
- double pointsMultiplier = mainConfig.getFileConfiguration().getDouble("Materials." + material + ".Points");
+ double pointsMultiplier = plugin.getLevelling().getDouble("Materials." + material + ".Points");
- if (!settingsConfig.getFileConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") && pointsMultiplier == 0)
+ if (!plugin.getConfiguration().getBoolean("Island.Levelling.IncludeEmptyPointsInList") && pointsMultiplier == 0)
return;
inventorySlot++;
- long materialLimit = mainConfig.getFileConfiguration().getLong("Materials." + material + ".Limit", -1);
+ long materialLimit = plugin.getLevelling().getLong("Materials." + material + ".Limit", -1);
long materialAmountCounted = Math.min(materialLimit, materialAmount);
if (materialLimit == -1)
@@ -289,9 +286,9 @@ public class Levelling {
}
}
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Title")));
+ nInv.setTitle(plugin.formatText(configLoad.getString("Menu.Levelling.Title")));
nInv.setRows(6);
- Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open());
+ Bukkit.getServer().getScheduler().runTask(plugin, nInv::open);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/songoda/skyblock/menus/Members.java b/src/main/java/com/songoda/skyblock/menus/Members.java
index 50b83df4..676b2e69 100644
--- a/src/main/java/com/songoda/skyblock/menus/Members.java
+++ b/src/main/java/com/songoda/skyblock/menus/Members.java
@@ -53,8 +53,7 @@ public class Members {
FileManager fileManager = plugin.getFileManager();
if (playerDataManager.hasPlayerData(player)) {
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (playerDataManager.hasPlayerData(player)) {
@@ -333,7 +332,7 @@ public class Members {
new Placeholder("%island_members",
"" + (islandMembers.size() + islandOperators.size() + 1)),
new Placeholder("%island_capacity",
- "" + island.getMaxMembers()),
+ "" + island.getMaxMembers(player)),
new Placeholder("%members", "" + islandMembers.size()),
new Placeholder("%operators", "" + islandOperators.size())},
null, null), 4);
diff --git a/src/main/java/com/songoda/skyblock/menus/Ownership.java b/src/main/java/com/songoda/skyblock/menus/Ownership.java
index 788a27a0..dbe10376 100644
--- a/src/main/java/com/songoda/skyblock/menus/Ownership.java
+++ b/src/main/java/com/songoda/skyblock/menus/Ownership.java
@@ -48,11 +48,9 @@ public class Ownership {
MessageManager messageManager = plugin.getMessageManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
- FileManager fileManager = plugin.getFileManager();
if (playerDataManager.hasPlayerData(player)) {
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (playerDataManager.hasPlayerData(player)) {
diff --git a/src/main/java/com/songoda/skyblock/menus/Settings.java b/src/main/java/com/songoda/skyblock/menus/Settings.java
index 81990404..80131366 100644
--- a/src/main/java/com/songoda/skyblock/menus/Settings.java
+++ b/src/main/java/com/songoda/skyblock/menus/Settings.java
@@ -15,7 +15,6 @@ import com.songoda.skyblock.utils.AbstractAnvilGUI;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.visit.Visit;
import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@@ -53,9 +52,8 @@ public class Settings {
if (playerDataManager.hasPlayerData(player)) {
Island island = islandManager.getIsland(player);
- Config mainConfig = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
+ FileConfiguration mainConfig = plugin.getConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
if (menuType == Settings.Type.Categories) {
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
@@ -80,13 +78,11 @@ public class Settings {
ItemStack is = event.getItem();
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
- '&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
} else if ((is.getType() == Material.NAME_TAG) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
- '&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Settings.Categories.Item.Coop.Displayname"))))) {
if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Coop.Enable")) {
@@ -113,7 +109,7 @@ public class Settings {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Coop, null), 1L);
} else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .equals(plugin.formatText(configLoad
.getString("Menu.Settings.Categories.Item.Visitor.Displayname"))))) {
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())
&& !permissionManager.hasPermission(island13, "Visitor", IslandRole.Operator)) {
@@ -132,7 +128,7 @@ public class Settings {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Visitor, null), 1L);
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .equals(plugin.formatText(configLoad
.getString("Menu.Settings.Categories.Item.Member.Displayname"))))) {
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())
&& !permissionManager.hasPermission(island13, "Member", IslandRole.Operator)) {
@@ -150,7 +146,7 @@ public class Settings {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Member, null), 1L);
} else if ((is.getType() == Material.ITEM_FRAME) && (is.hasItemMeta()) && (is.getItemMeta()
- .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .getDisplayName().equals(plugin.formatText(configLoad
.getString("Menu.Settings.Categories.Item.Operator.Displayname"))))) {
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())) {
messageManager.sendMessage(player,
@@ -168,7 +164,7 @@ public class Settings {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Role, IslandRole.Operator, null), 1L);
} else if ((is.getType() == CompatibleMaterial.OAK_SAPLING.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .equals(plugin.formatText(configLoad
.getString("Menu.Settings.Categories.Item.Owner.Displayname"))))) {
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())
&& !permissionManager.hasPermission(island13,"Island", IslandRole.Operator)) {
@@ -199,7 +195,7 @@ public class Settings {
configLoad.getString("Menu.Settings.Categories.Item.Operator.Displayname"),
configLoad.getStringList("Menu.Settings.Categories.Item.Operator.Lore"), null, null, null), 4);
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (plugin.getConfiguration()
.getBoolean("Island.Coop.Enable")) {
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Settings.Categories.Item.Exit.Displayname"), null, null, null,
@@ -219,8 +215,7 @@ public class Settings {
configLoad.getStringList("Menu.Settings.Categories.Item.Owner.Lore"), null, null, null), 6);
}
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Settings.Categories.Title")));
+ nInv.setTitle(plugin.formatText(configLoad.getString("Menu.Settings.Categories.Title")));
nInv.setRows(1);
Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open());
@@ -264,27 +259,23 @@ public class Settings {
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
- "Menu.Settings." + role.name() + ".Item.Return.Displayname"))))) {
+ .equals(plugin.formatText(configLoad.getString("Menu.Settings." + role.name() + ".Item.Return.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Categories, null, null), 1L);
} else if ((is.getType() == Material.PAPER) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
- .getString("Menu.Settings.Visitor.Item.Signature.Displayname"))))) {
+ .equals(plugin.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Signature.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Panel, null, Panel.Signature), 1L);
} else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Settings.Visitor.Item.Welcome.Displayname"))))) {
+ .equals(plugin.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Welcome.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player, Type.Panel, null, Panel.Welcome), 1L);
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta()
- .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad
- .getString("Menu.Settings.Visitor.Item.Statistics.Displayname"))))) {
+ .getDisplayName().equals(plugin.formatText(configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"))))) {
switch (island14.getStatus()) {
case OPEN:
islandManager.whitelistIsland(island14);
@@ -306,7 +297,7 @@ public class Settings {
for (IslandPermission settingList : island14.getSettings(role)) {
if (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&',
+ .equals(plugin.formatText(
configLoad.getString("Menu.Settings." + roleName + ".Item.Setting."
+ settingList.getPermission().getName() + ".Displayname")))) {
if (!hasPermission(island14, player, role)) {
@@ -317,11 +308,7 @@ public class Settings {
return;
}
- if (settingList.getStatus()) {
- settingList.setStatus(false);
- } else {
- settingList.setStatus(true);
- }
+ settingList.setStatus(!settingList.getStatus());
if (settingList.getPermission().getName().equals("KeepItemsOnDeath")
|| settingList.getPermission().getName().equals("PvP")
@@ -488,13 +475,13 @@ public class Settings {
createItem(island, role, "ExperienceOrbPickup", CompatibleMaterial.EXPERIENCE_BOTTLE.getItem()),
53);
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
+ nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Settings." + role.name() + ".Title")));
nInv.setRows(6);
} else if (role == IslandRole.Operator) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Visitor.Banning")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Coop.Enable")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
+ if (mainConfig.getBoolean("Island.Visitor.Banning")) {
+ if (mainConfig.getBoolean("Island.Coop.Enable")) {
+ if (mainConfig.getBoolean("Island.WorldBorder.Enable")) {
nInv.addItemStack(
createItem(island, role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 9);
nInv.addItemStack(createItem(island, role, "Kick", new ItemStack(Material.IRON_DOOR)),
@@ -550,7 +537,7 @@ public class Settings {
nInv.addItemStack(createItem(island, role, "Weather", CompatibleMaterial.CLOCK.getItem()), 24);
}
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
+ if (mainConfig.getBoolean("Island.WorldBorder.Enable")) {
nInv.addItemStack(
createItem(island, role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10);
nInv.addItemStack(createItem(island, role, "Kick", new ItemStack(Material.IRON_DOOR)),
@@ -601,8 +588,8 @@ public class Settings {
nInv.setRows(3);
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Coop.Enable")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
+ if (mainConfig.getBoolean("Island.Coop.Enable")) {
+ if (mainConfig.getBoolean("Island.WorldBorder.Enable")) {
nInv.addItemStack(
createItem(island, role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10);
nInv.addItemStack(createItem(island, role, "Kick", new ItemStack(Material.IRON_DOOR)),
@@ -652,7 +639,7 @@ public class Settings {
nInv.setRows(3);
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.WorldBorder.Enable")) {
+ if (mainConfig.getBoolean("Island.WorldBorder.Enable")) {
nInv.addItemStack(
createItem(island, role, "Invite", CompatibleMaterial.WRITABLE_BOOK.getItem()), 10);
nInv.addItemStack(createItem(island, role, "Kick", new ItemStack(Material.IRON_DOOR)),
@@ -698,13 +685,13 @@ public class Settings {
}
}
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
+ nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Settings." + role.name() + ".Title")));
} else if (role == IslandRole.Owner) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.PvP.Enable")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.PvP.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Damage.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(createItem(island, role, "NaturalMobSpawning",
CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9);
nInv.addItemStack(
@@ -749,7 +736,7 @@ public class Settings {
createItem(island, role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 17);
}
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(createItem(island, role, "NaturalMobSpawning",
CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9);
nInv.addItemStack(
@@ -791,8 +778,8 @@ public class Settings {
}
}
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Damage.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(createItem(island, role, "NaturalMobSpawning",
CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9);
nInv.addItemStack(
@@ -833,7 +820,7 @@ public class Settings {
createItem(island, role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16);
}
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(createItem(island, role, "NaturalMobSpawning",
CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 10);
nInv.addItemStack(
@@ -872,9 +859,9 @@ public class Settings {
}
}
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Damage.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(createItem(island, role, "NaturalMobSpawning",
CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 9);
nInv.addItemStack(
@@ -915,7 +902,7 @@ public class Settings {
createItem(island, role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16);
}
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(createItem(island, role, "NaturalMobSpawning",
CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 10);
nInv.addItemStack(
@@ -953,8 +940,8 @@ public class Settings {
}
}
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")) {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Damage.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(createItem(island, role, "NaturalMobSpawning",
CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 10);
nInv.addItemStack(
@@ -991,7 +978,7 @@ public class Settings {
createItem(island, role, "Damage", CompatibleMaterial.RED_DYE.getItem()), 16);
}
} else {
- if (mainConfig.getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")) {
+ if (mainConfig.getBoolean("Island.Settings.Hunger.Enable")) {
nInv.addItemStack(createItem(island, role, "NaturalMobSpawning",
CompatibleMaterial.PIG_SPAWN_EGG.getItem()), 10);
nInv.addItemStack(
@@ -1027,7 +1014,7 @@ public class Settings {
}
}
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
+ nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Settings." + role.name() + ".Title")));
nInv.setRows(2);
}
@@ -1072,7 +1059,7 @@ public class Settings {
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(
- ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Panel.Welcome.Item.Return.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
@@ -1080,7 +1067,7 @@ public class Settings {
() -> open(player, Type.Role, IslandRole.Visitor, null), 1L);
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(
- ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Item.Statistics.Displayname"))))) {
switch (island15.getStatus()) {
case OPEN:
@@ -1100,7 +1087,7 @@ public class Settings {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> open(player, Type.Role, IslandRole.Visitor, null), 1L);
} else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ .equals(plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Panel.Welcome.Item.Message.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, 1.0F);
@@ -1108,7 +1095,7 @@ public class Settings {
event.setWillDestroy(false);
} else if ((is.getType() == Material.ARROW) && (is.hasItemMeta()) && (is.getItemMeta()
.getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ .equals(plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Panel.Welcome.Item.Line.Add.Displayname"))))) {
if (island15.getMessage(IslandMessage.Welcome).size() >= plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "config.yml"))
@@ -1224,7 +1211,7 @@ public class Settings {
}
} else if ((is.getType() == Material.ARROW) && (is.hasItemMeta()) && (is.getItemMeta()
.getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ .equals(plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Panel.Welcome.Item.Line.Remove.Displayname"))))) {
List welcomeMessage = island15.getMessage(IslandMessage.Welcome);
@@ -1248,7 +1235,7 @@ public class Settings {
List welcomeMessage = island.getMessage(IslandMessage.Welcome);
- if (welcomeMessage.size() == mainConfig.getFileConfiguration()
+ if (welcomeMessage.size() == mainConfig
.getInt("Island.Visitor.Welcome.Lines")) {
nInv.addItem(nInv.createItem(new ItemStack(Material.ARROW),
configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Item.Line.Add.Displayname"),
@@ -1291,8 +1278,7 @@ public class Settings {
configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Item.Return.Displayname"), null,
null, null, null), 0, 4);
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Title")));
+ nInv.setTitle(plugin.formatText(configLoad.getString("Menu.Settings.Visitor.Panel.Welcome.Title")));
nInv.setType(InventoryType.HOPPER);
Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open());
@@ -1330,7 +1316,7 @@ public class Settings {
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(
- ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Panel.Signature.Item.Return.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
@@ -1338,7 +1324,7 @@ public class Settings {
() -> open(player, Type.Role, IslandRole.Visitor, null), 1L);
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(
- ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Item.Statistics.Displayname"))))) {
switch (island12.getStatus()) {
case OPEN:
@@ -1358,7 +1344,7 @@ public class Settings {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> open(player, Type.Role, IslandRole.Visitor, null), 1L);
} else if ((is.hasItemMeta()) && (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ .equals(plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Panel.Signature.Item.Message.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, 1.0F);
@@ -1366,7 +1352,7 @@ public class Settings {
event.setWillDestroy(false);
} else if ((is.getType() == Material.ARROW) && (is.hasItemMeta()) && (is.getItemMeta()
.getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ .equals(plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Panel.Signature.Item.Line.Add.Displayname"))))) {
if (island12.getMessage(IslandMessage.Signature).size() >= plugin.getFileManager()
.getConfig(new File(plugin.getDataFolder(), "config.yml"))
@@ -1482,7 +1468,7 @@ public class Settings {
}
} else if ((is.getType() == Material.ARROW) && (is.hasItemMeta()) && (is.getItemMeta()
.getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
+ .equals(plugin.formatText(configLoad.getString(
"Menu.Settings.Visitor.Panel.Signature.Item.Line.Remove.Displayname"))))) {
List signatureMessage = island12.getMessage(IslandMessage.Signature);
@@ -1507,7 +1493,7 @@ public class Settings {
List signatureMessage = island.getMessage(IslandMessage.Signature);
- if (signatureMessage.size() == mainConfig.getFileConfiguration()
+ if (signatureMessage.size() == mainConfig
.getInt("Island.Visitor.Signature.Lines")) {
nInv.addItem(nInv.createItem(new ItemStack(Material.ARROW),
configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Item.Line.Add.Displayname"),
@@ -1551,7 +1537,7 @@ public class Settings {
configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Item.Return.Displayname"), null,
null, null, null), 0, 4);
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
+ nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Settings.Visitor.Panel.Signature.Title")));
nInv.setType(InventoryType.HOPPER);
@@ -1578,18 +1564,18 @@ public class Settings {
roleName = "Default";
}
- im.setDisplayName(ChatColor.translateAlternateColorCodes('&',
+ im.setDisplayName(plugin.formatText(
configLoad.getString("Menu.Settings." + roleName + ".Item.Setting." + setting + ".Displayname")));
if (island.hasPermission(role, permissionManager.getPermission(setting))) {
for (String itemLoreList : configLoad
.getStringList("Menu.Settings." + roleName + ".Item.Setting.Status.Enabled.Lore")) {
- itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList));
+ itemLore.add(plugin.formatText(itemLoreList));
}
} else {
for (String itemLoreList : configLoad
.getStringList("Menu.Settings." + roleName + ".Item.Setting.Status.Disabled.Lore")) {
- itemLore.add(ChatColor.translateAlternateColorCodes('&', itemLoreList));
+ itemLore.add(plugin.formatText(itemLoreList));
}
}
diff --git a/src/main/java/com/songoda/skyblock/menus/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/Upgrade.java
index c043fae3..3770e1bd 100644
--- a/src/main/java/com/songoda/skyblock/menus/Upgrade.java
+++ b/src/main/java/com/songoda/skyblock/menus/Upgrade.java
@@ -54,11 +54,9 @@ public class Upgrade {
UpgradeManager upgradeManager = plugin.getUpgradeManager();
IslandManager islandManager = plugin.getIslandManager();
SoundManager soundManager = plugin.getSoundManager();
- FileManager fileManager = plugin.getFileManager();
Economy economy = plugin.getEconomyManager().getEconomy();
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
if (!economy.isEnabled()) {
messageManager.sendMessage(player, configLoad.getString("Island.Upgrade.Disabled.Message"));
@@ -91,7 +89,7 @@ public class Upgrade {
ItemStack is = event.getItem();
if ((is.getType() == Material.POTION) && (is.hasItemMeta())) {
- if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ if (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Upgrade.Item.Speed.Displayname")))) {
if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Speed)) {
if (island.isUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Speed)) {
@@ -206,11 +204,7 @@ public class Upgrade {
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Crop.Displayname"))))) {
if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Crop)) {
- if (island.isUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Crop)) {
- island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Crop, false);
- } else {
- island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Crop, true);
- }
+ island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Crop, !island.isUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Crop));
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@@ -308,12 +302,8 @@ public class Upgrade {
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Drops.Displayname"))))) {
if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Drops)) {
- if (island.isUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Drops)) {
- island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Drops,
- false);
- } else {
- island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Drops, true);
- }
+ island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Drops,
+ !island.isUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Drops));
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@@ -367,8 +357,8 @@ public class Upgrade {
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Members.Displayname")
.replace("%tier", "" + tier)))) {
- if (upgrade.getValue() > island.getMaxMembers()
- && upgrade.getValue() != island.getMaxMembers()) {
+ if (upgrade.getValue() > island.getMaxMembers(player)
+ && upgrade.getValue() != island.getMaxMembers(player)) {
if (economy.hasBalance(player, upgrade.getCost())) {
messageManager.sendMessage(player,
configLoad.getString("Island.Upgrade.Bought.Message").replace(
@@ -465,13 +455,8 @@ public class Upgrade {
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Spawner.Displayname"))))) {
if (island.hasUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner)) {
- if (island.isUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner)) {
- island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner,
- false);
- } else {
- island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner,
- true);
- }
+ island.setUpgrade(player, com.songoda.skyblock.upgrade.Upgrade.Type.Spawner,
+ !island.isUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner));
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@@ -749,12 +734,12 @@ public class Upgrade {
int tier = i + 1;
if (tier != upgrades.size()) {
- if (upgrade.getValue() <= island.getMaxMembers()) {
+ if (upgrade.getValue() <= island.getMaxMembers(player)) {
continue;
}
}
- if (island.getMaxMembers() >= upgrade.getValue()) {
+ if (island.getMaxMembers(player) >= upgrade.getValue()) {
nInv.addItem(nInv.createItem(new ItemStack(Material.BOOKSHELF),
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Upgrade.Item.Members.Displayname").replace("%tier",
@@ -910,8 +895,7 @@ public class Upgrade {
private String getStatus(Island island, com.songoda.skyblock.upgrade.Upgrade.Type type) {
SkyBlock plugin = SkyBlock.getInstance();
- FileConfiguration configLoad = plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
String upgradeStatus;
if (island.isUpgrade(type)) {
diff --git a/src/main/java/com/songoda/skyblock/menus/Visit.java b/src/main/java/com/songoda/skyblock/menus/Visit.java
index 1cb345fe..f483432c 100644
--- a/src/main/java/com/songoda/skyblock/menus/Visit.java
+++ b/src/main/java/com/songoda/skyblock/menus/Visit.java
@@ -54,8 +54,7 @@ public class Visit {
VisitManager visitManager = plugin.getVisitManager();
FileManager fileManager = plugin.getFileManager();
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (playerDataManager.hasPlayerData(player)) {
@@ -171,8 +170,7 @@ public class Visit {
if ((!island.hasRole(IslandRole.Member, player.getUniqueId())
&& !island.hasRole(IslandRole.Operator, player.getUniqueId())
&& !island.hasRole(IslandRole.Owner, player.getUniqueId()))
- && fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
+ && plugin.getConfiguration().getBoolean("Island.Visitor.Vote")) {
if (event.getClick() == ClickType.RIGHT) {
if (playerData.getIsland() != null
&& playerData.getIsland().equals(island.getOwnerUUID())) {
@@ -268,8 +266,7 @@ public class Visit {
Map openIslands = visitManager.getOpenIslands();
List visitIslands = new ArrayList<>();
- boolean keepBannedIslands = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Visit.Menu.Bans");
+ boolean keepBannedIslands = plugin.getConfiguration().getBoolean("Island.Visit.Menu.Bans");
for (int i = 0; i < openIslands.size(); i++) {
UUID islandOwnerUUID = (UUID) openIslands.keySet().toArray()[i];
@@ -383,14 +380,12 @@ public class Visit {
nInv.addItem(nInv.createItem(new ItemStack(Material.BARRIER),
configLoad.getString("Menu.Visit.Item.Nothing.Displayname"), null, null, null, null), 31);
} else {
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"));
-
int index = playerMenuPage * 36 - 36,
endIndex = index >= visitIslands.size() ? visitIslands.size() - 1 : index + 36, inventorySlot = 17,
- playerCapacity = config.getFileConfiguration().getInt("Island.Visitor.Capacity");
+ playerCapacity = plugin.getConfiguration().getInt("Island.Visitor.Capacity");
- boolean voteEnabled = config.getFileConfiguration().getBoolean("Island.Visitor.Vote");
- boolean signatureEnabled = config.getFileConfiguration().getBoolean("Island.Visitor.Signature.Enable");
+ boolean voteEnabled = plugin.getConfiguration().getBoolean("Island.Visitor.Vote");
+ boolean signatureEnabled = plugin.getConfiguration().getBoolean("Island.Visitor.Signature.Enable");
for (; index < endIndex; index++) {
if (visitIslands.size() > index) {
diff --git a/src/main/java/com/songoda/skyblock/menus/Visitors.java b/src/main/java/com/songoda/skyblock/menus/Visitors.java
index 9d5f747a..32a235b2 100644
--- a/src/main/java/com/songoda/skyblock/menus/Visitors.java
+++ b/src/main/java/com/songoda/skyblock/menus/Visitors.java
@@ -48,8 +48,7 @@ public class Visitors {
FileManager fileManager = plugin.getFileManager();
if (playerDataManager.hasPlayerData(player)) {
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (playerDataManager.hasPlayerData(player)) {
@@ -109,9 +108,7 @@ public class Visitors {
isOwner = island.hasRole(IslandRole.Owner, player.getUniqueId()),
canKick = permissionManager.hasPermission(island, "Kick", IslandRole.Operator),
canBan = permissionManager.hasPermission(island, "Ban", IslandRole.Operator),
- banningEnabled = fileManager
- .getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Visitor.Banning");
+ banningEnabled = plugin.getConfiguration().getBoolean("Island.Visitor.Banning");
String playerName = ChatColor.stripColor(is.getItemMeta().getDisplayName());
if ((isOperator && canKick) || isOwner) {
@@ -213,8 +210,7 @@ public class Visitors {
isOwner = island.hasRole(IslandRole.Owner, player.getUniqueId()),
canKick = plugin.getPermissionManager().hasPermission(island, "Kick", IslandRole.Operator),
canBan = plugin.getPermissionManager().hasPermission(island, "Ban", IslandRole.Operator),
- banningEnabled = fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Visitor.Banning");
+ banningEnabled = plugin.getConfiguration().getBoolean("Island.Visitor.Banning");
int index = playerMenuPage * 36 - 36,
endIndex = index >= islandVisitors.size() ? islandVisitors.size() - 1 : index + 36,
inventorySlot = 17;
diff --git a/src/main/java/com/songoda/skyblock/menus/Weather.java b/src/main/java/com/songoda/skyblock/menus/Weather.java
index e1174d9a..902194a9 100644
--- a/src/main/java/com/songoda/skyblock/menus/Weather.java
+++ b/src/main/java/com/songoda/skyblock/menus/Weather.java
@@ -45,11 +45,9 @@ public class Weather {
IslandManager islandManager = plugin.getIslandManager();
PermissionManager permissionManager = plugin.getPermissionManager();
SoundManager soundManager = plugin.getSoundManager();
- FileManager fileManager = plugin.getFileManager();
if (playerDataManager.hasPlayerData(player)) {
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (playerDataManager.hasPlayerData(player)) {
@@ -118,8 +116,7 @@ public class Weather {
all.resetPlayerTime();
all.resetPlayerWeather();
all.setPlayerTime(island.getTime(),
- fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
+ plugin.getConfiguration().getBoolean("Island.Weather.Time.Cycle"));
all.setPlayerWeather(island.getWeather());
}
}
@@ -141,8 +138,7 @@ public class Weather {
all.resetPlayerTime();
all.resetPlayerWeather();
all.setPlayerTime(island.getTime(),
- fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
+ plugin.getConfiguration().getBoolean("Island.Weather.Time.Cycle"));
all.setPlayerWeather(island.getWeather());
}
}
@@ -161,8 +157,7 @@ public class Weather {
for (Player all : islandManager.getPlayersAtIsland(island, IslandWorld.Normal)) {
all.setPlayerTime(islandTime,
- fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
+ plugin.getConfiguration().getBoolean("Island.Weather.Time.Cycle"));
all.setPlayerWeather(islandWeather);
}
} else {
diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Creator.java b/src/main/java/com/songoda/skyblock/menus/admin/Creator.java
index 11253c25..5c14c52c 100644
--- a/src/main/java/com/songoda/skyblock/menus/admin/Creator.java
+++ b/src/main/java/com/songoda/skyblock/menus/admin/Creator.java
@@ -55,8 +55,7 @@ public class Creator implements Listener {
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, null);
@@ -778,11 +777,7 @@ public class Creator implements Listener {
if (structureManager.containsStructure(name)) {
Structure structure = structureManager.getStructure(name);
- if (structure.isPermission()) {
- structure.setPermission(false);
- } else {
- structure.setPermission(true);
- }
+ structure.setPermission(!structure.isPermission());
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@@ -1148,24 +1143,22 @@ public class Creator implements Listener {
CompatibleMaterial materials = CompatibleMaterial.getMaterial(event.getCurrentItem().getType());
materials.getItem().setData(event.getCurrentItem().getData());
- if (materials != null) {
- structure.setMaterial(materials);
+ structure.setMaterial(materials);
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
- Config config113 = fileManager
- .getConfig(new File(plugin.getDataFolder(), "structures.yml"));
- FileConfiguration configLoad113 = config113.getFileConfiguration();
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
+ Config config113 = fileManager
+ .getConfig(new File(plugin.getDataFolder(), "structures.yml"));
+ FileConfiguration configLoad113 = config113.getFileConfiguration();
- configLoad113.set("Structures." + structure.getName() + ".Item.Material",
- structure.getMaterial().name());
+ configLoad113.set("Structures." + structure.getName() + ".Item.Material",
+ structure.getMaterial().name());
- try {
- configLoad113.save(config113.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
- }
+ try {
+ configLoad113.save(config113.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
viewer.setItem(false);
@@ -1286,7 +1279,7 @@ public class Creator implements Listener {
public class Viewer {
- private String name;
+ private final String name;
private boolean item = false;
public Viewer(String name) {
diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Generator.java b/src/main/java/com/songoda/skyblock/menus/admin/Generator.java
index c0fba741..85ffe496 100644
--- a/src/main/java/com/songoda/skyblock/menus/admin/Generator.java
+++ b/src/main/java/com/songoda/skyblock/menus/admin/Generator.java
@@ -55,8 +55,7 @@ public class Generator implements Listener {
PlayerData playerData = plugin.getPlayerDataManager().getPlayerData(player);
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, null);
@@ -190,8 +189,7 @@ public class Generator implements Listener {
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
String inventoryName = "";
if (NMSUtil.getVersionNumber() > 13) {
@@ -288,7 +286,7 @@ public class Generator implements Listener {
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
Config config14 = fileManager
.getConfig(new File(plugin.getDataFolder(), "generators.yml"));
- FileConfiguration configLoad14 = config14.getFileConfiguration();
+ FileConfiguration configLoad14 = plugin.getGenerators();
configLoad14.set("Generators." + event1.getName() + ".Name", event1.getName());
@@ -340,11 +338,7 @@ public class Generator implements Listener {
if (generatorManager.containsGenerator(name)) {
com.songoda.skyblock.generator.Generator generator = generatorManager.getGenerator(name);
- if (generator.isPermission()) {
- generator.setPermission(false);
- } else {
- generator.setPermission(true);
- }
+ generator.setPermission(!generator.isPermission());
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@@ -680,7 +674,7 @@ public class Generator implements Listener {
public class Viewer {
- private String name;
+ private final String name;
public Viewer(String name) {
this.name = name;
diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java
index 22397636..df2af1ed 100644
--- a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java
+++ b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java
@@ -66,14 +66,13 @@ public class Levelling implements Listener {
ItemStack itemStack = x.getMaterials().getItem();
itemStack.setAmount(1);
itemStack.setDurability(x.getItemStack().getDurability());
- if (itemStack == null || itemStack.getItemMeta() == null) return false;
+ if (itemStack.getItemMeta() == null) return false;
testInventory.clear();
testInventory.setItem(0, itemStack);
return testInventory.getItem(0) != null;
}).collect(Collectors.toList());
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
nInventoryUtil nInv = new nInventoryUtil(player, null);
nInv.addItem(
@@ -162,8 +161,7 @@ public class Levelling implements Listener {
SoundManager soundManager = plugin.getSoundManager();
FileManager fileManager = plugin.getFileManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
String inventoryName = "";
if (NMSUtil.getVersionNumber() > 13) {
diff --git a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java
index d541b949..58aa335f 100644
--- a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java
+++ b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java
@@ -16,7 +16,6 @@ import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@@ -55,8 +54,7 @@ public class Upgrade {
FileManager fileManager = plugin.getFileManager();
if (playerDataManager.hasPlayerData(player) && playerDataManager.getPlayerData(player).getViewer() != null) {
- FileConfiguration configLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
Viewer viewer = (Upgrade.Viewer) playerDataManager.getPlayerData(player).getViewer();
if (viewer == null || viewer.getType() == Upgrade.Viewer.Type.Upgrades) {
@@ -74,43 +72,43 @@ public class Upgrade {
com.songoda.skyblock.upgrade.Upgrade upgrade = null;
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Exit.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
return;
} else if ((is.getType() == Material.POTION) && (is.hasItemMeta())) {
- if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ if (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Speed.Displayname")))) {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Speed)
.get(0);
viewer.setUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Speed);
- } else if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes(
- '&', configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Jump.Displayname")))) {
+ } else if (is.getItemMeta().getDisplayName().equals(plugin.formatText(
+ configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Jump.Displayname")))) {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Jump)
.get(0);
viewer.setUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Jump);
}
} else if ((is.getType() == CompatibleMaterial.WHEAT_SEEDS.getMaterial()) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Crop.Displayname"))))) {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Crop)
.get(0);
viewer.setUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Crop);
} else if ((is.getType() == Material.FEATHER) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Fly.Displayname"))))) {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Fly)
.get(0);
viewer.setUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Fly);
} else if ((is.getType() == Material.SPIDER_EYE) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Drops.Displayname"))))) {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Drops)
.get(0);
viewer.setUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Drops);
} else if ((is.getType() == Material.BEACON) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Size.Displayname"))))) {
viewer.setType(Viewer.Type.Size);
viewer.setUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Size);
@@ -119,7 +117,7 @@ public class Upgrade {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L);
} else if ((is.getType() == Material.BOOKSHELF) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
+ && (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Members.Displayname"))))) {
viewer.setType(Viewer.Type.Members);
viewer.setUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Members);
@@ -129,7 +127,7 @@ public class Upgrade {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L);
} else if ((is.getType() == CompatibleMaterial.SPAWNER.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .equals(plugin.formatText(configLoad
.getString("Menu.Admin.Upgrade.Upgrades.Item.Spawner.Displayname"))))) {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner)
.get(0);
@@ -138,11 +136,7 @@ public class Upgrade {
if (upgrade != null) {
if (event.getClick() == ClickType.LEFT) {
- if (upgrade.isEnabled()) {
- upgrade.setEnabled(false);
- } else {
- upgrade.setEnabled(true);
- }
+ upgrade.setEnabled(!upgrade.isEnabled());
if (playerDataManager.hasPlayerData(player)) {
com.songoda.skyblock.upgrade.Upgrade.Type upgradeType = ((Viewer) playerDataManager
@@ -272,7 +266,7 @@ public class Upgrade {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Speed).get(0);
nInv.addItem(nInv.createItem(speedPotion,
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Speed.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Speed.Lore"),
new Placeholder[]{
@@ -290,7 +284,7 @@ public class Upgrade {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Jump).get(0);
nInv.addItem(nInv.createItem(jumpPotion,
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Jump.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Jump.Lore"),
new Placeholder[]{
@@ -300,7 +294,7 @@ public class Upgrade {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Crop).get(0);
nInv.addItem(nInv.createItem(CompatibleMaterial.WHEAT_SEEDS.getItem(),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Crop.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Crop.Lore"),
new Placeholder[]{
@@ -310,7 +304,7 @@ public class Upgrade {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Fly).get(0);
nInv.addItem(nInv.createItem(new ItemStack(Material.FEATHER),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Fly.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Fly.Lore"),
new Placeholder[]{
@@ -320,7 +314,7 @@ public class Upgrade {
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Drops).get(0);
nInv.addItem(nInv.createItem(new ItemStack(Material.SPIDER_EYE),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Drops.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Drops.Lore"),
new Placeholder[]{
@@ -338,7 +332,7 @@ public class Upgrade {
}
nInv.addItem(nInv.createItem(new ItemStack(Material.BEACON),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Size.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Size.Lore"),
new Placeholder[]{new Placeholder("%tiers", "" + upgradeTiersSize)}, null, null), 5);
@@ -352,16 +346,14 @@ public class Upgrade {
upgradeTiersMembers = upgradesMembers.size();
}
- nInv.addItem(nInv.createItem(CompatibleMaterial.BOOKSHELF.getItem(),
- ChatColor.translateAlternateColorCodes('&',
+ nInv.addItem(nInv.createItem(CompatibleMaterial.BOOKSHELF.getItem(), plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Members.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Members.Lore"),
new Placeholder[]{new Placeholder("%tiers", "" + upgradeTiersMembers)}, null, null), 4);
upgrade = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Spawner).get(0);
nInv.addItem(nInv.createItem(CompatibleMaterial.SPAWNER.getItem(),
- ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Spawner.Displayname")),
+ plugin.formatText(configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Spawner.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Upgrades.Item.Spawner.Lore"),
new Placeholder[]{
new Placeholder("%cost", NumberUtil.formatNumberByDecimal(upgrade.getCost())),
@@ -369,15 +361,13 @@ public class Upgrade {
null, null), 6);
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
- ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Exit.Displayname")),
+ plugin.formatText(configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Exit.Displayname")),
null, null, null, null), 8);
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Admin.Upgrade.Upgrades.Title")));
+ nInv.setTitle(plugin.formatText(configLoad.getString("Menu.Admin.Upgrade.Upgrades.Title")));
nInv.setRows(1);
- Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open());
+ Bukkit.getServer().getScheduler().runTask(plugin, nInv::open);
} else if (viewer.getType() == Upgrade.Viewer.Type.Size) {
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (!(player.hasPermission("fabledskyblock.admin.upgrade") || player.hasPermission("fabledskyblock.admin.*")
@@ -395,14 +385,14 @@ public class Upgrade {
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .equals(plugin.formatText(configLoad
.getString("Menu.Admin.Upgrade.Size.Item.Return.Displayname"))))) {
playerData.setViewer(new Viewer(Viewer.Type.Upgrades, null));
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L);
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta()
- .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .getDisplayName().equals(plugin.formatText(configLoad
.getString("Menu.Admin.Upgrade.Size.Item.Information.Displayname"))))) {
List upgrades = upgradeManager
.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Size);
@@ -519,7 +509,7 @@ public class Upgrade {
} else if ((is.getType() == CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getMaterial())
&& (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .equals(plugin.formatText(configLoad
.getString("Menu.Admin.Upgrade.Size.Item.Barrier.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
@@ -763,16 +753,16 @@ public class Upgrade {
});
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Size.Item.Return.Displayname")),
null, null, null, null), 0);
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Size.Item.Information.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Size.Item.Information.Lore"), null, null, null),
1);
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Size.Item.Barrier.Displayname")),
null, null, null, null), 2);
@@ -787,7 +777,7 @@ public class Upgrade {
if (upgrade != null) {
nInv.addItem(nInv.createItem(new ItemStack(Material.PAPER, tier),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Size.Item.Tier.Displayname")
.replace("%tier", "" + tier)),
configLoad.getStringList("Menu.Admin.Upgrade.Size.Item.Tier.Lore"),
@@ -800,11 +790,11 @@ public class Upgrade {
}
}
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
+ nInv.setTitle(plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Size.Title")));
nInv.setRows(1);
- Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open());
+ Bukkit.getServer().getScheduler().runTask(plugin, nInv::open);
} else if (viewer.getType() == Viewer.Type.Members) {
nInventoryUtil nInv = new nInventoryUtil(player, event -> {
if (!(player.hasPermission("fabledskyblock.admin.upgrade") || player.hasPermission("fabledskyblock.admin.*")
@@ -822,14 +812,14 @@ public class Upgrade {
if ((is.getType() == CompatibleMaterial.OAK_FENCE_GATE.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .equals(plugin.formatText(configLoad
.getString("Menu.Admin.Upgrade.Members.Item.Return.Displayname"))))) {
playerData.setViewer(new Viewer(Viewer.Type.Upgrades, null));
soundManager.playSound(player, CompatibleSound.ENTITY_ARROW_HIT.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L);
} else if ((is.getType() == Material.PAINTING) && (is.hasItemMeta()) && (is.getItemMeta()
- .getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .getDisplayName().equals(plugin.formatText(configLoad
.getString("Menu.Admin.Upgrade.Members.Item.Information.Displayname"))))) {
List upgrades = upgradeManager
.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Members);
@@ -946,7 +936,7 @@ public class Upgrade {
} else if ((is.getType() == CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getMaterial())
&& (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName()
- .equals(ChatColor.translateAlternateColorCodes('&', configLoad
+ .equals(plugin.formatText(configLoad
.getString("Menu.Admin.Upgrade.Members.Item.Barrier.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_GLASS_BREAK.getSound(), 1.0F, 1.0F);
@@ -1190,16 +1180,16 @@ public class Upgrade {
});
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Members.Item.Return.Displayname")),
null, null, null, null), 0);
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Members.Item.Information.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Members.Item.Information.Lore"), null, null, null),
1);
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Members.Item.Barrier.Displayname")),
null, null, null, null), 2);
@@ -1214,7 +1204,7 @@ public class Upgrade {
if (upgrade != null) {
nInv.addItem(nInv.createItem(new ItemStack(Material.PAPER, tier),
- ChatColor.translateAlternateColorCodes('&',
+ plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Members.Item.Tier.Displayname")
.replace("%tier", "" + tier)),
configLoad.getStringList("Menu.Admin.Upgrade.Members.Item.Tier.Lore"),
@@ -1227,19 +1217,16 @@ public class Upgrade {
}
}
- nInv.setTitle(ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Admin.Upgrade.Members.Title")));
+ nInv.setTitle(plugin.formatText(configLoad.getString("Menu.Admin.Upgrade.Members.Title")));
nInv.setRows(1);
- Bukkit.getServer().getScheduler().runTask(plugin, () -> nInv.open());
+ Bukkit.getServer().getScheduler().runTask(plugin, nInv::open);
}
}
}
private String getStatus(com.songoda.skyblock.upgrade.Upgrade upgrade) {
- SkyBlock plugin = SkyBlock.getInstance();
- FileConfiguration configLoad = plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(), "language.yml")).getFileConfiguration();
+ FileConfiguration configLoad = SkyBlock.getInstance().getLanguage();
if (upgrade.isEnabled()) {
return configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Word.Disable");
diff --git a/src/main/java/com/songoda/skyblock/message/MessageManager.java b/src/main/java/com/songoda/skyblock/message/MessageManager.java
index 5285d36f..64c97b48 100644
--- a/src/main/java/com/songoda/skyblock/message/MessageManager.java
+++ b/src/main/java/com/songoda/skyblock/message/MessageManager.java
@@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
public class MessageManager {
@@ -45,15 +46,10 @@ public class MessageManager {
}
} else {
if (message.contains("\n") || message.contains("\\n")) {
- List messages = new ArrayList<>();
message = message.replace("\\n", "\n");
- for (String messageList : message.split("\n")) {
- messages.add(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', messageList)));
- }
-
- sender.sendMessage(messages.toArray(new String[messages.size()]));
+ sender.sendMessage(Arrays.stream(message.split("\n")).map(messageList -> ChatColor.stripColor(plugin.formatText(messageList))).toArray(String[]::new));
} else {
sender.sendMessage(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', message)));
}
diff --git a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java
index cbc80da6..a358ef6a 100644
--- a/src/main/java/com/songoda/skyblock/permission/BasicPermission.java
+++ b/src/main/java/com/songoda/skyblock/permission/BasicPermission.java
@@ -34,9 +34,7 @@ public abstract class BasicPermission {
public ItemStack getItem(boolean permissionEnabled, IslandRole role) {
ItemStack is = icon.getItem();
- FileManager.Config config = SkyBlock.getInstance().getFileManager()
- .getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = SkyBlock.getInstance().getLanguage();
List itemLore = new ArrayList<>();
diff --git a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java
index f07087e9..b4a456db 100644
--- a/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java
+++ b/src/main/java/com/songoda/skyblock/permission/ListeningPermission.java
@@ -88,8 +88,7 @@ public abstract class ListeningPermission extends BasicPermission {
}
messageManager.sendMessage(player,
- plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ plugin.getLanguage().getString("Island.Settings.Permission.Message"));
plugin.getSoundManager().playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1f, 1f);
}
diff --git a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java
index 20f0eff9..d773a7fc 100644
--- a/src/main/java/com/songoda/skyblock/permission/PermissionManager.java
+++ b/src/main/java/com/songoda/skyblock/permission/PermissionManager.java
@@ -59,6 +59,7 @@ public class PermissionManager {
new TramplePermission(plugin),
new PressurePlatePermission(plugin),
new CakePermission(plugin),
+ new TrapdoorPermission(plugin),
new PlacePermission(plugin),
new LeashPermission(plugin),
new AnimalBreedingPermission(plugin),
@@ -101,33 +102,28 @@ public class PermissionManager {
new MainSpawnPermission(),
new VisitorSpawnPermission());
- if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Settings.KeepItemsOnDeath.Enable")){
+ if(plugin.getConfiguration().getBoolean("Island.Settings.KeepItemsOnDeath.Enable")){
registerPermission(new KeepItemsOnDeathPermission());
}
- if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Settings.PvP.Enable")){
+ if(plugin.getConfiguration().getBoolean("Island.Settings.PvP.Enable")){
registerPermission(new PvpPermission(plugin));
}
- if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Settings.Damage.Enable")){
+ if(plugin.getConfiguration().getBoolean("Island.Settings.Damage.Enable")){
registerPermission(new DamagePermission(plugin));
}
- if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Settings.Hunger.Enable")){
+ if(plugin.getConfiguration().getBoolean("Island.Settings.Hunger.Enable")){
registerPermission(new HungerPermission(plugin));
}
- registeredHandlers = registeredHandlers.stream().sorted(Comparator.comparingInt(h -> {
- final PermissionHandler permissionHandler = h.getHandler().getAnnotation(PermissionHandler.class);
- return permissionHandler.priority().ordinal();
- })).collect(Collectors.toList());
+ registeredHandlers = registeredHandlers.stream()
+ .sorted(Comparator.comparingInt(h -> h.getHandler().getAnnotation(PermissionHandler.class).priority().ordinal()))
+ .collect(Collectors.toList());
}
- private void updateSettingsConfig(BasicPermission permission){
+ private synchronized void updateSettingsConfig(BasicPermission permission){
FileManager.Config settingsConfig = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "settings.yml"));
FileConfiguration settingsConfigLoad = settingsConfig.getFileConfiguration();
@@ -174,19 +170,12 @@ public class PermissionManager {
} catch (NoClassDefFoundError e) {
return false;
}
- for (Method method : methods) {
- final PermissionHandler permissionHandler = method.getAnnotation(PermissionHandler.class);
- if (permissionHandler == null) continue;
- registeredHandlers.add(new HandlerWrapper(permission, method));
- }
+ methods.stream().filter(method -> method.getAnnotation(PermissionHandler.class) != null).forEachOrdered(method -> registeredHandlers.add(new HandlerWrapper(permission, method)));
return true;
}
public boolean registerPermissions(BasicPermission... permissions) {
- for (BasicPermission permission : permissions)
- if (!registerPermission(permission))
- return false;
- return true;
+ return Arrays.stream(permissions).allMatch(this::registerPermission);
}
public boolean processPermission(Cancellable cancellable, Island island) {
@@ -232,8 +221,7 @@ public class PermissionManager {
if (player.hasPermission("fabledskyblock.bypass." + permission.getName().toLowerCase()))
return !reversePermission;
- FileManager.Config config = SkyBlock.getInstance().getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = SkyBlock.getInstance().getConfiguration();
switch(island.getRole(player)){
case Owner:
diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DoorPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DoorPermission.java
index 7844dc6b..784166aa 100644
--- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DoorPermission.java
+++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DoorPermission.java
@@ -24,15 +24,19 @@ public class DoorPermission extends ListeningPermission {
@PermissionHandler
public void onInteract(PlayerInteractEvent event) {
-
-
- if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK)
+ if (event.getAction() != Action.LEFT_CLICK_BLOCK)
return;
-
+
Player player = event.getPlayer();
- if (event.getClickedBlock() instanceof Openable)
+ CompatibleMaterial material = CompatibleMaterial.getMaterial(event.getClickedBlock());
+ if (material == CompatibleMaterial.BIRCH_DOOR || material == CompatibleMaterial.ACACIA_DOOR
+ || material == CompatibleMaterial.DARK_OAK_DOOR || material == CompatibleMaterial.JUNGLE_DOOR
+ || material == CompatibleMaterial.SPRUCE_DOOR || material == CompatibleMaterial.OAK_DOOR)
cancelAndMessage(event, player, plugin, messageManager);
+
+
+
}
}
diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java
index 313975a4..13de7e7c 100644
--- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java
+++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/ExplosionsPermission.java
@@ -20,7 +20,7 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent;
public class ExplosionsPermission extends ListeningPermission {
- private SkyBlock plugin;
+ private final SkyBlock plugin;
public ExplosionsPermission(SkyBlock plugin) {
super("Explosions", CompatibleMaterial.GUNPOWDER, PermissionType.ISLAND);
diff --git a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java
index 6ace0f46..50f45601 100644
--- a/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java
+++ b/src/main/java/com/songoda/skyblock/placeholder/PlaceholderProcessor.java
@@ -246,7 +246,7 @@ public class PlaceholderProcessor {
} else {
returnValue = TextUtils.formatText(
placeholdersLoad.getString("Placeholders.fabledskyblock_island_maxmembers.Non-empty")
- .replace("{PLACEHOLDER}", "" + island.getMaxMembers()));
+ .replace("{PLACEHOLDER}", "" + island.getMaxMembers(player)));
}
break;
case "fabledskyblock_island_operators":
diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java
index 0644294f..b4dcea07 100644
--- a/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java
+++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerData.java
@@ -19,11 +19,11 @@ import java.util.*;
public class PlayerData {
private final SkyBlock plugin;
- private UUID uuid;
+ private final UUID uuid;
private UUID islandOwnerUUID;
private UUID ownershipUUID;
- private List pages;
+ private final List pages;
private int playTime;
private int visitTime;
private int confirmationTime;
@@ -33,10 +33,10 @@ public class PlayerData {
private Object type;
private Object sort;
- private Area area;
+ private final Area area;
private boolean chatSpy;
- private Set spiedIslands;
+ private final Set spiedIslands;
private boolean chat;
private boolean preview;
diff --git a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java
index ee0cdd6f..172951dc 100644
--- a/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java
+++ b/src/main/java/com/songoda/skyblock/playerdata/PlayerDataManager.java
@@ -27,7 +27,7 @@ import java.util.UUID;
public class PlayerDataManager {
private final SkyBlock plugin;
- private Map playerDataStorage = new HashMap<>();
+ private final Map playerDataStorage = new HashMap<>();
public PlayerDataManager(SkyBlock plugin) {
this.plugin = plugin;
@@ -128,12 +128,10 @@ public class PlayerDataManager {
public void storeIsland(Player player) {
MessageManager messageManager = plugin.getMessageManager();
IslandManager islandManager = plugin.getIslandManager();
- WorldManager worldManager = plugin.getWorldManager();
- FileManager fileManager = plugin.getFileManager();
+ WorldManager worldManager = plugin.getWorldManager();;
BanManager banManager = plugin.getBanManager();
- Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
if (hasPlayerData(player)) {
if (worldManager.isIslandWorld(player.getWorld())) {
@@ -150,7 +148,7 @@ public class PlayerDataManager {
targetPlayerName = targetPlayer.getName();
}
- if (banManager.hasIsland(island.getOwnerUUID()) && fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")
+ if (banManager.hasIsland(island.getOwnerUUID()) && this.plugin.getConfiguration().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));
@@ -161,7 +159,7 @@ public class PlayerDataManager {
if (world == IslandWorld.Normal) {
if (!island.isWeatherSynchronized()) {
- player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
+ player.setPlayerTime(island.getTime(), this.plugin.getConfiguration().getBoolean("Island.Weather.Time.Cycle"));
player.setPlayerWeather(island.getWeather());
}
}
@@ -181,7 +179,7 @@ public class PlayerDataManager {
if (world == IslandWorld.Normal) {
if (!island.isWeatherSynchronized()) {
- player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
+ player.setPlayerTime(island.getTime(), this.plugin.getConfiguration().getBoolean("Island.Weather.Time.Cycle"));
player.setPlayerWeather(island.getWeather());
}
}
@@ -192,6 +190,8 @@ public class PlayerDataManager {
for (Player loopPlayer : Bukkit.getOnlinePlayers()) {
PlayerData targetPlayerData = getPlayerData(loopPlayer);
+ if (targetPlayerData == null)
+ continue;
if (targetPlayerData.getOwner() != null &&
targetPlayerData.getOwner().equals(island.getOwnerUUID())) {
@@ -227,7 +227,7 @@ public class PlayerDataManager {
targetPlayerName = targetPlayer.getName();
}
- if (banManager.hasIsland(visitIslandList) && fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Visitor.Banning")
+ if (banManager.hasIsland(visitIslandList) && this.plugin.getConfiguration().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));
@@ -252,7 +252,7 @@ public class PlayerDataManager {
if (world == IslandWorld.Normal) {
if (!island.isWeatherSynchronized()) {
- player.setPlayerTime(island.getTime(), fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.Time.Cycle"));
+ player.setPlayerTime(island.getTime(), this.plugin.getConfiguration().getBoolean("Island.Weather.Time.Cycle"));
player.setPlayerWeather(island.getWeather());
}
}
diff --git a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java
index 985b8d1a..976ab4a8 100644
--- a/src/main/java/com/songoda/skyblock/scoreboard/Driver.java
+++ b/src/main/java/com/songoda/skyblock/scoreboard/Driver.java
@@ -14,15 +14,12 @@ import java.util.List;
class Driver extends BukkitRunnable {
- private final SkyBlock plugin;
-
private final Row title;
private final List rows;
private final List holders;
private final ScoreboardType boardType;
Driver(SkyBlock plugin, ScoreboardType boardType) {
- this.plugin = plugin;
FileManager fileManager = plugin.getFileManager();
FileConfiguration scoreboardLoad = fileManager.getConfig(
new File(plugin.getDataFolder(), "scoreboard.yml")).getFileConfiguration();
diff --git a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java
index 3ebd1f04..d275f903 100644
--- a/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java
+++ b/src/main/java/com/songoda/skyblock/scoreboard/ScoreboardManager.java
@@ -71,8 +71,8 @@ public class ScoreboardManager extends Manager {
IslandManager islandManager = plugin.getIslandManager();
PlayerData playerData = playerDataManager.getPlayerData(player);
- Island island = islandManager.getIslandByPlayer(player);
-
+ Island island = islandManager.getIsland(player);
+
if(playerData.isScoreboard()) {
ScoreboardType type;
if(island != null) {
diff --git a/src/main/java/com/songoda/skyblock/sound/SoundManager.java b/src/main/java/com/songoda/skyblock/sound/SoundManager.java
index 7c5a044e..f9b993fe 100644
--- a/src/main/java/com/songoda/skyblock/sound/SoundManager.java
+++ b/src/main/java/com/songoda/skyblock/sound/SoundManager.java
@@ -20,8 +20,7 @@ public class SoundManager {
public void playSound(CommandSender sender, Sound sound, float volume, float pitch) {
if (sender instanceof Player) {
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
if (configLoad.getBoolean("Sound.Enable")) {
Player player = (Player) sender;
@@ -31,10 +30,7 @@ public class SoundManager {
}
public void playSound(Location location, Sound sound, float volume, float pitch) {
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
-
- if (configLoad.getBoolean("Sound.Enable")) {
+ if (plugin.getConfiguration().getBoolean("Sound.Enable")) {
location.getWorld().playSound(location, sound, volume, pitch);
}
}
diff --git a/src/main/java/com/songoda/skyblock/stackable/Stackable.java b/src/main/java/com/songoda/skyblock/stackable/Stackable.java
index d760fc0a..ab257220 100644
--- a/src/main/java/com/songoda/skyblock/stackable/Stackable.java
+++ b/src/main/java/com/songoda/skyblock/stackable/Stackable.java
@@ -20,7 +20,7 @@ import java.util.UUID;
public class Stackable {
- private UUID uuid;
+ private final UUID uuid;
private Location location;
private CompatibleMaterial material;
@@ -183,7 +183,7 @@ public class Stackable {
private String getCustomName() {
return ChatColor
- .translateAlternateColorCodes('&', SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration().getString("Hologram.Stackable.Message"))
+ .translateAlternateColorCodes('&', SkyBlock.getInstance().getLanguage().getString("Hologram.Stackable.Message"))
.replace("%block", SkyBlock.getInstance().getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(material)).replace("%amount", NumberUtil.formatNumber(this.size));
}
}
diff --git a/src/main/java/com/songoda/skyblock/stackable/StackableManager.java b/src/main/java/com/songoda/skyblock/stackable/StackableManager.java
index f46ffd6f..84762397 100644
--- a/src/main/java/com/songoda/skyblock/stackable/StackableManager.java
+++ b/src/main/java/com/songoda/skyblock/stackable/StackableManager.java
@@ -19,8 +19,8 @@ public class StackableManager {
// ToDO: Should pobably be a GUI for this
private final SkyBlock plugin;
- private Set stackableMaterials = EnumSet.noneOf(CompatibleMaterial.class);
- private Map stacks = new HashMap<>();
+ private final Set stackableMaterials = EnumSet.noneOf(CompatibleMaterial.class);
+ private final Map stacks = new HashMap<>();
public StackableManager(SkyBlock plugin) {
this.plugin = plugin;
@@ -28,8 +28,7 @@ public class StackableManager {
}
public void registerStackables() {
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "stackables.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getStackables();
List stackableList = configLoad.getStringList("Stackables");
if (stackableList.isEmpty()) return;
diff --git a/src/main/java/com/songoda/skyblock/structure/Structure.java b/src/main/java/com/songoda/skyblock/structure/Structure.java
index ca09b8e6..7eaadb1b 100644
--- a/src/main/java/com/songoda/skyblock/structure/Structure.java
+++ b/src/main/java/com/songoda/skyblock/structure/Structure.java
@@ -9,7 +9,7 @@ public class Structure implements com.songoda.skyblock.api.structure.Structure {
private CompatibleMaterial material;
- private String name;
+ private final String name;
private String overworldFile;
private String netherFile;
private String endFile;
@@ -17,8 +17,8 @@ public class Structure implements com.songoda.skyblock.api.structure.Structure {
private boolean permission;
- private List description = new ArrayList<>();
- private List commands = new ArrayList<>();
+ private final List description;
+ private final List commands;
private double deletionCost;
diff --git a/src/main/java/com/songoda/skyblock/structure/StructureManager.java b/src/main/java/com/songoda/skyblock/structure/StructureManager.java
index 8bf54871..ced70b70 100644
--- a/src/main/java/com/songoda/skyblock/structure/StructureManager.java
+++ b/src/main/java/com/songoda/skyblock/structure/StructureManager.java
@@ -11,8 +11,7 @@ import java.util.List;
public class StructureManager {
- public List knownStructures;
- private List structureStorage = new ArrayList<>();
+ private final List structureStorage = new ArrayList<>();
public StructureManager(SkyBlock plugin) {
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "structures.yml"));
@@ -20,7 +19,7 @@ public class StructureManager {
if (configLoad.getString("Structures") != null) {
for (String structureList : configLoad.getConfigurationSection("Structures").getKeys(false)) {
- CompatibleMaterial materials = null;
+ CompatibleMaterial materials;
if (configLoad.getString("Structures." + structureList + ".Item.Material") == null) {
materials = CompatibleMaterial.GRASS_BLOCK;
@@ -73,8 +72,6 @@ public class StructureManager {
if (endFile == null && overworldFile != null) {
endFile = overworldFile;
- } else if (endFile == null && netherFile != null) {
- endFile = netherFile;
}
}
@@ -105,23 +102,11 @@ public class StructureManager {
}
public Structure getStructure(String name) {
- for (Structure structureList : structureStorage) {
- if (structureList.getName().equalsIgnoreCase(name)) {
- return structureList;
- }
- }
-
- return null;
+ return structureStorage.stream().filter(structureList -> structureList.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
}
public boolean containsStructure(String name) {
- for (Structure structureList : structureStorage) {
- if (structureList.getName().equalsIgnoreCase(name)) {
- return true;
- }
- }
-
- return false;
+ return structureStorage.stream().anyMatch(structureList -> structureList.getName().equalsIgnoreCase(name));
}
public List getStructures() {
diff --git a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java
index 1650f379..5810dc52 100644
--- a/src/main/java/com/songoda/skyblock/tasks/HologramTask.java
+++ b/src/main/java/com/songoda/skyblock/tasks/HologramTask.java
@@ -46,11 +46,9 @@ public class HologramTask extends BukkitRunnable {
@Override
public void run() {
- FileManager fileManager = plugin.getFileManager();
for (HologramType hologramTypeList : HologramType.values()) {
if (hologramTypeList == HologramType.Votes) {
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
+ if (!plugin.getConfiguration().getBoolean("Island.Visitor.Vote")) {
continue;
}
}
@@ -82,11 +80,9 @@ public class HologramTask extends BukkitRunnable {
}
private List getHologramLines(HologramType type) {
- FileManager fileManager = plugin.getFileManager();
LeaderboardManager leaderboardManager = plugin.getLeaderboardManager();
- FileConfiguration languageConfigLoad = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"))
- .getFileConfiguration();
+ FileConfiguration languageConfigLoad = plugin.getLanguage();
List hologramLines = new ArrayList<>();
Leaderboard.Type leaderboardType = null;
@@ -151,19 +147,12 @@ public class HologramTask extends BukkitRunnable {
}
public Hologram getHologram(HologramType type) {
- for (Hologram hologramList : hologramStorage) {
- if (hologramList.getType() == type) {
- return hologramList;
- }
- }
+ return hologramStorage.stream().filter(hologramList -> hologramList.getType() == type).findFirst().orElse(null);
- return null;
}
public void updateHologram() {
- for (Hologram hologramList : new ArrayList<>(hologramStorage)) {
- hologramList.update(getHologramLines(hologramList.getType()));
- }
+ new ArrayList<>(hologramStorage).forEach(hologramList -> hologramList.update(getHologramLines(hologramList.getType())));
}
public void removeHologram(Hologram hologram) {
diff --git a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java
index ca9c76d7..df0768c7 100644
--- a/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java
+++ b/src/main/java/com/songoda/skyblock/tasks/MobNetherWaterTask.java
@@ -37,9 +37,7 @@ public class MobNetherWaterTask extends BukkitRunnable {
@Override
public void run() {
- FileManager fileManager = plugin.getFileManager();
- if (fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml"))
- .getFileConfiguration().getBoolean("Island.Nether.WaterDisappearWithNetherMobs", false)){
+ if (plugin.getConfiguration().getBoolean("Island.Nether.WaterDisappearWithNetherMobs", false)){
for(World world : Bukkit.getServer().getWorlds()){
if(plugin.getWorldManager().isIslandWorld(world) && plugin.getWorldManager().getIslandWorld(world).equals(IslandWorld.Nether)){
for(Entity ent : world.getEntities()) {
diff --git a/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java b/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java
index b01e5f78..15059719 100644
--- a/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java
+++ b/src/main/java/com/songoda/skyblock/upgrade/UpgradeManager.java
@@ -16,14 +16,13 @@ import java.util.*;
public class UpgradeManager {
- private SkyBlock plugin;
- private Map> upgradeStorage = new HashMap<>();
+ private final SkyBlock plugin;
+ private final Map> upgradeStorage = new HashMap<>();
public UpgradeManager(SkyBlock plugin) {
this.plugin = plugin;
- Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "upgrades.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getUpgrades();
for (Upgrade.Type typeList : Upgrade.Type.values()) {
if (typeList != Upgrade.Type.Size && typeList != Upgrade.Type.Members) {
@@ -55,7 +54,7 @@ public class UpgradeManager {
}
if (configLoad.getString("Upgrades.Members") != null) {
- List upgrades = new ArrayList<>();
+ List upgrades = new LinkedList<>();
for (String tierList : configLoad.getConfigurationSection("Upgrades.Members").getKeys(false)) {
if (configLoad.getString("Upgrades.Members." + tierList + ".Value") != null) {
@@ -80,7 +79,7 @@ public class UpgradeManager {
}
- public void addUpgrade(Upgrade.Type type, int value) {
+ public synchronized void addUpgrade(Upgrade.Type type, int value) {
List upgrades = new ArrayList<>();
Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "upgrades.yml"));
@@ -215,6 +214,7 @@ public class UpgradeManager {
jump = new PotionEffect(PotionEffectType.JUMP, jump.getDuration() + 21, 1);
}
player.addPotionEffect(jump, true);
+ player.addPotionEffect(jump);
}
}
}
diff --git a/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java b/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java
index d7815dbf..27ca04ae 100644
--- a/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java
+++ b/src/main/java/com/songoda/skyblock/usercache/UserCacheManager.java
@@ -119,13 +119,7 @@ public final class UserCacheManager {
public boolean hasUser(String name) {
FileConfiguration configLoad = config.getFileConfiguration();
- for (String userList : configLoad.getConfigurationSection("").getKeys(false)) {
- if (configLoad.getString(userList).equalsIgnoreCase(name)) {
- return true;
- }
- }
-
- return false;
+ return configLoad.getConfigurationSection("").getKeys(false).stream().anyMatch(userList -> configLoad.getString(userList).equalsIgnoreCase(name));
}
public void saveAsync() {
diff --git a/src/main/java/com/songoda/skyblock/utils/AbstractAnvilGUI.java b/src/main/java/com/songoda/skyblock/utils/AbstractAnvilGUI.java
index e5c84d2d..29d84af0 100644
--- a/src/main/java/com/songoda/skyblock/utils/AbstractAnvilGUI.java
+++ b/src/main/java/com/songoda/skyblock/utils/AbstractAnvilGUI.java
@@ -23,19 +23,19 @@ import java.util.HashMap;
import java.util.Map;
public class AbstractAnvilGUI {
- private static Class> BlockPositionClass;
- private static Class> PacketPlayOutOpenWindowClass;
- private static Class> IChatBaseComponentClass;
- private static Class> ICraftingClass;
- private static Class> ContainerAnvilClass;
- private static Class> ChatMessageClass;
- private static Class> EntityHumanClass;
- private static Class> ContainerClass;
+ private static final Class> BlockPositionClass;
+ private static final Class> PacketPlayOutOpenWindowClass;
+ private static final Class> IChatBaseComponentClass;
+ private static final Class> ICraftingClass;
+ private static final Class> ContainerAnvilClass;
+ private static final Class> ChatMessageClass;
+ private static final Class> EntityHumanClass;
+ private static final Class> ContainerClass;
private static Class> ContainerAccessClass;
- private static Class> WorldClass;
- private static Class> PlayerInventoryClass;
+ private static final Class> WorldClass;
+ private static final Class> PlayerInventoryClass;
private static Class> ContainersClass;
- private static Class> CraftPlayerClass;
+ private static final Class> CraftPlayerClass;
static {
BlockPositionClass = NMSUtil.getNMSClass("BlockPosition");
@@ -211,7 +211,7 @@ public class AbstractAnvilGUI {
INPUT_RIGHT(1),
OUTPUT(2);
- private int slot;
+ private final int slot;
AnvilSlot(int slot) {
this.slot = slot;
@@ -238,9 +238,9 @@ public class AbstractAnvilGUI {
}
public class AnvilClickEvent {
- private AnvilSlot slot;
+ private final AnvilSlot slot;
- private String name;
+ private final String name;
private boolean close = true;
private boolean destroy = true;
diff --git a/src/main/java/com/songoda/skyblock/utils/ChatComponent.java b/src/main/java/com/songoda/skyblock/utils/ChatComponent.java
index 8b66cb4d..5b020349 100644
--- a/src/main/java/com/songoda/skyblock/utils/ChatComponent.java
+++ b/src/main/java/com/songoda/skyblock/utils/ChatComponent.java
@@ -7,7 +7,7 @@ import net.md_5.bungee.api.chat.TextComponent;
public class ChatComponent {
- private TextComponent textComponent;
+ private final TextComponent textComponent;
public ChatComponent(String text, boolean bold, ChatColor color, ClickEvent clickEvent, HoverEvent hoverEvent) {
textComponent = new TextComponent(ChatColor.translateAlternateColorCodes('&', text));
diff --git a/src/main/java/com/songoda/skyblock/utils/Compression.java b/src/main/java/com/songoda/skyblock/utils/Compression.java
index 9ddbf1be..fad59bec 100644
--- a/src/main/java/com/songoda/skyblock/utils/Compression.java
+++ b/src/main/java/com/songoda/skyblock/utils/Compression.java
@@ -1,6 +1,7 @@
package com.songoda.skyblock.utils;
import java.io.*;
+import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@@ -19,7 +20,7 @@ public class Compression {
public static String decompress(byte[] compressed) throws IOException {
ByteArrayInputStream bis = new ByteArrayInputStream(compressed);
GZIPInputStream gis = new GZIPInputStream(bis);
- BufferedReader br = new BufferedReader(new InputStreamReader(gis, "UTF-8"));
+ BufferedReader br = new BufferedReader(new InputStreamReader(gis, StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
String line;
while((line = br.readLine()) != null) {
diff --git a/src/main/java/com/songoda/skyblock/utils/StringUtil.java b/src/main/java/com/songoda/skyblock/utils/StringUtil.java
index 65e60847..8c91ee89 100644
--- a/src/main/java/com/songoda/skyblock/utils/StringUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/StringUtil.java
@@ -23,7 +23,7 @@ public final class StringUtil {
}
public static String capitalizeWord(String str){
- String words[]=str.split("\\s");
+ String[] words =str.split("\\s");
String capitalizeWord="";
for(String w:words){
String first=w.substring(0,1);
diff --git a/src/main/java/com/songoda/skyblock/utils/item/InventoryUtil.java b/src/main/java/com/songoda/skyblock/utils/item/InventoryUtil.java
index 6f9b5482..0eb49d1f 100644
--- a/src/main/java/com/songoda/skyblock/utils/item/InventoryUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/item/InventoryUtil.java
@@ -80,12 +80,11 @@ public class InventoryUtil {
public static void takeItem(Player player, int amount) {
if (player.getGameMode() == GameMode.CREATIVE) return;
- ItemStack item = player.getInventory().getItemInHand();
- if (item == null) return;
+ ItemStack item = player.getInventory().getItemInMainHand();
int result = item.getAmount() - amount;
item.setAmount(result);
- player.setItemInHand(result > 0 ? item : null);
+ player.getInventory().setItemInMainHand(result > 0 ? item : null);
}
}
diff --git a/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java b/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java
index b1555f3d..d8813ab1 100644
--- a/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java
@@ -1,6 +1,5 @@
package com.songoda.skyblock.utils.item;
-
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.utils.version.NMSUtil;
@@ -11,21 +10,26 @@ import java.io.*;
import java.lang.reflect.Constructor;
import java.math.BigInteger;
-public final class ItemStackUtil {
+public class ItemStackUtil {
+
+ private static final boolean isAbove1_16_R1 = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_16)
+ && !ServerVersion.getServerVersionString().equals("v1_16_R1");
public static ItemStack deserializeItemStack(String data) {
ByteArrayInputStream inputStream = new ByteArrayInputStream(new BigInteger(data, 32).toByteArray());
DataInputStream dataInputStream = new DataInputStream(inputStream);
ItemStack itemStack = null;
-
+
try {
Class> NBTTagCompoundClass = NMSUtil.getNMSClass("NBTTagCompound");
Class> NMSItemStackClass = NMSUtil.getNMSClass("ItemStack");
- Object NBTTagCompound = NMSUtil.getNMSClass("NBTCompressedStreamTools")
+ Object NBTTagCompound = isAbove1_16_R1 ? NMSUtil.getNMSClass("NBTCompressedStreamTools")
+ .getMethod("a", DataInput.class).invoke(null, dataInputStream)
+ : NMSUtil.getNMSClass("NBTCompressedStreamTools")
.getMethod("a", DataInputStream.class).invoke(null, dataInputStream);
Object craftItemStack;
-
+
assert NMSItemStackClass != null;
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
craftItemStack = NMSItemStackClass.getMethod("a", NBTTagCompoundClass).invoke(null, NBTTagCompound);
@@ -77,4 +81,5 @@ public final class ItemStackUtil {
return new BigInteger(1, outputStream.toByteArray()).toString(32);
}
+
}
diff --git a/src/main/java/com/songoda/skyblock/utils/item/MenuClickRegistry.java b/src/main/java/com/songoda/skyblock/utils/item/MenuClickRegistry.java
index 4ebaff7c..82389f76 100644
--- a/src/main/java/com/songoda/skyblock/utils/item/MenuClickRegistry.java
+++ b/src/main/java/com/songoda/skyblock/utils/item/MenuClickRegistry.java
@@ -20,8 +20,8 @@ public final class MenuClickRegistry {
return instance == null ? instance = new MenuClickRegistry() : instance;
}
- private Set populators;
- private Map executors;
+ private final Set populators;
+ private final Map executors;
private MenuClickRegistry() {
this.executors = new HashMap<>();
@@ -59,13 +59,13 @@ public final class MenuClickRegistry {
executor.onClick(SkyBlock.getInstance(), clicker, e);
}
- public static interface MenuPopulator {
+ public interface MenuPopulator {
void populate(Map executors);
}
- public static interface MenuExecutor {
+ public interface MenuExecutor {
void onClick(SkyBlock plugin, Player clicker, ClickEvent e);
diff --git a/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java b/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java
index 5bd97ffd..13ae25c6 100644
--- a/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/item/SkullUtil.java
@@ -22,7 +22,7 @@ public final class SkullUtil {
.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", skinTexture).getBytes());
gameProfile.getProperties().put("textures", new Property("textures", new String(encodedData)));
- Field profileField = null;
+ Field profileField;
try {
profileField = sm.getClass().getDeclaredField("profile");
diff --git a/src/main/java/com/songoda/skyblock/utils/item/nInventoryUtil.java b/src/main/java/com/songoda/skyblock/utils/item/nInventoryUtil.java
index f5418db5..bf5d69a7 100644
--- a/src/main/java/com/songoda/skyblock/utils/item/nInventoryUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/item/nInventoryUtil.java
@@ -20,15 +20,12 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
public class nInventoryUtil {
- private Player player;
+ private final Player player;
private Listener listener;
private Inventory inv;
@@ -36,7 +33,7 @@ public class nInventoryUtil {
private String title;
private int size = 9;
private InventoryType type;
- private Map items = new HashMap<>();
+ private final Map items = new HashMap<>();
public nInventoryUtil(Player player, final ClickEventHandler handler) {
this.player = player;
@@ -100,15 +97,11 @@ public class nInventoryUtil {
}
public void addItem(Item item, int... slots) {
- for (int slotList : slots) {
- items.put(slotList, item.prepareItem());
- }
+ Arrays.stream(slots).forEachOrdered(slotList -> items.put(slotList, item.prepareItem()));
}
public void addItemStack(ItemStack is, int... slots) {
- for (int slotList : slots) {
- items.put(slotList, is);
- }
+ Arrays.stream(slots).forEachOrdered(slotList -> items.put(slotList, is));
}
public Map getItems() {
@@ -160,9 +153,7 @@ public class nInventoryUtil {
}
}
- for(Entry entry : items.entrySet()) {
- inv.setItem(entry.getKey(), entry.getValue());
- }
+ items.forEach((key, value) -> inv.setItem(key, value));
}
public Inventory getInventory() {
@@ -192,12 +183,12 @@ public class nInventoryUtil {
public static class Item {
- private ItemStack is;
- private String itemDisplayname;
+ private final ItemStack is;
+ private final String itemDisplayname;
private List itemLore;
- private Placeholder[] placeholders;
- private Enchantment[] itemEnchantments;
- private ItemFlag[] itemFlags;
+ private final Placeholder[] placeholders;
+ private final Enchantment[] itemEnchantments;
+ private final ItemFlag[] itemFlags;
public Item(ItemStack is, String itemDisplayname, List itemLore, Placeholder[] placeholders, Enchantment[] itemEnchantments, ItemFlag[] itemFlags) {
this.is = is;
@@ -257,9 +248,9 @@ public class nInventoryUtil {
public class ClickEvent {
- private ClickType click;
- private int slot;
- private ItemStack is;
+ private final ClickType click;
+ private final int slot;
+ private final ItemStack is;
private boolean close = true;
private boolean destroy = true;
diff --git a/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java b/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java
index 406cc286..30446f54 100644
--- a/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java
+++ b/src/main/java/com/songoda/skyblock/utils/player/NameFetcher.java
@@ -20,7 +20,7 @@ public final class NameFetcher {
return null;
}
- Names[] names = null;
+ Names[] names;
Scanner jsonScanner = new Scanner((new URL("https://api.mojang.com/user/profiles/" + FastUUID.toString(uuid).replaceAll("-", "") + "/names")).openConnection().getInputStream(), "UTF-8");
names = new Gson().fromJson(jsonScanner.next(), Names[].class);
diff --git a/src/main/java/com/songoda/skyblock/utils/structure/Area.java b/src/main/java/com/songoda/skyblock/utils/structure/Area.java
index 6d9d728a..e263265d 100644
--- a/src/main/java/com/songoda/skyblock/utils/structure/Area.java
+++ b/src/main/java/com/songoda/skyblock/utils/structure/Area.java
@@ -7,7 +7,7 @@ import java.util.Map;
public class Area {
- private Map positions;
+ private final Map positions;
public Area() {
positions = new HashMap<>();
diff --git a/src/main/java/com/songoda/skyblock/utils/structure/Location.java b/src/main/java/com/songoda/skyblock/utils/structure/Location.java
index 44bfdc5d..95890e04 100644
--- a/src/main/java/com/songoda/skyblock/utils/structure/Location.java
+++ b/src/main/java/com/songoda/skyblock/utils/structure/Location.java
@@ -2,11 +2,11 @@ package com.songoda.skyblock.utils.structure;
public class Location {
- private int x;
- private int y;
- private int z;
+ private final int x;
+ private final int y;
+ private final int z;
- private boolean originLocation;
+ private final boolean originLocation;
public Location(int x, int y, int z, boolean originLocation) {
this.x = x;
diff --git a/src/main/java/com/songoda/skyblock/utils/structure/Storage.java b/src/main/java/com/songoda/skyblock/utils/structure/Storage.java
index 744aa097..defdb7ab 100644
--- a/src/main/java/com/songoda/skyblock/utils/structure/Storage.java
+++ b/src/main/java/com/songoda/skyblock/utils/structure/Storage.java
@@ -2,13 +2,13 @@ package com.songoda.skyblock.utils.structure;
public class Storage {
- private String blocks;
- private String entities;
- private String originLocation;
+ private final String blocks;
+ private final String entities;
+ private final String originLocation;
- private long time;
+ private final long time;
- private int version;
+ private final int version;
public Storage(String blocks, String entities, String originLocation, long time, int version) {
this.blocks = blocks;
diff --git a/src/main/java/com/songoda/skyblock/utils/structure/Structure.java b/src/main/java/com/songoda/skyblock/utils/structure/Structure.java
index 8285d684..1354b7c8 100644
--- a/src/main/java/com/songoda/skyblock/utils/structure/Structure.java
+++ b/src/main/java/com/songoda/skyblock/utils/structure/Structure.java
@@ -2,8 +2,8 @@ package com.songoda.skyblock.utils.structure;
public class Structure {
- private Storage storage;
- private String file;
+ private final Storage storage;
+ private final String file;
public Structure(Storage storage, String file) {
this.storage = storage;
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 dbc16a54..7482dc40 100644
--- a/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java
@@ -5,6 +5,8 @@ import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.nms.NmsManager;
+import com.songoda.core.nms.nbt.NBTEntity;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.utils.Compression;
@@ -30,10 +32,7 @@ import java.io.FileInputStream;
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.*;
import java.util.logging.Level;
import java.util.regex.Pattern;
@@ -185,11 +184,22 @@ public final class StructureUtil {
}.getType())) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(SkyBlock.getInstance(), () -> {
try {
- org.bukkit.Location blockRotationLocation = LocationUtil.rotateLocation(new org.bukkit.Location(location.getWorld(), entityDataList.getX(), entityDataList.getY(), entityDataList.getZ()), type);
- org.bukkit.Location blockLocation = new org.bukkit.Location(location.getWorld(), location.getX() - Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[0])),
- location.getY() - Integer.parseInt(storage.getOriginLocation().split(":")[1]), location.getZ() + Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[2])));
- blockLocation.add(blockRotationLocation);
- EntityUtil.convertEntityDataToEntity(entityDataList, blockLocation, type);
+ if (entityDataList.getSerializedNBT() != null) {
+ org.bukkit.Location blockRotationLocation = LocationUtil.rotateLocation(new org.bukkit.Location(location.getWorld(), entityDataList.getX(), entityDataList.getY(), entityDataList.getZ()), type);
+ org.bukkit.Location blockLocation = new org.bukkit.Location(location.getWorld(), location.getX() - Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[0])),
+ location.getY() - Integer.parseInt(storage.getOriginLocation().split(":")[1]), location.getZ() + Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[2])));
+ blockLocation.add(blockRotationLocation);
+ NBTEntity nbtEntity = NmsManager.getNbt().newEntity();
+ nbtEntity.deSerialize(entityDataList.getSerializedNBT());
+ nbtEntity.set("UUID", UUID.randomUUID());
+ nbtEntity.spawn(blockLocation);
+ } else {
+ org.bukkit.Location blockRotationLocation = LocationUtil.rotateLocation(new org.bukkit.Location(location.getWorld(), entityDataList.getX(), entityDataList.getY(), entityDataList.getZ()), type);
+ org.bukkit.Location blockLocation = new org.bukkit.Location(location.getWorld(), location.getX() - Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[0])),
+ location.getY() - Integer.parseInt(storage.getOriginLocation().split(":")[1]), location.getZ() + Math.abs(Integer.parseInt(storage.getOriginLocation().split(":")[2])));
+ blockLocation.add(blockRotationLocation);
+ EntityUtil.convertEntityDataToEntity(entityDataList, blockLocation, type);
+ }
} catch (Exception e) {
SkyBlock.getInstance().getLogger().warning("Unable to convert EntityData to Entity for type {" + entityDataList.getEntityType() + "} in structure {" + structure.getStructureFile() + "}");
}
@@ -205,10 +215,9 @@ public final class StructureUtil {
FileManager fileManager = plugin.getFileManager();
- FileManager.Config config = fileManager.getConfig(new File(plugin.getDataFolder(), "language.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getLanguage();
- ItemStack is = new ItemStack(Material.valueOf(fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration().getString("Island.Admin.Structure.Selector")));
+ ItemStack is = new ItemStack(Material.valueOf(plugin.getConfiguration().getString("Island.Admin.Structure.Selector")));
ItemMeta im = is.getItemMeta();
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Island.Structure.Tool.Item.Displayname")));
diff --git a/src/main/java/com/songoda/skyblock/utils/version/CompatibleSpawners.java b/src/main/java/com/songoda/skyblock/utils/version/CompatibleSpawners.java
index 588f3e2a..a0dac09a 100644
--- a/src/main/java/com/songoda/skyblock/utils/version/CompatibleSpawners.java
+++ b/src/main/java/com/songoda/skyblock/utils/version/CompatibleSpawners.java
@@ -70,7 +70,7 @@ public enum CompatibleSpawners {
private static final Set ALL = Collections.unmodifiableSet(EnumSet.allOf(CompatibleSpawners.class));
static int newV = -1;
- private static Map cachedSearch = new HashMap<>();
+ private static final Map cachedSearch = new HashMap<>();
String old13Mat;
String old12Mat;
int data;
diff --git a/src/main/java/com/songoda/skyblock/utils/version/NMSUtil.java b/src/main/java/com/songoda/skyblock/utils/version/NMSUtil.java
index 1518604c..83becd3b 100644
--- a/src/main/java/com/songoda/skyblock/utils/version/NMSUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/version/NMSUtil.java
@@ -47,8 +47,7 @@ public class NMSUtil {
public static Class> getCraftClass(String className) {
try {
- String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
- return Class.forName(fullName);
+ return Class.forName("org.bukkit.craftbukkit." + getVersion() + className);
} catch (Exception e) {
e.printStackTrace();
return null;
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 f438880a..cae2cbab 100644
--- a/src/main/java/com/songoda/skyblock/utils/version/SBiome.java
+++ b/src/main/java/com/songoda/skyblock/utils/version/SBiome.java
@@ -6,6 +6,8 @@ import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.inventory.ItemStack;
+import java.util.Arrays;
+
/**
* A Biome wrapper for supporting Biomes in 1.8-1.13+
*/
@@ -32,11 +34,11 @@ public enum SBiome {
THE_VOID("SKY", CompatibleMaterial.OBSIDIAN),
WARM_OCEAN(true, CompatibleMaterial.TROPICAL_FISH);
- private static boolean isPostVersion = NMSUtil.getVersionNumber() >= 13;
+ private static final boolean isPostVersion = NMSUtil.getVersionNumber() >= 13;
- private String legacyName;
- private boolean isPost13;
- private CompatibleMaterial guiIcon;
+ private final String legacyName;
+ private final boolean isPost13;
+ private final CompatibleMaterial guiIcon;
SBiome(CompatibleMaterial guiIcon) {
this(null, false, guiIcon);
@@ -63,10 +65,7 @@ public enum SBiome {
*/
@SuppressWarnings("deprecation")
public static SBiome getFromGuiIcon(Material material, byte data) {
- for (SBiome biome : values())
- if (biome.isAvailable() && biome.getGuiIcon().getType().equals(material) && (isPostVersion || biome.getGuiIcon().getData().getData() == data))
- return biome;
- return null;
+ return Arrays.stream(values()).filter(biome -> biome.isAvailable() && biome.getGuiIcon().getType().equals(material) && (isPostVersion || biome.getGuiIcon().getData().getData() == data)).findFirst().orElse(null);
}
/**
@@ -84,11 +83,7 @@ public enum SBiome {
* @return The Biome this SBiome represents, or null if it is not available in this server version
*/
public Biome getBiome() {
- if (!this.isAvailable())
- return null;
- if (isPostVersion || this.legacyName == null)
- return Biome.valueOf(this.name());
- return Biome.valueOf(this.legacyName);
+ return !this.isAvailable() ? null : isPostVersion || this.legacyName == null ? Biome.valueOf(this.name()) : Biome.valueOf(this.legacyName);
}
/**
@@ -97,9 +92,7 @@ public enum SBiome {
* @return The formatted Biome name
*/
public String getFormattedBiomeName() {
- if (!this.isAvailable())
- return null;
- return StringUtil.capitalizeWord(this.getBiome().name().replaceAll("_", " "));
+ return !this.isAvailable() ? null : StringUtil.capitalizeWord(this.getBiome().name().replaceAll("_", " "));
}
/**
@@ -108,9 +101,7 @@ public enum SBiome {
* @return The Gui icon that represents this Biome
*/
public ItemStack getGuiIcon() {
- if (!this.isAvailable())
- return null;
- return this.guiIcon.getItem();
+ return !this.isAvailable() ? null : this.guiIcon.getItem();
}
}
diff --git a/src/main/java/com/songoda/skyblock/utils/world/block/BlockData.java b/src/main/java/com/songoda/skyblock/utils/world/block/BlockData.java
index 544ca768..6c438d27 100644
--- a/src/main/java/com/songoda/skyblock/utils/world/block/BlockData.java
+++ b/src/main/java/com/songoda/skyblock/utils/world/block/BlockData.java
@@ -36,7 +36,7 @@ public class BlockData {
private String facing;
private int charges = 0;
- private Map inventory = new HashMap<>();
+ private final Map inventory = new HashMap<>();
private int version;
private int x = 0;
diff --git a/src/main/java/com/songoda/skyblock/utils/world/block/BlockDegreesType.java b/src/main/java/com/songoda/skyblock/utils/world/block/BlockDegreesType.java
index b3c5ad1c..90fd4c3d 100644
--- a/src/main/java/com/songoda/skyblock/utils/world/block/BlockDegreesType.java
+++ b/src/main/java/com/songoda/skyblock/utils/world/block/BlockDegreesType.java
@@ -4,7 +4,7 @@ public enum BlockDegreesType {
ROTATE_90(90F), ROTATE_180(180F), ROTATE_270(270F), ROTATE_360(360F);
- private float angle;
+ private final float angle;
BlockDegreesType(float angle) {
this.angle = angle;
diff --git a/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java b/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java
index 2a74d19a..3ab2ed59 100644
--- a/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/world/block/BlockUtil.java
@@ -19,6 +19,7 @@ import org.bukkit.potion.PotionEffectType;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
@SuppressWarnings("deprecation")
public final class BlockUtil extends BlockUtils {
@@ -41,11 +42,7 @@ public final class BlockUtil extends BlockUtils {
blockData.setBaseColor(banner.getBaseColor().toString());
final List bannerPatterns = banner.getPatterns();
- final List stringPatterns = new ArrayList<>(bannerPatterns.size());
-
- for (Pattern patternList : bannerPatterns) {
- stringPatterns.add(patternList.getPattern().toString() + ":" + patternList.getColor().toString());
- }
+ final List stringPatterns = bannerPatterns.stream().map(patternList -> patternList.getPattern().toString() + ":" + patternList.getColor().toString()).collect(Collectors.toCollection(() -> new ArrayList<>(bannerPatterns.size())));
blockData.setPatterns(stringPatterns);
blockData.setStateType(BlockStateType.BANNER.toString());
@@ -140,9 +137,8 @@ public final class BlockUtil extends BlockUtils {
} else if (blockState instanceof Jukebox) {
Jukebox jukebox = (Jukebox) blockState;
- if (jukebox.getPlaying() != null) {
- blockData.setPlaying(jukebox.getPlaying().toString());
- }
+ jukebox.getPlaying();
+ blockData.setPlaying(jukebox.getPlaying().toString());
blockData.setStateType(BlockStateType.JUKEBOX.toString());
} else if (blockState instanceof Sign) {
@@ -150,20 +146,18 @@ public final class BlockUtil extends BlockUtils {
String[] signLines = sign.getLines();
- if (signLines != null) {
- List correctedSignLines = new ArrayList<>();
+ List correctedSignLines = new ArrayList<>();
- for (String signLineList : signLines) {
- for (ChatColor chatColorList : ChatColor.values()) {
- signLineList = signLineList.replace(chatColorList + "", "&" + chatColorList.toString().substring(chatColorList.toString().length() - 1));
- }
-
- correctedSignLines.add(signLineList);
+ for (String signLineList : signLines) {
+ for (ChatColor chatColorList : ChatColor.values()) {
+ signLineList = signLineList.replace(chatColorList + "", "&" + chatColorList.toString().substring(chatColorList.toString().length() - 1));
}
- signLines = correctedSignLines.toArray(new String[correctedSignLines.size()]);
+ correctedSignLines.add(signLineList);
}
+ signLines = correctedSignLines.toArray(new String[correctedSignLines.size()]);
+
blockData.setSignLines(signLines);
blockData.setStateType(BlockStateType.SIGN.toString());
} else if (blockState instanceof Skull) {
@@ -479,30 +473,28 @@ public final class BlockUtil extends BlockUtils {
materialStr = flower[0].toUpperCase();
- if (materialStr != null) {
- ItemStack is = new ItemStack(Material.getMaterial(materialStr), 1, (byte) materialData);
+ ItemStack is = new ItemStack(Material.getMaterial(materialStr), 1, (byte) materialData);
- World world = block.getWorld();
+ World world = block.getWorld();
- Class> blockPositionClass = NMSUtil.getNMSClass("BlockPosition");
+ Class> blockPositionClass = NMSUtil.getNMSClass("BlockPosition");
- Object worldHandle = world.getClass().getMethod("getHandle").invoke(world);
- Object blockPosition = blockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(block.getX(), block.getY(), block.getZ());
- Object tileEntity = worldHandle.getClass().getMethod("getTileEntity", blockPositionClass).invoke(worldHandle, blockPosition);
- Object itemStack = NMSUtil.getCraftClass("inventory.CraftItemStack").getMethod("asNMSCopy", is.getClass()).invoke(null, is);
- Object item = itemStack.getClass().getMethod("getItem").invoke(itemStack);
- Object data = itemStack.getClass().getMethod("getData").invoke(itemStack);
+ Object worldHandle = world.getClass().getMethod("getHandle").invoke(world);
+ Object blockPosition = blockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(block.getX(), block.getY(), block.getZ());
+ Object tileEntity = worldHandle.getClass().getMethod("getTileEntity", blockPositionClass).invoke(worldHandle, blockPosition);
+ Object itemStack = NMSUtil.getCraftClass("inventory.CraftItemStack").getMethod("asNMSCopy", is.getClass()).invoke(null, is);
+ Object item = itemStack.getClass().getMethod("getItem").invoke(itemStack);
+ Object data = itemStack.getClass().getMethod("getData").invoke(itemStack);
- Field aField = tileEntity.getClass().getDeclaredField("a");
- aField.setAccessible(true);
- aField.set(tileEntity, item);
+ Field aField = tileEntity.getClass().getDeclaredField("a");
+ aField.setAccessible(true);
+ aField.set(tileEntity, item);
- Field fField = tileEntity.getClass().getDeclaredField("f");
- fField.setAccessible(true);
- fField.set(tileEntity, data);
+ Field fField = tileEntity.getClass().getDeclaredField("f");
+ fField.setAccessible(true);
+ fField.set(tileEntity, data);
- tileEntity.getClass().getMethod("update").invoke(tileEntity);
- }
+ tileEntity.getClass().getMethod("update").invoke(tileEntity);
} catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityData.java b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityData.java
index 111cfea9..907386c0 100644
--- a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityData.java
+++ b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityData.java
@@ -2,6 +2,8 @@ package com.songoda.skyblock.utils.world.entity;
public class EntityData {
+ private byte[] serializedNBT;
+
private String entityType;
private String hand;
private String helmet;
@@ -71,6 +73,7 @@ public class EntityData {
private boolean ai;
private boolean baby;
+ @Deprecated
public EntityData(String entityType, double x, double y, double z, String customName, boolean customNameVisible,
int fireTicks, int ticksLived) {
this.entityType = entityType;
@@ -88,226 +91,297 @@ public class EntityData {
this.ai = true;
}
+ public EntityData(byte[] serializedNBT, double x, double y, double z) {
+ this.serializedNBT = serializedNBT;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public byte[] getSerializedNBT() {
+ return serializedNBT;
+ }
+
+ public void setSerializedNBT(byte[] serializedNBT) {
+ this.serializedNBT = serializedNBT;
+ }
+
+ @Deprecated
public String getEntityType() {
return entityType;
}
+ @Deprecated
public void setEntityType(String entityType) {
this.entityType = entityType;
}
+ @Deprecated
public String getHand() {
return this.hand;
}
+ @Deprecated
public void setHand(String hand) {
this.hand = hand;
}
+ @Deprecated
public String getHelmet() {
return this.helmet;
}
+ @Deprecated
public void setHelmet(String helmet) {
this.helmet = helmet;
}
+ @Deprecated
public String getChestplate() {
return this.chestplate;
}
+ @Deprecated
public void setChestplate(String chestplate) {
this.chestplate = chestplate;
}
+ @Deprecated
public String getLeggings() {
return this.leggings;
}
+ @Deprecated
public void setLeggings(String leggings) {
this.leggings = leggings;
}
+ @Deprecated
public String getBoots() {
return this.boots;
}
+ @Deprecated
public void setBoots(String boots) {
this.boots = boots;
}
+ @Deprecated
public String getBodyPose() {
return this.bodyPose;
}
+ @Deprecated
public void setBodyPose(String bodyPose) {
this.bodyPose = bodyPose;
}
+ @Deprecated
public String getHeadPose() {
return this.headPose;
}
+ @Deprecated
public void setHeadPose(String headPose) {
this.headPose = headPose;
}
+ @Deprecated
public String getLeftArmPose() {
return this.leftArmPose;
}
+ @Deprecated
public void setLeftArmPose(String leftArmPose) {
this.leftArmPose = leftArmPose;
}
+ @Deprecated
public String getLeftLegPose() {
return this.leftLegPose;
}
+ @Deprecated
public void setLeftLegPose(String leftLegPose) {
this.leftLegPose = leftLegPose;
}
+ @Deprecated
public String getRightArmPose() {
return this.rightArmPose;
}
+ @Deprecated
public void setRightArmPose(String rightArmPose) {
this.rightArmPose = rightArmPose;
}
+ @Deprecated
public String getRightLegPose() {
return this.rightLegPose;
}
+ @Deprecated
public void setRightLegPose(String rightLegPose) {
this.rightLegPose = rightLegPose;
}
+ @Deprecated
public String getOffHand() {
return this.offHand;
}
+ @Deprecated
public void setOffHand(String offHand) {
this.offHand = offHand;
}
+ @Deprecated
public String getWoodType() {
return this.woodType;
}
+ @Deprecated
public void setWoodType(String woodType) {
this.woodType = woodType;
}
+ @Deprecated
public String getCarryBlock() {
return this.carryBlock;
}
+ @Deprecated
public void setCarryBlock(String carryBlock) {
this.carryBlock = carryBlock;
}
+ @Deprecated
public String getCustomName() {
return this.customName;
}
+ @Deprecated
public void setCustomName(String customName) {
this.customName = customName;
}
+ @Deprecated
public String getHorseColor() {
return this.horseColor;
}
+ @Deprecated
public void setHorseColor(String horseColor) {
this.horseColor = horseColor;
}
+ @Deprecated
public String getHorseStyle() {
return this.horseStyle;
}
+ @Deprecated
public void setHorseStyle(String horseStyle) {
this.horseStyle = horseStyle;
}
+ @Deprecated
public String getItem() {
return this.item;
}
+ @Deprecated
public void setItem(String item) {
this.item = item;
}
+ @Deprecated
public String getRotate() {
return this.rotate;
}
+ @Deprecated
public void setRotate(String rotate) {
this.rotate = rotate;
}
+ @Deprecated
public String getLlamaColor() {
return this.llamaColor;
}
+ @Deprecated
public void setLlamaColor(String llamaColor) {
this.llamaColor = llamaColor;
}
+ @Deprecated
public String getOcelotType() {
return this.ocelotType;
}
+ @Deprecated
public void setOcelotType(String ocelotType) {
this.ocelotType = ocelotType;
}
+ @Deprecated
public String getArt() {
return this.art;
}
+ @Deprecated
public void setArt(String art) {
this.art = art;
}
+ @Deprecated
public String getParrotVariant() {
return this.parrotVariant;
}
+ @Deprecated
public void setParrotVariant(String parrotVariant) {
this.parrotVariant = parrotVariant;
}
+ @Deprecated
public String getRabbitType() {
return this.rabbitType;
}
+ @Deprecated
public void setRabbitType(String rabbitType) {
this.rabbitType = rabbitType;
}
+ @Deprecated
public String getProfession() {
return this.profession;
}
+ @Deprecated
public void setProfession(String profession) {
this.profession = profession;
}
+ @Deprecated
public String getColor() {
return this.color;
}
+ @Deprecated
public void setColor(String color) {
this.color = color;
}
+ @Deprecated
public String[] getInventory() {
return this.inventory;
}
+ @Deprecated
public void setInventory(String[] inventory) {
this.inventory = inventory;
}
@@ -336,258 +410,322 @@ public class EntityData {
this.z = z;
}
+ @Deprecated
public float getHandChance() {
return this.handChance;
}
+ @Deprecated
public void setHandChance(float handChance) {
this.handChance = handChance;
}
+ @Deprecated
public float getOffHandChance() {
return this.offHandChance;
}
+ @Deprecated
public void setOffHandChange(float offHandChange) {
this.offHandChance = offHandChange;
}
+ @Deprecated
public float getHelmetChance() {
return this.helmetChance;
}
+ @Deprecated
public void setHelmetChance(float helmetChance) {
this.helmetChance = helmetChance;
}
+ @Deprecated
public float getChestplateChance() {
return this.chestplateChance;
}
+ @Deprecated
public void setChestplateChance(float chestplateChance) {
this.chestplateChance = chestplateChance;
}
+ @Deprecated
public float getLeggingsChance() {
return this.leggingsChance;
}
+ @Deprecated
public void setLeggingsChance(float leggingsChance) {
this.leggingsChance = leggingsChance;
}
+ @Deprecated
public float getBootsChance() {
return this.bootsChance;
}
+ @Deprecated
public void setBootsChance(float bootsChance) {
this.bootsChance = bootsChance;
}
+ @Deprecated
public float getYaw() {
return this.yaw;
}
+ @Deprecated
public void setYaw(float yaw) {
this.yaw = yaw;
}
+ @Deprecated
public float getPitch() {
return this.pitch;
}
+ @Deprecated
public void setPitch(float pitch) {
this.pitch = pitch;
}
+ @Deprecated
public int getVersion() {
return this.version;
}
+ @Deprecated
public void setVersion(int version) {
this.version = version;
}
+ @Deprecated
public int getFireTicks() {
return this.fireTicks;
}
+ @Deprecated
public void setFireTicks(int fireTicks) {
this.fireTicks = fireTicks;
}
+ @Deprecated
public int getTicksLived() {
return this.ticksLived;
}
+ @Deprecated
public void setTicksLived(int ticksLived) {
this.ticksLived = ticksLived;
}
+ @Deprecated
public int getLlamaStrength() {
return this.llamaStrength;
}
+ @Deprecated
public void setLlamaStrength(int llamaStrength) {
this.llamaStrength = llamaStrength;
}
+ @Deprecated
public int getAngerLevel() {
return this.angerLevel;
}
+ @Deprecated
public void setAngerLevel(int angerLevel) {
this.angerLevel = angerLevel;
}
+ @Deprecated
public int getSlimeSize() {
return this.slimeSize;
}
+ @Deprecated
public void setSlimeSize(int slimeSize) {
this.slimeSize = slimeSize;
}
+ @Deprecated
public int getAge() {
return this.age;
}
+ @Deprecated
public void setAge(int age) {
this.age = age;
}
+ @Deprecated
public boolean hasArms() {
return this.arms;
}
+ @Deprecated
public void setArms(boolean arms) {
this.arms = arms;
}
+ @Deprecated
public boolean hasBasePlate() {
return this.basePlate;
}
+ @Deprecated
public void setBasePlate(boolean basePlate) {
this.basePlate = basePlate;
}
+ @Deprecated
public boolean isVisible() {
return this.visible;
}
+ @Deprecated
public void setVisible(boolean visible) {
this.visible = visible;
}
+ @Deprecated
public boolean isSmall() {
return this.small;
}
+ @Deprecated
public void setSmall(boolean small) {
this.small = small;
}
+ @Deprecated
public boolean isMarker() {
return this.marker;
}
+ @Deprecated
public void setMarker(boolean marker) {
this.marker = marker;
}
+ @Deprecated
public boolean isAwake() {
return this.awake;
}
+ @Deprecated
public void setAwake(boolean awake) {
this.awake = awake;
}
+ @Deprecated
public boolean isPowered() {
return this.powered;
}
+ @Deprecated
public void setPowered(boolean powered) {
this.powered = powered;
}
+ @Deprecated
public boolean isCustomNameVisible() {
return this.customNameVisible;
}
+ @Deprecated
public void setCustomNameVisible(boolean customNameVisible) {
this.customNameVisible = customNameVisible;
}
+ @Deprecated
public boolean isCreatedByPlayer() {
return this.createdByPlayer;
}
+ @Deprecated
public void setCreatedByPlayer(boolean createdByPlayer) {
this.createdByPlayer = createdByPlayer;
}
+ @Deprecated
public boolean hasSaddle() {
return this.saddle;
}
+ @Deprecated
public void setSaddle(boolean saddle) {
this.saddle = saddle;
}
+ @Deprecated
public boolean isAngry() {
return this.angry;
}
+ @Deprecated
public void setAngry(boolean angry) {
this.angry = angry;
}
+ @Deprecated
public boolean isSheared() {
return this.sheared;
}
+ @Deprecated
public void setSheared(boolean sheared) {
this.sheared = sheared;
}
+ @Deprecated
public boolean isDerp() {
return this.derp;
}
+ @Deprecated
public void setDerp(boolean derp) {
this.derp = derp;
}
+ @Deprecated
public boolean isAgeLock() {
return this.ageLock;
}
+ @Deprecated
public void setAgeLock(boolean ageLock) {
this.ageLock = ageLock;
}
+ @Deprecated
public boolean canBreed() {
return this.breed;
}
+ @Deprecated
public void setBreed(boolean breed) {
this.breed = breed;
}
+ @Deprecated
public boolean hasAI() {
return this.ai;
}
+ @Deprecated
public void setAI(boolean ai) {
this.ai = ai;
}
+ @Deprecated
public boolean isBaby() {
return this.baby;
}
+ @Deprecated
public void setBaby(boolean baby) {
this.baby = baby;
}
diff --git a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java
index 14d093a0..ec41bffe 100644
--- a/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/world/entity/EntityUtil.java
@@ -1,6 +1,8 @@
package com.songoda.skyblock.utils.world.entity;
import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.nms.NmsManager;
+import com.songoda.core.nms.nbt.NBTEntity;
import com.songoda.skyblock.utils.item.ItemStackUtil;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
@@ -22,241 +24,7 @@ import java.util.List;
public final class EntityUtil {
public static EntityData convertEntityToEntityData(Entity entity, int x, int y, int z) {
- EntityData entityData = new EntityData(entity.getType().toString(), x, y, z, entity.getCustomName(),
- entity.isCustomNameVisible(), entity.getFireTicks(), entity.getTicksLived());
- entityData.setVersion(NMSUtil.getVersionNumber());
-
- if (entity instanceof ArmorStand) {
- ArmorStand armorStand = (ArmorStand) entity;
- entityData.setArms(armorStand.hasArms());
-
- if (armorStand.getItemInHand() != null && armorStand.getItemInHand().getType() != Material.AIR) {
- entityData.setHand(ItemStackUtil.serializeItemStack(armorStand.getItemInHand()));
- }
-
- if (armorStand.getHelmet() != null && armorStand.getHelmet().getType() != Material.AIR) {
- entityData.setHelmet(ItemStackUtil.serializeItemStack(armorStand.getHelmet()));
- }
-
- if (armorStand.getChestplate() != null && armorStand.getChestplate().getType() != Material.AIR) {
- entityData.setChestplate(ItemStackUtil.serializeItemStack(armorStand.getChestplate()));
- }
-
- if (armorStand.getLeggings() != null && armorStand.getLeggings().getType() != Material.AIR) {
- entityData.setLeggings(ItemStackUtil.serializeItemStack(armorStand.getLeggings()));
- }
-
- if (armorStand.getBoots() != null && armorStand.getBoots().getType() != Material.AIR) {
- entityData.setBoots(ItemStackUtil.serializeItemStack(armorStand.getBoots()));
- }
-
- entityData.setBasePlate(armorStand.hasBasePlate());
- entityData.setVisible(armorStand.isVisible());
- entityData.setSmall(armorStand.isSmall());
- entityData.setMarker(armorStand.isMarker());
- entityData.setBodyPose(armorStand.getBodyPose().getX() + " " + armorStand.getBodyPose().getY() + " "
- + armorStand.getBodyPose().getZ());
- entityData.setHeadPose(armorStand.getHeadPose().getX() + " " + armorStand.getHeadPose().getY() + " "
- + armorStand.getHeadPose().getZ());
- entityData.setLeftArmPose(armorStand.getLeftArmPose().getX() + " " + armorStand.getLeftArmPose().getY()
- + " " + armorStand.getLeftArmPose().getZ());
- entityData.setLeftLegPose(armorStand.getLeftLegPose().getX() + " " + armorStand.getLeftLegPose().getY()
- + " " + armorStand.getLeftLegPose().getZ());
- entityData.setRightArmPose(armorStand.getRightArmPose().getX() + " " + armorStand.getRightArmPose().getY()
- + " " + armorStand.getRightArmPose().getZ());
- entityData.setRightLegPose(armorStand.getRightLegPose().getX() + " " + armorStand.getRightLegPose().getY()
- + " " + armorStand.getRightLegPose().getZ());
-
- return entityData;
- }
-
- int NMSVersion = NMSUtil.getVersionNumber();
-
- if (entity instanceof LivingEntity) {
- LivingEntity livingEntity = (LivingEntity) entity;
- EntityEquipment entityEquipment = livingEntity.getEquipment();
-
- if (NMSVersion > 8) {
- if (NMSVersion > 9) {
- entityData.setAI(livingEntity.hasAI());
- }
-
- if (entityEquipment.getItemInMainHand() != null
- && entityEquipment.getItemInMainHand().getType() != Material.AIR) {
- entityData.setHand(ItemStackUtil.serializeItemStack(entityEquipment.getItemInMainHand()));
- }
-
- entityData.setHandChance(entityEquipment.getItemInMainHandDropChance());
-
- if (entityEquipment.getItemInOffHand() != null
- && entityEquipment.getItemInOffHand().getType() != Material.AIR) {
- entityData.setOffHand(ItemStackUtil.serializeItemStack(entityEquipment.getItemInOffHand()));
- }
-
- entityData.setOffHandChange(entityEquipment.getItemInOffHandDropChance());
- } else {
- if (entityEquipment.getItemInHand() != null
- && entityEquipment.getItemInHand().getType() != Material.AIR) {
- entityData.setHand(ItemStackUtil.serializeItemStack(entityEquipment.getItemInHand()));
- }
-
- entityData.setHandChance(entityEquipment.getItemInHandDropChance());
- }
-
- if (entityEquipment.getHelmet() != null && entityEquipment.getHelmet().getType() != Material.AIR) {
- entityData.setHelmet(ItemStackUtil.serializeItemStack(entityEquipment.getHelmet()));
- }
-
- if (entityEquipment.getChestplate() != null && entityEquipment.getChestplate().getType() != Material.AIR) {
- entityData.setChestplate(ItemStackUtil.serializeItemStack(entityEquipment.getChestplate()));
- }
-
- if (entityEquipment.getLeggings() != null && entityEquipment.getLeggings().getType() != Material.AIR) {
- entityData.setLeggings(ItemStackUtil.serializeItemStack(entityEquipment.getLeggings()));
- }
-
- if (entityEquipment.getBoots() != null && entityEquipment.getBoots().getType() != Material.AIR) {
- entityData.setBoots(ItemStackUtil.serializeItemStack(entityEquipment.getBoots()));
- }
-
- entityData.setHelmetChance(entityEquipment.getHelmetDropChance());
- entityData.setChestplateChance(entityEquipment.getChestplateDropChance());
- entityData.setLeggingsChance(entityEquipment.getLeggingsDropChance());
- entityData.setBootsChance(entityEquipment.getBootsDropChance());
-
- if (entity instanceof Bat) {
- entityData.setAwake(((Bat) entityData).isAwake());
- } else if (entity instanceof Creeper) {
- entityData.setPowered(((Creeper) entity).isPowered());
- } else if (entity instanceof Enderman) {
- Enderman enderman = ((Enderman) entity);
-
- if (NMSVersion > 12) {
- if (enderman.getCarriedBlock() == null) {
- entityData.setCarryBlock("");
- } else {
- entityData.setCarryBlock(enderman.getCarriedBlock().getMaterial().name() + ":0");
- }
- } else {
- MaterialData materialData = enderman.getCarriedMaterial();
-
- if (materialData == null) {
- entityData.setCarryBlock("");
- } else {
- entityData.setCarryBlock(materialData.getItemType().toString() + ":" + materialData.getData());
- }
- }
- } else if (entity instanceof Horse) {
- Horse horse = ((Horse) entity);
- entityData.setHorseColor(horse.getColor().toString());
- entityData.setHorseStyle(horse.getStyle().toString());
-
- List items = new ArrayList<>();
-
- for (ItemStack itemList : horse.getInventory().getContents()) {
- if (itemList != null && itemList.getType() != Material.AIR) {
- items.add(ItemStackUtil.serializeItemStack(itemList));
- }
- }
-
- entityData.setInventory(items.toArray(new String[0]));
- } else if (entity instanceof IronGolem) {
- entityData.setCreatedByPlayer(((IronGolem) entity).isPlayerCreated());
- } else if (entity instanceof Ocelot) {
- entityData.setOcelotType(((Ocelot) entity).getCatType().toString());
- } else if (entity instanceof Pig) {
- entityData.setSaddle(((Pig) entity).hasSaddle());
- } else if (entity instanceof Zombie) {
- entityData.setBaby(((Zombie) entity).isBaby());
- } else if (entity instanceof PigZombie) {
- PigZombie pigZombie = ((PigZombie) entity);
- entityData.setAngry(pigZombie.isAngry());
- entityData.setAngerLevel(pigZombie.getAnger());
- } else if (entity instanceof Rabbit) {
- entityData.setRabbitType(((Rabbit) entity).getRabbitType().toString());
- } else if (entity instanceof Sheep) {
- entityData.setSheared(((Sheep) entity).isSheared());
- entityData.setColor(((Colorable) entity).getColor().toString());
- } else if (entity instanceof Slime) {
- entityData.setSlimeSize(((Slime) entity).getSize());
- } else if (entity instanceof Snowman) {
- entityData.setDerp(((Snowman) entity).isDerp());
- } else if (entity instanceof Villager) {
- Villager villager = ((Villager) entity);
- entityData.setProfession(villager.getProfession().toString());
-
- List items = new ArrayList<>();
-
- for (ItemStack itemList : villager.getInventory().getContents()) {
- if (itemList != null && itemList.getType() != Material.AIR) {
- items.add(ItemStackUtil.serializeItemStack(itemList));
- }
- }
-
- entityData.setInventory(items.toArray(new String[0]));
- }
-
- if (NMSVersion > 10) {
- if (entity instanceof Llama) {
- Llama llama = ((Llama) entity);
- entityData.setLlamaColor(llama.getColor().toString());
- entityData.setLlamaStrength(llama.getStrength());
-
- List items = new ArrayList<>();
-
- for (ItemStack itemList : llama.getInventory().getContents()) {
- if (itemList != null && itemList.getType() != Material.AIR) {
- items.add(ItemStackUtil.serializeItemStack(itemList));
- }
- }
- }
-
- if (NMSVersion > 11) {
- if (entity instanceof Parrot) {
- entityData.setParrotVariant(((Parrot) entity).getVariant().toString());
- }
- }
- }
- }
-
- if (entity instanceof Ageable) {
- Ageable ageable = ((Ageable) entity);
- entityData.setBreed(ageable.canBreed());
- entityData.setAge(ageable.getAge());
- entityData.setAgeLock(ageable.getAgeLock());
- entityData.setBaby(!ageable.isAdult());
- } else if (entity instanceof Vehicle) {
- if (entity instanceof Boat) {
- entityData.setWoodType(((Boat) entity).getWoodType().toString());
- } else if (entity instanceof StorageMinecart || entity instanceof HopperMinecart) {
- List items = new ArrayList<>();
-
- for (ItemStack itemList : ((InventoryHolder) entity).getInventory().getContents()) {
- if (itemList != null && itemList.getType() != Material.AIR) {
- items.add(ItemStackUtil.serializeItemStack(itemList));
- }
- }
-
- entityData.setInventory(items.toArray(new String[0]));
- }
- } else if (entity instanceof Hanging) {
- if (entity instanceof ItemFrame) {
- ItemFrame itemFrame = ((ItemFrame) entity);
- ItemStack is = itemFrame.getItem();
-
- if (is == null) {
- entityData.setItem("");
- } else {
- entityData.setItem(ItemStackUtil.serializeItemStack(is));
- }
-
- entityData.setRotate(itemFrame.getRotation().toString());
- } else if (entity instanceof Painting) {
- entityData.setArt(((Painting) entity).getArt().toString());
- }
- }
-
- return entityData;
+ return new EntityData(NmsManager.getNbt().of(entity).serialize("Attributes"), x, y, z);
}
public static void convertEntityDataToEntity(EntityData entityData, Location loc, BlockDegreesType type) {
diff --git a/src/main/java/com/songoda/skyblock/visit/Visit.java b/src/main/java/com/songoda/skyblock/visit/Visit.java
index 546cf927..78a44cb5 100644
--- a/src/main/java/com/songoda/skyblock/visit/Visit.java
+++ b/src/main/java/com/songoda/skyblock/visit/Visit.java
@@ -22,7 +22,7 @@ public class Visit {
private final IslandLevel islandLevel;
private UUID islandOwnerUUID;
private String islandOwnerName;
- private IslandLocation[] islandLocations;
+ private final IslandLocation[] islandLocations;
private int islandSize;
private int islandMembers;
private int safeLevel;
diff --git a/src/main/java/com/songoda/skyblock/visit/VisitManager.java b/src/main/java/com/songoda/skyblock/visit/VisitManager.java
index 69e29a90..72f9f9ce 100644
--- a/src/main/java/com/songoda/skyblock/visit/VisitManager.java
+++ b/src/main/java/com/songoda/skyblock/visit/VisitManager.java
@@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class VisitManager {
private final SkyBlock plugin;
- private HashMap visitStorage = new HashMap<>();
+ private final HashMap visitStorage = new HashMap<>();
public VisitManager(SkyBlock plugin) {
this.plugin = plugin;
@@ -40,7 +40,7 @@ public class VisitManager {
WorldManager worldManager = plugin.getWorldManager();
FileManager fileManager = plugin.getFileManager();
- if (!fileManager.getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration()
+ if (!this.plugin.getConfiguration()
.getBoolean("Island.Visitor.Unload")) {
File configFile = new File(plugin.getDataFolder().toString() + "/island-data");
@@ -54,14 +54,6 @@ public class VisitManager {
UUID islandOwnerUUID = FastUUID.parseUUID(fileList.getName().replace(".yml", ""));
- if (islandOwnerUUID == null) {
- islandOwnerUUID = FastUUID.parseUUID(fileList.getName().replaceFirst("[.][^.]+$", ""));
-
- if (islandOwnerUUID == null) {
- continue;
- }
- }
-
List islandSignature = new ArrayList<>();
if (configLoad.getString("Visitor.Signature.Message") != null) {
diff --git a/src/main/java/com/songoda/skyblock/world/WorldManager.java b/src/main/java/com/songoda/skyblock/world/WorldManager.java
index c2067ef3..255e4f03 100644
--- a/src/main/java/com/songoda/skyblock/world/WorldManager.java
+++ b/src/main/java/com/songoda/skyblock/world/WorldManager.java
@@ -25,8 +25,7 @@ public class WorldManager {
}
public void loadWorlds() {
- FileManager.Config config = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"));
- FileConfiguration configLoad = config.getFileConfiguration();
+ FileConfiguration configLoad = plugin.getConfiguration();
String normalWorldName = configLoad.getString("Island.World.Normal.Name");
String netherWorldName = configLoad.getString("Island.World.Nether.Name");
diff --git a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java
index 87ab3db6..e35500ff 100644
--- a/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java
+++ b/src/main/java/com/songoda/skyblock/world/generator/VoidGenerator.java
@@ -26,7 +26,7 @@ public class VoidGenerator extends ChunkGenerator {
final ChunkData chunkData = createChunkData(world);
final SkyBlock plugin = SkyBlock.getInstance();
- final Configuration configLoad = plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml")).getFileConfiguration();
+ final Configuration configLoad = plugin.getConfiguration();
final ConfigurationSection worldSection = configLoad.getConfigurationSection("Island.World");
Biome biome;
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index a1a8405e..45f01d74 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -17,6 +17,22 @@ Economy:
# Possible managers: Default, Vault, PlayerPoints and Reserve
Manager: Default
Island:
+ # This is settings is primary when damage, permission island dont work is false
+ Entity_Damage:
+ # player vs player
+ PVP: true
+ # entity vs player
+ EVP: true
+ # player vs entity
+ PVE: true
+ # entity vs entity
+ EVE: true
+ # Enabled or Disabled Task
+ Task:
+ PlaytimeTask: true
+ VisitTask: true
+
+
Performance:
# Chunk loading per tick affecting operations like island deletion, scan and biome changing.
# This option is ignored when using Paper's async chunk load
@@ -63,6 +79,8 @@ Island:
Time: 60
ClearInventory: false
ClearEnderChest: false
+ # When disabled, on deleting an island, it will only get removed from the plugin, the island itself stays
+ DeleteIsland: true
World:
# Delete the Island world when changing the liquid option.
# If lava disabled, the world will be a water world.