diff --git a/build.gradle b/build.gradle index 10c6de4e..9fd79de3 100644 --- a/build.gradle +++ b/build.gradle @@ -51,7 +51,7 @@ allprojects { } dependencies { - compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT' + compileOnly 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT' compileOnly 'org.jetbrains:annotations:19.0.0' // Lombok diff --git a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java index 775e81da..0cc874a1 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java +++ b/eco-api/src/main/java/com/willfp/eco/core/EcoPlugin.java @@ -23,7 +23,6 @@ import com.willfp.eco.internal.factory.EcoNamespacedKeyFactory; import com.willfp.eco.internal.factory.EcoRunnableFactory; import com.willfp.eco.internal.integration.PlaceholderIntegrationPAPI; import com.willfp.eco.internal.scheduling.EcoScheduler; -import com.willfp.eco.util.Prerequisite; import lombok.Getter; import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.bstats.bukkit.Metrics; diff --git a/eco-api/src/main/java/com/willfp/eco/util/Prerequisite.java b/eco-api/src/main/java/com/willfp/eco/core/Prerequisite.java similarity index 86% rename from eco-api/src/main/java/com/willfp/eco/util/Prerequisite.java rename to eco-api/src/main/java/com/willfp/eco/core/Prerequisite.java index bb158b09..81270915 100644 --- a/eco-api/src/main/java/com/willfp/eco/util/Prerequisite.java +++ b/eco-api/src/main/java/com/willfp/eco/core/Prerequisite.java @@ -1,6 +1,6 @@ -package com.willfp.eco.util; +package com.willfp.eco.core; -import com.willfp.eco.core.proxy.ProxyConstants; +import com.willfp.eco.util.ClassUtils; import lombok.Getter; import org.jetbrains.annotations.NotNull; @@ -14,15 +14,6 @@ public class Prerequisite { * All existing prerequisites are registered on creation. */ private static final List VALUES = new ArrayList<>(); - - /** - * Requires the server to be running minecraft version 1.16 or higher. - */ - public static final Prerequisite MINIMUM_1_16 = new Prerequisite( - () -> !ProxyConstants.NMS_VERSION.contains("15"), - "Requires minimum server version of 1.16" - ); - /** * Requires the server to be running an implementation of paper. */ diff --git a/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java b/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java deleted file mode 100644 index de291221..00000000 --- a/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.willfp.eco.core.fast; - -import com.willfp.eco.internal.fast.AbstractFastItemStackHandler; -import com.willfp.eco.internal.fast.FastItemStackHandlerFactory; -import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.persistence.PersistentDataType; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class FastItemStack { - /** - * The ItemStack handler. - */ - private static FastItemStackHandlerFactory factory; - - /** - * The ItemStack to interface with. - */ - private final AbstractFastItemStackHandler handle; - - /** - * Create a new fast ItemStack. - * - * @param itemStack The ItemStack. - */ - public FastItemStack(@NotNull final ItemStack itemStack) { - this.handle = factory.create(itemStack); - } - - /** - * Get the enchantments on the item. - * - * @return The enchantments. - */ - public Map getEnchantments() { - return handle.getEnchantments(); - } - - /** - * Get the level of a specific enchantment. - * - * @param enchantment The enchantments. - * @return The level, or 0 if not found. - */ - public int getEnchantmentLevel(@NotNull final Enchantment enchantment) { - return handle.getEnchantmentLevel(enchantment); - } - - /** - * Get the lore of an item. - * - * @return The lore. - */ - public List getLore() { - return handle.getLore(); - } - - /** - * Set the lore of an item. - * - * @param lore The lore. - */ - public void setLore(@NotNull final List lore) { - handle.setLore(lore); - } - - /** - * Get the item flags on an item. - * - * @return The item flags. - */ - public Set getItemFlags() { - return handle.getItemFlags(); - } - - /** - * Set the item flags on an item. - * - * @param flags The flags. - */ - public void setItemFlags(@NotNull final Set flags) { - handle.setItemFlags(flags); - } - - /** - * Write a key in persistent meta. - * - * @param key The key. - * @param type The type. - * @param value The value. - * @param The type. - * @param The type. - */ - public void writePersistentKey(@NotNull final NamespacedKey key, - @NotNull final PersistentDataType type, - @NotNull final Z value) { - handle.writePersistentKey(key, type, value); - } - - /** - * Read a key from persistent meta. - * - * @param key The key. - * @param type The type. - * @param The type. - * @param The type. - * @return The value. - */ - public Z readPersistentKey(@NotNull final NamespacedKey key, - @NotNull final PersistentDataType type) { - return handle.readPersistentKey(key, type); - } - - /** - * Get persistent meta keys. - * - * @return The keys. - */ - public Set getPersistentKeys() { - return handle.getPersistentKeys(); - } - - /** - * Get the display name - * - * @return The display name. - */ - public String getDisplayName() { - return handle.getDisplayName(); - } - - /** - * Set the display name. - * - * @param name The name. - */ - public void setDisplayName(@NotNull final String name) { - handle.setDisplayName(name); - } - - /** - * Apply changes. - */ - public void apply() { - handle.apply(); - } - - /** - * Initialize the ItemStack handler factory. - * - * @param handlerFactory The handler factory. - */ - @ApiStatus.Internal - public static void initialize(@NotNull final FastItemStackHandlerFactory handlerFactory) { - factory = handlerFactory; - } -} diff --git a/eco-api/src/main/java/com/willfp/eco/internal/fast/AbstractFastItemStackHandler.java b/eco-api/src/main/java/com/willfp/eco/internal/fast/AbstractFastItemStackHandler.java deleted file mode 100644 index 434baf7a..00000000 --- a/eco-api/src/main/java/com/willfp/eco/internal/fast/AbstractFastItemStackHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.eco.internal.fast; - -import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.persistence.PersistentDataType; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -public interface AbstractFastItemStackHandler { - Map getEnchantments(); - - int getEnchantmentLevel(@NotNull Enchantment enchantment); - - List getLore(); - - void setLore(@NotNull List lore); - - Set getItemFlags(); - - void setItemFlags(@NotNull Set flags); - - void writePersistentKey(@NotNull NamespacedKey key, - @NotNull PersistentDataType type, - @NotNull Z value); - - Z readPersistentKey(@NotNull NamespacedKey key, - @NotNull PersistentDataType type); - - Set getPersistentKeys(); - - String getDisplayName(); - - void setDisplayName(@NotNull String name); - - void apply(); -} diff --git a/eco-api/src/main/java/com/willfp/eco/internal/fast/FastItemStackHandlerFactory.java b/eco-api/src/main/java/com/willfp/eco/internal/fast/FastItemStackHandlerFactory.java deleted file mode 100644 index 503cc362..00000000 --- a/eco-api/src/main/java/com/willfp/eco/internal/fast/FastItemStackHandlerFactory.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.eco.internal.fast; - -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -public interface FastItemStackHandlerFactory { - /** - * Create new FastItemStackHandler. - * - * @param itemStack The ItemStack to handle. - * @return The handler. - */ - AbstractFastItemStackHandler create(@NotNull ItemStack itemStack); -} diff --git a/eco-api/src/main/java/com/willfp/eco/util/PlayerUtils.java b/eco-api/src/main/java/com/willfp/eco/util/PlayerUtils.java deleted file mode 100644 index 74836d99..00000000 --- a/eco-api/src/main/java/com/willfp/eco/util/PlayerUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.willfp.eco.util; - -import lombok.experimental.UtilityClass; -import org.apache.commons.lang.Validate; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Function; - -@UtilityClass -public class PlayerUtils { - /** - * If the meta set function has been set. - */ - private boolean initialized = false; - - /** - * The cooldown function. - */ - private Function cooldownFunction = null; - - /** - * Get the attack cooldown for a player. - * - * @param player The player's attack cooldown. - * @return A value between 0 and 1, with 1 representing full power. - */ - public double getAttackCooldown(@NotNull final Player player) { - Validate.isTrue(initialized, "Must be initialized!"); - Validate.notNull(cooldownFunction, "Must be initialized!"); - - if (Prerequisite.MINIMUM_1_16.isMet()) { - return player.getAttackCooldown(); - } - - return cooldownFunction.apply(player); - } - - /** - * Initialize the cooldown function. - * - * @param function The function. - */ - @ApiStatus.Internal - public void initialize(@NotNull final Function function) { - Validate.isTrue(!initialized, "Already initialized!"); - - cooldownFunction = function; - - initialized = true; - } -} diff --git a/eco-api/src/main/java/com/willfp/eco/util/StringUtils.java b/eco-api/src/main/java/com/willfp/eco/util/StringUtils.java index 81b8070f..99816695 100644 --- a/eco-api/src/main/java/com/willfp/eco/util/StringUtils.java +++ b/eco-api/src/main/java/com/willfp/eco/util/StringUtils.java @@ -44,9 +44,7 @@ public class StringUtils { public String translate(@NotNull final String message, @Nullable final Player player) { String processedMessage = message; - if (Prerequisite.MINIMUM_1_16.isMet()) { - processedMessage = translateGradients(processedMessage); - } + processedMessage = translateGradients(processedMessage); processedMessage = PlaceholderManager.translatePlaceholders(processedMessage, player); processedMessage = translateHexColorCodes(processedMessage); processedMessage = ChatColor.translateAlternateColorCodes('&', processedMessage); diff --git a/eco-api/src/main/java/com/willfp/eco/util/TeamUtils.java b/eco-api/src/main/java/com/willfp/eco/util/TeamUtils.java index c9bf5aa7..6c61f28e 100644 --- a/eco-api/src/main/java/com/willfp/eco/util/TeamUtils.java +++ b/eco-api/src/main/java/com/willfp/eco/util/TeamUtils.java @@ -79,9 +79,6 @@ public class TeamUtils { MATERIAL_COLORS.forcePut(Material.LAPIS_ORE, ChatColor.BLUE); MATERIAL_COLORS.forcePut(Material.REDSTONE_ORE, ChatColor.RED); MATERIAL_COLORS.forcePut(Material.DIAMOND_ORE, ChatColor.AQUA); - - if (Prerequisite.MINIMUM_1_16.isMet()) { - MATERIAL_COLORS.forcePut(Material.ANCIENT_DEBRIS, ChatColor.DARK_RED); - } + MATERIAL_COLORS.forcePut(Material.ANCIENT_DEBRIS, ChatColor.DARK_RED); } } diff --git a/eco-core/core-nms/v1_15_R1/build.gradle b/eco-core/core-nms/v1_15_R1/build.gradle deleted file mode 100644 index 52cdf754..00000000 --- a/eco-core/core-nms/v1_15_R1/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -group 'com.willfp' -version rootProject.version - -dependencies { - compileOnly 'org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT' -} \ No newline at end of file diff --git a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/AutoCraft.java b/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/AutoCraft.java deleted file mode 100644 index fea87597..00000000 --- a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/AutoCraft.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.willfp.eco.proxy.v1_15_R1; - -import com.willfp.eco.proxy.proxies.AutoCraftProxy; -import net.minecraft.server.v1_15_R1.MinecraftKey; -import net.minecraft.server.v1_15_R1.PacketPlayOutAutoRecipe; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.Field; - -public final class AutoCraft implements AutoCraftProxy { - @Override - public void modifyPacket(@NotNull final Object packet) throws NoSuchFieldException, IllegalAccessException { - PacketPlayOutAutoRecipe recipePacket = (PacketPlayOutAutoRecipe) packet; - Field fKey = recipePacket.getClass().getDeclaredField("b"); - fKey.setAccessible(true); - MinecraftKey key = (MinecraftKey) fKey.get(recipePacket); - fKey.set(recipePacket, new MinecraftKey(key.getNamespace(), key.getKey() + "_displayed")); - } -} diff --git a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/BlockBreak.java b/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/BlockBreak.java deleted file mode 100644 index 789eae66..00000000 --- a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/BlockBreak.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.eco.proxy.v1_15_R1; - -import com.willfp.eco.proxy.proxies.BlockBreakProxy; -import net.minecraft.server.v1_15_R1.BlockPosition; -import org.bukkit.block.Block; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -public final class BlockBreak implements BlockBreakProxy { - @Override - public void breakBlock(@NotNull final Player player, - @NotNull final Block block) { - ((CraftPlayer) player).getHandle().playerInteractManager.breakBlock(new BlockPosition(block.getX(), block.getY(), block.getZ())); - } -} diff --git a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/ChatComponent.java b/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/ChatComponent.java deleted file mode 100644 index 1bbd9fdc..00000000 --- a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/ChatComponent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.willfp.eco.proxy.v1_15_R1; - -import com.willfp.eco.proxy.proxies.ChatComponentProxy; -import org.jetbrains.annotations.NotNull; - -public final class ChatComponent implements ChatComponentProxy { - @Override - public Object modifyComponent(@NotNull final Object object) { - return object; - } -} diff --git a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/Cooldown.java b/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/Cooldown.java deleted file mode 100644 index 4fc88652..00000000 --- a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/Cooldown.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.willfp.eco.proxy.v1_15_R1; - -import com.willfp.eco.proxy.proxies.CooldownProxy; -import net.minecraft.server.v1_15_R1.EntityHuman; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -public final class Cooldown implements CooldownProxy { - @Override - public double getAttackCooldown(@NotNull final Player player) { - EntityHuman entityHuman = ((CraftPlayer) player).getHandle(); - return entityHuman.s(0); - } -} diff --git a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/Skull.java b/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/Skull.java deleted file mode 100644 index 7241699b..00000000 --- a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/Skull.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.willfp.eco.proxy.v1_15_R1; - -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.willfp.eco.proxy.proxies.SkullProxy; -import org.bukkit.inventory.meta.SkullMeta; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.UUID; - -public final class Skull implements SkullProxy { - /** - * Cached method to set the gameProfile. - */ - private Method setProfile = null; - - @Override - public void setSkullTexture(@NotNull final SkullMeta meta, - @NotNull final String base64) { - try { - if (setProfile == null) { - setProfile = meta.getClass().getDeclaredMethod("setProfile", GameProfile.class); - setProfile.setAccessible(true); - } - - UUID uuid = new UUID( - base64.substring(base64.length() - 20).hashCode(), - base64.substring(base64.length() - 10).hashCode() - ); - - GameProfile profile = new GameProfile(uuid, "talismans"); - profile.getProperties().put("textures", new Property("textures", base64)); - - setProfile.invoke(meta, profile); - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } - } -} diff --git a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/TridentStack.java b/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/TridentStack.java deleted file mode 100644 index b21dc50a..00000000 --- a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/TridentStack.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.willfp.eco.proxy.v1_15_R1; - -import com.willfp.eco.proxy.proxies.TridentStackProxy; -import net.minecraft.server.v1_15_R1.EntityThrownTrident; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftTrident; -import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; -import org.bukkit.entity.Trident; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -public final class TridentStack implements TridentStackProxy { - @Override - public ItemStack getTridentStack(@NotNull final Trident trident) { - EntityThrownTrident t = ((CraftTrident) trident).getHandle(); - return CraftItemStack.asBukkitCopy(t.trident); - } -} diff --git a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/VillagerTrade.java b/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/VillagerTrade.java deleted file mode 100644 index 70bb8f45..00000000 --- a/eco-core/core-nms/v1_15_R1/src/main/java/com/willfp/eco/proxy/v1_15_R1/VillagerTrade.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.eco.proxy.v1_15_R1; - -import com.willfp.eco.proxy.proxies.VillagerTradeProxy; -import com.willfp.eco.core.display.Display; -import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; -import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftMerchantRecipe; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.MerchantRecipe; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.Field; - -public final class VillagerTrade implements VillagerTradeProxy { - @Override - public void displayTrade(@NotNull final MerchantRecipe merchantRecipe) { - try { - // Bukkit MerchantRecipe result - Field fResult = MerchantRecipe.class.getDeclaredField("result"); - fResult.setAccessible(true); - - ItemStack result = merchantRecipe.getResult(); - Display.displayAndFinalize(result); - fResult.set(merchantRecipe, result); - - // Get NMS MerchantRecipe from CraftMerchantRecipe - Field fHandle = CraftMerchantRecipe.class.getDeclaredField("handle"); - fHandle.setAccessible(true); - net.minecraft.server.v1_15_R1.MerchantRecipe handle = (net.minecraft.server.v1_15_R1.MerchantRecipe) fHandle.get(merchantRecipe); // NMS Recipe - - Field fSelling = net.minecraft.server.v1_15_R1.MerchantRecipe.class.getDeclaredField("sellingItem"); - fSelling.setAccessible(true); - - ItemStack selling = CraftItemStack.asBukkitCopy(handle.sellingItem); - Display.displayAndFinalize(selling); - fSelling.set(handle, CraftItemStack.asNMSCopy(selling)); - } catch (IllegalAccessException | NoSuchFieldException e) { - e.printStackTrace(); - } - } -} diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/FastItemStackHandlerFactory.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/FastItemStackHandlerFactory.java deleted file mode 100644 index 7ac2ae2b..00000000 --- a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/FastItemStackHandlerFactory.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.willfp.eco.proxy.v1_16_R3; - -import com.willfp.eco.internal.fast.AbstractFastItemStackHandler; -import com.willfp.eco.proxy.proxies.FastItemStackHandlerFactoryProxy; -import com.willfp.eco.proxy.v1_16_R3.fast.FastItemStackHandler; -import org.apache.commons.lang.Validate; -import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.NotNull; - -import java.lang.reflect.Field; - -public class FastItemStackHandlerFactory implements FastItemStackHandlerFactoryProxy { - /** - * The field to get the handle without a copy. - */ - private static final Field HANDLE_FIELD; - - @Override - public AbstractFastItemStackHandler create(@NotNull final ItemStack itemStack) { - return new FastItemStackHandler(get(itemStack)); - } - - /** - * Get from field. - * - * @param itemStack The ItemStack. - * @return The NMS ItemStack. - */ - public net.minecraft.server.v1_16_R3.ItemStack get(@NotNull final ItemStack itemStack) { - Validate.isTrue(itemStack instanceof CraftItemStack, "Must be a CraftItemStack!"); - - try { - return (net.minecraft.server.v1_16_R3.ItemStack) HANDLE_FIELD.get(itemStack); - } catch (ReflectiveOperationException e) { - e.printStackTrace(); - } - - return null; - } - - static { - Field handle = null; - try { - handle = CraftItemStack.class.getDeclaredField("handle"); - handle.setAccessible(true); - } catch (ReflectiveOperationException e) { - e.printStackTrace(); - } - HANDLE_FIELD = handle; - } -} diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/fast/FastItemStackHandler.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/fast/FastItemStackHandler.java deleted file mode 100644 index 07b0bb13..00000000 --- a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/eco/proxy/v1_16_R3/fast/FastItemStackHandler.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.willfp.eco.proxy.v1_16_R3.fast; - -import com.willfp.eco.internal.fast.AbstractFastItemStackHandler; -import net.minecraft.server.v1_16_R3.NBTBase; -import net.minecraft.server.v1_16_R3.NBTTagCompound; -import net.minecraft.server.v1_16_R3.NBTTagList; -import net.minecraft.server.v1_16_R3.NBTTagString; -import org.bukkit.NamespacedKey; -import org.bukkit.craftbukkit.v1_16_R3.util.CraftChatMessage; -import org.bukkit.craftbukkit.v1_16_R3.util.CraftMagicNumbers; -import org.bukkit.craftbukkit.v1_16_R3.util.CraftNamespacedKey; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.persistence.PersistentDataType; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class FastItemStackHandler implements AbstractFastItemStackHandler { - /** - * The ItemStack. - */ - private final net.minecraft.server.v1_16_R3.ItemStack itemStack; - - /** - * The nbt tag. - */ - private final NBTTagCompound tag; - - /** - * Create new FastItemStack handler. - * - * @param itemStack The ItemStack. - */ - public FastItemStackHandler(@NotNull final net.minecraft.server.v1_16_R3.ItemStack itemStack) { - this.itemStack = itemStack; - - this.tag = itemStack.getOrCreateTag(); - } - - - @Override - public Map getEnchantments() { - NBTTagList enchantmentNBT = itemStack.getEnchantments(); - HashMap foundEnchantments = new HashMap<>(); - - for (NBTBase base : enchantmentNBT) { - NBTTagCompound compound = (NBTTagCompound) base; - String key = compound.getString("id"); - int level = '\uffff' & compound.getShort("lvl"); - - Enchantment found = Enchantment.getByKey(CraftNamespacedKey.fromStringOrNull(key)); - if (found != null) { - foundEnchantments.put(found, level); - } - } - - return foundEnchantments; - } - - @Override - public int getEnchantmentLevel(@NotNull final Enchantment enchantment) { - NBTTagList enchantmentNBT = itemStack.getEnchantments(); - - for (NBTBase base : enchantmentNBT) { - NBTTagCompound compound = (NBTTagCompound) base; - String key = compound.getString("id"); - if (!key.equals(enchantment.getKey().toString())) { - continue; - } - - return '\uffff' & compound.getShort("lvl"); - } - return 0; - } - - @Override - public List getLore() { - NBTTagCompound displayTag = getDisplayTag(this.tag); - if (displayTag.hasKey("Lore")) { - NBTTagList list = displayTag.getList("Lore", CraftMagicNumbers.NBT.TAG_STRING); - List lore = new ArrayList<>(list.size()); - - for (int index = 0; index < list.size(); index++) { - String line = list.getString(index); - lore.add(CraftChatMessage.fromJSONComponent(line)); - } - - return lore; - } else { - return new ArrayList<>(); - } - } - - @Override - public void setLore(@NotNull final List lore) { - NBTTagList tagList = new NBTTagList(); - for (String value : lore) { - tagList.add(NBTTagString.a(CraftChatMessage.fromJSONComponent(value))); - } - - setDisplayTag("Lore", tagList); - } - - @Override - public Set getItemFlags() { - return null; - } - - @Override - public void setItemFlags(@NotNull final Set flags) { - - } - - @Override - public void writePersistentKey(@NotNull final NamespacedKey key, - @NotNull final PersistentDataType type, - @NotNull final Z value) { - - } - - @Override - public Z readPersistentKey(@NotNull final NamespacedKey key, - @NotNull final PersistentDataType type) { - return null; - } - - @Override - public Set getPersistentKeys() { - return null; - } - - @Override - public String getDisplayName() { - return CraftChatMessage.fromComponent(itemStack.getName()); - } - - @Override - public void setDisplayName(@NotNull final String name) { - itemStack.a(CraftChatMessage.fromStringOrNull(name)); - } - - @Override - public void apply() { - itemStack.setTag(tag); - } - - private NBTTagCompound getDisplayTag(@NotNull final NBTTagCompound base) { - return base.getCompound("display"); - } - - private void setDisplayTag(@NotNull final String key, - @NotNull final NBTBase value) { - final NBTTagCompound display = tag.getCompound("display"); - - display.set(key, value); - - tag.set("display", display); - } -} diff --git a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoSpigotPlugin.java b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoSpigotPlugin.java index f489ba39..ffcaa5b8 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoSpigotPlugin.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/eco/spigot/EcoSpigotPlugin.java @@ -1,8 +1,14 @@ package com.willfp.eco.spigot; +import com.willfp.eco.core.AbstractPacketAdapter; +import com.willfp.eco.core.command.AbstractCommand; +import com.willfp.eco.core.display.Display; +import com.willfp.eco.core.display.DisplayModule; +import com.willfp.eco.core.integrations.IntegrationLoader; +import com.willfp.eco.core.integrations.anticheat.AnticheatManager; +import com.willfp.eco.core.integrations.antigrief.AntigriefManager; +import com.willfp.eco.core.integrations.mcmmo.McmmoManager; import com.willfp.eco.proxy.proxies.BlockBreakProxy; -import com.willfp.eco.proxy.proxies.CooldownProxy; -import com.willfp.eco.proxy.proxies.FastItemStackHandlerFactoryProxy; import com.willfp.eco.proxy.proxies.SkullProxy; import com.willfp.eco.proxy.proxies.TridentStackProxy; import com.willfp.eco.spigot.display.PacketAutoRecipe; @@ -29,18 +35,8 @@ import com.willfp.eco.spigot.integrations.antigrief.AntigriefWorldGuard; import com.willfp.eco.spigot.integrations.mcmmo.McmmoIntegrationImpl; import com.willfp.eco.spigot.recipes.RecipeListener; import com.willfp.eco.util.BlockUtils; -import com.willfp.eco.util.PlayerUtils; import com.willfp.eco.util.SkullUtils; import com.willfp.eco.util.TridentUtils; -import com.willfp.eco.core.command.AbstractCommand; -import com.willfp.eco.core.display.Display; -import com.willfp.eco.core.display.DisplayModule; -import com.willfp.eco.core.fast.FastItemStack; -import com.willfp.eco.core.integrations.IntegrationLoader; -import com.willfp.eco.core.integrations.anticheat.AnticheatManager; -import com.willfp.eco.core.integrations.antigrief.AntigriefManager; -import com.willfp.eco.core.integrations.mcmmo.McmmoManager; -import com.willfp.eco.core.AbstractPacketAdapter; import lombok.Getter; import org.bukkit.event.Listener; import org.jetbrains.annotations.Nullable; @@ -65,9 +61,7 @@ public class EcoSpigotPlugin extends com.willfp.eco.core.EcoPlugin { Display.setFinalizeKey(this.getNamespacedKeyFactory().create("finalized")); SkullUtils.initialize((skullMeta, base64) -> InternalProxyUtils.getProxy(SkullProxy.class).setSkullTexture(skullMeta, base64)); BlockUtils.initialize(((player, block) -> InternalProxyUtils.getProxy(BlockBreakProxy.class).breakBlock(player, block))); - PlayerUtils.initialize(((player) -> InternalProxyUtils.getProxy(CooldownProxy.class).getAttackCooldown(player))); TridentUtils.initialize(((trident) -> InternalProxyUtils.getProxy(TridentStackProxy.class).getTridentStack(trident))); - FastItemStack.initialize(InternalProxyUtils.getProxy(FastItemStackHandlerFactoryProxy.class)); } @Override diff --git a/eco-core/core-plugin/src/main/resources/plugin.yml b/eco-core/core-plugin/src/main/resources/plugin.yml index 019f7b8d..2889bbdd 100644 --- a/eco-core/core-plugin/src/main/resources/plugin.yml +++ b/eco-core/core-plugin/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: eco version: ${projectVersion} main: com.willfp.eco.spigot.EcoPlugin -api-version: 1.15 +api-version: 1.16 authors: [Auxilor] website: willfp.com loadbefore: diff --git a/eco-core/core-proxy/src/main/java/com/willfp/eco/proxy/proxies/CooldownProxy.java b/eco-core/core-proxy/src/main/java/com/willfp/eco/proxy/proxies/CooldownProxy.java deleted file mode 100644 index 1e3e575f..00000000 --- a/eco-core/core-proxy/src/main/java/com/willfp/eco/proxy/proxies/CooldownProxy.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.willfp.eco.proxy.proxies; - -import com.willfp.eco.core.proxy.AbstractProxy; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -public interface CooldownProxy extends AbstractProxy { - /** - * Get the attack cooldown for a player. - * - * @param player The player's attack cooldown. - * @return A value between 0 and 1, with 1 representing full power. - */ - double getAttackCooldown(@NotNull Player player); -} diff --git a/eco-core/core-proxy/src/main/java/com/willfp/eco/proxy/proxies/FastItemStackHandlerFactoryProxy.java b/eco-core/core-proxy/src/main/java/com/willfp/eco/proxy/proxies/FastItemStackHandlerFactoryProxy.java deleted file mode 100644 index 3126a625..00000000 --- a/eco-core/core-proxy/src/main/java/com/willfp/eco/proxy/proxies/FastItemStackHandlerFactoryProxy.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.willfp.eco.proxy.proxies; - -import com.willfp.eco.internal.fast.FastItemStackHandlerFactory; -import com.willfp.eco.core.proxy.AbstractProxy; - -public interface FastItemStackHandlerFactoryProxy extends AbstractProxy, FastItemStackHandlerFactory { -} diff --git a/settings.gradle b/settings.gradle index 0105667c..f4cc4b59 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,6 @@ rootProject.name = 'eco' include ':eco-api' include ':eco-core' include ':eco-core:core-nms' -include ':eco-core:core-nms:v1_15_R1' include ':eco-core:core-nms:v1_16_R1' include ':eco-core:core-nms:v1_16_R2' include ':eco-core:core-nms:v1_16_R3'