Big refactor of Pandalib. More modules and better managed dependencies

This commit is contained in:
Marc Baloup 2022-07-20 13:18:57 +02:00
parent 1aec628b19
commit 7dcd92f72d
184 changed files with 1000 additions and 1986 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
/.idea /.idea
/*/target
dependency-reduced-pom.xml

View File

@ -8,35 +8,29 @@
</parent> </parent>
<artifactId>pandalib-bungee</artifactId> <artifactId>pandalib-bungee</artifactId>
<packaging>jar</packaging>
<name>PandaLib-Bungee</name> <repositories>
<repository>
<repositories> <id>bungeecord-repo</id>
<repository> <url>https://oss.sonatype.org/content/repositories/snapshots</url>
<id>papermc</id> </repository>
<url>https://papermc.io/repo/repository/maven-public/</url> </repositories>
</repository>
</repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>fr.pandacube.lib</groupId> <groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-core</artifactId> <artifactId>pandalib-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>${bungeecord.version}</version>
</dependency>
<!--
BungeeCord
-->
<dependency>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-proxy</artifactId>
<version>${bungeecord.version}</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>

View File

@ -1,229 +0,0 @@
package fr.pandacube.lib.bungee.commands;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.context.ParsedCommandNode;
import com.mojang.brigadier.context.StringRange;
import com.mojang.brigadier.suggestion.Suggestion;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import com.mojang.brigadier.tree.LiteralCommandNode;
import fr.pandacube.lib.core.chat.ChatStatic;
import fr.pandacube.lib.core.commands.SuggestionsSupplier;
import fr.pandacube.lib.core.players.IPlayerManager;
import fr.pandacube.lib.core.players.PlayerFinder;
import fr.pandacube.lib.core.util.Log;
import fr.pandacube.lib.core.util.Reflect;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;
import net.md_5.bungee.command.ConsoleCommandSender;
public abstract class BrigadierCommand extends ChatStatic {
protected BrigadierDispatcher dispatcher;
public BrigadierCommand() {
if (BrigadierDispatcher.getInstance() == null) {
throw new IllegalStateException("BrigadierDispatcher is not yet initialized.");
}
dispatcher = BrigadierDispatcher.getInstance();
LiteralArgumentBuilder<CommandSender> builder;
String[] aliases;
try {
builder = buildCommand();
aliases = getAliases();
} catch (Exception e) {
Log.severe("Exception encountered when building Brigadier command " + getClass().getName(), e);
return;
}
if (aliases == null)
aliases = new String[0];
LiteralCommandNode<CommandSender> commandNode = dispatcher.register(builder);
// still have to be registered for console
BungeeCord.getInstance().getPluginManager().registerCommand(dispatcher.plugin, new CommandRelay(commandNode.getLiteral()));
for (String alias : aliases) {
dispatcher.register(literal(alias)
.requires(commandNode.getRequirement())
.executes(commandNode.getCommand())
.redirect(commandNode)
);
BungeeCord.getInstance().getPluginManager().registerCommand(dispatcher.plugin, new CommandRelay(alias));
}
}
private class CommandRelay extends Command implements TabExecutor {
private final String alias;
public CommandRelay(String alias) {
super(alias);
this.alias = alias;
}
@Override
public void execute(CommandSender sender, String[] args) {
dispatcher.execute(sender, alias + (args.length == 0 ? "" : (" " + String.join(" ", args))));
}
@Override
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
String cursor = "/" + alias + " " + String.join(" ", args);
StringRange supportedRange = StringRange.between(cursor.lastIndexOf(' ') + 1, cursor.length());
Suggestions suggestions = dispatcher.getSuggestions(sender, cursor.substring(1));
if (!suggestions.getRange().equals(supportedRange))
return Collections.emptyList();
return suggestions.getList()
.stream()
.filter(s -> s.getRange().equals(supportedRange))
.map(Suggestion::getText)
.collect(Collectors.toList());
}
}
protected abstract LiteralArgumentBuilder<CommandSender> buildCommand();
protected String[] getAliases() {
return new String[0];
}
public static LiteralArgumentBuilder<CommandSender> literal(String name) {
return LiteralArgumentBuilder.literal(name);
}
public static <T> RequiredArgumentBuilder<CommandSender, T> argument(String name, ArgumentType<T> type) {
return RequiredArgumentBuilder.argument(name, type);
}
public static Predicate<CommandSender> hasPermission(String permission) {
return sender -> sender.hasPermission(permission);
}
public static Predicate<CommandSender> isPlayer() {
return BrigadierCommand::isPlayer;
}
public static boolean isPlayer(CommandSender sender) {
return sender instanceof ProxiedPlayer;
}
public static Predicate<CommandSender> isConsole() {
return BrigadierCommand::isConsole;
}
public static boolean isConsole(CommandSender sender) {
return sender instanceof ConsoleCommandSender;
}
public static boolean isLiteralParsed(CommandContext<CommandSender> context, String literal) {
for (ParsedCommandNode<CommandSender> node : context.getNodes()) {
if (!(node.getNode() instanceof LiteralCommandNode))
continue;
if (((LiteralCommandNode<CommandSender>)node.getNode()).getLiteral().equals(literal))
return true;
}
return false;
}
public static <T> T tryGetArgument(CommandContext<CommandSender> context, String argument, Class<T> type) {
return tryGetArgument(context, argument, type, null);
}
public static <T> T tryGetArgument(CommandContext<CommandSender> context, String argument, Class<T> type, T deflt) {
try {
return context.getArgument(argument, type);
} catch (IllegalArgumentException e) {
return deflt;
}
}
protected static SuggestionProvider<CommandSender> wrapSuggestions(SuggestionsSupplier<CommandSender> suggestions) {
return (context, builder) -> {
CommandSender sender = context.getSource();
String message = builder.getInput();
try {
int tokenStartPos = builder.getStart();
int firstSpacePos = message.indexOf(" ");
String[] args = (firstSpacePos + 1 > tokenStartPos - 1) ? new String[0]
: message.substring(firstSpacePos + 1, tokenStartPos - 1).split(" ", -1);
args = Arrays.copyOf(args, args.length + 1);
args[args.length - 1] = message.substring(tokenStartPos);
List<String> results = suggestions.getSuggestions(sender, args.length - 1, args[args.length - 1], args);
for (String s : results) {
if (s != null)
builder.suggest(s);
}
} catch (Throwable e) {
Log.severe("Error while tab-completing '" + message + "' for " + sender.getName(), e);
}
return completableFutureSuggestionsKeepsOriginalOrdering(builder);
};
}
public static CompletableFuture<Suggestions> completableFutureSuggestionsKeepsOriginalOrdering(SuggestionsBuilder builder) {
return CompletableFuture.completedFuture(
BrigadierDispatcher.createSuggestionsOriginalOrdering(builder.getInput(), getSuggestionsFromSuggestionsBuilder(builder))
);
}
@SuppressWarnings("unchecked")
private static List<Suggestion> getSuggestionsFromSuggestionsBuilder(SuggestionsBuilder builder) {
try {
return (List<Suggestion>) Reflect.ofClass(SuggestionsBuilder.class).field("result").getValue(builder);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
public static final SuggestionsSupplier<CommandSender> TAB_PLAYER_CURRENT_SERVER = (sender, ti, token, a) -> SuggestionsSupplier.collectFilteredStream(
IPlayerManager.getInstance().getNamesOnlyVisibleFor((sender instanceof ProxiedPlayer pl) ? pl.getUniqueId() : null, sender instanceof ProxiedPlayer).stream(),
token);
public static final SuggestionsSupplier<CommandSender> TAB_PLAYER_ALL_SERVERS = (sender, ti, token, a) -> SuggestionsSupplier.collectFilteredStream(
IPlayerManager.getInstance().getNamesOnlyVisibleFor((sender instanceof ProxiedPlayer pl) ? pl.getUniqueId() : null, false).stream(),
token);
public static final SuggestionsSupplier<CommandSender> TAB_PLAYER_ALL_SERVERS_THEN_OFFLINE = TAB_PLAYER_ALL_SERVERS.orIfEmpty(PlayerFinder.TAB_PLAYER_OFFLINE());
}

View File

@ -1,218 +0,0 @@
package fr.pandacube.lib.bungee.commands;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContextBuilder;
import com.mojang.brigadier.context.StringRange;
import com.mojang.brigadier.context.SuggestionContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.suggestion.Suggestion;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import fr.pandacube.lib.core.chat.Chat;
import fr.pandacube.lib.core.util.Log;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ChatEvent;
import net.md_5.bungee.api.event.CommandsDeclareEvent;
import net.md_5.bungee.api.event.TabCompleteRequestEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;
public class BrigadierDispatcher implements Listener {
private static BrigadierDispatcher instance = null;
public static synchronized void init(Plugin plugin) {
instance = new BrigadierDispatcher(plugin);
}
public static synchronized BrigadierDispatcher getInstance() {
return instance;
}
private final CommandDispatcher<CommandSender> dispatcher;
/* package */ final Plugin plugin;
private BrigadierDispatcher(Plugin pl) {
plugin = pl;
dispatcher = new CommandDispatcher<>();
ProxyServer.getInstance().getPluginManager().registerListener(plugin, this);
}
/* package */ LiteralCommandNode<CommandSender> register(LiteralArgumentBuilder<CommandSender> node) {
return dispatcher.register(node);
}
public CommandDispatcher<CommandSender> getDispatcher() {
return dispatcher;
}
@EventHandler
public void onCommandsDeclare(CommandsDeclareEvent event) {
dispatcher.getRoot().getChildren().forEach(node -> {
event.getRoot().getChildren().remove(event.getRoot().getChild(node.getName())); // may not work in the future
event.getRoot().addChild(node);
});
}
@EventHandler
public void onTabComplete(TabCompleteRequestEvent event) {
if (!event.getCursor().startsWith("/"))
return;
String commandLine = event.getCursor().substring(1);
String commandName = commandLine.split(" ", -1)[0];
if (dispatcher.getRoot().getChild(commandName) == null)
return;
Suggestions suggestions = getSuggestions((ProxiedPlayer) event.getSender(), commandLine);
// shift suggestion range 1 to the right to consider the /
suggestions = new Suggestions(new StringRange(suggestions.getRange().getStart() + 1, suggestions.getRange().getEnd() + 1), suggestions.getList());
event.setSuggestions(suggestions);
}
@EventHandler
public void onChat(ChatEvent event) {
if (!event.getMessage().startsWith("/"))
return;
String commandLine = event.getMessage().substring(1);
String commandName = commandLine.split(" ", -1)[0];
if (dispatcher.getRoot().getChild(commandName) == null)
return;
event.setCancelled(true);
ProxyServer.getInstance().getScheduler().runAsync(plugin, () -> execute((ProxiedPlayer) event.getSender(), commandLine));
}
/* package */ void execute(CommandSender sender, String commandWithoutSlash) {
ParseResults<CommandSender> parsed = dispatcher.parse(commandWithoutSlash, sender);
try {
dispatcher.execute(parsed);
} catch (CommandSyntaxException e) {
sender.sendMessage(Chat.failureText("Erreur d'utilisation de la commande : " + e.getMessage()).get());
} catch (Throwable e) {
sender.sendMessage(Chat.failureText("Erreur lors de l'exécution de la commande : " + e.getMessage()).get());
Log.severe(e);
}
}
/* package */ Suggestions getSuggestions(CommandSender sender, String buffer) {
ParseResults<CommandSender> parsed = dispatcher.parse(buffer, sender);
try {
CompletableFuture<Suggestions> futureSuggestions = buildSuggestionBrigadier(parsed);
return futureSuggestions.join();
} catch (Throwable e) {
sender.sendMessage(Chat.failureText("Erreur dexécution des suggestions :\n" + e.getMessage()).get());
Log.severe(e);
return Suggestions.empty().join();
}
}
CompletableFuture<Suggestions> buildSuggestionBrigadier(ParseResults<CommandSender> parsed) {
int cursor = parsed.getReader().getTotalLength();
final CommandContextBuilder<CommandSender> context = parsed.getContext();
final SuggestionContext<CommandSender> nodeBeforeCursor = context.findSuggestionContext(cursor);
final CommandNode<CommandSender> parent = nodeBeforeCursor.parent;
final int start = Math.min(nodeBeforeCursor.startPos, cursor);
final String fullInput = parsed.getReader().getString();
final String truncatedInput = fullInput.substring(0, cursor);
@SuppressWarnings("unchecked") final CompletableFuture<Suggestions>[] futures = new CompletableFuture[parent.getChildren().size()];
int i = 0;
for (final CommandNode<CommandSender> node : parent.getChildren()) {
CompletableFuture<Suggestions> future = Suggestions.empty();
try {
future = node.listSuggestions(context.build(truncatedInput), new SuggestionsBuilder(truncatedInput, start));
} catch (final CommandSyntaxException ignored) {
}
futures[i++] = future;
}
final CompletableFuture<Suggestions> result = new CompletableFuture<>();
CompletableFuture.allOf(futures).thenRun(() -> {
final List<Suggestions> suggestions = new ArrayList<>();
for (final CompletableFuture<Suggestions> future : futures) {
suggestions.add(future.join());
}
result.complete(mergeSuggestionsOriginalOrdering(fullInput, suggestions));
});
return result;
}
// inspired from com.mojang.brigadier.suggestion.Suggestions#merge, but without the sorting part
public static Suggestions mergeSuggestionsOriginalOrdering(String input, Collection<Suggestions> suggestions) {
if (suggestions.isEmpty()) {
return new Suggestions(StringRange.at(0), new ArrayList<>(0));
} else if (suggestions.size() == 1) {
return suggestions.iterator().next();
}
final List<Suggestion> texts = new ArrayList<>();
for (final Suggestions suggestions1 : suggestions) {
texts.addAll(suggestions1.getList());
}
return createSuggestionsOriginalOrdering(input, texts);
}
// inspired from com.mojang.brigadier.suggestion.Suggestions#create, but without the sorting part
public static Suggestions createSuggestionsOriginalOrdering(String command, Collection<Suggestion> suggestions) {
if (suggestions.isEmpty()) {
return new Suggestions(StringRange.at(0), new ArrayList<>(0));
}
int start = Integer.MAX_VALUE;
int end = Integer.MIN_VALUE;
for (final Suggestion suggestion : suggestions) {
start = Math.min(suggestion.getRange().getStart(), start);
end = Math.max(suggestion.getRange().getEnd(), end);
}
final StringRange range = new StringRange(start, end);
final List<Suggestion> texts = new ArrayList<>(suggestions.size());
for (final Suggestion suggestion : suggestions) {
texts.add(suggestion.expand(command, range));
}
return new Suggestions(range, texts);
}
}

View File

@ -8,8 +8,7 @@
</parent> </parent>
<artifactId>pandalib-cli</artifactId> <artifactId>pandalib-cli</artifactId>
<packaging>jar</packaging>
<name>PandaLib-CLI</name>
<repositories> <repositories>
<repository> <repository>
@ -17,7 +16,11 @@
<name>Minecraft Libraries</name> <name>Minecraft Libraries</name>
<url>https://libraries.minecraft.net</url> <url>https://libraries.minecraft.net</url>
</repository> </repository>
</repositories> <repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies> <dependencies>
<dependency> <dependency>
@ -28,13 +31,13 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>fr.pandacube.bungeecord</groupId> <groupId>net.md-5</groupId>
<artifactId>bungeecord-log</artifactId> <artifactId>bungeecord-log</artifactId>
<version>${bungeecord.version}</version> <version>${bungeecord.version}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>fr.pandacube.bungeecord</groupId> <groupId>net.md-5</groupId>
<artifactId>bungeecord-config</artifactId> <artifactId>bungeecord-config</artifactId>
<version>${bungeecord.version}</version> <version>${bungeecord.version}</version>
<scope>compile</scope> <scope>compile</scope>

View File

@ -15,10 +15,10 @@ import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder; import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import com.mojang.brigadier.tree.LiteralCommandNode; import com.mojang.brigadier.tree.LiteralCommandNode;
import fr.pandacube.lib.core.chat.ChatStatic; import fr.pandacube.lib.chat.ChatStatic;
import fr.pandacube.lib.core.commands.SuggestionsSupplier; import fr.pandacube.lib.core.commands.SuggestionsSupplier;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
public abstract class BrigadierCommand extends ChatStatic { public abstract class BrigadierCommand extends ChatStatic {

View File

@ -18,7 +18,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode; import com.mojang.brigadier.tree.LiteralCommandNode;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import jline.console.completer.Completer; import jline.console.completer.Completer;
public class BrigadierDispatcher implements Completer { public class BrigadierDispatcher implements Completer {

View File

@ -3,10 +3,10 @@ package fr.pandacube.lib.cli;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Logger; import java.util.logging.Logger;
import jline.console.ConsoleReader;
import org.fusesource.jansi.AnsiConsole; import org.fusesource.jansi.AnsiConsole;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import jline.console.ConsoleReader;
public class CLI { public class CLI {

57
Chat/pom.xml Normal file
View File

@ -0,0 +1,57 @@
<?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>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>pandalib-chat</artifactId>
<packaging>jar</packaging>
<repositories>
<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>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-plain</artifactId>
<version>4.11.0</version>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId>
<version>${bungeecord.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.chat; package fr.pandacube.lib.chat;
import java.awt.Color; import java.awt.Color;
import java.util.Objects; import java.util.Objects;
@ -6,8 +6,6 @@ import java.util.function.Consumer;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.function.UnaryOperator; import java.util.function.UnaryOperator;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.BlockNBTComponent; import net.kyori.adventure.text.BlockNBTComponent;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@ -296,12 +294,12 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource
@Override @Override
public @NonNull HoverEvent<Component> asHoverEvent(@NonNull UnaryOperator<Component> op) { public HoverEvent<Component> asHoverEvent(UnaryOperator<Component> op) {
return HoverEvent.showText(op.apply(getAdv())); return HoverEvent.showText(op.apply(getAdv()));
} }
@Override @Override
public @NonNull Component asComponent() { public Component asComponent() {
return getAdv(); return getAdv();
} }

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.chat; package fr.pandacube.lib.chat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View File

@ -1,14 +1,15 @@
package fr.pandacube.lib.core.chat; package fr.pandacube.lib.chat;
import java.util.Objects; import java.util.Objects;
import fr.pandacube.lib.core.chat.Chat.FormatableChat;
import fr.pandacube.lib.core.util.Log;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import fr.pandacube.lib.chat.Chat.FormatableChat;
import fr.pandacube.lib.util.Log;
public abstract class ChatStatic { public abstract class ChatStatic {

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.chat; package fr.pandacube.lib.chat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -8,7 +8,6 @@ import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.collect.ImmutableMap;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.TranslatableComponent;
@ -18,24 +17,20 @@ import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.format.TextDecoration.State; import net.kyori.adventure.text.format.TextDecoration.State;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import fr.pandacube.lib.core.chat.Chat.FormatableChat; import fr.pandacube.lib.chat.Chat.FormatableChat;
import static fr.pandacube.lib.core.chat.ChatStatic.chat;
import static fr.pandacube.lib.core.chat.ChatStatic.legacyText;
import static fr.pandacube.lib.core.chat.ChatStatic.text;
public class ChatUtil { public class ChatUtil {
public static final int DEFAULT_CHAR_SIZE = 6; public static final int DEFAULT_CHAR_SIZE = 6;
public static final Map<Integer, String> CHARS_SIZE = new ImmutableMap.Builder<Integer, String>() public static final Map<Integer, String> CHARS_SIZE = Map.ofEntries(
.put(-6, "§") Map.entry(-6, "§"),
.put(2, "!.,:;i|¡'") Map.entry(2, "!.,:;i|¡'"),
.put(3, "`lìí") Map.entry(3, "`lìí"),
.put(4, " I[]tï×") Map.entry(4, " I[]tï×"),
.put(5, "\"()*<>fk{}") Map.entry(5, "\"()*<>fk{}"),
.put(7, "@~®©«»") Map.entry(7, "@~®©«»"),
.put(9, "├└") Map.entry(9, "├└")
.build(); );
@ -54,16 +49,16 @@ public class ChatUtil {
public static FormatableChat createURLLink(String text, String url) { public static FormatableChat createURLLink(String text, String url) {
return createURLLink(legacyText(text), url, null); return createURLLink(ChatStatic.legacyText(text), url, null);
} }
public static FormatableChat createURLLink(String text, String url, String hoverText) { public static FormatableChat createURLLink(String text, String url, String hoverText) {
return createURLLink(legacyText(text), url, hoverText != null ? legacyText(hoverText) : null); return createURLLink(ChatStatic.legacyText(text), url, hoverText != null ? ChatStatic.legacyText(hoverText) : null);
} }
/* package */ static FormatableChat createURLLink(Chat element, String url, Chat hover) { /* package */ static FormatableChat createURLLink(Chat element, String url, Chat hover) {
String dispURL = (url.length() > 50) ? (url.substring(0, 48) + "...") : url; String dispURL = (url.length() > 50) ? (url.substring(0, 48) + "...") : url;
return (FormatableChat) chat() return (FormatableChat) ChatStatic.chat()
.clickURL(url) .clickURL(url)
.urlColor() .urlColor()
.hover( .hover(
@ -80,14 +75,14 @@ public class ChatUtil {
public static FormatableChat createCommandLink(String text, String commandWithSlash, String hoverText) { public static FormatableChat createCommandLink(String text, String commandWithSlash, String hoverText) {
return createCommandLink(text, commandWithSlash, hoverText == null ? null : legacyText(hoverText)); return createCommandLink(text, commandWithSlash, hoverText == null ? null : ChatStatic.legacyText(hoverText));
} }
public static FormatableChat createCommandLink(String text, String commandWithSlash, Chat hoverText) { public static FormatableChat createCommandLink(String text, String commandWithSlash, Chat hoverText) {
return createCommandLink(legacyText(text), commandWithSlash, hoverText); return createCommandLink(ChatStatic.legacyText(text), commandWithSlash, hoverText);
} }
/* package */ static FormatableChat createCommandLink(Chat d, String commandWithSlash, Chat hoverText) { /* package */ static FormatableChat createCommandLink(Chat d, String commandWithSlash, Chat hoverText) {
FormatableChat c = chat() FormatableChat c = ChatStatic.chat()
.clickCommand(commandWithSlash) .clickCommand(commandWithSlash)
.commandColor(); .commandColor();
if (hoverText != null) if (hoverText != null)
@ -105,14 +100,14 @@ public class ChatUtil {
public static FormatableChat createCommandSuggest(String text, String commandWithSlash, String hoverText) { public static FormatableChat createCommandSuggest(String text, String commandWithSlash, String hoverText) {
return createCommandSuggest(text, commandWithSlash, hoverText == null ? null : legacyText(hoverText)); return createCommandSuggest(text, commandWithSlash, hoverText == null ? null : ChatStatic.legacyText(hoverText));
} }
public static FormatableChat createCommandSuggest(String text, String commandWithSlash, Chat hoverText) { public static FormatableChat createCommandSuggest(String text, String commandWithSlash, Chat hoverText) {
return createCommandSuggest(legacyText(text), commandWithSlash, hoverText); return createCommandSuggest(ChatStatic.legacyText(text), commandWithSlash, hoverText);
} }
/* package */ static FormatableChat createCommandSuggest(Chat d, String commandWithSlash, Chat hoverText) { /* package */ static FormatableChat createCommandSuggest(Chat d, String commandWithSlash, Chat hoverText) {
FormatableChat c = chat() FormatableChat c = ChatStatic.chat()
.clickSuggest(commandWithSlash) .clickSuggest(commandWithSlash)
.commandColor(); .commandColor();
if (hoverText != null) if (hoverText != null)
@ -143,7 +138,7 @@ public class ChatUtil {
pagesToDisplay.add(i); pagesToDisplay.add(i);
} }
Chat d = chat().thenLegacyText(prefix); Chat d = ChatStatic.chat().thenLegacyText(prefix);
boolean first = true; boolean first = true;
int previous = 0; int previous = 0;
@ -213,7 +208,7 @@ public class ChatUtil {
return text; return text;
String sideChars = repeatedChar(repeatedChar, sideNbChar); String sideChars = repeatedChar(repeatedChar, sideNbChar);
FormatableChat side = text(sideChars).color(decorationColor); FormatableChat side = ChatStatic.text(sideChars).color(decorationColor);
if (decorationBold) if (decorationBold)
side.bold(); side.bold();
@ -242,11 +237,11 @@ public class ChatUtil {
int rightNbChar = (maxWidth - (textWidth + leftWidth)) / repeatedCharWidth; int rightNbChar = (maxWidth - (textWidth + leftWidth)) / repeatedCharWidth;
Chat d = chat() Chat d = ChatStatic.chat()
.then(text(repeatedChar(repeatedChar, nbLeft)).color(decorationColor)) .then(ChatStatic.text(repeatedChar(repeatedChar, nbLeft)).color(decorationColor))
.then(text); .then(text);
if (repeatedChar != ' ') { if (repeatedChar != ' ') {
d.then(text(repeatedChar(repeatedChar, rightNbChar)).color(decorationColor)); d.then(ChatStatic.text(repeatedChar(repeatedChar, rightNbChar)).color(decorationColor));
} }
return d; return d;
@ -268,11 +263,11 @@ public class ChatUtil {
int leftNbChar = (maxWidth - (textWidth + rightWidth)) / repeatedCharWidth; int leftNbChar = (maxWidth - (textWidth + rightWidth)) / repeatedCharWidth;
Chat d = chat() Chat d = ChatStatic.chat()
.then(text(repeatedChar(repeatedChar, leftNbChar)).color(decorationColor)) .then(ChatStatic.text(repeatedChar(repeatedChar, leftNbChar)).color(decorationColor))
.then(text); .then(text);
if (repeatedChar != ' ') { if (repeatedChar != ' ') {
d.then(text(repeatedChar(repeatedChar, nbRight)).color(decorationColor)); d.then(ChatStatic.text(repeatedChar(repeatedChar, nbRight)).color(decorationColor));
} }
return d; return d;
@ -288,7 +283,7 @@ public class ChatUtil {
public static Chat emptyLine(char repeatedChar, TextColor decorationColor, boolean decorationBold, boolean console, int maxWidth) { public static Chat emptyLine(char repeatedChar, TextColor decorationColor, boolean decorationBold, boolean console, int maxWidth) {
int count = maxWidth / charW(repeatedChar, console, decorationBold); int count = maxWidth / charW(repeatedChar, console, decorationBold);
FormatableChat line = text(repeatedChar(repeatedChar, count)).color(decorationColor); FormatableChat line = ChatStatic.text(repeatedChar(repeatedChar, count)).color(decorationColor);
if (decorationBold) if (decorationBold)
line.bold(); line.bold();
return line; return line;
@ -585,13 +580,13 @@ public class ChatUtil {
} }
// 2. Generate rendered text // 2. Generate rendered text
Chat c = text(PROGRESS_BAR_START); Chat c = ChatStatic.text(PROGRESS_BAR_START);
int sumSizes = 0; int sumSizes = 0;
for (int i = 0; i < sizes.length; i++) { for (int i = 0; i < sizes.length; i++) {
sumSizes += sizes[i]; sumSizes += sizes[i];
FormatableChat subC = text(repeatedChar(PROGRESS_BAR_FULL_CHAR, sizes[i])); FormatableChat subC = ChatStatic.text(repeatedChar(PROGRESS_BAR_FULL_CHAR, sizes[i]));
if (colors != null && i < colors.length && colors[i] != null) if (colors != null && i < colors.length && colors[i] != null)
subC.color(colors[i]); subC.color(colors[i]);
@ -600,7 +595,7 @@ public class ChatUtil {
} }
return c return c
.then(text(repeatedChar(PROGRESS_BAR_EMPTY_CHAR, progressCharWidth - sumSizes)) .then(ChatStatic.text(repeatedChar(PROGRESS_BAR_EMPTY_CHAR, progressCharWidth - sumSizes))
.color(PROGRESS_BAR_EMPTY_COLOR)) .color(PROGRESS_BAR_EMPTY_COLOR))
.thenText(PROGRESS_BAR_END); .thenText(PROGRESS_BAR_END);
} }
@ -674,7 +669,7 @@ public class ChatUtil {
public static List<Chat> treeView(DisplayTreeNode node, boolean console) { public static List<Chat> treeView(DisplayTreeNode node, boolean console) {
List<Chat> ret = new ArrayList<>(); List<Chat> ret = new ArrayList<>();
ret.add(chat() ret.add(ChatStatic.chat()
.then(node.component)); .then(node.component));
for (int i = 0; i < node.children.size(); i++) { for (int i = 0; i < node.children.size(); i++) {
@ -685,7 +680,7 @@ public class ChatUtil {
String prefix = last ? (j == 0 ? TREE_END_CONNECTED : (console ? TREE_END_OPEN_CONSOLE : TREE_END_OPEN)) String prefix = last ? (j == 0 ? TREE_END_CONNECTED : (console ? TREE_END_OPEN_CONSOLE : TREE_END_OPEN))
: (j == 0 ? TREE_MIDDLE_CONNECTED : (console ? TREE_MIDDLE_OPEN_CONSOLE : TREE_MIDDLE_OPEN)); : (j == 0 ? TREE_MIDDLE_CONNECTED : (console ? TREE_MIDDLE_OPEN_CONSOLE : TREE_MIDDLE_OPEN));
ret.add(text(prefix) ret.add(ChatStatic.text(prefix)
.then(childComponents.get(j))); .then(childComponents.get(j)));
} }
} }

View File

@ -12,8 +12,6 @@
<artifactId>pandalib-core</artifactId> <artifactId>pandalib-core</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>PandaLib-Core</name>
<repositories> <repositories>
<repository> <repository>
<id>sonatype-oss-snapshots</id> <id>sonatype-oss-snapshots</id>
@ -27,34 +25,42 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>fr.pandacube.bungeecord</groupId> <groupId>fr.pandacube.lib</groupId>
<artifactId>bungeecord-chat</artifactId> <artifactId>pandalib-util</artifactId>
<version>${bungeecord.version}</version> <version>${project.version}</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.kyori</groupId> <groupId>fr.pandacube.lib</groupId>
<artifactId>adventure-api</artifactId> <artifactId>pandalib-chat</artifactId>
<version>4.11.0</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bungeecord</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-serializer-plain</artifactId>
<version>4.11.0</version>
</dependency>
<dependency> <dependency>
<groupId>io.github.classgraph</groupId> <groupId>fr.pandacube.lib</groupId>
<artifactId>classgraph</artifactId> <artifactId>pandalib-db</artifactId>
<version>4.8.147</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-reflect</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-permissions</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-network-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>com.fathzer</groupId> <groupId>com.fathzer</groupId>
@ -67,33 +73,6 @@
<groupId>org.geysermc.floodgate</groupId> <groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId> <artifactId>api</artifactId>
<version>2.0-SNAPSHOT</version> <version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>io.github.classgraph:classgraph</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -2,7 +2,7 @@ package fr.pandacube.lib.core.commands;
import java.util.Arrays; import java.util.Arrays;
import fr.pandacube.lib.core.chat.ChatStatic; import fr.pandacube.lib.chat.ChatStatic;
public class AbstractCommand extends ChatStatic { public class AbstractCommand extends ChatStatic {

View File

@ -11,7 +11,8 @@ 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.core.util.ListUtil; import fr.pandacube.lib.util.ListUtil;
import fr.pandacube.lib.util.TimeUtil;
@FunctionalInterface @FunctionalInterface
public interface SuggestionsSupplier<S> { public interface SuggestionsSupplier<S> {
@ -187,6 +188,49 @@ public interface SuggestionsSupplier<S> {
public static <S> SuggestionsSupplier<S> suggestDuration() {
final List<String> emptyTokenSuggestions = TimeUtil.DURATION_SUFFIXES.stream().map(p -> "1" + p).collect(Collectors.toList());
return (s, ti, token, args) -> {
if (token.isEmpty()) {
return emptyTokenSuggestions;
}
List<String> remainingSuffixes = new ArrayList<>(TimeUtil.DURATION_SUFFIXES);
char[] tokenChars = token.toCharArray();
String accSuffix = "";
for (char c : tokenChars) {
if (Character.isDigit(c)) {
scanAndRemovePastSuffixes(remainingSuffixes, accSuffix);
accSuffix = "";
} else if (Character.isLetter(c)) {
accSuffix += c;
} else
return Collections.emptyList();
}
String prefixToken = token.substring(0, token.length() - accSuffix.length());
return SuggestionsSupplier.collectFilteredStream(remainingSuffixes.stream(), accSuffix)
.stream()
.map(str -> prefixToken + str)
.collect(Collectors.toList());
};
}
private static void scanAndRemovePastSuffixes(List<String> suffixes, String foundSuffix) {
for (int i = 0; i < suffixes.size(); i++) {
if (foundSuffix.startsWith(suffixes.get(i))) {
suffixes.subList(0, i + 1).clear();
return;
}
}
}
/** /**
* Create a {@link SuggestionsSupplier} that support greedy strings argument using the suggestion from this {@link SuggestionsSupplier}. * Create a {@link SuggestionsSupplier} that support greedy strings argument using the suggestion from this {@link SuggestionsSupplier}.
* @param index the index of the first argument of the greedy string argument * @param index the index of the first argument of the greedy string argument

View File

@ -8,8 +8,9 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import fr.pandacube.lib.core.chat.ChatColorUtil; import fr.pandacube.lib.chat.ChatColorUtil;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
/** /**
* Class tht loads a specific config file or directory * Class tht loads a specific config file or directory
* *

View File

@ -1,21 +1,21 @@
package fr.pandacube.lib.core.players; package fr.pandacube.lib.core.players;
import static fr.pandacube.lib.core.chat.ChatStatic.dataText;
import static fr.pandacube.lib.core.chat.ChatStatic.successText;
import static fr.pandacube.lib.core.chat.ChatStatic.text;
import static fr.pandacube.lib.core.chat.ChatStatic.warningText;
import java.util.Calendar; import java.util.Calendar;
import java.util.OptionalLong; import java.util.OptionalLong;
import java.util.UUID; import java.util.UUID;
import java.util.stream.LongStream; import java.util.stream.LongStream;
import fr.pandacube.lib.core.chat.Chat; import fr.pandacube.lib.chat.Chat;
import fr.pandacube.lib.core.chat.ChatColorUtil; import fr.pandacube.lib.chat.ChatColorUtil;
import fr.pandacube.lib.core.db.DBException; import fr.pandacube.lib.db.DBException;
import fr.pandacube.lib.core.permissions.PermPlayer; import fr.pandacube.lib.permissions.PermPlayer;
import fr.pandacube.lib.core.permissions.Permissions; import fr.pandacube.lib.permissions.Permissions;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import static fr.pandacube.lib.chat.ChatStatic.dataText;
import static fr.pandacube.lib.chat.ChatStatic.successText;
import static fr.pandacube.lib.chat.ChatStatic.text;
import static fr.pandacube.lib.chat.ChatStatic.warningText;
public interface IOffPlayer { public interface IOffPlayer {

View File

@ -8,8 +8,8 @@ import java.util.stream.LongStream;
import org.geysermc.floodgate.api.FloodgateApi; import org.geysermc.floodgate.api.FloodgateApi;
import org.geysermc.floodgate.api.player.FloodgatePlayer; import org.geysermc.floodgate.api.player.FloodgatePlayer;
import fr.pandacube.lib.core.chat.Chat; import fr.pandacube.lib.chat.Chat;
import fr.pandacube.lib.core.db.DBException; import fr.pandacube.lib.db.DBException;
import net.kyori.adventure.identity.Identified; import net.kyori.adventure.identity.Identified;
import net.kyori.adventure.identity.Identity; import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;

View File

@ -13,15 +13,15 @@ import java.util.stream.Collectors;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import fr.pandacube.lib.core.chat.Chat;
import fr.pandacube.lib.core.db.DB;
import fr.pandacube.lib.core.db.DBInitTableException;
import fr.pandacube.lib.core.util.Log;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.ComponentLike;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import fr.pandacube.lib.chat.Chat;
import fr.pandacube.lib.db.DB;
import fr.pandacube.lib.db.DBInitTableException;
import fr.pandacube.lib.util.Log;
public abstract class IPlayerManager<OP extends IOnlinePlayer, OF extends IOffPlayer> { public abstract class IPlayerManager<OP extends IOnlinePlayer, OF extends IOffPlayer> {
private static IPlayerManager<?, ?> instance; private static IPlayerManager<?, ?> instance;

View File

@ -19,11 +19,11 @@ import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.UncheckedExecutionException; import com.google.common.util.concurrent.UncheckedExecutionException;
import fr.pandacube.lib.core.commands.SuggestionsSupplier; import fr.pandacube.lib.core.commands.SuggestionsSupplier;
import fr.pandacube.lib.core.db.DB; import fr.pandacube.lib.db.DB;
import fr.pandacube.lib.core.db.DBException; import fr.pandacube.lib.db.DBException;
import fr.pandacube.lib.core.db.SQLOrderBy; import fr.pandacube.lib.db.SQLOrderBy;
import fr.pandacube.lib.core.util.LevenshteinDistance; import fr.pandacube.lib.util.LevenshteinDistance;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
/* /*
* Etape de recherche de joueur : * Etape de recherche de joueur :

View File

@ -6,12 +6,12 @@ import java.util.GregorianCalendar;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import fr.pandacube.lib.core.db.DB; import fr.pandacube.lib.db.DB;
import fr.pandacube.lib.core.db.DBException; import fr.pandacube.lib.db.DBException;
import fr.pandacube.lib.core.db.SQLElement; import fr.pandacube.lib.db.SQLElement;
import fr.pandacube.lib.core.db.SQLElementList; import fr.pandacube.lib.db.SQLElementList;
import fr.pandacube.lib.core.db.SQLField; import fr.pandacube.lib.db.SQLField;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
public class SQLPlayer extends SQLElement<SQLPlayer> { public class SQLPlayer extends SQLElement<SQLPlayer> {

View File

@ -2,12 +2,12 @@ package fr.pandacube.lib.core.players;
import java.util.UUID; import java.util.UUID;
import fr.pandacube.lib.core.db.DB; import fr.pandacube.lib.db.DB;
import fr.pandacube.lib.core.db.DBException; import fr.pandacube.lib.db.DBException;
import fr.pandacube.lib.core.db.SQLElement; import fr.pandacube.lib.db.SQLElement;
import fr.pandacube.lib.core.db.SQLElementList; import fr.pandacube.lib.db.SQLElementList;
import fr.pandacube.lib.core.db.SQLFKField; import fr.pandacube.lib.db.SQLFKField;
import fr.pandacube.lib.core.db.SQLField; import fr.pandacube.lib.db.SQLField;
public class SQLPlayerConfig extends SQLElement<SQLPlayerConfig> { public class SQLPlayerConfig extends SQLElement<SQLPlayerConfig> {

View File

@ -3,10 +3,10 @@ package fr.pandacube.lib.core.players;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import fr.pandacube.lib.core.db.DB; import fr.pandacube.lib.db.DB;
import fr.pandacube.lib.core.db.DBException; import fr.pandacube.lib.db.DBException;
import fr.pandacube.lib.core.db.SQLElement; import fr.pandacube.lib.db.SQLElement;
import fr.pandacube.lib.core.db.SQLFKField; import fr.pandacube.lib.db.SQLFKField;
public class SQLPlayerIgnore extends SQLElement<SQLPlayerIgnore> { public class SQLPlayerIgnore extends SQLElement<SQLPlayerIgnore> {

View File

@ -2,12 +2,12 @@ package fr.pandacube.lib.core.players;
import java.util.UUID; import java.util.UUID;
import fr.pandacube.lib.core.db.DB; import fr.pandacube.lib.db.DB;
import fr.pandacube.lib.core.db.DBException; import fr.pandacube.lib.db.DBException;
import fr.pandacube.lib.core.db.SQLElement; import fr.pandacube.lib.db.SQLElement;
import fr.pandacube.lib.core.db.SQLFKField; import fr.pandacube.lib.db.SQLFKField;
import fr.pandacube.lib.core.db.SQLField; import fr.pandacube.lib.db.SQLField;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
public class SQLPlayerNameHistory extends SQLElement<SQLPlayerNameHistory> { public class SQLPlayerNameHistory extends SQLElement<SQLPlayerNameHistory> {

View File

@ -2,9 +2,9 @@ package fr.pandacube.lib.core.players;
import java.util.UUID; import java.util.UUID;
import fr.pandacube.lib.core.chat.Chat; import fr.pandacube.lib.chat.Chat;
import fr.pandacube.lib.core.db.DBInitTableException; import fr.pandacube.lib.db.DBInitTableException;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
/** /**

View File

@ -2,7 +2,7 @@ package fr.pandacube.lib.core.search;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,773 +0,0 @@
package fr.pandacube.lib.core.util;
import java.net.URL;
import java.util.ArrayList;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
/**
* Class GifDecoder - Decodes a GIF file into one or more frames.
* <br><pre>
* Example:
* GifDecoder d = new GifDecoder();
* d.read("sample.gif");
* int n = d.getFrameCount();
* for (int i = 0; i < n; i++) {
* BufferedImage frame = d.getFrame(i); // frame i
* int t = d.getDelay(i); // display duration of frame in milliseconds
* // do something with frame
* }
* </pre>
* No copyright asserted on the source code of this class. May be used for
* any purpose, however, refer to the Unisys LZW patent for any additional
* restrictions. Please forward any corrections to questions at fmsware.com.
*
* @author Kevin Weiner, FM Software; LZW decoder adapted from John Cristy's ImageMagick.
* @version 1.03 November 2003
*
*/
public class GifDecoder {
/**
* File read status: No errors.
*/
public static final int STATUS_OK = 0;
/**
* File read status: Error decoding file (may be partially decoded)
*/
public static final int STATUS_FORMAT_ERROR = 1;
/**
* File read status: Unable to open source.
*/
public static final int STATUS_OPEN_ERROR = 2;
protected BufferedInputStream in;
protected int status;
protected int width; // full image width
protected int height; // full image height
protected boolean gctFlag; // global color table used
protected int gctSize; // size of global color table
protected int loopCount = 1; // iterations; 0 = repeat forever
protected int[] gct; // global color table
protected int[] lct; // local color table
protected int[] act; // active color table
protected int bgIndex; // background color index
protected int bgColor; // background color
protected int lastBgColor; // previous bg color
protected int pixelAspect; // pixel aspect ratio
protected boolean lctFlag; // local color table flag
protected boolean interlace; // interlace flag
protected int lctSize; // local color table size
protected int ix, iy, iw, ih; // current image rectangle
protected Rectangle lastRect; // last image rect
protected BufferedImage image; // current frame
protected BufferedImage lastImage; // previous frame
protected byte[] block = new byte[256]; // current data block
protected int blockSize = 0; // block size
// last graphic control extension info
protected int dispose = 0;
// 0=no action; 1=leave in place; 2=restore to bg; 3=restore to prev
protected int lastDispose = 0;
protected boolean transparency = false; // use transparent color
protected int delay = 0; // delay in milliseconds
protected int transIndex; // transparent color index
protected static final int MaxStackSize = 4096;
// max decoder pixel stack size
// LZW decoder working arrays
protected short[] prefix;
protected byte[] suffix;
protected byte[] pixelStack;
protected byte[] pixels;
protected ArrayList<GifFrame> frames; // frames read from current file
protected int frameCount;
record GifFrame(BufferedImage image, int delay) {
}
/**
* Gets display duration for specified frame.
*
* @param n int index of frame
* @return delay in milliseconds
*/
public int getDelay(int n) {
//
delay = -1;
if ((n >= 0) && (n < frameCount)) {
delay = frames.get(n).delay;
}
return delay;
}
/**
* Gets the number of frames read from file.
* @return frame count
*/
public int getFrameCount() {
return frameCount;
}
/**
* Gets the first (or only) image read.
*
* @return BufferedImage containing first frame, or null if none.
*/
public BufferedImage getImage() {
return getFrame(0);
}
/**
* Gets the "Netscape" iteration count, if any.
* A count of 0 means repeat indefinitiely.
*
* @return iteration count if one was specified, else 1.
*/
public int getLoopCount() {
return loopCount;
}
/**
* Creates new frame image from current data (and previous
* frames as specified by their disposition codes).
*/
protected void setPixels() {
// expose destination image's pixels as int array
int[] dest =
((DataBufferInt) image.getRaster().getDataBuffer()).getData();
// fill in starting image contents based on last image's dispose code
if (lastDispose > 0) {
if (lastDispose == 3) {
// use image before last
int n = frameCount - 2;
if (n > 0) {
lastImage = getFrame(n - 1);
} else {
lastImage = null;
}
}
if (lastImage != null) {
int[] prev =
((DataBufferInt) lastImage.getRaster().getDataBuffer()).getData();
System.arraycopy(prev, 0, dest, 0, width * height);
// copy pixels
if (lastDispose == 2) {
// fill last image rect area with background color
Graphics2D g = image.createGraphics();
Color c = transparency ? new Color(0, 0, 0, 0) : new Color(lastBgColor);
g.setColor(c);
g.setComposite(AlphaComposite.Src); // replace area
g.fill(lastRect);
g.dispose();
}
}
}
// copy each source line to the appropriate place in the destination
int pass = 1;
int inc = 8;
int iline = 0;
for (int i = 0; i < ih; i++) {
int line = i;
if (interlace) {
if (iline >= ih) {
pass++;
switch (pass) {
case 2 :
iline = 4;
break;
case 3 :
iline = 2;
inc = 4;
break;
case 4 :
iline = 1;
inc = 2;
}
}
line = iline;
iline += inc;
}
line += iy;
if (line < height) {
int k = line * width;
int dx = k + ix; // start of line in dest
int dlim = dx + iw; // end of dest line
if ((k + width) < dlim) {
dlim = k + width; // past dest edge
}
int sx = i * iw; // start of line in source
while (dx < dlim) {
// map color and insert in destination
int index = (pixels[sx++]) & 0xff;
int c = act[index];
if (c != 0) {
dest[dx] = c;
}
dx++;
}
}
}
}
/**
* Gets the image contents of frame n.
*
* @return BufferedImage representation of frame, or null if n is invalid.
*/
public BufferedImage getFrame(int n) {
BufferedImage im = null;
if ((n >= 0) && (n < frameCount)) {
im = frames.get(n).image;
}
return im;
}
/**
* Gets image size.
*
* @return GIF image dimensions
*/
public Dimension getFrameSize() {
return new Dimension(width, height);
}
/**
* Reads GIF image from stream
*
* @param is containing GIF file.
* @return read status code (0 = no errors)
*/
public int read(BufferedInputStream is) {
init();
if (is != null) {
in = is;
readHeader();
if (!err()) {
readContents();
if (frameCount < 0) {
status = STATUS_FORMAT_ERROR;
}
}
try {
is.close();
} catch (IOException ignored) {
}
} else {
status = STATUS_OPEN_ERROR;
}
return status;
}
/**
* Reads GIF image from stream
*
* @param is containing GIF file.
* @return read status code (0 = no errors)
*/
public int read(InputStream is) {
init();
if (is != null) {
if (!(is instanceof BufferedInputStream))
is = new BufferedInputStream(is);
in = (BufferedInputStream) is;
readHeader();
if (!err()) {
readContents();
if (frameCount < 0) {
status = STATUS_FORMAT_ERROR;
}
}
try {
is.close();
} catch (IOException ignored) {
}
} else {
status = STATUS_OPEN_ERROR;
}
return status;
}
/**
* Reads GIF file from specified file/URL source
* (URL assumed if name contains ":/" or "file:")
*
* @param name String containing source
* @return read status code (0 = no errors)
*/
public int read(String name) {
status = STATUS_OK;
try {
name = name.trim().toLowerCase();
if ((name.contains("file:")) ||
(name.indexOf(":/") > 0)) {
URL url = new URL(name);
in = new BufferedInputStream(url.openStream());
} else {
in = new BufferedInputStream(new FileInputStream(name));
}
status = read(in);
} catch (IOException e) {
status = STATUS_OPEN_ERROR;
}
return status;
}
/**
* Decodes LZW image data into pixel array.
* Adapted from John Cristy's ImageMagick.
*/
protected void decodeImageData() {
int NullCode = -1;
int npix = iw * ih;
int available,
clear,
code_mask,
code_size,
end_of_information,
in_code,
old_code,
bits,
code,
count,
i,
datum,
data_size,
first,
top,
bi,
pi;
if ((pixels == null) || (pixels.length < npix)) {
pixels = new byte[npix]; // allocate new pixel array
}
if (prefix == null) prefix = new short[MaxStackSize];
if (suffix == null) suffix = new byte[MaxStackSize];
if (pixelStack == null) pixelStack = new byte[MaxStackSize + 1];
// Initialize GIF data stream decoder.
data_size = read();
clear = 1 << data_size;
end_of_information = clear + 1;
available = clear + 2;
old_code = NullCode;
code_size = data_size + 1;
code_mask = (1 << code_size) - 1;
for (code = 0; code < clear; code++) {
prefix[code] = 0;
suffix[code] = (byte) code;
}
// Decode GIF pixel stream.
datum = bits = count = first = top = pi = bi = 0;
for (i = 0; i < npix;) {
if (top == 0) {
if (bits < code_size) {
// Load bytes until there are enough bits for a code.
if (count == 0) {
// Read a new data block.
count = readBlock();
if (count <= 0)
break;
bi = 0;
}
datum += ((block[bi]) & 0xff) << bits;
bits += 8;
bi++;
count--;
continue;
}
// Get the next code.
code = datum & code_mask;
datum >>= code_size;
bits -= code_size;
// Interpret the code
if ((code > available) || (code == end_of_information))
break;
if (code == clear) {
// Reset decoder.
code_size = data_size + 1;
code_mask = (1 << code_size) - 1;
available = clear + 2;
old_code = NullCode;
continue;
}
if (old_code == NullCode) {
pixelStack[top++] = suffix[code];
old_code = code;
first = code;
continue;
}
in_code = code;
if (code == available) {
pixelStack[top++] = (byte) first;
code = old_code;
}
while (code > clear) {
pixelStack[top++] = suffix[code];
code = prefix[code];
}
first = (suffix[code]) & 0xff;
// Add a new string to the string table,
if (available >= MaxStackSize) {
pixelStack[top++] = (byte) first;
continue;
}
pixelStack[top++] = (byte) first;
prefix[available] = (short) old_code;
suffix[available] = (byte) first;
available++;
if (((available & code_mask) == 0)
&& (available < MaxStackSize)) {
code_size++;
code_mask += available;
}
old_code = in_code;
}
// Pop a pixel off the pixel stack.
top--;
pixels[pi++] = pixelStack[top];
i++;
}
for (i = pi; i < npix; i++) {
pixels[i] = 0; // clear missing pixels
}
}
/**
* Returns true if an error was encountered during reading/decoding
*/
protected boolean err() {
return status != STATUS_OK;
}
/**
* Initializes or re-initializes reader
*/
protected void init() {
status = STATUS_OK;
frameCount = 0;
frames = new ArrayList<>();
gct = null;
lct = null;
}
/**
* Reads a single byte from the input stream.
*/
protected int read() {
int curByte = 0;
try {
curByte = in.read();
} catch (IOException e) {
status = STATUS_FORMAT_ERROR;
}
return curByte;
}
/**
* Reads next variable length block from input.
*
* @return number of bytes stored in "buffer"
*/
protected int readBlock() {
blockSize = read();
int n = 0;
if (blockSize > 0) {
try {
int count;
while (n < blockSize) {
count = in.read(block, n, blockSize - n);
if (count == -1)
break;
n += count;
}
} catch (IOException ignored) {
}
if (n < blockSize) {
status = STATUS_FORMAT_ERROR;
}
}
return n;
}
/**
* Reads color table as 256 RGB integer values
*
* @param ncolors int number of colors to read
* @return int array containing 256 colors (packed ARGB with full alpha)
*/
protected int[] readColorTable(int ncolors) {
int nbytes = 3 * ncolors;
int[] tab = null;
byte[] c = new byte[nbytes];
int n = 0;
try {
n = in.read(c);
} catch (IOException ignored) {
}
if (n < nbytes) {
status = STATUS_FORMAT_ERROR;
} else {
tab = new int[256]; // max size to avoid bounds checks
int i = 0;
int j = 0;
while (i < ncolors) {
int r = (c[j++]) & 0xff;
int g = (c[j++]) & 0xff;
int b = (c[j++]) & 0xff;
tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b;
}
}
return tab;
}
/**
* Main file parser. Reads GIF content blocks.
*/
protected void readContents() {
// read GIF file content blocks
boolean done = false;
while (!(done || err())) {
int code = read();
switch (code) {
case 0x2C : // image separator
readImage();
break;
case 0x21 : // extension
code = read();
switch (code) {
case 0xf9 : // graphics control extension
readGraphicControlExt();
break;
case 0xff : // application extension
readBlock();
StringBuilder app = new StringBuilder();
for (int i = 0; i < 11; i++) {
app.append((char) block[i]);
}
if (app.toString().equals("NETSCAPE2.0")) {
readNetscapeExt();
}
else
skip(); // don't care
break;
default : // uninteresting extension
skip();
}
break;
case 0x3b : // terminator
done = true;
break;
case 0x00 : // bad byte, but keep going and see what happens
break;
default :
status = STATUS_FORMAT_ERROR;
}
}
}
/**
* Reads Graphics Control Extension values
*/
protected void readGraphicControlExt() {
read(); // block size
int packed = read(); // packed fields
dispose = (packed & 0x1c) >> 2; // disposal method
if (dispose == 0) {
dispose = 1; // elect to keep old image if discretionary
}
transparency = (packed & 1) != 0;
delay = readShort() * 10; // delay in milliseconds
transIndex = read(); // transparent color index
read(); // block terminator
}
/**
* Reads GIF file header information.
*/
protected void readHeader() {
StringBuilder id = new StringBuilder();
for (int i = 0; i < 6; i++) {
id.append((char) read());
}
if (!id.toString().startsWith("GIF")) {
status = STATUS_FORMAT_ERROR;
return;
}
readLSD();
if (gctFlag && !err()) {
gct = readColorTable(gctSize);
bgColor = gct[bgIndex];
}
}
/**
* Reads next frame image
*/
protected void readImage() {
ix = readShort(); // (sub)image position & size
iy = readShort();
iw = readShort();
ih = readShort();
int packed = read();
lctFlag = (packed & 0x80) != 0; // 1 - local color table flag
interlace = (packed & 0x40) != 0; // 2 - interlace flag
// 3 - sort flag
// 4-5 - reserved
lctSize = 2 << (packed & 7); // 6-8 - local color table size
if (lctFlag) {
lct = readColorTable(lctSize); // read table
act = lct; // make local table active
} else {
act = gct; // make global table active
if (bgIndex == transIndex)
bgColor = 0;
}
int save = 0;
if (transparency) {
save = act[transIndex];
act[transIndex] = 0; // set transparent color if specified
}
if (act == null) {
status = STATUS_FORMAT_ERROR; // no color table defined
}
if (err()) return;
decodeImageData(); // decode pixel data
skip();
if (err()) return;
frameCount++;
// create new image to receive frame data
image =
new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
setPixels(); // transfer pixel data to image
frames.add(new GifFrame(image, delay)); // add image to frame list
if (transparency) {
act[transIndex] = save;
}
resetFrame();
}
/**
* Reads Logical Screen Descriptor
*/
protected void readLSD() {
// logical screen size
width = readShort();
height = readShort();
// packed fields
int packed = read();
gctFlag = (packed & 0x80) != 0; // 1 : global color table flag
// 2-4 : color resolution
// 5 : gct sort flag
gctSize = 2 << (packed & 7); // 6-8 : gct size
bgIndex = read(); // background color index
pixelAspect = read(); // pixel aspect ratio
}
/**
* Reads Netscape extenstion to obtain iteration count
*/
protected void readNetscapeExt() {
do {
readBlock();
if (block[0] == 1) {
// loop count sub-block
int b1 = (block[1]) & 0xff;
int b2 = (block[2]) & 0xff;
loopCount = (b2 << 8) | b1;
}
} while ((blockSize > 0) && !err());
}
/**
* Reads next 16-bit value, LSB first
*/
protected int readShort() {
// read 16-bit value, LSB first
return read() | (read() << 8);
}
/**
* Resets frame state for reading next image.
*/
protected void resetFrame() {
lastDispose = dispose;
lastRect = new Rectangle(ix, iy, iw, ih);
lastImage = image;
lastBgColor = bgColor;
lct = null;
}
/**
* Skips variable length blocks up to and including
* next zero length block.
*/
protected void skip() {
do {
readBlock();
} while ((blockSize > 0) && !err());
}
}

View File

@ -10,6 +10,8 @@ import java.util.Objects;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import fr.pandacube.lib.util.Log;
public class ServerPropertyFile { public class ServerPropertyFile {
private final transient File file; private final transient File file;

23
DB/pom.xml Normal file
View File

@ -0,0 +1,23 @@
<?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>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>pandalib-db</artifactId>
<dependencies>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-util</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -13,13 +13,13 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Consumer; import java.util.function.Consumer;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
/** /**
* Static class to handle most of the database operations. * Static class to handle most of the database operations.
* *
* To use this database library, first call {@link #init(DBConnection, String)} with an appropriate {@link DBConnection}, * To use this database library, first call {@link #init(DBConnection, String)} with an appropriate {@link DBConnection},
* they you can initialize every table you need for your application, using {@link #initTable(Class)}. * then you can initialize every table you need for your application, using {@link #initTable(Class)}.
* *
* @author Marc Baloup * @author Marc Baloup
*/ */

View File

@ -1,11 +1,11 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
public class DBConnection { public class DBConnection {
private static final long CONNECTION_CHECK_TIMEOUT = 30000; // in ms private static final long CONNECTION_CHECK_TIMEOUT = 30000; // in ms
@ -40,7 +40,7 @@ public class DBConnection {
} }
} }
public boolean isConnected() private boolean isConnected()
{ {
try { try {
if (conn.isClosed()) if (conn.isClosed())

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
public class DBException extends Exception { public class DBException extends Exception {

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
public class DBInitTableException extends DBException { public class DBInitTableException extends DBException {

View File

@ -1,8 +1,6 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import java.util.List; import java.util.List;
public record ParameterizedSQLString(String sqlString, List<Object> parameters) { public record ParameterizedSQLString(String sqlString, List<Object> parameters) {
} }

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import java.util.function.Function; import java.util.function.Function;

View File

@ -1,11 +1,4 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.gson.JsonObject;
import fr.pandacube.lib.core.util.EnumUtil;
import fr.pandacube.lib.core.util.Json;
import fr.pandacube.lib.core.util.Log;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.sql.Date; import java.sql.Date;
@ -23,6 +16,10 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
import fr.pandacube.lib.util.EnumUtil;
import fr.pandacube.lib.util.Log;
public abstract class SQLElement<E extends SQLElement<E>> { public abstract class SQLElement<E extends SQLElement<E>> {
/** cache for fields for each subclass of SQLElement */ /** cache for fields for each subclass of SQLElement */
@ -363,16 +360,19 @@ public abstract class SQLElement<E extends SQLElement<E>> {
@Override @Override
public String toString() { public String toString() {
ToStringHelper b = MoreObjects.toStringHelper(this); StringBuilder sb = new StringBuilder(this.getClass().getName());
sb.append('{');
for (SQLField<E, ?> f : fields.values()) sb.append(fields.values().stream()
try { .map(f -> {
b.add(f.getName(), get(f)); try {
} catch (IllegalArgumentException e) { return f.getName() + "=" + get(f);
b.add(f.getName(), "(Undefined)"); } catch (IllegalArgumentException e) {
} return f.getName() + "=(Undefined)";
}
return b.toString(); })
.collect(Collectors.joining(", ")));
sb.append('}');
return sb.toString();
} }
@Override @Override
@ -390,16 +390,6 @@ public abstract class SQLElement<E extends SQLElement<E>> {
public JsonObject asJsonObject() {
JsonObject json = new JsonObject();
for (SQLField<E, ?> f : getFields().values()) {
json.add(f.getName(), Json.gson.toJsonTree(get(f)));
}
return json;
}

View File

@ -1,7 +1,4 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import com.google.gson.JsonArray;
import fr.pandacube.lib.core.util.Log;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -13,6 +10,8 @@ import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import fr.pandacube.lib.util.Log;
/** /**
* *
* @param <E> * @param <E>
@ -185,12 +184,4 @@ public class SQLElementList<E extends SQLElement<E>> extends ArrayList<E> {
public JsonArray asJsonArray() {
JsonArray json = new JsonArray();
forEach(el -> json.add(el.asJsonObject()));
return json;
}
} }

View File

@ -1,6 +1,6 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
/** /**
* *

View File

@ -1,14 +1,14 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import fr.pandacube.lib.core.db.SQLWhere.SQLWhereComp; import fr.pandacube.lib.db.SQLWhere.SQLWhereComp;
import fr.pandacube.lib.core.db.SQLWhere.SQLWhereComp.SQLComparator; import fr.pandacube.lib.db.SQLWhere.SQLWhereComp.SQLComparator;
import fr.pandacube.lib.core.db.SQLWhere.SQLWhereIn; import fr.pandacube.lib.db.SQLWhere.SQLWhereIn;
import fr.pandacube.lib.core.db.SQLWhere.SQLWhereLike; import fr.pandacube.lib.db.SQLWhere.SQLWhereLike;
import fr.pandacube.lib.core.db.SQLWhere.SQLWhereNull; import fr.pandacube.lib.db.SQLWhere.SQLWhereNull;
public class SQLField<E extends SQLElement<E>, T> { public class SQLField<E extends SQLElement<E>, T> {
@ -91,49 +91,49 @@ public class SQLField<E extends SQLElement<E>, T> {
public SQLWhere<E> eq(T r) { public fr.pandacube.lib.db.SQLWhere<E> eq(T r) {
return comp(SQLComparator.EQ, r); return comp(SQLComparator.EQ, r);
} }
public SQLWhere<E> geq(T r) { public fr.pandacube.lib.db.SQLWhere<E> geq(T r) {
return comp(SQLComparator.GEQ, r); return comp(SQLComparator.GEQ, r);
} }
public SQLWhere<E> gt(T r) { public fr.pandacube.lib.db.SQLWhere<E> gt(T r) {
return comp(SQLComparator.GT, r); return comp(SQLComparator.GT, r);
} }
public SQLWhere<E> leq(T r) { public fr.pandacube.lib.db.SQLWhere<E> leq(T r) {
return comp(SQLComparator.LEQ, r); return comp(SQLComparator.LEQ, r);
} }
public SQLWhere<E> lt(T r) { public fr.pandacube.lib.db.SQLWhere<E> lt(T r) {
return comp(SQLComparator.LT, r); return comp(SQLComparator.LT, r);
} }
public SQLWhere<E> neq(T r) { public fr.pandacube.lib.db.SQLWhere<E> neq(T r) {
return comp(SQLComparator.NEQ, r); return comp(SQLComparator.NEQ, r);
} }
private SQLWhere<E> comp(SQLComparator c, T r) { private fr.pandacube.lib.db.SQLWhere<E> comp(SQLComparator c, T r) {
if (r == null) if (r == null)
throw new IllegalArgumentException("The value cannot be null. Use SQLField#isNull(value) or SQLField#isNotNull(value) to check for null values"); throw new IllegalArgumentException("The value cannot be null. Use SQLField#isNull(value) or SQLField#isNotNull(value) to check for null values");
return new SQLWhereComp<>(this, c, r); return new SQLWhereComp<>(this, c, r);
} }
public SQLWhere<E> like(String like) { public fr.pandacube.lib.db.SQLWhere<E> like(String like) {
return new SQLWhereLike<>(this, like); return new SQLWhereLike<>(this, like);
} }
public SQLWhere<E> in(Collection<T> v) { public fr.pandacube.lib.db.SQLWhere<E> in(Collection<T> v) {
return new SQLWhereIn<>(this, v); return new SQLWhereIn<>(this, v);
} }
public SQLWhere<E> isNull() { public fr.pandacube.lib.db.SQLWhere<E> isNull() {
return new SQLWhereNull<>(this, true); return new SQLWhereNull<>(this, true);
} }
public SQLWhere<E> isNotNull() { public fr.pandacube.lib.db.SQLWhere<E> isNotNull() {
return new SQLWhereNull<>(this, false); return new SQLWhereNull<>(this, false);
} }

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
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.core.db; package fr.pandacube.lib.db;
public class SQLType<T> { public class SQLType<T> {

View File

@ -1,11 +1,11 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
public class SQLUpdate<E extends SQLElement<E>> { public class SQLUpdate<E extends SQLElement<E>> {

View File

@ -1,11 +1,10 @@
package fr.pandacube.lib.core.db; package fr.pandacube.lib.db;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
public abstract class SQLWhere<E extends SQLElement<E>> { public abstract class SQLWhere<E extends SQLElement<E>> {
@ -291,10 +290,11 @@ public abstract class SQLWhere<E extends SQLElement<E>> {
* "IS NOT NULL" * "IS NOT NULL"
*/ */
/* package */ SQLWhereNull(SQLField<E, ?> field, boolean isNull) { /* package */ SQLWhereNull(SQLField<E, ?> field, boolean isNull) {
if (field == null) throw new IllegalArgumentException("field can't be null"); if (field == null)
if (!field.canBeNull) Log.getLogger().log(Level.WARNING, throw new IllegalArgumentException("field can't be null");
"Useless : Trying to check IS [NOT] NULL on the field " + field.getSQLElementType().getName() + "#" if (!field.canBeNull)
+ field.getName() + " which is declared in the ORM as 'can't be null'"); Log.warning("Useless : Trying to check IS [NOT] NULL on the field " + field.getSQLElementType().getName()
+ "#" + field.getName() + " which is declared in the ORM as 'can't be null'");
this.field = field; this.field = field;
this.isNull = isNull; this.isNull = isNull;
} }

12
Net/Readme.md Normal file
View File

@ -0,0 +1,12 @@
# pandacube-net
A TCP network library that uses the standard Java socket API, to ease the ommunication between the different processes
running the server network Pandacube.
Its still in development (actually not touched since years), and its supposed to be a replacement for the old
`pandalib-network-api`. This module is then marked as Beta using the Google Guava annotation.
- Packet based communication
- Supports Request/Answer packets
- Uses binary packet id and data
* Input streams are handled in separate Threads

27
Net/pom.xml Normal file
View File

@ -0,0 +1,27 @@
<?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>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>pandalib-net</artifactId>
<dependencies>
<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>
</dependency>
</dependencies>
</project>

View File

@ -1,7 +1,10 @@
package fr.pandacube.lib.core.net; package fr.pandacube.lib.net;
import java.util.Arrays; import java.util.Arrays;
import com.google.common.annotations.Beta;
@Beta
public class Array8Bit { public class Array8Bit {
public static final int BIT_COUNT = Byte.SIZE; public static final int BIT_COUNT = Byte.SIZE;

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.net; package fr.pandacube.lib.net;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -6,6 +6,9 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import com.google.common.annotations.Beta;
@Beta
public final class ByteBuffer implements Cloneable { public final class ByteBuffer implements Cloneable {
public static final Charset NETWORK_CHARSET = StandardCharsets.UTF_8; public static final Charset NETWORK_CHARSET = StandardCharsets.UTF_8;

View File

@ -1,7 +1,10 @@
package fr.pandacube.lib.core.net; package fr.pandacube.lib.net;
import java.util.Arrays; import java.util.Arrays;
import com.google.common.annotations.Beta;
@Beta
public class PPacket { public class PPacket {
public final String name; public final String name;
/* package */ int id; /* package */ int id;

View File

@ -1,7 +1,10 @@
package fr.pandacube.lib.core.net; package fr.pandacube.lib.net;
import java.util.Arrays; import java.util.Arrays;
import com.google.common.annotations.Beta;
@Beta
public class PPacketAnswer extends PPacket { public class PPacketAnswer extends PPacket {
/* package */ final int answer; /* package */ final int answer;

View File

@ -1,5 +1,8 @@
package fr.pandacube.lib.core.net; package fr.pandacube.lib.net;
import com.google.common.annotations.Beta;
@Beta
@FunctionalInterface @FunctionalInterface
public interface PPacketListener<P extends PPacket> { public interface PPacketListener<P extends PPacket> {

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.net; package fr.pandacube.lib.net;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
@ -12,10 +12,11 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import com.google.common.base.MoreObjects; import com.google.common.annotations.Beta;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
@Beta
public class PServer extends Thread implements Closeable { public class PServer extends Thread implements Closeable {
private static final AtomicInteger connectionCounterId = new AtomicInteger(0); private static final AtomicInteger connectionCounterId = new AtomicInteger(0);
@ -92,7 +93,7 @@ public class PServer extends Thread implements Closeable {
boolean loggedIn; boolean loggedIn;
private TCPServerClientConnection(Socket s, int coId) { private TCPServerClientConnection(Socket s, int coId) {
super(s, "Conn#" + coId + " via TCPSv " + socketName, password); super(s, "Conn#" + coId + " via PServer " + socketName, password);
addConnectionListener(new PSocketConnectionListener() { addConnectionListener(new PSocketConnectionListener() {
@Override @Override
public void onDisconnect(PSocket connection) { public void onDisconnect(PSocket connection) {
@ -150,10 +151,7 @@ public class PServer extends Thread implements Closeable {
@Override @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(this) return this.getClass().getName() + "{thread=" + getName() + ", socket=" + socket + "}";
.add("thread", getName())
.add("socket", socket)
.toString();
} }
} }

View File

@ -1,4 +1,4 @@
package fr.pandacube.lib.core.net; package fr.pandacube.lib.net;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.Closeable; import java.io.Closeable;
@ -13,12 +13,12 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import com.google.common.base.MoreObjects; import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
/** /**
* A wrapper for a {@link Socket}. The connection must point to a software using {@link PServer} * A wrapper for a {@link Socket}. The connection must point to a software using {@link PServer}
@ -27,11 +27,12 @@ import fr.pandacube.lib.core.util.Log;
* This class provides a simple way to exchange data between client and server : * This class provides a simple way to exchange data between client and server :
* <li>Maintained connection with the server</li> * <li>Maintained connection with the server</li>
* <li>Login with a password (send in the first packet)</li> * <li>Login with a password (send in the first packet)</li>
* <li>Named packets</li> * <li>Binary packet id</li>
* <li>Binary data</li> * <li>Binary data</li>
* <li>Input stream in a separate Thread</li> * <li>Input stream in a separate Thread</li>
* *
*/ */
@Beta
public class PSocket extends Thread implements Closeable { public class PSocket extends Thread implements Closeable {
public static final int NETWORK_TCP_BUFFER_SIZE = 1024 * 1024; public static final int NETWORK_TCP_BUFFER_SIZE = 1024 * 1024;
@ -103,7 +104,7 @@ public class PSocket extends Thread implements Closeable {
} }
try { try {
String receivedPassword = new ByteBuffer(packet.content).getString(); String receivedPassword = new ByteBuffer(packet.content).getString();
if (!Objects.equal(receivedPassword, password)) { if (!Objects.equals(receivedPassword, password)) {
send(PPacket.buildLoginBadPacket()); send(PPacket.buildLoginBadPacket());
close(); close();
return; return;
@ -341,10 +342,7 @@ public class PSocket extends Thread implements Closeable {
@Override @Override
public String toString() { public String toString() {
return MoreObjects.toStringHelper(this) return this.getClass().getName() + "{thread=" + getName() + ", socket=" + socket + "}";
.add("thread", getName())
.add("socket", socket.getRemoteSocketAddress())
.toString();
} }
} }

View File

@ -1,5 +1,8 @@
package fr.pandacube.lib.core.net; package fr.pandacube.lib.net;
import com.google.common.annotations.Beta;
@Beta
public interface PSocketConnectionListener { public interface PSocketConnectionListener {
/** /**

22
NetworkAPI/pom.xml Normal file
View File

@ -0,0 +1,22 @@
<?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>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>pandalib-network-api</artifactId>
<dependencies>
<dependency>
<groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-util</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1,8 +1,7 @@
package fr.pandacube.lib.core.network_api.client; package fr.pandacube.lib.netapi.client;
import java.io.PrintStream; import java.io.PrintStream;
@Deprecated
public abstract class AbstractRequest { public abstract class AbstractRequest {
private final String pass; private final String pass;

View File

@ -1,11 +1,10 @@
package fr.pandacube.lib.core.network_api.client; package fr.pandacube.lib.netapi.client;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
@Deprecated
public class NetworkAPISender { public class NetworkAPISender {
public static ResponseAnalyser sendRequest(InetSocketAddress cible, AbstractRequest request) throws IOException { public static ResponseAnalyser sendRequest(InetSocketAddress cible, AbstractRequest request) throws IOException {

View File

@ -1,11 +1,10 @@
package fr.pandacube.lib.core.network_api.client; package fr.pandacube.lib.netapi.client;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.Socket; import java.net.Socket;
@Deprecated
public class ResponseAnalyser { public class ResponseAnalyser {
/** /**
* Indique si la requête s'est bien exécutée (l'entête de la réponse est * Indique si la requête s'est bien exécutée (l'entête de la réponse est

View File

@ -1,13 +1,12 @@
package fr.pandacube.lib.core.network_api.server; package fr.pandacube.lib.netapi.server;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
@Deprecated
public abstract class AbstractRequestExecutor { public abstract class AbstractRequestExecutor {
public final String command; public final String command;

View File

@ -1,13 +1,12 @@
package fr.pandacube.lib.core.network_api.server; package fr.pandacube.lib.netapi.server;
import java.io.IOException; import java.io.IOException;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
@Deprecated
public class NetworkAPIListener implements Runnable { public class NetworkAPIListener implements Runnable {
private final int port; private final int port;

View File

@ -1,11 +1,11 @@
package fr.pandacube.lib.core.network_api.server; package fr.pandacube.lib.netapi.server;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.Socket; import java.net.Socket;
import fr.pandacube.lib.core.network_api.server.RequestAnalyser.BadRequestException; import fr.pandacube.lib.netapi.server.RequestAnalyser.BadRequestException;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
/** /**
* Prends en charge un socket client et le transmet au gestionnaire de paquet * Prends en charge un socket client et le transmet au gestionnaire de paquet
@ -16,7 +16,6 @@ import fr.pandacube.lib.core.util.Log;
* @author Marc Baloup * @author Marc Baloup
* *
*/ */
@Deprecated
public class PacketExecutor implements Runnable { public class PacketExecutor implements Runnable {
private final Socket socket; private final Socket socket;
private final NetworkAPIListener networkAPIListener; private final NetworkAPIListener networkAPIListener;

View File

@ -1,11 +1,10 @@
package fr.pandacube.lib.core.network_api.server; package fr.pandacube.lib.netapi.server;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.Socket; import java.net.Socket;
@Deprecated
public class RequestAnalyser { public class RequestAnalyser {
public final String command; public final String command;

View File

@ -1,8 +1,7 @@
package fr.pandacube.lib.core.network_api.server; package fr.pandacube.lib.netapi.server;
import java.io.PrintStream; import java.io.PrintStream;
@Deprecated
public class Response { public class Response {
public boolean good = true; public boolean good = true;
public String data = ""; public String data = "";

View File

@ -8,8 +8,7 @@
</parent> </parent>
<artifactId>pandalib-paper</artifactId> <artifactId>pandalib-paper</artifactId>
<packaging>jar</packaging>
<name>PandaLib-Paper</name>
<repositories> <repositories>
<repository> <repository>
@ -27,7 +26,6 @@
<groupId>fr.pandacube.lib</groupId> <groupId>fr.pandacube.lib</groupId>
<artifactId>pandalib-core</artifactId> <artifactId>pandalib-core</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>net.kyori</groupId> <groupId>net.kyori</groupId>
@ -45,13 +43,11 @@
<groupId>io.papermc.paper</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId> <artifactId>paper-api</artifactId>
<version>${paper.version}-SNAPSHOT</version> <version>${paper.version}-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.papermc.paper</groupId> <groupId>io.papermc.paper</groupId>
<artifactId>paper-mojangapi</artifactId> <artifactId>paper-mojangapi</artifactId>
<version>${paper.version}-SNAPSHOT</version> <version>${paper.version}-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
<!-- Needed to read obfuscation mapping file. Already included in Paper --> <!-- Needed to read obfuscation mapping file. Already included in Paper -->

View File

@ -20,7 +20,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.PlayerInventory;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import fr.pandacube.lib.paper.util.BukkitEvent; import fr.pandacube.lib.paper.util.BukkitEvent;
/** /**

View File

@ -21,9 +21,9 @@ import org.bukkit.plugin.Plugin;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import fr.pandacube.lib.core.chat.Chat; import fr.pandacube.lib.chat.Chat;
import fr.pandacube.lib.core.players.IPlayerManager; import fr.pandacube.lib.core.players.IPlayerManager;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import fr.pandacube.lib.paper.util.ItemStackBuilder; import fr.pandacube.lib.paper.util.ItemStackBuilder;
public class GUIInventory implements Listener { public class GUIInventory implements Listener {

View File

@ -19,12 +19,12 @@ import java.util.stream.Collectors;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.core.util.Reflect.ReflectClass; import fr.pandacube.lib.reflect.Reflect.ReflectClass;
import fr.pandacube.lib.core.util.Reflect.ReflectField; import fr.pandacube.lib.reflect.Reflect.ReflectField;
import fr.pandacube.lib.core.util.Reflect.ReflectMember; import fr.pandacube.lib.reflect.Reflect.ReflectMember;
import fr.pandacube.lib.core.util.Reflect.ReflectMethod; import fr.pandacube.lib.reflect.Reflect.ReflectMethod;
import net.fabricmc.mappingio.MappingReader; import net.fabricmc.mappingio.MappingReader;
import net.fabricmc.mappingio.format.MappingFormat; import net.fabricmc.mappingio.format.MappingFormat;
import net.fabricmc.mappingio.tree.MappingTree; import net.fabricmc.mappingio.tree.MappingTree;

View File

@ -2,8 +2,8 @@ package fr.pandacube.lib.paper.reflect;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.core.util.Reflect.ReflectClass; import fr.pandacube.lib.reflect.Reflect.ReflectClass;
public class OBCReflect { public class OBCReflect {

View File

@ -6,7 +6,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import fr.pandacube.lib.core.util.Reflect.ReflectClass; import fr.pandacube.lib.reflect.Reflect.ReflectClass;
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
public class Type implements Comparable<Type> { public class Type implements Comparable<Type> {

View File

@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
import fr.pandacube.lib.core.util.MappedListView; import fr.pandacube.lib.util.MappedListView;
public class ReflectListWrapper<W extends ReflectWrapperI> extends MappedListView<Object, W> implements ReflectWrapperTypedI<List<Object>> { public class ReflectListWrapper<W extends ReflectWrapperI> extends MappedListView<Object, W> implements ReflectWrapperTypedI<List<Object>> {

View File

@ -1,13 +1,13 @@
package fr.pandacube.lib.paper.reflect.wrapper; package fr.pandacube.lib.paper.reflect.wrapper;
import com.google.common.collect.MapMaker; import com.google.common.collect.MapMaker;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
public abstract class ReflectWrapper implements ReflectWrapperI { public abstract class ReflectWrapper implements ReflectWrapperI {

View File

@ -1,8 +1,8 @@
package fr.pandacube.lib.paper.reflect.wrapper; package fr.pandacube.lib.paper.reflect.wrapper;
import fr.pandacube.lib.core.util.Log; import fr.pandacube.lib.util.Log;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.core.util.Reflect.ReflectConstructor; import fr.pandacube.lib.reflect.Reflect.ReflectConstructor;
import fr.pandacube.lib.paper.reflect.wrapper.brigadier.CommandNode; 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.CraftMapView;
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftNamespacedKey; import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftNamespacedKey;

View File

@ -1,10 +1,10 @@
package fr.pandacube.lib.paper.reflect.wrapper.brigadier; package fr.pandacube.lib.paper.reflect.wrapper.brigadier;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped; import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class CommandNode<S> extends ReflectWrapperTyped<com.mojang.brigadier.tree.CommandNode<S>> { public class CommandNode<S> extends ReflectWrapperTyped<com.mojang.brigadier.tree.CommandNode<S>> {
public static final Reflect.ReflectClass<?> REFLECT = Reflect.ofClass(com.mojang.brigadier.tree.CommandNode.class); public static final Reflect.ReflectClass<?> REFLECT = Reflect.ofClass(com.mojang.brigadier.tree.CommandNode.class);

View File

@ -1,14 +1,14 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.map.MapView; import org.bukkit.map.MapView;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class CraftMapView extends ReflectWrapperTyped<MapView> { public class CraftMapView extends ReflectWrapperTyped<MapView> {
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("map.CraftMapView")); public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("map.CraftMapView"));

View File

@ -1,13 +1,13 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class CraftNamespacedKey extends ReflectWrapper { public class CraftNamespacedKey extends ReflectWrapper {
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftNamespacedKey")); public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftNamespacedKey"));

View File

@ -1,13 +1,13 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class CraftPlayer extends ReflectWrapperTyped<Player> { public class CraftPlayer extends ReflectWrapperTyped<Player> {
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("entity.CraftPlayer")); public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("entity.CraftPlayer"));

View File

@ -1,14 +1,14 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.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 org.bukkit.Server; import org.bukkit.Server;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class CraftServer extends ReflectWrapperTyped<Server> { public class CraftServer extends ReflectWrapperTyped<Server> {
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("CraftServer")); public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("CraftServer"));

View File

@ -1,14 +1,14 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.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 org.bukkit.util.Vector; import org.bukkit.util.Vector;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class CraftVector extends ReflectWrapper { public class CraftVector extends ReflectWrapper {
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftVector")); public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftVector"));

View File

@ -1,13 +1,13 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerLevel; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerLevel;
import org.bukkit.World; import org.bukkit.World;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class CraftWorld extends ReflectWrapperTyped<World> { public class CraftWorld extends ReflectWrapperTyped<World> {
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("CraftWorld")); public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("CraftWorld"));

View File

@ -1,11 +1,11 @@
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit; package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class RenderData extends ReflectWrapper { public class RenderData extends ReflectWrapper {
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("map.RenderData")); public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("map.RenderData"));

View File

@ -2,15 +2,15 @@ package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource; import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.CommandNode;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands; import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.command.defaults.BukkitCommand;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class VanillaCommandWrapper extends ReflectWrapperTyped<BukkitCommand> { public class VanillaCommandWrapper extends ReflectWrapperTyped<BukkitCommand> {
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("command.VanillaCommandWrapper")); public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("command.VanillaCommandWrapper"));

View File

@ -3,7 +3,7 @@ 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.paper.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
public class DetectedVersion extends ReflectWrapper implements WorldVersion { public class DetectedVersion extends ReflectWrapper implements WorldVersion {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.DetectedVersion")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.DetectedVersion"));

View File

@ -1,11 +1,11 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft; package fr.pandacube.lib.paper.reflect.wrapper.minecraft;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class SharedConstants extends ReflectWrapper { public class SharedConstants extends ReflectWrapper {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.SharedConstants")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.SharedConstants"));

View File

@ -6,7 +6,7 @@ import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI; import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
@ConcreteWrapper(WorldVersion.__concrete.class) @ConcreteWrapper(WorldVersion.__concrete.class)
public interface WorldVersion extends ReflectWrapperI { public interface WorldVersion extends ReflectWrapperI {

View File

@ -1,12 +1,12 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; 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.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class BlockPosArgument extends ReflectWrapperTyped<ArgumentType<?>> { public class BlockPosArgument extends ReflectWrapperTyped<ArgumentType<?>> {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.BlockPosArgument")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.BlockPosArgument"));

View File

@ -4,7 +4,7 @@ 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.paper.reflect.wrapper.ReflectWrapperTyped;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
public class CommandSourceStack extends ReflectWrapperTyped<BukkitBrigadierCommandSource> { public class CommandSourceStack extends ReflectWrapperTyped<BukkitBrigadierCommandSource> {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.CommandSourceStack")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.CommandSourceStack"));

View File

@ -2,12 +2,12 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource; import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class Commands extends ReflectWrapper { public class Commands extends ReflectWrapper {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.Commands")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.Commands"));

View File

@ -1,12 +1,12 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; 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.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class ComponentArgument extends ReflectWrapperTyped<ArgumentType<?>> { public class ComponentArgument extends ReflectWrapperTyped<ArgumentType<?>> {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ComponentArgument")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ComponentArgument"));

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; 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.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ConcreteWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
@ -9,8 +9,8 @@ import fr.pandacube.lib.paper.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 static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.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.paper.reflect.wrapper.ReflectWrapper.wrap;
@ConcreteWrapper(Coordinates.__concrete.class) @ConcreteWrapper(Coordinates.__concrete.class)

View File

@ -1,12 +1,12 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; 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.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class EntityArgument extends ReflectWrapperTyped<ArgumentType<?>> { public class EntityArgument extends ReflectWrapperTyped<ArgumentType<?>> {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.EntityArgument")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.EntityArgument"));

View File

@ -1,7 +1,7 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; 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.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectListWrapper;
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper; import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
@ -10,8 +10,8 @@ import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity;
import java.util.List; import java.util.List;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class EntitySelector extends ReflectWrapper { public class EntitySelector extends ReflectWrapper {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.selector.EntitySelector")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.selector.EntitySelector"));

View File

@ -1,12 +1,12 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; 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.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class GameProfileArgument extends ReflectWrapperTyped<ArgumentType<?>> { public class GameProfileArgument extends ReflectWrapperTyped<ArgumentType<?>> {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.GameProfileArgument")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.GameProfileArgument"));

View File

@ -1,12 +1,12 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; 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.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class ResourceLocationArgument extends ReflectWrapperTyped<ArgumentType<?>> { public class ResourceLocationArgument extends ReflectWrapperTyped<ArgumentType<?>> {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ResourceLocationArgument")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ResourceLocationArgument"));

View File

@ -1,12 +1,12 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands; 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.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapperTyped;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class Vec3Argument extends ReflectWrapperTyped<ArgumentType<?>> { public class Vec3Argument extends ReflectWrapperTyped<ArgumentType<?>> {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Vec3Argument")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Vec3Argument"));

View File

@ -2,7 +2,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core;
import fr.pandacube.lib.paper.reflect.NMSReflect; import fr.pandacube.lib.paper.reflect.NMSReflect;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
public class BlockPos extends Vec3i { public class BlockPos extends Vec3i {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.core.BlockPos")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.core.BlockPos"));

View File

@ -1,11 +1,11 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core;
import fr.pandacube.lib.core.util.Reflect; import fr.pandacube.lib.reflect.Reflect;
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.paper.reflect.wrapper.ReflectWrapper;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
public class Vec3i extends ReflectWrapper { public class Vec3i extends ReflectWrapper {
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.core.Vec3i")); public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.core.Vec3i"));

View File

@ -1,14 +1,14 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import fr.pandacube.lib.core.util.Reflect.ReflectMethod; import fr.pandacube.lib.reflect.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.paper.reflect.wrapper.ReflectWrapper;

View File

@ -1,10 +1,10 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import java.io.File; import java.io.File;
import fr.pandacube.lib.core.util.Reflect.ReflectMethod; import fr.pandacube.lib.reflect.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.paper.reflect.wrapper.ReflectWrapper;

View File

@ -1,6 +1,6 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; 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;

View File

@ -1,9 +1,9 @@
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt; package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
import static fr.pandacube.lib.core.util.ThrowableUtil.wrapReflectEx; import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
import fr.pandacube.lib.core.util.Reflect.ReflectMethod; import fr.pandacube.lib.reflect.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.paper.reflect.wrapper.ConcreteWrapper;

Some files were not shown because too many files have changed in this diff Show More