fix: Исправлена серьезная потеря экстры при клонировании предмета
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
package com.reider745.api.pointers;
|
||||
|
||||
public abstract class PointerClass<T> {
|
||||
public final long pointer;
|
||||
public final PointersStorage storage;
|
||||
|
||||
public PointerClass(){
|
||||
this.storage = PointersStorage.getStorageForType(getPointerStorageType());
|
||||
pointer = storage.addPointer(this);
|
||||
}
|
||||
|
||||
protected PointerClass(PointersStorage storage){
|
||||
this.storage = storage;
|
||||
pointer = storage.addPointer(this);
|
||||
}
|
||||
|
||||
abstract public String getPointerStorageType();
|
||||
|
||||
public final long getPointer(){
|
||||
return pointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void finalize() throws Throwable {
|
||||
storage.removePointer(pointer);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.reider745.api.pointers;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class PointerClassAdditionalValue<T> extends ClassPointer<T> {
|
||||
private Object value = null;
|
||||
|
||||
public PointerClassAdditionalValue(WeakReference<T> reference) {
|
||||
super(reference);
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,6 @@ public class ItemUtils implements HookClass {
|
||||
CompoundTag custom = extra.getNamedTag();
|
||||
if (custom != null) {
|
||||
item.setNamedTag(custom);
|
||||
// Logger.info("get(" + id + ":" + meta + ")=" + item.getOrCreateNamedTag().getString(INNER_CORE_TAG_NAME));
|
||||
}
|
||||
}
|
||||
return item;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ItemStack {
|
||||
}
|
||||
|
||||
public ItemStack(ItemStack stack) {
|
||||
this(stack.id, stack.count, stack.data, null);
|
||||
this(stack.id, stack.count, stack.data, stack.extra);
|
||||
}
|
||||
|
||||
public ItemStack(NativeItemInstance itemInstance) {
|
||||
@@ -76,7 +76,8 @@ public class ItemStack {
|
||||
} catch (JSONException e) {
|
||||
return null;
|
||||
}
|
||||
return new ItemStack(json.optInt("id", 0), json.optInt("count", 0), json.optInt("data", 0), NativeItemInstanceExtra.fromJson(json.optJSONObject("extra")));
|
||||
return new ItemStack(json.optInt("id", 0), json.optInt("count", 0), json.optInt("data", 0),
|
||||
NativeItemInstanceExtra.fromJson(json.optJSONObject("extra")));
|
||||
} else if (obj instanceof NativeItemInstance) {
|
||||
return new ItemStack((NativeItemInstance) obj);
|
||||
} else if (obj instanceof Item) {
|
||||
|
||||
@@ -317,15 +317,13 @@ public class NativeItemInstanceExtra {
|
||||
public void setAllCustomData(String extra) {
|
||||
customData = new JSONObject(extra);
|
||||
if (item != null) {
|
||||
String dataJson = customData.toString();
|
||||
CompoundTag tag = item.getOrCreateNamedTag();
|
||||
if (!customData.isEmpty()) {
|
||||
tag.putString(ItemUtils.INNER_CORE_TAG_NAME, dataJson);
|
||||
tag.putString(ItemUtils.INNER_CORE_TAG_NAME, customData.toString());
|
||||
} else {
|
||||
tag.remove(ItemUtils.INNER_CORE_TAG_NAME);
|
||||
}
|
||||
item.setNamedTag(tag);
|
||||
// Logger.info("setAllCustomData(" + item.getId() + ":" + item.getDamage() + ")=" + dataJson);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user