diff --git a/build.gradle b/build.gradle index 42c502a..232fee9 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ allprojects { } dependencies { - compileOnly 'com.willfp:eco:3.6.0' + compileOnly 'com.willfp:eco:3.8.0' compileOnly 'org.jetbrains:annotations:19.0.0' diff --git a/eco-core/core-nms/build.gradle b/eco-core/core-nms/build.gradle deleted file mode 100644 index 4aa1efc..0000000 --- a/eco-core/core-nms/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -group 'com.willfp' -version rootProject.version - -subprojects { - dependencies { - compileOnly project(':eco-core:core-proxy') - compileOnly project(':eco-core:core-plugin') - } -} \ No newline at end of file diff --git a/eco-core/core-nms/v1_16_R1/build.gradle b/eco-core/core-nms/v1_16_R1/build.gradle deleted file mode 100644 index 4962362..0000000 --- a/eco-core/core-nms/v1_16_R1/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -group 'com.willfp' -version rootProject.version - -dependencies { - compileOnly 'org.spigotmc:spigot:1.16.1-R0.1-SNAPSHOT' -} \ No newline at end of file diff --git a/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoarmor/proxy/v1_16_R1/Skull.java b/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoarmor/proxy/v1_16_R1/Skull.java deleted file mode 100644 index 9250d5e..0000000 --- a/eco-core/core-nms/v1_16_R1/src/main/java/com/willfp/ecoarmor/proxy/v1_16_R1/Skull.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.willfp.ecoarmor.proxy.v1_16_R1; - -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.willfp.ecoarmor.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 class Skull implements SkullProxy { - /** - * Cached method to set the gameProfile. - */ - private Method setProfile = null; - - @Override - public void setTexture(@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_16_R2/build.gradle b/eco-core/core-nms/v1_16_R2/build.gradle deleted file mode 100644 index 3f4d50c..0000000 --- a/eco-core/core-nms/v1_16_R2/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -group 'com.willfp' -version rootProject.version - -dependencies { - compileOnly 'org.spigotmc:spigot:1.16.3-R0.1-SNAPSHOT' -} \ No newline at end of file diff --git a/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoarmor/proxy/v1_16_R2/Skull.java b/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoarmor/proxy/v1_16_R2/Skull.java deleted file mode 100644 index 9f80b60..0000000 --- a/eco-core/core-nms/v1_16_R2/src/main/java/com/willfp/ecoarmor/proxy/v1_16_R2/Skull.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.willfp.ecoarmor.proxy.v1_16_R2; - -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.willfp.ecoarmor.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 class Skull implements SkullProxy { - /** - * Cached method to set the gameProfile. - */ - private Method setProfile = null; - - @Override - public void setTexture(@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_16_R3/build.gradle b/eco-core/core-nms/v1_16_R3/build.gradle deleted file mode 100644 index 5930f17..0000000 --- a/eco-core/core-nms/v1_16_R3/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -group 'com.willfp' -version rootProject.version - -dependencies { - compileOnly 'org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT' -} \ No newline at end of file diff --git a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoarmor/proxy/v1_16_R3/Skull.java b/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoarmor/proxy/v1_16_R3/Skull.java deleted file mode 100644 index 392f434..0000000 --- a/eco-core/core-nms/v1_16_R3/src/main/java/com/willfp/ecoarmor/proxy/v1_16_R3/Skull.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.willfp.ecoarmor.proxy.v1_16_R3; - -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import com.willfp.ecoarmor.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 class Skull implements SkullProxy { - /** - * Cached method to set the gameProfile. - */ - private Method setProfile = null; - - @Override - public void setTexture(@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-plugin/build.gradle b/eco-core/core-plugin/build.gradle index 24c5be8..3f90b63 100644 --- a/eco-core/core-plugin/build.gradle +++ b/eco-core/core-plugin/build.gradle @@ -2,11 +2,5 @@ group 'com.willfp' version rootProject.version dependencies { - compileOnly project(":eco-core:core-proxy") compileOnly 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT' - compileOnly 'commons-io:commons-io:2.8.0' - compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT' - compileOnly 'net.ess3:EssentialsX:2.18.1' - compileOnly 'com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT' - compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.157' } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/display/ArmorDisplay.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/display/ArmorDisplay.java index 6abe0c5..dba5fe9 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/display/ArmorDisplay.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/display/ArmorDisplay.java @@ -1,12 +1,11 @@ package com.willfp.ecoarmor.display; +import com.willfp.eco.util.SkullUtils; import com.willfp.ecoarmor.config.EcoArmorConfigs; -import com.willfp.ecoarmor.proxy.proxies.SkullProxy; import com.willfp.ecoarmor.sets.ArmorSet; import com.willfp.ecoarmor.sets.meta.ArmorSlot; import com.willfp.ecoarmor.sets.util.ArmorUtils; import com.willfp.ecoarmor.upgrades.crystal.UpgradeCrystal; -import com.willfp.ecoarmor.util.ProxyUtils; import lombok.experimental.UtilityClass; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; @@ -122,7 +121,7 @@ public class ArmorDisplay { if (meta instanceof SkullMeta && slotMeta instanceof SkullMeta) { String base64 = EcoArmorConfigs.SETS.getString(set.getName() + "." + slot.name().toLowerCase() + ".skull-texture"); - ProxyUtils.getProxy(SkullProxy.class).setTexture((SkullMeta) meta, base64); + SkullUtils.setSkullTexture((SkullMeta) meta, base64); } if (meta instanceof LeatherArmorMeta && slotMeta instanceof LeatherArmorMeta) { diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSet.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSet.java index 01bcb95..21281b5 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSet.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/sets/ArmorSet.java @@ -1,5 +1,6 @@ package com.willfp.ecoarmor.sets; +import com.willfp.eco.util.SkullUtils; import com.willfp.eco.util.StringUtils; import com.willfp.eco.util.recipe.EcoShapedRecipe; import com.willfp.eco.util.recipe.lookup.RecipePartUtils; @@ -9,10 +10,8 @@ import com.willfp.ecoarmor.config.EcoArmorConfigs; import com.willfp.ecoarmor.display.ArmorDisplay; import com.willfp.ecoarmor.effects.Effect; import com.willfp.ecoarmor.effects.Effects; -import com.willfp.ecoarmor.proxy.proxies.SkullProxy; import com.willfp.ecoarmor.sets.meta.ArmorSlot; import com.willfp.ecoarmor.sets.util.ArmorUtils; -import com.willfp.ecoarmor.util.ProxyUtils; import lombok.Getter; import org.bukkit.Color; import org.bukkit.Material; @@ -231,7 +230,7 @@ public class ArmorSet { if (meta instanceof SkullMeta) { String base64 = EcoArmorConfigs.SETS.getString(name + "." + pieceName + ".skull-texture"); - ProxyUtils.getProxy(SkullProxy.class).setTexture((SkullMeta) meta, base64); + SkullUtils.setSkullTexture((SkullMeta) meta, base64); } if (meta instanceof LeatherArmorMeta) { diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/util/ProxyUtils.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/util/ProxyUtils.java deleted file mode 100644 index 6bd92bf..0000000 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoarmor/util/ProxyUtils.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.willfp.ecoarmor.util; - -import com.willfp.eco.util.proxy.AbstractProxy; -import com.willfp.ecoarmor.EcoArmorPlugin; -import com.willfp.ecoarmor.proxy.util.ProxyFactory; -import lombok.experimental.UtilityClass; -import org.jetbrains.annotations.NotNull; - -@UtilityClass -public class ProxyUtils { - /** - * Get the implementation of a specified proxy. - * - * @param proxyClass The proxy interface. - * @param The type of the proxy. - * @return The proxy implementation. - */ - public @NotNull T getProxy(@NotNull final Class proxyClass) { - return new ProxyFactory<>(EcoArmorPlugin.getInstance(), proxyClass).getProxy(); - } -} diff --git a/eco-core/core-proxy/build.gradle b/eco-core/core-proxy/build.gradle deleted file mode 100644 index 3f90b63..0000000 --- a/eco-core/core-proxy/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -group 'com.willfp' -version rootProject.version - -dependencies { - compileOnly 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT' -} \ No newline at end of file diff --git a/eco-core/core-proxy/src/main/java/com/willfp/ecoarmor/proxy/proxies/SkullProxy.java b/eco-core/core-proxy/src/main/java/com/willfp/ecoarmor/proxy/proxies/SkullProxy.java deleted file mode 100644 index f50bfaf..0000000 --- a/eco-core/core-proxy/src/main/java/com/willfp/ecoarmor/proxy/proxies/SkullProxy.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.willfp.ecoarmor.proxy.proxies; - -import com.willfp.eco.util.proxy.AbstractProxy; -import org.bukkit.inventory.meta.SkullMeta; -import org.jetbrains.annotations.NotNull; - -public interface SkullProxy extends AbstractProxy { - /** - * Set the texture of a skull from base64. - * - * @param meta The meta to modify. - * @param base64 The base64 texture. - */ - void setTexture(@NotNull SkullMeta meta, - @NotNull String base64); -} diff --git a/eco-core/core-proxy/src/main/java/com/willfp/ecoarmor/proxy/util/ProxyFactory.java b/eco-core/core-proxy/src/main/java/com/willfp/ecoarmor/proxy/util/ProxyFactory.java deleted file mode 100644 index a2ca812..0000000 --- a/eco-core/core-proxy/src/main/java/com/willfp/ecoarmor/proxy/util/ProxyFactory.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.willfp.ecoarmor.proxy.util; - -import com.willfp.eco.util.internal.PluginDependent; -import com.willfp.eco.util.plugin.AbstractEcoPlugin; -import com.willfp.eco.util.proxy.AbstractProxy; -import com.willfp.eco.util.proxy.ProxyConstants; -import com.willfp.eco.util.proxy.UnsupportedVersionException; -import org.jetbrains.annotations.NotNull; - -import java.util.IdentityHashMap; -import java.util.Map; - -public class ProxyFactory extends PluginDependent { - /** - * Cached proxy implementations in order to not perform expensive reflective class-finding. - */ - private static final Map, AbstractProxy> CACHE = new IdentityHashMap<>(); - - /** - * The class of the proxy interface. - */ - private final Class proxyClass; - - /** - * Create a new Proxy Factory for a specific type. - * - * @param plugin The plugin to create proxies for. - * @param proxyClass The class of the proxy interface. - */ - public ProxyFactory(@NotNull final AbstractEcoPlugin plugin, - @NotNull final Class proxyClass) { - super(plugin); - this.proxyClass = proxyClass; - } - - /** - * Get the implementation of a proxy. - * - * @return The proxy implementation. - */ - public @NotNull T getProxy() { - try { - T cachedProxy = attemptCache(); - if (cachedProxy != null) { - return cachedProxy; - } - - String className = this.getPlugin().getProxyPackage() + "." + ProxyConstants.NMS_VERSION + "." + proxyClass.getSimpleName().replace("Proxy", ""); - final Class class2 = Class.forName(className); - Object instance = class2.getConstructor().newInstance(); - if (proxyClass.isAssignableFrom(class2) && proxyClass.isInstance(instance)) { - T proxy = proxyClass.cast(instance); - CACHE.put(proxyClass, proxy); - return proxy; - } - } catch (Exception e) { - // If not returned, then throw error - } - - throw new UnsupportedVersionException("You're running an unsupported server version: " + ProxyConstants.NMS_VERSION); - } - - private T attemptCache() { - Object proxy = CACHE.get(proxyClass); - if (proxy == null) { - return null; - } - - if (proxyClass.isInstance(proxy)) { - return proxyClass.cast(proxy); - } - - return null; - } -} diff --git a/settings.gradle b/settings.gradle index 5411e65..e303cd1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,9 +2,4 @@ rootProject.name = 'EcoArmor' // Core include ':eco-core' -include ':eco-core:core-nms' -include ':eco-core:core-nms:v1_16_R1' -include ':eco-core:core-nms:v1_16_R2' -include ':eco-core:core-nms:v1_16_R3' -include ':eco-core:core-proxy' include ':eco-core:core-plugin' \ No newline at end of file