Removed unneeded reflection from ChatComponent implementations

This commit is contained in:
Auxilor 2020-12-22 20:25:26 +00:00
parent bae63f00b8
commit 665fbbf55b
6 changed files with 10 additions and 22 deletions

View File

@ -4,5 +4,6 @@ version rootProject.version
subprojects { subprojects {
dependencies { dependencies {
compileOnly project(':eco-core:core-proxy') compileOnly project(':eco-core:core-proxy')
compileOnly project(':eco-core:core-plugin')
} }
} }

View File

@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.willfp.eco.core.proxy.proxies.ChatComponentProxy; import com.willfp.eco.core.proxy.proxies.ChatComponentProxy;
import com.willfp.ecoenchants.display.EnchantDisplay;
import net.minecraft.server.v1_16_R1.ChatBaseComponent; import net.minecraft.server.v1_16_R1.ChatBaseComponent;
import net.minecraft.server.v1_16_R1.ChatHoverable; import net.minecraft.server.v1_16_R1.ChatHoverable;
import net.minecraft.server.v1_16_R1.ChatMessage; import net.minecraft.server.v1_16_R1.ChatMessage;
@ -15,7 +16,6 @@ import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays; import java.util.Arrays;
public class ChatComponent implements ChatComponentProxy { public class ChatComponent implements ChatComponentProxy {
@ -53,11 +53,7 @@ public class ChatComponent implements ChatComponentProxy {
String tag = json.getAsJsonObject().get("tag").toString(); String tag = json.getAsJsonObject().get("tag").toString();
ItemStack itemStack = getFromTag(tag, id); ItemStack itemStack = getFromTag(tag, id);
try { itemStack = EnchantDisplay.displayEnchantments(itemStack);
itemStack = (ItemStack) Class.forName("com.willfp.ecoenchants.display.EnchantDisplay").getMethod("displayEnchantments", ItemStack.class).invoke(null, itemStack);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
}
json.getAsJsonObject().remove("tag"); json.getAsJsonObject().remove("tag");
String newTag = toJson(itemStack); String newTag = toJson(itemStack);

View File

@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.willfp.eco.core.proxy.proxies.ChatComponentProxy; import com.willfp.eco.core.proxy.proxies.ChatComponentProxy;
import com.willfp.ecoenchants.display.EnchantDisplay;
import net.minecraft.server.v1_16_R2.ChatBaseComponent; import net.minecraft.server.v1_16_R2.ChatBaseComponent;
import net.minecraft.server.v1_16_R2.ChatHoverable; import net.minecraft.server.v1_16_R2.ChatHoverable;
import net.minecraft.server.v1_16_R2.ChatMessage; import net.minecraft.server.v1_16_R2.ChatMessage;
@ -15,7 +16,6 @@ import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays; import java.util.Arrays;
public class ChatComponent implements ChatComponentProxy { public class ChatComponent implements ChatComponentProxy {
@ -53,11 +53,7 @@ public class ChatComponent implements ChatComponentProxy {
String tag = json.getAsJsonObject().get("tag").toString(); String tag = json.getAsJsonObject().get("tag").toString();
ItemStack itemStack = getFromTag(tag, id); ItemStack itemStack = getFromTag(tag, id);
try { itemStack = EnchantDisplay.displayEnchantments(itemStack);
itemStack = (ItemStack) Class.forName("com.willfp.ecoenchants.display.EnchantDisplay").getMethod("displayEnchantments", ItemStack.class).invoke(null, itemStack);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
}
json.getAsJsonObject().remove("tag"); json.getAsJsonObject().remove("tag");
String newTag = toJson(itemStack); String newTag = toJson(itemStack);

View File

@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.willfp.eco.core.proxy.proxies.ChatComponentProxy; import com.willfp.eco.core.proxy.proxies.ChatComponentProxy;
import com.willfp.ecoenchants.display.EnchantDisplay;
import net.minecraft.server.v1_16_R3.ChatBaseComponent; import net.minecraft.server.v1_16_R3.ChatBaseComponent;
import net.minecraft.server.v1_16_R3.ChatHoverable; import net.minecraft.server.v1_16_R3.ChatHoverable;
import net.minecraft.server.v1_16_R3.ChatMessage; import net.minecraft.server.v1_16_R3.ChatMessage;
@ -15,7 +16,6 @@ import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays; import java.util.Arrays;
public class ChatComponent implements ChatComponentProxy { public class ChatComponent implements ChatComponentProxy {
@ -53,11 +53,7 @@ public class ChatComponent implements ChatComponentProxy {
String tag = json.getAsJsonObject().get("tag").toString(); String tag = json.getAsJsonObject().get("tag").toString();
ItemStack itemStack = getFromTag(tag, id); ItemStack itemStack = getFromTag(tag, id);
try { itemStack = EnchantDisplay.displayEnchantments(itemStack);
itemStack = (ItemStack) Class.forName("com.willfp.ecoenchants.display.EnchantDisplay").getMethod("displayEnchantments", ItemStack.class).invoke(null, itemStack);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
}
json.getAsJsonObject().remove("tag"); json.getAsJsonObject().remove("tag");
String newTag = toJson(itemStack); String newTag = toJson(itemStack);

View File

@ -1,6 +1,8 @@
package com.willfp.ecoenchants.enchantments; package com.willfp.ecoenchants.enchantments;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.AshArtifact; import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.AshArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CloudsArtifact; import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CloudsArtifact;
@ -228,10 +230,8 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta; import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@ -244,7 +244,7 @@ public class EcoEnchants {
public static final String OBTAINING_LOCATION = "obtaining."; public static final String OBTAINING_LOCATION = "obtaining.";
public static final String GENERAL_LOCATION = "general-config."; public static final String GENERAL_LOCATION = "general-config.";
private static final Map<NamespacedKey, EcoEnchant> byKey = new HashMap<>(); private static final BiMap<NamespacedKey, EcoEnchant> byKey = HashBiMap.create();
public static final EcoEnchant TELEKINESIS = new Telekinesis(); public static final EcoEnchant TELEKINESIS = new Telekinesis();
public static final EcoEnchant MARKSMAN = new Marksman(); public static final EcoEnchant MARKSMAN = new Marksman();

View File

@ -21,7 +21,6 @@ public class VectorUtils {
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return false; return false;
} }
return true; return true;
} }