From 045ca8b6403cf8b728e569de191cbdf6bad2ea12 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Thu, 8 Sep 2022 23:42:12 +0200 Subject: [PATCH] Fix various warnings and progress some javadoc --- .../permissions/PermissionsInjectorVault.java | 14 +++++ pandalib-paper-reflect/pom.xml | 12 ++++ .../lib/paper/reflect/NMSReflect.java | 60 +++++++++++++------ .../lib/paper/reflect/OBCReflect.java | 15 ++++- pandalib-permissions/pom.xml | 2 +- 5 files changed, 81 insertions(+), 22 deletions(-) diff --git a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorVault.java b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorVault.java index 298515f..acded4e 100644 --- a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorVault.java +++ b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorVault.java @@ -70,11 +70,13 @@ import fr.pandacube.lib.util.Log; return permission.startsWith("-"); } + @Deprecated @Override public boolean playerAdd(String world, String player, String permission) { return false; } + @Deprecated @Override public boolean playerRemove(String world, String player, String permission) { return false; @@ -114,11 +116,13 @@ import fr.pandacube.lib.util.Log; return Permissions.getPlayer(player.getUniqueId()).isInGroup(group); } + @Deprecated @Override public boolean playerAddGroup(String world, String player, String group) { return false; } + @Deprecated @Override public boolean playerRemoveGroup(String world, String player, String group) { return false; @@ -210,40 +214,50 @@ import fr.pandacube.lib.util.Log; return Permissions.getGroup(group).getSuffix(); } + @Deprecated @Override public void setPlayerPrefix(String world, String player, String prefix) { /* unsupported */ } + @Deprecated @Override public void setPlayerSuffix(String world, String player, String suffix) { /* unsupported */ } @Override public void setGroupPrefix(String world, String group, String prefix) { /* unsupported */ } @Override public void setGroupSuffix(String world, String group, String suffix) { /* unsupported */ } + @Deprecated @Override public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) { return defaultValue; } + @Deprecated @Override public void setPlayerInfoInteger(String world, String player, String node, int value) { /* unsupported */ } @Override public int getGroupInfoInteger(String world, String group, String node, int defaultValue) { return defaultValue; } @Override public void setGroupInfoInteger(String world, String group, String node, int value) { /* unsupported */ } + @Deprecated @Override public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) { return defaultValue; } + @Deprecated @Override public void setPlayerInfoDouble(String world, String player, String node, double value) { /* unsupported */ } @Override public double getGroupInfoDouble(String world, String group, String node, double defaultValue) { return defaultValue; } @Override public void setGroupInfoDouble(String world, String group, String node, double value) { /* unsupported */ } + @Deprecated @Override public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) { return defaultValue; } + @Deprecated @Override public void setPlayerInfoBoolean(String world, String player, String node, boolean value) { /* unsupported */ } @Override public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) { return defaultValue; } @Override public void setGroupInfoBoolean(String world, String group, String node, boolean value) { /* unsupported */ } + @Deprecated @Override public String getPlayerInfoString(String world, String player, String node, String defaultValue) { return defaultValue; } + @Deprecated @Override public void setPlayerInfoString(String world, String player, String node, String value) { /* unsupported */ } @Override diff --git a/pandalib-paper-reflect/pom.xml b/pandalib-paper-reflect/pom.xml index 3577f30..f8f54c4 100644 --- a/pandalib-paper-reflect/pom.xml +++ b/pandalib-paper-reflect/pom.xml @@ -60,4 +60,16 @@ + + + + org.apache.maven.plugins + maven-javadoc-plugin + + fr.pandacube.lib.paper.reflect.wrapper.* + + + + + \ No newline at end of file diff --git a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java index 3dad204..0193f70 100644 --- a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java +++ b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java @@ -30,6 +30,10 @@ import net.fabricmc.mappingio.format.MappingFormat; import net.fabricmc.mappingio.tree.MappingTree; import net.fabricmc.mappingio.tree.MemoryMappingTree; +/** + * Provides reflection tools related to Minecraft servers internals. + * It automatically deals with the obfuscated classes and methods. + */ public class NMSReflect { @@ -42,7 +46,10 @@ public class NMSReflect { private static Boolean IS_SERVER_OBFUSCATED; private static boolean isInit = false; - + + /** + * Initialize all the obfuscation mapping data. + */ public static void init() { synchronized (NMSReflect.class) { @@ -137,7 +144,9 @@ public class NMSReflect { /** + * Returns the class mapping instance for the provided class. * @param mojName the binary name of the desired class, on the mojang mapping. + * @return the class mapping instance for the provided class. * @throws NullPointerException if there is no mapping for the provided Mojang mapped class. */ public static ClassMapping mojClass(String mojName) { @@ -169,9 +178,12 @@ public class NMSReflect { return classes; } } - - - + + + /** + * Prints an HTML rendering of the currently loaded obfuscation mapping, into the provided {@link PrintStream}. + * @param out the stream in which to print the HTML content. + */ public static void printHTMLMapping(PrintStream out) { String title = "Obfuscation mapping - " + Bukkit.getName() + " version " + Bukkit.getVersion(); out.println("\n" @@ -275,12 +287,12 @@ public class NMSReflect { + " running on " + Bukkit.getName() + " version " + Bukkit.getVersion() + "

" + ""); } - - - - - - public static class ClassMapping { + + + /** + * 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; /* package */ final int id = nextID++; @@ -317,14 +329,22 @@ public class NMSReflect { if (runtimeReflectClass == null) runtimeReflectClass = Reflect.ofClass(IS_SERVER_OBFUSCATED ? obfName : mojName); } - - - - + + + /** + * Returns the actual runtime {@link Class} represented by this {@link ClassMapping}, wrapped into a + * {@link ReflectClass}. + * @return the actual runtime {@link Class} represented by this {@link ClassMapping}, wrapped into a + * * {@link ReflectClass}. + */ public ReflectClass runtimeReflect() { return runtimeReflectClass; } - + + /** + * Returns the actual runtime Class represented by this {@link ClassMapping}. + * @return the actual runtime Class represented by this {@link ClassMapping}. + */ public Class runtimeClass() { return runtimeReflectClass.get(); } @@ -333,11 +353,14 @@ public class NMSReflect { /** - * + * Returns the actual runtime Method that has the provided mojang name and parameter types, wrapped into a + * {@link ReflectMethod}. * @param mojName the Mojang mapped name of the method. * @param mojParametersType the list of parameters of the method. * Each parameter type must be an instance of one of the following type: * {@link NMSTypeWrapper}, {@link Class}, {@link ReflectClass} or {@link ClassMapping}. + * @return the actual runtime Method that has the provided mojang name and parameter types, wrapped into a + * {@link ReflectMethod}. * @throws IllegalArgumentException if one of the parameter has an invalid type * @throws NullPointerException if one of the parameter is null, or if there is no mapping for the provided Mojang mapped method. * @throws ClassNotFoundException if there is no runtime class to represent one of the provided parametersType. @@ -364,10 +387,11 @@ public class NMSReflect { /** - * + * Returns the actual runtime Field that has the provided mojang name, wrapped into a {@link ReflectField}. * @param mojName the Mojang mapped name of the field. + * @return the actual runtime Field that has the provided mojang name, wrapped into a {@link ReflectField}. * @throws NullPointerException if there is no mapping for the provided Mojang mapped field. - * @throws NoSuchFieldException if there is no runtime method to represent the provided method. + * @throws NoSuchFieldException if there is no runtime field to represent the provided mojang field. */ public ReflectField mojField(String mojName) throws NoSuchFieldException { MemberMapping> fm = fieldsByMoj.get(mojName); diff --git a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/OBCReflect.java b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/OBCReflect.java index 466c717..b0c8076 100644 --- a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/OBCReflect.java +++ b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/OBCReflect.java @@ -5,6 +5,9 @@ import org.bukkit.Bukkit; import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.ReflectClass; +/** + * Provides reflection tools related to {@code org.bukkit.craftbukkit}. + */ public class OBCReflect { private static final String OBC_PACKAGE_PREFIX = "org.bukkit.craftbukkit."; @@ -18,9 +21,15 @@ public class OBCReflect { OBC_PACKAGE_VERSION = name; } - - - + + + /** + * 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 + * 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. + */ public static ReflectClass ofClass(String obcClass) throws ClassNotFoundException { return Reflect.ofClass(OBC_PACKAGE_PREFIX + OBC_PACKAGE_VERSION + "." + obcClass); } diff --git a/pandalib-permissions/pom.xml b/pandalib-permissions/pom.xml index d51456f..7cec9a4 100644 --- a/pandalib-permissions/pom.xml +++ b/pandalib-permissions/pom.xml @@ -65,7 +65,7 @@ META-INF/*.SF META-INF/*.DSA META-INF/*.RSA - META-INF/MANIFEDT.MF + META-INF/MANIFEST.MF