Progress javadoc, various refactor + new module pandalib-commands

This commit is contained in:
Marc Baloup 2022-08-03 01:45:18 +02:00
parent 660414424e
commit 3bcd8d315b
Signed by: marcbal
GPG Key ID: BBC0FE3ABC30B893
78 changed files with 791 additions and 683 deletions

View File

@ -49,12 +49,12 @@
<artifactId>bungeecord-config</artifactId> <artifactId>bungeecord-config</artifactId>
<version>${bungeecord.version}</version> <version>${bungeecord.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.mojang</groupId> <groupId>fr.pandacube.lib</groupId>
<artifactId>brigadier</artifactId> <artifactId>pandalib-commands</artifactId>
<version>1.0.17</version> <version>${project.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -16,7 +16,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import com.mojang.brigadier.tree.LiteralCommandNode; import com.mojang.brigadier.tree.LiteralCommandNode;
import fr.pandacube.lib.chat.ChatStatic; import fr.pandacube.lib.chat.ChatStatic;
import fr.pandacube.lib.core.commands.SuggestionsSupplier; import fr.pandacube.lib.commands.SuggestionsSupplier;
import fr.pandacube.lib.util.Log; import fr.pandacube.lib.util.Log;
import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.Reflect;

43
pandalib-commands/pom.xml Normal file
View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>pandalib-parent</artifactId>
<groupId>fr.pandacube.lib</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>pandalib-commands</artifactId>
<packaging>jar</packaging>
<repositories>
<repository>
<id>minecraft-libraries</id>
<name>Minecraft Libraries</name>
<url>https://libraries.minecraft.net</url>
</repository>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>brigadier</artifactId>
<version>1.0.18</version>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,6 @@
package fr.pandacube.lib.core.commands; package fr.pandacube.lib.commands;
import fr.pandacube.lib.util.ListUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -11,25 +13,51 @@ import java.util.stream.Collectors;
import java.util.stream.LongStream; import java.util.stream.LongStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import fr.pandacube.lib.util.ListUtil; /**
import fr.pandacube.lib.util.TimeUtil; * Functionnal interface providing suggestions for an argument of a command.
* @param <S> the type of the command sender.
*/
@FunctionalInterface @FunctionalInterface
public interface SuggestionsSupplier<S> { public interface SuggestionsSupplier<S> {
/**
* Gets the suggestion based on the parameters.
* @param sender the sender of the command
* @param tokenIndex the index, in {@code args}, of the currently typed token
* @param token the token current value.
* @param args all the space-separated parameters.
* @return the suggestions to show to the user.
*/
List<String> getSuggestions(S sender, int tokenIndex, String token, String[] args);
/** /**
* Number of suggestion visible at once without having to scroll * Number of suggestion visible at once without having to scroll IG.
*/ */
int VISIBLE_SUGGESTION_COUNT = 10; int VISIBLE_SUGGESTION_COUNT = 10;
List<String> getSuggestions(S sender, int tokenIndex, String token, String[] args);
/**
* Provides a filter that only accepts Strings that starts with the provided token, ignoring the case.
* @param token the token to filter with.
* @return a filter for the provided token.
*/
static Predicate<String> filter(String token) { static Predicate<String> filter(String token) {
return suggestion -> suggestion != null && suggestion.toLowerCase().startsWith(token.toLowerCase()); return suggestion -> suggestion != null && suggestion.toLowerCase().startsWith(token.toLowerCase());
} }
@ -37,49 +65,122 @@ public interface SuggestionsSupplier<S> {
/** /**
* Filter the provided {@link Stream} of string according to the provided token, using the filter returned by {@link #filter(String)}, * Filter the provided {@link Stream} of string according to the provided token, using the filter returned by {@link #filter(String)},
* then returns the strings collected into a {@link List}. * then returns the strings collected into a {@link List}.
* * <p>
* This methods consume the provided stream, so will not be usable anymore. * This methods consume the provided stream, so will not be usable anymore.
* @param stream the stream to filter and collet.
* @param token the token to consider for filtering.
* @return the stream, filtered and collected into a {@link List}.
*/ */
static List<String> collectFilteredStream(Stream<String> stream, String token) { static List<String> collectFilteredStream(Stream<String> stream, String token) {
return stream.filter(filter(token)).sorted().collect(Collectors.toList()); return stream.filter(filter(token)).sorted().collect(Collectors.toList());
} }
/**
* Creates a {@link SuggestionsSupplier} that suggest nothing.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
*/
static <S> SuggestionsSupplier<S> empty() { return (s, ti, t, a) -> Collections.emptyList(); } static <S> SuggestionsSupplier<S> empty() { return (s, ti, t, a) -> Collections.emptyList(); }
/**
* Creates a {@link SuggestionsSupplier} that suggest the values from the supplied {@link Collection}.
* The provided {@link Supplier} will be called on each request for suggestions.
* @param streamSupplier a {@link Supplier} that provide an instance of {@link Collection} to iterate through for
* suggestions.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
*/
static <S> SuggestionsSupplier<S> fromCollectionsSupplier(Supplier<Collection<String>> streamSupplier) { static <S> SuggestionsSupplier<S> fromCollectionsSupplier(Supplier<Collection<String>> streamSupplier) {
return (s, ti, token, a) -> collectFilteredStream(streamSupplier.get().stream(), token); return (s, ti, token, a) -> collectFilteredStream(streamSupplier.get().stream(), token);
} }
/**
* Creates a {@link SuggestionsSupplier} that suggest the values from the supplied {@link Stream}.
* The provided {@link Supplier} will be called on each request for suggestions.
* @param streamSupplier a {@link Supplier} that provide an instance of {@link Stream} to iterate through for
* suggestions.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
*/
static <S> SuggestionsSupplier<S> fromStreamSupplier(Supplier<Stream<String>> streamSupplier) { static <S> SuggestionsSupplier<S> fromStreamSupplier(Supplier<Stream<String>> streamSupplier) {
return (s, ti, token, a) -> collectFilteredStream(streamSupplier.get(), token); return (s, ti, token, a) -> collectFilteredStream(streamSupplier.get(), token);
} }
/**
* Creates a {@link SuggestionsSupplier} that suggest the values from the provided {@link Collection}.
* If the provided collection is modified, the changes will not be reflected on the suggestions.
* @param suggestions the list of suggestion.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
*/
static <S> SuggestionsSupplier<S> fromCollection(Collection<String> suggestions) { static <S> SuggestionsSupplier<S> fromCollection(Collection<String> suggestions) {
return fromStreamSupplier(suggestions::stream); return fromStreamSupplier(suggestions::stream);
} }
/**
* Creates a {@link SuggestionsSupplier} that suggest the values from the provided strings.
* If the provided array is modified, the changes will not be reflected on the suggestions.
* @param suggestions the suggestions.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
*/
static <S> SuggestionsSupplier<S> fromArray(String... suggestions) { static <S> SuggestionsSupplier<S> fromArray(String... suggestions) {
return fromStreamSupplier(() -> Arrays.stream(suggestions)); return fromStreamSupplier(() -> Arrays.stream(suggestions));
} }
/**
* Creates a {@link SuggestionsSupplier} that suggest the values from the provided enum.
* @param enumClass the class of the enum from which to suggest its values.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
* @param <E> the enum type.
*/
static <E extends Enum<E>, S> SuggestionsSupplier<S> fromEnum(Class<E> enumClass) { static <E extends Enum<E>, S> SuggestionsSupplier<S> fromEnum(Class<E> enumClass) {
return fromEnumValues(enumClass.getEnumConstants()); return fromEnumValues(enumClass.getEnumConstants());
} }
/**
* Creates a {@link SuggestionsSupplier} that suggest the values from the provided enum.
* @param enumClass the class of the enum from which to suggest its values.
* @param lowerCase true to lowercase the enum values names, false to keep the case.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
* @param <E> the enum type.
*/
static <E extends Enum<E>, S> SuggestionsSupplier<S> fromEnum(Class<E> enumClass, boolean lowerCase) { static <E extends Enum<E>, S> SuggestionsSupplier<S> fromEnum(Class<E> enumClass, boolean lowerCase) {
return fromEnumValues(lowerCase, enumClass.getEnumConstants()); return fromEnumValues(lowerCase, enumClass.getEnumConstants());
} }
/**
* Creates a {@link SuggestionsSupplier} that suggest the provided enum values.
* @param enumValues the values from an enum.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
* @param <E> the enum type.
*/
@SafeVarargs @SafeVarargs
static <E extends Enum<E>, S> SuggestionsSupplier<S> fromEnumValues(E... enumValues) { static <E extends Enum<E>, S> SuggestionsSupplier<S> fromEnumValues(E... enumValues) {
return fromEnumValues(false, enumValues); return fromEnumValues(false, enumValues);
} }
/**
* Creates a {@link SuggestionsSupplier} that suggest the provided enum values.
* @param lowerCase true to lowercase the enum values names, false to keep the case.
* @param enumValues the values from an enum.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
* @param <E> the enum type.
*/
@SafeVarargs @SafeVarargs
static <E extends Enum<E>, S> SuggestionsSupplier<S> fromEnumValues(boolean lowerCase, E... enumValues) { static <E extends Enum<E>, S> SuggestionsSupplier<S> fromEnumValues(boolean lowerCase, E... enumValues) {
return (s, ti, token, a) -> { return (s, ti, token, a) -> {
@ -89,21 +190,31 @@ public interface SuggestionsSupplier<S> {
return collectFilteredStream(st, token); return collectFilteredStream(st, token);
}; };
} }
/**
* Creates a {@link SuggestionsSupplier} that suggest {@code "true"} or {@code "false"}.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
*/
static <S> SuggestionsSupplier<S> booleanValues() { static <S> SuggestionsSupplier<S> booleanValues() {
return fromCollection(Arrays.asList("true", "false")); return fromCollection(Arrays.asList("true", "false"));
} }
/** /**
* Create a {@link SuggestionsSupplier} that suggest numbers according to the provided range. * Creates a {@link SuggestionsSupplier} that suggest numbers according to the provided int range.
* * The current implementation only support ranges that include either -1 or 1.
* The current implementation only support range that include either -1 or 1. * @param min the minimum value of the interval, included.
* @param max the maximum value of the interval, included.
* @param compact if the suggestion must be compact. <b>Disabling this feature may have big performance impact
* on large intervals.</b>
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
*/ */
static <S> SuggestionsSupplier<S> fromIntRange(int min, int max, boolean compact) { static <S> SuggestionsSupplier<S> fromIntRange(int min, int max, boolean compact) {
return fromLongRange(min, max, compact); return fromLongRange(min, max, compact);
@ -113,9 +224,14 @@ public interface SuggestionsSupplier<S> {
/** /**
* Create a {@link SuggestionsSupplier} that suggest numbers according to the provided range. * Creates a {@link SuggestionsSupplier} that suggest numbers according to the provided long range.
* * The current implementation only support ranges that include either -1 or 1.
* The current implementation only support range that include either -1 or 1. * @param min the minimum value of the interval, included.
* @param max the maximum value of the interval, included.
* @param compact if the suggestion must be compact. <b>Disabling this feature may have big performance impact
* on large intervals.</b>
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
*/ */
static <S> SuggestionsSupplier<S> fromLongRange(long min, long max, boolean compact) { static <S> SuggestionsSupplier<S> fromLongRange(long min, long max, boolean compact) {
if (max < min) { if (max < min) {
@ -186,9 +302,11 @@ public interface SuggestionsSupplier<S> {
} }
/**
* Creates a {@link SuggestionsSupplier} that suggests duration strings, like "3d" for 3 days, or "1h" for 1 hour.
* @return a new {@link SuggestionsSupplier}.
* @param <S> the type of the command sender.
*/
static <S> SuggestionsSupplier<S> suggestDuration() { static <S> SuggestionsSupplier<S> suggestDuration() {
final List<String> emptyTokenSuggestions = DURATION_SUFFIXES.stream().map(p -> "1" + p).collect(Collectors.toList()); final List<String> emptyTokenSuggestions = DURATION_SUFFIXES.stream().map(p -> "1" + p).collect(Collectors.toList());
return (s, ti, token, args) -> { return (s, ti, token, args) -> {
@ -232,13 +350,15 @@ public interface SuggestionsSupplier<S> {
/** /**
* Create a {@link SuggestionsSupplier} that support greedy strings argument using the suggestion from this {@link SuggestionsSupplier}. * Creates a {@link SuggestionsSupplier} that provides the suggestions of this instance, but with support for
* @param index the index of the first argument of the greedy string argument * greedy string (arguments that goes until the end of the command).
* @param index the index of the first argument of the greedy string argument.
* @return a {@link SuggestionsSupplier} that supports quotable strings.
*/ */
default SuggestionsSupplier<S> greedyString(int index) { default SuggestionsSupplier<S> greedyString(int index) {
@ -246,8 +366,8 @@ public interface SuggestionsSupplier<S> {
if (ti < index) if (ti < index)
return Collections.emptyList(); return Collections.emptyList();
String gToken = AbstractCommand.getLastParams(args, index); String gToken = String.join(" ", Arrays.copyOfRange(args, index, args.length));
String[] splitGToken = gToken.split(" ", -1); String[] splitGToken = gToken.split(" ", -1);
int currentTokenPosition = splitGToken.length - 1; int currentTokenPosition = splitGToken.length - 1;
String[] prevWordsGToken = Arrays.copyOf(splitGToken, currentTokenPosition); String[] prevWordsGToken = Arrays.copyOf(splitGToken, currentTokenPosition);
@ -270,11 +390,13 @@ public interface SuggestionsSupplier<S> {
return currentTokenProposal; return currentTokenProposal;
}; };
} }
/**
* Creates a {@link SuggestionsSupplier} that provides the suggestions of this instance, but with support for
* quotable strings, as used by the Brigadier argument type StringArgumentType.string().
* @return a {@link SuggestionsSupplier} that supports quotable strings.
*/
default SuggestionsSupplier<S> quotableString() { default SuggestionsSupplier<S> quotableString() {
return (s, ti, token, a) -> { return (s, ti, token, a) -> {
boolean startWithQuote = token.length() > 0 && (token.charAt(0) == '"' || token.charAt(0) == '\''); boolean startWithQuote = token.length() > 0 && (token.charAt(0) == '"' || token.charAt(0) == '\'');
@ -298,7 +420,7 @@ public interface SuggestionsSupplier<S> {
} }
// inspired from com.mojang.brigadier.StringReader#readQuotedString() // inspired from com.mojang.brigadier.StringReader#readQuotedString()
static String unescapeBrigadierQuotable(String input, char quote) { private static String unescapeBrigadierQuotable(String input, char quote) {
StringBuilder builder = new StringBuilder(input.length()); StringBuilder builder = new StringBuilder(input.length());
boolean escaped = false; boolean escaped = false;
for (char c : input.toCharArray()) { for (char c : input.toCharArray()) {
@ -321,18 +443,18 @@ public interface SuggestionsSupplier<S> {
} }
// from com.mojang.brigadier.StringReader#isAllowedInUnquotedString(char) // from com.mojang.brigadier.StringReader#isAllowedInUnquotedString(char)
static boolean isAllowedInBrigadierUnquotedString(char c) { private static boolean isAllowedInBrigadierUnquotedString(char c) {
return c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' return c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z'
|| c == '_' || c == '-' || c == '.' || c == '+'; || c == '_' || c == '-' || c == '.' || c == '+';
} }
static boolean isAllowedInBrigadierUnquotedString(String s) { private static boolean isAllowedInBrigadierUnquotedString(String s) {
for (char c : s.toCharArray()) for (char c : s.toCharArray())
if (!isAllowedInBrigadierUnquotedString(c)) if (!isAllowedInBrigadierUnquotedString(c))
return false; return false;
return true; return true;
} }
static String escapeBrigadierQuotable(final String input) { private static String escapeBrigadierQuotable(final String input) {
final StringBuilder result = new StringBuilder("\""); final StringBuilder result = new StringBuilder("\"");
for (int i = 0; i < input.length(); i++) { for (int i = 0; i < input.length(); i++) {
@ -346,11 +468,17 @@ public interface SuggestionsSupplier<S> {
result.append("\""); result.append("\"");
return result.toString(); return result.toString();
} }
/**
* Creates a new {@link SuggestionsSupplier} that provides the suggestions of this instance, if and only if the
* provided predicate returns true for the command sender.
* @param check the predicate to test.
* @return a new {@link SuggestionsSupplier}.
*/
default SuggestionsSupplier<S> requires(Predicate<S> check) { default SuggestionsSupplier<S> requires(Predicate<S> check) {
return (s, ti, to, a) -> check.test(s) ? getSuggestions(s, ti, to, a) : Collections.emptyList(); return (s, ti, to, a) -> check.test(s) ? getSuggestions(s, ti, to, a) : Collections.emptyList();
} }
@ -358,8 +486,10 @@ public interface SuggestionsSupplier<S> {
/** /**
* Returns a new {@link SuggestionsSupplier} containing all the element of this instance then the element of the provided one, * Creates a new {@link SuggestionsSupplier} containing all the element of this instance then the element of the provided one,
* with all duplicated values removed using {@link Stream#distinct()}. * with all duplicated values removed using {@link Stream#distinct()}.
* @param other another {@link SuggestionsSupplier} to merge with.
* @return a new {@link SuggestionsSupplier}.
*/ */
default SuggestionsSupplier<S> merge(SuggestionsSupplier<S> other) { default SuggestionsSupplier<S> merge(SuggestionsSupplier<S> other) {
return (s, ti, to, a) -> { return (s, ti, to, a) -> {
@ -373,8 +503,10 @@ public interface SuggestionsSupplier<S> {
/** /**
* Returns a new {@link SuggestionsSupplier} containing all the suggestions of this instance, * Creates a new {@link SuggestionsSupplier} containing all the suggestions of this instance,
* but if this list is still empty, returns the suggestions from the provided one. * but if this list is still empty, returns the suggestions from the provided one.
* @param other another {@link SuggestionsSupplier} to fallback to.
* @return a new {@link SuggestionsSupplier}.
*/ */
default SuggestionsSupplier<S> orIfEmpty(SuggestionsSupplier<S> other) { default SuggestionsSupplier<S> orIfEmpty(SuggestionsSupplier<S> other) {
return (s, ti, to, a) -> { return (s, ti, to, a) -> {

View File

@ -1,40 +0,0 @@
package fr.pandacube.lib.core.commands;
import java.util.Arrays;
import fr.pandacube.lib.chat.ChatStatic;
public class AbstractCommand extends ChatStatic {
public final String commandName;
public AbstractCommand(String cmdName) {
commandName = cmdName;
}
/**
* <p>
* Concatène les chaines de caractères passés dans <code>args</code> (avec
* <code>" "</code> comme séparateur), en ommettant
* celles qui se trouvent avant <code>index</code>.<br/>
* Par exemple :
* </p>
* <code>
* getLastParams(new String[] {"test", "bouya", "chaka", "bukkit"}, 1);
* </code>
* <p>
* retournera la chaine "bouya chaka bukkit"
*
* @param args liste des arguments d'une commandes.<br/>
* Le premier élément est l'argument qui suit le nom de la commande.
* Usuellement, ce paramètre correspond au paramètre
* <code>args</code> de la méthode onCommand
*/
public static String getLastParams(String[] args, int index) {
return String.join(" ", Arrays.copyOfRange(args, index, args.length));
}
}

View File

@ -1,30 +0,0 @@
package fr.pandacube.lib.core.commands;
import java.util.logging.Logger;
/**
* Throw an instance of this exception to indicate to the plugin command handler
* that the user has missused the command. The message, if provided, must indicate
* the reason of the mussusage of the command. It will be displayed on the screen
* with eventually indication of how to use the command (help command for example).
* If a {@link Throwable} cause is provided, it will be relayed to the plugin {@link Logger}.
*
*/
public class BadCommandUsage extends RuntimeException {
public BadCommandUsage() {
super();
}
public BadCommandUsage(Throwable cause) {
super(cause);
}
public BadCommandUsage(String message) {
super(message);
}
public BadCommandUsage(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -12,24 +12,23 @@ import fr.pandacube.lib.chat.ChatColorUtil;
import fr.pandacube.lib.util.Log; import fr.pandacube.lib.util.Log;
/** /**
* Class tht loads a specific config file or directory * Class that loads a specific config file or directory.
*
*/ */
public abstract class AbstractConfig { public abstract class AbstractConfig {
/** /**
* Correspond au dossier ou au fichier de configuration traité par la sous-classe * The {@link File} corresponging to this config file or directory.
* courante de {@link AbstractConfig}
*/ */
protected final File configFile; protected final File configFile;
/** /**
* Creates a new {@link AbstractConfig}.
* @param configDir the parent directory * @param configDir the parent directory
* @param fileOrDirName The name of the config file or folder * @param fileOrDirName The name of the config file or folder
* @param type if the provided name is a file or a directory * @param type if the provided name is a file or a directory
* @throws IOException if we cannot create the file * @throws IOException if we cannot create the file or directory.
*/ */
public AbstractConfig(File configDir, String fileOrDirName, FileType type) throws IOException { protected AbstractConfig(File configDir, String fileOrDirName, FileType type) throws IOException {
configFile = new File(configDir, fileOrDirName); configFile = new File(configDir, fileOrDirName);
if (type == FileType.DIR) if (type == FileType.DIR)
configFile.mkdir(); configFile.mkdir();
@ -38,14 +37,15 @@ public abstract class AbstractConfig {
} }
/** /**
* Gets the lines from the config file * Gets the lines from the provided file.
* @param ignoreEmpty <code>true</code> if we ignore the empty lines * @param ignoreEmpty {@code true} if we ignore the empty lines.
* @param ignoreHashtagComment <code>true</code> if we ignore the comment lines (starting with {@code #}) * @param ignoreHashtagComment {@code true} if we ignore the comment lines (starting with {@code #}).
* @param trimOutput <code>true</code> if we want to trim all lines using {@link String#trim()} * @param trimOutput {@code true} if we want to trim all lines using {@link String#trim()}.
* @param f the file to read * @param f the file to read.
* @return the list of lines, filtered according to the parameters * @return the list of lines, filtered according to the parameters, or null if its not a regular file.
* @throws IOException if an IO error occurs.
*/ */
protected List<String> getFileLines(boolean ignoreEmpty, boolean ignoreHashtagComment, boolean trimOutput, File f) throws IOException { protected static List<String> getFileLines(boolean ignoreEmpty, boolean ignoreHashtagComment, boolean trimOutput, File f) throws IOException {
if (!f.isFile()) if (!f.isFile())
return null; return null;
@ -74,26 +74,27 @@ public abstract class AbstractConfig {
return lines; return lines;
} }
/** /**
* Retourne toutes les lignes du fichier de configuration * Gets the lines from the config file.
* @param ignoreEmpty <code>true</code> si on doit ignorer les lignes vides * @param ignoreEmpty {@code true} if we ignore the empty lines.
* @param ignoreHashtagComment <code>true</code> si on doit ignorer les lignes commentés (commençant par un #) * @param ignoreHashtagComment {@code true} if we ignore the comment lines (starting with {@code #}).
* @param trimOutput <code>true</code> si on doit appeller la méthode String.trim() sur chaque ligne retournée * @param trimOutput {@code true} if we want to trim all lines using {@link String#trim()}.
* @return la liste des lignes utiles * @return the list of lines, filtered according to the parameters, or null if its not a regular file.
* @throws IOException if an IO error occurs.
*/ */
protected List<String> getFileLines(boolean ignoreEmpty, boolean ignoreHashtagComment, boolean trimOutput) throws IOException { protected List<String> getFileLines(boolean ignoreEmpty, boolean ignoreHashtagComment, boolean trimOutput) throws IOException {
return getFileLines(ignoreEmpty, ignoreHashtagComment, trimOutput, configFile); return getFileLines(ignoreEmpty, ignoreHashtagComment, trimOutput, configFile);
} }
/**
* Gets the list of files in the config directory.
* @return the list of files in the config directory, or null if this config is not a directory.
*/
protected List<File> getFileList() { protected List<File> getFileList() {
if (!configFile.isDirectory()) return configFile.isDirectory() ? Arrays.asList(configFile.listFiles()) : null;
return null;
return Arrays.asList(configFile.listFiles());
} }
@ -101,43 +102,45 @@ public abstract class AbstractConfig {
/** /**
* Découpe une chaine de caractère contenant une série de noeuds * Splits the provided string into a list of permission nodes.
* de permissions séparés par des point-virgules et la retourne sous forme d'une liste. * The permission nodes must be separated by {@code ";"}.
* @param perms la chaine de permissions à traiter * @param perms one or more permissions nodes, separated by {@code ";"}.
* @return <code>null</code> si le paramètre est nulle ou si <code>perms.equals("*")</code>, ou alors la chaine splittée. * @return {@code null} if the parameter is null or is equal to {@code "*"}, or the string splitted using {@code ";"}.
*/ */
public static List<String> splitPermissionsString(String perms) { public static List<String> splitPermissionsString(String perms) {
if (perms == null || perms.equals("*")) if (perms == null || perms.equals("*"))
return null; return null;
return getSplittedString(perms, ";"); return List.of(perms.split(";"));
} }
public static List<String> getSplittedString(String value, String split) {
return List.of(value.split(split));
}
/**
* Utility method to that translate the {@code '&'} formated string to the legacy format.
* @param string the string to convert.
* @return a legacy formated string (using {@code '§'}).
*/
public static String getTranslatedColorCode(String string) { public static String getTranslatedColorCode(String string) {
return ChatColorUtil.translateAlternateColorCodes('&', string); return ChatColorUtil.translateAlternateColorCodes('&', string);
} }
/**
* Logs the message as a warning into console, prefixed with the context of this config.
* @param message the message to log.
*/
protected void warning(String message) { protected void warning(String message) {
Log.warning("Erreur dans la configuration de '"+configFile.getName()+"' : "+message); Log.warning("Error in configuration '"+configFile.getName()+"': " + message);
} }
/**
* The type of config.
*/
protected enum FileType { protected enum FileType {
FILE, DIR /** A config file. */
FILE,
/** A config directory. */
DIR
} }
} }

View File

@ -3,10 +3,23 @@ package fr.pandacube.lib.core.config;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
/**
* An abstract manager for a set of configuration files and folders.
* Its uses is to manage the loading/reloading of the configuration of a plugin.
*/
public abstract class AbstractConfigManager { public abstract class AbstractConfigManager {
/**
* The global configuration directory.
* May be the one provided by the environmenet API (like Plugin.getPluginFolder() in Bukkit).
*/
protected final File configDir; protected final File configDir;
/**
* Create a new instance of config manager.
* @param configD the config directory.
* @throws IOException if an IO error occurs.
*/
public AbstractConfigManager(File configD) throws IOException { public AbstractConfigManager(File configD) throws IOException {
configDir = configD; configDir = configD;
@ -16,18 +29,24 @@ public abstract class AbstractConfigManager {
} }
/** /**
* Implementation must close all closeable configuration (saving for example) * Closes the configuration. May handle saving of any non-saved data.
* @throws IOException if an IO error occurs.
*/ */
public abstract void close() throws IOException; public abstract void close() throws IOException;
/** /**
* Implementation must init all config data * Loads (or reloads) the configuration data.
* @throws IOException if an IO error occurs.
*/ */
public abstract void init() throws IOException; public abstract void init() throws IOException;
/**
* Utility method to close then reload the config.
* @throws IOException if an IO error occurs.
* @see #close()
* @see #init()
*/
public synchronized void reloadConfig() throws IOException { public synchronized void reloadConfig() throws IOException {
close(); close();
init(); init();

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.util; package fr.pandacube.lib.core.json;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -17,13 +17,40 @@ import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
/**
* Provides pre-instanciated {@link Gson} instances, all with support for Java records.
*/
public class Json { public class Json {
/**
* {@link Gson} instance with {@link GsonBuilder#setLenient()} and support for Java records.
*/
public static final Gson gson = build(Function.identity()); public static final Gson gson = build(Function.identity());
/**
* {@link Gson} instance with {@link GsonBuilder#setLenient()}, {@link GsonBuilder#setPrettyPrinting()}
* and support for Java records.
*/
public static final Gson gsonPrettyPrinting = build(GsonBuilder::setPrettyPrinting); public static final Gson gsonPrettyPrinting = build(GsonBuilder::setPrettyPrinting);
/**
* {@link Gson} instance with {@link GsonBuilder#setLenient()}, {@link GsonBuilder#serializeNulls()}
* and support for Java records.
*/
public static final Gson gsonSerializeNulls = build(GsonBuilder::serializeNulls); public static final Gson gsonSerializeNulls = build(GsonBuilder::serializeNulls);
/**
* {@link Gson} instance with {@link GsonBuilder#setLenient()}, {@link GsonBuilder#serializeNulls()},
* {@link GsonBuilder#setPrettyPrinting()} and support for Java records.
*/
public static final Gson gsonSerializeNullsPrettyPrinting = build(b -> b.serializeNulls().setPrettyPrinting()); public static final Gson gsonSerializeNullsPrettyPrinting = build(b -> b.serializeNulls().setPrettyPrinting());
private static Gson build(Function<GsonBuilder, GsonBuilder> builderModifier) { private static Gson build(Function<GsonBuilder, GsonBuilder> builderModifier) {
return builderModifier return builderModifier
.apply(new GsonBuilder().registerTypeAdapterFactory(new RecordAdapterFactory()).setLenient()).create(); .apply(new GsonBuilder().registerTypeAdapterFactory(new RecordAdapterFactory()).setLenient()).create();
@ -32,6 +59,10 @@ public class Json {
// from https://github.com/google/gson/issues/1794#issuecomment-812964421 // from https://github.com/google/gson/issues/1794#issuecomment-812964421
private static class RecordAdapterFactory implements TypeAdapterFactory { private static class RecordAdapterFactory implements TypeAdapterFactory {
@Override @Override

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.util; package fr.pandacube.lib.core.json;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -8,13 +8,16 @@ import java.util.Map;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
/** /**
* Utility for conversion of basic Java types and JsonElements types * Provides conversion between Java types and {@link JsonElement} types.
* @author Marc
*
*/ */
public class TypeConverter { public class TypeConverter {
/**
* Converts the provided object to an {@link Integer}.
* @param o the object to convert.
* @return a the object converted to an {@link Integer}.
* @throws ConvertionException is a conversion error occurs.
*/
public static Integer toInteger(Object o) { public static Integer toInteger(Object o) {
if (o == null) { if (o == null) {
return null; return null;
@ -44,14 +47,26 @@ public class TypeConverter {
throw new ConvertionException("No integer convertion available for an instance of "+o.getClass()); throw new ConvertionException("No integer convertion available for an instance of "+o.getClass());
} }
/**
* Converts the provided object to a primitive int.
* @param o the object to convert.
* @return a the object converted to a primitive int.
* @throws ConvertionException is a conversion error occurs.
*/
public static int toPrimInt(Object o) { public static int toPrimInt(Object o) {
Integer val = toInteger(o); Integer val = toInteger(o);
if (val == null) if (val == null)
throw new ConvertionException("null values can't be converted to primitive int"); throw new ConvertionException("null values can't be converted to primitive int");
return val; return val;
} }
/**
* Converts the provided object to a {@link Double}.
* @param o the object to convert.
* @return a the object converted to a {@link Double}.
* @throws ConvertionException is a conversion error occurs.
*/
public static Double toDouble(Object o) { public static Double toDouble(Object o) {
if (o == null) { if (o == null) {
return null; return null;
@ -82,14 +97,26 @@ public class TypeConverter {
throw new ConvertionException("No double convertion available for an instance of "+o.getClass()); throw new ConvertionException("No double convertion available for an instance of "+o.getClass());
} }
/**
* Converts the provided object to a primitive double.
* @param o the object to convert.
* @return a the object converted to a primitive double.
* @throws ConvertionException is a conversion error occurs.
*/
public static double toPrimDouble(Object o) { public static double toPrimDouble(Object o) {
Double val = toDouble(o); Double val = toDouble(o);
if (val == null) if (val == null)
throw new ConvertionException("null values can't converted to primitive int"); throw new ConvertionException("null values can't converted to primitive int");
return val; return val;
} }
/**
* Converts the provided object to a {@link String}.
* @param o the object to convert.
* @return a the object converted to a {@link String}.
* @throws ConvertionException is a conversion error occurs.
*/
public static String toString(Object o) { public static String toString(Object o) {
if (o == null) { if (o == null) {
return null; return null;
@ -112,11 +139,13 @@ public class TypeConverter {
} }
/** /**
* * Converts the provided object to a {@link Map}.
* @param o the object to convert to good type * @param o the object to convert.
* @param mapIntKeys if the String key representing an int should be duplicated as integer type, * @param mapIntKeys if the String key representing an int should be duplicated as integer type,
* which map to the same value as the original String key. For example, if a key is "12" and map * which map to the same value as the original String key. For example, if a key is "12" and map
* to the object <i>o</i>, an integer key 12 will be added and map to the same object <i>o</i> * to the object <i>o</i>, an integer key 12 will be added and map to the same object <i>o</i>.
* @return a the object converted to a {@link Map}.
* @throws ConvertionException is a conversion error occurs.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static Map<Object, Object> toMap(Object o, boolean mapIntKeys) { public static Map<Object, Object> toMap(Object o, boolean mapIntKeys) {
@ -156,14 +185,17 @@ public class TypeConverter {
} }
return map; return map;
} }
throw new ConvertionException("No Map convertion available for an instance of "+o.getClass()); throw new ConvertionException("No Map convertion available for an instance of "+o.getClass());
} }
/**
* Converts the provided object to a {@link List}.
* @param o the object to convert.
* @return a the object converted to a {@link List}.
* @throws ConvertionException is a conversion error occurs.
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static List<Object> toList(Object o) { public static List<Object> toList(Object o) {
if (o == null) { if (o == null) {
@ -190,23 +222,19 @@ public class TypeConverter {
} }
/**
* Thrown when a convertion error occurs.
*/
public static class ConvertionException extends RuntimeException { public static class ConvertionException extends RuntimeException {
public ConvertionException(String m) { private ConvertionException(String m) {
super(m); super(m);
} }
public ConvertionException(Throwable t) { private ConvertionException(Throwable t) {
super(t); super(t);
} }
public ConvertionException(String m, Throwable t) {
super(m, t);
}
} }

View File

@ -15,9 +15,11 @@ import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* Utility class to manage searching among a set of * Utility class to manage searching among a set of {@link SearchResult} instances, using case insensitive keywords.
* SearchResult instances, using case insensitive * The search engine is responsible for storing a database of entries ({@link SearchResult}) that can be searched using
* keywords. * keywords. This class provides methods to returns a list of results for provided keywords, a list of keyword
* suggestions based on pre-typed keywords.
* @param <R> the type of search result.
*/ */
public class SearchEngine<R extends SearchResult> { public class SearchEngine<R extends SearchResult> {
@ -30,13 +32,21 @@ public class SearchEngine<R extends SearchResult> {
private final Set<R> resultSet = new HashSet<>(); private final Set<R> resultSet = new HashSet<>();
private final Cache<Set<String>, List<String>> suggestionsCache; private final Cache<Set<String>, List<String>> suggestionsCache;
/**
* Creates a new search engine.
* @param suggestionsCacheSize the size of the cache for keyword suggestions (for optimization).
*/
public SearchEngine(int suggestionsCacheSize) { public SearchEngine(int suggestionsCacheSize) {
suggestionsCache = CacheBuilder.newBuilder() suggestionsCache = CacheBuilder.newBuilder()
.maximumSize(suggestionsCacheSize) .maximumSize(suggestionsCacheSize)
.build(); .build();
} }
/**
* Adds an entry in this search engine.
* @param result the new entry.
*/
public synchronized void addResult(R result) { public synchronized void addResult(R result) {
if (result == null) if (result == null)
throw new IllegalArgumentException("Provided result cannot be null."); throw new IllegalArgumentException("Provided result cannot be null.");
@ -83,7 +93,11 @@ public class SearchEngine<R extends SearchResult> {
suggestionsCache.invalidateAll(); suggestionsCache.invalidateAll();
} }
/**
* Removes the provided entry from this search engine.
* @param result the new entry.
*/
public synchronized void removeResult(R result) { public synchronized void removeResult(R result) {
if (result == null || !resultSet.contains(result)) if (result == null || !resultSet.contains(result))
return; return;
@ -118,7 +132,12 @@ public class SearchEngine<R extends SearchResult> {
suggestionsCache.invalidateAll(); suggestionsCache.invalidateAll();
} }
/**
* Provides all the search results that correspond to all the provided keywords.
* @param searchTerms all the search terms (keywords).
* @return all the search results that correspond to all the provided keywords.
*/
public synchronized Set<R> search(Set<String> searchTerms) { public synchronized Set<R> search(Set<String> searchTerms) {
if (searchTerms == null) if (searchTerms == null)
searchTerms = new HashSet<>(); searchTerms = new HashSet<>();
@ -130,7 +149,12 @@ public class SearchEngine<R extends SearchResult> {
return retainedResults; return retainedResults;
} }
/**
* Provides all the search results that correspond to the provided keyword.
* @param searchTerm the search term (keyword). If null, all the possible results are returned.
* @return all the search results that correspond to the provided keyword.
*/
public synchronized Set<R> search(String searchTerm) { public synchronized Set<R> search(String searchTerm) {
if (searchTerm == null || searchTerm.isEmpty()) { if (searchTerm == null || searchTerm.isEmpty()) {
return new HashSet<>(resultSet); return new HashSet<>(resultSet);
@ -145,7 +169,12 @@ public class SearchEngine<R extends SearchResult> {
return retainedResults; return retainedResults;
} }
/**
* Provides the next keyword to suggest, based on the already typed keywords.
* @param prevSearchTerms the already typed keywords.
* @return the next keywords to suggest.
*/
public synchronized List<String> suggestKeywords(List<String> prevSearchTerms) { public synchronized List<String> suggestKeywords(List<String> prevSearchTerms) {
if (prevSearchTerms == null || prevSearchTerms.isEmpty()) { if (prevSearchTerms == null || prevSearchTerms.isEmpty()) {
return new ArrayList<>(suggestionsKeywordsResultMap.keySet()); return new ArrayList<>(suggestionsKeywordsResultMap.keySet());

View File

@ -2,10 +2,22 @@ package fr.pandacube.lib.core.search;
import java.util.Set; import java.util.Set;
/**
* An entry in the {@link SearchEngine}.
*/
public interface SearchResult { public interface SearchResult {
/**
* Returns the keywords corresponding to this search result.
* @return the keywords corresponding to this search result.
*/
Set<String> getSearchKeywords(); Set<String> getSearchKeywords();
/**
* Returns the keywords to suggest corresponding to this search result.
* It may be different from the search keywords.
* @return the keywords to suggest corresponding to this search result.
*/
Set<String> getSuggestionKeywords(); Set<String> getSuggestionKeywords();
} }

View File

@ -1,129 +0,0 @@
package fr.pandacube.lib.core.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Objects;
import com.google.gson.JsonSyntaxException;
import fr.pandacube.lib.util.Log;
public class ServerPropertyFile {
private final transient File file;
private String name = "default_name";
private String memory = "512M";
private String javaArgs = "";
private String MinecraftArgs = "";
private String jarFile = "";
private long startupDelay = 0;
private boolean run = true;
public ServerPropertyFile(File f) {
file = Objects.requireNonNull(f, "f");
}
/**
* Charge le fichier de configuration dans cette instance de la classe
*
* @return true si le chargement a réussi, false sinon
*/
public boolean loadFromFile() {
try (BufferedReader in = new BufferedReader(new FileReader(file))) {
ServerPropertyFile dataFile = Json.gsonPrettyPrinting.fromJson(in, getClass());
name = dataFile.name;
memory = dataFile.memory;
javaArgs = dataFile.javaArgs;
MinecraftArgs = dataFile.MinecraftArgs;
jarFile = dataFile.jarFile;
run = dataFile.run;
startupDelay = dataFile.startupDelay;
return true;
} catch(JsonSyntaxException e) {
Log.severe("Error in config file " + file + ": backed up and creating a new one from previous or default values.", e);
return save();
} catch (IOException e) {
Log.severe(e);
return false;
}
}
public boolean save() {
try (BufferedWriter out = new BufferedWriter(new FileWriter(file, false))) {
Json.gsonPrettyPrinting.toJson(this, out);
out.flush();
return true;
} catch (IOException e) {
Log.severe(e);
}
return false;
}
public String getName() {
return name;
}
public String getMemory() {
return memory;
}
public String getJavaArgs() {
return javaArgs;
}
public String getMinecraftArgs() {
return MinecraftArgs;
}
public String getJarFile() {
return jarFile;
}
public boolean isRun() {
return run;
}
public long getStartupDelay() {
return startupDelay;
}
public void setName(String n) {
if (n == null || !n.matches("^[a-zA-Z]$")) throw new IllegalArgumentException();
name = n;
}
public void setMemory(String m) {
if (m == null || !m.matches("^\\d+[mgMG]$")) throw new IllegalArgumentException();
memory = m;
}
public void setJavaArgs(String ja) {
if (ja == null) throw new IllegalArgumentException();
javaArgs = ja;
}
public void setMinecraftArgs(String ma) {
if (ma == null) throw new IllegalArgumentException();
MinecraftArgs = ma;
}
public void setJarFile(String j) {
if (j == null) throw new IllegalArgumentException();
jarFile = j;
}
public void setRun(boolean r) {
run = r;
}
}

View File

@ -1,11 +1,164 @@
package fr.pandacube.lib.paper.reflect; package fr.pandacube.lib.paper.reflect;
import fr.pandacube.lib.paper.reflect.wrapper.WrapperRegistry; import fr.pandacube.lib.paper.reflect.wrapper.brigadier.CommandNode;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftMapView;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftNamespacedKey;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftPlayer;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftServer;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftVector;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftWorld;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.RenderData;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.VanillaCommandWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.DetectedVersion;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.SharedConstants;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.WorldVersion;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.BlockPosArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.CommandSourceStack;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.ComponentArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Coordinates;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.EntityArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.EntitySelector;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.GameProfileArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.ResourceLocationArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Vec3Argument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.Vec3i;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.NbtIo;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.StringTag;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.Tag;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.FriendlyByteBuf;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.ClientboundCustomPayloadPacket;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.ClientboundGameEventPacket;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.Packet;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ChunkMap;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedPlayerList;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedServer;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedServerProperties;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.MinecraftServer;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerChunkCache;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerGamePacketListenerImpl;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerLevel;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.Settings;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.util.ProgressListener;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.AABB;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ChunkPos;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ChunkStorage;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.DamageSource;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Level;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.SavedData;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block.BambooBlock;
import fr.pandacube.lib.paper.reflect.wrapper.netty.ByteBuf;
import fr.pandacube.lib.paper.reflect.wrapper.netty.Unpooled;
import fr.pandacube.lib.paper.reflect.wrapper.paper.AABBVoxelShape;
import fr.pandacube.lib.paper.reflect.wrapper.paper.PaperAdventure;
import fr.pandacube.lib.paper.reflect.wrapper.paper.QueuedChangesMapLong2Object;
import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.FallbackValue_Int;
import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.WorldConfiguration;
import static fr.pandacube.lib.reflect.wrapper.WrapperRegistry.initWrapper;
public class PandalibPaperReflect { public class PandalibPaperReflect {
public static void init() { public static void init() {
NMSReflect.init(); NMSReflect.init();
WrapperRegistry.init(); initWrapperClasses();
}
private static void initWrapperClasses() {
// brigadier
initWrapper(CommandNode.class, CommandNode.REFLECT.get());
// craftbukkit
initWrapper(CraftMapView.class, CraftMapView.REFLECT.get());
initWrapper(CraftNamespacedKey.class, CraftNamespacedKey.REFLECT.get());
initWrapper(CraftPlayer.class, CraftPlayer.REFLECT.get());
initWrapper(CraftServer.class, CraftServer.REFLECT.get());
initWrapper(CraftVector.class, CraftVector.REFLECT.get());
initWrapper(CraftWorld.class, CraftWorld.REFLECT.get());
initWrapper(RenderData.class, RenderData.REFLECT.get());
initWrapper(VanillaCommandWrapper.class, VanillaCommandWrapper.REFLECT.get());
// minecraft.commands
initWrapper(BlockPosArgument.class, BlockPosArgument.MAPPING.runtimeClass());
initWrapper(Commands.class, Commands.MAPPING.runtimeClass());
initWrapper(CommandSourceStack.class, CommandSourceStack.MAPPING.runtimeClass());
initWrapper(ComponentArgument.class, ComponentArgument.MAPPING.runtimeClass());
initWrapper(Coordinates.class, Coordinates.MAPPING.runtimeClass());
initWrapper(EntityArgument.class, EntityArgument.MAPPING.runtimeClass());
initWrapper(EntitySelector.class, EntitySelector.MAPPING.runtimeClass());
initWrapper(GameProfileArgument.class, GameProfileArgument.MAPPING.runtimeClass());
initWrapper(ResourceLocationArgument.class, ResourceLocationArgument.MAPPING.runtimeClass());
initWrapper(Vec3Argument.class, Vec3Argument.MAPPING.runtimeClass());
// minecraft.core
initWrapper(BlockPos.class, BlockPos.MAPPING.runtimeClass());
initWrapper(Vec3i.class, Vec3i.MAPPING.runtimeClass());
// minecraft.nbt
initWrapper(CompoundTag.class, CompoundTag.MAPPING.runtimeClass());
initWrapper(NbtIo.class, NbtIo.MAPPING.runtimeClass());
initWrapper(StringTag.class, StringTag.MAPPING.runtimeClass());
initWrapper(Tag.class, Tag.MAPPING.runtimeClass());
// minecraft.network.chat
initWrapper(Component.class, Component.MAPPING.runtimeClass());
// minecraft.network.protocol
initWrapper(ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket.MAPPING.runtimeClass());
initWrapper(ClientboundGameEventPacket.class, ClientboundGameEventPacket.MAPPING.runtimeClass());
initWrapper(ClientboundGameEventPacket.Type.class, ClientboundGameEventPacket.Type.MAPPING.runtimeClass());
initWrapper(Packet.class, Packet.MAPPING.runtimeClass());
// minecraft.network
initWrapper(FriendlyByteBuf.class, FriendlyByteBuf.MAPPING.runtimeClass());
// minecraft.resources
initWrapper(ResourceLocation.class, ResourceLocation.MAPPING.runtimeClass());
// minecraft.server
initWrapper(ChunkMap.class, ChunkMap.MAPPING.runtimeClass());
initWrapper(DedicatedPlayerList.class, DedicatedPlayerList.MAPPING.runtimeClass());
initWrapper(DedicatedServer.class, DedicatedServer.MAPPING.runtimeClass());
initWrapper(DedicatedServerProperties.class, DedicatedServerProperties.MAPPING.runtimeClass());
initWrapper(MinecraftServer.class, MinecraftServer.MAPPING.runtimeClass());
initWrapper(ServerChunkCache.class, ServerChunkCache.MAPPING.runtimeClass());
initWrapper(ServerGamePacketListenerImpl.class, ServerGamePacketListenerImpl.MAPPING.runtimeClass());
initWrapper(ServerLevel.class, ServerLevel.MAPPING.runtimeClass());
initWrapper(ServerPlayer.class, ServerPlayer.MAPPING.runtimeClass());
initWrapper(Settings.class, Settings.MAPPING.runtimeClass());
// minecraft.util
initWrapper(ProgressListener.class, ProgressListener.MAPPING.runtimeClass());
// minecraft.world.block
initWrapper(BambooBlock.class, BambooBlock.MAPPING.runtimeClass());
// minecraft.world
initWrapper(AABB.class, AABB.MAPPING.runtimeClass());
initWrapper(ChunkPos.class, ChunkPos.MAPPING.runtimeClass());
initWrapper(ChunkStorage.class, ChunkStorage.MAPPING.runtimeClass());
initWrapper(DamageSource.class, DamageSource.MAPPING.runtimeClass());
initWrapper(Entity.class, Entity.MAPPING.runtimeClass());
initWrapper(Level.class, Level.MAPPING.runtimeClass());
initWrapper(MapItemSavedData.class, MapItemSavedData.MAPPING.runtimeClass());
initWrapper(SavedData.class, SavedData.MAPPING.runtimeClass());
initWrapper(Vec3.class, Vec3.MAPPING.runtimeClass());
initWrapper(VoxelShape.class, VoxelShape.MAPPING.runtimeClass());
// minecraft
initWrapper(DetectedVersion.class, DetectedVersion.MAPPING.runtimeClass());
initWrapper(SharedConstants.class, SharedConstants.MAPPING.runtimeClass());
initWrapper(WorldVersion.class, WorldVersion.MAPPING.runtimeClass());
// netty
initWrapper(ByteBuf.class, ByteBuf.REFLECT.get());
initWrapper(Unpooled.class, Unpooled.REFLECT.get());
// paper.configuration
initWrapper(FallbackValue_Int.class, FallbackValue_Int.REFLECT.get());
initWrapper(WorldConfiguration.class, WorldConfiguration.REFLECT.get());
initWrapper(WorldConfiguration.Chunks.class, WorldConfiguration.Chunks.REFLECT.get());
// paper
initWrapper(AABBVoxelShape.class, AABBVoxelShape.REFLECT.get());
initWrapper(PaperAdventure.class, PaperAdventure.REFLECT.get());
initWrapper(QueuedChangesMapLong2Object.class, QueuedChangesMapLong2Object.REFLECT.get());
} }
} }

View File

@ -1,233 +0,0 @@
package fr.pandacube.lib.paper.reflect.wrapper;
import fr.pandacube.lib.util.Log;
import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.reflect.ReflectConstructor;
import fr.pandacube.lib.paper.reflect.wrapper.brigadier.CommandNode;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftMapView;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftNamespacedKey;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftPlayer;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftServer;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftVector;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftWorld;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.RenderData;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.VanillaCommandWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.DetectedVersion;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.SharedConstants;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.WorldVersion;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.BlockPosArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.CommandSourceStack;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.ComponentArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Coordinates;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.EntityArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.EntitySelector;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.GameProfileArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.ResourceLocationArgument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Vec3Argument;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.Vec3i;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.NbtIo;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.StringTag;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.Tag;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.FriendlyByteBuf;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.ClientboundCustomPayloadPacket;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.ClientboundGameEventPacket;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.Packet;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ChunkMap;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedPlayerList;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedServer;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedServerProperties;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.MinecraftServer;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerChunkCache;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerGamePacketListenerImpl;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerLevel;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.Settings;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.util.ProgressListener;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.AABB;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ChunkPos;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ChunkStorage;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.DamageSource;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Level;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.SavedData;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block.BambooBlock;
import fr.pandacube.lib.paper.reflect.wrapper.netty.ByteBuf;
import fr.pandacube.lib.paper.reflect.wrapper.netty.Unpooled;
import fr.pandacube.lib.paper.reflect.wrapper.paper.AABBVoxelShape;
import fr.pandacube.lib.paper.reflect.wrapper.paper.PaperAdventure;
import fr.pandacube.lib.paper.reflect.wrapper.paper.QueuedChangesMapLong2Object;
import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.FallbackValue_Int;
import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.WorldConfiguration;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
public class WrapperRegistry {
public static void init() {
// craftbukkit
initWrapper(CommandNode.class, CommandNode.REFLECT.get());
// craftbukkit
initWrapper(CraftMapView.class, CraftMapView.REFLECT.get());
initWrapper(CraftNamespacedKey.class, CraftNamespacedKey.REFLECT.get());
initWrapper(CraftPlayer.class, CraftPlayer.REFLECT.get());
initWrapper(CraftServer.class, CraftServer.REFLECT.get());
initWrapper(CraftVector.class, CraftVector.REFLECT.get());
initWrapper(CraftWorld.class, CraftWorld.REFLECT.get());
initWrapper(RenderData.class, RenderData.REFLECT.get());
initWrapper(VanillaCommandWrapper.class, VanillaCommandWrapper.REFLECT.get());
// minecraft.commands
initWrapper(BlockPosArgument.class, BlockPosArgument.MAPPING.runtimeClass());
initWrapper(Commands.class, Commands.MAPPING.runtimeClass());
initWrapper(CommandSourceStack.class, CommandSourceStack.MAPPING.runtimeClass());
initWrapper(ComponentArgument.class, ComponentArgument.MAPPING.runtimeClass());
initWrapper(Coordinates.class, Coordinates.MAPPING.runtimeClass());
initWrapper(EntityArgument.class, EntityArgument.MAPPING.runtimeClass());
initWrapper(EntitySelector.class, EntitySelector.MAPPING.runtimeClass());
initWrapper(GameProfileArgument.class, GameProfileArgument.MAPPING.runtimeClass());
initWrapper(ResourceLocationArgument.class, ResourceLocationArgument.MAPPING.runtimeClass());
initWrapper(Vec3Argument.class, Vec3Argument.MAPPING.runtimeClass());
// minecraft.core
initWrapper(BlockPos.class, BlockPos.MAPPING.runtimeClass());
initWrapper(Vec3i.class, Vec3i.MAPPING.runtimeClass());
// minecraft.nbt
initWrapper(CompoundTag.class, CompoundTag.MAPPING.runtimeClass());
initWrapper(NbtIo.class, NbtIo.MAPPING.runtimeClass());
initWrapper(StringTag.class, StringTag.MAPPING.runtimeClass());
initWrapper(Tag.class, Tag.MAPPING.runtimeClass());
// minecraft.network.chat
initWrapper(Component.class, Component.MAPPING.runtimeClass());
// minecraft.network.protocol
initWrapper(ClientboundCustomPayloadPacket.class, ClientboundCustomPayloadPacket.MAPPING.runtimeClass());
initWrapper(ClientboundGameEventPacket.class, ClientboundGameEventPacket.MAPPING.runtimeClass());
initWrapper(ClientboundGameEventPacket.Type.class, ClientboundGameEventPacket.Type.MAPPING.runtimeClass());
initWrapper(Packet.class, Packet.MAPPING.runtimeClass());
// minecraft.network
initWrapper(FriendlyByteBuf.class, FriendlyByteBuf.MAPPING.runtimeClass());
// minecraft.resources
initWrapper(ResourceLocation.class, ResourceLocation.MAPPING.runtimeClass());
// minecraft.server
initWrapper(ChunkMap.class, ChunkMap.MAPPING.runtimeClass());
initWrapper(DedicatedPlayerList.class, DedicatedPlayerList.MAPPING.runtimeClass());
initWrapper(DedicatedServer.class, DedicatedServer.MAPPING.runtimeClass());
initWrapper(DedicatedServerProperties.class, DedicatedServerProperties.MAPPING.runtimeClass());
initWrapper(MinecraftServer.class, MinecraftServer.MAPPING.runtimeClass());
initWrapper(ServerChunkCache.class, ServerChunkCache.MAPPING.runtimeClass());
initWrapper(ServerGamePacketListenerImpl.class, ServerGamePacketListenerImpl.MAPPING.runtimeClass());
initWrapper(ServerLevel.class, ServerLevel.MAPPING.runtimeClass());
initWrapper(ServerPlayer.class, ServerPlayer.MAPPING.runtimeClass());
initWrapper(Settings.class, Settings.MAPPING.runtimeClass());
// minecraft.util
initWrapper(ProgressListener.class, ProgressListener.MAPPING.runtimeClass());
// minecraft.world.block
initWrapper(BambooBlock.class, BambooBlock.MAPPING.runtimeClass());
// minecraft.world
initWrapper(AABB.class, AABB.MAPPING.runtimeClass());
initWrapper(ChunkPos.class, ChunkPos.MAPPING.runtimeClass());
initWrapper(ChunkStorage.class, ChunkStorage.MAPPING.runtimeClass());
initWrapper(DamageSource.class, DamageSource.MAPPING.runtimeClass());
initWrapper(Entity.class, Entity.MAPPING.runtimeClass());
initWrapper(Level.class, Level.MAPPING.runtimeClass());
initWrapper(MapItemSavedData.class, MapItemSavedData.MAPPING.runtimeClass());
initWrapper(SavedData.class, SavedData.MAPPING.runtimeClass());
initWrapper(Vec3.class, Vec3.MAPPING.runtimeClass());
initWrapper(VoxelShape.class, VoxelShape.MAPPING.runtimeClass());
// minecraft
initWrapper(DetectedVersion.class, DetectedVersion.MAPPING.runtimeClass());
initWrapper(SharedConstants.class, SharedConstants.MAPPING.runtimeClass());
initWrapper(WorldVersion.class, WorldVersion.MAPPING.runtimeClass());
// netty
initWrapper(ByteBuf.class, ByteBuf.REFLECT.get());
initWrapper(Unpooled.class, Unpooled.REFLECT.get());
// paper.configuration
initWrapper(FallbackValue_Int.class, FallbackValue_Int.REFLECT.get());
initWrapper(WorldConfiguration.class, WorldConfiguration.REFLECT.get());
initWrapper(WorldConfiguration.Chunks.class, WorldConfiguration.Chunks.REFLECT.get());
// paper
initWrapper(AABBVoxelShape.class, AABBVoxelShape.REFLECT.get());
initWrapper(PaperAdventure.class, PaperAdventure.REFLECT.get());
initWrapper(QueuedChangesMapLong2Object.class, QueuedChangesMapLong2Object.REFLECT.get());
}
/* package */ static Class<? extends ReflectWrapperI> getWrapperOfRuntimeClass(Class<?> runtime) {
RegistryEntry e = WRAPPER_DATA_BY_RUNTIME_CLASS.get(runtime);
return e == null ? null : e.wrapperClass;
}
/* package */ static Class<?> getRuntimeClassOfWrapperClass(Class<? extends ReflectWrapperI> wrapperClass) {
RegistryEntry e = WRAPPER_DATA_BY_WRAPPER_CLASS.get(wrapperClass);
return e == null ? null : e.runtimeClass;
}
/* package */ static ReflectConstructor<? extends ReflectWrapperI> getWrapperConstructorOfWrapperClass(Class<? extends ReflectWrapperI> wrapperClass) {
RegistryEntry e = WRAPPER_DATA_BY_WRAPPER_CLASS.get(wrapperClass);
return e == null ? null : e.objectWrapperConstructor;
}
private static final Map<Class<?>, RegistryEntry> WRAPPER_DATA_BY_RUNTIME_CLASS = new HashMap<>();
private static final Map<Class<? extends ReflectWrapperI>, RegistryEntry> WRAPPER_DATA_BY_WRAPPER_CLASS = new HashMap<>();
public static void initWrapper(Class<? extends ReflectWrapperI> wrapper, Class<?> runtime) {
Class<? extends ReflectWrapperI> concreteWrapper = wrapper;
ReflectConstructor<? extends ReflectWrapperI> objectWrapperConstructor;
if (wrapper.isInterface() || Modifier.isAbstract(wrapper.getModifiers())) {
ConcreteWrapper concreteWrapperAnnotation = wrapper.getAnnotation(ConcreteWrapper.class);
if (concreteWrapperAnnotation == null || concreteWrapperAnnotation.value() == null) {
Log.severe("The provided non-concrete (interface or abstract class) wrapper " + wrapper + " does not" +
" provide any concrete wrapper.");
return;
}
concreteWrapper = concreteWrapperAnnotation.value();
if (!wrapper.isAssignableFrom(concreteWrapper)) {
Log.severe("The concrete wrapper " + concreteWrapper + " does not extends or implements " + wrapper + ".");
return;
}
}
try {
objectWrapperConstructor = Reflect.ofClass(concreteWrapper).constructor(Object.class);
} catch (NoSuchMethodException e) {
Log.severe("The wrapper " + concreteWrapper + " does not provide a constructor that takes a unique" +
" Object parameter.", e);
return;
}
RegistryEntry e = new RegistryEntry(runtime, wrapper, concreteWrapper, objectWrapperConstructor);
WRAPPER_DATA_BY_RUNTIME_CLASS.put(runtime, e);
WRAPPER_DATA_BY_WRAPPER_CLASS.put(wrapper, e);
if (concreteWrapper != wrapper) {
WRAPPER_DATA_BY_WRAPPER_CLASS.put(concreteWrapper, e);
}
}
private record RegistryEntry(Class<?> runtimeClass,
Class<? extends ReflectWrapperI> wrapperClass,
Class<? extends ReflectWrapperI> concreteWrapperClass,
ReflectConstructor<? extends ReflectWrapperI> objectWrapperConstructor) {
}
}

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.brigadier; package fr.pandacube.lib.paper.reflect.wrapper.brigadier;
import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.paper.reflect.OBCReflect; import fr.pandacube.lib.paper.reflect.OBCReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.paper.reflect.OBCReflect; import fr.pandacube.lib.paper.reflect.OBCReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.paper.reflect.OBCReflect; import fr.pandacube.lib.paper.reflect.OBCReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.paper.reflect.OBCReflect; import fr.pandacube.lib.paper.reflect.OBCReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedPlayerList; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedPlayerList;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedServer; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedServer;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.paper.reflect.OBCReflect; import fr.pandacube.lib.paper.reflect.OBCReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.paper.reflect.OBCReflect; import fr.pandacube.lib.paper.reflect.OBCReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerLevel; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerLevel;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.paper.reflect.OBCReflect; import fr.pandacube.lib.paper.reflect.OBCReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;

View File

@ -4,7 +4,7 @@ import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.CommandNode;
import fr.pandacube.lib.paper.reflect.OBCReflect; import fr.pandacube.lib.paper.reflect.OBCReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.ReflectConstructor;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft; package fr.pandacube.lib.paper.reflect.wrapper.minecraft;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft; package fr.pandacube.lib.paper.reflect.wrapper.minecraft;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -2,9 +2,9 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -3,7 +3,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.ArgumentType;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -2,7 +2,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource; import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -4,7 +4,7 @@ import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -3,7 +3,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.ArgumentType;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -3,16 +3,16 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource; import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
import static fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper.wrap; import static fr.pandacube.lib.reflect.wrapper.ReflectWrapper.wrap;
@ConcreteWrapper(Coordinates.__concrete.class) @ConcreteWrapper(Coordinates.__concrete.class)
public interface Coordinates extends ReflectWrapperI { public interface Coordinates extends ReflectWrapperI {

View File

@ -3,7 +3,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.ArgumentType;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -3,8 +3,8 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource; import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectListWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectListWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -3,7 +3,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.ArgumentType;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -3,7 +3,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.ArgumentType;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -3,7 +3,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.arguments.ArgumentType;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -11,7 +11,7 @@ import java.util.UUID;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
public class CompoundTag extends ReflectWrapper implements Tag { public class CompoundTag extends ReflectWrapper implements Tag {
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.CompoundTag")); public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.CompoundTag"));

View File

@ -7,7 +7,7 @@ import java.io.File;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
public class NbtIo extends ReflectWrapper { public class NbtIo extends ReflectWrapper {
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.NbtIo")); public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.NbtIo"));

View File

@ -4,7 +4,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
public class StringTag extends ReflectWrapper implements Tag { public class StringTag extends ReflectWrapper implements Tag {
public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.StringTag")); public static final ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.nbt.StringTag"));

View File

@ -6,9 +6,9 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
@ConcreteWrapper(Tag.__concrete.class) @ConcreteWrapper(Tag.__concrete.class)
public interface Tag extends ReflectWrapperI { public interface Tag extends ReflectWrapperI {

View File

@ -1,9 +1,9 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.FriendlyByteBuf; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.FriendlyByteBuf;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation;
import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.ReflectConstructor;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.ReflectConstructor;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;

View File

@ -1,9 +1,9 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.Packet; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.Packet;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;
import java.util.Properties; import java.util.Properties;

View File

@ -1,9 +1,9 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.util; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.util;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper; import fr.pandacube.lib.reflect.wrapper.ConcreteWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI; import fr.pandacube.lib.reflect.wrapper.ReflectWrapperI;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.ReflectConstructor;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectConstructor; import fr.pandacube.lib.reflect.ReflectConstructor;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.WorldConfiguration; import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.WorldConfiguration;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.netty; package fr.pandacube.lib.paper.reflect.wrapper.netty;
import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.netty; package fr.pandacube.lib.paper.reflect.wrapper.netty;
import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.paper; package fr.pandacube.lib.paper.reflect.wrapper.paper;
import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.paper; package fr.pandacube.lib.paper.reflect.wrapper.paper;
import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.paper.configuration; package fr.pandacube.lib.paper.reflect.wrapper.paper.configuration;
import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectMethod; import fr.pandacube.lib.reflect.ReflectMethod;

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.paper.configuration; package fr.pandacube.lib.paper.reflect.wrapper.paper.configuration;
import fr.pandacube.lib.reflect.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.reflect.ReflectClass; import fr.pandacube.lib.reflect.ReflectClass;
import fr.pandacube.lib.reflect.ReflectField; import fr.pandacube.lib.reflect.ReflectField;

View File

@ -19,6 +19,16 @@
<artifactId>classgraph</artifactId> <artifactId>classgraph</artifactId>
<version>4.8.149</version> <version>4.8.149</version>
</dependency> </dependency>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-util</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version> <!-- Match the version imported by Paper API/BungeeCord API if possible -->
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.paper.reflect.wrapper; package fr.pandacube.lib.reflect.wrapper;
import java.lang.annotation.ElementType; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.paper.reflect.wrapper; package fr.pandacube.lib.reflect.wrapper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.paper.reflect.wrapper; package fr.pandacube.lib.reflect.wrapper;
import com.google.common.collect.MapMaker; import com.google.common.collect.MapMaker;

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.paper.reflect.wrapper; package fr.pandacube.lib.reflect.wrapper;
public interface ReflectWrapperI { public interface ReflectWrapperI {

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.paper.reflect.wrapper; package fr.pandacube.lib.reflect.wrapper;
public abstract class ReflectWrapperTyped<T> extends ReflectWrapper implements ReflectWrapperTypedI<T> { public abstract class ReflectWrapperTyped<T> extends ReflectWrapper implements ReflectWrapperTypedI<T> {

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.paper.reflect.wrapper; package fr.pandacube.lib.reflect.wrapper;
public interface ReflectWrapperTypedI<T> extends ReflectWrapperI { public interface ReflectWrapperTypedI<T> extends ReflectWrapperI {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -0,0 +1,79 @@
package fr.pandacube.lib.reflect.wrapper;
import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.reflect.ReflectConstructor;
import fr.pandacube.lib.util.Log;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.Map;
public class WrapperRegistry {
/* package */ static Class<? extends ReflectWrapperI> getWrapperOfRuntimeClass(Class<?> runtime) {
RegistryEntry e = WRAPPER_DATA_BY_RUNTIME_CLASS.get(runtime);
return e == null ? null : e.wrapperClass;
}
/* package */ static Class<?> getRuntimeClassOfWrapperClass(Class<? extends ReflectWrapperI> wrapperClass) {
RegistryEntry e = WRAPPER_DATA_BY_WRAPPER_CLASS.get(wrapperClass);
return e == null ? null : e.runtimeClass;
}
/* package */ static ReflectConstructor<? extends ReflectWrapperI> getWrapperConstructorOfWrapperClass(Class<? extends ReflectWrapperI> wrapperClass) {
RegistryEntry e = WRAPPER_DATA_BY_WRAPPER_CLASS.get(wrapperClass);
return e == null ? null : e.objectWrapperConstructor;
}
private static final Map<Class<?>, RegistryEntry> WRAPPER_DATA_BY_RUNTIME_CLASS = new HashMap<>();
private static final Map<Class<? extends ReflectWrapperI>, RegistryEntry> WRAPPER_DATA_BY_WRAPPER_CLASS = new HashMap<>();
public static void initWrapper(Class<? extends ReflectWrapperI> wrapper, Class<?> runtime) {
Class<? extends ReflectWrapperI> concreteWrapper = wrapper;
ReflectConstructor<? extends ReflectWrapperI> objectWrapperConstructor;
if (wrapper.isInterface() || Modifier.isAbstract(wrapper.getModifiers())) {
ConcreteWrapper concreteWrapperAnnotation = wrapper.getAnnotation(ConcreteWrapper.class);
if (concreteWrapperAnnotation == null || concreteWrapperAnnotation.value() == null) {
Log.severe("The provided non-concrete (interface or abstract class) wrapper " + wrapper + " does not" +
" provide any concrete wrapper.");
return;
}
concreteWrapper = concreteWrapperAnnotation.value();
if (!wrapper.isAssignableFrom(concreteWrapper)) {
Log.severe("The concrete wrapper " + concreteWrapper + " does not extends or implements " + wrapper + ".");
return;
}
}
try {
objectWrapperConstructor = Reflect.ofClass(concreteWrapper).constructor(Object.class);
} catch (NoSuchMethodException e) {
Log.severe("The wrapper " + concreteWrapper + " does not provide a constructor that takes a unique" +
" Object parameter.", e);
return;
}
RegistryEntry e = new RegistryEntry(runtime, wrapper, concreteWrapper, objectWrapperConstructor);
WRAPPER_DATA_BY_RUNTIME_CLASS.put(runtime, e);
WRAPPER_DATA_BY_WRAPPER_CLASS.put(wrapper, e);
if (concreteWrapper != wrapper) {
WRAPPER_DATA_BY_WRAPPER_CLASS.put(concreteWrapper, e);
}
}
private record RegistryEntry(Class<?> runtimeClass,
Class<? extends ReflectWrapperI> wrapperClass,
Class<? extends ReflectWrapperI> concreteWrapperClass,
ReflectConstructor<? extends ReflectWrapperI> objectWrapperConstructor) {
}
}

View File

@ -66,6 +66,7 @@
<module>pandalib-bungee-players</module> <module>pandalib-bungee-players</module>
<module>pandalib-chat</module> <module>pandalib-chat</module>
<module>pandalib-cli</module> <module>pandalib-cli</module>
<module>pandalib-commands</module>
<module>pandalib-core</module> <module>pandalib-core</module>
<module>pandalib-db</module> <module>pandalib-db</module>
<module>pandalib-net</module> <module>pandalib-net</module>