Fixed 1.19.3 support
This commit is contained in:
parent
2735fbeb1c
commit
d3badb5fd3
3 changed files with 44 additions and 13 deletions
|
@ -123,7 +123,7 @@ public class MapSender {
|
||||||
id, //ID
|
id, //ID
|
||||||
(byte) 0, //Scale, 0 = 1 block per pixel
|
(byte) 0, //Scale, 0 = 1 block per pixel
|
||||||
false, //Show icons
|
false, //Show icons
|
||||||
new ArrayList<>(), //Icons
|
new ReflectionUtil.CollectionParam<>(), //Icons
|
||||||
updateData
|
updateData
|
||||||
);
|
);
|
||||||
} else if (ReflectionUtil.supports(14)) { //1.16-1.14
|
} else if (ReflectionUtil.supports(14)) { //1.16-1.14
|
||||||
|
@ -132,7 +132,7 @@ public class MapSender {
|
||||||
(byte) 0, //Scale, 0 = 1 block per pixel
|
(byte) 0, //Scale, 0 = 1 block per pixel
|
||||||
false, //Tracking position
|
false, //Tracking position
|
||||||
false, //Locked
|
false, //Locked
|
||||||
new ArrayList<>(), //Icons
|
new ReflectionUtil.CollectionParam<>(), //Icons
|
||||||
content.array, //Data
|
content.array, //Data
|
||||||
content.minX, //X pos
|
content.minX, //X pos
|
||||||
content.minY, //Y pos
|
content.minY, //Y pos
|
||||||
|
@ -144,7 +144,7 @@ public class MapSender {
|
||||||
id, //ID
|
id, //ID
|
||||||
(byte) 0, //Scale, 0 = 1 block per pixel
|
(byte) 0, //Scale, 0 = 1 block per pixel
|
||||||
false, //???
|
false, //???
|
||||||
new ArrayList<>(), //Icons
|
new ReflectionUtil.CollectionParam<>(), //Icons
|
||||||
content.array, //Data
|
content.array, //Data
|
||||||
content.minX, //X pos
|
content.minX, //X pos
|
||||||
content.minY, //Y pos
|
content.minY, //Y pos
|
||||||
|
|
|
@ -31,7 +31,11 @@ import tech.sbdevelopment.mapreflectionapi.api.exceptions.MapLimitExceededExcept
|
||||||
import tech.sbdevelopment.mapreflectionapi.managers.Configuration;
|
import tech.sbdevelopment.mapreflectionapi.managers.Configuration;
|
||||||
import tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtil;
|
import tech.sbdevelopment.mapreflectionapi.utils.ReflectionUtil;
|
||||||
|
|
||||||
import java.util.*;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link MapWrapper} wraps one image.
|
* A {@link MapWrapper} wraps one image.
|
||||||
|
@ -333,12 +337,21 @@ public class MapWrapper extends AbstractMapWrapper {
|
||||||
}
|
}
|
||||||
Object dataWatcherObject = ReflectionUtil.getDeclaredField(entityItemFrameClass, dataWatcherObjectName);
|
Object dataWatcherObject = ReflectionUtil.getDeclaredField(entityItemFrameClass, dataWatcherObjectName);
|
||||||
|
|
||||||
List list = new ArrayList<>();
|
ReflectionUtil.ListParam list = new ReflectionUtil.ListParam<>();
|
||||||
|
|
||||||
Object packet;
|
Object packet;
|
||||||
if (ReflectionUtil.supports(19, 3)) { //1.19.3
|
if (ReflectionUtil.supports(19, 2)) { //1.19.3
|
||||||
Object dataWatcherField = ReflectionUtil.getDeclaredField(dataWatcherClass, "b");
|
Class<?> dataWatcherRecordClass = ReflectionUtil.getNMSClass("network.syncher", "DataWatcher$b");
|
||||||
Object dataWatcherItem = ReflectionUtil.callDeclaredMethod(dataWatcherField, "a", dataWatcherObject, nmsStack);
|
// Sadly not possible to use ReflectionUtil (in its current state), because of the Object parameter
|
||||||
|
Object dataWatcherItem;
|
||||||
|
try {
|
||||||
|
Method m = dataWatcherRecordClass.getMethod("a", dataWatcherObject.getClass(), Object.class);
|
||||||
|
m.setAccessible(true);
|
||||||
|
dataWatcherItem = m.invoke(null, dataWatcherObject, nmsStack);
|
||||||
|
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
list.add(dataWatcherItem);
|
list.add(dataWatcherItem);
|
||||||
|
|
||||||
packet = ReflectionUtil.callConstructor(entityMetadataPacketClass,
|
packet = ReflectionUtil.callConstructor(entityMetadataPacketClass,
|
||||||
|
|
|
@ -31,10 +31,7 @@ import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -200,6 +197,24 @@ public class ReflectionUtil {
|
||||||
return VER >= major && VER_MINOR >= minor;
|
return VER >= major && VER_MINOR >= minor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class converted to {@link List}
|
||||||
|
*
|
||||||
|
* @param <E> The storage type
|
||||||
|
*/
|
||||||
|
public static class ListParam<E> extends ArrayList<E> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class converted to {@link Collection}
|
||||||
|
*
|
||||||
|
* @param <E> The storage type
|
||||||
|
*/
|
||||||
|
public static class CollectionParam<E> extends ArrayList<E> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static Class<?> wrapperToPrimitive(Class<?> clazz) {
|
private static Class<?> wrapperToPrimitive(Class<?> clazz) {
|
||||||
if (clazz == Boolean.class) return boolean.class;
|
if (clazz == Boolean.class) return boolean.class;
|
||||||
if (clazz == Integer.class) return int.class;
|
if (clazz == Integer.class) return int.class;
|
||||||
|
@ -210,7 +225,10 @@ public class ReflectionUtil {
|
||||||
if (clazz == Byte.class) return byte.class;
|
if (clazz == Byte.class) return byte.class;
|
||||||
if (clazz == Void.class) return void.class;
|
if (clazz == Void.class) return void.class;
|
||||||
if (clazz == Character.class) return char.class;
|
if (clazz == Character.class) return char.class;
|
||||||
if (clazz == ArrayList.class) return Collection.class;
|
if (clazz == CollectionParam.class) return Collection.class;
|
||||||
|
if (clazz == ListParam.class) return List.class;
|
||||||
|
if (clazz == ArrayList.class) return Collection.class; //LEGACY!
|
||||||
|
if (clazz == HashMap.class) return Map.class;
|
||||||
return clazz;
|
return clazz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue