diff --git a/pom.xml b/pom.xml
index a3b7c6c7..14969023 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 3.1.0
+ 3.3.0-SNAPSHOT
shaded
@@ -104,6 +104,12 @@
+
+
+ apache.snapshots
+ https://repository.apache.org/snapshots/
+
+
spigot-repo
@@ -156,7 +162,7 @@
org.spigotmc
spigot
- 1.16.2
+ 1.17
com.github.MilkBowl
@@ -167,7 +173,7 @@
com.songoda
SongodaCore
- LATEST
+ 2.5.6
compile
diff --git a/src/main/java/com/songoda/skyblock/api/utils/APIUtil.java b/src/main/java/com/songoda/skyblock/api/utils/APIUtil.java
index dd4106cb..28101104 100644
--- a/src/main/java/com/songoda/skyblock/api/utils/APIUtil.java
+++ b/src/main/java/com/songoda/skyblock/api/utils/APIUtil.java
@@ -1,8 +1,14 @@
package com.songoda.skyblock.api.utils;
-import com.songoda.skyblock.api.island.*;
+import com.songoda.core.world.SWorldBorder;
+import com.songoda.skyblock.api.island.IslandBorderColor;
+import com.songoda.skyblock.api.island.IslandEnvironment;
+import com.songoda.skyblock.api.island.IslandMessage;
+import com.songoda.skyblock.api.island.IslandRole;
+import com.songoda.skyblock.api.island.IslandStatus;
+import com.songoda.skyblock.api.island.IslandUpgrade;
+import com.songoda.skyblock.api.island.IslandWorld;
import com.songoda.skyblock.upgrade.Upgrade;
-import com.songoda.skyblock.utils.world.WorldBorder;
public final class APIUtil {
@@ -57,7 +63,7 @@ public final class APIUtil {
return null;
}
-
+
public static com.songoda.skyblock.island.IslandStatus toImplementation(IslandStatus status) {
switch (status) {
case OPEN:
@@ -67,10 +73,10 @@ public final class APIUtil {
case WHITELISTED:
return com.songoda.skyblock.island.IslandStatus.WHITELISTED;
}
-
+
return null;
}
-
+
public static IslandStatus fromImplementation(com.songoda.skyblock.island.IslandStatus status) {
switch (status) {
case OPEN:
@@ -80,7 +86,7 @@ public final class APIUtil {
case WHITELISTED:
return IslandStatus.WHITELISTED;
}
-
+
return null;
}
@@ -186,20 +192,20 @@ public final class APIUtil {
return null;
}
- public static WorldBorder.Color toImplementation(IslandBorderColor color) {
+ public static SWorldBorder.Color toImplementation(IslandBorderColor color) {
switch (color) {
case Blue:
- return WorldBorder.Color.Blue;
+ return SWorldBorder.Color.Blue;
case Green:
- return WorldBorder.Color.Green;
+ return SWorldBorder.Color.Green;
case Red:
- return WorldBorder.Color.Red;
+ return SWorldBorder.Color.Red;
}
return null;
}
- public static IslandBorderColor fromImplementation(WorldBorder.Color color) {
+ public static IslandBorderColor fromImplementation(SWorldBorder.Color color) {
switch (color) {
case Blue:
return IslandBorderColor.Blue;
diff --git a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java
index 999d3739..6473c966 100644
--- a/src/main/java/com/songoda/skyblock/biome/BiomeManager.java
+++ b/src/main/java/com/songoda/skyblock/biome/BiomeManager.java
@@ -7,7 +7,6 @@ import com.songoda.skyblock.blockscanner.ChunkLoader;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandEnvironment;
import com.songoda.skyblock.island.IslandWorld;
-import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Biome;
diff --git a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java
index 3f350403..4ab97416 100644
--- a/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java
+++ b/src/main/java/com/songoda/skyblock/generator/GeneratorManager.java
@@ -2,10 +2,10 @@ package com.songoda.skyblock.generator;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.IslandWorld;
-import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@@ -105,7 +105,7 @@ public class GeneratorManager {
@SuppressWarnings("deprecation")
private int getLiquidLevel(Block block) {
- if (NMSUtil.getVersionNumber() > 12 && block.getState().getBlockData() instanceof Levelled) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12) && block.getState().getBlockData() instanceof Levelled) {
Levelled levelled = (Levelled) block.getState().getBlockData();
return levelled.getLevel();
} else {
@@ -125,7 +125,7 @@ public class GeneratorManager {
plugin.getSoundManager().playSound(block.getLocation(), CompatibleSound.BLOCK_FIRE_EXTINGUISH.getSound(), 1.0F, 10.0F);
- if (NMSUtil.getVersionNumber() > 12) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
block.setType(materials.getMaterial());
} else {
ItemStack is = materials.getItem();
diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java
index 753672c7..8adf2ec8 100644
--- a/src/main/java/com/songoda/skyblock/island/Island.java
+++ b/src/main/java/com/songoda/skyblock/island/Island.java
@@ -4,6 +4,7 @@ import com.eatthepath.uuid.FastUUID;
import com.songoda.core.compatibility.CompatibleBiome;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.utils.PlayerUtils;
+import com.songoda.core.world.SWorldBorder;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.api.event.island.*;
import com.songoda.skyblock.api.utils.APIUtil;
@@ -16,7 +17,6 @@ import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.upgrade.Upgrade;
import com.songoda.core.utils.NumberUtils;
-import com.songoda.skyblock.utils.world.WorldBorder;
import com.songoda.skyblock.visit.Visit;
import com.songoda.skyblock.world.WorldManager;
import org.apache.commons.lang.WordUtils;
@@ -132,7 +132,7 @@ public class Island {
if (configLoad.getString("Border") == null) {
configLoad.set("Border.Enable", mainConfigLoad.getBoolean("Island.WorldBorder.Default", false));
- configLoad.set("Border.Color", WorldBorder.Color.Blue.name());
+ configLoad.set("Border.Color", SWorldBorder.Color.Blue.name());
}
if (configLoad.getString("Members") != null) {
@@ -230,7 +230,7 @@ public class Island {
configLoad.set("UUID", islandUUID.toString());
configLoad.set("Visitor.Status", mainConfigLoad.getString("Island.Visitor.Status").toUpperCase());
configLoad.set("Border.Enable", mainConfigLoad.getBoolean("Island.WorldBorder.Default", false));
- configLoad.set("Border.Color", WorldBorder.Color.Blue.name());
+ configLoad.set("Border.Color", SWorldBorder.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
configLoad.set("Weather.Time", mainConfigLoad.getInt("Island.Weather.Default.Time"));
@@ -435,13 +435,13 @@ public class Island {
.getFileConfiguration().set("Border.Enable", border);
}
- public WorldBorder.Color getBorderColor() {
- return WorldBorder.Color.valueOf(plugin.getFileManager().getConfig(
+ public SWorldBorder.Color getBorderColor() {
+ return SWorldBorder.Color.valueOf(plugin.getFileManager().getConfig(
new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().getString("Border.Color"));
}
- public void setBorderColor(WorldBorder.Color color) {
+ public void setBorderColor(SWorldBorder.Color color) {
plugin.getFileManager().getConfig(
new File(new File(plugin.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml"))
.getFileConfiguration().set("Border.Color", color.name());
diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java
index 8da953c9..8c030747 100644
--- a/src/main/java/com/songoda/skyblock/island/IslandManager.java
+++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java
@@ -9,6 +9,7 @@ import com.songoda.core.compatibility.CompatibleBiome;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.compatibility.ServerVersion;
+import com.songoda.core.world.SWorldBorder;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.api.event.island.*;
import com.songoda.skyblock.ban.BanManager;
@@ -36,9 +37,7 @@ import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.utils.player.PlayerUtil;
import com.songoda.skyblock.utils.structure.SchematicUtil;
import com.songoda.skyblock.utils.structure.StructureUtil;
-import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
-import com.songoda.skyblock.utils.world.WorldBorder;
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
import com.songoda.skyblock.visit.VisitManager;
import com.songoda.skyblock.world.WorldManager;
@@ -1460,7 +1459,7 @@ public class IslandManager {
updateFlight(player);
if (world == IslandWorld.Nether) {
- if (NMSUtil.getVersionNumber() < 13) {
+ if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
return;
}
}
@@ -1469,11 +1468,11 @@ public class IslandManager {
Bukkit.getScheduler().runTask(plugin, () -> {
if (configLoad.getBoolean("Island.WorldBorder.Enable") && island.isBorder()) {
- WorldBorder.send(player, island.getBorderColor(), island.getSize(),
+ SWorldBorder.send(player, island.getBorderColor(), island.getSize(),
island.getLocation(worldManager.getIslandWorld(player.getWorld()),
IslandEnvironment.Island).clone().add(increment, 0, increment));
} else {
- WorldBorder.send(player, null, 1.4999992E7D, new org.bukkit.Location(player.getWorld(), 0, 0, 0));
+ SWorldBorder.send(player, null, 1.4999992E7D, new org.bukkit.Location(player.getWorld(), 0, 0, 0));
}
});
}
@@ -1615,7 +1614,7 @@ public class IslandManager {
if (worldList != IslandWorld.Nether || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
Bukkit.getScheduler().runTask(plugin, () -> {
for (Player all : getPlayersAtIsland(island)) {
- WorldBorder.send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island).clone().add(increment, 0, increment));
+ SWorldBorder.send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island).clone().add(increment, 0, increment));
}
});
}
@@ -1627,7 +1626,7 @@ public class IslandManager {
if (worldList != IslandWorld.Nether || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
Bukkit.getScheduler().runTask(plugin, () -> {
for (Player all : getPlayersAtIsland(island)) {
- WorldBorder.send(all, null, 1.4999992E7D, new Location(all.getWorld(), 0, 0, 0));
+ SWorldBorder.send(all, null, 1.4999992E7D, new Location(all.getWorld(), 0, 0, 0));
}
});
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/BlockListeners.java b/src/main/java/com/songoda/skyblock/listeners/BlockListeners.java
index 9c027b54..51349092 100644
--- a/src/main/java/com/songoda/skyblock/listeners/BlockListeners.java
+++ b/src/main/java/com/songoda/skyblock/listeners/BlockListeners.java
@@ -21,7 +21,6 @@ import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.core.utils.NumberUtils;
import com.songoda.skyblock.utils.version.CompatibleSpawners;
-import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import org.apache.commons.lang.WordUtils;
@@ -176,9 +175,8 @@ public class BlockListeners implements Listener {
break;
}
}
- if (material == null) {
+ if (material == null)
material = CompatibleMaterial.getMaterial(block);
- }
if (material == null) return;
@@ -653,7 +651,7 @@ public class BlockListeners implements Listener {
IslandManager islandManager = plugin.getIslandManager();
// PortalCreateEvent.getBlocks() changed from ArrayList to
// ArrayList in 1.14.1
- if (NMSUtil.getVersionNumber() > 13) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
List blocks = event.getBlocks(); // TODO 1.8
if (event.getBlocks().isEmpty()) return;
diff --git a/src/main/java/com/songoda/skyblock/listeners/EntityListeners.java b/src/main/java/com/songoda/skyblock/listeners/EntityListeners.java
index 10aab47f..9f3db175 100644
--- a/src/main/java/com/songoda/skyblock/listeners/EntityListeners.java
+++ b/src/main/java/com/songoda/skyblock/listeners/EntityListeners.java
@@ -12,7 +12,6 @@ import com.songoda.skyblock.limit.impl.EntityLimitation;
import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.upgrade.Upgrade;
-import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.Bukkit;
@@ -203,7 +202,7 @@ public class EntityListeners implements Listener {
islandManager.getIslandAtLocation(event.getRightClicked().getLocation())))
return;
- if (NMSUtil.getVersionNumber() != 8) return;
+ if (ServerVersion.isServerVersion(ServerVersion.V1_8)) return;
StackableManager stackableManager = SkyBlock.getInstance().getStackableManager();
if (stackableManager == null) return;
diff --git a/src/main/java/com/songoda/skyblock/listeners/GrowListeners.java b/src/main/java/com/songoda/skyblock/listeners/GrowListeners.java
index f649a72d..2091cf62 100644
--- a/src/main/java/com/songoda/skyblock/listeners/GrowListeners.java
+++ b/src/main/java/com/songoda/skyblock/listeners/GrowListeners.java
@@ -1,6 +1,7 @@
package com.songoda.skyblock.listeners;
import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
@@ -8,7 +9,6 @@ import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.permission.PermissionManager;
import com.songoda.skyblock.upgrade.Upgrade;
-import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import org.bukkit.Bukkit;
@@ -95,7 +95,7 @@ public class GrowListeners implements Listener {
if (upgrades == null || upgrades.size() == 0 || !upgrades.get(0).isEnabled() || !island.isUpgrade(Upgrade.Type.Crop))
return;
- if (NMSUtil.getVersionNumber() > 12) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
try {
Object blockData = block.getClass().getMethod("getBlockData").invoke(block);
if (blockData instanceof org.bukkit.block.data.Ageable) {
diff --git a/src/main/java/com/songoda/skyblock/listeners/MoveListeners.java b/src/main/java/com/songoda/skyblock/listeners/MoveListeners.java
index 7f374c14..0592fce2 100644
--- a/src/main/java/com/songoda/skyblock/listeners/MoveListeners.java
+++ b/src/main/java/com/songoda/skyblock/listeners/MoveListeners.java
@@ -1,6 +1,7 @@
package com.songoda.skyblock.listeners;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
@@ -10,7 +11,6 @@ import com.songoda.skyblock.permission.PermissionManager;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
-import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import io.papermc.lib.PaperLib;
@@ -122,7 +122,7 @@ public class MoveListeners implements Listener {
player.setLevel(0);
player.setExp(0.0F);
- if (NMSUtil.getVersionNumber() > 8) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
player.setHealth(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue());
} else {
player.setHealth(player.getMaxHealth());
diff --git a/src/main/java/com/songoda/skyblock/listeners/SpawnerListeners.java b/src/main/java/com/songoda/skyblock/listeners/SpawnerListeners.java
index d62187b5..3abb46aa 100644
--- a/src/main/java/com/songoda/skyblock/listeners/SpawnerListeners.java
+++ b/src/main/java/com/songoda/skyblock/listeners/SpawnerListeners.java
@@ -1,10 +1,10 @@
package com.songoda.skyblock.listeners;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.upgrade.Upgrade;
-import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -29,73 +29,75 @@ public class SpawnerListeners implements Listener {
CreatureSpawner spawner = event.getSpawner();
org.bukkit.Location location = spawner.getBlock().getLocation();
- if (plugin.getWorldManager().isIslandWorld(location.getWorld())) {
- Island island = islandManager.getIslandAtLocation(location);
+ if (!plugin.getWorldManager().isIslandWorld(location.getWorld()))
+ return;
- if (island != null) {
- List upgrades = plugin.getUpgradeManager().getUpgrades(Upgrade.Type.Spawner);
+ Island island = islandManager.getIslandAtLocation(location);
- if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()
- && island.isUpgrade(Upgrade.Type.Spawner)) {
- if (NMSUtil.getVersionNumber() > 12) {
- if (spawner.getDelay() == 20) {
- spawner.setDelay(10);
- }
+ if (island == null)
+ return;
- spawner.setMinSpawnDelay(100);
- spawner.setMaxSpawnDelay(400);
- } else {
- try {
- Object MobSpawner;
+ List upgrades = plugin.getUpgradeManager().getUpgrades(Upgrade.Type.Spawner);
- try {
- Field TileEntityMobSpawnerField = spawner.getClass().getDeclaredField("spawner");
- TileEntityMobSpawnerField.setAccessible(true);
- Object TileEntityMobSpawner = TileEntityMobSpawnerField.get(spawner);
- MobSpawner = TileEntityMobSpawner.getClass().getMethod("getSpawner")
- .invoke(TileEntityMobSpawner);
- } catch (NoSuchFieldException ignored) {
- Field snapshotField = spawner.getClass().getSuperclass().getDeclaredField("snapshot");
- snapshotField.setAccessible(true);
- Object snapshot = snapshotField.get(spawner);
- MobSpawner = snapshot.getClass().getMethod("getSpawner").invoke(snapshot);
- }
+ if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()
+ && island.isUpgrade(Upgrade.Type.Spawner)) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
+ if (spawner.getDelay() == 20) {
+ spawner.setDelay(10);
+ }
- int spawnDelay = (int) MobSpawner.getClass().getSuperclass().getField("spawnDelay")
- .get(MobSpawner);
+ spawner.setMinSpawnDelay(100);
+ spawner.setMaxSpawnDelay(400);
+ } else {
+ try {
+ Object MobSpawner;
- if (spawnDelay == 20) {
- Field spawnDelayField = MobSpawner.getClass().getSuperclass().getField("spawnDelay");
- spawnDelayField.setAccessible(true);
- spawnDelayField.set(MobSpawner, 10);
- }
-
- Field minSpawnDelayField = MobSpawner.getClass().getSuperclass()
- .getDeclaredField("minSpawnDelay");
- minSpawnDelayField.setAccessible(true);
- int minSpawnDelay = (int) minSpawnDelayField.get(MobSpawner);
-
- if (minSpawnDelay != 100) {
- minSpawnDelayField.set(MobSpawner, 100);
- }
-
- Field maxSpawnDelayField = MobSpawner.getClass().getSuperclass()
- .getDeclaredField("maxSpawnDelay");
- maxSpawnDelayField.setAccessible(true);
- int maxSpawnDelay = (int) maxSpawnDelayField.get(MobSpawner);
-
- if (maxSpawnDelay != 400) {
- maxSpawnDelayField.set(MobSpawner, 400);
- }
- } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
- | SecurityException | InvocationTargetException | NoSuchMethodException e) {
- e.printStackTrace();
- }
+ try {
+ Field TileEntityMobSpawnerField = spawner.getClass().getDeclaredField("spawner");
+ TileEntityMobSpawnerField.setAccessible(true);
+ Object TileEntityMobSpawner = TileEntityMobSpawnerField.get(spawner);
+ MobSpawner = TileEntityMobSpawner.getClass().getMethod("getSpawner")
+ .invoke(TileEntityMobSpawner);
+ } catch (NoSuchFieldException ignored) {
+ Field snapshotField = spawner.getClass().getSuperclass().getDeclaredField("snapshot");
+ snapshotField.setAccessible(true);
+ Object snapshot = snapshotField.get(spawner);
+ MobSpawner = snapshot.getClass().getMethod("getSpawner").invoke(snapshot);
}
-
- spawner.update();
+
+ int spawnDelay = (int) MobSpawner.getClass().getSuperclass().getField("spawnDelay")
+ .get(MobSpawner);
+
+ if (spawnDelay == 20) {
+ Field spawnDelayField = MobSpawner.getClass().getSuperclass().getField("spawnDelay");
+ spawnDelayField.setAccessible(true);
+ spawnDelayField.set(MobSpawner, 10);
+ }
+
+ Field minSpawnDelayField = MobSpawner.getClass().getSuperclass()
+ .getDeclaredField("minSpawnDelay");
+ minSpawnDelayField.setAccessible(true);
+ int minSpawnDelay = (int) minSpawnDelayField.get(MobSpawner);
+
+ if (minSpawnDelay != 100) {
+ minSpawnDelayField.set(MobSpawner, 100);
+ }
+
+ Field maxSpawnDelayField = MobSpawner.getClass().getSuperclass()
+ .getDeclaredField("maxSpawnDelay");
+ maxSpawnDelayField.setAccessible(true);
+ int maxSpawnDelay = (int) maxSpawnDelayField.get(MobSpawner);
+
+ if (maxSpawnDelay != 400) {
+ maxSpawnDelayField.set(MobSpawner, 400);
+ }
+ } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
+ | SecurityException | InvocationTargetException | NoSuchMethodException e) {
+ e.printStackTrace();
}
}
+
+ spawner.update();
}
}
}
diff --git a/src/main/java/com/songoda/skyblock/menus/Bans.java b/src/main/java/com/songoda/skyblock/menus/Bans.java
index 7f0f4459..1b54d1b1 100644
--- a/src/main/java/com/songoda/skyblock/menus/Bans.java
+++ b/src/main/java/com/songoda/skyblock/menus/Bans.java
@@ -2,6 +2,7 @@ package com.songoda.skyblock.menus;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.gui.AnvilGui;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
@@ -13,7 +14,6 @@ import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
-import com.songoda.skyblock.utils.AbstractAnvilGUI;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import org.bukkit.Bukkit;
@@ -92,17 +92,13 @@ public class Bans {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
Bukkit.getServer().dispatchCommand(player,
- "island ban " + event1.getName());
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
- }
+ "island ban " + gui.getInputText());
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin, () -> open(player), 1L);
+ player.closeInventory();
});
ItemStack is1 = new ItemStack(Material.NAME_TAG);
@@ -110,8 +106,8 @@ public class Bans {
im.setDisplayName(configLoad.getString("Menu.Bans.Item.Word.Enter"));
is1.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is1);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
}, 1L);
} else if ((is.getType() == Material.BARRIER) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(plugin.formatText(
diff --git a/src/main/java/com/songoda/skyblock/menus/Border.java b/src/main/java/com/songoda/skyblock/menus/Border.java
index a06487a5..e4487189 100644
--- a/src/main/java/com/songoda/skyblock/menus/Border.java
+++ b/src/main/java/com/songoda/skyblock/menus/Border.java
@@ -2,8 +2,8 @@ package com.songoda.skyblock.menus;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.world.SWorldBorder;
import com.songoda.skyblock.SkyBlock;
-import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
@@ -11,7 +11,6 @@ import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.item.nInventoryUtil;
-import com.songoda.skyblock.utils.world.WorldBorder;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -20,8 +19,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
-import java.io.File;
-
public class Border {
private static Border instance;
@@ -52,11 +49,11 @@ public class Border {
return;
} else if (!((island.hasRole(IslandRole.Operator, player.getUniqueId())
- && plugin.getPermissionManager().hasPermission(island,"Border", IslandRole.Operator))
+ && plugin.getPermissionManager().hasPermission(island, "Border", IslandRole.Operator))
|| island.hasRole(IslandRole.Owner, player.getUniqueId()))) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Border.Permission.Message"));
- soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
+ soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
return;
} else if (!plugin.getConfiguration().getBoolean("Island.WorldBorder.Enable")) {
@@ -86,13 +83,13 @@ public class Border {
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Blue")))))) {
- if (island.getBorderColor() == WorldBorder.Color.Blue) {
+ if (island.getBorderColor() == SWorldBorder.Color.Blue) {
soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
} else {
- island.setBorderColor(WorldBorder.Color.Blue);
+ island.setBorderColor(SWorldBorder.Color.Blue);
islandManager.updateBorder(island);
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@@ -104,13 +101,13 @@ public class Border {
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Green")))))) {
- if (island.getBorderColor() == WorldBorder.Color.Green) {
+ if (island.getBorderColor() == SWorldBorder.Color.Green) {
soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
} else {
- island.setBorderColor(WorldBorder.Color.Green);
+ island.setBorderColor(SWorldBorder.Color.Green);
islandManager.updateBorder(island);
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@@ -122,13 +119,13 @@ public class Border {
.equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Red")))))) {
- if (island.getBorderColor() == WorldBorder.Color.Red) {
+ if (island.getBorderColor() == SWorldBorder.Color.Red) {
soundManager.playSound(player, CompatibleSound.ENTITY_CHICKEN_EGG.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
} else {
- island.setBorderColor(WorldBorder.Color.Red);
+ island.setBorderColor(SWorldBorder.Color.Red);
islandManager.updateBorder(island);
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
@@ -143,7 +140,7 @@ public class Border {
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Border.Item.Exit.Displayname"), null, null, null, null), 0);
- WorldBorder.Color borderColor = island.getBorderColor();
+ SWorldBorder.Color borderColor = island.getBorderColor();
String borderToggle;
if (island.isBorder()) {
@@ -157,8 +154,8 @@ public class Border {
configLoad.getStringList("Menu.Border.Item.Toggle.Lore"),
new Placeholder[]{new Placeholder("%toggle", borderToggle)}, null, null), 1);
- if(player.hasPermission("fabledskyblock.island.border.blue")){
- if (borderColor == WorldBorder.Color.Blue) {
+ if (player.hasPermission("fabledskyblock.island.border.blue")) {
+ if (borderColor == SWorldBorder.Color.Blue) {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIGHT_BLUE_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Blue")),
@@ -177,8 +174,8 @@ public class Border {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
"", null, null, null, null), 2);
}
- if(player.hasPermission("fabledskyblock.island.border.green")){
- if (borderColor == WorldBorder.Color.Green) {
+ if (player.hasPermission("fabledskyblock.island.border.green")) {
+ if (borderColor == SWorldBorder.Color.Green) {
nInv.addItem(nInv.createItem(CompatibleMaterial.LIME_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Green")),
@@ -199,8 +196,8 @@ public class Border {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(),
"", null, null, null, null), 3);
}
- if(player.hasPermission("fabledskyblock.island.border.red")){
- if (borderColor == WorldBorder.Color.Red) {
+ if (player.hasPermission("fabledskyblock.island.border.red")) {
+ if (borderColor == SWorldBorder.Color.Red) {
nInv.addItem(nInv.createItem(CompatibleMaterial.RED_DYE.getItem(),
configLoad.getString("Menu.Border.Item.Color.Displayname").replace("%color",
configLoad.getString("Menu.Border.Item.Word.Red")),
diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java
index f397037a..ced90f49 100644
--- a/src/main/java/com/songoda/skyblock/menus/Levelling.java
+++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java
@@ -2,6 +2,7 @@ package com.songoda.skyblock.menus;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
@@ -21,7 +22,6 @@ import com.songoda.skyblock.sound.SoundManager;
import com.songoda.core.utils.NumberUtils;
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;
@@ -267,7 +267,7 @@ public class Levelling {
String name = plugin.getLocalizationManager().getLocalizationFor(CompatibleMaterial.class).getLocale(materials);
- if (materials == CompatibleMaterial.FARMLAND && NMSUtil.getVersionNumber() < 9)
+ if (materials == CompatibleMaterial.FARMLAND && ServerVersion.isServerVersionBelow(ServerVersion.V1_9))
materials = CompatibleMaterial.DIRT;
ItemStack is = materials.getItem();
diff --git a/src/main/java/com/songoda/skyblock/menus/Ownership.java b/src/main/java/com/songoda/skyblock/menus/Ownership.java
index 9f68fe69..a06227f3 100644
--- a/src/main/java/com/songoda/skyblock/menus/Ownership.java
+++ b/src/main/java/com/songoda/skyblock/menus/Ownership.java
@@ -2,6 +2,7 @@ package com.songoda.skyblock.menus;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.gui.AnvilGui;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.island.Island;
@@ -12,7 +13,6 @@ import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
-import com.songoda.skyblock.utils.AbstractAnvilGUI;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import org.bukkit.Bukkit;
@@ -100,8 +100,8 @@ public class Ownership {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
if (playerDataManager.hasPlayerData(player)) {
Island island1 = islandManager.getIsland(player);
@@ -123,12 +123,9 @@ public class Ownership {
}
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getServer().dispatchCommand(player,
- "island ownership " + event1.getName()));
+ "island ownership " + gui.getInputText()));
}
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
- }
+ player.closeInventory();
});
ItemStack is1 = new ItemStack(Material.NAME_TAG);
@@ -136,8 +133,8 @@ public class Ownership {
im.setDisplayName(configLoad.getString("Menu.Ownership.Item.Assign.Word.Enter"));
is1.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is1);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
}, 1L);
} else if ((is.getType() == CompatibleMaterial.MAP.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
@@ -177,8 +174,8 @@ public class Ownership {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event12 -> {
- if (event12.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
if (playerDataManager.hasPlayerData(player)) {
Island island12 = islandManager.getIsland(player);
@@ -200,17 +197,14 @@ public class Ownership {
}
island12.setPassword(
- event12.getName().replace("&", "").replace(" ", ""));
+ gui.getInputText().replace("&", "").replace(" ", ""));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F,
1.0F);
Bukkit.getServer().getScheduler()
.runTaskLater(plugin, () -> open(player), 1L);
}
- } else {
- event12.setWillClose(false);
- event12.setWillDestroy(false);
- }
+ player.closeInventory();
});
ItemStack is12 = new ItemStack(Material.NAME_TAG);
@@ -219,8 +213,8 @@ public class Ownership {
configLoad.getString("Menu.Ownership.Item.Password.Hidden.Word.Enter"));
is12.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is12);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
}, 1L);
}
}
diff --git a/src/main/java/com/songoda/skyblock/menus/Settings.java b/src/main/java/com/songoda/skyblock/menus/Settings.java
index 80131366..5c510f7e 100644
--- a/src/main/java/com/songoda/skyblock/menus/Settings.java
+++ b/src/main/java/com/songoda/skyblock/menus/Settings.java
@@ -2,16 +2,21 @@ package com.songoda.skyblock.menus;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.gui.AnvilGui;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
-import com.songoda.skyblock.island.*;
+import com.songoda.skyblock.island.Island;
+import com.songoda.skyblock.island.IslandManager;
+import com.songoda.skyblock.island.IslandMessage;
+import com.songoda.skyblock.island.IslandPermission;
+import com.songoda.skyblock.island.IslandRole;
+import com.songoda.skyblock.island.IslandStatus;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.PermissionManager;
import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
-import com.songoda.skyblock.utils.AbstractAnvilGUI;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.visit.Visit;
import org.bukkit.Bukkit;
@@ -97,7 +102,7 @@ public class Settings {
&& !permissionManager.hasPermission(island13, "Coop", IslandRole.Operator)) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
- soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
+ soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
@@ -115,7 +120,7 @@ public class Settings {
&& !permissionManager.hasPermission(island13, "Visitor", IslandRole.Operator)) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
- soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
+ soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
@@ -134,7 +139,7 @@ public class Settings {
&& !permissionManager.hasPermission(island13, "Member", IslandRole.Operator)) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
- soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
+ soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
@@ -151,7 +156,7 @@ public class Settings {
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
- soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
+ soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
@@ -167,10 +172,10 @@ public class Settings {
.equals(plugin.formatText(configLoad
.getString("Menu.Settings.Categories.Item.Owner.Displayname"))))) {
if (island13.hasRole(IslandRole.Operator, player.getUniqueId())
- && !permissionManager.hasPermission(island13,"Island", IslandRole.Operator)) {
+ && !permissionManager.hasPermission(island13, "Island", IslandRole.Operator)) {
messageManager.sendMessage(player,
configLoad.getString("Command.Island.Settings.Permission.Access.Message"));
- soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
+ soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F);
event.setWillClose(false);
event.setWillDestroy(false);
@@ -342,7 +347,7 @@ public class Settings {
}
if (config.getFileConfiguration().getBoolean("Island.Visitor.Vote")) {
- switch (visit.getStatus()){
+ switch (visit.getStatus()) {
case OPEN:
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING),
configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"),
@@ -378,7 +383,7 @@ public class Settings {
break;
}
} else {
- switch (visit.getStatus()){
+ switch (visit.getStatus()) {
case OPEN:
nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING),
configLoad.getString("Menu.Settings.Visitor.Item.Statistics.Displayname"),
@@ -1109,94 +1114,83 @@ public class Settings {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- Island island1 = islandManager.getIsland(player);
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
- if (island1 == null) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Command.Island.Settings.Owner.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
- player.closeInventory();
+ Island island1 = islandManager.getIsland(player);
- event1.setWillClose(true);
- event1.setWillDestroy(true);
+ if (island1 == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Command.Island.Settings.Owner.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+ player.closeInventory();
- return;
- } else if (!(island1.hasRole(IslandRole.Operator,
- player.getUniqueId())
- || island1.hasRole(IslandRole.Owner,
- player.getUniqueId()))) {
- messageManager.sendMessage(player, configLoad
- .getString("Command.Island.Role.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
- player.closeInventory();
+ return;
+ } else if (!(island1.hasRole(IslandRole.Operator,
+ player.getUniqueId())
+ || island1.hasRole(IslandRole.Owner,
+ player.getUniqueId()))) {
+ messageManager.sendMessage(player, configLoad
+ .getString("Command.Island.Role.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+ player.closeInventory();
- event1.setWillClose(true);
- event1.setWillDestroy(true);
+ return;
+ } else if (!plugin.getFileManager()
+ .getConfig(new File(plugin.getDataFolder(),
+ "config.yml"))
+ .getFileConfiguration()
+ .getBoolean("Island.Visitor.Welcome.Enable")) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Settings.Visitor.Welcome.Disabled.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
- return;
- } else if (!plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(),
- "config.yml"))
- .getFileConfiguration()
- .getBoolean("Island.Visitor.Welcome.Enable")) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Settings.Visitor.Welcome.Disabled.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
+ player.closeInventory();
- event1.setWillClose(true);
- event1.setWillDestroy(true);
-
- return;
- }
-
- Config config1 = plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(),
- "config.yml"));
- FileConfiguration configLoad1 = config1
- .getFileConfiguration();
-
- if (island1.getMessage(IslandMessage.Welcome)
- .size() > configLoad1
- .getInt("Island.Visitor.Welcome.Lines")
- || event1.getName().length() > configLoad1
- .getInt("Island.Visitor.Welcome.Length")) {
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
- } else {
- List welcomeMessage = island1
- .getMessage(IslandMessage.Welcome);
- welcomeMessage.add(event1.getName());
- island1.setMessage(IslandMessage.Welcome,
- player.getName(), welcomeMessage);
- 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);
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ return;
}
+
+ Config config1 = plugin.getFileManager()
+ .getConfig(new File(plugin.getDataFolder(),
+ "config.yml"));
+ FileConfiguration configLoad1 = config1
+ .getFileConfiguration();
+
+ if (island1.getMessage(IslandMessage.Welcome)
+ .size() > configLoad1
+ .getInt("Island.Visitor.Welcome.Lines")
+ || gui.getInputText().length() > configLoad1
+ .getInt("Island.Visitor.Welcome.Length")) {
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+ } else {
+ List welcomeMessage = island1
+ .getMessage(IslandMessage.Welcome);
+ welcomeMessage.add(gui.getInputText());
+ island1.setMessage(IslandMessage.Welcome,
+ player.getName(), welcomeMessage);
+ 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);
+
+ player.closeInventory();
});
ItemStack is1 = new ItemStack(Material.NAME_TAG);
@@ -1205,8 +1199,9 @@ public class Settings {
"Menu.Settings.Visitor.Panel.Welcome.Item.Line.Add.Word.Enter"));
is1.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is1);
- gui.open();
+ gui.setInput(is1);
+ plugin.getGuiManager().showGUI(player, gui);
+
}, 1L);
}
} else if ((is.getType() == Material.ARROW) && (is.hasItemMeta()) && (is.getItemMeta()
@@ -1366,94 +1361,81 @@ public class Settings {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- Island island1 = islandManager.getIsland(player);
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
- if (island1 == null) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Command.Island.Settings.Owner.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
- player.closeInventory();
+ Island island1 = islandManager.getIsland(player);
- event1.setWillClose(true);
- event1.setWillDestroy(true);
+ if (island1 == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Command.Island.Settings.Owner.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+ player.closeInventory();
+ return;
+ } else if (!(island1.hasRole(IslandRole.Operator,
+ player.getUniqueId())
+ || island1.hasRole(IslandRole.Owner,
+ player.getUniqueId()))) {
+ messageManager.sendMessage(player, configLoad
+ .getString("Command.Island.Role.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+ player.closeInventory();
+ return;
+ } else if (!plugin.getFileManager()
+ .getConfig(new File(plugin.getDataFolder(),
+ "config.yml"))
+ .getFileConfiguration().getBoolean(
+ "Island.Visitor.Signature.Enable")) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Settings.Visitor.Signature.Disabled.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
- return;
- } else if (!(island1.hasRole(IslandRole.Operator,
- player.getUniqueId())
- || island1.hasRole(IslandRole.Owner,
- player.getUniqueId()))) {
- messageManager.sendMessage(player, configLoad
- .getString("Command.Island.Role.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
- player.closeInventory();
+ player.closeInventory();
- event1.setWillClose(true);
- event1.setWillDestroy(true);
-
- return;
- } else if (!plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(),
- "config.yml"))
- .getFileConfiguration().getBoolean(
- "Island.Visitor.Signature.Enable")) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Settings.Visitor.Signature.Disabled.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
-
- return;
- }
-
- Config config1 = plugin.getFileManager()
- .getConfig(new File(plugin.getDataFolder(),
- "config.yml"));
- FileConfiguration configLoad1 = config1
- .getFileConfiguration();
-
- if (island1.getMessage(IslandMessage.Signature)
- .size() > configLoad1.getInt(
- "Island.Visitor.Signature.Lines")
- || event1.getName().length() > configLoad1
- .getInt("Island.Visitor.Signature.Length")) {
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
- } else {
- List signatureMessage = island1
- .getMessage(IslandMessage.Signature);
- signatureMessage.add(event1.getName());
- island1.setMessage(IslandMessage.Signature,
- player.getName(), signatureMessage);
- 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);
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ return;
}
+
+ Config config1 = plugin.getFileManager()
+ .getConfig(new File(plugin.getDataFolder(),
+ "config.yml"));
+ FileConfiguration configLoad1 = config1
+ .getFileConfiguration();
+
+ if (island1.getMessage(IslandMessage.Signature)
+ .size() > configLoad1.getInt(
+ "Island.Visitor.Signature.Lines")
+ || gui.getInputText().length() > configLoad1
+ .getInt("Island.Visitor.Signature.Length")) {
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+ } else {
+ List signatureMessage = island1
+ .getMessage(IslandMessage.Signature);
+ signatureMessage.add(gui.getInputText());
+ island1.setMessage(IslandMessage.Signature,
+ player.getName(), signatureMessage);
+ 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);
+
+ player.closeInventory();
});
ItemStack is12 = new ItemStack(Material.NAME_TAG);
@@ -1462,8 +1444,9 @@ public class Settings {
"Menu.Settings.Visitor.Panel.Signature.Item.Line.Add.Word.Enter"));
is12.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is12);
- gui.open();
+ gui.setInput(is12);
+ plugin.getGuiManager().showGUI(player, gui);
+
}, 1L);
}
} else if ((is.getType() == Material.ARROW) && (is.hasItemMeta()) && (is.getItemMeta()
diff --git a/src/main/java/com/songoda/skyblock/menus/Upgrade.java b/src/main/java/com/songoda/skyblock/menus/Upgrade.java
index 8cedad20..3a4f2dfc 100644
--- a/src/main/java/com/songoda/skyblock/menus/Upgrade.java
+++ b/src/main/java/com/songoda/skyblock/menus/Upgrade.java
@@ -2,6 +2,7 @@ package com.songoda.skyblock.menus;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.hooks.economies.Economy;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.api.event.island.IslandUpgradeEvent;
@@ -17,7 +18,6 @@ import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.upgrade.UpgradeManager;
import com.songoda.core.utils.NumberUtils;
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;
@@ -504,18 +504,17 @@ public class Upgrade {
List upgrades;
ItemStack potion = new ItemStack(Material.POTION);
- int NMSVersion = NMSUtil.getVersionNumber();
if(player.hasPermission("fabledskyblock.upgrade." + com.songoda.skyblock.upgrade.Upgrade.Type.Speed.name().toLowerCase())) {
upgrades = upgradeManager.getUpgrades(com.songoda.skyblock.upgrade.Upgrade.Type.Speed);
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) {
com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
-
- if (NMSVersion > 8) {
+
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
PotionMeta pm = (PotionMeta) potion.getItemMeta();
-
- if (NMSVersion > 9) {
+
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10)) {
pm.setBasePotionData(new PotionData(PotionType.SPEED));
} else {
pm.addCustomEffect(new PotionEffect(PotionEffectType.SPEED, 1, 0), true);
@@ -564,11 +563,11 @@ public class Upgrade {
if (upgrades != null && upgrades.size() > 0 && upgrades.get(0).isEnabled()) {
com.songoda.skyblock.upgrade.Upgrade upgrade = upgrades.get(0);
- if (NMSVersion > 8) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_8)) {
potion = new ItemStack(Material.POTION);
PotionMeta pm = (PotionMeta) potion.getItemMeta();
- if (NMSVersion > 9) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
pm.setBasePotionData(new PotionData(PotionType.JUMP));
} else {
pm.addCustomEffect(new PotionEffect(PotionEffectType.JUMP, 1, 0), true);
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 385a480a..664d022e 100644
--- a/src/main/java/com/songoda/skyblock/menus/admin/Creator.java
+++ b/src/main/java/com/songoda/skyblock/menus/admin/Creator.java
@@ -2,6 +2,8 @@ package com.songoda.skyblock.menus.admin;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.compatibility.ServerVersion;
+import com.songoda.core.gui.AnvilGui;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
@@ -14,9 +16,7 @@ import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.structure.Structure;
import com.songoda.skyblock.structure.StructureManager;
-import com.songoda.skyblock.utils.AbstractAnvilGUI;
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.configuration.file.FileConfiguration;
@@ -268,7 +268,7 @@ public class Creator implements Listener {
FileConfiguration configLoad = config.getFileConfiguration();
String inventoryName = "";
- if (NMSUtil.getVersionNumber() > 13) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
inventoryName = event.getView().getTitle();
} else {
try {
@@ -322,56 +322,50 @@ public class Creator implements Listener {
configLoad.getString("Menu.Admin.Creator.Browse.Item.Information.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.creator")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Permission.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (structureManager.containsStructure(event1.getName())) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Already.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (!event1.getName().replace(" ", "").matches("^[a-zA-Z0-9]+$")) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Characters.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else {
- structureManager.addStructure(event1.getName(), CompatibleMaterial.GRASS_BLOCK, null, null, null,
- null, false, new ArrayList<>(), new ArrayList<>(), 0.0D);
-
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Created.Message")
- .replace("%structure", event1.getName()));
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
-
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
- Config config111 = fileManager
- .getConfig(new File(plugin.getDataFolder(), "structures.yml"));
- FileConfiguration configLoad111 = config111.getFileConfiguration();
-
- configLoad111.set("Structures." + event1.getName() + ".Name", event1.getName());
-
- try {
- configLoad111.save(config111.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
-
- player.closeInventory();
-
- Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L);
- }
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
+ if (!(player.hasPermission("fabledskyblock.admin.creator")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Permission.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ } else if (structureManager.containsStructure(gui.getInputText())) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Already.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ } else if (!gui.getInputText().replace(" ", "").matches("^[a-zA-Z0-9]+$")) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Characters.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ structureManager.addStructure(gui.getInputText(), CompatibleMaterial.GRASS_BLOCK, null, null, null,
+ null, false, new ArrayList<>(), new ArrayList<>(), 0.0D);
+
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Created.Message")
+ .replace("%structure", gui.getInputText()));
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
+
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
+ Config config111 = fileManager
+ .getConfig(new File(plugin.getDataFolder(), "structures.yml"));
+ FileConfiguration configLoad111 = config111.getFileConfiguration();
+
+ configLoad111.set("Structures." + gui.getInputText() + ".Name", gui.getInputText());
+
+ try {
+ configLoad111.save(config111.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+
+ player.closeInventory();
+
+ Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L);
}
+ player.closeInventory();
});
is = new ItemStack(CompatibleMaterial.NAME_TAG.getMaterial());
@@ -379,8 +373,8 @@ public class Creator implements Listener {
im.setDisplayName(configLoad.getString("Menu.Admin.Creator.Browse.Item.Information.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
return;
} else if ((event.getCurrentItem().getType() == CompatibleMaterial.BARRIER.getMaterial()) && (is.hasItemMeta())
@@ -406,67 +400,62 @@ public class Creator implements Listener {
if (structureManager.containsStructure(name)) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.creator")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Permission.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (playerData.getViewer() == null) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Selected.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
- player.closeInventory();
+ if (!(player.hasPermission("fabledskyblock.admin.creator")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Permission.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ } else if (playerData.getViewer() == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Selected.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- } else if (!structureManager.containsStructure(name)) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Exist.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ player.closeInventory();
- player.closeInventory();
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
+ } else if (!structureManager.containsStructure(name)) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Exist.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- } else {
- Structure structure = structureManager.getStructure(name);
- structure.setDisplayname(event1.getName());
+ player.closeInventory();
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
-
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
- () -> {
- Config config1 = fileManager.getConfig(
- new File(plugin.getDataFolder(), "structures.yml"));
- FileConfiguration configLoad1 = config1.getFileConfiguration();
-
- configLoad1.set(
- "Structures." + structure.getName() + ".Displayname",
- event1.getName());
-
- try {
- configLoad1.save(config1.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
-
- player.closeInventory();
-
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- }
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
} else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ Structure structure = structureManager.getStructure(name);
+ structure.setDisplayname(gui.getInputText());
+
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
+
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
+ () -> {
+ Config config1 = fileManager.getConfig(
+ new File(plugin.getDataFolder(), "structures.yml"));
+ FileConfiguration configLoad1 = config1.getFileConfiguration();
+
+ configLoad1.set(
+ "Structures." + structure.getName() + ".Displayname",
+ gui.getInputText());
+
+ try {
+ configLoad1.save(config1.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+
+ player.closeInventory();
+
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
}
+ player.closeInventory();
});
is = new ItemStack(CompatibleMaterial.NAME_TAG.getMaterial());
@@ -475,8 +464,9 @@ public class Creator implements Listener {
configLoad.getString("Menu.Admin.Creator.Options.Item.Displayname.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
+
} else {
playerData.setViewer(null);
@@ -541,66 +531,61 @@ public class Creator implements Listener {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.creator")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Permission.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (playerData.getViewer() == null) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Selected.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
- player.closeInventory();
+ if (!(player.hasPermission("fabledskyblock.admin.creator")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Permission.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ } else if (playerData.getViewer() == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Selected.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- } else if (!structureManager.containsStructure(name)) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Exist.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ player.closeInventory();
- player.closeInventory();
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
+ } else if (!structureManager.containsStructure(name)) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Exist.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- } else {
- structure.addLine(event1.getName());
+ player.closeInventory();
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
-
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
- () -> {
- Config config13 = fileManager.getConfig(
- new File(plugin.getDataFolder(), "structures.yml"));
- FileConfiguration configLoad13 = config13.getFileConfiguration();
-
- configLoad13.set(
- "Structures." + structure.getName() + ".Description",
- structure.getDescription());
-
- try {
- configLoad13.save(config13.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
-
- player.closeInventory();
-
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- }
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
} else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ structure.addLine(gui.getInputText());
+
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
+
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
+ () -> {
+ Config config13 = fileManager.getConfig(
+ new File(plugin.getDataFolder(), "structures.yml"));
+ FileConfiguration configLoad13 = config13.getFileConfiguration();
+
+ configLoad13.set(
+ "Structures." + structure.getName() + ".Description",
+ structure.getDescription());
+
+ try {
+ configLoad13.save(config13.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+
+ player.closeInventory();
+
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
}
+ player.closeInventory();
});
is = new ItemStack(CompatibleMaterial.NAME_TAG.getMaterial());
@@ -609,8 +594,9 @@ public class Creator implements Listener {
configLoad.getString("Menu.Admin.Creator.Options.Item.Description.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
+
} else {
playerData.setViewer(null);
@@ -675,66 +661,61 @@ public class Creator implements Listener {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.creator")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Permission.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (playerData.getViewer() == null) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Selected.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
- player.closeInventory();
+ if (!(player.hasPermission("fabledskyblock.admin.creator")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Permission.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ } else if (playerData.getViewer() == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Selected.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- } else if (!structureManager.containsStructure(name)) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Exist.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ player.closeInventory();
- player.closeInventory();
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
+ } else if (!structureManager.containsStructure(name)) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Exist.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- } else {
- structure.addCommand(event1.getName());
+ player.closeInventory();
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
-
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
- () -> {
- Config config15 = fileManager.getConfig(
- new File(plugin.getDataFolder(), "structures.yml"));
- FileConfiguration configLoad15 = config15.getFileConfiguration();
-
- configLoad15.set(
- "Structures." + structure.getName() + ".Commands",
- structure.getCommands());
-
- try {
- configLoad15.save(config15.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
-
- player.closeInventory();
-
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- }
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
} else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ structure.addCommand(gui.getInputText());
+
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
+
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
+ () -> {
+ Config config15 = fileManager.getConfig(
+ new File(plugin.getDataFolder(), "structures.yml"));
+ FileConfiguration configLoad15 = config15.getFileConfiguration();
+
+ configLoad15.set(
+ "Structures." + structure.getName() + ".Commands",
+ structure.getCommands());
+
+ try {
+ configLoad15.save(config15.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+
+ player.closeInventory();
+
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
}
+ player.closeInventory();
});
is = new ItemStack(CompatibleMaterial.NAME_TAG.getMaterial());
@@ -743,8 +724,9 @@ public class Creator implements Listener {
configLoad.getString("Menu.Admin.Creator.Options.Item.Commands.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
+
} else {
playerData.setViewer(null);
@@ -759,10 +741,16 @@ public class Creator implements Listener {
}
return;
- } else if ((event.getCurrentItem().getType() == CompatibleMaterial.MAP.getMaterial())
+ } else if ((event.getCurrentItem().
+
+ getType() == CompatibleMaterial.MAP.getMaterial())
&& (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Admin.Creator.Options.Item.Permission.Displayname"))))) {
+ && (is.getItemMeta().
+
+ getDisplayName().
+
+ equals(ChatColor.translateAlternateColorCodes('&',
+ configLoad.getString("Menu.Admin.Creator.Options.Item.Permission.Displayname"))))) {
if (playerData.getViewer() == null) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Creator.Selected.Message"));
@@ -813,9 +801,15 @@ public class Creator implements Listener {
}
return;
- } else if ((event.getCurrentItem().getType() == CompatibleMaterial.PAPER.getMaterial()) && (is.hasItemMeta())
- && (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
- configLoad.getString("Menu.Admin.Creator.Options.Item.File.Displayname"))))) {
+ } else if ((event.getCurrentItem().
+
+ getType() == CompatibleMaterial.PAPER.getMaterial()) && (is.hasItemMeta())
+ && (is.getItemMeta().
+
+ getDisplayName().
+
+ equals(ChatColor.translateAlternateColorCodes('&',
+ configLoad.getString("Menu.Admin.Creator.Options.Item.File.Displayname"))))) {
if (event.getClick() == ClickType.LEFT || event.getClick() == ClickType.MIDDLE
|| event.getClick() == ClickType.RIGHT) {
if (playerData.getViewer() == null) {
@@ -832,127 +826,122 @@ public class Creator implements Listener {
if (structureManager.containsStructure(name)) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.creator")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Permission.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (playerData.getViewer() == null) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Selected.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
- player.closeInventory();
+ if (!(player.hasPermission("fabledskyblock.admin.creator")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Permission.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ } else if (playerData.getViewer() == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Selected.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- } else if (!structureManager.containsStructure(name)) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Exist.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ player.closeInventory();
- player.closeInventory();
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
+ } else if (!structureManager.containsStructure(name)) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Exist.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
- } else {
- String fileName = event1.getName();
- if (fileManager.isFileExist(new File(plugin.getDataFolder().toString() + "/structures", fileName)) ||
- fileManager.isFileExist(new File(plugin.getDataFolder().toString() + "/schematics", fileName))) {
- if (event.getClick() == ClickType.LEFT) {
- Structure structure = structureManager.getStructure(name);
- structure.setOverworldFile(fileName);
+ player.closeInventory();
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
- 1.0F, 1.0F);
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
+ } else {
+ String fileName = gui.getInputText();
+ if (fileManager.isFileExist(new File(plugin.getDataFolder().toString() + "/structures", fileName)) ||
+ fileManager.isFileExist(new File(plugin.getDataFolder().toString() + "/schematics", fileName))) {
+ if (event.getClick() == ClickType.LEFT) {
+ Structure structure = structureManager.getStructure(name);
+ structure.setOverworldFile(fileName);
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
- () -> {
- Config config17 = fileManager.getConfig(
- new File(plugin.getDataFolder(),
- "structures.yml"));
- FileConfiguration configLoad17 = config17
- .getFileConfiguration();
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
+ 1.0F, 1.0F);
- configLoad17.set("Structures." + structure.getName() + ".File.Overworld", fileName);
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
+ () -> {
+ Config config17 = fileManager.getConfig(
+ new File(plugin.getDataFolder(),
+ "structures.yml"));
+ FileConfiguration configLoad17 = config17
+ .getFileConfiguration();
- try {
- configLoad17.save(config17.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
- } else if (event.getClick() == ClickType.MIDDLE) {
- Structure structure = structureManager.getStructure(name);
- structure.setNetherFile(fileName);
+ configLoad17.set("Structures." + structure.getName() + ".File.Overworld", fileName);
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
- 1.0F, 1.0F);
+ try {
+ configLoad17.save(config17.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ } else if (event.getClick() == ClickType.MIDDLE) {
+ Structure structure = structureManager.getStructure(name);
+ structure.setNetherFile(fileName);
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
- () -> {
- Config config18 = fileManager.getConfig(
- new File(plugin.getDataFolder(),
- "structures.yml"));
- FileConfiguration configLoad18 = config18
- .getFileConfiguration();
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
+ 1.0F, 1.0F);
- configLoad18.set("Structures." + structure.getName()
- + ".File.Nether", fileName);
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
+ () -> {
+ Config config18 = fileManager.getConfig(
+ new File(plugin.getDataFolder(),
+ "structures.yml"));
+ FileConfiguration configLoad18 = config18
+ .getFileConfiguration();
- try {
- configLoad18.save(config18.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
- } else {
- Structure structure = structureManager.getStructure(name);
- structure.setEndFile(fileName);
+ configLoad18.set("Structures." + structure.getName()
+ + ".File.Nether", fileName);
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
- 1.0F, 1.0F);
-
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
- () -> {
- Config config19 = fileManager.getConfig(
- new File(plugin.getDataFolder(),
- "structures.yml"));
- FileConfiguration configLoad19 = config19
- .getFileConfiguration();
-
- configLoad19.set("Structures." + structure.getName()
- + ".File.End", fileName);
-
- try {
- configLoad19.save(config19.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
- }
+ try {
+ configLoad18.save(config18.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
} else {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.File.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
+ Structure structure = structureManager.getStructure(name);
+ structure.setEndFile(fileName);
+
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
+ 1.0F, 1.0F);
+
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
+ () -> {
+ Config config19 = fileManager.getConfig(
+ new File(plugin.getDataFolder(),
+ "structures.yml"));
+ FileConfiguration configLoad19 = config19
+ .getFileConfiguration();
+
+ configLoad19.set("Structures." + structure.getName()
+ + ".File.End", fileName);
+
+ try {
+ configLoad19.save(config19.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
}
-
- player.closeInventory();
-
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
+ } else {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.File.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
}
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ player.closeInventory();
+
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
}
+ player.closeInventory();
});
is = new ItemStack(CompatibleMaterial.NAME_TAG.getMaterial());
@@ -961,8 +950,9 @@ public class Creator implements Listener {
configLoad.getString("Menu.Admin.Creator.Options.Item.File.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
+
} else {
playerData.setViewer(null);
@@ -1036,78 +1026,75 @@ public class Creator implements Listener {
if (structureManager.containsStructure(name)) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.creator")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Permission.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
- return;
- } else if (playerData.getViewer() == null) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Selected.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+ if (!(player.hasPermission("fabledskyblock.admin.creator")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Permission.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- player.closeInventory();
+ return;
+ } else if (playerData.getViewer() == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Selected.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
-
- return;
- } else if (!structureManager.containsStructure(name)) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Exist.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
-
- player.closeInventory();
-
- Bukkit.getServer().getScheduler().runTaskLater(plugin,
- () -> open(player), 1L);
-
- return;
- } else if (!(event1.getName().matches("[0-9]+")
- || event1.getName().matches("([0-9]*)\\.([0-9]{1,2}$)"))) {
- messageManager.sendMessage(player,
- configLoad.getString("Island.Admin.Creator.Numerical.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
-
- event1.setWillClose(false);
- event1.setWillDestroy(false);
-
- return;
- }
-
- double deletionCost = Double.valueOf(event1.getName());
-
- Structure structure = structureManager.getStructure(name);
- structure.setDeletionCost(deletionCost);
-
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
-
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
- Config config112 = fileManager
- .getConfig(new File(plugin.getDataFolder(), "structures.yml"));
- FileConfiguration configLoad112 = config112.getFileConfiguration();
-
- configLoad112.set("Structures." + structure.getName() + ".Deletion.Cost",
- deletionCost);
-
- try {
- configLoad112.save(config112.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
+ player.closeInventory();
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> open(player), 1L);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+
+ return;
+ } else if (!structureManager.containsStructure(name)) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Exist.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+
+ player.closeInventory();
+
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
+
+ return;
+ } else if (!(gui.getInputText().matches("[0-9]+")
+ || gui.getInputText().matches("([0-9]*)\\.([0-9]{1,2}$)"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString("Island.Admin.Creator.Numerical.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
+
+ player.closeInventory();
+
+ return;
}
+
+ double deletionCost = Double.valueOf(gui.getInputText());
+
+ Structure structure = structureManager.getStructure(name);
+ structure.setDeletionCost(deletionCost);
+
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
+
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
+ Config config112 = fileManager
+ .getConfig(new File(plugin.getDataFolder(), "structures.yml"));
+ FileConfiguration configLoad112 = config112.getFileConfiguration();
+
+ configLoad112.set("Structures." + structure.getName() + ".Deletion.Cost",
+ deletionCost);
+
+ try {
+ configLoad112.save(config112.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+
+ Bukkit.getServer().getScheduler().runTaskLater(plugin,
+ () -> open(player), 1L);
+ player.closeInventory();
});
is = new ItemStack(CompatibleMaterial.NAME_TAG.getMaterial());
@@ -1116,8 +1103,9 @@ public class Creator implements Listener {
configLoad.getString("Menu.Admin.Creator.Options.Item.DeletionCost.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
+
} else {
playerData.setViewer(null);
@@ -1249,7 +1237,7 @@ public class Creator implements Listener {
FileConfiguration configLoad = config.getFileConfiguration();
String inventoryName = "";
- if (NMSUtil.getVersionNumber() > 13) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
inventoryName = event.getView().getTitle();
} else {
try {
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 70fc87c0..0856cec9 100644
--- a/src/main/java/com/songoda/skyblock/menus/admin/Generator.java
+++ b/src/main/java/com/songoda/skyblock/menus/admin/Generator.java
@@ -2,6 +2,8 @@ package com.songoda.skyblock.menus.admin;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.compatibility.ServerVersion;
+import com.songoda.core.gui.AnvilGui;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
@@ -14,9 +16,7 @@ import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.sound.SoundManager;
-import com.songoda.skyblock.utils.AbstractAnvilGUI;
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;
@@ -192,7 +192,7 @@ public class Generator implements Listener {
FileConfiguration configLoad = plugin.getLanguage();
String inventoryName = "";
- if (NMSUtil.getVersionNumber() > 13) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
inventoryName = event.getView().getTitle();
} else {
try {
@@ -259,28 +259,28 @@ public class Generator implements Listener {
configLoad.getString("Menu.Admin.Generator.Browse.Item.Information.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
if (!(player.hasPermission("fabledskyblock.admin.generator")
|| player.hasPermission("fabledskyblock.admin.*")
|| player.hasPermission("fabledskyblock.*"))) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Generator.Permission.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (generatorManager.containsGenerator(event1.getName())) {
+ } else if (generatorManager.containsGenerator(gui.getInputText())) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Generator.Already.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
- } else if (!event1.getName().replace(" ", "").matches("^[a-zA-Z0-9]+$")) {
+ } else if (!gui.getInputText().replace(" ", "").matches("^[a-zA-Z0-9]+$")) {
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Generator.Characters.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
- generatorManager.addGenerator(event1.getName(), IslandWorld.Normal, new ArrayList<>(), 0, false);
+ generatorManager.addGenerator(gui.getInputText(), IslandWorld.Normal, new ArrayList<>(), 0, false);
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Generator.Created.Message")
- .replace("%generator", event1.getName()));
+ .replace("%generator", gui.getInputText()));
soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
@@ -288,7 +288,7 @@ public class Generator implements Listener {
.getConfig(new File(plugin.getDataFolder(), "generators.yml"));
FileConfiguration configLoad14 = plugin.getGenerators();
- configLoad14.set("Generators." + event1.getName() + ".Name", event1.getName());
+ configLoad14.set("Generators." + gui.getInputText() + ".Name", gui.getInputText());
try {
configLoad14.save(config14.getFile());
@@ -301,13 +301,7 @@ public class Generator implements Listener {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> open(player), 1L);
}
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
- }
+ player.closeInventory();
});
is = new ItemStack(Material.NAME_TAG);
@@ -315,8 +309,8 @@ public class Generator implements Listener {
im.setDisplayName(configLoad.getString("Menu.Admin.Generator.Browse.Item.Information.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
return;
} else if ((event.getCurrentItem().getType() == CompatibleMaterial.MAP.getMaterial())
@@ -428,94 +422,88 @@ public class Generator implements Listener {
if (event.getClick() == ClickType.LEFT) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.generator")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
- messageManager.sendMessage(player, configLoad
- .getString("Island.Admin.Generator.Permission.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
- 1.0F, 1.0F);
- } else if (generatorManager.containsGenerator(event1.getName())) {
- messageManager.sendMessage(player, configLoad
- .getString("Island.Admin.Generator.Already.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
- 1.0F, 1.0F);
- } else if (!event1.getName().replace(" ", "")
- .matches("^[a-zA-Z0-9|.]+$")) {
- messageManager.sendMessage(player, configLoad
- .getString("Island.Admin.Generator.Characters.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
- 1.0F, 1.0F);
- } else if (!generator.getGeneratorMaterials()
- .contains(generatorMaterialList)) {
- messageManager.sendMessage(player, configLoad.getString(
- "Island.Admin.Generator.Material.Exist.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
- 1.0F, 1.0F);
- } else if (!event1.getName().matches("-?\\d+(?:\\.\\d+)?")) {
- messageManager.sendMessage(player, configLoad.getString(
- "Island.Admin.Generator.Chance.Numerical.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
- 1.0F, 1.0F);
- } else {
- double materialChance = Double.valueOf(event1.getName());
- double totalMaterialChance = materialChance;
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
+ if (!(player.hasPermission("fabledskyblock.admin.generator")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player, configLoad
+ .getString("Island.Admin.Generator.Permission.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
+ 1.0F, 1.0F);
+ } else if (generatorManager.containsGenerator(gui.getInputText())) {
+ messageManager.sendMessage(player, configLoad
+ .getString("Island.Admin.Generator.Already.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
+ 1.0F, 1.0F);
+ } else if (!gui.getInputText().replace(" ", "")
+ .matches("^[a-zA-Z0-9|.]+$")) {
+ messageManager.sendMessage(player, configLoad
+ .getString("Island.Admin.Generator.Characters.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
+ 1.0F, 1.0F);
+ } else if (!generator.getGeneratorMaterials()
+ .contains(generatorMaterialList)) {
+ messageManager.sendMessage(player, configLoad.getString(
+ "Island.Admin.Generator.Material.Exist.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
+ 1.0F, 1.0F);
+ } else if (!gui.getInputText().matches("-?\\d+(?:\\.\\d+)?")) {
+ messageManager.sendMessage(player, configLoad.getString(
+ "Island.Admin.Generator.Chance.Numerical.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
+ 1.0F, 1.0F);
+ } else {
+ double materialChance = Double.valueOf(gui.getInputText());
+ double totalMaterialChance = materialChance;
- for (GeneratorMaterial generatorMaterialList1 : generator
- .getGeneratorMaterials()) {
- if (generatorMaterialList1 != generatorMaterialList) {
- totalMaterialChance = totalMaterialChance
- + generatorMaterialList1.getChance();
- }
- }
-
- if (totalMaterialChance > 100) {
- messageManager.sendMessage(player, configLoad.getString(
- "Island.Admin.Generator.Chance.Over.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
- 1.0F, 1.0F);
- } else {
- generatorMaterialList
- .setChance(Double.valueOf(event1.getName()));
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
- 1.0F, 1.0F);
-
- Bukkit.getServer().getScheduler()
- .runTaskAsynchronously(plugin, () -> {
- Config config12 = fileManager.getConfig(
- new File(plugin.getDataFolder(),
- "generators.yml"));
- FileConfiguration configLoad12 = config12
- .getFileConfiguration();
-
- configLoad12.set("Generators."
- + generator.getName() + ".Materials."
- + generatorMaterialList.getMaterials()
- .name()
- + ".Chance", materialChance);
-
- try {
- configLoad12.save(config12.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
-
- player.closeInventory();
-
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin, () -> open(player), 1L);
+ for (GeneratorMaterial generatorMaterialList1 : generator
+ .getGeneratorMaterials()) {
+ if (generatorMaterialList1 != generatorMaterialList) {
+ totalMaterialChance = totalMaterialChance
+ + generatorMaterialList1.getChance();
}
}
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ if (totalMaterialChance > 100) {
+ messageManager.sendMessage(player, configLoad.getString(
+ "Island.Admin.Generator.Chance.Over.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
+ 1.0F, 1.0F);
+ } else {
+ generatorMaterialList
+ .setChance(Double.valueOf(gui.getInputText()));
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
+ 1.0F, 1.0F);
+
+ Bukkit.getServer().getScheduler()
+ .runTaskAsynchronously(plugin, () -> {
+ Config config12 = fileManager.getConfig(
+ new File(plugin.getDataFolder(),
+ "generators.yml"));
+ FileConfiguration configLoad12 = config12
+ .getFileConfiguration();
+
+ configLoad12.set("Generators."
+ + generator.getName() + ".Materials."
+ + generatorMaterialList.getMaterials()
+ .name()
+ + ".Chance", materialChance);
+
+ try {
+ configLoad12.save(config12.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+
+ player.closeInventory();
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin, () -> open(player), 1L);
+ }
}
+ player.closeInventory();
});
is = new ItemStack(Material.NAME_TAG);
@@ -524,8 +512,8 @@ public class Generator implements Listener {
.getString("Menu.Admin.Generator.Generator.Item.Material.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
} else if (event.getClick() == ClickType.RIGHT) {
generator.getGeneratorMaterials().remove(generatorMaterialList);
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 85bbe907..b05a4bc5 100644
--- a/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java
+++ b/src/main/java/com/songoda/skyblock/menus/admin/Levelling.java
@@ -2,6 +2,8 @@ package com.songoda.skyblock.menus.admin;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.compatibility.ServerVersion;
+import com.songoda.core.gui.AnvilGui;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
@@ -13,10 +15,8 @@ import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.sound.SoundManager;
-import com.songoda.skyblock.utils.AbstractAnvilGUI;
import com.songoda.core.utils.NumberUtils;
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;
@@ -164,7 +164,7 @@ public class Levelling implements Listener {
FileConfiguration configLoad = plugin.getLanguage();
String inventoryName = "";
- if (NMSUtil.getVersionNumber() > 13) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
inventoryName = event.getView().getTitle();
} else {
try {
@@ -206,8 +206,9 @@ public class Levelling implements Listener {
configLoad.getString("Menu.Admin.Levelling.Item.Information.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
+
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
if (!(player.hasPermission("fabledskyblock.admin.level")
|| player.hasPermission("fabledskyblock.admin.*")
|| player.hasPermission("fabledskyblock.*"))) {
@@ -216,7 +217,7 @@ public class Levelling implements Listener {
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else {
try {
- double pointDivision = Double.parseDouble(event1.getName());
+ double pointDivision = Double.parseDouble(gui.getInputText());
messageManager.sendMessage(player,
configLoad.getString("Island.Admin.Levelling.Division.Message")
@@ -246,13 +247,7 @@ public class Levelling implements Listener {
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
}
}
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
- }
+ player.closeInventory();
});
is = new ItemStack(Material.NAME_TAG);
@@ -260,8 +255,8 @@ public class Levelling implements Listener {
im.setDisplayName(configLoad.getString("Menu.Admin.Levelling.Item.Information.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setInput(is);
+ plugin.getGuiManager().showGUI(player, gui);
return;
} else if ((event.getCurrentItem().getType() == Material.BARRIER) && (is.hasItemMeta())
@@ -306,8 +301,8 @@ public class Levelling implements Listener {
if (event.getClick() == ClickType.LEFT) {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(ev -> {
if (!(player.hasPermission("fabledskyblock.admin.level")
|| player.hasPermission("fabledskyblock.admin.*")
|| player.hasPermission("fabledskyblock.*"))) {
@@ -316,7 +311,7 @@ public class Levelling implements Listener {
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
} else if (levellingManager.hasWorth(materials)) {
try {
- double materialPoints = Double.parseDouble(event1.getName());
+ double materialPoints = Double.parseDouble(gui.getInputText());
materialList.setPoints(materialPoints);
messageManager.sendMessage(player, configLoad
@@ -360,13 +355,6 @@ public class Levelling implements Listener {
configLoad.getString("Island.Admin.Levelling.Exist.Message"));
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
}
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
- }
});
is = new ItemStack(Material.NAME_TAG);
@@ -375,8 +363,8 @@ public class Levelling implements Listener {
configLoad.getString("Menu.Admin.Levelling.Item.Material.Word.Enter"));
is.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is);
- gui.open();
+ gui.setOutput(is);
+ plugin.getGuiManager().showGUI(player, gui);
} else if (event.getClick() == ClickType.RIGHT) {
levellingManager.removeWorth(materialList.getMaterials());
open(player);
@@ -408,7 +396,7 @@ public class Levelling implements Listener {
CompatibleMaterial materials = CompatibleMaterial.getMaterial(event.getCurrentItem().getType());
- if (NMSUtil.getVersionNumber() < 13) {
+ if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
materials.getItem().setData(event.getCurrentItem().getData());
}
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 5ab30b3f..ae1f8b9d 100644
--- a/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java
+++ b/src/main/java/com/songoda/skyblock/menus/admin/Upgrade.java
@@ -2,6 +2,9 @@ package com.songoda.skyblock.menus.admin;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.compatibility.ServerVersion;
+import com.songoda.core.gui.AnvilGui;
+import com.songoda.core.utils.NumberUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
@@ -11,10 +14,7 @@ import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.upgrade.UpgradeManager;
-import com.songoda.skyblock.utils.AbstractAnvilGUI;
-import com.songoda.core.utils.NumberUtils;
import com.songoda.skyblock.utils.item.nInventoryUtil;
-import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
@@ -84,7 +84,7 @@ public class Upgrade {
.get(0);
viewer.setUpgrade(com.songoda.skyblock.upgrade.Upgrade.Type.Speed);
} else if (is.getItemMeta().getDisplayName().equals(plugin.formatText(
- configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Jump.Displayname")))) {
+ 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);
@@ -169,69 +169,63 @@ public class Upgrade {
soundManager.playSound(player, CompatibleSound.BLOCK_WOODEN_BUTTON_CLICK_ON.getSound(), 1.0F, 1.0F);
Bukkit.getServer().getScheduler().runTaskLater(plugin, () -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.upgrade")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
- messageManager.sendMessage(player, configLoad
- .getString("Island.Admin.Upgrade.Permission.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
- 1.0F, 1.0F);
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
- return;
- } else if (!(event1.getName().matches("[0-9]+")
- || event1.getName().matches("([0-9]*)\\.([0-9]{1,2}$)"))) {
- messageManager.sendMessage(player, configLoad
- .getString("Island.Admin.Upgrade.Numerical.Message"));
- soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
- 1.0F, 1.0F);
+ if (!(player.hasPermission("fabledskyblock.admin.upgrade")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player, configLoad
+ .getString("Island.Admin.Upgrade.Permission.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
+ 1.0F, 1.0F);
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ return;
+ } else if (!(gui.getInputText().matches("[0-9]+")
+ || gui.getInputText().matches("([0-9]*)\\.([0-9]{1,2}$)"))) {
+ messageManager.sendMessage(player, configLoad
+ .getString("Island.Admin.Upgrade.Numerical.Message"));
+ soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(),
+ 1.0F, 1.0F);
- return;
- }
+ player.closeInventory();
- if (playerDataManager.hasPlayerData(player)) {
- double upgradeCost = Double.valueOf(event1.getName());
- com.songoda.skyblock.upgrade.Upgrade.Type upgradeType = ((Viewer) playerDataManager
- .getPlayerData(player).getViewer()).getUpgrade();
-
- com.songoda.skyblock.upgrade.Upgrade upgrade1 = upgradeManager
- .getUpgrades(upgradeType).get(0);
- upgrade1.setCost(upgradeCost);
- soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
- 1.0F, 1.0F);
-
- Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
- () -> {
- Config config = fileManager.getConfig(new File(
- plugin.getDataFolder(), "upgrades.yml"));
- FileConfiguration configLoad1 = config
- .getFileConfiguration();
-
- configLoad1.set(
- "Upgrades." + upgradeType.name() + ".Cost",
- upgradeCost);
-
- try {
- configLoad1.save(config.getFile());
- } catch (IOException e) {
- e.printStackTrace();
- }
- });
-
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin, () -> open(player), 1L);
- }
-
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ return;
}
+
+ if (playerDataManager.hasPlayerData(player)) {
+ double upgradeCost = Double.valueOf(gui.getInputText());
+ com.songoda.skyblock.upgrade.Upgrade.Type upgradeType = ((Viewer) playerDataManager
+ .getPlayerData(player).getViewer()).getUpgrade();
+
+ com.songoda.skyblock.upgrade.Upgrade upgrade1 = upgradeManager
+ .getUpgrades(upgradeType).get(0);
+ upgrade1.setCost(upgradeCost);
+ soundManager.playSound(player, CompatibleSound.BLOCK_NOTE_BLOCK_PLING.getSound(),
+ 1.0F, 1.0F);
+
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin,
+ () -> {
+ Config config = fileManager.getConfig(new File(
+ plugin.getDataFolder(), "upgrades.yml"));
+ FileConfiguration configLoad1 = config
+ .getFileConfiguration();
+
+ configLoad1.set(
+ "Upgrades." + upgradeType.name() + ".Cost",
+ upgradeCost);
+
+ try {
+ configLoad1.save(config.getFile());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin, () -> open(player), 1L);
+ }
+ player.closeInventory();
});
ItemStack is1 = new ItemStack(Material.NAME_TAG);
@@ -240,8 +234,9 @@ public class Upgrade {
configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Word.Enter"));
is1.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is1);
- gui.open();
+ gui.setInput(is1);
+ plugin.getGuiManager().showGUI(player, gui);
+
}, 1L);
} else {
event.setWillClose(false);
@@ -254,9 +249,7 @@ public class Upgrade {
ItemStack jumpPotion = new ItemStack(Material.POTION);
com.songoda.skyblock.upgrade.Upgrade upgrade;
- int NMSVersion = NMSUtil.getVersionNumber();
-
- if (NMSVersion > 12) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
PotionMeta pm = (PotionMeta) speedPotion.getItemMeta();
pm.setBasePotionData(new PotionData(PotionType.SPEED));
speedPotion.setItemMeta(pm);
@@ -274,7 +267,7 @@ public class Upgrade {
new Placeholder("%status", getStatus(upgrade))},
null, new ItemFlag[]{ItemFlag.HIDE_POTION_EFFECTS}), 0);
- if (NMSVersion > 12) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
PotionMeta pm = (PotionMeta) jumpPotion.getItemMeta();
pm.setBasePotionData(new PotionData(PotionType.JUMP));
jumpPotion.setItemMeta(pm);
@@ -347,7 +340,7 @@ public class Upgrade {
}
nInv.addItem(nInv.createItem(CompatibleMaterial.BOOKSHELF.getItem(), plugin.formatText(
- configLoad.getString("Menu.Admin.Upgrade.Upgrades.Item.Members.Displayname")),
+ 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);
@@ -409,91 +402,84 @@ public class Upgrade {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (playerDataManager.hasPlayerData(player)
- && playerDataManager
- .getPlayerData(player) != null) {
- if (!event1.getName().matches("[0-9]+")) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Numerical.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event1.setWillClose(false);
- event1.setWillDestroy(false);
-
- return;
- } else {
- List upgrades1 = upgradeManager
- .getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Size);
-
- if (upgrades1 != null && upgrades1.size() >= 5) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Limit.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin,
- () -> open(player), 1L);
-
- return;
- }
- }
-
- int size = Integer.valueOf(event1.getName());
-
- if (size > 1000) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Size.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event.setWillClose(false);
- event.setWillDestroy(false);
-
- return;
- } else if (upgradeManager.hasUpgrade(
- com.songoda.skyblock.upgrade.Upgrade.Type.Size,
- size)) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Exist.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event1.setWillClose(false);
- event1.setWillDestroy(false);
-
- return;
- }
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
+ if (playerDataManager.hasPlayerData(player)
+ && playerDataManager
+ .getPlayerData(player) != null) {
+ if (!gui.getInputText().matches("[0-9]+")) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Numerical.Message"));
soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
- upgradeManager.addUpgrade(
- com.songoda.skyblock.upgrade.Upgrade.Type.Size,
- size);
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin,
- () -> open(player), 1L);
+ player.closeInventory();
+
+ return;
+ } else {
+ List upgrades1 = upgradeManager
+ .getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Size);
+
+ if (upgrades1 != null && upgrades1.size() >= 5) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Limit.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin,
+ () -> open(player), 1L);
+
+ return;
+ }
}
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ int size = Integer.valueOf(gui.getInputText());
+
+ if (size > 1000) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Size.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ event.setWillClose(false);
+ event.setWillDestroy(false);
+
+ return;
+ } else if (upgradeManager.hasUpgrade(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Size,
+ size)) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Exist.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ player.closeInventory();
+
+ return;
+ }
+
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
+ upgradeManager.addUpgrade(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Size,
+ size);
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin,
+ () -> open(player), 1L);
}
+ player.closeInventory();
});
ItemStack is12 = new ItemStack(Material.NAME_TAG);
@@ -502,8 +488,9 @@ public class Upgrade {
.getString("Menu.Admin.Upgrade.Size.Item.Word.Size.Enter"));
is12.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is12);
- gui.open();
+ gui.setInput(is12);
+ plugin.getGuiManager().showGUI(player, gui);
+
}, 1L);
}
} else if ((is.getType() == CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getMaterial())
@@ -528,107 +515,102 @@ public class Upgrade {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.upgrade")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
+
+ if (!(player.hasPermission("fabledskyblock.admin.upgrade")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Permission.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ return;
+ }
+
+ if (playerDataManager.hasPlayerData(player)
+ && playerDataManager
+ .getPlayerData(player) != null) {
+ if (!gui.getInputText().matches("[0-9]+")) {
messageManager.sendMessage(player,
configLoad.getString(
- "Island.Admin.Upgrade.Permission.Message"));
+ "Island.Admin.Upgrade.Numerical.Message"));
soundManager.playSound(player,
CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
1.0F);
+ player.closeInventory();
+
return;
- }
-
- if (playerDataManager.hasPlayerData(player)
- && playerDataManager
- .getPlayerData(player) != null) {
- if (!event1.getName().matches("[0-9]+")) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Numerical.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event1.setWillClose(false);
- event1.setWillDestroy(false);
-
- return;
- } else if (upgradeManager.getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Size)
- .get(tier) == null) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Selected.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin,
- () -> open(player), 1L);
-
- return;
- }
-
- int size = Integer.valueOf(event1.getName());
-
- if (size > 1000) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Size.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event.setWillClose(false);
- event.setWillDestroy(false);
-
- return;
- } else if (upgradeManager.hasUpgrade(
- com.songoda.skyblock.upgrade.Upgrade.Type.Size,
- size)) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Exist.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event.setWillClose(false);
- event.setWillDestroy(false);
-
- return;
- }
-
+ } else if (upgradeManager.getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Size)
+ .get(tier) == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Selected.Message"));
soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
- upgradeManager.getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Size)
- .get(tier).setValue(size);
- fileManager
- .getConfig(
- new File(plugin.getDataFolder(),
- "upgrades.yml"))
- .getFileConfiguration()
- .set("Upgrades.Size." + tier + ".Value",
- size);
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
Bukkit.getServer().getScheduler()
.runTaskLater(plugin,
() -> open(player), 1L);
+
+ return;
}
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ int size = Integer.valueOf(gui.getInputText());
+
+ if (size > 1000) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Size.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ event.setWillClose(false);
+ event.setWillDestroy(false);
+
+ return;
+ } else if (upgradeManager.hasUpgrade(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Size,
+ size)) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Exist.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ event.setWillClose(false);
+ event.setWillDestroy(false);
+
+ return;
+ }
+
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
+ upgradeManager.getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Size)
+ .get(tier).setValue(size);
+ fileManager
+ .getConfig(
+ new File(plugin.getDataFolder(),
+ "upgrades.yml"))
+ .getFileConfiguration()
+ .set("Upgrades.Size." + tier + ".Value",
+ size);
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin,
+ () -> open(player), 1L);
}
+
+ player.closeInventory();
});
ItemStack is13 = new ItemStack(Material.NAME_TAG);
@@ -637,8 +619,9 @@ public class Upgrade {
"Menu.Admin.Upgrade.Size.Item.Word.Size.Enter"));
is13.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is13);
- gui.open();
+ gui.setInput(is13);
+ plugin.getGuiManager().showGUI(player, gui);
+
}, 1L);
return;
@@ -651,81 +634,76 @@ public class Upgrade {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.upgrade")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
+
+ if (!(player.hasPermission("fabledskyblock.admin.upgrade")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Permission.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ return;
+ }
+
+ if (playerDataManager.hasPlayerData(player)
+ && playerDataManager
+ .getPlayerData(player) != null) {
+ if (!(gui.getInputText().matches("[0-9]+")
+ || gui.getInputText().matches(
+ "([0-9]*)\\.([0-9]{2}$)"))) {
messageManager.sendMessage(player,
configLoad.getString(
- "Island.Admin.Upgrade.Permission.Message"));
+ "Island.Admin.Upgrade.Numerical.Message"));
soundManager.playSound(player,
CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
1.0F);
+ player.closeInventory();
+
return;
- }
-
- if (playerDataManager.hasPlayerData(player)
- && playerDataManager
- .getPlayerData(player) != null) {
- if (!(event1.getName().matches("[0-9]+")
- || event1.getName().matches(
- "([0-9]*)\\.([0-9]{2}$)"))) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Numerical.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event1.setWillClose(false);
- event1.setWillDestroy(false);
-
- return;
- } else if (upgradeManager.getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Size)
- .get(tier) == null) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Selected.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin,
- () -> open(player), 1L);
-
- return;
- }
-
- double cost = Double.valueOf(event1.getName());
-
+ } else if (upgradeManager.getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Size)
+ .get(tier) == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Selected.Message"));
soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
- upgradeManager.getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Size)
- .get(tier).setCost(cost);
- fileManager
- .getConfig(
- new File(plugin.getDataFolder(),
- "upgrades.yml"))
- .getFileConfiguration()
- .set("Upgrades.Size." + tier + ".Cost",
- cost);
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
Bukkit.getServer().getScheduler()
.runTaskLater(plugin,
() -> open(player), 1L);
+
+ return;
}
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ double cost = Double.valueOf(gui.getInputText());
+
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
+ upgradeManager.getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Size)
+ .get(tier).setCost(cost);
+ fileManager
+ .getConfig(
+ new File(plugin.getDataFolder(),
+ "upgrades.yml"))
+ .getFileConfiguration()
+ .set("Upgrades.Size." + tier + ".Cost",
+ cost);
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin,
+ () -> open(player), 1L);
}
+
+ player.closeInventory();
});
ItemStack is14 = new ItemStack(Material.NAME_TAG);
@@ -734,8 +712,9 @@ public class Upgrade {
"Menu.Admin.Upgrade.Size.Item.Word.Cost.Enter"));
is14.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is14);
- gui.open();
+ gui.setInput(is14);
+ plugin.getGuiManager().showGUI(player, gui);
+
}, 1L);
return;
@@ -756,7 +735,9 @@ public class Upgrade {
plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Size.Item.Return.Displayname")),
null, null, null, null), 0);
- nInv.addItem(nInv.createItem(new ItemStack(Material.PAINTING),
+ nInv.addItem(nInv.createItem(new
+
+ ItemStack(Material.PAINTING),
plugin.formatText(
configLoad.getString("Menu.Admin.Upgrade.Size.Item.Information.Displayname")),
configLoad.getStringList("Menu.Admin.Upgrade.Size.Item.Information.Lore"), null, null, null),
@@ -794,7 +775,11 @@ public class Upgrade {
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.*")
@@ -836,91 +821,86 @@ public class Upgrade {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (playerDataManager.hasPlayerData(player)
- && playerDataManager
- .getPlayerData(player) != null) {
- if (!event1.getName().matches("[0-9]+")) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Numerical.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event1.setWillClose(false);
- event1.setWillDestroy(false);
-
- return;
- } else {
- List upgrades1 = upgradeManager
- .getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Members);
-
- if (upgrades1 != null && upgrades1.size() >= 5) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Limit.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin,
- () -> open(player), 1L);
-
- return;
- }
- }
-
- int size = Integer.valueOf(event1.getName());
-
- if (size > 1000) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Members.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event.setWillClose(false);
- event.setWillDestroy(false);
-
- return;
- } else if (upgradeManager.hasUpgrade(
- com.songoda.skyblock.upgrade.Upgrade.Type.Members,
- size)) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Exist.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event1.setWillClose(false);
- event1.setWillDestroy(false);
-
- return;
- }
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
+ if (playerDataManager.hasPlayerData(player)
+ && playerDataManager
+ .getPlayerData(player) != null) {
+ if (!gui.getInputText().matches("[0-9]+")) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Numerical.Message"));
soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
- upgradeManager.addUpgrade(
- com.songoda.skyblock.upgrade.Upgrade.Type.Members,
- size);
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin,
- () -> open(player), 1L);
+ player.closeInventory();
+
+ return;
+ } else {
+ List upgrades1 = upgradeManager
+ .getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Members);
+
+ if (upgrades1 != null && upgrades1.size() >= 5) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Limit.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin,
+ () -> open(player), 1L);
+
+ return;
+ }
}
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ int size = Integer.valueOf(gui.getInputText());
+
+ if (size > 1000) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Members.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ event.setWillClose(false);
+ event.setWillDestroy(false);
+
+ return;
+ } else if (upgradeManager.hasUpgrade(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Members,
+ size)) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Exist.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ player.closeInventory();
+
+ return;
+ }
+
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
+ upgradeManager.addUpgrade(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Members,
+ size);
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin,
+ () -> open(player), 1L);
}
+
+ player.closeInventory();
+
});
ItemStack is12 = new ItemStack(Material.NAME_TAG);
@@ -929,8 +909,9 @@ public class Upgrade {
.getString("Menu.Admin.Upgrade.Members.Item.Word.Members.Enter"));
is12.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is12);
- gui.open();
+ gui.setInput(is12);
+ plugin.getGuiManager().showGUI(player, gui);
+
}, 1L);
}
} else if ((is.getType() == CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getMaterial())
@@ -955,107 +936,102 @@ public class Upgrade {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.upgrade")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
+
+ if (!(player.hasPermission("fabledskyblock.admin.upgrade")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Permission.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ return;
+ }
+
+ if (playerDataManager.hasPlayerData(player)
+ && playerDataManager
+ .getPlayerData(player) != null) {
+ if (!gui.getInputText().matches("[0-9]+")) {
messageManager.sendMessage(player,
configLoad.getString(
- "Island.Admin.Upgrade.Permission.Message"));
+ "Island.Admin.Upgrade.Numerical.Message"));
soundManager.playSound(player,
CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
1.0F);
+ player.closeInventory();
+
return;
- }
-
- if (playerDataManager.hasPlayerData(player)
- && playerDataManager
- .getPlayerData(player) != null) {
- if (!event1.getName().matches("[0-9]+")) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Numerical.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event1.setWillClose(false);
- event1.setWillDestroy(false);
-
- return;
- } else if (upgradeManager.getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Members)
- .get(tier) == null) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Selected.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin,
- () -> open(player), 1L);
-
- return;
- }
-
- int size = Integer.valueOf(event1.getName());
-
- if (size > 1000) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Members.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event.setWillClose(false);
- event.setWillDestroy(false);
-
- return;
- } else if (upgradeManager.hasUpgrade(
- com.songoda.skyblock.upgrade.Upgrade.Type.Members,
- size)) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Exist.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event.setWillClose(false);
- event.setWillDestroy(false);
-
- return;
- }
-
+ } else if (upgradeManager.getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Members)
+ .get(tier) == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Selected.Message"));
soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
- upgradeManager.getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Members)
- .get(tier).setValue(size);
- fileManager
- .getConfig(
- new File(plugin.getDataFolder(),
- "upgrades.yml"))
- .getFileConfiguration()
- .set("Upgrades.Members." + tier + ".Value",
- size);
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
Bukkit.getServer().getScheduler()
.runTaskLater(plugin,
() -> open(player), 1L);
+
+ return;
}
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ int size = Integer.valueOf(gui.getInputText());
+
+ if (size > 1000) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Members.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ event.setWillClose(false);
+ event.setWillDestroy(false);
+
+ return;
+ } else if (upgradeManager.hasUpgrade(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Members,
+ size)) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Exist.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ event.setWillClose(false);
+ event.setWillDestroy(false);
+
+ return;
+ }
+
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
+ upgradeManager.getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Members)
+ .get(tier).setValue(size);
+ fileManager
+ .getConfig(
+ new File(plugin.getDataFolder(),
+ "upgrades.yml"))
+ .getFileConfiguration()
+ .set("Upgrades.Members." + tier + ".Value",
+ size);
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin,
+ () -> open(player), 1L);
}
+
+ player.closeInventory();
});
ItemStack is13 = new ItemStack(Material.NAME_TAG);
@@ -1064,8 +1040,9 @@ public class Upgrade {
"Menu.Admin.Upgrade.Members.Item.Word.Members.Enter"));
is13.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is13);
- gui.open();
+ gui.setInput(is13);
+ plugin.getGuiManager().showGUI(player, gui);
+
}, 1L);
return;
@@ -1078,81 +1055,76 @@ public class Upgrade {
Bukkit.getServer().getScheduler().runTaskLater(plugin,
() -> {
- AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event1 -> {
- if (event1.getSlot() == AbstractAnvilGUI.AnvilSlot.OUTPUT) {
- if (!(player.hasPermission("fabledskyblock.admin.upgrade")
- || player.hasPermission("fabledskyblock.admin.*")
- || player.hasPermission("fabledskyblock.*"))) {
+ AnvilGui gui = new AnvilGui(player);
+ gui.setAction(event1 -> {
+
+ if (!(player.hasPermission("fabledskyblock.admin.upgrade")
+ || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*"))) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Permission.Message"));
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
+
+ return;
+ }
+
+ if (playerDataManager.hasPlayerData(player)
+ && playerDataManager
+ .getPlayerData(player) != null) {
+ if (!(gui.getInputText().matches("[0-9]+")
+ || gui.getInputText().matches(
+ "([0-9]*)\\.([0-9]{2}$)"))) {
messageManager.sendMessage(player,
configLoad.getString(
- "Island.Admin.Upgrade.Permission.Message"));
+ "Island.Admin.Upgrade.Numerical.Message"));
soundManager.playSound(player,
CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
1.0F);
+ player.closeInventory();
+
return;
- }
-
- if (playerDataManager.hasPlayerData(player)
- && playerDataManager
- .getPlayerData(player) != null) {
- if (!(event1.getName().matches("[0-9]+")
- || event1.getName().matches(
- "([0-9]*)\\.([0-9]{2}$)"))) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Numerical.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- event1.setWillClose(false);
- event1.setWillDestroy(false);
-
- return;
- } else if (upgradeManager.getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Members)
- .get(tier) == null) {
- messageManager.sendMessage(player,
- configLoad.getString(
- "Island.Admin.Upgrade.Tier.Selected.Message"));
- soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
- 1.0F);
-
- Bukkit.getServer().getScheduler()
- .runTaskLater(plugin,
- () -> open(player), 1L);
-
- return;
- }
-
- double cost = Double.valueOf(event1.getName());
-
+ } else if (upgradeManager.getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Members)
+ .get(tier) == null) {
+ messageManager.sendMessage(player,
+ configLoad.getString(
+ "Island.Admin.Upgrade.Tier.Selected.Message"));
soundManager.playSound(player,
- CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
- upgradeManager.getUpgrades(
- com.songoda.skyblock.upgrade.Upgrade.Type.Members)
- .get(tier).setCost(cost);
- fileManager
- .getConfig(
- new File(plugin.getDataFolder(),
- "upgrades.yml"))
- .getFileConfiguration()
- .set("Upgrades.Members." + tier + ".Cost",
- cost);
+ CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F,
+ 1.0F);
Bukkit.getServer().getScheduler()
.runTaskLater(plugin,
() -> open(player), 1L);
+
+ return;
}
- event1.setWillClose(true);
- event1.setWillDestroy(true);
- } else {
- event1.setWillClose(false);
- event1.setWillDestroy(false);
+ double cost = Double.valueOf(gui.getInputText());
+
+ soundManager.playSound(player,
+ CompatibleSound.BLOCK_ANVIL_USE.getSound(), 1.0F, 1.0F);
+ upgradeManager.getUpgrades(
+ com.songoda.skyblock.upgrade.Upgrade.Type.Members)
+ .get(tier).setCost(cost);
+ fileManager
+ .getConfig(
+ new File(plugin.getDataFolder(),
+ "upgrades.yml"))
+ .getFileConfiguration()
+ .set("Upgrades.Members." + tier + ".Cost",
+ cost);
+
+ Bukkit.getServer().getScheduler()
+ .runTaskLater(plugin,
+ () -> open(player), 1L);
}
+
+ player.closeInventory();
});
ItemStack is14 = new ItemStack(Material.NAME_TAG);
@@ -1161,8 +1133,9 @@ public class Upgrade {
"Menu.Admin.Upgrade.Members.Item.Word.Cost.Enter"));
is14.setItemMeta(im);
- gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, is14);
- gui.open();
+ gui.setInput(is14);
+ plugin.getGuiManager().showGUI(player, gui);
+
}, 1L);
return;
diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/AnimalBreedingPermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/AnimalBreedingPermission.java
index ca613e64..49e55d47 100644
--- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/AnimalBreedingPermission.java
+++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/AnimalBreedingPermission.java
@@ -1,12 +1,12 @@
package com.songoda.skyblock.permission.permissions.listening;
import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType;
-import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -50,7 +50,7 @@ public class AnimalBreedingPermission extends ListeningPermission {
} else if (entity.getType() == EntityType.CHICKEN) {
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.WHEAT_SEEDS
|| CompatibleMaterial.getMaterial(is) == CompatibleMaterial.PUMPKIN_SEEDS || CompatibleMaterial.getMaterial(is) == CompatibleMaterial.MELON_SEEDS)) {
- if (NMSUtil.getVersionNumber() > 8) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.BEETROOT_SEEDS)) {
return;
}
@@ -87,14 +87,12 @@ public class AnimalBreedingPermission extends ListeningPermission {
return;
}
} else {
- int NMSVersion = NMSUtil.getVersionNumber();
-
- if (NMSVersion > 10) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_10)) {
if (entity.getType() == EntityType.LLAMA) {
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.HAY_BLOCK)) {
return;
}
- } else if (NMSVersion > 12) {
+ } else if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
if (entity.getType() == EntityType.TURTLE) {
if (!(CompatibleMaterial.getMaterial(is) == CompatibleMaterial.SEAGRASS)) {
return;
diff --git a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java
index 6f0356e1..87bacd5c 100644
--- a/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java
+++ b/src/main/java/com/songoda/skyblock/permission/permissions/listening/DamagePermission.java
@@ -1,12 +1,12 @@
package com.songoda.skyblock.permission.permissions.listening;
import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.permission.ListeningPermission;
import com.songoda.skyblock.permission.PermissionHandler;
import com.songoda.skyblock.permission.PermissionType;
-import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
@@ -38,7 +38,7 @@ public class DamagePermission extends ListeningPermission {
return;
}
} else {
- if (NMSUtil.getVersionNumber() > 11) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) {
if (event.getCause() == EntityDamageEvent.DamageCause.valueOf("ENTITY_SWEEP_ATTACK")) {
EntityDamageByEntityEvent entityDamageByEntityEvent = (EntityDamageByEntityEvent) event;
diff --git a/src/main/java/com/songoda/skyblock/stackable/Stackable.java b/src/main/java/com/songoda/skyblock/stackable/Stackable.java
index 741ab608..da36191a 100644
--- a/src/main/java/com/songoda/skyblock/stackable/Stackable.java
+++ b/src/main/java/com/songoda/skyblock/stackable/Stackable.java
@@ -2,10 +2,10 @@ package com.songoda.skyblock.stackable;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.core.utils.NumberUtils;
-import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
@@ -146,9 +146,8 @@ public class Stackable {
as.setVisible(false);
as.setGravity(false);
as.setSmall(true);
- if (NMSUtil.getVersionNumber() > 8) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9))
as.setMarker(true);
- }
as.setBasePlate(true);
as.setHelmet(material.getItem());
as.setCustomName(this.getCustomName());
diff --git a/src/main/java/com/songoda/skyblock/utils/AbstractAnvilGUI.java b/src/main/java/com/songoda/skyblock/utils/AbstractAnvilGUI.java
deleted file mode 100644
index 29d84af0..00000000
--- a/src/main/java/com/songoda/skyblock/utils/AbstractAnvilGUI.java
+++ /dev/null
@@ -1,278 +0,0 @@
-package com.songoda.skyblock.utils;
-
-import com.songoda.skyblock.SkyBlock;
-import com.songoda.skyblock.utils.version.NMSUtil;
-import org.bukkit.Bukkit;
-import org.bukkit.Material;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.HandlerList;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.InventoryClickEvent;
-import org.bukkit.event.inventory.InventoryCloseEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-public class AbstractAnvilGUI {
- 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 final Class> WorldClass;
- private static final Class> PlayerInventoryClass;
- private static Class> ContainersClass;
- private static final Class> CraftPlayerClass;
-
- static {
- BlockPositionClass = NMSUtil.getNMSClass("BlockPosition");
- PacketPlayOutOpenWindowClass = NMSUtil.getNMSClass("PacketPlayOutOpenWindow");
- IChatBaseComponentClass = NMSUtil.getNMSClass("IChatBaseComponent");
- ICraftingClass = NMSUtil.getNMSClass("ICrafting");
- ContainerAnvilClass = NMSUtil.getNMSClass("ContainerAnvil");
- EntityHumanClass = NMSUtil.getNMSClass("EntityHuman");
- ChatMessageClass = NMSUtil.getNMSClass("ChatMessage");
- ContainerClass = NMSUtil.getNMSClass("Container");
- WorldClass = NMSUtil.getNMSClass("World");
- PlayerInventoryClass = NMSUtil.getNMSClass("PlayerInventory");
- CraftPlayerClass = NMSUtil.getCraftClass("entity.CraftPlayer");
-
- if (NMSUtil.getVersionNumber() > 13) {
- ContainerAccessClass = NMSUtil.getNMSClass("ContainerAccess");
- ContainersClass = NMSUtil.getNMSClass("Containers");
- }
- }
-
- private Player player;
- private Map items = new HashMap<>();
- private Inventory inv;
- private Listener listener;
-
- public AbstractAnvilGUI(Player player, AnvilClickEventHandler handler) {
- SkyBlock instance = SkyBlock.getInstance();
- this.player = player;
-
- this.listener = new Listener() {
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onInventoryClick(InventoryClickEvent event) {
- if (event.getWhoClicked() instanceof Player && event.getInventory().equals(AbstractAnvilGUI.this.inv)) {
- event.setCancelled(true);
-
- ItemStack item = event.getCurrentItem();
- int slot = event.getRawSlot();
-
- if (item == null || item.getType().equals(Material.AIR) || slot != 2)
- return;
-
- String name = "";
-
- ItemMeta meta = item.getItemMeta();
- if (meta != null && meta.hasDisplayName())
- name = meta.getDisplayName();
-
- AnvilClickEvent clickEvent = new AnvilClickEvent(AnvilSlot.bySlot(slot), name);
- handler.onAnvilClick(clickEvent);
-
- if (clickEvent.getWillClose())
- event.getWhoClicked().closeInventory();
-
- if (clickEvent.getWillDestroy())
- AbstractAnvilGUI.this.destroy();
- }
- }
-
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onInventoryClose(InventoryCloseEvent event) {
- if (event.getPlayer() instanceof Player && AbstractAnvilGUI.this.inv.equals(event.getInventory())) {
- Inventory inv = event.getInventory();
- player.setLevel(player.getLevel() - 1);
- inv.clear();
- Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
- AbstractAnvilGUI.this.destroy();
- }, 1L);
- }
- }
-
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onPlayerQuit(PlayerQuitEvent event) {
- if (event.getPlayer().equals(AbstractAnvilGUI.this.player)) {
- player.setLevel(player.getLevel() - 1);
- AbstractAnvilGUI.this.destroy();
- }
- }
- };
-
- Bukkit.getPluginManager().registerEvents(this.listener, instance);
- }
-
- public Player getPlayer() {
- return this.player;
- }
-
- public void setSlot(AnvilSlot slot, ItemStack item) {
- this.items.put(slot, item);
- }
-
- public void open() {
- this.player.setLevel(this.player.getLevel() + 1);
-
- try {
- Object craftPlayer = CraftPlayerClass.cast(this.player);
- Method getHandleMethod = CraftPlayerClass.getMethod("getHandle");
- Object entityPlayer = getHandleMethod.invoke(craftPlayer);
- Object playerInventory = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "inventory", false));
- Object world = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "world", false));
- Object blockPosition = BlockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(0, 0, 0);
-
- Object container;
-
- if (NMSUtil.getVersionNumber() > 13) {
- container = ContainerAnvilClass
- .getConstructor(int.class, PlayerInventoryClass, ContainerAccessClass)
- .newInstance(7, playerInventory, ContainerAccessClass.getMethod("at", WorldClass, BlockPositionClass).invoke(null, world, blockPosition));
- } else {
- container = ContainerAnvilClass
- .getConstructor(PlayerInventoryClass, WorldClass, BlockPositionClass, EntityHumanClass)
- .newInstance(playerInventory, world, blockPosition, entityPlayer);
- }
-
- NMSUtil.getField(ContainerClass, "checkReachable", true).set(container, false);
-
- Method getBukkitViewMethod = container.getClass().getMethod("getBukkitView");
- Object bukkitView = getBukkitViewMethod.invoke(container);
- Method getTopInventoryMethod = bukkitView.getClass().getMethod("getTopInventory");
- this.inv = (Inventory) getTopInventoryMethod.invoke(bukkitView);
-
- for (AnvilSlot slot : this.items.keySet()) {
- this.inv.setItem(slot.getSlot(), this.items.get(slot));
- }
-
- Method nextContainerCounterMethod = entityPlayer.getClass().getMethod("nextContainerCounter");
- int c = (int) nextContainerCounterMethod.invoke(entityPlayer);
-
- Constructor> chatMessageConstructor = ChatMessageClass.getConstructor(String.class, Object[].class);
- Object inventoryTitle = chatMessageConstructor.newInstance("Repairing", new Object[]{});
-
- Object packet;
-
- if (NMSUtil.getVersionNumber() > 13) {
- packet = PacketPlayOutOpenWindowClass
- .getConstructor(int.class, ContainersClass, IChatBaseComponentClass)
- .newInstance(c, ContainersClass.getField("ANVIL").get(null), inventoryTitle);
- } else {
- packet = PacketPlayOutOpenWindowClass
- .getConstructor(int.class, String.class, IChatBaseComponentClass, int.class)
- .newInstance(c, "minecraft:anvil", inventoryTitle, 0);
- }
-
- NMSUtil.sendPacket(this.player, packet);
-
- Field activeContainerField = NMSUtil.getField(EntityHumanClass, "activeContainer", true);
-
- if (activeContainerField != null) {
- activeContainerField.set(entityPlayer, container);
- NMSUtil.getField(ContainerClass, "windowId", true).set(activeContainerField.get(entityPlayer), c);
- Method addSlotListenerMethod = activeContainerField.get(entityPlayer).getClass().getMethod("addSlotListener", ICraftingClass);
- addSlotListenerMethod.invoke(activeContainerField.get(entityPlayer), entityPlayer);
-
- if (NMSUtil.getVersionNumber() > 13) {
- ContainerClass.getMethod("setTitle", IChatBaseComponentClass).invoke(container, inventoryTitle);
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public void destroy() {
- this.player = null;
- this.items = null;
-
- HandlerList.unregisterAll(this.listener);
-
- this.listener = null;
- }
-
- public enum AnvilSlot {
- INPUT_LEFT(0),
- INPUT_RIGHT(1),
- OUTPUT(2);
-
- private final int slot;
-
- AnvilSlot(int slot) {
- this.slot = slot;
- }
-
- public static AnvilSlot bySlot(int slot) {
- for (AnvilSlot anvilSlot : values()) {
- if (anvilSlot.getSlot() == slot) {
- return anvilSlot;
- }
- }
-
- return null;
- }
-
- public int getSlot() {
- return this.slot;
- }
- }
-
- @FunctionalInterface
- public interface AnvilClickEventHandler {
- void onAnvilClick(AnvilClickEvent event);
- }
-
- public class AnvilClickEvent {
- private final AnvilSlot slot;
-
- private final String name;
-
- private boolean close = true;
- private boolean destroy = true;
-
- public AnvilClickEvent(AnvilSlot slot, String name) {
- this.slot = slot;
- this.name = name;
- }
-
- public AnvilSlot getSlot() {
- return this.slot;
- }
-
- public String getName() {
- return this.name;
- }
-
- public boolean getWillClose() {
- return this.close;
- }
-
- public void setWillClose(boolean close) {
- this.close = close;
- }
-
- public boolean getWillDestroy() {
- return this.destroy;
- }
-
- public void setWillDestroy(boolean destroy) {
- this.destroy = destroy;
- }
- }
-
-}
\ No newline at end of file
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 0eb49d1f..09482880 100644
--- a/src/main/java/com/songoda/skyblock/utils/item/InventoryUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/item/InventoryUtil.java
@@ -1,6 +1,5 @@
package com.songoda.skyblock.utils.item;
-
-import com.songoda.skyblock.utils.version.NMSUtil;
+import com.songoda.core.compatibility.ServerVersion;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -21,7 +20,7 @@ public class InventoryUtil {
ItemStack is = ammo.get(index);
ItemMeta im = is.getItemMeta();
- if (NMSUtil.getVersionNumber() > 12) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
if (((Damageable) im).getDamage() != 0) {
continue;
}
@@ -57,7 +56,7 @@ public class InventoryUtil {
ItemMeta im = is.getItemMeta();
if (!im.hasDisplayName()) {
- if (NMSUtil.getVersionNumber() > 12) {
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) {
if (((Damageable) im).getDamage() != 0) {
continue;
}
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 d8813ab1..d8fd3e0a 100644
--- a/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/item/ItemStackUtil.java
@@ -1,8 +1,9 @@
package com.songoda.skyblock.utils.item;
+import com.songoda.core.compatibility.ClassMapping;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion;
-import com.songoda.skyblock.utils.version.NMSUtil;
+import com.songoda.core.utils.NMSUtils;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@@ -22,11 +23,11 @@ public class ItemStackUtil {
ItemStack itemStack = null;
try {
- Class> NBTTagCompoundClass = NMSUtil.getNMSClass("NBTTagCompound");
- Class> NMSItemStackClass = NMSUtil.getNMSClass("ItemStack");
- Object NBTTagCompound = isAbove1_16_R1 ? NMSUtil.getNMSClass("NBTCompressedStreamTools")
+ Class> NBTTagCompoundClass = ClassMapping.NBT_TAG_COMPOUND.getClazz();
+ Class> NMSItemStackClass = ClassMapping.ITEM_STACK.getClazz();
+ Object NBTTagCompound = isAbove1_16_R1 ? ClassMapping.NBT_COMPRESSED_STREAM_TOOLS.getClazz()
.getMethod("a", DataInput.class).invoke(null, dataInputStream)
- : NMSUtil.getNMSClass("NBTCompressedStreamTools")
+ : ClassMapping.NBT_COMPRESSED_STREAM_TOOLS.getClazz()
.getMethod("a", DataInputStream.class).invoke(null, dataInputStream);
Object craftItemStack;
@@ -40,7 +41,7 @@ public class ItemStackUtil {
NBTTagCompound);
}
- itemStack = (ItemStack) NMSUtil.getCraftClass("inventory.CraftItemStack")
+ itemStack = (ItemStack) NMSUtils.getCraftClass("inventory.CraftItemStack")
.getMethod("asBukkitCopy", NMSItemStackClass).invoke(null, craftItemStack);
// TODO: This method of serialization has some issues. Not all the names are the same between versions
@@ -66,14 +67,14 @@ public class ItemStackUtil {
DataOutputStream dataOutput = new DataOutputStream(outputStream);
try {
- Class> NBTTagCompoundClass = NMSUtil.getNMSClass("NBTTagCompound");
+ Class> NBTTagCompoundClass = ClassMapping.NBT_TAG_COMPOUND.getClazz();
Constructor> nbtTagCompoundConstructor = NBTTagCompoundClass.getConstructor();
Object NBTTagCompound = nbtTagCompoundConstructor.newInstance();
- Object NMSItemStackClass = NMSUtil.getCraftClass("inventory.CraftItemStack")
+ Object NMSItemStackClass = NMSUtils.getCraftClass("inventory.CraftItemStack")
.getMethod("asNMSCopy", ItemStack.class).invoke(null, item);
- NMSUtil.getNMSClass("ItemStack").getMethod("save", NBTTagCompoundClass).invoke(NMSItemStackClass,
+ ClassMapping.ITEM_STACK.getClazz().getMethod("save", NBTTagCompoundClass).invoke(NMSItemStackClass,
NBTTagCompound);
- NMSUtil.getNMSClass("NBTCompressedStreamTools").getMethod("a", NBTTagCompoundClass, DataOutput.class)
+ ClassMapping.NBT_COMPRESSED_STREAM_TOOLS.getClazz().getMethod("a", NBTTagCompoundClass, DataOutput.class)
.invoke(null, NBTTagCompound, dataOutput);
} catch (Exception e) {
e.printStackTrace();
diff --git a/src/main/java/com/songoda/skyblock/utils/structure/SchematicUtil.java b/src/main/java/com/songoda/skyblock/utils/structure/SchematicUtil.java
index a74cb0b8..fa9587ac 100644
--- a/src/main/java/com/songoda/skyblock/utils/structure/SchematicUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/structure/SchematicUtil.java
@@ -1,7 +1,7 @@
package com.songoda.skyblock.utils.structure;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.SkyBlock;
-import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.plugin.PluginManager;
@@ -20,7 +20,7 @@ public class SchematicUtil {
throw new IllegalStateException("Tried to generate an island using a schematic file without WorldEdit installed!");
Runnable pasteTask = () -> {
- if (NMSUtil.getVersionNumber() > 12) { // WorldEdit 7
+ if (ServerVersion.isServerVersionAbove(ServerVersion.V1_12)) { // WorldEdit 7
com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat format = com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats.findByFile(schematicFile);
try (com.sk89q.worldedit.extent.clipboard.io.ClipboardReader reader = format.getReader(new FileInputStream(schematicFile))) {
com.sk89q.worldedit.extent.clipboard.Clipboard clipboard = reader.read();
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 7482dc40..0e1b378e 100644
--- a/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/structure/StructureUtil.java
@@ -5,12 +5,12 @@ 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.compatibility.ServerVersion;
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;
-import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.utils.world.block.BlockData;
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
@@ -83,7 +83,7 @@ public final class StructureUtil {
originBlockLocation = originBlockLocation + ":" + originLocation.getYaw() + ":" + originLocation.getPitch();
}
- String JSONString = new Gson().toJson(new Storage(new Gson().toJson(blockData), new Gson().toJson(entityData), originBlockLocation, System.currentTimeMillis(), NMSUtil.getVersionNumber()), Storage.class);
+ String JSONString = new Gson().toJson(new Storage(new Gson().toJson(blockData), new Gson().toJson(entityData), originBlockLocation, System.currentTimeMillis(), Integer.parseInt(ServerVersion.getVersionReleaseNumber())), Storage.class);
FileOutputStream fileOutputStream = new FileOutputStream(configFile, false);
fileOutputStream.write(Base64.getEncoder().encode(JSONString.getBytes(StandardCharsets.UTF_8)));
@@ -198,7 +198,7 @@ public final class StructureUtil {
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);
+ EntityUtil.convertEntityDataToEntity(entityDataList, blockLocation);
}
} catch (Exception e) {
SkyBlock.getInstance().getLogger().warning("Unable to convert EntityData to Entity for type {" + entityDataList.getEntityType() + "} in structure {" + structure.getStructureFile() + "}");
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 a0dac09a..89b455b3 100644
--- a/src/main/java/com/songoda/skyblock/utils/version/CompatibleSpawners.java
+++ b/src/main/java/com/songoda/skyblock/utils/version/CompatibleSpawners.java
@@ -1,10 +1,15 @@
package com.songoda.skyblock.utils.version;
import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.compatibility.ServerVersion;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
-import java.util.*;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
public enum CompatibleSpawners {
@@ -179,7 +184,7 @@ public enum CompatibleSpawners {
}
public static CompatibleSpawners getMaterials(Material material, byte data) {
- if (NMSUtil.getVersionNumber() > 12) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
return fromString(material.name());
} else {
return requestMaterials(material.name(), 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
deleted file mode 100644
index 83becd3b..00000000
--- a/src/main/java/com/songoda/skyblock/utils/version/NMSUtil.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.songoda.skyblock.utils.version;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import java.lang.reflect.Field;
-
-public class NMSUtil {
-
- private static final String version;
- private static final int versionNumber;
- private static final int versionReleaseNumber;
-
- static {
-
- String packageName = Bukkit.getServer().getClass().getPackage().getName();
- version = packageName.substring(packageName.lastIndexOf('.') + 1) + ".";
-
- String name = version.substring(3);
- versionNumber = Integer.parseInt(name.substring(0, name.length() - 4));
-
- versionReleaseNumber = Integer.parseInt(version.substring(version.length() - 2).replace(".", ""));
-
- }
-
- public static String getVersion() {
- return version;
- }
-
- public static int getVersionNumber() {
- return versionNumber;
- }
-
- public static int getVersionReleaseNumber() {
- return versionReleaseNumber;
- }
-
- public static Class> getNMSClass(String className) {
- try {
- String fullName = "net.minecraft.server." + getVersion() + className;
- return Class.forName(fullName);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public static Class> getCraftClass(String className) {
- try {
- return Class.forName("org.bukkit.craftbukkit." + getVersion() + className);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public static Field getField(Class> clazz, String name, boolean declared) {
- try {
- Field field;
-
- if (declared) {
- field = clazz.getDeclaredField(name);
- } else {
- field = clazz.getField(name);
- }
-
- field.setAccessible(true);
- return field;
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public static Object getFieldObject(Object object, Field field) {
- try {
- return field.get(object);
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
-
- public static void setField(Object object, String fieldName, Object fieldValue, boolean declared) {
- try {
- Field field;
-
- if (declared) {
- field = object.getClass().getDeclaredField(fieldName);
- } else {
- field = object.getClass().getField(fieldName);
- }
-
- field.setAccessible(true);
- field.set(object, fieldValue);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static void sendPacket(Player player, Object packet) {
- try {
- Object handle = player.getClass().getMethod("getHandle").invoke(player);
- Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
- playerConnection.getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(playerConnection, packet);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
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 cae2cbab..30363676 100644
--- a/src/main/java/com/songoda/skyblock/utils/version/SBiome.java
+++ b/src/main/java/com/songoda/skyblock/utils/version/SBiome.java
@@ -1,6 +1,7 @@
package com.songoda.skyblock.utils.version;
import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.utils.StringUtil;
import org.bukkit.Material;
import org.bukkit.block.Biome;
@@ -34,7 +35,7 @@ public enum SBiome {
THE_VOID("SKY", CompatibleMaterial.OBSIDIAN),
WARM_OCEAN(true, CompatibleMaterial.TROPICAL_FISH);
- private static final boolean isPostVersion = NMSUtil.getVersionNumber() >= 13;
+ private static final boolean isPostVersion = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13);
private final String legacyName;
private final boolean isPost13;
diff --git a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java
index 4221ddc9..75fbc4c2 100644
--- a/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java
+++ b/src/main/java/com/songoda/skyblock/utils/world/LocationUtil.java
@@ -10,7 +10,6 @@ import com.songoda.skyblock.island.IslandEnvironment;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandWorld;
import com.songoda.skyblock.utils.math.VectorUtil;
-import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
import com.songoda.skyblock.world.WorldManager;
import io.papermc.lib.PaperLib;
@@ -90,7 +89,7 @@ public final class LocationUtil {
locChecked.getBlock().getType().isBlock() &&
locChecked.add(0d,1d,0d).getBlock().getType().equals(CompatibleMaterial.AIR.getMaterial()) &&
locChecked.add(0d,2d,0d).getBlock().getType().equals(CompatibleMaterial.AIR.getMaterial()) &&
- !(NMSUtil.getVersionNumber() >= 13 && locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
+ !(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) && locChecked.getBlock().getBlockData() instanceof org.bukkit.block.data.Waterlogged)){
safe = true;
switch(CompatibleMaterial.getMaterial(locChecked.getBlock())){
case ACACIA_DOOR: // <= 1.8.8
diff --git a/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java b/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java
deleted file mode 100644
index c6645a22..00000000
--- a/src/main/java/com/songoda/skyblock/utils/world/WorldBorder.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.songoda.skyblock.utils.world;
-
-import com.songoda.core.compatibility.ServerVersion;
-import com.songoda.skyblock.SkyBlock;
-import com.songoda.skyblock.utils.version.NMSUtil;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public final class WorldBorder {
-
- private static Class> packetPlayOutWorldBorderEnumClass;
- private static Class> worldBorderClass;
- private static Class> craftWorldClass;
- private static Constructor> packetPlayOutWorldBorderConstructor;
-
- static {
- try {
- Class> packetPlayOutWorldBorder = NMSUtil.getNMSClass("PacketPlayOutWorldBorder");
-
- if(packetPlayOutWorldBorder != null) {
- if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
- packetPlayOutWorldBorderEnumClass = packetPlayOutWorldBorder.getDeclaredClasses()[0];
- } else {
- packetPlayOutWorldBorderEnumClass = packetPlayOutWorldBorder.getDeclaredClasses()[1];
- }
-
- worldBorderClass = NMSUtil.getNMSClass("WorldBorder");
- craftWorldClass = NMSUtil.getCraftClass("CraftWorld");
-
- packetPlayOutWorldBorderConstructor = packetPlayOutWorldBorder.getConstructor(worldBorderClass,
- packetPlayOutWorldBorderEnumClass);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public static void send(Player player, Color color, double size, Location centerLocation) {
- try {
- if (centerLocation == null || centerLocation.getWorld() == null)
- return;
-
- Object worldBorder = worldBorderClass.getConstructor().newInstance();
-
- if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
- Object craftWorld = craftWorldClass.cast(centerLocation.getWorld());
- Method getHandleMethod = craftWorld.getClass().getMethod("getHandle");
- Object worldServer = getHandleMethod.invoke(craftWorld);
- NMSUtil.setField(worldBorder, "world", worldServer, false);
- }
-
- Method setCenter = worldBorder.getClass().getMethod("setCenter", double.class, double.class);
- setCenter.invoke(worldBorder, centerLocation.getX(), centerLocation.getZ());
-
- Method setSize = worldBorder.getClass().getMethod("setSize", double.class);
- setSize.invoke(worldBorder, size);
-
- Method setWarningTime = worldBorder.getClass().getMethod("setWarningTime", int.class);
- setWarningTime.invoke(worldBorder, 0);
-
- Method setWarningDistance = worldBorder.getClass().getMethod("setWarningDistance", int.class);
- setWarningDistance.invoke(worldBorder, 0);
-
- Method transitionSizeBetween = worldBorder.getClass().getMethod("transitionSizeBetween", double.class,
- double.class, long.class);
-
- if (color == Color.Green) {
- transitionSizeBetween.invoke(worldBorder, size - 0.1D, size, 20000000L);
- } else if (color == Color.Red) {
- transitionSizeBetween.invoke(worldBorder, size, size - 1.0D, 20000000L);
- }
-
- @SuppressWarnings({"unchecked", "rawtypes"})
- Object packet = packetPlayOutWorldBorderConstructor.newInstance(worldBorder,
- Enum.valueOf((Class) packetPlayOutWorldBorderEnumClass, "INITIALIZE"));
- NMSUtil.sendPacket(player, packet);
- } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
- e.printStackTrace();
- }
- }
-
- public enum Color {
-
- Blue, Green, Red
-
- }
-}
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 3ab2ed59..969b4efd 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
@@ -1,10 +1,11 @@
package com.songoda.skyblock.utils.world.block;
+import com.songoda.core.compatibility.ClassMapping;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.utils.BlockUtils;
+import com.songoda.core.utils.NMSUtils;
import com.songoda.skyblock.utils.item.ItemStackUtil;
-import com.songoda.skyblock.utils.version.NMSUtil;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.block.banner.Pattern;
@@ -27,8 +28,7 @@ public final class BlockUtil extends BlockUtils {
public static BlockData convertBlockToBlockData(Block block, int x, int y, int z) {
BlockData blockData = new BlockData(block.getType().name(), block.getData(), x, y, z, block.getBiome().toString());
- int NMSVersion = NMSUtil.getVersionNumber();
- blockData.setVersion(NMSVersion);
+ blockData.setVersion(Integer.parseInt(ServerVersion.getVersionReleaseNumber()));
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
blockData.setBlockData(block.getBlockData().getAsString());
@@ -227,24 +227,24 @@ public final class BlockUtil extends BlockUtils {
try {
World world = block.getWorld();
- Class> blockPositionClass = NMSUtil.getNMSClass("BlockPosition");
+ Class> blockPositionClass = ClassMapping.BLOCK_POSITION.getClazz();;
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);
Field aField = tileEntity.getClass().getDeclaredField("a");
- aField.setAccessible(true);
+ aField.setAccessible(true);
Object item = aField.get(tileEntity);
if (item != null) {
- Object itemStackNMS = NMSUtil.getNMSClass("ItemStack").getConstructor(NMSUtil.getNMSClass("Item")).newInstance(item);
+ Object itemStackNMS = ClassMapping.ITEM_STACK.getClazz().getConstructor(ClassMapping.ITEM.getClazz()).newInstance(item);
- ItemStack itemStack = (ItemStack) NMSUtil.getCraftClass("inventory.CraftItemStack").getMethod("asBukkitCopy", itemStackNMS.getClass()).invoke(null, itemStackNMS);
+ ItemStack itemStack = (ItemStack) NMSUtils.getCraftClass("inventory.CraftItemStack").getMethod("asBukkitCopy", itemStackNMS.getClass()).invoke(null, itemStackNMS);
Field fField = tileEntity.getClass().getDeclaredField("f");
- fField.setAccessible(true);
+ fField.setAccessible(true);
int data = (int) fField.get(tileEntity);
@@ -268,7 +268,6 @@ public final class BlockUtil extends BlockUtils {
}
public static void convertBlockDataToBlock(Block block, BlockData blockData) {
- int NMSVersion = NMSUtil.getVersionNumber();
String materialStr = blockData.getMaterial();
if (materialStr == null) return;
@@ -461,7 +460,7 @@ public final class BlockUtil extends BlockUtils {
state.setData(stairs);
} else if (blockDataType == BlockDataType.FLOWERPOT) {
setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), CompatibleMaterial.STONE, (byte) 0);
- if (NMSVersion >= 8 && NMSVersion <= 12) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_8) && ServerVersion.isServerVersionAtOrBelow(ServerVersion.V1_12)) {
if (block.getLocation().clone().subtract(0.0D, 1.0D, 0.0D).getBlock().getType() == Material.AIR) {
setBlockFast(block.getWorld(), block.getX(), block.getY() - 1, block.getZ(), CompatibleMaterial.STONE, (byte) 0);
}
@@ -477,12 +476,12 @@ public final class BlockUtil extends BlockUtils {
World world = block.getWorld();
- Class> blockPositionClass = NMSUtil.getNMSClass("BlockPosition");
+ Class> blockPositionClass = ClassMapping.BLOCK_POSITION.getClazz();
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 itemStack = NMSUtils.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);
@@ -491,7 +490,7 @@ public final class BlockUtil extends BlockUtils {
aField.set(tileEntity, item);
Field fField = tileEntity.getClass().getDeclaredField("f");
- fField.setAccessible(true);
+ fField.setAccessible(true);
fField.set(tileEntity, data);
tileEntity.getClass().getMethod("update").invoke(tileEntity);
@@ -506,11 +505,11 @@ public final class BlockUtil extends BlockUtils {
materialStr = null;
if (blockData.getVersion() > 12) {
- if (NMSVersion > 12) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
materialStr = flower[0].toUpperCase();
}
} else {
- if (NMSVersion < 13) {
+ if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
materialStr = flower[0].toUpperCase();
}
}
@@ -531,7 +530,7 @@ public final class BlockUtil extends BlockUtils {
if (bottomBlock.getType() == Material.AIR && !topBlock.getType().name().equals("DOUBLE_PLANT")) {
bottomBlock.setType(CompatibleMaterial.LARGE_FERN.getMaterial());
- if (NMSVersion < 13) {
+ if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
try {
bottomBlock.getClass().getMethod("setData", byte.class).invoke(bottomBlock, (byte) 2);
} catch (Exception e) {
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 ec41bffe..e394a726 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,11 +1,9 @@
package com.songoda.skyblock.utils.world.entity;
import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.compatibility.ServerVersion;
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;
import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.entity.minecart.HopperMinecart;
@@ -13,7 +11,6 @@ import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.material.Colorable;
import org.bukkit.material.MaterialData;
import org.bukkit.util.EulerAngle;
@@ -27,7 +24,7 @@ public final class EntityUtil {
return new EntityData(NmsManager.getNbt().of(entity).serialize("Attributes"), x, y, z);
}
- public static void convertEntityDataToEntity(EntityData entityData, Location loc, BlockDegreesType type) {
+ public static void convertEntityDataToEntity(EntityData entityData, Location loc) {
Entity entity = loc.getWorld().spawnEntity(loc, EntityType.valueOf(entityData.getEntityType().toUpperCase()));
entity.setCustomName(entityData.getCustomName());
entity.setCustomNameVisible(entityData.isCustomNameVisible());
@@ -88,14 +85,12 @@ public final class EntityUtil {
Double.parseDouble(rightLegPose[1]), Double.parseDouble(rightLegPose[2])));
}
- int NMSVersion = NMSUtil.getVersionNumber();
-
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
EntityEquipment entityEquipment = livingEntity.getEquipment();
- if (NMSVersion > 8) {
- if (NMSVersion > 9) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_10)) {
livingEntity.setAI(entityData.hasAI());
}
@@ -150,7 +145,7 @@ public final class EntityUtil {
Material material = CompatibleMaterial.getMaterial(materialData[0].toUpperCase()).getMaterial();
if (material != null) {
- if (NMSVersion > 12) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
((Enderman) entity).setCarriedBlock(Bukkit.getServer().createBlockData(material));
} else {
((Enderman) entity).setCarriedMaterial(new MaterialData(material, data));
@@ -204,7 +199,7 @@ public final class EntityUtil {
villager.getInventory().setContents(items.toArray(new ItemStack[0]));
}
- if (NMSVersion > 10) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (entity instanceof Llama) {
Llama llama = ((Llama) entity);
llama.setColor(Llama.Color.valueOf(entityData.getLlamaColor().toUpperCase()));
@@ -219,7 +214,7 @@ public final class EntityUtil {
llama.getInventory().setContents(items.toArray(new ItemStack[0]));
}
- if (NMSVersion > 11) {
+ if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
if (entity instanceof Parrot) {
((Parrot) entity)
.setVariant(Parrot.Variant.valueOf(entityData.getParrotVariant().toUpperCase()));