Various code simplification/fixes and a lot of typo/grammar fixes (may brake some stuff)
This commit is contained in:
@@ -68,7 +68,7 @@ public class NMSReflect {
|
||||
OBF_NAMESPACE = (String) obfHelperClass.field("SPIGOT_NAMESPACE").getStaticValue();
|
||||
MOJ_NAMESPACE = (String) obfHelperClass.field("MOJANG_PLUS_YARN_NAMESPACE").getStaticValue();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new ReflectiveOperationException("Unable to find the Paper ofbuscation mapping class or class members.", e);
|
||||
throw new ReflectiveOperationException("Unable to find the Paper obfuscation mapping class or class members.", e);
|
||||
}
|
||||
|
||||
List<ClassMapping> mappings = loadMappings(obfHelperClass);
|
||||
@@ -165,7 +165,7 @@ public class NMSReflect {
|
||||
private static List<ClassMapping> loadMappings(ReflectClass<?> obfHelperClass) throws IOException {
|
||||
try (final InputStream mappingsInputStream = obfHelperClass.get().getClassLoader().getResourceAsStream("META-INF/mappings/reobf.tiny")) {
|
||||
if (mappingsInputStream == null) {
|
||||
throw new RuntimeException("Unable to find the ofbuscation mapping file in the Paper jar.");
|
||||
throw new RuntimeException("Unable to find the obfuscation mapping file in the Paper jar.");
|
||||
}
|
||||
|
||||
MemoryMappingTree tree = new MemoryMappingTree();
|
||||
@@ -290,7 +290,7 @@ public class NMSReflect {
|
||||
|
||||
|
||||
/**
|
||||
* Represents the mapping between the obfuscated and mojang names of a class and all its members.
|
||||
* Represents the mapping between the obfuscated and Mojang names of a class and all its members.
|
||||
*/
|
||||
public static class ClassMapping {
|
||||
private static int nextID = 0;
|
||||
@@ -463,9 +463,9 @@ public class NMSReflect {
|
||||
private List<NMSTypeWrapper> superInterfaces(boolean obf) {
|
||||
Class<?>[] interfaces = runtimeClass().getInterfaces();
|
||||
List<NMSTypeWrapper> types = new ArrayList<>(interfaces.length);
|
||||
for (Class<?> interfce : interfaces) {
|
||||
ClassMapping cm = (IS_SERVER_OBFUSCATED ? CLASSES_BY_OBF : CLASSES_BY_MOJ).get(interfce.getName());
|
||||
types.add((cm != null) ? cm.toType(obf) : NMSTypeWrapper.of(interfce));
|
||||
for (Class<?> i : interfaces) {
|
||||
ClassMapping cm = (IS_SERVER_OBFUSCATED ? CLASSES_BY_OBF : CLASSES_BY_MOJ).get(i.getName());
|
||||
types.add((cm != null) ? cm.toType(obf) : NMSTypeWrapper.of(i));
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ public class OBCReflect {
|
||||
|
||||
/**
|
||||
* Returns the OBC class that has the provided name, wrapped into a {@link ReflectClass}.
|
||||
* @param obcClass the name of the class, including the subpackage in whitch the requested class is. This parameter
|
||||
* @param obcClass the name of the class, including the subpackage in which the requested class is. This parameter
|
||||
* will be prefixed with the {@code OBC} package and the current package version.
|
||||
* @return the OBC class that has the provided name, wrapped into a {@link ReflectClass}.
|
||||
* @throws ClassNotFoundException if the provided class was not found in {@code OBC} package.
|
||||
|
@@ -79,14 +79,14 @@ import fr.pandacube.lib.util.ThrowableAccumulator;
|
||||
import static fr.pandacube.lib.reflect.wrapper.WrapperRegistry.initWrapper;
|
||||
|
||||
/**
|
||||
* Initializer for all the reflect tools in {@code pandalib-paper-reflect} module.
|
||||
* Initializer for all the reflection tools in {@code pandalib-paper-reflect} module.
|
||||
*/
|
||||
public class PandalibPaperReflect {
|
||||
|
||||
private static boolean isInit = false;
|
||||
|
||||
/**
|
||||
* Initializes the reflect tools in {@code pandalib-paper-reflect} module.
|
||||
* Initializes the reflection tools in {@code pandalib-paper-reflect} module.
|
||||
* @throws Exception if a problem occurs when initializing wrapper classes.
|
||||
*/
|
||||
public static void init() throws Exception {
|
||||
@@ -117,7 +117,7 @@ public class PandalibPaperReflect {
|
||||
thAcc.catchThrowable(() -> initWrapper(RenderData.class, RenderData.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(VanillaCommandWrapper.class, VanillaCommandWrapper.REFLECT.get()));
|
||||
|
||||
// dataconverter
|
||||
// data-converter
|
||||
thAcc.catchThrowable(() -> initWrapper(MCDataConverter.class, MCDataConverter.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(MCDataType.class, MCDataType.REFLECT.get()));
|
||||
thAcc.catchThrowable(() -> initWrapper(MCTypeRegistry.class, MCTypeRegistry.REFLECT.get()));
|
||||
@@ -204,7 +204,7 @@ public class PandalibPaperReflect {
|
||||
thAcc.catchThrowable(() -> initWrapper(QueuedChangesMapLong2Object.class, QueuedChangesMapLong2Object.REFLECT.get()));
|
||||
|
||||
|
||||
thAcc.throwCatched();
|
||||
thAcc.throwCaught();
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ public final class BedrockBambooCollisionFixer implements Listener {
|
||||
// Make the bamboo block have zero collision.
|
||||
try {
|
||||
BambooStalkBlock.COLLISION_SHAPE(new AABBVoxelShape(new AABB(0.5, 0, 0.5, 0.5, 0, 0.5)));
|
||||
Log.info("Bamboo block collision box removed succesfully.");
|
||||
Log.info("Bamboo block collision box removed successfully.");
|
||||
} catch (Exception e) {
|
||||
Log.severe("Unable to remove the collision box of the Bamboo block.", e);
|
||||
return;
|
||||
|
@@ -2,14 +2,10 @@ package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
||||
|
||||
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.ReflectField;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||
|
@@ -19,12 +19,12 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||
|
||||
public class VanillaCommandWrapper extends ReflectWrapperTyped<BukkitCommand> {
|
||||
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("command.VanillaCommandWrapper"));
|
||||
public static final ReflectConstructor<?> CONSTRUTOR = wrapEx(() -> REFLECT.constructor(Commands.MAPPING.runtimeClass(), CommandNode.class));
|
||||
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(Commands.MAPPING.runtimeClass(), CommandNode.class));
|
||||
public static final ReflectField<?> vanillaCommand = wrapEx(() -> REFLECT.field("vanillaCommand"));
|
||||
public static final ReflectMethod<?> getListener = wrapEx(() -> REFLECT.method("getListener", CommandSender.class));
|
||||
|
||||
public VanillaCommandWrapper(Commands dispatcher, CommandNode<BukkitBrigadierCommandSource> vanillaCommand) {
|
||||
this(wrapReflectEx(() -> CONSTRUTOR.instanciate(unwrap(dispatcher), vanillaCommand)));
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(dispatcher), vanillaCommand)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.dataconverter;
|
||||
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component;
|
||||
import fr.pandacube.lib.reflect.Reflect;
|
||||
import fr.pandacube.lib.reflect.ReflectClass;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
|
@@ -57,7 +57,7 @@ public class CompoundTag extends ReflectWrapper implements Tag {
|
||||
private static final ReflectMethod<?> containsStringInt = wrapEx(() -> MAPPING.mojMethod("contains", String.class, int.class));
|
||||
|
||||
public CompoundTag() {
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate()));
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate()));
|
||||
}
|
||||
|
||||
protected CompoundTag(Object nms) {
|
||||
@@ -167,7 +167,7 @@ public class CompoundTag extends ReflectWrapper implements Tag {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, ?> entries() {
|
||||
// we cannot easily wrap every value of the map without being able to synch the returned map with the wrapped map
|
||||
// we cannot easily wrap every value of the map without being able to synchronize the returned map with the wrapped map
|
||||
return (Map<String, ?>) wrapReflectEx(() -> entries.invoke(__getRuntimeInstance()));
|
||||
}
|
||||
public int size() {
|
||||
|
@@ -4,7 +4,6 @@ import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
||||
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||
@@ -19,7 +18,7 @@ public class ListTag extends CollectionTag {
|
||||
}
|
||||
|
||||
public ListTag() {
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate()));
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate()));
|
||||
}
|
||||
|
||||
protected ListTag(Object nms) {
|
||||
|
@@ -14,7 +14,7 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
private static final ReflectMethod<?> writeUtf = wrapEx(() -> MAPPING.mojMethod("writeUtf", String.class));
|
||||
|
||||
public FriendlyByteBuf(ByteBuf parent) {
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(parent))));
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(parent))));
|
||||
}
|
||||
|
||||
public FriendlyByteBuf writeUtf(String string) {
|
||||
|
@@ -24,6 +24,6 @@ public class ClientboundCustomPayloadPacket extends ReflectWrapper implements Pa
|
||||
}
|
||||
|
||||
public ClientboundCustomPayloadPacket(ResourceLocation res, FriendlyByteBuf buff) {
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(res), unwrap(buff))));
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(res), unwrap(buff))));
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ public class ClientboundGameEventPacket extends ReflectWrapper implements Packet
|
||||
}
|
||||
|
||||
public ClientboundGameEventPacket(Type type, float value) {
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(type), value)));
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(type), value)));
|
||||
}
|
||||
|
||||
protected ClientboundGameEventPacket(Object obj) {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
||||
|
||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
|
||||
|
@@ -12,7 +12,7 @@ public class AABB extends ReflectWrapper {
|
||||
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(double.class, double.class, double.class, double.class, double.class, double.class));
|
||||
|
||||
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(x1, y1, z1, x2, y2, z2)));
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x1, y1, z1, x2, y2, z2)));
|
||||
}
|
||||
|
||||
protected AABB(Object obj) {
|
||||
|
@@ -12,7 +12,7 @@ public class ChunkPos extends ReflectWrapper {
|
||||
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(int.class, int.class));
|
||||
|
||||
public ChunkPos(int x, int z) {
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(x, z)));
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(x, z)));
|
||||
}
|
||||
|
||||
protected ChunkPos(Object obj) {
|
||||
|
@@ -2,10 +2,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
import fr.pandacube.lib.reflect.ReflectField;
|
||||
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||
|
||||
public class DamageSource extends ReflectWrapper {
|
||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSource"));
|
||||
|
@@ -1,11 +1,9 @@
|
||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||
import fr.pandacube.lib.reflect.ReflectField;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||
|
||||
public class DamageSources extends ReflectWrapper {
|
||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSources"));
|
||||
|
@@ -2,8 +2,6 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||
|
||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
||||
import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.WorldConfiguration;
|
||||
import fr.pandacube.lib.reflect.ReflectField;
|
||||
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||
|
||||
|
@@ -14,7 +14,7 @@ public class AABBVoxelShape extends VoxelShape {
|
||||
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(AABB.MAPPING.runtimeClass()));
|
||||
|
||||
public AABBVoxelShape(AABB aabb) {
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(aabb))));
|
||||
this(wrapReflectEx(() -> CONSTRUCTOR.instantiate(unwrap(aabb))));
|
||||
}
|
||||
|
||||
protected AABBVoxelShape(Object obj) {
|
||||
|
Reference in New Issue
Block a user