diff --git a/jitpack.yml b/jitpack.yml index 1e41e00..3ed1cdb 100644 --- a/jitpack.yml +++ b/jitpack.yml @@ -1,2 +1,5 @@ jdk: - - openjdk17 \ No newline at end of file + - openjdk17 +before_install: + - sdk install java 17.0.2-open + - sdk use java 17.0.2-open \ No newline at end of file diff --git a/pandalib-bungee-permissions/pom.xml b/pandalib-bungee-permissions/pom.xml index 577f359..760ef06 100644 --- a/pandalib-bungee-permissions/pom.xml +++ b/pandalib-bungee-permissions/pom.xml @@ -25,7 +25,6 @@ fr.pandacube.lib pandalib-players-permissible ${project.version} - provided fr.pandacube.lib diff --git a/pandalib-bungee-players/src/main/java/fr/pandacube/lib/bungee/players/BungeeOnlinePlayer.java b/pandalib-bungee-players/src/main/java/fr/pandacube/lib/bungee/players/BungeeOnlinePlayer.java index c5d8036..470b8a7 100644 --- a/pandalib-bungee-players/src/main/java/fr/pandacube/lib/bungee/players/BungeeOnlinePlayer.java +++ b/pandalib-bungee-players/src/main/java/fr/pandacube/lib/bungee/players/BungeeOnlinePlayer.java @@ -121,7 +121,7 @@ public interface BungeeOnlinePlayer extends BungeeOffPlayer, StandaloneOnlinePla class BungeeClientOptions implements StandaloneOnlinePlayer.ClientOptions { - BungeeOnlinePlayer op; + private final BungeeOnlinePlayer op; public BungeeClientOptions(BungeeOnlinePlayer op) { this.op = op; } diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/commands/SuggestionsSupplier.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/commands/SuggestionsSupplier.java index 62d2c45..8feaa47 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/commands/SuggestionsSupplier.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/commands/SuggestionsSupplier.java @@ -189,7 +189,7 @@ public interface SuggestionsSupplier { - public static SuggestionsSupplier suggestDuration() { + static SuggestionsSupplier suggestDuration() { final List emptyTokenSuggestions = TimeUtil.DURATION_SUFFIXES.stream().map(p -> "1" + p).collect(Collectors.toList()); return (s, ti, token, args) -> { if (token.isEmpty()) { diff --git a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElementList.java b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElementList.java index b2b0ee1..46c4b3a 100644 --- a/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElementList.java +++ b/pandalib-db/src/main/java/fr/pandacube/lib/db/SQLElementList.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.function.Function; import java.util.stream.Collectors; import fr.pandacube.lib.util.Log; @@ -144,10 +145,12 @@ public class SQLElementList> extends ArrayList { public > Map getReferencedEntriesInGroups(SQLFKField foreignKey) throws DBException { SQLElementList

foreignElemts = getReferencedEntries(foreignKey, null); - - Map ret = new HashMap<>(); - foreignElemts.forEach(foreignVal -> ret.put(foreignVal.get(foreignKey.getPrimaryField()), foreignVal)); - return ret; + + return foreignElemts.stream() + .collect(Collectors.toMap( + foreignVal -> foreignVal.get(foreignKey.getPrimaryField()), + Function.identity(), (a, b) -> b) + ); } diff --git a/pandalib-net/src/main/java/fr/pandacube/lib/net/ByteBuffer.java b/pandalib-net/src/main/java/fr/pandacube/lib/net/ByteBuffer.java index 84864af..7373325 100644 --- a/pandalib-net/src/main/java/fr/pandacube/lib/net/ByteBuffer.java +++ b/pandalib-net/src/main/java/fr/pandacube/lib/net/ByteBuffer.java @@ -45,6 +45,7 @@ public final class ByteBuffer implements Cloneable { /** * This clone method also clone the underlying array. */ + @SuppressWarnings("MethodDoesntCallSuperMethod") @Override public ByteBuffer clone() { return new ByteBuffer(Arrays.copyOf(buff.array(), buff.array().length)); diff --git a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PandalibPaperPermissions.java b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PandalibPaperPermissions.java index b45cfd7..0f74512 100644 --- a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PandalibPaperPermissions.java +++ b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PandalibPaperPermissions.java @@ -7,7 +7,6 @@ import java.util.Objects; import java.util.concurrent.ExecutionException; import java.util.function.Function; import java.util.function.Predicate; -import java.util.stream.Collectors; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -77,11 +76,11 @@ public class PandalibPaperPermissions implements Listener { - /* package */ static Function> SUPERPERMS_PARENT_PERMISSION_GETTER = childPerm -> { - return Bukkit.getPluginManager().getPermissions().stream() - .filter(p -> p.getChildren().containsKey(childPerm)) - .collect(Collectors.toList()); - }; + /* package */ static final Function> SUPERPERMS_PARENT_PERMISSION_GETTER = childPerm -> Bukkit.getPluginManager() + .getPermissions() + .stream() + .filter(p -> p.getChildren().containsKey(childPerm)) + .toList(); /* package */ static ServerOperator dummyOperator(boolean isOp) { return new ServerOperator() { diff --git a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorBukkit.java b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorBukkit.java index 754fe9b..045539a 100644 --- a/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorBukkit.java +++ b/pandalib-paper-permissions/src/main/java/fr/pandacube/lib/paper/permissions/PermissionsInjectorBukkit.java @@ -113,10 +113,14 @@ public class PermissionsInjectorBukkit private final CommandSender sender; private final Permissible oldPermissible; - /* package */ LoadingCache> superPermsPermissionCache = CacheBuilder.newBuilder() + /* package */ final LoadingCache> superPermsPermissionCache = CacheBuilder.newBuilder() .build(CacheLoader.from(PandalibPaperPermissions.SUPERPERMS_PARENT_PERMISSION_GETTER::apply)); - + + @SuppressWarnings("UnusedAssignment") private boolean init = false; + /* assigment to false is necessary because of super class constructor calling the method recalculatePermission() + * and we don’t want that. + */ private PandaPermissible(CommandSender sender, Permissible oldPermissible) { @@ -175,7 +179,7 @@ public class PermissionsInjectorBukkit res = PandalibPaperPermissions.hasSuperPermsPermission(sender, permission.getName(), this::hasPermission, this); // supports negative permission if (res != null) return res; - + return oldPermissible.hasPermission(permission); // doesn’t need to manage negative permission (should not happend) } diff --git a/pandalib-paper-players/src/main/java/fr/pandacub/lib/paper/players/PaperOffPlayer.java b/pandalib-paper-players/src/main/java/fr/pandacub/lib/paper/players/PaperOffPlayer.java index 464a35d..4689b66 100644 --- a/pandalib-paper-players/src/main/java/fr/pandacub/lib/paper/players/PaperOffPlayer.java +++ b/pandalib-paper-players/src/main/java/fr/pandacub/lib/paper/players/PaperOffPlayer.java @@ -64,6 +64,7 @@ public interface PaperOffPlayer extends StandaloneOffPlayer { default String getDisplayName() { String name = getName(); Player p = getBukkitPlayer(); + @SuppressWarnings("deprecation") String bukkitDispName = p != null ? p.getDisplayName() : name; if (!name.equals(bukkitDispName)) return bukkitDispName; @@ -80,8 +81,11 @@ public interface PaperOffPlayer extends StandaloneOffPlayer { Team team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(name); if (team == null) return null; + @SuppressWarnings("deprecation") String teamPrefix = team.getPrefix(); + @SuppressWarnings("deprecation") String teamSuffix = team.getSuffix(); + @SuppressWarnings("deprecation") String teamColor = team.getColor().toString(); return teamPrefix + teamColor + name + teamSuffix; diff --git a/pandalib-paper-players/src/main/java/fr/pandacub/lib/paper/players/PaperOnlinePlayer.java b/pandalib-paper-players/src/main/java/fr/pandacub/lib/paper/players/PaperOnlinePlayer.java index bf3392e..5ffa0d9 100644 --- a/pandalib-paper-players/src/main/java/fr/pandacub/lib/paper/players/PaperOnlinePlayer.java +++ b/pandalib-paper-players/src/main/java/fr/pandacub/lib/paper/players/PaperOnlinePlayer.java @@ -104,7 +104,7 @@ public interface PaperOnlinePlayer extends PaperOffPlayer, StandaloneOnlinePlaye @Override PaperClientOptions getClientOptions(); - public abstract class PaperClientOptions implements StandaloneOnlinePlayer.ClientOptions { + abstract class PaperClientOptions implements StandaloneOnlinePlayer.ClientOptions { private final PaperOnlinePlayer op; diff --git a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java index ce806b2..cbca1ed 100644 --- a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java +++ b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSReflect.java @@ -404,8 +404,8 @@ public class NMSReflect { private void printHTML(PrintStream out) { String modifiersHTML = classModifiersToHTML(runtimeClass()); out.println("" + modifiersHTML + "" + nameToHTML(true) + "" + nameToHTML(false) + ""); - fieldsByObf.values().stream().filter(mm -> mm.isStatic()).forEach(f -> f.printHTML(out)); - methodsByObf.values().stream().filter(mm -> mm.isStatic()).forEach(m -> m.printHTML(out)); + fieldsByObf.values().stream().filter(MemberMapping::isStatic).forEach(f -> f.printHTML(out)); + methodsByObf.values().stream().filter(MemberMapping::isStatic).forEach(m -> m.printHTML(out)); printConstructorsHTML(out); fieldsByObf.values().stream().filter(mm -> !mm.isStatic()).forEach(f -> f.printHTML(out)); methodsByObf.values().stream().filter(mm -> !mm.isStatic()).forEach(m -> m.printHTML(out)); diff --git a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSTypeWrapper.java b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSTypeWrapper.java index 15dce73..dedf0ae 100644 --- a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSTypeWrapper.java +++ b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/NMSTypeWrapper.java @@ -54,10 +54,6 @@ import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping; return cl; } - public NMSTypeWrapper arrayType() { - return new NMSTypeWrapper(type, arrayDepth + 1); - } - /* package */ static NMSTypeWrapper of(Class cl) { int arrayDepth = 0; while (cl.isArray()) { diff --git a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java index 5b82c8e..f63a6c8 100644 --- a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java +++ b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/nbt/CompoundTag.java @@ -65,6 +65,9 @@ public class CompoundTag extends ReflectWrapper implements Tag { public void putByteArray(String key, byte[] value) { wrapReflectEx(() -> putByteArray.invoke(__getRuntimeInstance(), key, value)); } + public void putByteArray(String key, List value) { + wrapReflectEx(() -> putByteArray_List.invoke(__getRuntimeInstance(), key, value)); + } public void putDouble(String key, double value) { wrapReflectEx(() -> putDouble.invoke(__getRuntimeInstance(), key, value)); } @@ -77,6 +80,9 @@ public class CompoundTag extends ReflectWrapper implements Tag { public void putIntArray(String key, int[] value) { wrapReflectEx(() -> putIntArray.invoke(__getRuntimeInstance(), key, value)); } + public void putIntArray(String key, List value) { + wrapReflectEx(() -> putIntArray_List.invoke(__getRuntimeInstance(), key, value)); + } public void putString(String key, String value) { wrapReflectEx(() -> putString.invoke(__getRuntimeInstance(), key, value)); } @@ -89,6 +95,9 @@ public class CompoundTag extends ReflectWrapper implements Tag { public void putLongArray(String key, long[] value) { wrapReflectEx(() -> putLongArray.invoke(__getRuntimeInstance(), key, value)); } + public void putLongArray(String key, List value) { + wrapReflectEx(() -> putLongArray_List.invoke(__getRuntimeInstance(), key, value)); + } public void putShort(String key, short value) { wrapReflectEx(() -> putShort.invoke(__getRuntimeInstance(), key, value)); } diff --git a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkStorage.java b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkStorage.java index ce95ca2..b3db311 100644 --- a/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkStorage.java +++ b/pandalib-paper-reflect/src/main/java/fr/pandacube/lib/paper/reflect/wrapper/minecraft/world/ChunkStorage.java @@ -13,7 +13,6 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx; public class ChunkStorage extends ReflectWrapper { public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.chunk.storage.ChunkStorage")); - private static final Reflect.ReflectMethod read = wrapEx(() -> MAPPING.mojMethod("read", ChunkPos.MAPPING)); private static final Reflect.ReflectMethod readSync = wrapEx(() -> MAPPING.runtimeReflect().method("readSync", ChunkPos.MAPPING.runtimeReflect().get())); // spigot/paper method public CompoundTag readSync(ChunkPos pos) { diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java index 8ac8ac2..5b22668 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java @@ -46,7 +46,7 @@ public class ScoreboardUtil { obj.displayName(title); } // fix display slot if someone else changed it - if (DisplaySlot.SIDEBAR != obj.getDisplaySlot()) { + if (obj.getDisplaySlot() != DisplaySlot.SIDEBAR) { obj.setDisplaySlot(DisplaySlot.SIDEBAR); } } diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionExpressionParser.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionExpressionParser.java index 0608bba..e60553a 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionExpressionParser.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionExpressionParser.java @@ -90,7 +90,7 @@ public class PermissionExpressionParser { } - /* + /* TODO move to test code public static void main(String[] args) { java.util.List pList = java.util.Arrays.asList("p1.cmd", "p1.toto", "p2.lol"); LitteralPermissionTester tester = p -> pList.contains(p); diff --git a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsResolver.java b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsResolver.java index 3d74bae..78b6204 100644 --- a/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsResolver.java +++ b/pandalib-permissions/src/main/java/fr/pandacube/lib/permissions/PermissionsResolver.java @@ -196,7 +196,7 @@ public class PermissionsResolver { public boolean equals(Object obj) { return obj instanceof DataCacheKey o && Objects.equals(name, o.name) - && Objects.equals(type, o.type) + && type == o.type && dataType == o.dataType; } } @@ -538,8 +538,8 @@ public class PermissionsResolver { @Override public boolean equals(Object obj) { return obj instanceof PermCacheKey o + && type == o.type && Objects.equals(name, o.name) - && Objects.equals(type, o.type) && Objects.equals(permission, o.permission) && Objects.equals(server, o.server) && Objects.equals(world, o.world); diff --git a/pandalib-players-standalone/src/main/java/fr/pandacube/lib/players/standalone/StandaloneOnlinePlayer.java b/pandalib-players-standalone/src/main/java/fr/pandacube/lib/players/standalone/StandaloneOnlinePlayer.java index 0e55428..51e1b39 100644 --- a/pandalib-players-standalone/src/main/java/fr/pandacube/lib/players/standalone/StandaloneOnlinePlayer.java +++ b/pandalib-players-standalone/src/main/java/fr/pandacube/lib/players/standalone/StandaloneOnlinePlayer.java @@ -8,7 +8,6 @@ import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; -import fr.pandacube.lib.chat.Chat; import fr.pandacube.lib.chat.ChatStatic; public interface StandaloneOnlinePlayer extends StandaloneOffPlayer {