mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2024-09-27 14:13:00 +02:00
Added 1.17 support.
This commit is contained in:
parent
8f3ed2defa
commit
22bed4f0cc
12
pom.xml
12
pom.xml
@ -54,7 +54,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
@ -104,6 +104,12 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache.snapshots</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
@ -156,7 +162,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.2</version>
|
||||
<version>1.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
@ -167,7 +173,7 @@
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>2.5.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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());
|
||||
|
@ -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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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<Block> to
|
||||
// ArrayList<BlockState> in 1.14.1
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
if (ServerVersion.isServerVersionAbove(ServerVersion.V1_13)) {
|
||||
List<BlockState> blocks = event.getBlocks(); // TODO 1.8
|
||||
if (event.getBlocks().isEmpty()) return;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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());
|
||||
|
@ -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<Upgrade> 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<Upgrade> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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")),
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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<String> 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<String> 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<String> 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<String> 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()
|
||||
|
@ -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<com.songoda.skyblock.upgrade.Upgrade> 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);
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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<AnvilSlot, ItemStack> 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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() + "}");
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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<Enum>) packetPlayOutWorldBorderEnumClass, "INITIALIZE"));
|
||||
NMSUtil.sendPacket(player, packet);
|
||||
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public enum Color {
|
||||
|
||||
Blue, Green, Red
|
||||
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
@ -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()));
|
||||
|
Loading…
Reference in New Issue
Block a user