mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Fix persistent brushes
This commit is contained in:
@ -47,6 +47,8 @@ public class ItemUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public CompoundTag getNBT(ItemStack item) {
|
||||
try {
|
||||
if (!item.hasItemMeta()) return null;
|
||||
|
@ -349,9 +349,7 @@ public class BukkitAdapter {
|
||||
*/
|
||||
public static BaseItemStack adapt(ItemStack itemStack) {
|
||||
checkNotNull(itemStack);
|
||||
|
||||
|
||||
return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount());
|
||||
return new BukkitItemStack(itemStack);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -362,6 +360,7 @@ public class BukkitAdapter {
|
||||
*/
|
||||
public static ItemStack adapt(BaseItemStack item) {
|
||||
checkNotNull(item);
|
||||
if (item instanceof BukkitItemStack) return ((BukkitItemStack) item).getBukkitItemStack();
|
||||
return new ItemStack(adapt(item.getType()), item.getAmount());
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
public class BukkitItemStack extends BaseItemStack {
|
||||
private ItemStack stack;
|
||||
private Object nativeItem;
|
||||
private boolean loadedNBT;
|
||||
|
||||
public BukkitItemStack(ItemStack stack) {
|
||||
@ -33,7 +34,23 @@ public class BukkitItemStack extends BaseItemStack {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getNativeItem() {
|
||||
return super.getNativeItem();
|
||||
ItemUtil util = Fawe.<FaweBukkit>imp().getItemUtil();
|
||||
if (util != null && nativeItem == null) {
|
||||
return nativeItem = util.getNMSItem(stack);
|
||||
}
|
||||
return nativeItem;
|
||||
}
|
||||
|
||||
public ItemStack getBukkitItemStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNbtData() {
|
||||
if (!loadedNBT) {
|
||||
return stack.hasItemMeta();
|
||||
}
|
||||
return super.hasNbtData();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -54,6 +71,7 @@ public class BukkitItemStack extends BaseItemStack {
|
||||
ItemUtil util = Fawe.<FaweBukkit>imp().getItemUtil();
|
||||
if (util != null) {
|
||||
stack = util.setNBT(stack, nbtData);
|
||||
nativeItem = null;
|
||||
}
|
||||
super.setNbtData(nbtData);
|
||||
}
|
||||
|
Reference in New Issue
Block a user