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
|
||||
(byte) 0, //Scale, 0 = 1 block per pixel
|
||||
false, //Show icons
|
||||
new ArrayList<>(), //Icons
|
||||
new ReflectionUtil.CollectionParam<>(), //Icons
|
||||
updateData
|
||||
);
|
||||
} else if (ReflectionUtil.supports(14)) { //1.16-1.14
|
||||
|
@ -132,7 +132,7 @@ public class MapSender {
|
|||
(byte) 0, //Scale, 0 = 1 block per pixel
|
||||
false, //Tracking position
|
||||
false, //Locked
|
||||
new ArrayList<>(), //Icons
|
||||
new ReflectionUtil.CollectionParam<>(), //Icons
|
||||
content.array, //Data
|
||||
content.minX, //X pos
|
||||
content.minY, //Y pos
|
||||
|
@ -144,7 +144,7 @@ public class MapSender {
|
|||
id, //ID
|
||||
(byte) 0, //Scale, 0 = 1 block per pixel
|
||||
false, //???
|
||||
new ArrayList<>(), //Icons
|
||||
new ReflectionUtil.CollectionParam<>(), //Icons
|
||||
content.array, //Data
|
||||
content.minX, //X 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.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.
|
||||
|
@ -333,12 +337,21 @@ public class MapWrapper extends AbstractMapWrapper {
|
|||
}
|
||||
Object dataWatcherObject = ReflectionUtil.getDeclaredField(entityItemFrameClass, dataWatcherObjectName);
|
||||
|
||||
List list = new ArrayList<>();
|
||||
ReflectionUtil.ListParam list = new ReflectionUtil.ListParam<>();
|
||||
|
||||
Object packet;
|
||||
if (ReflectionUtil.supports(19, 3)) { //1.19.3
|
||||
Object dataWatcherField = ReflectionUtil.getDeclaredField(dataWatcherClass, "b");
|
||||
Object dataWatcherItem = ReflectionUtil.callDeclaredMethod(dataWatcherField, "a", dataWatcherObject, nmsStack);
|
||||
if (ReflectionUtil.supports(19, 2)) { //1.19.3
|
||||
Class<?> dataWatcherRecordClass = ReflectionUtil.getNMSClass("network.syncher", "DataWatcher$b");
|
||||
// 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);
|
||||
|
||||
packet = ReflectionUtil.callConstructor(entityMetadataPacketClass,
|
||||
|
|
|
@ -31,10 +31,7 @@ import java.lang.reflect.Constructor;
|
|||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
|
@ -200,6 +197,24 @@ public class ReflectionUtil {
|
|||
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) {
|
||||
if (clazz == Boolean.class) return boolean.class;
|
||||
if (clazz == Integer.class) return int.class;
|
||||
|
@ -210,7 +225,10 @@ public class ReflectionUtil {
|
|||
if (clazz == Byte.class) return byte.class;
|
||||
if (clazz == Void.class) return void.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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue