diff --git a/build.gradle.kts b/build.gradle.kts index a9a5376..eba19f1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ plugins { } group = "me.lojosho" -version = "0.6.0${getGitCommitHash()}" +version = "0.6.1${getGitCommitHash()}" allprojects { apply(plugin = "java") diff --git a/common/src/main/java/me/lojosho/hibiscuscommons/HibiscusCommonsPlugin.java b/common/src/main/java/me/lojosho/hibiscuscommons/HibiscusCommonsPlugin.java index 22bcae2..cc15c94 100644 --- a/common/src/main/java/me/lojosho/hibiscuscommons/HibiscusCommonsPlugin.java +++ b/common/src/main/java/me/lojosho/hibiscuscommons/HibiscusCommonsPlugin.java @@ -20,13 +20,6 @@ public final class HibiscusCommonsPlugin extends HibiscusPlugin { public void onStart() { instance = this; - try { - NMSHandlers.setup(); - } catch (RuntimeException e) { - getServer().getPluginManager().disablePlugin(this); - return; - } - // Detects if a user is running a paper server if (ServerUtils.hasClass("com.destroystokyo.paper.PaperConfig") || ServerUtils.hasClass("io.papermc.paper.configuration.Configuration")) { onPaper = true; @@ -38,6 +31,13 @@ public final class HibiscusCommonsPlugin extends HibiscusPlugin { getLogger().warning("Download Paper at: https://papermc.io/"); } + try { + NMSHandlers.setup(); + } catch (RuntimeException e) { + getServer().getPluginManager().disablePlugin(this); + return; + } + // Plugin startup logic Hooks.setup(); diff --git a/common/src/main/java/me/lojosho/hibiscuscommons/HibiscusPlugin.java b/common/src/main/java/me/lojosho/hibiscuscommons/HibiscusPlugin.java index 6992540..f56c3cc 100644 --- a/common/src/main/java/me/lojosho/hibiscuscommons/HibiscusPlugin.java +++ b/common/src/main/java/me/lojosho/hibiscuscommons/HibiscusPlugin.java @@ -63,12 +63,13 @@ public abstract class HibiscusPlugin extends JavaPlugin { .onSuccess((commandSenders, latestVersion) -> { this.latestVersion = (String) latestVersion; String pluginName = getDescription().getName(); + String version = getDescription().getVersion(); - if (!this.latestVersion.equalsIgnoreCase(getDescription().getVersion())) { + if (!this.latestVersion.equalsIgnoreCase(version)) { getLogger().info("+++++++++++++++++++++++++++++++++++"); getLogger().info("There is a new update for " + pluginName + "!"); getLogger().info("Please download it as soon as possible for possible fixes and new features."); - getLogger().info("Current Version " + getDescription().getVersion() + " | Latest Version " + latestVersion); + getLogger().info("Current Version " + version + " | Latest Version " + latestVersion); //getLogger().info("Spigot: https://www.spigotmc.org/resources/100107/"); getLogger().info("Polymart: https://polymart.org/resource/" + resourceID); getLogger().info("+++++++++++++++++++++++++++++++++++"); diff --git a/common/src/main/java/me/lojosho/hibiscuscommons/config/serializer/ItemSerializer.java b/common/src/main/java/me/lojosho/hibiscuscommons/config/serializer/ItemSerializer.java index d408fcf..e35f41d 100644 --- a/common/src/main/java/me/lojosho/hibiscuscommons/config/serializer/ItemSerializer.java +++ b/common/src/main/java/me/lojosho/hibiscuscommons/config/serializer/ItemSerializer.java @@ -81,11 +81,8 @@ public class ItemSerializer implements TypeSerializer { if (itemMeta == null) return item; if (!nameNode.virtual()) { - if (HibiscusCommonsPlugin.isOnPaper()) { - itemMeta.displayName(AdventureUtils.MINI_MESSAGE.deserialize(nameNode.getString(""))); - } else { - itemMeta.setDisplayName(StringUtils.parseStringToString(nameNode.getString(""))); - } + if (HibiscusCommonsPlugin.isOnPaper()) itemMeta.displayName(AdventureUtils.MINI_MESSAGE.deserialize(nameNode.getString(""))); + else itemMeta.setDisplayName(StringUtils.parseStringToString(nameNode.getString(""))); } if (!unbreakableNode.virtual()) itemMeta.setUnbreakable(unbreakableNode.getBoolean()); if (!glowingNode.virtual()) { @@ -93,13 +90,12 @@ public class ItemSerializer implements TypeSerializer { itemMeta.addEnchant(Enchantment.LUCK, 1, true); } if (!loreNode.virtual()) { - if (HibiscusCommonsPlugin.isOnPaper()) { + if (HibiscusCommonsPlugin.isOnPaper()) itemMeta.lore(loreNode.getList(String.class, new ArrayList<>()). stream().map(AdventureUtils.MINI_MESSAGE::deserialize).collect(Collectors.toList())); - } else { - itemMeta.setLore(loreNode.getList(String.class, new ArrayList<>()). + else itemMeta.setLore(loreNode.getList(String.class, new ArrayList<>()). stream().map(StringUtils::parseStringToString).collect(Collectors.toList())); - } + } if (!modelDataNode.virtual()) itemMeta.setCustomModelData(modelDataNode.getInt()); @@ -113,13 +109,13 @@ public class ItemSerializer implements TypeSerializer { for (ConfigurationNode enchantNode : enchantsNode.childrenMap().values()) { String enchantName = enchantNode.key().toString().toLowerCase(); NamespacedKey key = NamespacedKey.minecraft(enchantName); - Enchantment enchant = Enchantment.getByKey(key); + Enchantment enchant = Registry.ENCHANTMENT.get(key); if (enchant == null) continue; itemMeta.addEnchant(enchant, enchantNode.getInt(1), true); } } - try { + if (!itemFlagsNode.virtual()) { for (String itemFlag : itemFlagsNode.getList(String.class)) { if (!EnumUtils.isValidEnum(ItemFlag.class, itemFlag)) continue; @@ -127,9 +123,6 @@ public class ItemSerializer implements TypeSerializer { itemMeta.addItemFlags(ItemFlag.valueOf(itemFlag)); } } - } catch (Exception e) { - e.printStackTrace(); - } if (item.getType() == Material.PLAYER_HEAD) { SkullMeta skullMeta = (SkullMeta) itemMeta; @@ -150,7 +143,7 @@ public class ItemSerializer implements TypeSerializer { skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullTexture(), PersistentDataType.STRING, textureString); } // Decodes the texture string and sets the texture url to the skull - PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID()); + PlayerProfile profile = Bukkit.createProfile(UUID.randomUUID()); PlayerTextures textures = profile.getTextures(); String decoded = new String(Base64.getDecoder().decode(textureString)); @@ -166,7 +159,6 @@ public class ItemSerializer implements TypeSerializer { skullMeta.setOwnerProfile(profile); } } - itemMeta = skullMeta; } if (!colorNode.virtual()) { @@ -186,6 +178,5 @@ public class ItemSerializer implements TypeSerializer { public void serialize(final Type type, @Nullable final ItemStack obj, final ConfigurationNode node) throws SerializationException { } - } diff --git a/common/src/main/java/me/lojosho/hibiscuscommons/util/ServerUtils.java b/common/src/main/java/me/lojosho/hibiscuscommons/util/ServerUtils.java index 014e9bc..4d6ffaf 100644 --- a/common/src/main/java/me/lojosho/hibiscuscommons/util/ServerUtils.java +++ b/common/src/main/java/me/lojosho/hibiscuscommons/util/ServerUtils.java @@ -2,6 +2,7 @@ package me.lojosho.hibiscuscommons.util; import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedSignedProperty; +import me.lojosho.hibiscuscommons.HibiscusCommonsPlugin; import me.lojosho.hibiscuscommons.nms.NMSHandlers; import org.bukkit.Color; import org.bukkit.entity.Entity; @@ -104,6 +105,7 @@ public class ServerUtils { */ @NotNull public static List getViewers(@NotNull Entity entity) { + if (HibiscusCommonsPlugin.isOnPaper()) return List.copyOf(entity.getTrackedBy()); ArrayList viewers = new ArrayList<>(); for (Player player : entity.getLocation().getWorld().getPlayers()) { if (player.canSee(entity)) viewers.add(player); diff --git a/gradle.properties b/gradle.properties index d36e203..14a7ad3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -userdevVersion=2.0.0-beta.11 \ No newline at end of file +userdevVersion=2.0.0-beta.14 \ No newline at end of file