Skip to content

Commit

Permalink
ReflectedNBTWrapper 1.2 Revision 3
Browse files Browse the repository at this point in the history
- Fixed ItemNBTImporter.import(ItemStack,ReflectedNBTCompound) make error with arrays
- *Warning!* If you edit nbt with arrays, error will occurred in previous versions.
- Changed package name to v1_2R3
  • Loading branch information
milkyway0308 committed Jan 25, 2020
1 parent 40eb5f3 commit a51c5e0
Show file tree
Hide file tree
Showing 22 changed files with 68 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skywolf46.NBTUtil.v1_2R2;
package skywolf46.NBTUtil.v1_2R3;

import org.bukkit.Bukkit;
import org.bukkit.Server;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skywolf46.NBTUtil.v1_2R2.Exception;
package skywolf46.NBTUtil.v1_2R3.Exception;

public class CollectionMismatchedException extends RuntimeException {
public CollectionMismatchedException(Class bef, Class nex) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skywolf46.NBTUtil.v1_2R2.Exception;
package skywolf46.NBTUtil.v1_2R3.Exception;

public class UndefinedNBTException extends RuntimeException {
public UndefinedNBTException(Class c) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skywolf46.NBTUtil.v1_2R2.Interface;
package skywolf46.NBTUtil.v1_2R3.Interface;

public interface IReflectedNBTBase<T> {
T getValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skywolf46.NBTUtil.v1_2R2.Interface;
package skywolf46.NBTUtil.v1_2R3.Interface;

import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skywolf46.NBTUtil.v1_2R2.Interface;
package skywolf46.NBTUtil.v1_2R3.Interface;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2;
package skywolf46.NBTUtil.v1_2R3;

import org.bukkit.inventory.ItemStack;
import skywolf46.NBTUtil.v1_2R2.NBTData.ReflectedNBTCompound;
import skywolf46.NBTUtil.v1_2R3.NBTData.ReflectedNBTCompound;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2;
package skywolf46.NBTUtil.v1_2R3;

import org.bukkit.inventory.ItemStack;
import skywolf46.NBTUtil.v1_2R2.NBTData.ReflectedNBTCompound;
import skywolf46.NBTUtil.v1_2R3.NBTData.ReflectedNBTCompound;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package skywolf46.NBTUtil.v1_2R2.Iterator;
package skywolf46.NBTUtil.v1_2R3.Iterator;

import java.util.Iterator;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Exception.UndefinedNBTException;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTCompound;
import skywolf46.NBTUtil.v1_2R2.ReflectedNBTStorage;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Exception.UndefinedNBTException;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTCompound;
import skywolf46.NBTUtil.v1_2R3.ReflectedNBTStorage;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand All @@ -20,7 +20,7 @@ public class ReflectedNBTIntegerArray implements IReflectedNBTBase<Integer[]> {
NBT_CLASS = BukkitVersionUtil.getNMSClass("NBTTagIntArray");
CONTENT_FIELD = NBT_CLASS.getDeclaredField("data");
CONTENT_FIELD.setAccessible(true);
NBT_CONSTRUCTOR = NBT_CLASS.getConstructor(new int[0].getClass());
NBT_CONSTRUCTOR = NBT_CLASS.getConstructor(int[].class);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
Expand Down Expand Up @@ -71,7 +71,10 @@ public void setNBTValue(IReflectedNBTBase<Integer[]> base) {

public Object getNBTBase() {
try {
return NBT_CONSTRUCTOR.newInstance(Arrays.copyOf(data, data.length));
int[] data = new int[this.data.length];
for (int i = 0; i < data.length; i++)
data[i] = this.data[i];
return NBT_CONSTRUCTOR.newInstance(data);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Exception.CollectionMismatchedException;
import skywolf46.NBTUtil.v1_2R2.Exception.UndefinedNBTException;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTList;
import skywolf46.NBTUtil.v1_2R2.Iterator.LinearIterator;
import skywolf46.NBTUtil.v1_2R2.ReflectedNBTStorage;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Exception.CollectionMismatchedException;
import skywolf46.NBTUtil.v1_2R3.Exception.UndefinedNBTException;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTList;
import skywolf46.NBTUtil.v1_2R3.Iterator.LinearIterator;
import skywolf46.NBTUtil.v1_2R3.ReflectedNBTStorage;

import javax.annotation.Nonnull;
import java.lang.reflect.*;
Expand Down Expand Up @@ -56,7 +56,7 @@ public ReflectedNBTList(Object o) {
for (Object obj : listNBT)
nb.add(ReflectedNBTStorage.createReflectedNBT(obj));
if (listNBT.size() != 0)
nbtClass = listNBT.get(0).getClass();
nbtClass = nb.get(0).getClass();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -43,6 +43,10 @@ public ReflectedNBTLong() {
this.d = 0;
}

public ReflectedNBTLong(long l) {
this.d = l;
}

@Override
public Long getValue() {
return d;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2.NBTData;
package skywolf46.NBTUtil.v1_2R3.NBTData;

import skywolf46.NBTUtil.v1_2R2.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.BukkitVersionUtil;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package skywolf46.NBTUtil.v1_2R2;
package skywolf46.NBTUtil.v1_2R3;

import skywolf46.NBTUtil.v1_2R2.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R2.NBTData.*;
import skywolf46.NBTUtil.v1_2R3.Interface.IReflectedNBTBase;
import skywolf46.NBTUtil.v1_2R3.NBTData.*;

import java.util.HashMap;
import java.util.function.Function;
Expand Down

0 comments on commit a51c5e0

Please sign in to comment.