+ fix tellraw
This commit is contained in:
parent
803542c589
commit
2617069878
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.skymc</groupId>
|
||||
<artifactId>TabooLib</artifactId>
|
||||
<version>4.7</version>
|
||||
<version>4.71</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -65,34 +65,37 @@ public class InternalTellraw implements AbstractTellraw {
|
||||
|
||||
@Override
|
||||
public ItemStack optimizeShulkerBox(ItemStack item) {
|
||||
if (item.getType().name().endsWith("SHULKER_BOX")) {
|
||||
ItemStack itemClone = item.clone();
|
||||
BlockStateMeta blockStateMeta = (BlockStateMeta) itemClone.getItemMeta();
|
||||
ShulkerBox shulkerBox = (ShulkerBox) blockStateMeta.getBlockState();
|
||||
ItemStack[] contents = shulkerBox.getInventory().getContents();
|
||||
ItemStack[] contentsClone = new ItemStack[contents.length];
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
ItemStack content = contents[i];
|
||||
if (!ItemUtils.isNull(content)) {
|
||||
ItemStack contentClone = new ItemStack(Material.STONE, content.getAmount(), content.getDurability());
|
||||
if (content.getItemMeta().hasDisplayName()) {
|
||||
ItemUtils.setName(contentClone, content.getItemMeta().getDisplayName());
|
||||
try {
|
||||
if (item.getType().name().endsWith("SHULKER_BOX")) {
|
||||
ItemStack itemClone = item.clone();
|
||||
BlockStateMeta blockStateMeta = (BlockStateMeta) itemClone.getItemMeta();
|
||||
ShulkerBox shulkerBox = (ShulkerBox) blockStateMeta.getBlockState();
|
||||
ItemStack[] contents = shulkerBox.getInventory().getContents();
|
||||
ItemStack[] contentsClone = new ItemStack[contents.length];
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
ItemStack content = contents[i];
|
||||
if (!ItemUtils.isNull(content)) {
|
||||
ItemStack contentClone = new ItemStack(Material.STONE, content.getAmount(), content.getDurability());
|
||||
if (content.getItemMeta().hasDisplayName()) {
|
||||
ItemUtils.setName(contentClone, content.getItemMeta().getDisplayName());
|
||||
}
|
||||
contentsClone[i] = contentClone;
|
||||
}
|
||||
contentsClone[i] = contentClone;
|
||||
}
|
||||
shulkerBox.getInventory().setContents(contentsClone);
|
||||
blockStateMeta.setBlockState(shulkerBox);
|
||||
itemClone.setItemMeta(blockStateMeta);
|
||||
return itemClone;
|
||||
} else if (item.getItemMeta() instanceof BlockStateMeta && ((BlockStateMeta) item.getItemMeta()).getBlockState() instanceof InventoryHolder) {
|
||||
ItemStack itemClone = item.clone();
|
||||
BlockStateMeta blockStateMeta = (BlockStateMeta) itemClone.getItemMeta();
|
||||
InventoryHolder inventoryHolder = (InventoryHolder) blockStateMeta.getBlockState();
|
||||
inventoryHolder.getInventory().clear();
|
||||
blockStateMeta.setBlockState((org.bukkit.block.BlockState) inventoryHolder);
|
||||
itemClone.setItemMeta(blockStateMeta);
|
||||
return itemClone;
|
||||
}
|
||||
shulkerBox.getInventory().setContents(contentsClone);
|
||||
blockStateMeta.setBlockState(shulkerBox);
|
||||
itemClone.setItemMeta(blockStateMeta);
|
||||
return itemClone;
|
||||
} else if (item.getItemMeta() instanceof BlockStateMeta && ((BlockStateMeta) item.getItemMeta()).getBlockState() instanceof InventoryHolder) {
|
||||
ItemStack itemClone = item.clone();
|
||||
BlockStateMeta blockStateMeta = (BlockStateMeta) itemClone.getItemMeta();
|
||||
InventoryHolder inventoryHolder = (InventoryHolder) blockStateMeta.getBlockState();
|
||||
inventoryHolder.getInventory().clear();
|
||||
blockStateMeta.setBlockState((org.bukkit.block.BlockState) inventoryHolder);
|
||||
itemClone.setItemMeta(blockStateMeta);
|
||||
return itemClone;
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user