mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-21 14:55:17 +01:00
Fixed ChatComponent
This commit is contained in:
parent
e21e9c6142
commit
a85563653f
@ -13,9 +13,7 @@ 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.EnchantmentStorageMeta;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
@ -54,14 +52,9 @@ public class ChatComponent implements ChatComponentWrapper {
|
||||
String id = json.getAsJsonObject().get("id").toString();
|
||||
String tag = json.getAsJsonObject().get("tag").toString();
|
||||
ItemStack itemStack = getFromTag(tag, id);
|
||||
boolean hideEnchants = false;
|
||||
if(itemStack.getItemMeta() != null) {
|
||||
if(itemStack.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) hideEnchants = true;
|
||||
if(itemStack.getItemMeta() instanceof EnchantmentStorageMeta && itemStack.getItemMeta().hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) hideEnchants = true;
|
||||
}
|
||||
|
||||
try {
|
||||
itemStack = (ItemStack) Class.forName("com.willfp.ecoenchants.display.EnchantDisplay").getMethod("displayEnchantments", ItemStack.class, boolean.class).invoke(null, itemStack, hideEnchants);
|
||||
itemStack = (ItemStack) Class.forName("com.willfp.ecoenchants.display.EnchantDisplay").getMethod("displayEnchantments", ItemStack.class).invoke(null, itemStack);
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -13,9 +13,7 @@ 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.EnchantmentStorageMeta;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
@ -54,14 +52,9 @@ public class ChatComponent implements ChatComponentWrapper {
|
||||
String id = json.getAsJsonObject().get("id").toString();
|
||||
String tag = json.getAsJsonObject().get("tag").toString();
|
||||
ItemStack itemStack = getFromTag(tag, id);
|
||||
boolean hideEnchants = false;
|
||||
if(itemStack.getItemMeta() != null) {
|
||||
if(itemStack.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) hideEnchants = true;
|
||||
if(itemStack.getItemMeta() instanceof EnchantmentStorageMeta && itemStack.getItemMeta().hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) hideEnchants = true;
|
||||
}
|
||||
|
||||
try {
|
||||
itemStack = (ItemStack) Class.forName("com.willfp.ecoenchants.display.EnchantDisplay").getMethod("displayEnchantments", ItemStack.class, boolean.class).invoke(null, itemStack, hideEnchants);
|
||||
itemStack = (ItemStack) Class.forName("com.willfp.ecoenchants.display.EnchantDisplay").getMethod("displayEnchantments", ItemStack.class).invoke(null, itemStack);
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -13,9 +13,7 @@ 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.EnchantmentStorageMeta;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
@ -54,14 +52,9 @@ public class ChatComponent implements ChatComponentWrapper {
|
||||
String id = json.getAsJsonObject().get("id").toString();
|
||||
String tag = json.getAsJsonObject().get("tag").toString();
|
||||
ItemStack itemStack = getFromTag(tag, id);
|
||||
boolean hideEnchants = false;
|
||||
if(itemStack.getItemMeta() != null) {
|
||||
if(itemStack.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) hideEnchants = true;
|
||||
if(itemStack.getItemMeta() instanceof EnchantmentStorageMeta && itemStack.getItemMeta().hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) hideEnchants = true;
|
||||
}
|
||||
|
||||
try {
|
||||
itemStack = (ItemStack) Class.forName("com.willfp.ecoenchants.display.EnchantDisplay").getMethod("displayEnchantments", ItemStack.class, boolean.class).invoke(null, itemStack, hideEnchants);
|
||||
itemStack = (ItemStack) Class.forName("com.willfp.ecoenchants.display.EnchantDisplay").getMethod("displayEnchantments", ItemStack.class).invoke(null, itemStack);
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ public class Telekinesis extends EcoEnchant {
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) return;
|
||||
if(this.getDisabledWorldNames().contains(player.getWorld().getName())) return;
|
||||
//if(this.getDisabledWorlds().contains(player.getWorld())) return;
|
||||
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
@ -58,6 +57,7 @@ public class Telekinesis extends EcoEnchant {
|
||||
new DropQueue(player)
|
||||
.setLocation(block.getLocation())
|
||||
.addItems(drops)
|
||||
.forceTelekinesis()
|
||||
.push();
|
||||
|
||||
player.updateInventory();
|
||||
|
@ -33,7 +33,7 @@ public class FastCollatedDropQueue extends InternalDropQueue {
|
||||
|
||||
@Override
|
||||
public void push() {
|
||||
CollatedDrops collatedDrops = COLLATED_MAP.containsKey(player) ? COLLATED_MAP.get(player).addDrops(items) : new CollatedDrops(items, loc, xp);
|
||||
CollatedDrops collatedDrops = COLLATED_MAP.containsKey(player) ? COLLATED_MAP.get(player).addDrops(items).setLocation(loc) : new CollatedDrops(items, loc, xp);
|
||||
COLLATED_MAP.put(player, collatedDrops);
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class FastCollatedDropQueue extends InternalDropQueue {
|
||||
|
||||
private static class CollatedDrops {
|
||||
private final List<ItemStack> drops;
|
||||
private final Location location;
|
||||
private Location location;
|
||||
private final int xp;
|
||||
|
||||
private CollatedDrops(List<ItemStack> drops, Location location, int xp) {
|
||||
@ -87,5 +87,11 @@ public class FastCollatedDropQueue extends InternalDropQueue {
|
||||
drops.addAll(toAdd);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollatedDrops setLocation(Location loc) {
|
||||
this.location = loc;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class InternalDropQueue implements AbstractDropQueue {
|
||||
assert world != null;
|
||||
|
||||
if(hasTelekinesis) {
|
||||
HashMap<Integer, ItemStack> leftover = player.getInventory().addItem(items.toArray(new ItemStack[]{}));
|
||||
HashMap<Integer, ItemStack> leftover = player.getInventory().addItem(items.toArray(new ItemStack[0]));
|
||||
for(ItemStack drop : leftover.values()) {
|
||||
world.dropItemNaturally(loc.add(0.5, 0, 0.5), drop).setVelocity(new Vector());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user