mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-23 00:31:20 +01:00
Added support for HideEnchants in ChatComponent
This commit is contained in:
parent
f893c7e297
commit
c28e4d94bd
@ -47,6 +47,10 @@ allprojects {
|
||||
onlyIf { !sourceSets.main.allSource.files.isEmpty() }
|
||||
}
|
||||
|
||||
compileJava {
|
||||
onlyIf { !sourceSets.main.allSource.files.isEmpty() }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.jetbrains:annotations:19.0.0'
|
||||
|
||||
|
@ -4,8 +4,8 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.willfp.ecoenchants.proxy.proxies.ChatComponentProxy;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
import com.willfp.ecoenchants.proxy.proxies.ChatComponentProxy;
|
||||
import net.minecraft.server.v1_16_R1.ChatBaseComponent;
|
||||
import net.minecraft.server.v1_16_R1.ChatHoverable;
|
||||
import net.minecraft.server.v1_16_R1.ChatMessage;
|
||||
@ -14,7 +14,9 @@ import net.minecraft.server.v1_16_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_16_R1.MojangsonParser;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -59,7 +61,15 @@ public final class ChatComponent implements ChatComponentProxy {
|
||||
String tag = json.getAsJsonObject().get("tag").toString();
|
||||
ItemStack itemStack = getFromTag(tag, id);
|
||||
|
||||
itemStack = EnchantDisplay.displayEnchantments(itemStack);
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
assert meta != null;
|
||||
boolean hideEnchants = false;
|
||||
if (meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) || meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
|
||||
hideEnchants = true;
|
||||
}
|
||||
|
||||
itemStack = EnchantDisplay.displayEnchantments(itemStack, hideEnchants);
|
||||
EnchantDisplay.addV(itemStack);
|
||||
|
||||
json.getAsJsonObject().remove("tag");
|
||||
String newTag = toJson(itemStack);
|
||||
|
@ -4,8 +4,8 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.willfp.ecoenchants.proxy.proxies.ChatComponentProxy;
|
||||
import com.willfp.ecoenchants.display.EnchantDisplay;
|
||||
import com.willfp.ecoenchants.proxy.proxies.ChatComponentProxy;
|
||||
import net.minecraft.server.v1_16_R2.ChatBaseComponent;
|
||||
import net.minecraft.server.v1_16_R2.ChatHoverable;
|
||||
import net.minecraft.server.v1_16_R2.ChatMessage;
|
||||
@ -14,7 +14,9 @@ import net.minecraft.server.v1_16_R2.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_16_R2.MojangsonParser;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -59,7 +61,15 @@ public final class ChatComponent implements ChatComponentProxy {
|
||||
String tag = json.getAsJsonObject().get("tag").toString();
|
||||
ItemStack itemStack = getFromTag(tag, id);
|
||||
|
||||
itemStack = EnchantDisplay.displayEnchantments(itemStack);
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
assert meta != null;
|
||||
boolean hideEnchants = false;
|
||||
if (meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) || meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
|
||||
hideEnchants = true;
|
||||
}
|
||||
|
||||
itemStack = EnchantDisplay.displayEnchantments(itemStack, hideEnchants);
|
||||
EnchantDisplay.addV(itemStack);
|
||||
|
||||
json.getAsJsonObject().remove("tag");
|
||||
String newTag = toJson(itemStack);
|
||||
|
@ -14,7 +14,9 @@ import net.minecraft.server.v1_16_R3.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_16_R3.MojangsonParser;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -59,7 +61,15 @@ public final class ChatComponent implements ChatComponentProxy {
|
||||
String tag = json.getAsJsonObject().get("tag").toString();
|
||||
ItemStack itemStack = getFromTag(tag, id);
|
||||
|
||||
itemStack = EnchantDisplay.displayEnchantments(itemStack);
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
assert meta != null;
|
||||
boolean hideEnchants = false;
|
||||
if (meta.hasItemFlag(ItemFlag.HIDE_ENCHANTS) || meta.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
|
||||
hideEnchants = true;
|
||||
}
|
||||
|
||||
itemStack = EnchantDisplay.displayEnchantments(itemStack, hideEnchants);
|
||||
EnchantDisplay.addV(itemStack);
|
||||
|
||||
json.getAsJsonObject().remove("tag");
|
||||
String newTag = toJson(itemStack);
|
||||
|
Loading…
Reference in New Issue
Block a user