Fix various warnings and progress some javadoc

This commit is contained in:
Marc Baloup 2022-09-08 23:42:12 +02:00
parent 83e35f21bd
commit 045ca8b640
5 changed files with 81 additions and 22 deletions

View File

@ -70,11 +70,13 @@ import fr.pandacube.lib.util.Log;
return permission.startsWith("-"); return permission.startsWith("-");
} }
@Deprecated
@Override @Override
public boolean playerAdd(String world, String player, String permission) { public boolean playerAdd(String world, String player, String permission) {
return false; return false;
} }
@Deprecated
@Override @Override
public boolean playerRemove(String world, String player, String permission) { public boolean playerRemove(String world, String player, String permission) {
return false; return false;
@ -114,11 +116,13 @@ import fr.pandacube.lib.util.Log;
return Permissions.getPlayer(player.getUniqueId()).isInGroup(group); return Permissions.getPlayer(player.getUniqueId()).isInGroup(group);
} }
@Deprecated
@Override @Override
public boolean playerAddGroup(String world, String player, String group) { public boolean playerAddGroup(String world, String player, String group) {
return false; return false;
} }
@Deprecated
@Override @Override
public boolean playerRemoveGroup(String world, String player, String group) { public boolean playerRemoveGroup(String world, String player, String group) {
return false; return false;
@ -210,40 +214,50 @@ import fr.pandacube.lib.util.Log;
return Permissions.getGroup(group).getSuffix(); return Permissions.getGroup(group).getSuffix();
} }
@Deprecated
@Override @Override
public void setPlayerPrefix(String world, String player, String prefix) { /* unsupported */ } public void setPlayerPrefix(String world, String player, String prefix) { /* unsupported */ }
@Deprecated
@Override @Override
public void setPlayerSuffix(String world, String player, String suffix) { /* unsupported */ } public void setPlayerSuffix(String world, String player, String suffix) { /* unsupported */ }
@Override @Override
public void setGroupPrefix(String world, String group, String prefix) { /* unsupported */ } public void setGroupPrefix(String world, String group, String prefix) { /* unsupported */ }
@Override @Override
public void setGroupSuffix(String world, String group, String suffix) { /* unsupported */ } public void setGroupSuffix(String world, String group, String suffix) { /* unsupported */ }
@Deprecated
@Override @Override
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) { return defaultValue; } public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) { return defaultValue; }
@Deprecated
@Override @Override
public void setPlayerInfoInteger(String world, String player, String node, int value) { /* unsupported */ } public void setPlayerInfoInteger(String world, String player, String node, int value) { /* unsupported */ }
@Override @Override
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) { return defaultValue; } public int getGroupInfoInteger(String world, String group, String node, int defaultValue) { return defaultValue; }
@Override @Override
public void setGroupInfoInteger(String world, String group, String node, int value) { /* unsupported */ } public void setGroupInfoInteger(String world, String group, String node, int value) { /* unsupported */ }
@Deprecated
@Override @Override
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) { return defaultValue; } public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) { return defaultValue; }
@Deprecated
@Override @Override
public void setPlayerInfoDouble(String world, String player, String node, double value) { /* unsupported */ } public void setPlayerInfoDouble(String world, String player, String node, double value) { /* unsupported */ }
@Override @Override
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) { return defaultValue; } public double getGroupInfoDouble(String world, String group, String node, double defaultValue) { return defaultValue; }
@Override @Override
public void setGroupInfoDouble(String world, String group, String node, double value) { /* unsupported */ } public void setGroupInfoDouble(String world, String group, String node, double value) { /* unsupported */ }
@Deprecated
@Override @Override
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) { return defaultValue; } public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) { return defaultValue; }
@Deprecated
@Override @Override
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) { /* unsupported */ } public void setPlayerInfoBoolean(String world, String player, String node, boolean value) { /* unsupported */ }
@Override @Override
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) { return defaultValue; } public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) { return defaultValue; }
@Override @Override
public void setGroupInfoBoolean(String world, String group, String node, boolean value) { /* unsupported */ } public void setGroupInfoBoolean(String world, String group, String node, boolean value) { /* unsupported */ }
@Deprecated
@Override @Override
public String getPlayerInfoString(String world, String player, String node, String defaultValue) { return defaultValue; } public String getPlayerInfoString(String world, String player, String node, String defaultValue) { return defaultValue; }
@Deprecated
@Override @Override
public void setPlayerInfoString(String world, String player, String node, String value) { /* unsupported */ } public void setPlayerInfoString(String world, String player, String node, String value) { /* unsupported */ }
@Override @Override

View File

@ -60,4 +60,16 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<excludePackageNames>fr.pandacube.lib.paper.reflect.wrapper.*</excludePackageNames>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -30,6 +30,10 @@ import net.fabricmc.mappingio.format.MappingFormat;
import net.fabricmc.mappingio.tree.MappingTree; import net.fabricmc.mappingio.tree.MappingTree;
import net.fabricmc.mappingio.tree.MemoryMappingTree; 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 { public class NMSReflect {
@ -42,7 +46,10 @@ public class NMSReflect {
private static Boolean IS_SERVER_OBFUSCATED; private static Boolean IS_SERVER_OBFUSCATED;
private static boolean isInit = false; private static boolean isInit = false;
/**
* Initialize all the obfuscation mapping data.
*/
public static void init() { public static void init() {
synchronized (NMSReflect.class) { 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. * @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. * @throws NullPointerException if there is no mapping for the provided Mojang mapped class.
*/ */
public static ClassMapping mojClass(String mojName) { public static ClassMapping mojClass(String mojName) {
@ -169,9 +178,12 @@ public class NMSReflect {
return classes; 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) { public static void printHTMLMapping(PrintStream out) {
String title = "Obfuscation mapping - " + Bukkit.getName() + " version " + Bukkit.getVersion(); String title = "Obfuscation mapping - " + Bukkit.getName() + " version " + Bukkit.getVersion();
out.println("<!DOCTYPE html><html><head>\n" out.println("<!DOCTYPE html><html><head>\n"
@ -275,12 +287,12 @@ public class NMSReflect {
+ " running on <a href='https://papermc.io/'>" + Bukkit.getName() + "</a> version " + Bukkit.getVersion() + "</p>" + " running on <a href='https://papermc.io/'>" + Bukkit.getName() + "</a> version " + Bukkit.getVersion() + "</p>"
+ "</body></html>"); + "</body></html>");
} }
/**
* Represents the mapping between the obfuscated and mojang names of a class and all its members.
*/
public static class ClassMapping { public static class ClassMapping {
private static int nextID = 0; private static int nextID = 0;
/* package */ final int id = nextID++; /* package */ final int id = nextID++;
@ -317,14 +329,22 @@ public class NMSReflect {
if (runtimeReflectClass == null) if (runtimeReflectClass == null)
runtimeReflectClass = Reflect.ofClass(IS_SERVER_OBFUSCATED ? obfName : mojName); 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() { public ReflectClass<?> runtimeReflect() {
return runtimeReflectClass; 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() { public Class<?> runtimeClass() {
return runtimeReflectClass.get(); 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 mojName the Mojang mapped name of the method.
* @param mojParametersType the list of parameters 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: * Each parameter type must be an instance of one of the following type:
* {@link NMSTypeWrapper}, {@link Class}, {@link ReflectClass} or {@link ClassMapping}. * {@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 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 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. * @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. * @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 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 { public ReflectField<?> mojField(String mojName) throws NoSuchFieldException {
MemberMapping<String, ReflectField<?>> fm = fieldsByMoj.get(mojName); MemberMapping<String, ReflectField<?>> fm = fieldsByMoj.get(mojName);

View File

@ -5,6 +5,9 @@ import org.bukkit.Bukkit;
import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
/**
* Provides reflection tools related to {@code org.bukkit.craftbukkit}.
*/
public class OBCReflect { public class OBCReflect {
private static final String OBC_PACKAGE_PREFIX = "org.bukkit.craftbukkit."; private static final String OBC_PACKAGE_PREFIX = "org.bukkit.craftbukkit.";
@ -18,9 +21,15 @@ public class OBCReflect {
OBC_PACKAGE_VERSION = name; 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 { public static ReflectClass<?> ofClass(String obcClass) throws ClassNotFoundException {
return Reflect.ofClass(OBC_PACKAGE_PREFIX + OBC_PACKAGE_VERSION + "." + obcClass); return Reflect.ofClass(OBC_PACKAGE_PREFIX + OBC_PACKAGE_VERSION + "." + obcClass);
} }

View File

@ -65,7 +65,7 @@
<exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude> <exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/MANIFEDT.MF</exclude> <exclude>META-INF/MANIFEST.MF</exclude>
</excludes> </excludes>
</filter> </filter>
</filters> </filters>