Merge branch 'development'

This commit is contained in:
Brianna 2021-06-21 17:20:31 -05:00
commit 7480e91b2d
50 changed files with 1495 additions and 2408 deletions

22
pom.xml
View File

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>skyblock</artifactId>
<version>2.3.27</version>
<version>2.3.28</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -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>
@ -125,10 +131,6 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>reserve-repo</id>
<url>https://dl.bintray.com/theneweconomy/java/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
@ -160,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>
@ -209,12 +211,6 @@
<version>7.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>EpicAnchors</artifactId>
<version>1.4.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit-bukkit</artifactId>

View File

@ -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;

View File

@ -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;

View File

@ -1,92 +0,0 @@
/**
*
*/
package com.songoda.skyblock.challenge.inventory;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
public class ItemBuilder {
private Material m;
private int count;
private int damage;
private String name;
private List<String> lores;
private String texture;
private ItemBuilder() {
}
public static ItemBuilder of(Material m) {
return of(m, 1);
}
public static ItemBuilder of(Material m, int count) {
return of(m, count, (short) 0);
}
public static ItemBuilder of(Material m, int count, int damage) {
ItemBuilder ib = new ItemBuilder();
ib.m = m;
ib.count = count;
ib.damage = damage;
return ib;
}
public ItemBuilder name(String name) {
this.name = name;
return this;
}
public ItemBuilder lore(List<String> lores) {
this.lores = lores;
return this;
}
public ItemBuilder texture(String texture) {
this.texture = texture;
return this;
}
public ItemStack build() {
ItemStack is = new ItemStack(m, count);
if (is instanceof Damageable) {
Damageable d = (Damageable) is;
d.setDamage(damage);
}
ItemMeta im = is.hasItemMeta() ? is.getItemMeta() : Bukkit.getItemFactory().getItemMeta(m);
if (im != null) {
im.setDisplayName(name);
im.setLore(lores);
if (m == Material.PLAYER_HEAD && texture != null && !"".equalsIgnoreCase(texture.trim())) {
SkullMeta headMeta = (SkullMeta) im;
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", texture));
try {
Field profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} catch (IllegalArgumentException | NoSuchFieldException | SecurityException
| IllegalAccessException ex) {
Bukkit.getLogger().log(Level.SEVERE, "Error while setting head texture", ex);
}
}
is.setItemMeta(im);
}
return is;
}
}

View File

@ -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();

View File

@ -5,6 +5,7 @@ import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.gui.AnvilGui;
import com.songoda.core.gui.Gui;
import com.songoda.core.gui.GuiUtils;
import com.songoda.core.utils.ItemUtils;
import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.island.Island;
@ -14,7 +15,6 @@ import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.permission.PermissionManager;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.item.SkullUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
@ -155,7 +155,7 @@ public class GuiCoop extends Gui {
}
}
ItemStack is = SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]);
ItemStack is = ItemUtils.getCustomHead(targetPlayerTexture[0], targetPlayerTexture[1]);
ItemMeta im = is.getItemMeta();
if (im != null) {
im.setDisplayName(TextUtils.formatText(languageLoad.getString("Menu.Coop.Item.Coop.Displayname")

View File

@ -4,12 +4,12 @@ import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.gui.Gui;
import com.songoda.core.gui.GuiUtils;
import com.songoda.core.utils.ItemUtils;
import com.songoda.core.utils.TextUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.item.SkullUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -113,7 +113,7 @@ public class GuiBans extends Gui {
}
}
ItemStack is = SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]);
ItemStack is = ItemUtils.getCustomHead(targetPlayerTexture[0], targetPlayerTexture[1]);
ItemMeta im = is.getItemMeta();
if(im != null){
im.setDisplayName(languageLoad.getString("Menu.Bans.Item.Ban.Displayname")

View File

@ -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());

View File

@ -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;
@ -59,9 +58,7 @@ import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
public class IslandManager {
@ -277,12 +274,14 @@ public class IslandManager {
Bukkit.getServer().getScheduler().runTaskLater(plugin, () ->
plugin.getBiomeManager().setBiome(island, IslandWorld.Normal, compatibleBiome, () -> {
if (structure.getCommands() != null) {
for (String commandList : structure.getCommands()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName()));
}
}
}), 20L);
if (structure.getCommands() != null) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
for (String commandList : structure.getCommands()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), commandList.replace("%player", player.getName()));
}
});
}
}), 20L);
// Recalculate island level after 5 seconds
if (configLoad.getBoolean("Island.Levelling.ScanAutomatically"))
@ -1460,20 +1459,22 @@ public class IslandManager {
updateFlight(player);
if (world == IslandWorld.Nether) {
if (NMSUtil.getVersionNumber() < 13) {
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_13)) {
return;
}
}
double increment = island.getSize() % 2 != 0 ? 0.5d : 0.0d;
if (configLoad.getBoolean("Island.WorldBorder.Enable") && island.isBorder()) {
WorldBorder.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));
}
Bukkit.getScheduler().runTask(plugin, () -> {
if (configLoad.getBoolean("Island.WorldBorder.Enable") && island.isBorder()) {
SWorldBorder.send(player, island.getBorderColor(), island.getSize(),
island.getLocation(worldManager.getIslandWorld(player.getWorld()),
IslandEnvironment.Island).clone().add(increment, 0, increment));
} else {
SWorldBorder.send(player, null, 1.4999992E7D, new org.bukkit.Location(player.getWorld(), 0, 0, 0));
}
});
}
}
});
@ -1611,9 +1612,11 @@ public class IslandManager {
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
if (worldList != IslandWorld.Nether || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
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));
}
Bukkit.getScheduler().runTask(plugin, () -> {
for (Player all : getPlayersAtIsland(island)) {
SWorldBorder.send(all, island.getBorderColor(), island.getSize(), island.getLocation(worldManager.getIslandWorld(all.getWorld()), IslandEnvironment.Island).clone().add(increment, 0, increment));
}
});
}
}
@ -1621,9 +1624,11 @@ public class IslandManager {
} else {
for (IslandWorld worldList : IslandWorld.getIslandWorlds()) {
if (worldList != IslandWorld.Nether || ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)) {
for (Player all : getPlayersAtIsland(island)) {
WorldBorder.send(all, null, 1.4999992E7D, new Location(all.getWorld(), 0, 0, 0));
}
Bukkit.getScheduler().runTask(plugin, () -> {
for (Player all : getPlayersAtIsland(island)) {
SWorldBorder.send(all, null, 1.4999992E7D, new Location(all.getWorld(), 0, 0, 0));
}
});
}
}

View File

@ -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;

View File

@ -2,13 +2,10 @@ package com.songoda.skyblock.listeners;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.placeholder.PlaceholderManager;
import com.songoda.skyblock.playerdata.PlayerData;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.utils.player.OfflinePlayer;
@ -21,7 +18,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.io.File;
import java.util.UUID;
public class ChatListeners implements Listener {
@ -36,7 +32,6 @@ public class ChatListeners implements Listener {
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
PlaceholderManager placeholderManager = plugin.getPlaceholderManager();
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
if (playerDataManager.hasPlayerData(player)) {
@ -53,24 +48,30 @@ public class ChatListeners implements Listener {
PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, island.getAPIWrapper(),
event.getMessage(), languageLoad.getString("Island.Chat.Format.Message"));
Bukkit.getServer().getPluginManager().callEvent(islandChatEvent);
Runnable callEvent = () -> Bukkit.getServer().getPluginManager().callEvent(islandChatEvent);
if (Bukkit.isPrimaryThread()) {
callEvent.run();
} else {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, callEvent);
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR,ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onIslandChat(PlayerIslandChatEvent event) {
PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
MessageManager messageManager = plugin.getMessageManager();
IslandManager islandManager = plugin.getIslandManager();
Island island = event.getIsland().getIsland();
Player player = event.getPlayer();
FileConfiguration languageLoad = plugin.getLanguage();
String islandRole = null;
if (island.hasRole(IslandRole.Member, player.getUniqueId())) {
islandRole = languageLoad.getString("Island.Chat.Format.Role.Member");
} else if (island.hasRole(IslandRole.Operator, player.getUniqueId())) {
@ -78,10 +79,10 @@ public class ChatListeners implements Listener {
} else if (island.hasRole(IslandRole.Owner, player.getUniqueId())) {
islandRole = languageLoad.getString("Island.Chat.Format.Role.Owner");
}
if(islandRole == null) {
if (islandRole == null) {
islandRole = "";
}
for (UUID islandMembersOnlineList : islandManager.getMembersOnline(island)) {
Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList);
String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer,
@ -89,14 +90,14 @@ public class ChatListeners implements Listener {
.replace("%message", event.getMessage());
messageManager.sendMessage(targetPlayer, message);
}
// Spy
for(Player targetPlayer : Bukkit.getServer().getOnlinePlayers()){
if(!targetPlayer.equals(event.getPlayer()) &&
for (Player targetPlayer : Bukkit.getServer().getOnlinePlayers()) {
if (!targetPlayer.equals(event.getPlayer()) &&
!islandManager.getMembersOnline(island).contains(targetPlayer.getUniqueId()) &&
targetPlayer.hasPermission("fabledskyblock.admin.chatspy")) {
PlayerData pd = playerDataManager.getPlayerData(targetPlayer);
if(pd != null && pd.isChatSpy() && (pd.isGlobalChatSpy() || pd.isChatSpyIsland(island))) {
if (pd != null && pd.isChatSpy() && (pd.isGlobalChatSpy() || pd.isChatSpyIsland(island))) {
String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer,
languageLoad.getString("Island.Chat.Spy.Format.Message").replace("%role", islandRole).replace("%player", player.getName())))
.replace("%islandOwner", new OfflinePlayer(island.getOwnerUUID()).getName())
@ -105,7 +106,7 @@ public class ChatListeners implements Listener {
}
}
}
if (this.plugin.getConfiguration().getBoolean("Island.Chat.OutputToConsole")) {
messageManager.sendMessage(Bukkit.getConsoleSender(), event.getFormat().replace("%role", islandRole).replace("%player", player.getName())
.replace("%message", event.getMessage()));

View File

@ -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;

View File

@ -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) {

View File

@ -318,13 +318,6 @@ public class InteractListeners implements Listener {
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")) {
if (Bukkit.getPluginManager().isPluginEnabled("EpicAnchors")) {
if (com.songoda.epicanchors.EpicAnchors.getInstance().getAnchorManager().getAnchor(block.getLocation()) != null) {
event.setCancelled(true);
return;
}
}
if (CompatibleHand.getHand(event) == CompatibleHand.OFF_HAND) return;
ItemStack is = event.getPlayer().getItemInHand();

View File

@ -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;
@ -100,7 +100,7 @@ public class MoveListeners implements Listener {
boolean keepItemsOnDeath;
if (configLoad.getBoolean("Island.Settings.KeepItemsOnDeath.Enable")) {
keepItemsOnDeath = permissionManager.hasPermission(island,"KeepItemsOnDeath", IslandRole.Owner);
keepItemsOnDeath = permissionManager.hasPermission(island, "KeepItemsOnDeath", IslandRole.Owner);
} else {
keepItemsOnDeath = configLoad.getBoolean("Island.KeepItemsOnDeath.Enable");
}
@ -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());
@ -206,17 +206,21 @@ public class MoveListeners implements Listener {
}
} else {
loc = island.getLocation(world, IslandEnvironment.Main);
if(plugin.getConfiguration().getBoolean("Island.Teleport.RemoveWater", false)) {
LocationUtil.removeWaterFromLoc(loc);
}
}
} else {
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)) {
if(plugin.getConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(world, IslandEnvironment.Visitor));
if (safeLoc != null) {
loc = safeLoc;
if (plugin.getConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
Location isLoc = island.getLocation(world, IslandEnvironment.Visitor);
if (isLoc != null) {
Location safeLoc = LocationUtil.getSafeLocation(isLoc);
if (safeLoc != null) {
loc = safeLoc;
}
}
}
} else {

View File

@ -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();
}
}
}

View File

@ -2,9 +2,10 @@ 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;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
@ -13,8 +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.SkullUtil;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import org.bukkit.Bukkit;
@ -25,7 +24,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.io.File;
import java.util.Set;
import java.util.UUID;
@ -94,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);
@ -112,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(
@ -122,7 +116,7 @@ public class Bans {
event.setWillClose(false);
event.setWillDestroy(false);
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
} else if ((is.getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(plugin.formatText(
configLoad.getString("Menu.Bans.Item.Previous.Displayname")))) {
playerData1.setPage(MenuType.BANS, playerData1.getPage(MenuType.BANS) - 1);
@ -173,14 +167,14 @@ public class Bans {
int playerMenuPage = playerData.getPage(MenuType.BANS), nextEndIndex = islandBans.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Bans.Item.Previous.Displayname"), null, null, null, null), 1);
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Bans.Item.Next.Displayname"), null, null, null, null), 7);
@ -220,7 +214,7 @@ public class Bans {
}
nInv.addItem(
nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]),
nInv.createItem(ItemUtils.getCustomHead(targetPlayerTexture[0], targetPlayerTexture[1]),
plugin.formatText(
configLoad.getString("Menu.Bans.Item.Ban.Displayname")
.replace("%player", targetPlayerName == null ? "" : targetPlayerName)),

View File

@ -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")),

View File

@ -2,9 +2,9 @@ package com.songoda.skyblock.menus;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
@ -14,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.item.SkullUtil;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.visit.Visit;
@ -26,7 +25,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@ -294,7 +292,7 @@ public class Information {
event.setWillClose(false);
event.setWillDestroy(false);
} else if ((is.getType() == SkullUtil.createItemStack().getType())
} else if ((is.getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial())
&& (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
@ -356,7 +354,7 @@ public class Information {
nextEndIndex = displayedMembers.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Information.Members.Item.Previous.Displayname"), null, null,
@ -364,7 +362,7 @@ public class Information {
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Information.Members.Item.Next.Displayname"), null, null,
@ -405,7 +403,7 @@ public class Information {
}
nInv.addItem(
nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]),
nInv.createItem(ItemUtils.getCustomHead(playerTexture[0], playerTexture[1]),
configLoad.getString("Menu.Information.Members.Item.Member.Displayname")
.replace("%player", playerName),
configLoad.getStringList("Menu.Information.Members.Item.Member.Lore"),
@ -453,7 +451,7 @@ public class Information {
event.setWillClose(false);
event.setWillDestroy(false);
} else if ((is.getType() == SkullUtil.createItemStack().getType())
} else if ((is.getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial())
&& (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName()
.equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString(
@ -501,7 +499,7 @@ public class Information {
nextEndIndex = displayedVisitors.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Information.Visitors.Item.Previous.Displayname"), null, null,
@ -509,7 +507,7 @@ public class Information {
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Information.Visitors.Item.Next.Displayname"), null, null,
@ -542,7 +540,7 @@ public class Information {
}
nInv.addItem(
nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]),
nInv.createItem(ItemUtils.getCustomHead(playerTexture[0], playerTexture[1]),
configLoad.getString("Menu.Information.Visitors.Item.Visitor.Displayname")
.replace("%player", playerName),
null, null, null, null),

View File

@ -2,14 +2,12 @@ package com.songoda.skyblock.menus;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.placeholder.Placeholder;
import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.core.utils.NumberUtils;
import com.songoda.skyblock.utils.item.SkullUtil;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.visit.Visit;
@ -21,7 +19,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@ -292,7 +289,7 @@ public class Leaderboard {
}
nInv.addItem(
nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]),
nInv.createItem(ItemUtils.getCustomHead(playerTexture[0], playerTexture[1]),
configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Island.Displayname")
.replace(
"%owner", playerName)
@ -313,7 +310,7 @@ public class Leaderboard {
for (int i = 0; i < itemSlots.length; i++) {
if (!nInv.getItems().containsKey(itemSlots[i])) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"gi+wnQt/y4Z6E9rn65iDWmt8vUOM2WXY66XvtydqDJZTzwgFrjVcx2c5YwdzvtOIRtiX2nZt4n2uWesUFKb59xS24YWbxCDXnalHhCpPFcIP58SQbCm9AYp3UPzkcRNWzuV4BddrS608QQZGyIFOUaLPOPasGITZu51VLcOKcTyFOCKu1QE2yRo1orTH8bWfdpE769BB/VYGdny0qJtm1amc12wGiVifMJRutZmYo2ZdA0APhIJVaNsPppNESVcbeBCvk60l4QK43C/p98/QEe5U6UJ6Z6N01pBQcswubMu8lCuPLasep+vX3v2K+Ui9jnTQNreGNIZPWVjf6V1GH4xMbbUVQJsoPdcaXG855VdzyoW+kyHdWYEojSn0qAY/moH6JCLnx6PLCv9mITSvOIUHq8ITet0M7Z9KALY5s6eg6VdA8TvClRy2TTm9tIRt//TJo5JxBoTYujawGNSR7ryODj2UEDQ2xOyWSagxAXZpispdrO5jHxRmBZUwX9vxnAp+CNWxifpu9sINJTlqYsT/KlGOJQC483gv5B6Nm5VBB1DRFmQkohzO6Wc2eDixgEbaU795GlLxrNaFfNjVH6Bwr1e7df2H3nE0P0bexs4wYdWplijn4gPyHwjT2LDBPGFQK3Vo2SlaXfPYbkIHX21c9qaz3eWHpLEXUBQfnWc=",
"eyJ0aW1lc3RhbXAiOjE1MzE3MTcxNjY3MDAsInByb2ZpbGVJZCI6IjYwNmUyZmYwZWQ3NzQ4NDI5ZDZjZTFkMzMyMWM3ODM4IiwicHJvZmlsZU5hbWUiOiJNSEZfUXVlc3Rpb24iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlL2QzNGUwNjNjYWZiNDY3YTVjOGRlNDNlYzc4NjE5Mzk5ZjM2OWY0YTUyNDM0ZGE4MDE3YTk4M2NkZDkyNTE2YTAifX19"),
configLoad.getString("Menu.Leaderboard.Leaderboard.Item.Empty.Displayname")

View File

@ -2,6 +2,8 @@ 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;
import com.songoda.skyblock.cooldown.Cooldown;
@ -19,9 +21,7 @@ import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.core.utils.NumberUtils;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.item.SkullUtil;
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;
@ -140,7 +140,7 @@ public class Levelling {
cooldownManager.createPlayer(CooldownType.Levelling, Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID()));
levellingManager.startScan(player, island);
});
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
} else if ((is.getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial()) && (is.hasItemMeta())) {
PlayerData playerData1 = plugin.getPlayerDataManager().getPlayerData(player);
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Menu.Levelling.Item.Previous.Displayname")))) {
@ -216,14 +216,14 @@ public class Levelling {
nInv.addItem(nInv.createItem(CompatibleMaterial.BLACK_STAINED_GLASS_PANE.getItem(), configLoad.getString("Menu.Levelling.Item.Barrier.Displayname"), null, null, null, null), 9, 10, 11, 12, 13, 14, 15, 16, 17);
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Levelling.Item.Previous.Displayname"), null, null, null, null), 1);
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Levelling.Item.Next.Displayname"), null, null, null, null), 7);
@ -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();

View File

@ -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.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
@ -12,10 +13,8 @@ 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.core.utils.NumberUtils;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.StringUtil;
import com.songoda.skyblock.utils.item.SkullUtil;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import org.bukkit.Bukkit;
@ -126,7 +125,7 @@ public class Members {
event.setWillClose(false);
event.setWillDestroy(false);
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
} else if ((is.getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Members.Item.Previous.Displayname")))) {
playerData.setPage(MenuType.MEMBERS, playerData.getPage(MenuType.MEMBERS) - 1);
@ -348,14 +347,14 @@ public class Members {
9, 10, 11, 12, 13, 14, 15, 16, 17);
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Members.Item.Previous.Displayname"), null, null, null, null), 1);
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Members.Item.Next.Displayname"), null, null, null, null), 7);
@ -560,7 +559,7 @@ public class Members {
}
nInv.addItem(
nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]),
nInv.createItem(ItemUtils.getCustomHead(playerTexture[0], playerTexture[1]),
configLoad.getString("Menu.Members.Item.Member.Displayname").replace("%player",
playerName),
itemLore,

View File

@ -2,8 +2,9 @@ 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;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
@ -12,8 +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.SkullUtil;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import org.bukkit.Bukkit;
@ -26,7 +25,6 @@ import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.io.File;
import java.util.UUID;
public class Ownership {
@ -81,7 +79,7 @@ public class Ownership {
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Ownership.Item.Exit.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.BLOCK_CHEST_CLOSE.getSound(), 1.0F, 1.0F);
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())
} else if ((is.getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial()) && (is.hasItemMeta())
&& (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Ownership.Item.Original.Displayname"))))) {
soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_YES.getSound(), 1.0F, 1.0F);
@ -102,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);
@ -125,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);
@ -138,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('&',
@ -179,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);
@ -202,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);
@ -221,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);
}
}
@ -248,7 +240,7 @@ public class Ownership {
nInv.addItem(nInv.createItem(CompatibleMaterial.OAK_FENCE_GATE.getItem(),
configLoad.getString("Menu.Ownership.Item.Exit.Displayname"), null, null, null, null), 0);
nInv.addItem(nInv.createItem(SkullUtil.create(playerTexture[0], playerTexture[1]),
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(playerTexture[0], playerTexture[1]),
configLoad.getString("Menu.Ownership.Item.Original.Displayname"),
configLoad.getStringList("Menu.Ownership.Item.Original.Lore"),
new Placeholder[]{new Placeholder("%player", originalOwnerName)}, null, null), 1);

View File

@ -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()

View File

@ -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);

View File

@ -2,10 +2,10 @@ package com.songoda.skyblock.menus;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.api.event.player.PlayerVoteEvent;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
import com.songoda.skyblock.island.Island;
import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.island.IslandRole;
@ -17,7 +17,6 @@ import com.songoda.skyblock.playerdata.PlayerDataManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.core.utils.NumberUtils;
import com.songoda.skyblock.utils.StringUtil;
import com.songoda.skyblock.utils.item.SkullUtil;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.visit.VisitManager;
@ -29,7 +28,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.*;
public class Visit {
@ -116,7 +114,7 @@ public class Visit {
event.setWillClose(false);
event.setWillDestroy(false);
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
} else if ((is.getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Visit.Item.Previous.Displayname")))) {
playerData.setPage(MenuType.VISIT, playerData.getPage(MenuType.VISIT) - 1);
@ -363,14 +361,14 @@ public class Visit {
9, 10, 11, 12, 13, 14, 15, 16, 17);
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Visit.Item.Previous.Displayname"), null, null, null, null), 1);
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Visit.Item.Next.Displayname"), null, null, null, null), 7);
@ -477,7 +475,7 @@ public class Visit {
}
}
nInv.addItem(nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]),
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(targetPlayerTexture[0], targetPlayerTexture[1]),
configLoad.getString("Menu.Visit.Item.Island.Displayname").replace("%player",
targetPlayerName),
itemLore,
@ -513,7 +511,7 @@ public class Visit {
.getStringList("Menu.Visit.Item.Island.Vote.Disabled.Signature.Disabled.Lore"));
}
nInv.addItem(nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]),
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(targetPlayerTexture[0], targetPlayerTexture[1]),
configLoad.getString("Menu.Visit.Item.Island.Displayname").replace("%player",
targetPlayerName),
itemLore,

View File

@ -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.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.island.Island;
@ -12,9 +13,7 @@ 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.core.utils.NumberUtils;
import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.item.SkullUtil;
import com.songoda.skyblock.utils.item.nInventoryUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -24,7 +23,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.*;
public class Visitors {
@ -91,7 +89,7 @@ public class Visitors {
event.setWillClose(false);
event.setWillDestroy(false);
} else if ((is.getType() == SkullUtil.createItemStack().getType()) && (is.hasItemMeta())) {
} else if ((is.getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial()) && (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Visitors.Item.Previous.Displayname")))) {
playerData.setPage(MenuType.VISITORS, playerData.getPage(MenuType.VISITORS) - 1);
@ -188,14 +186,14 @@ public class Visitors {
int playerMenuPage = playerData.getPage(MenuType.VISITORS), nextEndIndex = sortedIslandVisitors.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Visitors.Item.Previous.Displayname"), null, null, null, null), 1);
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Visitors.Item.Next.Displayname"), null, null, null, null), 7);
@ -275,7 +273,7 @@ public class Visitors {
}
nInv.addItem(
nInv.createItem(SkullUtil.create(targetPlayerTexture[0], targetPlayerTexture[1]),
nInv.createItem(ItemUtils.getCustomHead(targetPlayerTexture[0], targetPlayerTexture[1]),
ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Visitors.Item.Visitor.Displayname")
.replace("%player", targetPlayer.getName())),

View File

@ -2,6 +2,9 @@ package com.songoda.skyblock.menus.admin;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.gui.AnvilGui;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
@ -13,10 +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.SkullUtil;
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;
@ -78,7 +78,7 @@ public class Creator implements Listener {
int playerMenuPage = playerData.getPage(MenuType.ADMIN_CREATOR), nextEndIndex = structures.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Admin.Creator.Browse.Item.Previous.Displayname"), null, null, null,
@ -86,7 +86,7 @@ public class Creator implements Listener {
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Admin.Creator.Browse.Item.Next.Displayname"), null, null, null,
@ -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 {

View File

@ -2,6 +2,9 @@ package com.songoda.skyblock.menus.admin;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.gui.AnvilGui;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
@ -13,10 +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.SkullUtil;
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;
@ -78,7 +78,7 @@ public class Generator implements Listener {
int playerMenuPage = playerData.getPage(MenuType.ADMIN_GENERATOR), nextEndIndex = generators.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Admin.Generator.Browse.Item.Previous.Displayname"), null, null, null,
@ -86,7 +86,7 @@ public class Generator implements Listener {
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Admin.Generator.Browse.Item.Next.Displayname"), null, null, null,
@ -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())
@ -384,7 +378,7 @@ public class Generator implements Listener {
return;
}
} else if ((event.getCurrentItem().getType() == SkullUtil.createItemStack().getType())
} else if ((event.getCurrentItem().getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial())
&& (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Generator.Browse.Item.Previous.Displayname")))) {
@ -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);

View File

@ -2,6 +2,9 @@ package com.songoda.skyblock.menus.admin;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.gui.AnvilGui;
import com.songoda.core.utils.ItemUtils;
import com.songoda.skyblock.SkyBlock;
import com.songoda.skyblock.config.FileManager;
import com.songoda.skyblock.config.FileManager.Config;
@ -12,11 +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.SkullUtil;
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;
@ -97,14 +97,14 @@ public class Levelling implements Listener {
int playerMenuPage = playerData.getPage(MenuType.ADMIN_LEVELLING), nextEndIndex = levellingMaterials.size() - playerMenuPage * 36;
if (playerMenuPage != 1) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"ToR1w9ZV7zpzCiLBhoaJH3uixs5mAlMhNz42oaRRvrG4HRua5hC6oyyOPfn2HKdSseYA9b1be14fjNRQbSJRvXF3mlvt5/zct4sm+cPVmX8K5kbM2vfwHJgCnfjtPkzT8sqqg6YFdT35mAZGqb9/xY/wDSNSu/S3k2WgmHrJKirszaBZrZfnVnqITUOgM9TmixhcJn2obeqICv6tl7/Wyk/1W62wXlXGm9+WjS+8rRNB+vYxqKR3XmH2lhAiyVGbADsjjGtBVUTWjq+aPw670SjXkoii0YE8sqzUlMMGEkXdXl9fvGtnWKk3APSseuTsjedr7yq+AkXFVDqqkqcUuXwmZl2EjC2WRRbhmYdbtY5nEfqh5+MiBrGdR/JqdEUL4yRutyRTw8mSUAI6X2oSVge7EdM/8f4HwLf33EO4pTocTqAkNbpt6Z54asLe5Y12jSXbvd2dFsgeJbrslK7e4uy/TK8CXf0BP3KLU20QELYrjz9I70gtj9lJ9xwjdx4/xJtxDtrxfC4Afmpu+GNYA/mifpyP3GDeBB5CqN7btIvEWyVvRNH7ppAqZIPqYJ7dSDd2RFuhAId5Yq98GUTBn+eRzeigBvSi1bFkkEgldfghOoK5WhsQtQbXuBBXITMME3NaWCN6zG7DxspS6ew/rZ8E809Xe0ArllquIZ0sP+k=",
"eyJ0aW1lc3RhbXAiOjE0OTU3NTE5MTYwNjksInByb2ZpbGVJZCI6ImE2OGYwYjY0OGQxNDQwMDBhOTVmNGI5YmExNGY4ZGY5IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dMZWZ0Iiwic2lnbmF0dXJlUmVxdWlyZWQiOnRydWUsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS8zZWJmOTA3NDk0YTkzNWU5NTViZmNhZGFiODFiZWFmYjkwZmI5YmU0OWM3MDI2YmE5N2Q3OThkNWYxYTIzIn19fQ=="),
configLoad.getString("Menu.Admin.Levelling.Item.Previous.Displayname"), null, null, null, null), 1);
}
if (!(nextEndIndex == 0 || nextEndIndex < 0)) {
nInv.addItem(nInv.createItem(SkullUtil.create(
nInv.addItem(nInv.createItem(ItemUtils.getCustomHead(
"wZPrsmxckJn4/ybw/iXoMWgAe+1titw3hjhmf7bfg9vtOl0f/J6YLNMOI0OTvqeRKzSQVCxqNOij6k2iM32ZRInCQyblDIFmFadQxryEJDJJPVs7rXR6LRXlN8ON2VDGtboRTL7LwMGpzsrdPNt0oYDJLpR0huEeZKc1+g4W13Y4YM5FUgEs8HvMcg4aaGokSbvrYRRcEh3LR1lVmgxtbiUIr2gZkR3jnwdmZaIw/Ujw28+Et2pDMVCf96E5vC0aNY0KHTdMYheT6hwgw0VAZS2VnJg+Gz4JCl4eQmN2fs4dUBELIW2Rdnp4U1Eb+ZL8DvTV7ofBeZupknqPOyoKIjpInDml9BB2/EkD3zxFtW6AWocRphn03Z203navBkR6ztCMz0BgbmQU/m8VL/s8o4cxOn+2ppjrlj0p8AQxEsBdHozrBi8kNOGf1j97SDHxnvVAF3X8XDso+MthRx5pbEqpxmLyKKgFh25pJE7UaMSnzH2lc7aAZiax67MFw55pDtgfpl+Nlum4r7CK2w5Xob2QTCovVhu78/6SV7qM2Lhlwx/Sjqcl8rn5UIoyM49QE5Iyf1tk+xHXkIvY0m7q358oXsfca4eKmxMe6DFRjUDo1VuWxdg9iVjn22flqz1LD1FhGlPoqv0k4jX5Q733LwtPPI6VOTK+QzqrmiuR6e8=",
"eyJ0aW1lc3RhbXAiOjE0OTM4NjgxMDA2NzMsInByb2ZpbGVJZCI6IjUwYzg1MTBiNWVhMDRkNjBiZTlhN2Q1NDJkNmNkMTU2IiwicHJvZmlsZU5hbWUiOiJNSEZfQXJyb3dSaWdodCIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWI2ZjFhMjViNmJjMTk5OTQ2NDcyYWVkYjM3MDUyMjU4NGZmNmY0ZTgzMjIxZTU5NDZiZDJlNDFiNWNhMTNiIn19fQ=="),
configLoad.getString("Menu.Admin.Levelling.Item.Next.Displayname"), null, null, null, null), 7);
@ -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())
@ -270,7 +265,7 @@ public class Levelling implements Listener {
soundManager.playSound(player, CompatibleSound.BLOCK_ANVIL_LAND.getSound(), 1.0F, 1.0F);
return;
} else if ((event.getCurrentItem().getType() == SkullUtil.createItemStack().getType())
} else if ((event.getCurrentItem().getType() == CompatibleMaterial.PLAYER_HEAD.getMaterial())
&& (is.hasItemMeta())) {
if (is.getItemMeta().getDisplayName().equals(ChatColor.translateAlternateColorCodes('&',
configLoad.getString("Menu.Admin.Levelling.Item.Previous.Displayname")))) {
@ -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

View File

@ -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;

View File

@ -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;

View File

@ -72,15 +72,19 @@ public class PortalPermission extends ListeningPermission {
IslandManager islandManager = plugin.getIslandManager();
Island island = islandManager.getIslandAtLocation(from);
Location to = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
if(island.hasRole(IslandRole.Visitor, player.getUniqueId())){
if(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
if (island.hasRole(IslandRole.Visitor, player.getUniqueId())) {
if (plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "config.yml"))
.getFileConfiguration().getBoolean("Island.Teleport.SafetyCheck", true)) {
Location safeLoc = LocationUtil.getSafeLocation(island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor));
if (safeLoc != null) {
to = safeLoc;
Location isLoc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Visitor);
if (isLoc != null) {
Location safeLoc = LocationUtil.getSafeLocation(isLoc);
if (safeLoc != null) {
to = safeLoc;
}
}
}
if(to == null){
if (to == null) {
to = LocationUtil.getSpawnLocation();
}
}

View File

@ -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());

View File

@ -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;
}
}
}

View File

@ -1,168 +0,0 @@
package com.songoda.skyblock.utils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class Reflections {
public static String cbVer() {
return "org.bukkit.craftbukkit."+ver()+".";
}
public static String nmsVer() {
return "net.minecraft.server."+ver()+".";
}
public static String ver() {
String pkg = Bukkit.getServer().getClass().getPackage().getName();
return pkg.substring(pkg.lastIndexOf(".") + 1);
}
public static Class<?> wrapperToPrimitive(Class<?> clazz) {
if(clazz == Boolean.class) return boolean.class;
if(clazz == Integer.class) return int.class;
if(clazz == Double.class) return double.class;
if(clazz == Float.class) return float.class;
if(clazz == Long.class) return long.class;
if(clazz == Short.class) return short.class;
if(clazz == Byte.class) return byte.class;
if(clazz == Void.class) return void.class;
if(clazz == Character.class) return char.class;
return clazz;
}
public static Class<?>[] toParamTypes(Object... params) {
Class<?>[] classes = new Class<?>[params.length];
for(int i = 0; i < params.length; i++)
classes[i] = wrapperToPrimitive(params[i].getClass());
return classes;
}
public static Object getHandle(Entity e) {
return callMethod(e, "getHandle");
}
public static Object getHandle(World w) {
return callMethod(w, "getHandle");
}
public static Object playerConnection(Player p) {
return playerConnection(getHandle(p));
}
public static Object playerConnection(Object handle) {
return getDeclaredField(handle, "playerConnection");
}
public static void sendPacket(Player p, Object packet) {
Object pc = playerConnection(p);
try {
pc.getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(pc, packet);
} catch(Exception e) {
e.printStackTrace();
}
}
public static Object getPacket(String name, Object... params) {
return callDeclaredConstructor(getNMSClass(name), params);
}
public static void sendJson(Player p, String json) {
Object comp = callDeclaredMethod(getNMSClass("ChatSerializer"),
"a", json);
sendPacket(p, getPacket("PacketPlayOutChat", comp, true));
}
public static Class<?> getClass(String name) {
try {
return Class.forName(name);
} catch(Exception e) {
return null;
}
}
public static Class<?> getNMSClass(String name) {
return getClass(nmsVer()+name);
}
public static Class<?> getCBClass(String name) {
return getClass(cbVer()+name);
}
public static Object callDeclaredMethod(Object object, String method, Object... params) {
try {
Method m = object.getClass().getDeclaredMethod(method, toParamTypes(params));
m.setAccessible(true);
return m.invoke(object, params);
} catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static Object callMethod(Object object, String method, Object... params) {
try {
Method m = object.getClass().getMethod(method, toParamTypes(params));
m.setAccessible(true);
return m.invoke(object, params);
} catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static Object callDeclaredConstructor(Class<?> clazz, Object... params) {
try {
Constructor<?> con = clazz.getDeclaredConstructor(toParamTypes(params));
con.setAccessible(true);
return con.newInstance(params);
} catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static Object callConstructor(Class<?> clazz, Object... params) {
try {
Constructor<?> con = clazz.getConstructor(toParamTypes(params));
con.setAccessible(true);
return con.newInstance(params);
} catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static Object getDeclaredField(Object object, String field) {
try {
Field f = object.getClass().getDeclaredField(field);
f.setAccessible(true);
return f.get(object);
} catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static Object getField(Object object, String field) {
try {
Field f = object.getClass().getField(field);
f.setAccessible(true);
return f.get(object);
} catch(Exception e) {
e.printStackTrace();
return null;
}
}
public static void setDeclaredField(Object object, String field, Object value) {
try {
Field f = object.getClass().getDeclaredField(field);
f.setAccessible(true);
f.set(object, value);
} catch(Exception e) {
e.printStackTrace();
}
}
public static void setField(Object object, String field, Object value) {
try {
Field f = object.getClass().getField(field);
f.setAccessible(true);
f.set(object, value);
} catch(Exception e) {
e.printStackTrace();
}
}
}

View File

@ -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;
}

View File

@ -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();

View File

@ -1,70 +0,0 @@
package com.songoda.skyblock.utils.item;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.songoda.core.compatibility.CompatibleMaterial;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
import java.util.Base64;
import java.util.UUID;
public final class SkullUtil {
public static ItemStack create(String skinTexture) {
ItemStack is = createItemStack();
SkullMeta sm = (SkullMeta) is.getItemMeta();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null);
byte[] encodedData = Base64.getEncoder()
.encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", skinTexture).getBytes());
gameProfile.getProperties().put("textures", new Property("textures", new String(encodedData)));
Field profileField;
try {
profileField = sm.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(sm, gameProfile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
e1.printStackTrace();
}
is.setItemMeta(sm);
return is;
}
public static ItemStack create(String signature, String value) {
if (signature == null || signature.isEmpty() || value == null || value.isEmpty()) {
signature = "K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVsATJfwsAIZGS+9OZ5T2HB0tWBoxRvZNi73Vr+syRdvTLUWPusVXIg+2fhXmQoaNEtnQvQVGQpjdQP0TkZtYG8PbvRxE6Z75ddq+DVx/65OSNHLWIB/D+Rg4vINh4ukXNYttn9QvauDHh1aW7/IkIb1Bc0tLcQyqxZQ3mdglxJfgIerqnlA++Lt7TxaLdag4y1NhdZyd3OhklF5B0+B9zw/qP8QCzsZU7VzJIcds1+wDWKiMUO7+60OSrIwgE9FPamxOQDFoDvz5BOULQEeNx7iFMB+eBYsapCXpZx0zf1bduppBUbbVC9wVhto/J4tc0iNyUq06/esHUUB5MHzdJ0Y6IZJAD/xIw15OLCUH2ntvs8V9/cy5/n8u3JqPUM2zhUGeQ2p9FubUGk4Q928L56l3omRpKV+5QYTrvF+AxFkuj2hcfGQG3VE2iYZO6omXe7nRPpbJlHkMKhE8Xvd1HP4PKpgivSkHBoZ92QEUAmRzZydJkp8CNomQrZJf+MtPiNsl/Q5RQM+8CQThg3+4uWptUfP5dDFWOgTnMdA0nIODyrjpp+bvIJnsohraIKJ7ZDnj4tIp4ObTNKDFC/8j8JHz4VCrtr45mbnzvB2DcK8EIB3JYT7ElJTHnc5BKMyLy5SKzuw=";
value = "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19";
}
ItemStack is = createItemStack();
SkullMeta sm = (SkullMeta) is.getItemMeta();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null);
gameProfile.getProperties().put("textures", new Property("textures", value, signature));
Field profileField;
try {
profileField = sm.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(sm, gameProfile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
e1.printStackTrace();
}
is.setItemMeta(sm);
return is;
}
public static ItemStack createItemStack() {
return CompatibleMaterial.PLAYER_HEAD.getItem();
}
}

View File

@ -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();

View File

@ -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() + "}");

View File

@ -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);

View File

@ -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();
}
}
}

View File

@ -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;

View File

@ -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

View File

@ -1,90 +0,0 @@
package com.songoda.skyblock.utils.world;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.skyblock.utils.version.NMSUtil;
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
}
}

View File

@ -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) {

View File

@ -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()));

View File

@ -210,7 +210,7 @@ Command:
NullIsland:
Message: '&bSkyBlock &8| &cError&8: &eYou are not on an island, please specify a Player or move to an island. Or maybe you are on nullisland?'
ByConsole:
Message: '&bSkyBlock &8| &cError&8: &eIf you are using it from the console, you need to use like this: /island admin bank [Player] [<Deposit|Withdraw|Balance>] [Ammount]'
Message: '&bSkyBlock &8| &cError&8: &eIf you are using it from the console, you need to use like this: /island admin bank [Player] [<Deposit|Withdraw|Balance>] [Amount]'
Balance:
Message: ' %player% have %bal%.'
Info: