From 146406219cc24e09a02af17384d9b1bf48432e23 Mon Sep 17 00:00:00 2001 From: sun-mc-dev Date: Fri, 10 Apr 2026 23:52:14 +0530 Subject: [PATCH 001/260] v1.10.3 - added support for 1.21.11, 26.1.1 and folia - fixed sendTitle on 1.17+ (was still hitting the old EnumTitleAction path) - fixed hidePlayer calls, setGameRuleValue and AsyncChatEvent for paper 26.x - runTaskForEntity now checks for null instead of boolean (folia api returns ScheduledTask) - lookAtPlayer no longer does cross-region world access on folia - folia-supported flag added to plugin.yml - paper-api added as provided dependency - reformed code --- CODEOWNERS | 1 + README.md | 101 +- pom.xml | 283 +-- src/com/falchus/lib/enums/EventPriority.java | 12 +- src/com/falchus/lib/events/Cancellable.java | 6 +- src/com/falchus/lib/events/Event.java | 29 +- src/com/falchus/lib/events/EventExecutor.java | 2 +- src/com/falchus/lib/events/EventHandler.java | 12 +- .../falchus/lib/events/listener/Listener.java | 3 +- .../events/listener/RegisteredListener.java | 33 +- src/com/falchus/lib/interfaces/Mapper.java | 2 +- .../lib/interfaces/consumer/TriConsumer.java | 6 +- src/com/falchus/lib/manager/EventManager.java | 151 +- .../lib/minecraft/FalchusLibMinecraft.java | 65 +- .../lib/minecraft/command/BaseCommand.java | 10 +- .../command/impl/SpigotCommandAdapter.java | 10 +- .../command/impl/VelocityCommandAdapter.java | 14 +- .../falchus/lib/minecraft/enums/Software.java | 7 +- .../spigot/FalchusLibMinecraftSpigot.java | 75 +- .../lib/minecraft/spigot/enums/Biome.java | 6 +- .../lib/minecraft/spigot/enums/Client.java | 6 +- .../lib/minecraft/spigot/enums/GameRule.java | 34 +- .../lib/minecraft/spigot/enums/Material.java | 96 +- .../lib/minecraft/spigot/enums/Sound.java | 32 +- .../lib/minecraft/spigot/enums/Version.java | 60 +- .../spigot/events/LobbyCancelEvent.java | 26 +- .../events/player/PlayerClientJoinEvent.java | 27 +- .../events/player/PlayerPacketEvent.java | 41 +- .../events/player/PlayerPacketInEvent.java | 12 +- .../events/player/PlayerPacketOutEvent.java | 12 +- .../listeners/EntityPlayerListener.java | 6 +- .../spigot/listeners/FreezeListener.java | 48 +- .../spigot/listeners/ItemListener.java | 10 +- .../spigot/listeners/JoinQuitListener.java | 126 +- .../spigot/listeners/LobbyCancelListener.java | 56 +- .../message/LabyModMessageListener.java | 8 +- .../message/LunarMessageListener.java | 18 +- .../spigot/manager/ClientManager.java | 23 +- .../spigot/packets/PacketChannelHandler.java | 8 +- .../spigot/packets/PacketInjector.java | 102 +- .../spigot/packets/wrapper/PacketWrapper.java | 142 +- .../abilities/PacketAbilitiesWrapper.java | 45 +- .../abilities/WrappedPacketInAbilities.java | 18 +- .../abilities/WrappedPacketOutAbilities.java | 152 +- .../animation/PacketAnimationWrapper.java | 71 +- .../animation/WrappedPacketOutAnimation.java | 18 +- .../PacketArmAnimationWrapper.java | 11 +- .../WrappedPacketInArmAnimation.java | 18 +- .../PacketAttachEntityWrapper.java | 71 +- .../WrappedPacketOutAttachEntity.java | 18 +- .../action/PacketBlockActionWrapper.java | 134 +- .../action/WrappedPacketOutBlockAction.java | 14 +- .../PacketBlockBreakAnimationWrapper.java | 109 +- .../WrappedPacketOutBlockBreakAnimation.java | 18 +- .../change/PacketBlockChangeWrapper.java | 50 +- .../change/WrappedPacketOutBlockChange.java | 14 +- .../block/dig/PacketBlockDigWrapper.java | 133 +- .../block/dig/WrappedPacketInBlockDig.java | 18 +- .../block/place/PacketBlockPlaceWrapper.java | 141 +- .../place/WrappedPacketInBlockPlace.java | 18 +- .../update/PacketBlockUpdateWrapper.java | 88 +- .../update/WrappedPacketOutBlockUpdate.java | 18 +- .../wrapper/camera/PacketCameraWrapper.java | 45 +- .../camera/WrappedPacketOutCamera.java | 18 +- .../wrapper/chat/PacketChatWrapper.java | 53 +- .../wrapper/chat/WrappedPacketInChat.java | 38 +- .../wrapper/chat/WrappedPacketOutChat.java | 32 +- .../PacketClientCommandWrapper.java | 50 +- .../WrappedPacketInClientCommand.java | 14 +- .../closewindow/PacketCloseWindowWrapper.java | 45 +- .../WrappedPacketInCloseWindow.java | 18 +- .../WrappedPacketOutCloseWindow.java | 18 +- .../wrapper/collect/PacketCollectWrapper.java | 71 +- .../collect/WrappedPacketOutCollect.java | 18 +- .../PacketCustomPayloadWrapper.java | 6 +- .../WrappedPacketInCustomPayload.java | 14 +- .../WrappedPacketOutCustomPayload.java | 14 +- .../enchantitem/PacketEnchantItemWrapper.java | 71 +- .../WrappedPacketInEnchantItem.java | 18 +- .../wrapper/entity/PacketEntityWrapper.java | 47 +- .../entity/WrappedPacketInEntityAction.java | 88 +- .../entity/WrappedPacketOutEntity.java | 134 +- .../entity/WrappedPacketOutEntityDestroy.java | 20 +- .../entity/WrappedPacketOutEntityEffect.java | 102 +- .../WrappedPacketOutEntityEquipment.java | 20 +- .../WrappedPacketOutEntityHeadRotation.java | 52 +- .../WrappedPacketOutEntityMetadata.java | 20 +- .../entity/WrappedPacketOutEntityStatus.java | 50 +- .../WrappedPacketOutEntityTeleport.java | 76 +- .../WrappedPacketOutEntityVelocity.java | 20 +- .../experience/PacketExperienceWrapper.java | 97 +- .../WrappedPacketOutExperience.java | 18 +- .../explosion/PacketExplosionWrapper.java | 47 +- .../explosion/WrappedPacketOutExplosion.java | 18 +- .../wrapper/flying/PacketFlyingWrapper.java | 201 +- .../wrapper/flying/WrappedPacketInFlying.java | 18 +- .../PacketGameStateChangeWrapper.java | 45 +- .../WrappedPacketOutGameStateChange.java | 18 +- .../PacketHeldItemSlotWrapper.java | 45 +- .../WrappedPacketInHeldItemSlot.java | 18 +- .../WrappedPacketOutHeldItemSlot.java | 18 +- .../PacketKickDisconnectWrapper.java | 50 +- .../WrappedPacketOutKickDisconnect.java | 18 +- .../wrapper/login/PacketLoginWrapper.java | 121 +- .../wrapper/login/WrappedPacketOutLogin.java | 18 +- .../packets/wrapper/map/PacketMapWrapper.java | 45 +- .../wrapper/map/WrappedPacketOutMap.java | 18 +- .../PacketMultiBlockChangeWrapper.java | 11 +- .../WrappedPacketOutMultiBlockChange.java | 18 +- .../PacketNamedSoundEffectWrapper.java | 121 +- .../WrappedPacketOutNamedSoundEffect.java | 18 +- .../PacketOpenSignEditorWrapper.java | 57 +- .../WrappedPacketOutOpenSignEditor.java | 18 +- .../open/window/PacketOpenWindowWrapper.java | 83 +- .../window/WrappedPacketOutOpenWindow.java | 18 +- .../PacketPlayerListHeaderFooterWrapper.java | 95 +- ...rappedPacketOutPlayerListHeaderFooter.java | 18 +- .../position/PacketPositionWrapper.java | 11 +- .../position/WrappedPacketOutPosition.java | 18 +- .../PacketRemoveEntityEffectWrapper.java | 45 +- .../WrappedPacketOutRemoveEntityEffect.java | 18 +- .../PacketResourcePackStatusWrapper.java | 59 +- .../WrappedPacketInResourcePackStatus.java | 18 +- .../wrapper/respawn/PacketRespawnWrapper.java | 57 +- .../respawn/WrappedPacketOutRespawn.java | 18 +- ...cketScoreboardDisplayObjectiveWrapper.java | 45 +- ...edPacketOutScoreboardDisplayObjective.java | 18 +- .../PacketScoreboardObjectiveWrapper.java | 107 +- .../WrappedPacketOutScoreboardObjective.java | 18 +- .../score/PacketScoreboardScoreWrapper.java | 97 +- .../WrappedPacketOutScoreboardScore.java | 18 +- .../team/PacketScoreboardTeamWrapper.java | 99 +- .../team/WrappedPacketOutScoreboardTeam.java | 18 +- .../PacketServerDifficultyWrapper.java | 83 +- .../WrappedPacketOutServerDifficulty.java | 18 +- .../PacketSetCreativeSlotWrapper.java | 57 +- .../WrappedPacketInSetCreativeSlot.java | 18 +- .../set/slot/PacketSetSlotWrapper.java | 107 +- .../set/slot/WrappedPacketOutSetSlot.java | 18 +- .../settings/PacketSettingsWrapper.java | 11 +- .../settings/WrappedPacketInSettings.java | 18 +- .../entity/PacketSpawnEntityWrapper.java | 69 +- .../entity/WrappedPacketOutSpawnEntity.java | 18 +- .../position/PacketSpawnPositionWrapper.java | 11 +- .../WrappedPacketOutSpawnPosition.java | 18 +- .../spectate/PacketSpectateWrapper.java | 47 +- .../spectate/WrappedPacketInSpectate.java | 18 +- .../statistic/PacketStatisticWrapper.java | 11 +- .../statistic/WrappedPacketOutStatistic.java | 18 +- .../PacketSteerVehicleWrapper.java | 11 +- .../WrappedPacketInSteerVehicle.java | 18 +- .../tabcomplete/PacketTabCompleteWrapper.java | 11 +- .../WrappedPacketInTabComplete.java | 50 +- .../WrappedPacketOutTabComplete.java | 20 +- .../PacketTileEntityDataWrapper.java | 119 +- .../WrappedPacketOutTileEntityData.java | 18 +- .../wrapper/title/PacketTitleWrapper.java | 11 +- .../title/WrappedPacketOutAnimationTitle.java | 108 +- .../title/WrappedPacketOutSubtitleTitle.java | 64 +- .../title/WrappedPacketOutTitleTitle.java | 64 +- .../PacketUpdateAttributesWrapper.java | 45 +- .../WrappedPacketOutUpdateAttributes.java | 18 +- .../health/PacketUpdateHealthWrapper.java | 97 +- .../health/WrappedPacketOutUpdateHealth.java | 18 +- .../update/sign/PacketUpdateSignWrapper.java | 57 +- .../sign/WrappedPacketInUpdateSign.java | 18 +- .../update/time/PacketUpdateTimeWrapper.java | 71 +- .../time/WrappedPacketOutUpdateTime.java | 18 +- .../update/window/PacketUpdateWindow.java | 45 +- .../update/window/PacketUpdateWindowData.java | 70 +- .../window/PacketUpdateWindowItems.java | 10 +- .../window/WrappedPacketOutWindowData.java | 18 +- .../window/WrappedPacketOutWindowItems.java | 18 +- .../wrapper/use/PacketUseEntityWrapper.java | 77 +- .../wrapper/use/WrappedPacketInUseEntity.java | 18 +- .../click/PacketWindowClickWrapper.java | 121 +- .../click/WrappedPacketInWindowClick.java | 18 +- .../window/data/PacketWindowDataWrapper.java | 97 +- .../data/WrappedPacketOutWindowData.java | 18 +- .../items/PacketWindowItemsWrapper.java | 45 +- .../items/WrappedPacketOutWindowItems.java | 18 +- .../world/event/PacketWorldEventWrapper.java | 133 +- .../event/WrappedPacketOutWorldEvent.java | 18 +- .../spigot/player/elements/PlayerElement.java | 198 +- .../player/elements/impl/Actionbar.java | 70 +- .../spigot/player/elements/impl/Bossbar.java | 118 +- .../spigot/player/elements/impl/Chat.java | 208 +- .../spigot/player/elements/impl/Nametag.java | 90 +- .../player/elements/impl/Scoreboard.java | 255 ++- .../spigot/player/elements/impl/Tablist.java | 98 +- .../minecraft/spigot/utils/EntityUtils.java | 30 +- .../lib/minecraft/spigot/utils/ItemUtils.java | 88 +- .../lib/minecraft/spigot/utils/Metrics.java | 1582 ++++++++------- .../minecraft/spigot/utils/PlayerUtils.java | 440 ++-- .../spigot/utils/SchedulerUtils.java | 83 + .../minecraft/spigot/utils/ServerUtils.java | 154 +- .../minecraft/spigot/utils/WorldUtils.java | 143 +- .../utils/builder/EntityPlayerBuilder.java | 338 ++-- .../utils/builder/GameProfileBuilder.java | 8 +- .../utils/builder/InventoryBuilder.java | 190 +- .../spigot/utils/builder/ItemBuilder.java | 370 ++-- .../utils/inventory/InventoryBackup.java | 91 +- .../animation/InventoryAnimation.java | 94 +- .../open/InventoryOpenAnimation.java | 2 +- .../open/impl/ItemFillAnimation.java | 33 +- .../spigot/utils/labymod/LabyMod.java | 320 ++- .../spigot/utils/labymod/LabyModProtocol.java | 159 +- .../utils/lunar/LunarJsonObjectUtil.java | 112 +- .../utils/lunar/LunarJsonPacketUtil.java | 138 +- .../spigot/utils/version/IVersionAdapter.java | 397 ++-- .../spigot/utils/version/VersionAdapter.java | 1787 +++++++++-------- .../utils/version/VersionAdapterFolia.java | 57 + .../utils/version/VersionAdapterModern.java | 526 +++-- .../spigot/utils/version/VersionProvider.java | 110 +- .../v1_21_R1/VersionAdapter_v1_21_R1.java | 114 ++ .../v1_9_R1/VersionAdapter_v1_9_R1.java | 79 +- .../v26_1_R1/VersionAdapter_v26_1_R1.java | 70 + .../v_1_13_R1/VersionAdapter_v_1_13_R1.java | 307 +-- .../falchus/lib/minecraft/utils/APIUtils.java | 37 +- .../lib/minecraft/utils/AdventureUtils.java | 14 +- .../falchus/lib/minecraft/utils/CloudNet.java | 216 +- .../velocity/FalchusLibMinecraftVelocity.java | 8 +- src/com/falchus/lib/storage/Storage.java | 108 +- .../storage/impl/json/JsonArrayStorage.java | 11 +- .../storage/impl/json/JsonObjectStorage.java | 11 +- .../lib/storage/impl/json/JsonStorage.java | 10 +- .../lib/storage/serializer/Serializer.java | 6 +- .../serializer/json/JsonArraySerializer.java | 44 +- .../serializer/json/JsonObjectSerializer.java | 44 +- .../serializer/json/JsonSerializer.java | 7 +- src/com/falchus/lib/task/Task.java | 197 +- .../falchus/lib/task/impl/CountdownTask.java | 30 +- src/com/falchus/lib/utils/DiscordWebhook.java | 168 +- src/com/falchus/lib/utils/FastRandom.java | 127 +- src/com/falchus/lib/utils/FileUtils.java | 30 +- src/com/falchus/lib/utils/MySQL.java | 120 +- src/com/falchus/lib/utils/VPNApi.java | 41 +- .../utils/builder/ClassInstanceBuilder.java | 147 +- .../lib/utils/builder/HTTPServerBuilder.java | 31 +- .../falchus/lib/utils/http/HTTPRequest.java | 42 +- .../falchus/lib/utils/http/HTTPServer.java | 45 +- .../falchus/lib/utils/reflection/Dummy.java | 7 +- .../lib/utils/reflection/ReflectionUtils.java | 334 +-- .../lib/utils/reflection/keys/ClassKey.java | 12 +- .../utils/reflection/keys/ConstructorKey.java | 20 +- .../lib/utils/reflection/keys/FieldKey.java | 28 +- .../lib/utils/reflection/keys/MethodKey.java | 28 +- .../falchus/lib/utils/wrapper/Wrapper.java | 132 +- .../lib/utils/wrapper/impl/ClassWrapper.java | 75 +- .../utils/wrapper/impl/FirstClassWrapper.java | 33 +- src/plugin.yml | 5 +- src/velocity-plugin.json | 2 +- 252 files changed, 9820 insertions(+), 9313 deletions(-) create mode 100644 src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java create mode 100644 src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterFolia.java create mode 100644 src/com/falchus/lib/minecraft/spigot/utils/version/v1_21_R1/VersionAdapter_v1_21_R1.java create mode 100644 src/com/falchus/lib/minecraft/spigot/utils/version/v26_1_R1/VersionAdapter_v26_1_R1.java diff --git a/CODEOWNERS b/CODEOWNERS index 229391dd..6d2c2192 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1,2 @@ * @eliasfalch +* @sun-mc-dev \ No newline at end of file diff --git a/README.md b/README.md index 3131345b..4e24113e 100644 --- a/README.md +++ b/README.md @@ -3,18 +3,21 @@ A library designed to simplify & speed up software development. ### Features + - Reusable utilities for common tasks - Abstraction layers for easier integration - Productivity helpers to speed up development - Cross-platform and maintainable design ### Installation + ```xml falchus.com https://repo.falchus.com/releases ``` + ```xml com.falchus @@ -24,31 +27,41 @@ A library designed to simplify & speed up software development. ``` ### Usage + #### Tasks + `com.falchus.lib.task.Task` + ```java static Task runTask(Runnable runnable); static Task runTaskTimer(Runnable runnable, long period, TimeUnit unit); + void runTaskTimer(long period, TimeUnit unit); static Task runTaskTimer(Runnable runnable, long delay, long period, TimeUnit unit); + void runTaskTimer(long delay, long period, TimeUnit unit); static Task runTaskLater(Runnable runnable, long delay, TimeUnit unit); + void runTaskLater(long delay, TimeUnit unit); static void end(int id); + void end(); int getId(); @Override -void onRun(int tick) {} +void onRun(int tick) { +} @Override -void onEnd() {} +void onEnd() { +} ``` + - `com.falchus.lib.task.impl.CountdownTask` ```java CountdownTask(int remaining); @@ -58,7 +71,9 @@ void onEnd() {} ``` #### Builders + `com.falchus.lib.utils.builder.ClassInstanceBuilder` + ```java ClassInstanceBuilder(Class clazz); @@ -71,6 +86,7 @@ Object build(); ``` `com.falchus.lib.utils.builder.HTTPServerBuilder` + ```java HTTPServerBuilder port(int port); @@ -81,7 +97,9 @@ HTTPServer build(String ip); ``` #### Storage + `com.falchus.lib.storage.Storage` + ```java void save(T value); @@ -89,26 +107,32 @@ HTTPServer build(String ip); void delete(); ``` + - `com.falchus.lib.storage.impl.json.JsonStorage` - - `com.falchus.lib.storage.impl.json.JsonArrayStorage` - - `com.falchus.lib.storage.impl.json.JsonObjectStorage` + - `com.falchus.lib.storage.impl.json.JsonArrayStorage` + - `com.falchus.lib.storage.impl.json.JsonObjectStorage` `com.falchus.lib.storage.serializer.Serializer` + ```java String serialize(T value); T deserialize(String content); ``` + - `com.falchus.lib.storage.serializer.json.JsonSerializer` - - `com.falchus.lib.storage.serializer.json.JsonArraySerializer` - - `com.falchus.lib.storage.serializer.json.JsonObjectSerializer` + - `com.falchus.lib.storage.serializer.json.JsonArraySerializer` + - `com.falchus.lib.storage.serializer.json.JsonObjectSerializer` #### HTTP + `com.falchus.lib.utils.http.HTTPRequest` + ```java static String get(String url); ``` `com.falchus.lib.utils.http.HTTPServer` + ```java void start(); void stop(int delay); @@ -118,29 +142,38 @@ static void sendJson(HttpExchange exchange, String json, int statusCode); ``` #### Events + `com.falchus.lib.events.Cancellable` + ```java void setCancelled(boolean cancelled); boolean isCancelled(); ``` `com.falchus.lib.events.Event` + ```java Event(boolean async); boolean callEvent(); ``` + `com.falchus.lib.events.EventExecutor` + ```java void execute(Event event); ``` + `com.falchus.lib.events.EventHandler` + ```java EventPriority priority(); boolean ignoreCancelled(); ``` + `com.falchus.lib.manager.EventManager` + ```java static void registerListener(Listener listener); static void unregisterListener(Listener listener); @@ -150,12 +183,15 @@ static void callEvent(Event event); `com.falchus.lib.events.listener.Listener` `com.falchus.lib.events.listener.RegisteredListener` + ```java void execute(Event event); ``` #### Reflection & Wrapping + `com.falchus.lib.utils.reflection.ReflectionUtils` + ```java static Class getClass(String name); static Class getFirstClass(String... names); @@ -188,6 +224,7 @@ static Constructor getFirstConstructor(Set classes, Set> para ``` `com.falchus.lib.utils.wrapper.Wrapper` + ```java Wrapper(T handle); @@ -205,16 +242,17 @@ Constructor getFirstConstructor(Set> params); > U as(Class clazz, Class... params); ``` + - `com.falchus.lib.utils.wrapper.impl.ClassWrapper` ```java ClassWrapper(T handle, Set classes); Set getClasses(); ``` - - `com.falchus.lib.utils.wrapper.impl.FirstClassWrapper` - ```java - FirstClassWrapper(T handle, Set names); - ``` + - `com.falchus.lib.utils.wrapper.impl.FirstClassWrapper` + ```java + FirstClassWrapper(T handle, Set names); + ```
Minecraft @@ -234,6 +272,7 @@ author: Example depend: [FalchusLib] ``` +
velocity-plugin.json @@ -248,11 +287,15 @@ depend: [FalchusLib] "dependencies": [{"id": "falchuslib", "optional": false}] } ``` +
#### Usage + ##### Utils + `com.falchus.lib.minecraft.spigot.utils.EntityUtils` + ```java static Entity getBukkitEntity(Object entity); @@ -260,6 +303,7 @@ static void setYawPitch(Object entity, float yaw, float pitch); ``` `com.falchus.lib.minecraft.spigot.utils.ItemUtils` + ```java static ItemStack setUUID(ItemStack item, UUID uuid); static UUID getUUID(ItemStack item); @@ -271,6 +315,7 @@ static String itemStackArrayToBase64(ItemStack[] items); ``` `com.falchus.lib.minecraft.spigot.utils.PlayerUtils` + ```java static void sendPacket(Player player, Object packet); @@ -279,11 +324,13 @@ static void sendTitle(Player player, String title, String subtitle); static void playSound(Player player, Location location, Sound sound, float volume, float pitch); static void freeze(Player player); + static void unfreeze(Player player); static String getLuckPermsRankPrefix(Player player); static void vanish(Player player); + static void unvanish(Player player); static Object getEntityPlayer(Player player); @@ -293,21 +340,26 @@ static GameProfile getProfile(Object entityPlayer); static int getPing(Player player); static void setSkin(Player player, UUID uuid); + static void resetSkin(Player player); static void setName(Player player, String name); + static void resetName(Player player); static void refresh(Player player); static void addEntityPlayer(Player player, Object entityPlayer); + static void removeEntityPlayer(Player player, Object entityPlayer); + static void spawnEntityPlayer(Player player, Object entityPlayer); static void connectToServer(Player player, String server); ``` `com.falchus.lib.minecraft.spigot.utils.ServerUtils` + ```java static Object getMcServer(); static Object getBukkitServer(); @@ -321,11 +373,14 @@ static double[] getRecentTps(); ``` `com.falchus.lib.minecraft.spigot.utils.WorldUtils` + ```java static void setGameRule(World world, com.falchus.lib.minecraft.spigot.enums.GameRule gameRule, String value); static Object[] getWorldBiomes(World world); + static Object getNmsBiome(Biome biome); + static int getBiomeId(Biome biome); static Object getWorldServer(World world); @@ -336,7 +391,9 @@ static Material getMaterial(com.falchus.lib.minecraft.spigot.enums.Material mate ``` ##### Commands + `com.falchus.lib.minecraft.command.BaseCommand` + ```java String getPermission(); String getNoPermissionMessage(); @@ -351,11 +408,14 @@ boolean hasPermission(Object sender); void sendMessage(Object s, String message); ``` + - `com.falchus.lib.minecraft.command.impl.SpigotCommandAdapter` - `com.falchus.lib.minecraft.command.impl.VelocityCommandAdapter` ##### Events + `com.falchus.lib.minecraft.spigot.events.LobbyCancelEvent` + ```java boolean isCancelled(); @@ -365,6 +425,7 @@ Event getEvent(); ``` `com.falchus.lib.minecraft.spigot.events.player.PlayerClientJoinEvent` + ```java Player getPlayer(); @@ -372,6 +433,7 @@ Client getClient(); ``` `com.falchus.lib.minecraft.spigot.events.player.PlayerPacketEvent` + ```java boolean isAsynchronous(); @@ -383,11 +445,14 @@ Player getPlayer(); PacketWrapper getPacket(); ``` + - `com.falchus.lib.minecraft.spigot.events.player.PlayerPacketInEvent` - `com.falchus.lib.minecraft.spigot.events.player.PlayerPacketOutEvent` ##### Player Elements + `com.falchus.lib.minecraft.spigot.player.elements.PlayerElement` + ```java void update(); static void updateAll(Class clazz); @@ -398,6 +463,7 @@ void remove(); static T get(Class clazz, Player player); ``` + - `com.falchus.lib.minecraft.spigot.player.elements.impl.Actionbar` ```java void send(Supplier message); @@ -434,21 +500,26 @@ static T get(Class clazz, Player player); ``` ##### Packets + `com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper` + ```java T as(Class clazz); ``` + - `com.falchus.lib.minecraft.spigot.packets.wrapper.chat.PacketChatWrapper` ```java void setMessage(String message); Object getMessage(); ``` - - `com.falchus.lib.minecraft.spigot.packets.wrapper.chat.WrappedPacketInChat` - - `com.falchus.lib.minecraft.spigot.packets.wrapper.chat.WrappedPacketOutChat` + - `com.falchus.lib.minecraft.spigot.packets.wrapper.chat.WrappedPacketInChat` + - `com.falchus.lib.minecraft.spigot.packets.wrapper.chat.WrappedPacketOutChat` ##### Builders + `com.falchus.lib.minecraft.spigot.utils.builder.EntityPlayerBuilder` + ```java EntityPlayerBuilder setName(String name); @@ -468,6 +539,7 @@ Object build(); ``` `com.falchus.lib.minecraft.spigot.utils.builder.InventoryBuilder` + ```java InventoryBuilder(String title, Integer size); @@ -496,11 +568,14 @@ List buildPages(); ``` `com.falchus.lib.minecraft.spigot.utils.builder.ItemBuilder` + ```java ItemBuilder(Material material, int amount); + ItemBuilder(Material material); ItemBuilder(com.falchus.lib.minecraft.spigot.enums.Material material, int amount); + ItemBuilder(com.falchus.lib.minecraft.spigot.enums.Material material); ItemBuilder(ItemStack item); @@ -516,11 +591,13 @@ ItemBuilder addItemFlag(ItemFlag itemFlag); ItemBuilder setDurability(short durability); ItemBuilder setSkullOwner(String owner); + ItemBuilder setSkullTexture(String texture); ItemBuilder setUUID(UUID uuid); ItemBuilder withInteractListener(Consumer onPlayerInteract); + ItemBuilder withInventoryClickListener(TriConsumer onInventoryClick); ItemStack build(); diff --git a/pom.xml b/pom.xml index 26c81dc9..bc0da007 100644 --- a/pom.xml +++ b/pom.xml @@ -1,139 +1,146 @@ - - 4.0.0 - com.falchus - lib-java - 1.10.2 - - - 21 - 21 - UTF-8 - 1.18.44 - 4.0.0-RC14 - - - - - falchus.com - https://repo.falchus.com/releases - - - falchus.com - https://repo.falchus.com/snapshots - - - - - - papermc-repo - https://repo.papermc.io/repository/maven-public/ - - - spigotmc-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - cs-arcanearts - https://dl.cloudsmith.io/public/arcane/archive/maven/ - - - - - - org.projectlombok - lombok - ${lombok.version} - provided - - - - com.velocitypowered - velocity-api - 3.5.0-SNAPSHOT - provided - - - org.bukkit.craftbukkit - 1.8.8 - 1.8.8 - provided - - - org.spigotmc - spigot-api - 1.8.8-R0.1-SNAPSHOT - provided - - - - net.luckperms - api - 5.5 - provided - - - - eu.cloudnetservice.cloudnet - bridge-impl - ${cloudnet.version} - provided - - - eu.cloudnetservice.cloudnet - wrapper-jvm-api - ${cloudnet.version} - provided - - - - - src - - - src - - plugin.yml - velocity-plugin.json - - - **/*.java - - true - - - FalchusLib - - - org.apache.maven.plugins - maven-compiler-plugin - 3.15.0 - - - - org.projectlombok - lombok - ${lombok.version} - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.6.2 - - - package - - shade - - - false - - - - - - + + 4.0.0 + com.falchus + lib-java + 1.10.3 + + + 21 + 21 + UTF-8 + 1.18.44 + 4.0.0-RC14 + + + + + falchus.com + https://repo.falchus.com/releases + + + falchus.com + https://repo.falchus.com/snapshots + + + + + + papermc-repo + https://repo.papermc.io/repository/maven-public/ + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + cs-arcanearts + https://dl.cloudsmith.io/public/arcane/archive/maven/ + + + + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + com.velocitypowered + velocity-api + 3.5.0-SNAPSHOT + provided + + + io.papermc.paper + paper-api + 1.21-R0.1-SNAPSHOT + provided + + + org.bukkit.craftbukkit + 1.8.8 + 1.8.8 + provided + + + org.spigotmc + spigot-api + 1.8.8-R0.1-SNAPSHOT + provided + + + + net.luckperms + api + 5.5 + provided + + + + eu.cloudnetservice.cloudnet + bridge-impl + ${cloudnet.version} + provided + + + eu.cloudnetservice.cloudnet + wrapper-jvm-api + ${cloudnet.version} + provided + + + + + src + + + src + + plugin.yml + velocity-plugin.json + + + **/*.java + + true + + + FalchusLib + + + org.apache.maven.plugins + maven-compiler-plugin + 3.15.0 + + + + org.projectlombok + lombok + ${lombok.version} + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.6.2 + + + package + + shade + + + false + + + + + + \ No newline at end of file diff --git a/src/com/falchus/lib/enums/EventPriority.java b/src/com/falchus/lib/enums/EventPriority.java index 6e44e3a9..a9f3651d 100644 --- a/src/com/falchus/lib/enums/EventPriority.java +++ b/src/com/falchus/lib/enums/EventPriority.java @@ -1,10 +1,10 @@ package com.falchus.lib.enums; public enum EventPriority { - LOWEST, - LOW, - NORMAL, - HIGH, - HIGHEST, - MONITOR + LOWEST, + LOW, + NORMAL, + HIGH, + HIGHEST, + MONITOR } diff --git a/src/com/falchus/lib/events/Cancellable.java b/src/com/falchus/lib/events/Cancellable.java index edb96e27..05c0b0b0 100644 --- a/src/com/falchus/lib/events/Cancellable.java +++ b/src/com/falchus/lib/events/Cancellable.java @@ -2,7 +2,7 @@ public interface Cancellable { - void setCancelled(boolean cancelled); - - boolean isCancelled(); + boolean isCancelled(); + + void setCancelled(boolean cancelled); } diff --git a/src/com/falchus/lib/events/Event.java b/src/com/falchus/lib/events/Event.java index 20d2168a..93c8e7ab 100644 --- a/src/com/falchus/lib/events/Event.java +++ b/src/com/falchus/lib/events/Event.java @@ -1,7 +1,6 @@ package com.falchus.lib.events; import com.falchus.lib.manager.EventManager; - import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -13,18 +12,18 @@ @FieldDefaults(level = AccessLevel.PRIVATE) @RequiredArgsConstructor public class Event { - - final boolean async; - - public Event() { - this(false); - } - - public boolean callEvent() { - EventManager.callEvent(this); - if (this instanceof Cancellable cancellable) { - return !cancellable.isCancelled(); - } - return true; - } + + final boolean async; + + public Event() { + this(false); + } + + public boolean callEvent() { + EventManager.callEvent(this); + if (this instanceof Cancellable cancellable) { + return !cancellable.isCancelled(); + } + return true; + } } diff --git a/src/com/falchus/lib/events/EventExecutor.java b/src/com/falchus/lib/events/EventExecutor.java index 578a6cd9..dff04ce3 100644 --- a/src/com/falchus/lib/events/EventExecutor.java +++ b/src/com/falchus/lib/events/EventExecutor.java @@ -3,5 +3,5 @@ @FunctionalInterface public interface EventExecutor { - void execute(Event event); + void execute(Event event); } diff --git a/src/com/falchus/lib/events/EventHandler.java b/src/com/falchus/lib/events/EventHandler.java index fe0bd31c..cad8a264 100644 --- a/src/com/falchus/lib/events/EventHandler.java +++ b/src/com/falchus/lib/events/EventHandler.java @@ -1,17 +1,17 @@ package com.falchus.lib.events; +import com.falchus.lib.enums.EventPriority; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.falchus.lib.enums.EventPriority; - @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface EventHandler { - - EventPriority priority() default EventPriority.NORMAL; - - boolean ignoreCancelled() default false; + + EventPriority priority() default EventPriority.NORMAL; + + boolean ignoreCancelled() default false; } diff --git a/src/com/falchus/lib/events/listener/Listener.java b/src/com/falchus/lib/events/listener/Listener.java index 448c9318..6fdd73ba 100644 --- a/src/com/falchus/lib/events/listener/Listener.java +++ b/src/com/falchus/lib/events/listener/Listener.java @@ -1,3 +1,4 @@ package com.falchus.lib.events.listener; -public interface Listener {} +public interface Listener { +} diff --git a/src/com/falchus/lib/events/listener/RegisteredListener.java b/src/com/falchus/lib/events/listener/RegisteredListener.java index 594912f5..851e15ba 100644 --- a/src/com/falchus/lib/events/listener/RegisteredListener.java +++ b/src/com/falchus/lib/events/listener/RegisteredListener.java @@ -4,7 +4,6 @@ import com.falchus.lib.events.Event; import com.falchus.lib.events.EventExecutor; import com.falchus.lib.events.EventHandler; - import lombok.AccessLevel; import lombok.Getter; import lombok.experimental.FieldDefaults; @@ -12,20 +11,20 @@ @Getter @FieldDefaults(level = AccessLevel.PRIVATE) public class RegisteredListener { - - final Listener listener; - final EventExecutor executor; - final EventPriority priority; - final boolean ignoreCancelled; - - public RegisteredListener(Listener listener, EventExecutor executor, EventHandler handler) { - this.listener = listener; - this.executor = executor; - priority = handler.priority(); - ignoreCancelled = handler.ignoreCancelled(); - } - - public void execute(Event event) { - executor.execute(event); - } + + final Listener listener; + final EventExecutor executor; + final EventPriority priority; + final boolean ignoreCancelled; + + public RegisteredListener(Listener listener, EventExecutor executor, EventHandler handler) { + this.listener = listener; + this.executor = executor; + priority = handler.priority(); + ignoreCancelled = handler.ignoreCancelled(); + } + + public void execute(Event event) { + executor.execute(event); + } } diff --git a/src/com/falchus/lib/interfaces/Mapper.java b/src/com/falchus/lib/interfaces/Mapper.java index 940cc63b..5a657556 100644 --- a/src/com/falchus/lib/interfaces/Mapper.java +++ b/src/com/falchus/lib/interfaces/Mapper.java @@ -3,6 +3,6 @@ public interface Mapper { U to(T value); - + T from(U value); } diff --git a/src/com/falchus/lib/interfaces/consumer/TriConsumer.java b/src/com/falchus/lib/interfaces/consumer/TriConsumer.java index 06ca0d8f..363e15e3 100644 --- a/src/com/falchus/lib/interfaces/consumer/TriConsumer.java +++ b/src/com/falchus/lib/interfaces/consumer/TriConsumer.java @@ -5,17 +5,17 @@ /** * A functional interface similar to {@link BiConsumer}, * but accepts three input arguments instead of two. - * + * * @param the type of the first argument * @param the type of the second argument * @param the type of the third argument */ @FunctionalInterface public interface TriConsumer { - + /** * Performs this operation on the given arguments. - * + * * @param t the first input argument * @param u the second input argument * @param v the third input argument diff --git a/src/com/falchus/lib/manager/EventManager.java b/src/com/falchus/lib/manager/EventManager.java index 7ff5f863..f7b5005f 100644 --- a/src/com/falchus/lib/manager/EventManager.java +++ b/src/com/falchus/lib/manager/EventManager.java @@ -1,5 +1,12 @@ package com.falchus.lib.manager; +import com.falchus.lib.events.Cancellable; +import com.falchus.lib.events.Event; +import com.falchus.lib.events.EventHandler; +import com.falchus.lib.events.listener.Listener; +import com.falchus.lib.events.listener.RegisteredListener; +import lombok.experimental.UtilityClass; + import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Comparator; @@ -9,84 +16,76 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; -import com.falchus.lib.events.Cancellable; -import com.falchus.lib.events.Event; -import com.falchus.lib.events.EventHandler; -import com.falchus.lib.events.listener.Listener; -import com.falchus.lib.events.listener.RegisteredListener; - -import lombok.experimental.UtilityClass; - @UtilityClass public class EventManager { - private final Map, List> listeners = new ConcurrentHashMap<>(); - - @SuppressWarnings("unchecked") - public static void registerListener(Listener listener) { - for (Method method : listener.getClass().getDeclaredMethods()) { - if (!method.isAnnotationPresent(EventHandler.class)) continue; - - Class[] params = method.getParameterTypes(); - if (params.length != 1 || !Event.class.isAssignableFrom(params[0])) continue; - - Class clazz = (Class) params[0]; - EventHandler handler = method.getAnnotation(EventHandler.class); - - method.setAccessible(true); - - List listeners = EventManager.listeners.computeIfAbsent(clazz, k -> new CopyOnWriteArrayList<>()); - listeners.add(new RegisteredListener( - listener, - event -> { - try { - method.invoke(listener, event); - } catch (Exception e) { - throw new RuntimeException(e); - } - }, - handler - )); - listeners.sort(Comparator.comparingInt(k -> k.getPriority().ordinal())); - } - } - - public static void unregisterListener(Listener listener) { - for (List list : listeners.values()) { - list.removeIf(registered -> registered.getListener().equals(listener)); + private final Map, List> listeners = new ConcurrentHashMap<>(); + + @SuppressWarnings("unchecked") + public static void registerListener(Listener listener) { + for (Method method : listener.getClass().getDeclaredMethods()) { + if (!method.isAnnotationPresent(EventHandler.class)) continue; + + Class[] params = method.getParameterTypes(); + if (params.length != 1 || !Event.class.isAssignableFrom(params[0])) continue; + + Class clazz = (Class) params[0]; + EventHandler handler = method.getAnnotation(EventHandler.class); + + method.setAccessible(true); + + List listeners = EventManager.listeners.computeIfAbsent(clazz, k -> new CopyOnWriteArrayList<>()); + listeners.add(new RegisteredListener( + listener, + event -> { + try { + method.invoke(listener, event); + } catch (Exception e) { + throw new RuntimeException(e); + } + }, + handler + )); + listeners.sort(Comparator.comparingInt(k -> k.getPriority().ordinal())); + } + } + + public static void unregisterListener(Listener listener) { + for (List list : listeners.values()) { + list.removeIf(registered -> registered.getListener().equals(listener)); + } + } + + public static void callEvent(Event event) { + List listeners = new ArrayList<>(); + + Class clazz = event.getClass(); + while (clazz != null && Event.class.isAssignableFrom(clazz)) { + List list = EventManager.listeners.get(clazz); + if (list != null) { + listeners.addAll(list); + } + clazz = clazz.getSuperclass(); + } + + if (listeners.isEmpty()) return; + + listeners.sort(Comparator.comparingInt(k -> k.getPriority().ordinal())); + + for (RegisteredListener listener : listeners) { + if (event instanceof Cancellable cancellable) { + if (cancellable.isCancelled() && listener.isIgnoreCancelled()) continue; + } + + if (event.isAsync()) { + CompletableFuture.runAsync(() -> listener.execute(event)); + } else { + try { + listener.execute(event); + } catch (Exception e) { + e.printStackTrace(); + } + } } - } - - public static void callEvent(Event event) { - List listeners = new ArrayList<>(); - - Class clazz = event.getClass(); - while (clazz != null && Event.class.isAssignableFrom(clazz)) { - List list = EventManager.listeners.get(clazz); - if (list != null) { - listeners.addAll(list); - } - clazz = clazz.getSuperclass(); - } - - if (listeners.isEmpty()) return; - - listeners.sort(Comparator.comparingInt(k -> k.getPriority().ordinal())); - - for (RegisteredListener listener : listeners) { - if (event instanceof Cancellable cancellable) { - if (cancellable.isCancelled() && listener.isIgnoreCancelled()) continue; - } - - if (event.isAsync()) { - CompletableFuture.runAsync(() -> listener.execute(event)); - } else { - try { - listener.execute(event); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } + } } diff --git a/src/com/falchus/lib/minecraft/FalchusLibMinecraft.java b/src/com/falchus/lib/minecraft/FalchusLibMinecraft.java index 53a2daeb..88bb0ccf 100644 --- a/src/com/falchus/lib/minecraft/FalchusLibMinecraft.java +++ b/src/com/falchus/lib/minecraft/FalchusLibMinecraft.java @@ -1,33 +1,50 @@ package com.falchus.lib.minecraft; import com.falchus.lib.minecraft.enums.Software; +import org.jetbrains.annotations.Nullable; /** * Class for detecting the Minecraft server software at runtime. */ public class FalchusLibMinecraft { - - /** - * Detects the server software by checking for known classes. - * + + private static Software cached; + + /** + * Detects the server software by checking for known classes. + * Result is cached after first call. + * * @return {@link Software} or {@code null} if unknown. - */ - public static Software getSoftware() { - String[] classNames = { - "org.bukkit.plugin.java.JavaPlugin", - "com.velocitypowered.api.plugin.Plugin" - }; - Software[] softwares = { - Software.SPIGOT, - Software.VELOCITY - }; - - for (int i = 0; i < classNames.length; i++) { - try { - Class.forName(classNames[i]); - return softwares[i]; - } catch (ClassNotFoundException ignored) {} - } - return null; - } -} + */ + public static @Nullable Software getSoftware() { + if (cached != null) return cached; + + String[] classNames = { + "io.papermc.paper.threadedregions.RegionizedServer", + "org.bukkit.plugin.java.JavaPlugin", + "com.velocitypowered.api.plugin.Plugin" + }; + Software[] softwares = { + Software.FOLIA, + Software.SPIGOT, + Software.VELOCITY + }; + + for (int i = 0; i < classNames.length; i++) { + try { + Class.forName(classNames[i]); + cached = softwares[i]; + return cached; + } catch (ClassNotFoundException ignored) { + } + } + return null; + } + + /** + * @return {@code true} if the server is running Folia. + */ + public static boolean isFolia() { + return getSoftware() == Software.FOLIA; + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/command/BaseCommand.java b/src/com/falchus/lib/minecraft/command/BaseCommand.java index 42bec61d..f9e1e42f 100644 --- a/src/com/falchus/lib/minecraft/command/BaseCommand.java +++ b/src/com/falchus/lib/minecraft/command/BaseCommand.java @@ -6,27 +6,27 @@ import lombok.NonNull; public interface BaseCommand { - + /** * Returns the permission required. */ String getPermission(); - + /** * Returns the message to send when a sender does not have permission. */ String getNoPermissionMessage(); - + /** * Returns the usage message for the command. */ String getUsageMessage(); - + /** * Executes the command logic. */ void executeCommand(@NonNull Object sender, @NonNull String[] args); - + /** * Tab completion. */ diff --git a/src/com/falchus/lib/minecraft/command/impl/SpigotCommandAdapter.java b/src/com/falchus/lib/minecraft/command/impl/SpigotCommandAdapter.java index 44741789..07c88701 100644 --- a/src/com/falchus/lib/minecraft/command/impl/SpigotCommandAdapter.java +++ b/src/com/falchus/lib/minecraft/command/impl/SpigotCommandAdapter.java @@ -21,13 +21,13 @@ public abstract class SpigotCommandAdapter implements BaseCommand, CommandExecut private final String permission; private final String noPermissionMessage; private final String usageMessage; - + public SpigotCommandAdapter(String permission, String noPermissionMessage, String usageMessage) { this.permission = permission; this.noPermissionMessage = noPermissionMessage != null ? noPermissionMessage : FalchusLib.noPermissionMessage; this.usageMessage = usageMessage != null ? usageMessage : FalchusLib.prefix + "§cWrong usage."; } - + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!hasPermission(sender)) { @@ -37,14 +37,14 @@ public boolean onCommand(CommandSender sender, Command command, String label, St executeCommand(sender, args); return true; } - + @Override public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (!hasPermission(sender)) return Collections.emptyList(); List list = tabComplete(sender, args); return list != null ? list : Collections.emptyList(); } - + @Override public boolean hasPermission(@NonNull Object sender) { if (permission != null) { @@ -54,7 +54,7 @@ public boolean hasPermission(@NonNull Object sender) { } return true; } - + @Override public void sendMessage(@NonNull Object s, @NonNull String message) { if (s instanceof CommandSender sender) { diff --git a/src/com/falchus/lib/minecraft/command/impl/VelocityCommandAdapter.java b/src/com/falchus/lib/minecraft/command/impl/VelocityCommandAdapter.java index 44bafdb9..b43f22ae 100644 --- a/src/com/falchus/lib/minecraft/command/impl/VelocityCommandAdapter.java +++ b/src/com/falchus/lib/minecraft/command/impl/VelocityCommandAdapter.java @@ -20,13 +20,13 @@ public abstract class VelocityCommandAdapter implements BaseCommand, SimpleComma private final String permission; private final String noPermissionMessage; private final String usageMessage; - + public VelocityCommandAdapter(String permission, String noPermissionMessage, String usageMessage) { this.permission = permission; this.noPermissionMessage = noPermissionMessage != null ? noPermissionMessage : FalchusLib.noPermissionMessage; this.usageMessage = usageMessage != null ? usageMessage : FalchusLib.prefix + "§cWrong usage."; } - + @Override public void execute(Invocation invocation) { CommandSource sender = invocation.source(); @@ -37,7 +37,7 @@ public void execute(Invocation invocation) { } executeCommand(sender, args); } - + @Override public List suggest(Invocation invocation) { CommandSource sender = invocation.source(); @@ -46,22 +46,22 @@ public List suggest(Invocation invocation) { List list = tabComplete(sender, args); return list != null ? list : Collections.emptyList(); } - + @Override public CompletableFuture> suggestAsync(Invocation invocation) { return CompletableFuture.completedFuture(suggest(invocation)); } - + @Override public boolean hasPermission(@NonNull Object sender) { if (permission != null) { if (sender instanceof Player player) { return player.hasPermission(permission); - } + } } return true; } - + @Override public void sendMessage(@NonNull Object s, @NonNull String message) { if (s instanceof CommandSource sender) { diff --git a/src/com/falchus/lib/minecraft/enums/Software.java b/src/com/falchus/lib/minecraft/enums/Software.java index b15c5309..92655716 100644 --- a/src/com/falchus/lib/minecraft/enums/Software.java +++ b/src/com/falchus/lib/minecraft/enums/Software.java @@ -1,6 +1,7 @@ package com.falchus.lib.minecraft.enums; public enum Software { - SPIGOT, - VELOCITY -} + SPIGOT, + VELOCITY, + FOLIA +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/FalchusLibMinecraftSpigot.java b/src/com/falchus/lib/minecraft/spigot/FalchusLibMinecraftSpigot.java index 182f3971..936e93b8 100644 --- a/src/com/falchus/lib/minecraft/spigot/FalchusLibMinecraftSpigot.java +++ b/src/com/falchus/lib/minecraft/spigot/FalchusLibMinecraftSpigot.java @@ -1,45 +1,52 @@ package com.falchus.lib.minecraft.spigot; -import org.bukkit.plugin.java.JavaPlugin; - +import com.falchus.lib.minecraft.FalchusLibMinecraft; import com.falchus.lib.minecraft.spigot.listeners.*; -import com.falchus.lib.minecraft.spigot.listeners.message.*; -import com.falchus.lib.minecraft.spigot.manager.*; -import com.falchus.lib.minecraft.spigot.utils.*; - +import com.falchus.lib.minecraft.spigot.listeners.message.LabyModMessageListener; +import com.falchus.lib.minecraft.spigot.listeners.message.LunarMessageListener; +import com.falchus.lib.minecraft.spigot.manager.ClientManager; +import com.falchus.lib.minecraft.spigot.utils.Metrics; +import com.falchus.lib.minecraft.spigot.utils.SchedulerUtils; import lombok.AccessLevel; import lombok.Getter; import lombok.experimental.FieldDefaults; +import org.bukkit.plugin.java.JavaPlugin; @Getter @FieldDefaults(level = AccessLevel.PRIVATE) public class FalchusLibMinecraftSpigot extends JavaPlugin { - @Getter static FalchusLibMinecraftSpigot instance; - - LabyModMessageListener labyModMessageListener; - LunarMessageListener lunarMessageListener; - EntityPlayerListener entityPlayerListener; - FreezeListener freezeListener; - ItemListener itemListener; - JoinQuitListener joinQuitListener; - LobbyCancelListener lobbyCancelListener; - ClientManager clientManager; - - @Override - public void onEnable() { - instance = this; - new Metrics(this, 28050); - - getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); - - labyModMessageListener = new LabyModMessageListener(); - lunarMessageListener = new LunarMessageListener(); - entityPlayerListener = new EntityPlayerListener(); - freezeListener = new FreezeListener(); - itemListener = new ItemListener(); - joinQuitListener = new JoinQuitListener(); - lobbyCancelListener = new LobbyCancelListener(); - clientManager = new ClientManager(); - } -} + @Getter + static FalchusLibMinecraftSpigot instance; + + LabyModMessageListener labyModMessageListener; + LunarMessageListener lunarMessageListener; + EntityPlayerListener entityPlayerListener; + FreezeListener freezeListener; + ItemListener itemListener; + JoinQuitListener joinQuitListener; + LobbyCancelListener lobbyCancelListener; + ClientManager clientManager; + + @Override + public void onEnable() { + instance = this; + + if (FalchusLibMinecraft.isFolia()) { + getLogger().info("Folia detected — using Folia-compatible scheduler."); + } + + new Metrics(this, 28050); + + getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); + + labyModMessageListener = new LabyModMessageListener(); + lunarMessageListener = new LunarMessageListener(); + entityPlayerListener = new EntityPlayerListener(); + freezeListener = new FreezeListener(); + itemListener = new ItemListener(); + joinQuitListener = new JoinQuitListener(); + lobbyCancelListener = new LobbyCancelListener(); + clientManager = new ClientManager(); + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Biome.java b/src/com/falchus/lib/minecraft/spigot/enums/Biome.java index 93d516ce..bbecf5cc 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Biome.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Biome.java @@ -6,7 +6,7 @@ @AllArgsConstructor @Getter public enum Biome { - HELL("NETHER_WASTES"); - - private final String modernName; + HELL("NETHER_WASTES"); + + private final String modernName; } diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Client.java b/src/com/falchus/lib/minecraft/spigot/enums/Client.java index de770449..ce33b0fc 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Client.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Client.java @@ -1,7 +1,7 @@ package com.falchus.lib.minecraft.spigot.enums; public enum Client { - LABYMOD, - LUNAR, - OTHER + LABYMOD, + LUNAR, + OTHER } diff --git a/src/com/falchus/lib/minecraft/spigot/enums/GameRule.java b/src/com/falchus/lib/minecraft/spigot/enums/GameRule.java index d3a25485..3a7ad0a9 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/GameRule.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/GameRule.java @@ -6,21 +6,21 @@ @AllArgsConstructor @Getter public enum GameRule { - COMMAND_BLOCK_OUTPUT("commandBlockOutput"), - DO_DAYLIGHT_CYCLE("doDaylightCycle"), - DO_ENTITY_DROPS("doEntityDrops"), - DO_FIRE_TICK("doFireTick"), - DO_MOB_LOOT("doMobLoot"), - DO_MOB_SPAWNING("doMobSpawning"), - DO_TILE_DROPS("doTileDrops"), - KEEP_INVENTORY("keepInventory"), - LOG_ADMIN_COMMANDS("logAdminCommands"), - MOB_GRIEFING("mobGriefing"), - NATURAL_REGENERATION("naturalRegeneration"), - RANDOM_TICK_SPEED("randomTickSpeed"), - REDUCED_DEBUG_INFO("reducedDebugInfo"), - SEND_COMMAND_FEEDBACK("sendCommandFeedback"), - SHOW_DEATH_MESSAGES("showDeathMessages"); - - private final String key; + COMMAND_BLOCK_OUTPUT("commandBlockOutput"), + DO_DAYLIGHT_CYCLE("doDaylightCycle"), + DO_ENTITY_DROPS("doEntityDrops"), + DO_FIRE_TICK("doFireTick"), + DO_MOB_LOOT("doMobLoot"), + DO_MOB_SPAWNING("doMobSpawning"), + DO_TILE_DROPS("doTileDrops"), + KEEP_INVENTORY("keepInventory"), + LOG_ADMIN_COMMANDS("logAdminCommands"), + MOB_GRIEFING("mobGriefing"), + NATURAL_REGENERATION("naturalRegeneration"), + RANDOM_TICK_SPEED("randomTickSpeed"), + REDUCED_DEBUG_INFO("reducedDebugInfo"), + SEND_COMMAND_FEEDBACK("sendCommandFeedback"), + SHOW_DEATH_MESSAGES("showDeathMessages"); + + private final String key; } diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Material.java b/src/com/falchus/lib/minecraft/spigot/enums/Material.java index 1926d418..ec6b8702 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Material.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Material.java @@ -6,52 +6,52 @@ @AllArgsConstructor @Getter public enum Material { - BLACK_WOOL(15, "WOOL"), - BLUE_WOOL(11, "WOOL"), - CAULDRON("CAULDRON_ITEM"), - CLOCK("WATCH"), - COBBLESTONE_WALL("COBBLE_WALL"), - COBWEB("WEB"), - DANDELION("YELLOW_FLOWER"), - ENCHANTING_TABLE("ENCHANTMENT_TABLE"), - ENDER_EYE("EYE_OF_ENDER"), - END_STONE("ENDER_STONE"), - EXPERIENCE_BOTTLE("EXP_BOTTLE"), - GRASS_BLOCK("GRASS"), - GRAY_STAINED_GLASS_PANE(7, "STAINED_GLASS_PANE"), - GRAY_WOOL(7, "WOOL"), - GREEN_WOOL(13, "WOOL"), - LAPIS_LAZULI(4, "INK_SACK"), - LAVA("STATIONARY_LAVA"), - LIGHT_BLUE_WOOL(3, "WOOL"), - LIME_STAINED_GLASS_PANE(5, "STAINED_GLASS_PANE"), - LIME_WOOL(5, "WOOL"), - NETHER_BRICKS("NETHER_BRICK"), - OAK_FENCE("FENCE"), - OAK_FENCE_GATE("FENCE_GATE"), - OAK_LOG("LOG"), - OAK_PLANKS("WOOD"), - ORANGE_WOOL(1, "WOOL"), - PINK_WOOL(6, "WOOL"), - PLAYER_HEAD(3, "SKULL_ITEM"), - POPPY("RED_ROSE"), - PURPLE_WOOL(10, "WOOL"), - QUARTZ_SLAB(7, "STEP"), - RED_BED("BED"), - RED_DYE(1, "INK_SACK"), - RED_STAINED_GLASS_PANE(14, "STAINED_GLASS_PANE"), - RED_WOOL(14, "WOOL"), - SNOWBALL("SNOW_BALL"), - WATER("STATIONARY_WATER"), - WOODEN_AXE("WOOD_AXE"), - WOODEN_SWORD("WOOD_SWORD"), - YELLOW_STAINED_GLASS_PANE(4, "STAINED_GLASS_PANE"), - YELLOW_WOOL(4, "WOOL"); - - private final int legacyDurability; - private final String legacyName; - - Material(String legacyName) { - this(0, legacyName); - } + BLACK_WOOL(15, "WOOL"), + BLUE_WOOL(11, "WOOL"), + CAULDRON("CAULDRON_ITEM"), + CLOCK("WATCH"), + COBBLESTONE_WALL("COBBLE_WALL"), + COBWEB("WEB"), + DANDELION("YELLOW_FLOWER"), + ENCHANTING_TABLE("ENCHANTMENT_TABLE"), + ENDER_EYE("EYE_OF_ENDER"), + END_STONE("ENDER_STONE"), + EXPERIENCE_BOTTLE("EXP_BOTTLE"), + GRASS_BLOCK("GRASS"), + GRAY_STAINED_GLASS_PANE(7, "STAINED_GLASS_PANE"), + GRAY_WOOL(7, "WOOL"), + GREEN_WOOL(13, "WOOL"), + LAPIS_LAZULI(4, "INK_SACK"), + LAVA("STATIONARY_LAVA"), + LIGHT_BLUE_WOOL(3, "WOOL"), + LIME_STAINED_GLASS_PANE(5, "STAINED_GLASS_PANE"), + LIME_WOOL(5, "WOOL"), + NETHER_BRICKS("NETHER_BRICK"), + OAK_FENCE("FENCE"), + OAK_FENCE_GATE("FENCE_GATE"), + OAK_LOG("LOG"), + OAK_PLANKS("WOOD"), + ORANGE_WOOL(1, "WOOL"), + PINK_WOOL(6, "WOOL"), + PLAYER_HEAD(3, "SKULL_ITEM"), + POPPY("RED_ROSE"), + PURPLE_WOOL(10, "WOOL"), + QUARTZ_SLAB(7, "STEP"), + RED_BED("BED"), + RED_DYE(1, "INK_SACK"), + RED_STAINED_GLASS_PANE(14, "STAINED_GLASS_PANE"), + RED_WOOL(14, "WOOL"), + SNOWBALL("SNOW_BALL"), + WATER("STATIONARY_WATER"), + WOODEN_AXE("WOOD_AXE"), + WOODEN_SWORD("WOOD_SWORD"), + YELLOW_STAINED_GLASS_PANE(4, "STAINED_GLASS_PANE"), + YELLOW_WOOL(4, "WOOL"); + + private final int legacyDurability; + private final String legacyName; + + Material(String legacyName) { + this(0, legacyName); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Sound.java b/src/com/falchus/lib/minecraft/spigot/enums/Sound.java index 10b57b1c..4e523c13 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Sound.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Sound.java @@ -6,20 +6,20 @@ @AllArgsConstructor @Getter public enum Sound { - LEVEL_UP("ENTITY_PLAYER_LEVELUP"), - VILLAGER_NO("ENTITY_VILLAGER_NO"), - NOTE_PLING("BLOCK_NOTE_BLOCK_PLING"), - NOTE_BASS("BLOCK_NOTE_BLOCK_BASS"), - NOTE_BASS_DRUM("BLOCK_NOTE_BLOCK_BASEDRUM"), - AMBIENCE_THUNDER("ENTITY_LIGHTNING_BOLT_THUNDER"), - CHEST_OPEN("BLOCK_CHEST_OPEN"), - CHEST_CLOSE("BLOCK_CHEST_CLOSE"), - CHICKEN_EGG_POP("ENTITY_CHICKEN_EGG"), - ENDERDRAGON_GROWL("ENTITY_ENDER_DRAGON_GROWL"), - BURP("ENTITY_PLAYER_BURP"), - FIREWORK_LARGE_BLAST2("ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR"), - ANVIL_LAND("BLOCK_ANVIL_LAND"), - BAT_TAKEOFF("ENTITY_BAT_TAKEOFF"); - - private final String modernName; + LEVEL_UP("ENTITY_PLAYER_LEVELUP"), + VILLAGER_NO("ENTITY_VILLAGER_NO"), + NOTE_PLING("BLOCK_NOTE_BLOCK_PLING"), + NOTE_BASS("BLOCK_NOTE_BLOCK_BASS"), + NOTE_BASS_DRUM("BLOCK_NOTE_BLOCK_BASEDRUM"), + AMBIENCE_THUNDER("ENTITY_LIGHTNING_BOLT_THUNDER"), + CHEST_OPEN("BLOCK_CHEST_OPEN"), + CHEST_CLOSE("BLOCK_CHEST_CLOSE"), + CHICKEN_EGG_POP("ENTITY_CHICKEN_EGG"), + ENDERDRAGON_GROWL("ENTITY_ENDER_DRAGON_GROWL"), + BURP("ENTITY_PLAYER_BURP"), + FIREWORK_LARGE_BLAST2("ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR"), + ANVIL_LAND("BLOCK_ANVIL_LAND"), + BAT_TAKEOFF("ENTITY_BAT_TAKEOFF"); + + public final String modernName; } diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Version.java b/src/com/falchus/lib/minecraft/spigot/enums/Version.java index 91fc3cf1..13da3592 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Version.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Version.java @@ -2,35 +2,39 @@ import lombok.AllArgsConstructor; import lombok.Getter; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; @Getter @AllArgsConstructor public enum Version { - v1_7(1, 7), - v1_8(1, 8), - v1_9(1, 9), - v1_10(1, 10), - v1_11(1, 11), - v1_12(1, 12), - v1_13(1, 13), - v1_14(1, 14), - v1_15(1, 15), - v1_16(1, 16), - v1_17(1, 17), - v1_18(1, 18), - v1_19(1, 19), - v1_20(1, 20), - v1_21(1, 21), - v26_1(26, 1); - - private final int major; - private final int minor; - - public boolean isAfter(Version version) { - return major > version.major || (major == version.major && minor > version.minor); - } - - public boolean isBefore(Version version) { - return major < version.major || (major == version.major && minor < version.minor); - } -} + v1_7(1, 7), + v1_8(1, 8), + v1_9(1, 9), + v1_10(1, 10), + v1_11(1, 11), + v1_12(1, 12), + v1_13(1, 13), + v1_14(1, 14), + v1_15(1, 15), + v1_16(1, 16), + v1_17(1, 17), + v1_18(1, 18), + v1_19(1, 19), + v1_20(1, 20), + v1_21(1, 21), + v26_1(26, 1); + + private final int major; + private final int minor; + + @Contract(pure = true) + public boolean isAfter(@NotNull Version version) { + return major > version.major || (major == version.major && minor > version.minor); + } + + @Contract(pure = true) + public boolean isBefore(@NotNull Version version) { + return major < version.major || (major == version.major && minor < version.minor); + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/events/LobbyCancelEvent.java b/src/com/falchus/lib/minecraft/spigot/events/LobbyCancelEvent.java index 161ab79a..ff234019 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/LobbyCancelEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/LobbyCancelEvent.java @@ -1,12 +1,11 @@ package com.falchus.lib.minecraft.spigot.events; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Called when there's a event that should be cancelled in a Lobby. @@ -15,13 +14,14 @@ @RequiredArgsConstructor public class LobbyCancelEvent extends Event implements Cancellable { - @Getter private static final HandlerList handlerList = new HandlerList(); - @Setter private boolean cancelled; - - private final Event event; - - @Override - public HandlerList getHandlers() { - return handlerList; - } + @Getter + private static final HandlerList handlerList = new HandlerList(); + private final Event event; + @Setter + private boolean cancelled; + + @Override + public HandlerList getHandlers() { + return handlerList; + } } diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java index e4749a70..234d6e93 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java @@ -1,13 +1,11 @@ package com.falchus.lib.minecraft.spigot.events.player; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - import com.falchus.lib.minecraft.spigot.enums.Client; - import lombok.AllArgsConstructor; import lombok.Getter; +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; /** * Called when a player's client has been identified after joining. @@ -16,13 +14,14 @@ @Getter public class PlayerClientJoinEvent extends Event { - @Getter private static final HandlerList handlerList = new HandlerList(); - - private final Player player; - private final Client client; - - @Override - public HandlerList getHandlers() { - return handlerList; - } + @Getter + private static final HandlerList handlerList = new HandlerList(); + + private final Player player; + private final Client client; + + @Override + public HandlerList getHandlers() { + return handlerList; + } } diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java index 153bef5f..405d57bf 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java @@ -1,35 +1,34 @@ package com.falchus.lib.minecraft.spigot.events.player; +import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; +import lombok.Getter; +import lombok.Setter; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - -import lombok.Getter; -import lombok.Setter; - /** * Called when a player receives/sends a packet. */ @Getter public class PlayerPacketEvent extends Event implements Cancellable { - @Getter private static final HandlerList handlerList = new HandlerList(); - @Setter private boolean cancelled; - - private final Player player; - private final PacketWrapper packet; - - public PlayerPacketEvent(boolean async, Player player, PacketWrapper packet) { - super(async); - this.player = player; - this.packet = packet; - } - - @Override - public HandlerList getHandlers() { - return handlerList; - } + @Getter + private static final HandlerList handlerList = new HandlerList(); + private final Player player; + private final PacketWrapper packet; + @Setter + private boolean cancelled; + + public PlayerPacketEvent(boolean async, Player player, PacketWrapper packet) { + super(async); + this.player = player; + this.packet = packet; + } + + @Override + public HandlerList getHandlers() { + return handlerList; + } } diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketInEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketInEvent.java index 5aaf93bd..52ceff7f 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketInEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketInEvent.java @@ -1,18 +1,16 @@ package com.falchus.lib.minecraft.spigot.events.player; -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.Getter; +import org.bukkit.entity.Player; /** * Called when a player receives a packet. */ @Getter public class PlayerPacketInEvent extends PlayerPacketEvent { - - public PlayerPacketInEvent(boolean async, Player player, PacketWrapper packet) { - super(async, player, packet); - } + + public PlayerPacketInEvent(boolean async, Player player, PacketWrapper packet) { + super(async, player, packet); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketOutEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketOutEvent.java index b79e5880..f8ac09ca 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketOutEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketOutEvent.java @@ -1,18 +1,16 @@ package com.falchus.lib.minecraft.spigot.events.player; -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.Getter; +import org.bukkit.entity.Player; /** * Called when a player sends a packet. */ @Getter public class PlayerPacketOutEvent extends PlayerPacketEvent { - - public PlayerPacketOutEvent(boolean async, Player player, PacketWrapper packet) { - super(async, player, packet); - } + + public PlayerPacketOutEvent(boolean async, Player player, PacketWrapper packet) { + super(async, player, packet); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/EntityPlayerListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/EntityPlayerListener.java index 9c7b9860..b39c3156 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/EntityPlayerListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/EntityPlayerListener.java @@ -18,16 +18,16 @@ public class EntityPlayerListener implements Listener { private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); public final Map players = new HashMap<>(); public final Map> actions = new HashMap<>(); - + public EntityPlayerListener() { Bukkit.getPluginManager().registerEvents(this, plugin); } - + @EventHandler public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { if (!(event.getRightClicked() instanceof Player player)) return; UUID uuid = player.getUniqueId(); - + if (players.containsKey(uuid)) { Consumer action = actions.get(uuid); if (action != null) { diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/FreezeListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/FreezeListener.java index ab00a3b8..7052720c 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/FreezeListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/FreezeListener.java @@ -35,59 +35,59 @@ public class FreezeListener implements Listener { private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); public final Set players = new HashSet<>(); - + public FreezeListener() { Bukkit.getPluginManager().registerEvents(this, plugin); } - + @EventHandler public void onPlayerMove(PlayerMoveEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; - + Location from = event.getFrom(); Location to = event.getTo(); if (from.getBlockX() != to.getBlockX() || from.getBlockZ() != to.getBlockZ()) { event.setTo(from); } } - + @EventHandler(ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) - public void onInventoryClick(InventoryClickEvent event) { + public void onInventoryClick(InventoryClickEvent event) { if (!players.contains(event.getWhoClicked().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { if (!players.contains(event.getEntity().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof Player player) { if (players.contains(player.getUniqueId())) { event.setCancelled(true); } - + if (event.getDamager() instanceof Player damager) { if (players.contains(damager.getUniqueId())) { event.setCancelled(true); @@ -95,73 +95,73 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { } } } - + @EventHandler(ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerDropItem(PlayerDropItemEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerPickupItem(PlayerPickupItemEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) - public void onFoodLevelChange(FoodLevelChangeEvent event) { + public void onFoodLevelChange(FoodLevelChangeEvent event) { if (!players.contains(event.getEntity().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onHangingBreak(HangingBreakEvent event) { if (!players.contains(event.getEntity().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerBucketFill(PlayerBucketFillEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerShearEntity(PlayerShearEntityEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerArmorStandManipulate(PlayerArmorStandManipulateEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerChat(AsyncPlayerChatEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/ItemListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/ItemListener.java index 5575b989..ea94da22 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/ItemListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/ItemListener.java @@ -20,16 +20,16 @@ public class ItemListener implements Listener { private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - + public ItemListener() { Bukkit.getPluginManager().registerEvents(this, plugin); } - + @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { ItemStack item = event.getItem(); if (item == null) return; - + UUID uuid = ItemUtils.getUUID(item); if (uuid != null) { Consumer action = ItemUtils.itemActions.get(uuid); @@ -46,7 +46,7 @@ public void onInventoryClick(InventoryClickEvent event) { ItemStack item = event.getCurrentItem(); if (item == null) return; - + UUID uuid = ItemUtils.getUUID(item); if (uuid != null) { TriConsumer action = ItemUtils.itemActionsInventory.get(uuid); @@ -63,7 +63,7 @@ public void onInventoryClick(InventoryClickEvent event) { callback.accept(player, item, event); } } - + // TODO: search for a better, more bulletproof solution // @EventHandler // public void onInventoryClose(InventoryCloseEvent event) { diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/JoinQuitListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/JoinQuitListener.java index 89d8725b..e57d5542 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/JoinQuitListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/JoinQuitListener.java @@ -1,5 +1,10 @@ package com.falchus.lib.minecraft.spigot.listeners; +import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; +import com.falchus.lib.minecraft.spigot.packets.PacketInjector; +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; +import com.falchus.lib.minecraft.spigot.player.elements.impl.*; +import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -7,71 +12,62 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; - -import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; -import com.falchus.lib.minecraft.spigot.packets.PacketInjector; -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; -import com.falchus.lib.minecraft.spigot.player.elements.impl.Actionbar; -import com.falchus.lib.minecraft.spigot.player.elements.impl.Bossbar; -import com.falchus.lib.minecraft.spigot.player.elements.impl.Chat; -import com.falchus.lib.minecraft.spigot.player.elements.impl.Nametag; -import com.falchus.lib.minecraft.spigot.player.elements.impl.Scoreboard; -import com.falchus.lib.minecraft.spigot.player.elements.impl.Tablist; -import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; +import org.jetbrains.annotations.NotNull; public class JoinQuitListener implements Listener { - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - public JoinQuitListener() { - Bukkit.getPluginManager().registerEvents(this, plugin); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerJoin_LOWEST(PlayerJoinEvent event) { - PacketInjector.inject(event.getPlayer()); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - PlayerElement.updateAll(Actionbar.class); - PlayerElement.updateAll(Bossbar.class); - PlayerElement.updateAll(Chat.class); - PlayerElement.updateAll(Nametag.class); - PlayerElement.updateAll(Scoreboard.class); - PlayerElement.updateAll(Tablist.class); - } - - @EventHandler(priority = EventPriority.HIGH) - public void onPlayerJoin_HIGH(PlayerJoinEvent event) { - Player player = event.getPlayer(); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - if (PlayerUtils.vanished.contains(player.getUniqueId())) { - onlinePlayer.hidePlayer(player); - } else { - onlinePlayer.showPlayer(player); - } - if (PlayerUtils.vanished.contains(onlinePlayer.getUniqueId())) { - player.hidePlayer(onlinePlayer); - } else { - player.showPlayer(onlinePlayer); - } - } - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - PlayerElement.updateAll(Actionbar.class); - PlayerElement.updateAll(Bossbar.class); - PlayerElement.updateAll(Chat.class); - PlayerElement.updateAll(Nametag.class); - PlayerElement.updateAll(Scoreboard.class); - PlayerElement.updateAll(Tablist.class); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onPlayerQuit_HIGHEST(PlayerQuitEvent event) { - PacketInjector.uninject(event.getPlayer()); - } -} + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + public JoinQuitListener() { + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerJoin_LOWEST(@NotNull PlayerJoinEvent event) { + PacketInjector.inject(event.getPlayer()); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + PlayerElement.updateAll(Actionbar.class); + PlayerElement.updateAll(Bossbar.class); + PlayerElement.updateAll(Chat.class); + PlayerElement.updateAll(Nametag.class); + PlayerElement.updateAll(Scoreboard.class); + PlayerElement.updateAll(Tablist.class); + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerJoin_HIGH(@NotNull PlayerJoinEvent event) { + Player joining = event.getPlayer(); + + for (Player online : Bukkit.getOnlinePlayers()) { + if (PlayerUtils.vanished.contains(joining.getUniqueId())) { + online.hidePlayer(plugin, joining); + } else { + online.showPlayer(plugin, joining); + } + + if (PlayerUtils.vanished.contains(online.getUniqueId())) { + joining.hidePlayer(plugin, online); + } else { + joining.showPlayer(plugin, online); + } + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + PlayerElement.updateAll(Actionbar.class); + PlayerElement.updateAll(Bossbar.class); + PlayerElement.updateAll(Chat.class); + PlayerElement.updateAll(Nametag.class); + PlayerElement.updateAll(Scoreboard.class); + PlayerElement.updateAll(Tablist.class); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerQuit_HIGHEST(@NotNull PlayerQuitEvent event) { + PacketInjector.uninject(event.getPlayer()); + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/LobbyCancelListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/LobbyCancelListener.java index 19be8239..f3be77d9 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/LobbyCancelListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/LobbyCancelListener.java @@ -38,188 +38,188 @@ public class LobbyCancelListener implements Listener { private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - + public LobbyCancelListener() { Bukkit.getPluginManager().registerEvents(this, plugin); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onInventoryClick(InventoryClickEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockPhysics(BlockPhysicsEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockFade(BlockFadeEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockForm(BlockFormEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerDropItem(PlayerDropItemEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerPickupItem(PlayerPickupItemEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onFoodLevelChange(FoodLevelChangeEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onHangingBreak(HangingBreakEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntitySpawn(EntitySpawnEvent event) { if (event.getEntityType() == EntityType.ARMOR_STAND) return; - + LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onItemSpawn(ItemSpawnEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerBucketFill(PlayerBucketFillEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerShearEntity(PlayerShearEntityEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerArmorStandManipulate(PlayerArmorStandManipulateEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityTarget(EntityTargetEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleDamage(VehicleDamageEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleDestroy(VehicleDestroyEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/message/LabyModMessageListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/message/LabyModMessageListener.java index 02a2c4e0..e72419a2 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/message/LabyModMessageListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/message/LabyModMessageListener.java @@ -13,9 +13,9 @@ import io.netty.buffer.Unpooled; public class LabyModMessageListener implements PluginMessageListener { - + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - + public LabyModMessageListener() { plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, "labymod3:main", this); plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "labymod3:main"); @@ -24,10 +24,10 @@ public LabyModMessageListener() { @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { if (!channel.equals("labymod3:main")) return; - + ByteBuf buf = Unpooled.wrappedBuffer(message); String key = LabyModProtocol.readString(buf, Short.MAX_VALUE); - + // LabyMod user joins the server if (key.equals("INFO")) { plugin.getClientManager().set(player, Client.LABYMOD); diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/message/LunarMessageListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/message/LunarMessageListener.java index 27ff0ef4..1697ab71 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/message/LunarMessageListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/message/LunarMessageListener.java @@ -15,39 +15,39 @@ import com.google.gson.JsonObject; public class LunarMessageListener implements Listener { - + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - + public LunarMessageListener() { Messenger messenger = Bukkit.getServer().getMessenger(); messenger.registerIncomingPluginChannel(plugin, "lunar:apollo", (s, player, bytes) -> { }); messenger.registerIncomingPluginChannel(plugin, "apollo:json", (s, player, bytes) -> { }); messenger.registerOutgoingPluginChannel(plugin, "apollo:json"); - + Bukkit.getPluginManager().registerEvents(this, plugin); } @EventHandler private void onRegisterChannel(PlayerRegisterChannelEvent event) { if (!event.getChannel().equalsIgnoreCase("lunar:apollo")) return; - + Player player = event.getPlayer(); - + // Sending the player's world name to the client is required for some modules LunarJsonPacketUtil.sendPacket(player, createUpdatePlayerWorldMessage(player)); - + plugin.getClientManager().set(player, Client.LUNAR); Bukkit.getPluginManager().callEvent(new PlayerClientJoinEvent(player, Client.LUNAR)); } - + @EventHandler private void onPlayerChangedWorld(PlayerChangedWorldEvent event) { Player player = event.getPlayer(); - + // Sending the player's world name to the client is required for some modules LunarJsonPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); } - + private JsonObject createUpdatePlayerWorldMessage(Player player) { JsonObject message = new JsonObject(); message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.player.v1.UpdatePlayerWorldMessage"); diff --git a/src/com/falchus/lib/minecraft/spigot/manager/ClientManager.java b/src/com/falchus/lib/minecraft/spigot/manager/ClientManager.java index e6e3f21a..997d6ccb 100644 --- a/src/com/falchus/lib/minecraft/spigot/manager/ClientManager.java +++ b/src/com/falchus/lib/minecraft/spigot/manager/ClientManager.java @@ -1,21 +1,20 @@ package com.falchus.lib.minecraft.spigot.manager; +import com.falchus.lib.minecraft.spigot.enums.Client; +import org.bukkit.entity.Player; + import java.util.HashMap; import java.util.Map; -import org.bukkit.entity.Player; +public class ClientManager { -import com.falchus.lib.minecraft.spigot.enums.Client; + private static final Map clients = new HashMap<>(); -public class ClientManager { + public static Client get(Player player) { + return clients.getOrDefault(player, Client.OTHER); + } - private static final Map clients = new HashMap<>(); - - public static Client get(Player player) { - return clients.getOrDefault(player, Client.OTHER); - } - - public void set(Player player, Client client) { - clients.put(player, client); - } + public void set(Player player, Client client) { + clients.put(player, client); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/PacketChannelHandler.java b/src/com/falchus/lib/minecraft/spigot/packets/PacketChannelHandler.java index f09a276f..2fdc18c2 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/PacketChannelHandler.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/PacketChannelHandler.java @@ -17,22 +17,22 @@ public class PacketChannelHandler extends ChannelDuplexHandler { private final Player player; - + @Override public void channelRead(ChannelHandlerContext ctx, Object packet) throws Exception { PlayerPacketEvent event = new PlayerPacketInEvent(!Bukkit.isPrimaryThread(), player, PacketWrapper.wrap(packet)); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; - + super.channelRead(ctx, packet); } - + @Override public void write(ChannelHandlerContext ctx, Object packet, ChannelPromise promise) throws Exception { PlayerPacketEvent event = new PlayerPacketOutEvent(!Bukkit.isPrimaryThread(), player, PacketWrapper.wrap(packet)); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; - + super.write(ctx, packet, promise); } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/PacketInjector.java b/src/com/falchus/lib/minecraft/spigot/packets/PacketInjector.java index 0a940bb6..9bd9aa73 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/PacketInjector.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/PacketInjector.java @@ -1,62 +1,60 @@ package com.falchus.lib.minecraft.spigot.packets; +import com.falchus.lib.FalchusLib; +import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; +import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; +import io.netty.channel.Channel; +import org.bukkit.entity.Player; + import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.entity.Player; +public class PacketInjector { -import com.falchus.lib.FalchusLib; -import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; -import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; + private static final Set injected = ConcurrentHashMap.newKeySet(); -import io.netty.channel.Channel; + public static void inject(Player player) { + UUID uuid = player.getUniqueId(); + if (!injected.add(uuid)) return; -public class PacketInjector { - - private static final Set injected = ConcurrentHashMap.newKeySet(); - - public static void inject(Player player) { - UUID uuid = player.getUniqueId(); - if (!injected.add(uuid)) return; - - try { - Object entityPlayer = PlayerUtils.getEntityPlayer(player); - - Object connection = VersionProvider.get().getEntityPlayer_playerConnection().get(entityPlayer); - Object networkManager = VersionProvider.get().getPlayerConnection_networkManager().get(connection); - Object ch = VersionProvider.get().getNetworkManager_channel().get(networkManager); - - Channel channel = (Channel) ch; - if (channel.pipeline().get(FalchusLib.nameFull + "_" + uuid) != null) return; - - channel.pipeline().addBefore("packet_handler", FalchusLib.nameFull + "_" + uuid, new PacketChannelHandler(player)); - } catch (Exception e) { - injected.remove(uuid); - throw new RuntimeException(e); - } - } - - public static void uninject(Player player) { - UUID uuid = player.getUniqueId(); - if (!injected.remove(uuid)) return; - - try { - Object entityPlayer = PlayerUtils.getEntityPlayer(player); - - Object connection = VersionProvider.get().getEntityPlayer_playerConnection().get(entityPlayer); - Object networkManager = VersionProvider.get().getPlayerConnection_networkManager().get(connection); - Object ch = VersionProvider.get().getNetworkManager_channel().get(networkManager); - - Channel channel = (Channel) ch; - if (channel.pipeline().get(FalchusLib.nameFull + "_" + uuid) == null) return; - - channel.eventLoop().submit(() -> { - channel.pipeline().remove(FalchusLib.nameFull + "_" + uuid); - return null; - }); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + try { + Object entityPlayer = PlayerUtils.getEntityPlayer(player); + + Object connection = VersionProvider.get().getEntityPlayer_playerConnection().get(entityPlayer); + Object networkManager = VersionProvider.get().getPlayerConnection_networkManager().get(connection); + Object ch = VersionProvider.get().getNetworkManager_channel().get(networkManager); + + Channel channel = (Channel) ch; + if (channel.pipeline().get(FalchusLib.nameFull + "_" + uuid) != null) return; + + channel.pipeline().addBefore("packet_handler", FalchusLib.nameFull + "_" + uuid, new PacketChannelHandler(player)); + } catch (Exception e) { + injected.remove(uuid); + throw new RuntimeException(e); + } + } + + public static void uninject(Player player) { + UUID uuid = player.getUniqueId(); + if (!injected.remove(uuid)) return; + + try { + Object entityPlayer = PlayerUtils.getEntityPlayer(player); + + Object connection = VersionProvider.get().getEntityPlayer_playerConnection().get(entityPlayer); + Object networkManager = VersionProvider.get().getPlayerConnection_networkManager().get(connection); + Object ch = VersionProvider.get().getNetworkManager_channel().get(networkManager); + + Channel channel = (Channel) ch; + if (channel.pipeline().get(FalchusLib.nameFull + "_" + uuid) == null) return; + + channel.eventLoop().submit(() -> { + channel.pipeline().remove(FalchusLib.nameFull + "_" + uuid); + return null; + }); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/PacketWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/PacketWrapper.java index 1dc01e87..d1c196bc 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/PacketWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/PacketWrapper.java @@ -1,83 +1,83 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; - -import com.falchus.lib.minecraft.spigot.packets.wrapper.chat.*; +import com.falchus.lib.minecraft.spigot.packets.wrapper.chat.WrappedPacketInChat; +import com.falchus.lib.minecraft.spigot.packets.wrapper.chat.WrappedPacketOutChat; import com.falchus.lib.minecraft.spigot.utils.version.IVersionAdapter; import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; import com.falchus.lib.utils.builder.ClassInstanceBuilder; import com.falchus.lib.utils.reflection.Dummy; import com.falchus.lib.utils.wrapper.impl.FirstClassWrapper; - import lombok.NonNull; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + public class PacketWrapper extends FirstClassWrapper { - - protected static final IVersionAdapter version = VersionProvider.get(); - private static final String networkProtocol = version.getPackageNm() + "network.protocol."; - protected static final String networkProtocolCommon = networkProtocol + "common."; - protected static final String networkProtocolGame = networkProtocol + "game."; - private static final Map, Function> registry = new HashMap<>(); - - public PacketWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } - - @SuppressWarnings("unchecked") - private static void register() { - if (!registry.isEmpty()) return; - Class[] wrappers = new Class[] { - WrappedPacketInChat.class, - WrappedPacketOutChat.class - }; - - for (Class wrapper : wrappers) { - try { - PacketWrapper dummy = (T) new ClassInstanceBuilder( - wrapper - ).withParams( - Map.of( - Object.class, - Dummy.instance - ) - ).build(); - for (Class clazz : dummy.getClasses()) { - registry.put(clazz, obj -> { - try { - return (T) new ClassInstanceBuilder( - wrapper - ).withParams( - Map.of( - Object.class, - obj - ) - ).build(); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - public static PacketWrapper wrap(Object packet) { - register(); - - Function wrapper = registry.get(packet.getClass()); - if (wrapper != null) { - return wrapper.apply(packet); - } - return new PacketWrapper(packet, Set.of(packet.getClass().getName())); - } - - public T as(@NonNull Class clazz) { - return as(clazz, Object.class); - } + protected static final IVersionAdapter version = VersionProvider.get(); + private static final String networkProtocol = version.getPackageNm() + "network.protocol."; + protected static final String networkProtocolCommon = networkProtocol + "common."; + protected static final String networkProtocolGame = networkProtocol + "game."; + + private static final Map, Function> registry = new HashMap<>(); + + public PacketWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } + + @SuppressWarnings("unchecked") + private static void register() { + if (!registry.isEmpty()) return; + Class[] wrappers = new Class[]{ + WrappedPacketInChat.class, + WrappedPacketOutChat.class + }; + + for (Class wrapper : wrappers) { + try { + PacketWrapper dummy = (T) new ClassInstanceBuilder( + wrapper + ).withParams( + Map.of( + Object.class, + Dummy.instance + ) + ).build(); + for (Class clazz : dummy.getClasses()) { + registry.put(clazz, obj -> { + try { + return (T) new ClassInstanceBuilder( + wrapper + ).withParams( + Map.of( + Object.class, + obj + ) + ).build(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + public static PacketWrapper wrap(Object packet) { + register(); + + Function wrapper = registry.get(packet.getClass()); + if (wrapper != null) { + return wrapper.apply(packet); + } + return new PacketWrapper(packet, Set.of(packet.getClass().getName())); + } + + public T as(@NonNull Class clazz) { + return as(clazz, Object.class); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/PacketAbilitiesWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/PacketAbilitiesWrapper.java index 5ea10604..95546d13 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/PacketAbilitiesWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/PacketAbilitiesWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.abilities; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketAbilitiesWrapper extends PacketWrapper { - - Field flying; - - PacketAbilitiesWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - flying = getFirstField( - "isFlying", - "b" - ); - } - - public void setFlying(boolean isFlying) { - setField(this.flying, isFlying); - } - - public boolean isFlying() { - return getFieldValue(flying); - } + + Field flying; + + PacketAbilitiesWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + flying = getFirstField( + "isFlying", + "b" + ); + } + + public boolean isFlying() { + return getFieldValue(flying); + } + + public void setFlying(boolean isFlying) { + setField(this.flying, isFlying); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketInAbilities.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketInAbilities.java index 85fe2335..3a9376a3 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketInAbilities.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketInAbilities.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.abilities; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInAbilities extends PacketAbilitiesWrapper { - public WrappedPacketInAbilities(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInAbilities", - networkProtocolGame + "PacketPlayInAbilities" - ) - ); - } + public WrappedPacketInAbilities(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInAbilities", + networkProtocolGame + "PacketPlayInAbilities" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketOutAbilities.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketOutAbilities.java index 1ab03714..cf30da25 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketOutAbilities.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketOutAbilities.java @@ -1,84 +1,84 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.abilities; +import lombok.NonNull; + import java.lang.reflect.Field; import java.util.Set; -import lombok.NonNull; - public class WrappedPacketOutAbilities extends PacketAbilitiesWrapper { - Field invulnerable; - Field canFly; - Field instabuild; - Field flyingSpeed; - Field walkingSpeed; - - public WrappedPacketOutAbilities(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutAbilities", - networkProtocolGame + "PacketPlayOutAbilities" - ) - ); - - invulnerable = getFirstField( - "invulnerable", - "a" - ); - canFly = getFirstField( - "canFly", - "c" - ); - instabuild = getFirstField( - "instabuild", - "d" - ); - flyingSpeed = getFirstField( - "flyingSpeed", - "e" - ); - walkingSpeed = getFirstField( - "walkingSpeed", - "f" - ); - } - - public void setInvulnerable(boolean invulnerable) { - setField(this.invulnerable, invulnerable); - } - - public void setCanFly(boolean canFly) { - setField(this.canFly, canFly); - } - - public void setInstabuild(boolean instabuild) { - setField(this.instabuild, instabuild); - } - - public void setFlyingSpeed(float flyingSpeed) { - setField(this.flyingSpeed, flyingSpeed); - } - - public void setWalkingSpeed(float walkingSpeed) { - setField(this.walkingSpeed, walkingSpeed); - } - - public boolean isInvulnerable() { - return getFieldValue(invulnerable); - } - - public boolean isCanFly() { - return getFieldValue(canFly); - } - - public boolean isInstabuild() { - return getFieldValue(instabuild); - } - - public float getFlyingSpeed() { - return getFieldValue(flyingSpeed); - } - - public float getWalkingSpeed() { - return getFieldValue(walkingSpeed); - } + Field invulnerable; + Field canFly; + Field instabuild; + Field flyingSpeed; + Field walkingSpeed; + + public WrappedPacketOutAbilities(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutAbilities", + networkProtocolGame + "PacketPlayOutAbilities" + ) + ); + + invulnerable = getFirstField( + "invulnerable", + "a" + ); + canFly = getFirstField( + "canFly", + "c" + ); + instabuild = getFirstField( + "instabuild", + "d" + ); + flyingSpeed = getFirstField( + "flyingSpeed", + "e" + ); + walkingSpeed = getFirstField( + "walkingSpeed", + "f" + ); + } + + public boolean isInvulnerable() { + return getFieldValue(invulnerable); + } + + public void setInvulnerable(boolean invulnerable) { + setField(this.invulnerable, invulnerable); + } + + public boolean isCanFly() { + return getFieldValue(canFly); + } + + public void setCanFly(boolean canFly) { + setField(this.canFly, canFly); + } + + public boolean isInstabuild() { + return getFieldValue(instabuild); + } + + public void setInstabuild(boolean instabuild) { + setField(this.instabuild, instabuild); + } + + public float getFlyingSpeed() { + return getFieldValue(flyingSpeed); + } + + public void setFlyingSpeed(float flyingSpeed) { + setField(this.flyingSpeed, flyingSpeed); + } + + public float getWalkingSpeed() { + return getFieldValue(walkingSpeed); + } + + public void setWalkingSpeed(float walkingSpeed) { + setField(this.walkingSpeed, walkingSpeed); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/PacketAnimationWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/PacketAnimationWrapper.java index 2cc8b735..d342fa02 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/PacketAnimationWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/PacketAnimationWrapper.java @@ -1,45 +1,44 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.animation; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketAnimationWrapper extends PacketWrapper { - - Field id; - Field action; - - PacketAnimationWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - id = getFirstField( - "id", - "a" - ); - action = getFirstField( - "action", - "b" - ); - } - - public void setId(int id) { - setField(this.id, id); - } - - public void setAction(int action) { - setField(this.action, action); - } - - public int getId() { - return getFieldValue(id); - } - - public int getAction() { - return getFieldValue(action); - } + + Field id; + Field action; + + PacketAnimationWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + id = getFirstField( + "id", + "a" + ); + action = getFirstField( + "action", + "b" + ); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public int getAction() { + return getFieldValue(action); + } + + public void setAction(int action) { + setField(this.action, action); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/WrappedPacketOutAnimation.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/WrappedPacketOutAnimation.java index 1b59498f..5265621f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/WrappedPacketOutAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/WrappedPacketOutAnimation.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.animation; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutAnimation extends PacketAnimationWrapper { - public WrappedPacketOutAnimation(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutAnimation", - networkProtocolGame + "PacketPlayOutAnimation" - ) - ); - } + public WrappedPacketOutAnimation(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutAnimation", + networkProtocolGame + "PacketPlayOutAnimation" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/PacketArmAnimationWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/PacketArmAnimationWrapper.java index 000c4d2f..e5a84e3a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/PacketArmAnimationWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/PacketArmAnimationWrapper.java @@ -1,14 +1,13 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.armanimation; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; +import java.util.Set; + abstract class PacketArmAnimationWrapper extends PacketWrapper { - PacketArmAnimationWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketArmAnimationWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/WrappedPacketInArmAnimation.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/WrappedPacketInArmAnimation.java index 705b8b07..cc171ea8 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/WrappedPacketInArmAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/WrappedPacketInArmAnimation.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.armanimation; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInArmAnimation extends PacketArmAnimationWrapper { - public WrappedPacketInArmAnimation(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInArmAnimation", - networkProtocolGame + "PacketPlayInArmAnimation" - ) - ); - } + public WrappedPacketInArmAnimation(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInArmAnimation", + networkProtocolGame + "PacketPlayInArmAnimation" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/PacketAttachEntityWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/PacketAttachEntityWrapper.java index af2e2780..768e11ff 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/PacketAttachEntityWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/PacketAttachEntityWrapper.java @@ -1,45 +1,44 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.attachentity; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketAttachEntityWrapper extends PacketWrapper { - - Field sourceId; - Field destId; - - PacketAttachEntityWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - sourceId = getFirstField( - "sourceId", - "b" - ); - destId = getFirstField( - "destId", - "c" - ); - } - - public void setSourceId(int sourceId) { - setField(this.sourceId, sourceId); - } - - public void setDestId(int destId) { - setField(this.destId, destId); - } - - public int getSourceId() { - return getFieldValue(sourceId); - } - - public int getDestId() { - return getFieldValue(destId); - } + + Field sourceId; + Field destId; + + PacketAttachEntityWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + sourceId = getFirstField( + "sourceId", + "b" + ); + destId = getFirstField( + "destId", + "c" + ); + } + + public int getSourceId() { + return getFieldValue(sourceId); + } + + public void setSourceId(int sourceId) { + setField(this.sourceId, sourceId); + } + + public int getDestId() { + return getFieldValue(destId); + } + + public void setDestId(int destId) { + setField(this.destId, destId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/WrappedPacketOutAttachEntity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/WrappedPacketOutAttachEntity.java index 799bf6e6..f1ed59b2 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/WrappedPacketOutAttachEntity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/WrappedPacketOutAttachEntity.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.attachentity; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutAttachEntity extends PacketAttachEntityWrapper { - public WrappedPacketOutAttachEntity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutAttachEntity", - networkProtocolGame + "PacketPlayOutAttachEntity" - ) - ); - } + public WrappedPacketOutAttachEntity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutAttachEntity", + networkProtocolGame + "PacketPlayOutAttachEntity" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/PacketBlockActionWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/PacketBlockActionWrapper.java index 096c6d62..f35a6fea 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/PacketBlockActionWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/PacketBlockActionWrapper.java @@ -10,71 +10,71 @@ @FieldDefaults(makeFinal = true) abstract class PacketBlockActionWrapper extends PacketWrapper { - - Field pos; - Field type; - Field data; - Field block; - - PacketBlockActionWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - type = getFirstField( - "b0", - "b" - ); - data = getFirstField( - "b1", - "c" - ); - block = getFirstField( - "block", - "d" - ); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - public void setType(int type) { - setField(this.type, type); - } - - public void setData(int data) { - setField(this.data, data); - } - - /** - * @param block: Block - */ - public void setBlock(Object block) { - setField(this.block, block); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - public int getType() { - return getFieldValue(type); - } - - public int getData() { - return getFieldValue(data); - } - - public Object getBlock() { - return getFieldValue(block); - } + + Field pos; + Field type; + Field data; + Field block; + + PacketBlockActionWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + type = getFirstField( + "b0", + "b" + ); + data = getFirstField( + "b1", + "c" + ); + block = getFirstField( + "block", + "d" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } + + public int getType() { + return getFieldValue(type); + } + + public void setType(int type) { + setField(this.type, type); + } + + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } + + public Object getBlock() { + return getFieldValue(block); + } + + /** + * @param block: Block + */ + public void setBlock(Object block) { + setField(this.block, block); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/WrappedPacketOutBlockAction.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/WrappedPacketOutBlockAction.java index ce8e61c5..3949c619 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/WrappedPacketOutBlockAction.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/WrappedPacketOutBlockAction.java @@ -6,11 +6,11 @@ public class WrappedPacketOutBlockAction extends PacketBlockActionWrapper { - public WrappedPacketOutBlockAction(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutBlockAction", - networkProtocolGame + "PacketPlayOutBlockAction" - ) - ); - } + public WrappedPacketOutBlockAction(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutBlockAction", + networkProtocolGame + "PacketPlayOutBlockAction" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/PacketBlockBreakAnimationWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/PacketBlockBreakAnimationWrapper.java index c4f369a5..bfbb5d49 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/PacketBlockBreakAnimationWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/PacketBlockBreakAnimationWrapper.java @@ -1,64 +1,63 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.breakanimation; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketBlockBreakAnimationWrapper extends PacketWrapper { - - Field id; - Field pos; - Field progress; - - PacketBlockBreakAnimationWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - id = getFirstField( - "id", - "a" - ); - pos = getFirstField( - "pos", - "b" - ); - progress = getFirstField( - "progress", - "c" - ); - } - - public void setId(int id) { - setField(this.id, id); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - public void setProgress(int progress) { - setField(this.progress, progress); - } - - public int getId() { - return getFieldValue(id); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - public int getProgress() { - return getFieldValue(progress); - } + + Field id; + Field pos; + Field progress; + + PacketBlockBreakAnimationWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + id = getFirstField( + "id", + "a" + ); + pos = getFirstField( + "pos", + "b" + ); + progress = getFirstField( + "progress", + "c" + ); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } + + public int getProgress() { + return getFieldValue(progress); + } + + public void setProgress(int progress) { + setField(this.progress, progress); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/WrappedPacketOutBlockBreakAnimation.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/WrappedPacketOutBlockBreakAnimation.java index 126caef9..8d6b4555 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/WrappedPacketOutBlockBreakAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/WrappedPacketOutBlockBreakAnimation.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.breakanimation; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutBlockBreakAnimation extends PacketBlockBreakAnimationWrapper { - public WrappedPacketOutBlockBreakAnimation(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutBlockBreakAnimation", - networkProtocolGame + "PacketPlayOutBlockBreakAnimation" - ) - ); - } + public WrappedPacketOutBlockBreakAnimation(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutBlockBreakAnimation", + networkProtocolGame + "PacketPlayOutBlockBreakAnimation" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/PacketBlockChangeWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/PacketBlockChangeWrapper.java index efd9bb14..eced5465 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/PacketBlockChangeWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/PacketBlockChangeWrapper.java @@ -10,29 +10,29 @@ @FieldDefaults(makeFinal = true) abstract class PacketBlockChangeWrapper extends PacketWrapper { - - Field pos; - - PacketBlockChangeWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } + + Field pos; + + PacketBlockChangeWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/WrappedPacketOutBlockChange.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/WrappedPacketOutBlockChange.java index 6190f9d0..152f8f2e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/WrappedPacketOutBlockChange.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/WrappedPacketOutBlockChange.java @@ -6,11 +6,11 @@ public class WrappedPacketOutBlockChange extends PacketBlockChangeWrapper { - public WrappedPacketOutBlockChange(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutBlockChange", - networkProtocolGame + "PacketPlayOutBlockChange" - ) - ); - } + public WrappedPacketOutBlockChange(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutBlockChange", + networkProtocolGame + "PacketPlayOutBlockChange" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/PacketBlockDigWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/PacketBlockDigWrapper.java index 013ed891..c60c1da9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/PacketBlockDigWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/PacketBlockDigWrapper.java @@ -1,76 +1,75 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.dig; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketBlockDigWrapper extends PacketWrapper { - - Field pos; - Field direction; - Field action; - - PacketBlockDigWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - direction = getFirstField( - "direction", - "b" - ); - action = getFirstField( - "action", - "c" - ); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - /** - * @param pos: EnumDirection - */ - public void setDirection(Object direction) { - setField(this.direction, direction); - } - - /** - * @param pos: EnumPlayerDigType - */ - public void setAction(Object action) { - setField(this.action, action); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @return EnumDirection - */ - public Object getDirection() { - return getFieldValue(direction); - } - - /** - * @return EnumPlayerDigType - */ - public Object getAction() { - return getFieldValue(action); - } + + Field pos; + Field direction; + Field action; + + PacketBlockDigWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + direction = getFirstField( + "direction", + "b" + ); + action = getFirstField( + "action", + "c" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } + + /** + * @return EnumDirection + */ + public Object getDirection() { + return getFieldValue(direction); + } + + /** + * @param pos: EnumDirection + */ + public void setDirection(Object direction) { + setField(this.direction, direction); + } + + /** + * @return EnumPlayerDigType + */ + public Object getAction() { + return getFieldValue(action); + } + + /** + * @param pos: EnumPlayerDigType + */ + public void setAction(Object action) { + setField(this.action, action); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/WrappedPacketInBlockDig.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/WrappedPacketInBlockDig.java index f1fd44de..59254ca7 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/WrappedPacketInBlockDig.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/WrappedPacketInBlockDig.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.dig; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInBlockDig extends PacketBlockDigWrapper { - public WrappedPacketInBlockDig(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInBlockDig", - networkProtocolGame + "PacketPlayInBlockDig" - ) - ); - } + public WrappedPacketInBlockDig(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInBlockDig", + networkProtocolGame + "PacketPlayInBlockDig" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/PacketBlockPlaceWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/PacketBlockPlaceWrapper.java index c11b8ece..9a862865 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/PacketBlockPlaceWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/PacketBlockPlaceWrapper.java @@ -1,80 +1,79 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.place; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketBlockPlaceWrapper extends PacketWrapper { - - Field pos; - Field type; - Field data; - Field block; - - PacketBlockPlaceWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - type = getFirstField( - "b0", - "b" - ); - data = getFirstField( - "b1", - "c" - ); - block = getFirstField( - "block", - "d" - ); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - public void setType(int type) { - setField(this.type, type); - } - - public void setData(int data) { - setField(this.data, data); - } - - /** - * @param block: Block - */ - public void setBlock(Object block) { - setField(this.block, block); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - public int getType() { - return getFieldValue(type); - } - - public int getData() { - return getFieldValue(data); - } - - public Object getBlock() { - return getFieldValue(block); - } + + Field pos; + Field type; + Field data; + Field block; + + PacketBlockPlaceWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + type = getFirstField( + "b0", + "b" + ); + data = getFirstField( + "b1", + "c" + ); + block = getFirstField( + "block", + "d" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } + + public int getType() { + return getFieldValue(type); + } + + public void setType(int type) { + setField(this.type, type); + } + + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } + + public Object getBlock() { + return getFieldValue(block); + } + + /** + * @param block: Block + */ + public void setBlock(Object block) { + setField(this.block, block); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/WrappedPacketInBlockPlace.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/WrappedPacketInBlockPlace.java index 371ad5a5..b881b3bb 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/WrappedPacketInBlockPlace.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/WrappedPacketInBlockPlace.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.place; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInBlockPlace extends PacketBlockPlaceWrapper { - public WrappedPacketInBlockPlace(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInBlockPlace", - networkProtocolGame + "PacketPlayInBlockPlace" - ) - ); - } + public WrappedPacketInBlockPlace(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInBlockPlace", + networkProtocolGame + "PacketPlayInBlockPlace" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/PacketBlockUpdateWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/PacketBlockUpdateWrapper.java index 3a8e340f..b8ae9296 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/PacketBlockUpdateWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/PacketBlockUpdateWrapper.java @@ -10,48 +10,48 @@ @FieldDefaults(makeFinal = true) abstract class PacketBlockUpdateWrapper extends PacketWrapper { - - Field pos; - Field blockState; - - PacketBlockUpdateWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - blockState = getFirstField( - "blockState", - "b" - ); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - /** - * @param block: BlockState - */ - public void setBlockState(Object blockState) { - setField(this.blockState, blockState); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @return BlockState - */ - public Object getBlockState() { - return getFieldValue(blockState); - } + + Field pos; + Field blockState; + + PacketBlockUpdateWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + blockState = getFirstField( + "blockState", + "b" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } + + /** + * @return BlockState + */ + public Object getBlockState() { + return getFieldValue(blockState); + } + + /** + * @param block: BlockState + */ + public void setBlockState(Object blockState) { + setField(this.blockState, blockState); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/WrappedPacketOutBlockUpdate.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/WrappedPacketOutBlockUpdate.java index b2744b8f..f6f684eb 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/WrappedPacketOutBlockUpdate.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/WrappedPacketOutBlockUpdate.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.update; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutBlockUpdate extends PacketBlockUpdateWrapper { - public WrappedPacketOutBlockUpdate(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutBlockChange", - networkProtocolGame + "PacketPlayOutBlockChange" - ) - ); - } + public WrappedPacketOutBlockUpdate(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutBlockChange", + networkProtocolGame + "PacketPlayOutBlockChange" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/PacketCameraWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/PacketCameraWrapper.java index ed70f391..29bfea12 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/PacketCameraWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/PacketCameraWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.camera; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketCameraWrapper extends PacketWrapper { - - Field cameraId; - - PacketCameraWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - cameraId = getFirstField( - "cameraId", - "a" - ); - } - - public void setCameraId(int cameraId) { - setField(this.cameraId, cameraId); - } - - public int getCameraId() { - return getFieldValue(cameraId); - } + + Field cameraId; + + PacketCameraWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + cameraId = getFirstField( + "cameraId", + "a" + ); + } + + public int getCameraId() { + return getFieldValue(cameraId); + } + + public void setCameraId(int cameraId) { + setField(this.cameraId, cameraId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/WrappedPacketOutCamera.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/WrappedPacketOutCamera.java index 1e818dac..9b3bc031 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/WrappedPacketOutCamera.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/WrappedPacketOutCamera.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.camera; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutCamera extends PacketCameraWrapper { - public WrappedPacketOutCamera(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutCamera", - networkProtocolGame + "PacketPlayOutCamera" - ) - ); - } + public WrappedPacketOutCamera(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutCamera", + networkProtocolGame + "PacketPlayOutCamera" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/PacketChatWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/PacketChatWrapper.java index 30a955e9..ea5cbc31 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/PacketChatWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/PacketChatWrapper.java @@ -1,36 +1,35 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.chat; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketChatWrapper extends PacketWrapper { - - Field message; - - PacketChatWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - message = getFirstField( - "unsignedContent", - "content", - "message", - "a" - ); - } - - public abstract void setMessage(String message); - - /** - * In: {@link String} - * Out: IChatBaseComponent - */ - public Object getMessage() { - return getFieldValue(message); - } + + Field message; + + PacketChatWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + message = getFirstField( + "unsignedContent", + "content", + "message", + "a" + ); + } + + /** + * In: {@link String} + * Out: IChatBaseComponent + */ + public Object getMessage() { + return getFieldValue(message); + } + + public abstract void setMessage(String message); } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketInChat.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketInChat.java index c645ff27..6e9cb146 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketInChat.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketInChat.java @@ -1,26 +1,26 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.chat; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInChat extends PacketChatWrapper { - public WrappedPacketInChat(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInChat", - networkProtocolGame + "ServerboundChatPacket" - ) - ); - } - - @Override - public void setMessage(String message) { - setField(this.message, message); - } - - @Override - public String getMessage() { - return (String) super.getMessage(); - } + public WrappedPacketInChat(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInChat", + networkProtocolGame + "ServerboundChatPacket" + ) + ); + } + + @Override + public String getMessage() { + return (String) super.getMessage(); + } + + @Override + public void setMessage(String message) { + setField(this.message, message); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketOutChat.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketOutChat.java index abb1bb7d..cd0d113b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketOutChat.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketOutChat.java @@ -1,23 +1,23 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.chat; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutChat extends PacketChatWrapper { - public WrappedPacketOutChat(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutChat", - networkProtocolGame + "ClientboundSystemChatPacket", - networkProtocolGame + "ClientboundPlayerChatPacket", - networkProtocolGame + "ClientboundDisguisedChatPacket" - ) - ); - } - - @Override - public void setMessage(String message) { - setField(this.message, version.createChatComponentText(message)); - } + public WrappedPacketOutChat(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutChat", + networkProtocolGame + "ClientboundSystemChatPacket", + networkProtocolGame + "ClientboundPlayerChatPacket", + networkProtocolGame + "ClientboundDisguisedChatPacket" + ) + ); + } + + @Override + public void setMessage(String message) { + setField(this.message, version.createChatComponentText(message)); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/PacketClientCommandWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/PacketClientCommandWrapper.java index 622dbba3..9d8d4afc 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/PacketClientCommandWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/PacketClientCommandWrapper.java @@ -10,29 +10,29 @@ @FieldDefaults(makeFinal = true) abstract class PacketClientCommandWrapper extends PacketWrapper { - - Field action; - - PacketClientCommandWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - action = getFirstField( - "action", - "a" - ); - } - - /** - * @param action: PacketPlayInClientCommand$EnumClientCommand - */ - public void setAction(Object action) { - setField(this.action, action); - } - - /** - * @return PacketPlayInClientCommand$EnumClientCommand - */ - public Object getAction() { - return getFieldValue(action); - } + + Field action; + + PacketClientCommandWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + action = getFirstField( + "action", + "a" + ); + } + + /** + * @return PacketPlayInClientCommand$EnumClientCommand + */ + public Object getAction() { + return getFieldValue(action); + } + + /** + * @param action: PacketPlayInClientCommand$EnumClientCommand + */ + public void setAction(Object action) { + setField(this.action, action); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/WrappedPacketInClientCommand.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/WrappedPacketInClientCommand.java index e86e297f..eaa27182 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/WrappedPacketInClientCommand.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/WrappedPacketInClientCommand.java @@ -6,11 +6,11 @@ public class WrappedPacketInClientCommand extends PacketClientCommandWrapper { - public WrappedPacketInClientCommand(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInClientCommand", - networkProtocolGame + "PacketPlayInClientCommand" - ) - ); - } + public WrappedPacketInClientCommand(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInClientCommand", + networkProtocolGame + "PacketPlayInClientCommand" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/PacketCloseWindowWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/PacketCloseWindowWrapper.java index 982bf623..2b2a438d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/PacketCloseWindowWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/PacketCloseWindowWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.closewindow; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketCloseWindowWrapper extends PacketWrapper { - - Field containerId; - - PacketCloseWindowWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public int getContainerId() { - return getFieldValue(containerId); - } + + Field containerId; + + PacketCloseWindowWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketInCloseWindow.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketInCloseWindow.java index 51a436b7..dfc56181 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketInCloseWindow.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketInCloseWindow.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.closewindow; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInCloseWindow extends PacketCloseWindowWrapper { - public WrappedPacketInCloseWindow(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInCloseWindow", - networkProtocolGame + "PacketPlayInCloseWindow" - ) - ); - } + public WrappedPacketInCloseWindow(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInCloseWindow", + networkProtocolGame + "PacketPlayInCloseWindow" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketOutCloseWindow.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketOutCloseWindow.java index 61688c73..acbd7579 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketOutCloseWindow.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketOutCloseWindow.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.closewindow; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutCloseWindow extends PacketCloseWindowWrapper { - public WrappedPacketOutCloseWindow(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutCloseWindow", - networkProtocolGame + "PacketPlayOutCloseWindow" - ) - ); - } + public WrappedPacketOutCloseWindow(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutCloseWindow", + networkProtocolGame + "PacketPlayOutCloseWindow" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/PacketCollectWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/PacketCollectWrapper.java index 9635e397..1d0ee9d5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/PacketCollectWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/PacketCollectWrapper.java @@ -1,45 +1,44 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.collect; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketCollectWrapper extends PacketWrapper { - - Field itemId; - Field playerId; - - PacketCollectWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - itemId = getFirstField( - "itemId", - "a" - ); - playerId = getFirstField( - "playerId", - "b" - ); - } - - public void setItemId(int itemId) { - setField(this.itemId, itemId); - } - - public void setPlayerId(int playerId) { - setField(this.playerId, playerId); - } - - public int getItemId() { - return getFieldValue(itemId); - } - - public int getPlayerId() { - return getFieldValue(playerId); - } + + Field itemId; + Field playerId; + + PacketCollectWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + itemId = getFirstField( + "itemId", + "a" + ); + playerId = getFirstField( + "playerId", + "b" + ); + } + + public int getItemId() { + return getFieldValue(itemId); + } + + public void setItemId(int itemId) { + setField(this.itemId, itemId); + } + + public int getPlayerId() { + return getFieldValue(playerId); + } + + public void setPlayerId(int playerId) { + setField(this.playerId, playerId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/WrappedPacketOutCollect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/WrappedPacketOutCollect.java index cf1013c5..79fcc9a4 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/WrappedPacketOutCollect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/WrappedPacketOutCollect.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.collect; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutCollect extends PacketCollectWrapper { - public WrappedPacketOutCollect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutCollect", - networkProtocolGame + "PacketPlayOutCollect" - ) - ); - } + public WrappedPacketOutCollect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutCollect", + networkProtocolGame + "PacketPlayOutCollect" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/PacketCustomPayloadWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/PacketCustomPayloadWrapper.java index b540e5af..246bd50e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/PacketCustomPayloadWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/PacketCustomPayloadWrapper.java @@ -8,7 +8,7 @@ abstract class PacketCustomPayloadWrapper extends PacketWrapper { - PacketCustomPayloadWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketCustomPayloadWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketInCustomPayload.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketInCustomPayload.java index 5024af86..e2daa28d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketInCustomPayload.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketInCustomPayload.java @@ -6,11 +6,11 @@ public class WrappedPacketInCustomPayload extends PacketCustomPayloadWrapper { - public WrappedPacketInCustomPayload(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInCustomPayload", - networkProtocolCommon + "ServerboundCustomPayloadPacket" - ) - ); - } + public WrappedPacketInCustomPayload(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInCustomPayload", + networkProtocolCommon + "ServerboundCustomPayloadPacket" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketOutCustomPayload.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketOutCustomPayload.java index bd365b65..5eb0d62a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketOutCustomPayload.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketOutCustomPayload.java @@ -6,11 +6,11 @@ public class WrappedPacketOutCustomPayload extends PacketCustomPayloadWrapper { - public WrappedPacketOutCustomPayload(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutCustomPayload", - networkProtocolCommon + "ClientboundCustomPayloadPacket" - ) - ); - } + public WrappedPacketOutCustomPayload(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutCustomPayload", + networkProtocolCommon + "ClientboundCustomPayloadPacket" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/PacketEnchantItemWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/PacketEnchantItemWrapper.java index b841266b..e805bde6 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/PacketEnchantItemWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/PacketEnchantItemWrapper.java @@ -1,45 +1,44 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.enchantitem; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketEnchantItemWrapper extends PacketWrapper { - - Field containerId; - Field buttonId; - - PacketEnchantItemWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - buttonId = getFirstField( - "buttonId", - "b" - ); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public void setButtonId(int buttonId) { - setField(this.buttonId, buttonId); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public int getButtonId() { - return getFieldValue(buttonId); - } + + Field containerId; + Field buttonId; + + PacketEnchantItemWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + buttonId = getFirstField( + "buttonId", + "b" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } + + public int getButtonId() { + return getFieldValue(buttonId); + } + + public void setButtonId(int buttonId) { + setField(this.buttonId, buttonId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/WrappedPacketInEnchantItem.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/WrappedPacketInEnchantItem.java index cf3d2a5e..f2a74ba5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/WrappedPacketInEnchantItem.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/WrappedPacketInEnchantItem.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.enchantitem; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInEnchantItem extends PacketEnchantItemWrapper { - public WrappedPacketInEnchantItem(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInEnchantItem", - networkProtocolGame + "PacketPlayInEnchantItem" - ) - ); - } + public WrappedPacketInEnchantItem(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInEnchantItem", + networkProtocolGame + "PacketPlayInEnchantItem" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/PacketEntityWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/PacketEntityWrapper.java index e571d03f..91f8b201 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/PacketEntityWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/PacketEntityWrapper.java @@ -1,34 +1,33 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketEntityWrapper extends PacketWrapper { - Field entityId; - - PacketEntityWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - entityId = getFirstField( - "entityId", - "entity", - "id", - "a" - ); - } - - public void setEntityId(int entityId) { - setField(this.entityId, entityId); - } - - public int getEntityId() { - return getFieldValue(entityId); - } + Field entityId; + + PacketEntityWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + entityId = getFirstField( + "entityId", + "entity", + "id", + "a" + ); + } + + public int getEntityId() { + return getFieldValue(entityId); + } + + public void setEntityId(int entityId) { + setField(this.entityId, entityId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketInEntityAction.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketInEntityAction.java index d4ea9cb7..777f0687 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketInEntityAction.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketInEntityAction.java @@ -1,53 +1,53 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketInEntityAction extends PacketEntityWrapper { - Field action; - Field data; - - WrappedPacketInEntityAction(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInEntityAction", - networkProtocolGame + "PacketPlayInEntityAction" - ) - ); - - action = getFirstField( - "action", - "animation" - ); - data = getFirstField( - "data", - "c" - ); - } - - /** - * @param action: PacketPlayInEntityAction$EnumPlayerAction - */ - public void setAction(Object action) { - setField(this.action, action); - } - - public void setData(int data) { - setField(this.data, data); - } - - /** - * @return PacketPlayInEntityAction$EnumPlayerAction - */ - public Object getAction() { - return getFieldValue(action); - } - - public int getData() { - return getFieldValue(data); - } + Field action; + Field data; + + WrappedPacketInEntityAction(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInEntityAction", + networkProtocolGame + "PacketPlayInEntityAction" + ) + ); + + action = getFirstField( + "action", + "animation" + ); + data = getFirstField( + "data", + "c" + ); + } + + /** + * @return PacketPlayInEntityAction$EnumPlayerAction + */ + public Object getAction() { + return getFieldValue(action); + } + + /** + * @param action: PacketPlayInEntityAction$EnumPlayerAction + */ + public void setAction(Object action) { + setField(this.action, action); + } + + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntity.java index 47c1ffeb..6e24acc0 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntity.java @@ -1,75 +1,75 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntity extends PacketEntityWrapper { - - Field yRot; - Field xRot; - Field onGround; - Field hasRot; - - WrappedPacketOutEntity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntity", - networkProtocolGame + "PacketPlayOutEntity" - ) - ); - - yRot = getFirstField( - "yRot", - "yHeadRot", - "e", - "b" - ); - xRot = getFirstField( - "xRot", - "f" - ); - onGround = getFirstField( - "onGround", - "g" - ); - hasRot = getFirstField( - "hasRot", - "h" - ); - } - - public void setYRot(byte yRot) { - setField(this.yRot, yRot); - } - - public void setXRot(byte xRot) { - setField(this.xRot, xRot); - } - - public void setOnGround(boolean onGround) { - setField(this.onGround, onGround); - } - - public void setHasRot(boolean hasRot) { - setField(this.hasRot, hasRot); - } - - public byte getYRot() { - return getFieldValue(yRot); - } - - public byte getXRot() { - return getFieldValue(xRot); - } - - public boolean isOnGround() { - return getFieldValue(onGround); - } - - public boolean isHasRot() { - return getFieldValue(hasRot); - } + + Field yRot; + Field xRot; + Field onGround; + Field hasRot; + + WrappedPacketOutEntity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntity", + networkProtocolGame + "PacketPlayOutEntity" + ) + ); + + yRot = getFirstField( + "yRot", + "yHeadRot", + "e", + "b" + ); + xRot = getFirstField( + "xRot", + "f" + ); + onGround = getFirstField( + "onGround", + "g" + ); + hasRot = getFirstField( + "hasRot", + "h" + ); + } + + public byte getYRot() { + return getFieldValue(yRot); + } + + public void setYRot(byte yRot) { + setField(this.yRot, yRot); + } + + public byte getXRot() { + return getFieldValue(xRot); + } + + public void setXRot(byte xRot) { + setField(this.xRot, xRot); + } + + public boolean isOnGround() { + return getFieldValue(onGround); + } + + public void setOnGround(boolean onGround) { + setField(this.onGround, onGround); + } + + public boolean isHasRot() { + return getFieldValue(hasRot); + } + + public void setHasRot(boolean hasRot) { + setField(this.hasRot, hasRot); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityDestroy.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityDestroy.java index a60f1a2b..ae1c99c2 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityDestroy.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityDestroy.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutEntityDestroy extends PacketEntityWrapper { - - WrappedPacketOutEntityDestroy(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityDestroy", - networkProtocolGame + "PacketPlayOutEntityDestroy" - ) - ); - } + + WrappedPacketOutEntityDestroy(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityDestroy", + networkProtocolGame + "PacketPlayOutEntityDestroy" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEffect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEffect.java index 79860a48..2a33ca93 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEffect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEffect.java @@ -1,60 +1,60 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntityEffect extends PacketEntityWrapper { - Field effectAmplifier; - Field effectDurationTicks; - Field flags; - - WrappedPacketOutEntityEffect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityEffect", - networkProtocolGame + "PacketPlayOutEntityEffect" - ) - ); - - effectAmplifier = getFirstField( - "effectAmplifier", - "c" - ); - effectDurationTicks = getFirstField( - "effectDurationTicks", - "d" - ); - flags = getFirstField( - "flags", - "e" - ); - } - - public void setEffectAmplifier(byte effectAmplifier) { - setField(this.effectAmplifier, effectAmplifier); - } - - public void setEffectDurationTicks(int effectDurationTicks) { - setField(this.effectDurationTicks, effectDurationTicks); - } - - public void setFlags(byte flags) { - setField(this.flags, flags); - } - - public byte getEffectAmplifier() { - return getFieldValue(effectAmplifier); - } - - public int getEffectDurationTicks() { - return getFieldValue(effectDurationTicks); - } - - public byte getFlags() { - return getFieldValue(flags); - } + Field effectAmplifier; + Field effectDurationTicks; + Field flags; + + WrappedPacketOutEntityEffect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityEffect", + networkProtocolGame + "PacketPlayOutEntityEffect" + ) + ); + + effectAmplifier = getFirstField( + "effectAmplifier", + "c" + ); + effectDurationTicks = getFirstField( + "effectDurationTicks", + "d" + ); + flags = getFirstField( + "flags", + "e" + ); + } + + public byte getEffectAmplifier() { + return getFieldValue(effectAmplifier); + } + + public void setEffectAmplifier(byte effectAmplifier) { + setField(this.effectAmplifier, effectAmplifier); + } + + public int getEffectDurationTicks() { + return getFieldValue(effectDurationTicks); + } + + public void setEffectDurationTicks(int effectDurationTicks) { + setField(this.effectDurationTicks, effectDurationTicks); + } + + public byte getFlags() { + return getFieldValue(flags); + } + + public void setFlags(byte flags) { + setField(this.flags, flags); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEquipment.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEquipment.java index 0351e131..fdd9df38 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEquipment.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEquipment.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutEntityEquipment extends PacketEntityWrapper { - - WrappedPacketOutEntityEquipment(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityEquipment", - networkProtocolGame + "PacketPlayOutEntityEquipment" - ) - ); - } + + WrappedPacketOutEntityEquipment(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityEquipment", + networkProtocolGame + "PacketPlayOutEntityEquipment" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityHeadRotation.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityHeadRotation.java index 13b7e42b..eea902bd 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityHeadRotation.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityHeadRotation.java @@ -1,34 +1,34 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntityHeadRotation extends PacketEntityWrapper { - - Field yHeadRot; - - WrappedPacketOutEntityHeadRotation(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityHeadRotation", - networkProtocolGame + "PacketPlayOutEntityHeadRotation" - ) - ); - - yHeadRot = getFirstField( - "yHeadRot", - "b" - ); - } - - public void setYHeadRot(byte yHeadRot) { - setField(this.yHeadRot, yHeadRot); - } - - public byte getYHeadRot() { - return getFieldValue(yHeadRot); - } + + Field yHeadRot; + + WrappedPacketOutEntityHeadRotation(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityHeadRotation", + networkProtocolGame + "PacketPlayOutEntityHeadRotation" + ) + ); + + yHeadRot = getFirstField( + "yHeadRot", + "b" + ); + } + + public byte getYHeadRot() { + return getFieldValue(yHeadRot); + } + + public void setYHeadRot(byte yHeadRot) { + setField(this.yHeadRot, yHeadRot); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityMetadata.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityMetadata.java index fb2eec19..2d04b2cb 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityMetadata.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityMetadata.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutEntityMetadata extends PacketEntityWrapper { - - WrappedPacketOutEntityMetadata(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityMetadata", - networkProtocolGame + "PacketPlayOutEntityMetadata" - ) - ); - } + + WrappedPacketOutEntityMetadata(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityMetadata", + networkProtocolGame + "PacketPlayOutEntityMetadata" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityStatus.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityStatus.java index ca052419..d4495a15 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityStatus.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityStatus.java @@ -1,34 +1,34 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntityStatus extends PacketEntityWrapper { - Field eventId; - - WrappedPacketOutEntityStatus(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityStatus", - networkProtocolGame + "PacketPlayOutEntityStatus" - ) - ); - - eventId = getFirstField( - "eventId", - "b" - ); - } - - public void setEventId(byte eventId) { - setField(this.eventId, eventId); - } - - public byte getEventId() { - return getFieldValue(eventId); - } + Field eventId; + + WrappedPacketOutEntityStatus(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityStatus", + networkProtocolGame + "PacketPlayOutEntityStatus" + ) + ); + + eventId = getFirstField( + "eventId", + "b" + ); + } + + public byte getEventId() { + return getFieldValue(eventId); + } + + public void setEventId(byte eventId) { + setField(this.eventId, eventId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityTeleport.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityTeleport.java index af3d0ee0..f808cb98 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityTeleport.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityTeleport.java @@ -1,47 +1,47 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntityTeleport extends PacketEntityWrapper { - Field id; - Field onGround; - - WrappedPacketOutEntityTeleport(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityTeleport", - networkProtocolGame + "PacketPlayOutEntityTeleport" - ) - ); - - id = getFirstField( - "id", - "a" - ); - onGround = getFirstField( - "onGround", - "g" - ); - } - - public void setId(int id) { - setField(this.id, id); - } - - public void setOnGround(boolean onGround) { - setField(this.onGround, onGround); - } - - public int getId() { - return getFieldValue(id); - } - - public boolean isOnGround() { - return getFieldValue(onGround); - } + Field id; + Field onGround; + + WrappedPacketOutEntityTeleport(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityTeleport", + networkProtocolGame + "PacketPlayOutEntityTeleport" + ) + ); + + id = getFirstField( + "id", + "a" + ); + onGround = getFirstField( + "onGround", + "g" + ); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public boolean isOnGround() { + return getFieldValue(onGround); + } + + public void setOnGround(boolean onGround) { + setField(this.onGround, onGround); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityVelocity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityVelocity.java index b3499e85..5f8c9358 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityVelocity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityVelocity.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutEntityVelocity extends PacketEntityWrapper { - - WrappedPacketOutEntityVelocity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityVelocity", - networkProtocolGame + "PacketPlayOutEntityVelocity" - ) - ); - } + + WrappedPacketOutEntityVelocity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityVelocity", + networkProtocolGame + "PacketPlayOutEntityVelocity" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/PacketExperienceWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/PacketExperienceWrapper.java index c3757b2c..f39c8aa4 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/PacketExperienceWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/PacketExperienceWrapper.java @@ -1,58 +1,57 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.experience; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketExperienceWrapper extends PacketWrapper { - - Field experienceProgress; - Field totalExperience; - Field experienceLevel; - - PacketExperienceWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - experienceProgress = getFirstField( - "experienceProgress", - "a" - ); - totalExperience = getFirstField( - "totalExperience", - "b" - ); - experienceLevel = getFirstField( - "experienceLevel", - "c" - ); - } - - public void setExperienceProgress(float experienceProgress) { - setField(this.experienceProgress, experienceProgress); - } - - public void setTotalExperience(int totalExperience) { - setField(this.totalExperience, totalExperience); - } - - public void setExperienceLevel(int experienceLevel) { - setField(this.experienceLevel, experienceLevel); - } - - public float getExperienceProgress() { - return getFieldValue(experienceProgress); - } - - public int getTotalExperience() { - return getFieldValue(totalExperience); - } - - public int getExperienceLevel() { - return getFieldValue(experienceLevel); - } + + Field experienceProgress; + Field totalExperience; + Field experienceLevel; + + PacketExperienceWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + experienceProgress = getFirstField( + "experienceProgress", + "a" + ); + totalExperience = getFirstField( + "totalExperience", + "b" + ); + experienceLevel = getFirstField( + "experienceLevel", + "c" + ); + } + + public float getExperienceProgress() { + return getFieldValue(experienceProgress); + } + + public void setExperienceProgress(float experienceProgress) { + setField(this.experienceProgress, experienceProgress); + } + + public int getTotalExperience() { + return getFieldValue(totalExperience); + } + + public void setTotalExperience(int totalExperience) { + setField(this.totalExperience, totalExperience); + } + + public int getExperienceLevel() { + return getFieldValue(experienceLevel); + } + + public void setExperienceLevel(int experienceLevel) { + setField(this.experienceLevel, experienceLevel); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/WrappedPacketOutExperience.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/WrappedPacketOutExperience.java index 3d5b4bd1..428a83e5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/WrappedPacketOutExperience.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/WrappedPacketOutExperience.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.experience; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutExperience extends PacketExperienceWrapper { - public WrappedPacketOutExperience(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutExperience", - networkProtocolGame + "PacketPlayOutExperience" - ) - ); - } + public WrappedPacketOutExperience(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutExperience", + networkProtocolGame + "PacketPlayOutExperience" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/PacketExplosionWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/PacketExplosionWrapper.java index 398de481..6468d567 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/PacketExplosionWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/PacketExplosionWrapper.java @@ -1,33 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.explosion; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketExplosionWrapper extends PacketWrapper { - - Field radius; - - PacketExplosionWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - radius = getFirstField( - "radius", - "power", - "d" - ); - } - - public void setRadius(float radius) { - setField(this.radius, radius); - } - - public float getRadius() { - return getFieldValue(radius); - } + + Field radius; + + PacketExplosionWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + radius = getFirstField( + "radius", + "power", + "d" + ); + } + + public float getRadius() { + return getFieldValue(radius); + } + + public void setRadius(float radius) { + setField(this.radius, radius); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/WrappedPacketOutExplosion.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/WrappedPacketOutExplosion.java index 0bc4425d..a8b1c953 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/WrappedPacketOutExplosion.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/WrappedPacketOutExplosion.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.explosion; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutExplosion extends PacketExplosionWrapper { - public WrappedPacketOutExplosion(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutExplosion", - networkProtocolGame + "PacketPlayOutExplosion" - ) - ); - } + public WrappedPacketOutExplosion(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutExplosion", + networkProtocolGame + "PacketPlayOutExplosion" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/PacketFlyingWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/PacketFlyingWrapper.java index fd48a021..9ee8bd20 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/PacketFlyingWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/PacketFlyingWrapper.java @@ -1,111 +1,110 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.flying; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketFlyingWrapper extends PacketWrapper { - Field x; - Field y; - Field z; - Field yaw; - Field pitch; - Field onGround; - Field hasPos; - Field hasRot; - - PacketFlyingWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - x = getField("x"); - y = getField("y"); - z = getField("z"); - yaw = getFirstField( - "yaw", - "yRot" - ); - pitch = getFirstField( - "pitch", - "xRot" - ); - onGround = getFirstField( - "onGround", - "f" - ); - hasPos = getField("hasPos"); - hasRot = getFirstField( - "hasRot", - "hasLook" - ); - } - - public void setX(double x) { - setField(this.x, x); - } - - public void setY(double y) { - setField(this.y, y); - } - - public void setZ(double z) { - setField(this.z, z); - } - - public void setYaw(float yaw) { - setField(this.yaw, yaw); - } - - public void setPitch(float pitch) { - setField(this.pitch, pitch); - } - - public void setOnGround(boolean onGround) { - setField(this.onGround, onGround); - } - - public void setHasPos(boolean hasPos) { - setField(this.hasPos, hasPos); - } - - public void setHasRot(boolean hasRot) { - setField(this.hasRot, hasRot); - } - - public double getX() { - return getFieldValue(x); - } - - public double getY() { - return getFieldValue(y); - } - - public double getZ() { - return getFieldValue(z); - } - - public float getYaw() { - return getFieldValue(yaw); - } - - public float getPitch() { - return getFieldValue(pitch); - } - - public boolean isOnGround() { - return getFieldValue(onGround); - } - - public boolean isHasPos() { - return getFieldValue(hasPos); - } - - public boolean isHasRot() { - return getFieldValue(hasRot); - } + Field x; + Field y; + Field z; + Field yaw; + Field pitch; + Field onGround; + Field hasPos; + Field hasRot; + + PacketFlyingWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + x = getField("x"); + y = getField("y"); + z = getField("z"); + yaw = getFirstField( + "yaw", + "yRot" + ); + pitch = getFirstField( + "pitch", + "xRot" + ); + onGround = getFirstField( + "onGround", + "f" + ); + hasPos = getField("hasPos"); + hasRot = getFirstField( + "hasRot", + "hasLook" + ); + } + + public double getX() { + return getFieldValue(x); + } + + public void setX(double x) { + setField(this.x, x); + } + + public double getY() { + return getFieldValue(y); + } + + public void setY(double y) { + setField(this.y, y); + } + + public double getZ() { + return getFieldValue(z); + } + + public void setZ(double z) { + setField(this.z, z); + } + + public float getYaw() { + return getFieldValue(yaw); + } + + public void setYaw(float yaw) { + setField(this.yaw, yaw); + } + + public float getPitch() { + return getFieldValue(pitch); + } + + public void setPitch(float pitch) { + setField(this.pitch, pitch); + } + + public boolean isOnGround() { + return getFieldValue(onGround); + } + + public void setOnGround(boolean onGround) { + setField(this.onGround, onGround); + } + + public boolean isHasPos() { + return getFieldValue(hasPos); + } + + public void setHasPos(boolean hasPos) { + setField(this.hasPos, hasPos); + } + + public boolean isHasRot() { + return getFieldValue(hasRot); + } + + public void setHasRot(boolean hasRot) { + setField(this.hasRot, hasRot); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/WrappedPacketInFlying.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/WrappedPacketInFlying.java index 799d052a..3c65e695 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/WrappedPacketInFlying.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/WrappedPacketInFlying.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.flying; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInFlying extends PacketFlyingWrapper { - WrappedPacketInFlying(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInFlying", - networkProtocolGame + "PacketPlayInFlying" - ) - ); - } + WrappedPacketInFlying(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInFlying", + networkProtocolGame + "PacketPlayInFlying" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/PacketGameStateChangeWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/PacketGameStateChangeWrapper.java index 5e8fa278..f8c5186b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/PacketGameStateChangeWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/PacketGameStateChangeWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.gamestatechange; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketGameStateChangeWrapper extends PacketWrapper { - - Field param; - - PacketGameStateChangeWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - param = getFirstField( - "param", - "c" - ); - } - - public void setParam(float param) { - setField(this.param, param); - } - - public float getParam() { - return getFieldValue(param); - } + + Field param; + + PacketGameStateChangeWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + param = getFirstField( + "param", + "c" + ); + } + + public float getParam() { + return getFieldValue(param); + } + + public void setParam(float param) { + setField(this.param, param); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/WrappedPacketOutGameStateChange.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/WrappedPacketOutGameStateChange.java index a869f86d..4a5cf68c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/WrappedPacketOutGameStateChange.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/WrappedPacketOutGameStateChange.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.gamestatechange; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutGameStateChange extends PacketGameStateChangeWrapper { - WrappedPacketOutGameStateChange(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutGameStateChange", - networkProtocolGame + "PacketPlayOutGameStateChange" - ) - ); - } + WrappedPacketOutGameStateChange(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutGameStateChange", + networkProtocolGame + "PacketPlayOutGameStateChange" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/PacketHeldItemSlotWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/PacketHeldItemSlotWrapper.java index ee28d1a2..0ed911b0 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/PacketHeldItemSlotWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/PacketHeldItemSlotWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.helditemslot; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketHeldItemSlotWrapper extends PacketWrapper { - - Field slot; - - PacketHeldItemSlotWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - slot = getFirstField( - "slot", - "a" - ); - } - - public void setSlot(int slot) { - setField(this.slot, slot); - } - - public int getSlot() { - return getFieldValue(slot); - } + + Field slot; + + PacketHeldItemSlotWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + slot = getFirstField( + "slot", + "a" + ); + } + + public int getSlot() { + return getFieldValue(slot); + } + + public void setSlot(int slot) { + setField(this.slot, slot); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketInHeldItemSlot.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketInHeldItemSlot.java index 8526ae6e..c4f7dc30 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketInHeldItemSlot.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketInHeldItemSlot.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.helditemslot; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInHeldItemSlot extends PacketHeldItemSlotWrapper { - public WrappedPacketInHeldItemSlot(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInHeldItemSlot", - networkProtocolGame + "PacketPlayInHeldItemSlot" - ) - ); - } + public WrappedPacketInHeldItemSlot(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInHeldItemSlot", + networkProtocolGame + "PacketPlayInHeldItemSlot" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketOutHeldItemSlot.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketOutHeldItemSlot.java index b75c06c3..d1106c8d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketOutHeldItemSlot.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketOutHeldItemSlot.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.helditemslot; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutHeldItemSlot extends PacketHeldItemSlotWrapper { - public WrappedPacketOutHeldItemSlot(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutHeldItemSlot", - networkProtocolGame + "PacketPlayOutHeldItemSlot" - ) - ); - } + public WrappedPacketOutHeldItemSlot(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutHeldItemSlot", + networkProtocolGame + "PacketPlayOutHeldItemSlot" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/PacketKickDisconnectWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/PacketKickDisconnectWrapper.java index b032ae4b..9226a178 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/PacketKickDisconnectWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/PacketKickDisconnectWrapper.java @@ -10,29 +10,29 @@ @FieldDefaults(makeFinal = true) abstract class PacketKickDisconnectWrapper extends PacketWrapper { - - Field reason; - - PacketKickDisconnectWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - reason = getFirstField( - "reason", - "a" - ); - } - - /** - * @param reason: IChatBaseComponent - */ - public void setReason(Object reason) { - setField(this.reason, reason); - } - - /** - * @return IChatBaseComponent - */ - public Object getReason() { - return getFieldValue(reason); - } + + Field reason; + + PacketKickDisconnectWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + reason = getFirstField( + "reason", + "a" + ); + } + + /** + * @return IChatBaseComponent + */ + public Object getReason() { + return getFieldValue(reason); + } + + /** + * @param reason: IChatBaseComponent + */ + public void setReason(Object reason) { + setField(this.reason, reason); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/WrappedPacketOutKickDisconnect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/WrappedPacketOutKickDisconnect.java index 55aba901..5774162d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/WrappedPacketOutKickDisconnect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/WrappedPacketOutKickDisconnect.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.kickdisconnect; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutKickDisconnect extends PacketKickDisconnectWrapper { - WrappedPacketOutKickDisconnect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutKickDisconnect", - networkProtocolCommon + "ClientboundDisconnectPacket" - ) - ); - } + WrappedPacketOutKickDisconnect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutKickDisconnect", + networkProtocolCommon + "ClientboundDisconnectPacket" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/PacketLoginWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/PacketLoginWrapper.java index 3a4b4e8d..45788115 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/PacketLoginWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/PacketLoginWrapper.java @@ -1,71 +1,70 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.login; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketLoginWrapper extends PacketWrapper { - - Field playerId; - Field hardcore; - Field maxPlayers; - Field reducedDebugInfo; - PacketLoginWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - playerId = getFirstField( - "playerId", - "a" - ); - hardcore = getFirstField( - "hardcore", - "b" - ); - maxPlayers = getFirstField( - "maxPlayers", - "f" - ); - reducedDebugInfo = getFirstField( - "reducedDebugInfo", - "h" - ); - } - - public void setPlayerId(int playerId) { - setField(this.playerId, playerId); - } - - public void setHardcore(boolean hardcore) { - setField(this.hardcore, hardcore); - } - - public void setMaxPlayers(int maxPlayers) { - setField(this.maxPlayers, maxPlayers); - } - - public void setReducedDebugInfo(boolean reducedDebugInfo) { - setField(this.reducedDebugInfo, reducedDebugInfo); - } - - public int getPlayerId() { - return getFieldValue(playerId); - } - - public boolean getHardcore() { - return getFieldValue(hardcore); - } - - public int getMaxPlayers() { - return getFieldValue(maxPlayers); - } - - public boolean isReducedDebugInfo() { - return getFieldValue(reducedDebugInfo); - } + Field playerId; + Field hardcore; + Field maxPlayers; + Field reducedDebugInfo; + + PacketLoginWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + playerId = getFirstField( + "playerId", + "a" + ); + hardcore = getFirstField( + "hardcore", + "b" + ); + maxPlayers = getFirstField( + "maxPlayers", + "f" + ); + reducedDebugInfo = getFirstField( + "reducedDebugInfo", + "h" + ); + } + + public int getPlayerId() { + return getFieldValue(playerId); + } + + public void setPlayerId(int playerId) { + setField(this.playerId, playerId); + } + + public boolean getHardcore() { + return getFieldValue(hardcore); + } + + public void setHardcore(boolean hardcore) { + setField(this.hardcore, hardcore); + } + + public int getMaxPlayers() { + return getFieldValue(maxPlayers); + } + + public void setMaxPlayers(int maxPlayers) { + setField(this.maxPlayers, maxPlayers); + } + + public boolean isReducedDebugInfo() { + return getFieldValue(reducedDebugInfo); + } + + public void setReducedDebugInfo(boolean reducedDebugInfo) { + setField(this.reducedDebugInfo, reducedDebugInfo); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/WrappedPacketOutLogin.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/WrappedPacketOutLogin.java index 54ed0985..056d0ccd 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/WrappedPacketOutLogin.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/WrappedPacketOutLogin.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.login; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutLogin extends PacketLoginWrapper { - WrappedPacketOutLogin(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutLogin", - networkProtocolGame + "PacketPlayOutLogin" - ) - ); - } + WrappedPacketOutLogin(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutLogin", + networkProtocolGame + "PacketPlayOutLogin" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/PacketMapWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/PacketMapWrapper.java index 7ed4be9c..87535cb1 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/PacketMapWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/PacketMapWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.map; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketMapWrapper extends PacketWrapper { - - Field scale; - - PacketMapWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - scale = getFirstField( - "scale", - "b" - ); - } - - public void setScale(byte scale) { - setField(this.scale, scale); - } - - public byte getScale() { - return getFieldValue(scale); - } + + Field scale; + + PacketMapWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + scale = getFirstField( + "scale", + "b" + ); + } + + public byte getScale() { + return getFieldValue(scale); + } + + public void setScale(byte scale) { + setField(this.scale, scale); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/WrappedPacketOutMap.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/WrappedPacketOutMap.java index cacaa567..e5f333f3 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/WrappedPacketOutMap.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/WrappedPacketOutMap.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.map; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutMap extends PacketMapWrapper { - public WrappedPacketOutMap(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutMap", - networkProtocolGame + "PacketPlayOutMap" - ) - ); - } + public WrappedPacketOutMap(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutMap", + networkProtocolGame + "PacketPlayOutMap" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/PacketMultiBlockChangeWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/PacketMultiBlockChangeWrapper.java index aa7c0652..12b9690c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/PacketMultiBlockChangeWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/PacketMultiBlockChangeWrapper.java @@ -1,14 +1,13 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.multiblockchange; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; +import java.util.Set; + abstract class PacketMultiBlockChangeWrapper extends PacketWrapper { - PacketMultiBlockChangeWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketMultiBlockChangeWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/WrappedPacketOutMultiBlockChange.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/WrappedPacketOutMultiBlockChange.java index 9b60cc9f..17b1e4a5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/WrappedPacketOutMultiBlockChange.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/WrappedPacketOutMultiBlockChange.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.multiblockchange; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutMultiBlockChange extends PacketMultiBlockChangeWrapper { - public WrappedPacketOutMultiBlockChange(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutMultiBlockChange", - networkProtocolGame + "PacketPlayOutMultiBlockChange" - ) - ); - } + public WrappedPacketOutMultiBlockChange(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutMultiBlockChange", + networkProtocolGame + "PacketPlayOutMultiBlockChange" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/PacketNamedSoundEffectWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/PacketNamedSoundEffectWrapper.java index 88f6e022..25564680 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/PacketNamedSoundEffectWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/PacketNamedSoundEffectWrapper.java @@ -1,71 +1,70 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.namedsoundeffect; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketNamedSoundEffectWrapper extends PacketWrapper { - - Field x; - Field y; - Field z; - Field volume; - PacketNamedSoundEffectWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - x = getFirstField( - "x", - "b" - ); - y = getFirstField( - "y", - "c" - ); - z = getFirstField( - "z", - "d" - ); - volume = getFirstField( - "volume", - "e" - ); - } - - public void setX(int x) { - setField(this.x, x); - } - - public void setY(int y) { - setField(this.y, y); - } - - public void setZ(int z) { - setField(this.z, z); - } - - public void setVolume(float volume) { - setField(this.volume, volume); - } - - public int getX() { - return getFieldValue(x); - } - - public int getY() { - return getFieldValue(y); - } - - public int getZ() { - return getFieldValue(z); - } - - public float getVolume() { - return getFieldValue(volume); - } + Field x; + Field y; + Field z; + Field volume; + + PacketNamedSoundEffectWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + x = getFirstField( + "x", + "b" + ); + y = getFirstField( + "y", + "c" + ); + z = getFirstField( + "z", + "d" + ); + volume = getFirstField( + "volume", + "e" + ); + } + + public int getX() { + return getFieldValue(x); + } + + public void setX(int x) { + setField(this.x, x); + } + + public int getY() { + return getFieldValue(y); + } + + public void setY(int y) { + setField(this.y, y); + } + + public int getZ() { + return getFieldValue(z); + } + + public void setZ(int z) { + setField(this.z, z); + } + + public float getVolume() { + return getFieldValue(volume); + } + + public void setVolume(float volume) { + setField(this.volume, volume); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/WrappedPacketOutNamedSoundEffect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/WrappedPacketOutNamedSoundEffect.java index 60980411..d7d6c9c2 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/WrappedPacketOutNamedSoundEffect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/WrappedPacketOutNamedSoundEffect.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.namedsoundeffect; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutNamedSoundEffect extends PacketNamedSoundEffectWrapper { - public WrappedPacketOutNamedSoundEffect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutNamedSoundEffect", - networkProtocolGame + "PacketPlayOutNamedSoundEffect" - ) - ); - } + public WrappedPacketOutNamedSoundEffect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutNamedSoundEffect", + networkProtocolGame + "PacketPlayOutNamedSoundEffect" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/PacketOpenSignEditorWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/PacketOpenSignEditorWrapper.java index b91f866d..3d773651 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/PacketOpenSignEditorWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/PacketOpenSignEditorWrapper.java @@ -1,38 +1,37 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.open.signeditor; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketOpenSignEditorWrapper extends PacketWrapper { - - Field pos; - - PacketOpenSignEditorWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } + + Field pos; + + PacketOpenSignEditorWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/WrappedPacketOutOpenSignEditor.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/WrappedPacketOutOpenSignEditor.java index fdf74ce0..de4b5630 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/WrappedPacketOutOpenSignEditor.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/WrappedPacketOutOpenSignEditor.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.open.signeditor; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutOpenSignEditor extends PacketOpenSignEditorWrapper { - public WrappedPacketOutOpenSignEditor(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutOpenSignEditor", - networkProtocolGame + "PacketPlayOutOpenSignEditor" - ) - ); - } + public WrappedPacketOutOpenSignEditor(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutOpenSignEditor", + networkProtocolGame + "PacketPlayOutOpenSignEditor" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/PacketOpenWindowWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/PacketOpenWindowWrapper.java index 4a3d4c46..d5d1a851 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/PacketOpenWindowWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/PacketOpenWindowWrapper.java @@ -1,51 +1,50 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.open.window; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketOpenWindowWrapper extends PacketWrapper { - - Field containerId; - Field title; - - PacketOpenWindowWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - title = getFirstField( - "title", - "c" - ); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - /** - * @param title: IChatBaseComponent - */ - public void setTitle(Object title) { - setField(this.title, title); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - /** - * @return IChatBaseComponent - */ - public Object getTitle() { - return getFieldValue(title); - } + + Field containerId; + Field title; + + PacketOpenWindowWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + title = getFirstField( + "title", + "c" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } + + /** + * @return IChatBaseComponent + */ + public Object getTitle() { + return getFieldValue(title); + } + + /** + * @param title: IChatBaseComponent + */ + public void setTitle(Object title) { + setField(this.title, title); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/WrappedPacketOutOpenWindow.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/WrappedPacketOutOpenWindow.java index a2fd0db5..806251d7 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/WrappedPacketOutOpenWindow.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/WrappedPacketOutOpenWindow.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.open.window; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutOpenWindow extends PacketOpenWindowWrapper { - public WrappedPacketOutOpenWindow(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutOpenWindow", - networkProtocolGame + "PacketPlayOutOpenWindow" - ) - ); - } + public WrappedPacketOutOpenWindow(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutOpenWindow", + networkProtocolGame + "PacketPlayOutOpenWindow" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/PacketPlayerListHeaderFooterWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/PacketPlayerListHeaderFooterWrapper.java index d26d01f1..8e9a2f76 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/PacketPlayerListHeaderFooterWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/PacketPlayerListHeaderFooterWrapper.java @@ -1,57 +1,56 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.playerlistheaderfooter; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketPlayerListHeaderFooterWrapper extends PacketWrapper { - - Field header; - Field footer; - - PacketPlayerListHeaderFooterWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - header = getFirstField( - "header", - "a" - ); - footer = getFirstField( - "footer", - "b" - ); - } - - /** - * @param header: IChatBaseComponent - */ - public void setHeader(Object header) { - setField(this.header, header); - } - - /** - * @param footer: IChatBaseComponent - */ - public void setFooter(Object footer) { - setField(this.footer, footer); - } - - /** - * @return IChatBaseComponent - */ - public Object getHeader() { - return getFieldValue(header); - } - - /** - * @return IChatBaseComponent - */ - public Object getFooter() { - return getFieldValue(footer); - } + + Field header; + Field footer; + + PacketPlayerListHeaderFooterWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + header = getFirstField( + "header", + "a" + ); + footer = getFirstField( + "footer", + "b" + ); + } + + /** + * @return IChatBaseComponent + */ + public Object getHeader() { + return getFieldValue(header); + } + + /** + * @param header: IChatBaseComponent + */ + public void setHeader(Object header) { + setField(this.header, header); + } + + /** + * @return IChatBaseComponent + */ + public Object getFooter() { + return getFieldValue(footer); + } + + /** + * @param footer: IChatBaseComponent + */ + public void setFooter(Object footer) { + setField(this.footer, footer); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/WrappedPacketOutPlayerListHeaderFooter.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/WrappedPacketOutPlayerListHeaderFooter.java index bf2788c6..93550198 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/WrappedPacketOutPlayerListHeaderFooter.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/WrappedPacketOutPlayerListHeaderFooter.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.playerlistheaderfooter; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutPlayerListHeaderFooter extends PacketPlayerListHeaderFooterWrapper { - public WrappedPacketOutPlayerListHeaderFooter(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutPlayerListHeaderFooter", - networkProtocolGame + "PacketPlayOutPlayerListHeaderFooter" - ) - ); - } + public WrappedPacketOutPlayerListHeaderFooter(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutPlayerListHeaderFooter", + networkProtocolGame + "PacketPlayOutPlayerListHeaderFooter" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/PacketPositionWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/PacketPositionWrapper.java index c94fb2d9..b1c5f32b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/PacketPositionWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/PacketPositionWrapper.java @@ -1,14 +1,13 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.position; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; +import java.util.Set; + abstract class PacketPositionWrapper extends PacketWrapper { - PacketPositionWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketPositionWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/WrappedPacketOutPosition.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/WrappedPacketOutPosition.java index 2d2b5c06..b73e848d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/WrappedPacketOutPosition.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/WrappedPacketOutPosition.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.position; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutPosition extends PacketPositionWrapper { - WrappedPacketOutPosition(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutPosition", - networkProtocolCommon + "PacketPlayOutPosition" - ) - ); - } + WrappedPacketOutPosition(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutPosition", + networkProtocolCommon + "PacketPlayOutPosition" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/PacketRemoveEntityEffectWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/PacketRemoveEntityEffectWrapper.java index 46b958e6..3440127c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/PacketRemoveEntityEffectWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/PacketRemoveEntityEffectWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.removeentityeffect; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketRemoveEntityEffectWrapper extends PacketWrapper { - - Field entityId; - - PacketRemoveEntityEffectWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - entityId = getFirstField( - "entityId", - "a" - ); - } - - public void setEntityId(int entityId) { - setField(this.entityId, entityId); - } - - public int getEntityId() { - return getFieldValue(entityId); - } + + Field entityId; + + PacketRemoveEntityEffectWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + entityId = getFirstField( + "entityId", + "a" + ); + } + + public int getEntityId() { + return getFieldValue(entityId); + } + + public void setEntityId(int entityId) { + setField(this.entityId, entityId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/WrappedPacketOutRemoveEntityEffect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/WrappedPacketOutRemoveEntityEffect.java index 276ad92b..05915946 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/WrappedPacketOutRemoveEntityEffect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/WrappedPacketOutRemoveEntityEffect.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.removeentityeffect; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutRemoveEntityEffect extends PacketRemoveEntityEffectWrapper { - WrappedPacketOutRemoveEntityEffect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutRemoveEntityEffect", - networkProtocolCommon + "PacketPlayOutRemoveEntityEffect" - ) - ); - } + WrappedPacketOutRemoveEntityEffect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutRemoveEntityEffect", + networkProtocolCommon + "PacketPlayOutRemoveEntityEffect" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/PacketResourcePackStatusWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/PacketResourcePackStatusWrapper.java index 31413010..7e8a9a59 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/PacketResourcePackStatusWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/PacketResourcePackStatusWrapper.java @@ -1,39 +1,38 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.resourcepackstatus; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketResourcePackStatusWrapper extends PacketWrapper { - - Field status; - - PacketResourcePackStatusWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - status = getFirstField( - "status", - "action", - "b" - ); - } - - /** - * @param status: PacketPlayInResourcePackStatus$EnumResourcePackStatus - */ - public void setStatus(Object status) { - setField(this.status, status); - } - - /** - * @return PacketPlayInResourcePackStatus$EnumResourcePackStatus - */ - public Object getStatus() { - return getFieldValue(status); - } + + Field status; + + PacketResourcePackStatusWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + status = getFirstField( + "status", + "action", + "b" + ); + } + + /** + * @return PacketPlayInResourcePackStatus$EnumResourcePackStatus + */ + public Object getStatus() { + return getFieldValue(status); + } + + /** + * @param status: PacketPlayInResourcePackStatus$EnumResourcePackStatus + */ + public void setStatus(Object status) { + setField(this.status, status); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/WrappedPacketInResourcePackStatus.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/WrappedPacketInResourcePackStatus.java index 7cec3919..71871d35 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/WrappedPacketInResourcePackStatus.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/WrappedPacketInResourcePackStatus.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.resourcepackstatus; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInResourcePackStatus extends PacketResourcePackStatusWrapper { - WrappedPacketInResourcePackStatus(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInResourcePackStatus", - networkProtocolCommon + "ServerboundResourcePackPacket" - ) - ); - } + WrappedPacketInResourcePackStatus(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInResourcePackStatus", + networkProtocolCommon + "ServerboundResourcePackPacket" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/PacketRespawnWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/PacketRespawnWrapper.java index d1a278dd..0cd00643 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/PacketRespawnWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/PacketRespawnWrapper.java @@ -1,38 +1,37 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.respawn; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketRespawnWrapper extends PacketWrapper { - - Field levelType; - - PacketRespawnWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - levelType = getFirstField( - "levelType", - "d" - ); - } - - /** - * @param levelType: WorldType - */ - public void setLevelType(Object levelType) { - setField(this.levelType, levelType); - } - - /** - * @return WorldType - */ - public Object getLevelType() { - return getFieldValue(levelType); - } + + Field levelType; + + PacketRespawnWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + levelType = getFirstField( + "levelType", + "d" + ); + } + + /** + * @return WorldType + */ + public Object getLevelType() { + return getFieldValue(levelType); + } + + /** + * @param levelType: WorldType + */ + public void setLevelType(Object levelType) { + setField(this.levelType, levelType); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/WrappedPacketOutRespawn.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/WrappedPacketOutRespawn.java index b9b2f584..13b328a4 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/WrappedPacketOutRespawn.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/WrappedPacketOutRespawn.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.respawn; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutRespawn extends PacketRespawnWrapper { - WrappedPacketOutRespawn(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutRespawn", - networkProtocolGame + "PacketPlayOutRespawn" - ) - ); - } + WrappedPacketOutRespawn(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutRespawn", + networkProtocolGame + "PacketPlayOutRespawn" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/PacketScoreboardDisplayObjectiveWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/PacketScoreboardDisplayObjectiveWrapper.java index f2e28faa..67043b4e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/PacketScoreboardDisplayObjectiveWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/PacketScoreboardDisplayObjectiveWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.display.objective; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketScoreboardDisplayObjectiveWrapper extends PacketWrapper { - - Field objectiveName; - - PacketScoreboardDisplayObjectiveWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - objectiveName = getFirstField( - "objectiveName", - "b" - ); - } - - public void setObjectiveName(String objectiveName) { - setField(this.objectiveName, objectiveName); - } - - public String getObjectiveName() { - return getFieldValue(objectiveName); - } + + Field objectiveName; + + PacketScoreboardDisplayObjectiveWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + objectiveName = getFirstField( + "objectiveName", + "b" + ); + } + + public String getObjectiveName() { + return getFieldValue(objectiveName); + } + + public void setObjectiveName(String objectiveName) { + setField(this.objectiveName, objectiveName); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/WrappedPacketOutScoreboardDisplayObjective.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/WrappedPacketOutScoreboardDisplayObjective.java index a2232a2f..0091fc15 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/WrappedPacketOutScoreboardDisplayObjective.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/WrappedPacketOutScoreboardDisplayObjective.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.display.objective; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutScoreboardDisplayObjective extends PacketScoreboardDisplayObjectiveWrapper { - WrappedPacketOutScoreboardDisplayObjective(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutScoreboardDisplayObjective", - networkProtocolGame + "PacketPlayOutScoreboardDisplayObjective" - ) - ); - } + WrappedPacketOutScoreboardDisplayObjective(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutScoreboardDisplayObjective", + networkProtocolGame + "PacketPlayOutScoreboardDisplayObjective" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/PacketScoreboardObjectiveWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/PacketScoreboardObjectiveWrapper.java index a058f34b..c065e882 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/PacketScoreboardObjectiveWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/PacketScoreboardObjectiveWrapper.java @@ -1,64 +1,63 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.objective; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketScoreboardObjectiveWrapper extends PacketWrapper { - - Field objectiveName; - Field renderType; - Field method; - PacketScoreboardObjectiveWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - objectiveName = getFirstField( - "objectiveName", - "a" - ); - renderType = getFirstField( - "renderType", - "c" - ); - method = getFirstField( - "method", - "d" - ); - } - - public void setObjectiveName(String objectiveName) { - setField(this.objectiveName, objectiveName); - } - - /** - * @param renderType: IScoreboardCriteria$EnumScoreboardHealthDisplay - */ - public void setRenderType(Object renderType) { - setField(this.renderType, renderType); - } - - public void setMethod(int method) { - setField(this.method, method); - } - - public String getObjectiveName() { - return getFieldValue(objectiveName); - } - - /** - * @return IScoreboardCriteria$EnumScoreboardHealthDisplay - */ - public Object getRenderType() { - return getFieldValue(renderType); - } - - public int getMethod() { - return getFieldValue(method); - } + Field objectiveName; + Field renderType; + Field method; + + PacketScoreboardObjectiveWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + objectiveName = getFirstField( + "objectiveName", + "a" + ); + renderType = getFirstField( + "renderType", + "c" + ); + method = getFirstField( + "method", + "d" + ); + } + + public String getObjectiveName() { + return getFieldValue(objectiveName); + } + + public void setObjectiveName(String objectiveName) { + setField(this.objectiveName, objectiveName); + } + + /** + * @return IScoreboardCriteria$EnumScoreboardHealthDisplay + */ + public Object getRenderType() { + return getFieldValue(renderType); + } + + /** + * @param renderType: IScoreboardCriteria$EnumScoreboardHealthDisplay + */ + public void setRenderType(Object renderType) { + setField(this.renderType, renderType); + } + + public int getMethod() { + return getFieldValue(method); + } + + public void setMethod(int method) { + setField(this.method, method); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/WrappedPacketOutScoreboardObjective.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/WrappedPacketOutScoreboardObjective.java index 5df9db2e..34721dde 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/WrappedPacketOutScoreboardObjective.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/WrappedPacketOutScoreboardObjective.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.objective; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutScoreboardObjective extends PacketScoreboardObjectiveWrapper { - WrappedPacketOutScoreboardObjective(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutScoreboardObjective", - networkProtocolGame + "PacketPlayOutScoreboardObjective" - ) - ); - } + WrappedPacketOutScoreboardObjective(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutScoreboardObjective", + networkProtocolGame + "PacketPlayOutScoreboardObjective" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/PacketScoreboardScoreWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/PacketScoreboardScoreWrapper.java index 590d12aa..f2139fb8 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/PacketScoreboardScoreWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/PacketScoreboardScoreWrapper.java @@ -1,58 +1,57 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.score; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketScoreboardScoreWrapper extends PacketWrapper { - - Field owner; - Field objectiveName; - Field score; - - PacketScoreboardScoreWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - owner = getFirstField( - "owner", - "a" - ); - objectiveName = getFirstField( - "objectiveName", - "b" - ); - score = getFirstField( - "score", - "c" - ); - } - - public void setOwner(String owner) { - setField(this.owner, owner); - } - - public void setObjectiveName(String objectiveName) { - setField(this.objectiveName, objectiveName); - } - - public void setScore(int score) { - setField(this.score, score); - } - - public String getOwner() { - return getFieldValue(owner); - } - - public String getObjectiveName() { - return getFieldValue(objectiveName); - } - - public int getScore() { - return getFieldValue(score); - } + + Field owner; + Field objectiveName; + Field score; + + PacketScoreboardScoreWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + owner = getFirstField( + "owner", + "a" + ); + objectiveName = getFirstField( + "objectiveName", + "b" + ); + score = getFirstField( + "score", + "c" + ); + } + + public String getOwner() { + return getFieldValue(owner); + } + + public void setOwner(String owner) { + setField(this.owner, owner); + } + + public String getObjectiveName() { + return getFieldValue(objectiveName); + } + + public void setObjectiveName(String objectiveName) { + setField(this.objectiveName, objectiveName); + } + + public int getScore() { + return getFieldValue(score); + } + + public void setScore(int score) { + setField(this.score, score); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/WrappedPacketOutScoreboardScore.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/WrappedPacketOutScoreboardScore.java index 7a4697e3..65b067dd 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/WrappedPacketOutScoreboardScore.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/WrappedPacketOutScoreboardScore.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.score; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutScoreboardScore extends PacketScoreboardScoreWrapper { - WrappedPacketOutScoreboardScore(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutScoreboardScore", - networkProtocolGame + "PacketPlayOutScoreboardScore" - ) - ); - } + WrappedPacketOutScoreboardScore(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutScoreboardScore", + networkProtocolGame + "PacketPlayOutScoreboardScore" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/PacketScoreboardTeamWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/PacketScoreboardTeamWrapper.java index 115188e1..0c5b4d34 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/PacketScoreboardTeamWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/PacketScoreboardTeamWrapper.java @@ -1,59 +1,58 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.team; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketScoreboardTeamWrapper extends PacketWrapper { - - Field name; - Field players; - Field method; - - PacketScoreboardTeamWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - name = getFirstField( - "name", - "a" - ); - players = getFirstField( - "players", - "g" - ); - method = getFirstField( - "method", - "h" - ); - } - - public void setName(String name) { - setField(this.name, name); - } - - public void setPlayers(Collection players) { - setField(this.players, players); - } - - public void setMethod(int method) { - setField(this.method, method); - } - - public String getName() { - return getFieldValue(name); - } - - public Collection getPlayers() { - return getFieldValue(players); - } - - public int getMethod() { - return getFieldValue(method); - } + + Field name; + Field players; + Field method; + + PacketScoreboardTeamWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + name = getFirstField( + "name", + "a" + ); + players = getFirstField( + "players", + "g" + ); + method = getFirstField( + "method", + "h" + ); + } + + public String getName() { + return getFieldValue(name); + } + + public void setName(String name) { + setField(this.name, name); + } + + public Collection getPlayers() { + return getFieldValue(players); + } + + public void setPlayers(Collection players) { + setField(this.players, players); + } + + public int getMethod() { + return getFieldValue(method); + } + + public void setMethod(int method) { + setField(this.method, method); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/WrappedPacketOutScoreboardTeam.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/WrappedPacketOutScoreboardTeam.java index df802b3d..80df5d00 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/WrappedPacketOutScoreboardTeam.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/WrappedPacketOutScoreboardTeam.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.team; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutScoreboardTeam extends PacketScoreboardTeamWrapper { - WrappedPacketOutScoreboardTeam(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutScoreboardTeam", - networkProtocolGame + "PacketPlayOutScoreboardTeam" - ) - ); - } + WrappedPacketOutScoreboardTeam(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutScoreboardTeam", + networkProtocolGame + "PacketPlayOutScoreboardTeam" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/PacketServerDifficultyWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/PacketServerDifficultyWrapper.java index a326e0cf..dfe1c05c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/PacketServerDifficultyWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/PacketServerDifficultyWrapper.java @@ -1,51 +1,50 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.serverdifficulty; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketServerDifficultyWrapper extends PacketWrapper { - - Field difficulty; - Field locked; - - PacketServerDifficultyWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - difficulty = getFirstField( - "difficulty", - "a" - ); - locked = getFirstField( - "locked", - "b" - ); - } - - /** - * @param difficulty: EnumDifficulty - */ - public void setDifficulty(Object difficulty) { - setField(this.difficulty, difficulty); - } - - public void setLocked(boolean locked) { - setField(this.locked, locked); - } - - /** - * @return EnumDifficulty - */ - public Object getDifficulty() { - return getFieldValue(difficulty); - } - - public boolean isLocked() { - return getFieldValue(locked); - } + + Field difficulty; + Field locked; + + PacketServerDifficultyWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + difficulty = getFirstField( + "difficulty", + "a" + ); + locked = getFirstField( + "locked", + "b" + ); + } + + /** + * @return EnumDifficulty + */ + public Object getDifficulty() { + return getFieldValue(difficulty); + } + + /** + * @param difficulty: EnumDifficulty + */ + public void setDifficulty(Object difficulty) { + setField(this.difficulty, difficulty); + } + + public boolean isLocked() { + return getFieldValue(locked); + } + + public void setLocked(boolean locked) { + setField(this.locked, locked); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/WrappedPacketOutServerDifficulty.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/WrappedPacketOutServerDifficulty.java index 0e44a516..c2f91979 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/WrappedPacketOutServerDifficulty.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/WrappedPacketOutServerDifficulty.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.serverdifficulty; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutServerDifficulty extends PacketServerDifficultyWrapper { - WrappedPacketOutServerDifficulty(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutServerDifficulty", - networkProtocolGame + "PacketPlayOutServerDifficulty" - ) - ); - } + WrappedPacketOutServerDifficulty(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutServerDifficulty", + networkProtocolGame + "PacketPlayOutServerDifficulty" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/PacketSetCreativeSlotWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/PacketSetCreativeSlotWrapper.java index 508c21ac..9d6b5d34 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/PacketSetCreativeSlotWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/PacketSetCreativeSlotWrapper.java @@ -1,38 +1,37 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.set.creativeslot; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketSetCreativeSlotWrapper extends PacketWrapper { - - Field itemStack; - - PacketSetCreativeSlotWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - itemStack = getFirstField( - "itemStack", - "b" - ); - } - - /** - * @param itemStack: ItemStack - */ - public void setItemStack(Object itemStack) { - setField(this.itemStack, itemStack); - } - - /** - * @return ItemStack - */ - public Object getItemStack() { - return getFieldValue(itemStack); - } + + Field itemStack; + + PacketSetCreativeSlotWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + itemStack = getFirstField( + "itemStack", + "b" + ); + } + + /** + * @return ItemStack + */ + public Object getItemStack() { + return getFieldValue(itemStack); + } + + /** + * @param itemStack: ItemStack + */ + public void setItemStack(Object itemStack) { + setField(this.itemStack, itemStack); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/WrappedPacketInSetCreativeSlot.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/WrappedPacketInSetCreativeSlot.java index 3c89a1af..e20fa6d8 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/WrappedPacketInSetCreativeSlot.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/WrappedPacketInSetCreativeSlot.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.set.creativeslot; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInSetCreativeSlot extends PacketSetCreativeSlotWrapper { - public WrappedPacketInSetCreativeSlot(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInSetCreativeSlot", - networkProtocolGame + "PacketPlayInSetCreativeSlot" - ) - ); - } + public WrappedPacketInSetCreativeSlot(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInSetCreativeSlot", + networkProtocolGame + "PacketPlayInSetCreativeSlot" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/PacketSetSlotWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/PacketSetSlotWrapper.java index 6e60f63d..34b7e254 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/PacketSetSlotWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/PacketSetSlotWrapper.java @@ -1,64 +1,63 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.set.slot; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketSetSlotWrapper extends PacketWrapper { - - Field containerId; - Field slot; - Field itemStack; - PacketSetSlotWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - slot = getFirstField( - "slot", - "b" - ); - itemStack = getFirstField( - "itemStack", - "c" - ); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public void setSlot(int slot) { - setField(this.slot, slot); - } - - /** - * @param itemStack: ItemStack - */ - public void setItemStack(Object itemStack) { - setField(this.itemStack, itemStack); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public int getSlot() { - return getFieldValue(slot); - } - - /** - * @return ItemStack - */ - public Object getItemStack() { - return getFieldValue(itemStack); - } + Field containerId; + Field slot; + Field itemStack; + + PacketSetSlotWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + slot = getFirstField( + "slot", + "b" + ); + itemStack = getFirstField( + "itemStack", + "c" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } + + public int getSlot() { + return getFieldValue(slot); + } + + public void setSlot(int slot) { + setField(this.slot, slot); + } + + /** + * @return ItemStack + */ + public Object getItemStack() { + return getFieldValue(itemStack); + } + + /** + * @param itemStack: ItemStack + */ + public void setItemStack(Object itemStack) { + setField(this.itemStack, itemStack); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/WrappedPacketOutSetSlot.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/WrappedPacketOutSetSlot.java index 7215712f..89fcecc0 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/WrappedPacketOutSetSlot.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/WrappedPacketOutSetSlot.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.set.slot; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutSetSlot extends PacketSetSlotWrapper { - public WrappedPacketOutSetSlot(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutSetSlot", - networkProtocolGame + "PacketPlayOutSetSlot" - ) - ); - } + public WrappedPacketOutSetSlot(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutSetSlot", + networkProtocolGame + "PacketPlayOutSetSlot" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/PacketSettingsWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/PacketSettingsWrapper.java index 16c9cd61..4f7c2072 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/PacketSettingsWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/PacketSettingsWrapper.java @@ -1,14 +1,13 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.settings; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; +import java.util.Set; + abstract class PacketSettingsWrapper extends PacketWrapper { - PacketSettingsWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketSettingsWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/WrappedPacketInSettings.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/WrappedPacketInSettings.java index 21024b20..743fda8f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/WrappedPacketInSettings.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/WrappedPacketInSettings.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.settings; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInSettings extends PacketSettingsWrapper { - public WrappedPacketInSettings(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInSettings", - networkProtocolCommon + "ServerboundClientInformationPacket" - ) - ); - } + public WrappedPacketInSettings(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInSettings", + networkProtocolCommon + "ServerboundClientInformationPacket" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/PacketSpawnEntityWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/PacketSpawnEntityWrapper.java index cf01dbd6..7c2739fa 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/PacketSpawnEntityWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/PacketSpawnEntityWrapper.java @@ -1,45 +1,44 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spawn.entity; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketSpawnEntityWrapper extends PacketWrapper { - Field id; - Field data; - - PacketSpawnEntityWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - id = getFirstField( - "id", - "a" - ); - data = getFirstField( - "data", - "k" - ); - } - - public void setId(int id) { - setField(this.id, id); - } - - public void setData(int data) { - setField(this.data, data); - } - - public int getId() { - return getFieldValue(id); - } - - public int getData() { - return getFieldValue(data); - } + Field id; + Field data; + + PacketSpawnEntityWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + id = getFirstField( + "id", + "a" + ); + data = getFirstField( + "data", + "k" + ); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/WrappedPacketOutSpawnEntity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/WrappedPacketOutSpawnEntity.java index a1f36926..2b863dbb 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/WrappedPacketOutSpawnEntity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/WrappedPacketOutSpawnEntity.java @@ -1,17 +1,17 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spawn.entity; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + // TODO: add all entity spawn packets public class WrappedPacketOutSpawnEntity extends PacketSpawnEntityWrapper { - public WrappedPacketOutSpawnEntity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutSpawnEntity", - networkProtocolGame + "PacketPlayOutSpawnEntity" - ) - ); - } + public WrappedPacketOutSpawnEntity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutSpawnEntity", + networkProtocolGame + "PacketPlayOutSpawnEntity" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/PacketSpawnPositionWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/PacketSpawnPositionWrapper.java index 3c22432d..09eac289 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/PacketSpawnPositionWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/PacketSpawnPositionWrapper.java @@ -1,14 +1,13 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spawn.position; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; +import java.util.Set; + abstract class PacketSpawnPositionWrapper extends PacketWrapper { - PacketSpawnPositionWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketSpawnPositionWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/WrappedPacketOutSpawnPosition.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/WrappedPacketOutSpawnPosition.java index 0bf9808c..d2d014ac 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/WrappedPacketOutSpawnPosition.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/WrappedPacketOutSpawnPosition.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spawn.position; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutSpawnPosition extends PacketSpawnPositionWrapper { - public WrappedPacketOutSpawnPosition(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutSpawnPosition", - networkProtocolGame + "PacketPlayOutSpawnPosition" - ) - ); - } + public WrappedPacketOutSpawnPosition(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutSpawnPosition", + networkProtocolGame + "PacketPlayOutSpawnPosition" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java index ccf33bda..0d2c4a4a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java @@ -1,33 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spectate; -import java.lang.reflect.Field; -import java.util.Set; -import java.util.UUID; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; +import java.util.UUID; + @FieldDefaults(makeFinal = true) abstract class PacketSpectateWrapper extends PacketWrapper { - - Field uuid; - - PacketSpectateWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - uuid = getFirstField( - "uuid", - "a" - ); - } - - public void setUUID(int cameraId) { - setField(this.uuid, cameraId); - } - - public UUID getUUID() { - return getFieldValue(uuid); - } + + Field uuid; + + PacketSpectateWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + uuid = getFirstField( + "uuid", + "a" + ); + } + + public UUID getUUID() { + return getFieldValue(uuid); + } + + public void setUUID(int cameraId) { + setField(this.uuid, cameraId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/WrappedPacketInSpectate.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/WrappedPacketInSpectate.java index 67487f0b..8e0ea36f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/WrappedPacketInSpectate.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/WrappedPacketInSpectate.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spectate; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInSpectate extends PacketSpectateWrapper { - public WrappedPacketInSpectate(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInSpectate", - networkProtocolGame + "PacketPlayInSpectate" - ) - ); - } + public WrappedPacketInSpectate(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInSpectate", + networkProtocolGame + "PacketPlayInSpectate" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/PacketStatisticWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/PacketStatisticWrapper.java index bf444f0e..d3d986d2 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/PacketStatisticWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/PacketStatisticWrapper.java @@ -1,14 +1,13 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.statistic; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; +import java.util.Set; + abstract class PacketStatisticWrapper extends PacketWrapper { - PacketStatisticWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketStatisticWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/WrappedPacketOutStatistic.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/WrappedPacketOutStatistic.java index 0d5f30f5..521d04b9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/WrappedPacketOutStatistic.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/WrappedPacketOutStatistic.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.statistic; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutStatistic extends PacketStatisticWrapper { - public WrappedPacketOutStatistic(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutStatistic", - networkProtocolGame + "PacketPlayOutStatistic" - ) - ); - } + public WrappedPacketOutStatistic(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutStatistic", + networkProtocolGame + "PacketPlayOutStatistic" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/PacketSteerVehicleWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/PacketSteerVehicleWrapper.java index 6b4110ef..06c6be60 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/PacketSteerVehicleWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/PacketSteerVehicleWrapper.java @@ -1,14 +1,13 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.steervehicle; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; +import java.util.Set; + abstract class PacketSteerVehicleWrapper extends PacketWrapper { - PacketSteerVehicleWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketSteerVehicleWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/WrappedPacketInSteerVehicle.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/WrappedPacketInSteerVehicle.java index 9484d311..96d8f4f3 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/WrappedPacketInSteerVehicle.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/WrappedPacketInSteerVehicle.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.steervehicle; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInSteerVehicle extends PacketSteerVehicleWrapper { - public WrappedPacketInSteerVehicle(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInSteerVehicle", - networkProtocolGame + "PacketPlayInSteerVehicle" - ) - ); - } + public WrappedPacketInSteerVehicle(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInSteerVehicle", + networkProtocolGame + "PacketPlayInSteerVehicle" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/PacketTabCompleteWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/PacketTabCompleteWrapper.java index 5e7cf2f5..d9836b12 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/PacketTabCompleteWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/PacketTabCompleteWrapper.java @@ -1,14 +1,13 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tabcomplete; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; +import java.util.Set; + abstract class PacketTabCompleteWrapper extends PacketWrapper { - PacketTabCompleteWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketTabCompleteWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketInTabComplete.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketInTabComplete.java index 13426f7d..7f9ff433 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketInTabComplete.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketInTabComplete.java @@ -1,34 +1,34 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tabcomplete; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketInTabComplete extends PacketTabCompleteWrapper { - Field command; - - public WrappedPacketInTabComplete(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInTabComplete", - networkProtocolGame + "PacketPlayInTabComplete" - ) - ); - - command = getFirstField( - "command", - "b" - ); - } - - public void setCommand(int command) { - setField(this.command, command); - } - - public String getCommand() { - return getFieldValue(command); - } + Field command; + + public WrappedPacketInTabComplete(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInTabComplete", + networkProtocolGame + "PacketPlayInTabComplete" + ) + ); + + command = getFirstField( + "command", + "b" + ); + } + + public String getCommand() { + return getFieldValue(command); + } + + public void setCommand(int command) { + setField(this.command, command); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketOutTabComplete.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketOutTabComplete.java index a84a0db5..7f5e5262 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketOutTabComplete.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketOutTabComplete.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tabcomplete; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutTabComplete extends PacketTabCompleteWrapper { - - public WrappedPacketOutTabComplete(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTabComplete", - networkProtocolGame + "PacketPlayOutTabComplete" - ) - ); - } + + public WrappedPacketOutTabComplete(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTabComplete", + networkProtocolGame + "PacketPlayOutTabComplete" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/PacketTileEntityDataWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/PacketTileEntityDataWrapper.java index 2d6fbaa8..180398ca 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/PacketTileEntityDataWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/PacketTileEntityDataWrapper.java @@ -1,70 +1,69 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tileentitydata; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketTileEntityDataWrapper extends PacketWrapper { - - Field pos; - Field type; - Field tag; - PacketTileEntityDataWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - type = getFirstField( - "type", - "b" - ); - tag = getFirstField( - "tag", - "c" - ); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - public void setType(int type) { - setField(this.type, type); - } - - /** - * @param tag: NBTTagCompound - */ - public void setTag(Object tag) { - setField(this.tag, tag); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - public int getType() { - return getFieldValue(type); - } - - /** - * @return NBTTagCompound - */ - public Object getTag() { - return getFieldValue(tag); - } + Field pos; + Field type; + Field tag; + + PacketTileEntityDataWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + type = getFirstField( + "type", + "b" + ); + tag = getFirstField( + "tag", + "c" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } + + public int getType() { + return getFieldValue(type); + } + + public void setType(int type) { + setField(this.type, type); + } + + /** + * @return NBTTagCompound + */ + public Object getTag() { + return getFieldValue(tag); + } + + /** + * @param tag: NBTTagCompound + */ + public void setTag(Object tag) { + setField(this.tag, tag); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/WrappedPacketOutTileEntityData.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/WrappedPacketOutTileEntityData.java index c682b0c3..6962ede9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/WrappedPacketOutTileEntityData.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/WrappedPacketOutTileEntityData.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tileentitydata; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutTileEntityData extends PacketTileEntityDataWrapper { - public WrappedPacketOutTileEntityData(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTileEntityData", - networkProtocolGame + "PacketPlayOutTileEntityData" - ) - ); - } + public WrappedPacketOutTileEntityData(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTileEntityData", + networkProtocolGame + "PacketPlayOutTileEntityData" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/PacketTitleWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/PacketTitleWrapper.java index 7f3ee5d9..be2e66f2 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/PacketTitleWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/PacketTitleWrapper.java @@ -1,14 +1,13 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.title; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; +import java.util.Set; + abstract class PacketTitleWrapper extends PacketWrapper { - PacketTitleWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketTitleWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutAnimationTitle.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutAnimationTitle.java index 05a94457..7b5e3fa0 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutAnimationTitle.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutAnimationTitle.java @@ -1,63 +1,63 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.title; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutAnimationTitle extends PacketTitleWrapper { - Field fadeInTime; - Field stayTime; - Field fadeOutTime; - - WrappedPacketOutAnimationTitle(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTitle", - networkProtocolGame + "ClientboundSetTitlesAnimationPacket" - ) - ); - - fadeInTime = getFirstField( - "fadeInTime", - "fadeIn", - "c" - ); - stayTime = getFirstField( - "stayTime", - "stay", - "d" - ); - fadeOutTime = getFirstField( - "fadeOutTime", - "fadeOut", - "e" - ); - } - - public void setFadeInTime(int fadeInTime) { - setField(this.fadeInTime, fadeInTime); - } - - public void setStayTime(int stayTime) { - setField(this.stayTime, stayTime); - } - - public void setFadeOutTime(int fadeOutTime) { - setField(this.fadeOutTime, fadeOutTime); - } - - public int getFadeInTime() { - return getFieldValue(fadeInTime); - } - - public int getStayTime() { - return getFieldValue(stayTime); - } - - public int getFadeOutTime() { - return getFieldValue(fadeOutTime); - } + Field fadeInTime; + Field stayTime; + Field fadeOutTime; + + WrappedPacketOutAnimationTitle(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTitle", + networkProtocolGame + "ClientboundSetTitlesAnimationPacket" + ) + ); + + fadeInTime = getFirstField( + "fadeInTime", + "fadeIn", + "c" + ); + stayTime = getFirstField( + "stayTime", + "stay", + "d" + ); + fadeOutTime = getFirstField( + "fadeOutTime", + "fadeOut", + "e" + ); + } + + public int getFadeInTime() { + return getFieldValue(fadeInTime); + } + + public void setFadeInTime(int fadeInTime) { + setField(this.fadeInTime, fadeInTime); + } + + public int getStayTime() { + return getFieldValue(stayTime); + } + + public void setStayTime(int stayTime) { + setField(this.stayTime, stayTime); + } + + public int getFadeOutTime() { + return getFieldValue(fadeOutTime); + } + + public void setFadeOutTime(int fadeOutTime) { + setField(this.fadeOutTime, fadeOutTime); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutSubtitleTitle.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutSubtitleTitle.java index 8d9b881d..6e2f446f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutSubtitleTitle.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutSubtitleTitle.java @@ -1,40 +1,40 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.title; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutSubtitleTitle extends PacketTitleWrapper { - - Field text; - - WrappedPacketOutSubtitleTitle(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTitle", - networkProtocolGame + "ClientboundSetSubtitleTextPacket" - ) - ); - - text = getFirstField( - "text", - "b" - ); - } - - /** - * @param text: IChatBaseComponent - */ - public void setText(Object text) { - setField(this.text, text); - } - - /** - * @return IChatBaseComponent - */ - public Object getText() { - return getFieldValue(text); - } + + Field text; + + WrappedPacketOutSubtitleTitle(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTitle", + networkProtocolGame + "ClientboundSetSubtitleTextPacket" + ) + ); + + text = getFirstField( + "text", + "b" + ); + } + + /** + * @return IChatBaseComponent + */ + public Object getText() { + return getFieldValue(text); + } + + /** + * @param text: IChatBaseComponent + */ + public void setText(Object text) { + setField(this.text, text); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutTitleTitle.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutTitleTitle.java index 40ec6468..76606d54 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutTitleTitle.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutTitleTitle.java @@ -1,40 +1,40 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.title; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutTitleTitle extends PacketTitleWrapper { - - Field text; - - WrappedPacketOutTitleTitle(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTitle", - networkProtocolGame + "ClientboundSetTitleTextPacket" - ) - ); - - text = getFirstField( - "text", - "b" - ); - } - - /** - * @param text: IChatBaseComponent - */ - public void setText(Object text) { - setField(this.text, text); - } - - /** - * @return IChatBaseComponent - */ - public Object getText() { - return getFieldValue(text); - } + + Field text; + + WrappedPacketOutTitleTitle(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTitle", + networkProtocolGame + "ClientboundSetTitleTextPacket" + ) + ); + + text = getFirstField( + "text", + "b" + ); + } + + /** + * @return IChatBaseComponent + */ + public Object getText() { + return getFieldValue(text); + } + + /** + * @param text: IChatBaseComponent + */ + public void setText(Object text) { + setField(this.text, text); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/PacketUpdateAttributesWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/PacketUpdateAttributesWrapper.java index 1db9146c..96b2ac05 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/PacketUpdateAttributesWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/PacketUpdateAttributesWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.attributes; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketUpdateAttributesWrapper extends PacketWrapper { - - Field entityId; - - PacketUpdateAttributesWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - entityId = getFirstField( - "entityId", - "a" - ); - } - - public void setPos(int entityId) { - setField(this.entityId, entityId); - } - - public int getEntityId() { - return getFieldValue(entityId); - } + + Field entityId; + + PacketUpdateAttributesWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + entityId = getFirstField( + "entityId", + "a" + ); + } + + public void setPos(int entityId) { + setField(this.entityId, entityId); + } + + public int getEntityId() { + return getFieldValue(entityId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/WrappedPacketOutUpdateAttributes.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/WrappedPacketOutUpdateAttributes.java index c7535f73..dc8b317e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/WrappedPacketOutUpdateAttributes.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/WrappedPacketOutUpdateAttributes.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.attributes; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutUpdateAttributes extends PacketUpdateAttributesWrapper { - public WrappedPacketOutUpdateAttributes(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutUpdateAttributes", - networkProtocolGame + "PacketPlayOutUpdateAttributes" - ) - ); - } + public WrappedPacketOutUpdateAttributes(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutUpdateAttributes", + networkProtocolGame + "PacketPlayOutUpdateAttributes" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/PacketUpdateHealthWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/PacketUpdateHealthWrapper.java index aa7b4523..4ab06c9b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/PacketUpdateHealthWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/PacketUpdateHealthWrapper.java @@ -1,58 +1,57 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.health; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketUpdateHealthWrapper extends PacketWrapper { - - Field health; - Field food; - Field saturation; - - PacketUpdateHealthWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - health = getFirstField( - "health", - "a" - ); - food = getFirstField( - "food", - "b" - ); - saturation = getFirstField( - "saturation", - "c" - ); - } - - public void setHealth(float health) { - setField(this.health, health); - } - - public void setFood(int food) { - setField(this.food, food); - } - - public void setSaturation(int saturation) { - setField(this.saturation, saturation); - } - - public float getHealth() { - return getFieldValue(health); - } - - public int getFood() { - return getFieldValue(food); - } - - public float getSaturation() { - return getFieldValue(saturation); - } + + Field health; + Field food; + Field saturation; + + PacketUpdateHealthWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + health = getFirstField( + "health", + "a" + ); + food = getFirstField( + "food", + "b" + ); + saturation = getFirstField( + "saturation", + "c" + ); + } + + public float getHealth() { + return getFieldValue(health); + } + + public void setHealth(float health) { + setField(this.health, health); + } + + public int getFood() { + return getFieldValue(food); + } + + public void setFood(int food) { + setField(this.food, food); + } + + public float getSaturation() { + return getFieldValue(saturation); + } + + public void setSaturation(int saturation) { + setField(this.saturation, saturation); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/WrappedPacketOutUpdateHealth.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/WrappedPacketOutUpdateHealth.java index c40f47a5..eb8e53e7 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/WrappedPacketOutUpdateHealth.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/WrappedPacketOutUpdateHealth.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.health; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutUpdateHealth extends PacketUpdateHealthWrapper { - public WrappedPacketOutUpdateHealth(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutUpdateHealth", - networkProtocolGame + "PacketPlayOutUpdateHealth" - ) - ); - } + public WrappedPacketOutUpdateHealth(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutUpdateHealth", + networkProtocolGame + "PacketPlayOutUpdateHealth" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/PacketUpdateSignWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/PacketUpdateSignWrapper.java index 95794ebb..7b2c511a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/PacketUpdateSignWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/PacketUpdateSignWrapper.java @@ -1,38 +1,37 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.sign; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketUpdateSignWrapper extends PacketWrapper { - - Field pos; - - PacketUpdateSignWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } + + Field pos; + + PacketUpdateSignWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/WrappedPacketInUpdateSign.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/WrappedPacketInUpdateSign.java index 0e07780b..1e311817 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/WrappedPacketInUpdateSign.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/WrappedPacketInUpdateSign.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.sign; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInUpdateSign extends PacketUpdateSignWrapper { - public WrappedPacketInUpdateSign(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInUpdateSign", - networkProtocolGame + "PacketPlayInUpdateSign" - ) - ); - } + public WrappedPacketInUpdateSign(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInUpdateSign", + networkProtocolGame + "PacketPlayInUpdateSign" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/PacketUpdateTimeWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/PacketUpdateTimeWrapper.java index bd49f4bf..addae0cc 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/PacketUpdateTimeWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/PacketUpdateTimeWrapper.java @@ -1,45 +1,44 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.time; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketUpdateTimeWrapper extends PacketWrapper { - - Field gameTime; - Field dayTime; - - PacketUpdateTimeWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - gameTime = getFirstField( - "gameTime", - "a" - ); - dayTime = getFirstField( - "dayTime", - "b" - ); - } - - public void setGameTime(long gameTime) { - setField(this.gameTime, gameTime); - } - - public void setDayTime(long dayTime) { - setField(this.dayTime, dayTime); - } - - public long getGameTime() { - return getFieldValue(gameTime); - } - - public long getDayTime() { - return getFieldValue(dayTime); - } + + Field gameTime; + Field dayTime; + + PacketUpdateTimeWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + gameTime = getFirstField( + "gameTime", + "a" + ); + dayTime = getFirstField( + "dayTime", + "b" + ); + } + + public long getGameTime() { + return getFieldValue(gameTime); + } + + public void setGameTime(long gameTime) { + setField(this.gameTime, gameTime); + } + + public long getDayTime() { + return getFieldValue(dayTime); + } + + public void setDayTime(long dayTime) { + setField(this.dayTime, dayTime); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/WrappedPacketOutUpdateTime.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/WrappedPacketOutUpdateTime.java index 744f6138..29b78790 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/WrappedPacketOutUpdateTime.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/WrappedPacketOutUpdateTime.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.time; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutUpdateTime extends PacketUpdateTimeWrapper { - public WrappedPacketOutUpdateTime(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutUpdateTime", - networkProtocolGame + "PacketPlayOutUpdateTime" - ) - ); - } + public WrappedPacketOutUpdateTime(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutUpdateTime", + networkProtocolGame + "PacketPlayOutUpdateTime" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindow.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindow.java index 88022c01..a245c33c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindow.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindow.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketUpdateWindow extends PacketWrapper { - - Field containerId; - - PacketUpdateWindow(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public int getContainerId() { - return getFieldValue(containerId); - } + + Field containerId; + + PacketUpdateWindow(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowData.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowData.java index a5c118be..79fe70cf 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowData.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowData.java @@ -1,43 +1,43 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; -import java.lang.reflect.Field; -import java.util.Set; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketUpdateWindowData extends PacketUpdateWindow { - - Field id; - Field value; - - PacketUpdateWindowData(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - id = getFirstField( - "id", - "b" - ); - value = getFirstField( - "value", - "c" - ); - } - - public void setId(int id) { - setField(this.id, id); - } - - public void setValue(int value) { - setField(this.value, value); - } - - public int getId() { - return getFieldValue(id); - } - - public int getValue() { - return getFieldValue(value); - } + + Field id; + Field value; + + PacketUpdateWindowData(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + id = getFirstField( + "id", + "b" + ); + value = getFirstField( + "value", + "c" + ); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public int getValue() { + return getFieldValue(value); + } + + public void setValue(int value) { + setField(this.value, value); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowItems.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowItems.java index 434839f9..30a7ab4e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowItems.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowItems.java @@ -1,12 +1,12 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + abstract class PacketUpdateWindowItems extends PacketUpdateWindow { - PacketUpdateWindowItems(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketUpdateWindowItems(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowData.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowData.java index d08c7bba..7d43075e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowData.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowData.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutWindowData extends PacketUpdateWindowData { - public WrappedPacketOutWindowData(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWindowData", - networkProtocolGame + "PacketPlayOutWindowData" - ) - ); - } + public WrappedPacketOutWindowData(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWindowData", + networkProtocolGame + "PacketPlayOutWindowData" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowItems.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowItems.java index bb3494f9..9b7eca30 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowItems.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowItems.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutWindowItems extends PacketUpdateWindowItems { - public WrappedPacketOutWindowItems(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWindowItems", - networkProtocolGame + "PacketPlayOutWindowItems" - ) - ); - } + public WrappedPacketOutWindowItems(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWindowItems", + networkProtocolGame + "PacketPlayOutWindowItems" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/PacketUseEntityWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/PacketUseEntityWrapper.java index 930141cf..5b7953f1 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/PacketUseEntityWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/PacketUseEntityWrapper.java @@ -1,48 +1,47 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.use; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketUseEntityWrapper extends PacketWrapper { - - Field entityId; - Field action; - - PacketUseEntityWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - entityId = getFirstField( - "entityId", - "a" - ); - action = getField("action"); - } - - public void setEntityId(int entityId) { - setField(this.entityId, entityId); - } - - /** - * @param action: PacketPlayInUseEntity$EnumEntityUseAction - */ - public void setAction(Object action) { - setField(this.action, action); - } - - public int getEntityId() { - return getFieldValue(entityId); - } - - /** - * @return PacketPlayInUseEntity$EnumEntityUseAction - */ - public Object getAction() { - return getFieldValue(action); - } + + Field entityId; + Field action; + + PacketUseEntityWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + entityId = getFirstField( + "entityId", + "a" + ); + action = getField("action"); + } + + public int getEntityId() { + return getFieldValue(entityId); + } + + public void setEntityId(int entityId) { + setField(this.entityId, entityId); + } + + /** + * @return PacketPlayInUseEntity$EnumEntityUseAction + */ + public Object getAction() { + return getFieldValue(action); + } + + /** + * @param action: PacketPlayInUseEntity$EnumEntityUseAction + */ + public void setAction(Object action) { + setField(this.action, action); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/WrappedPacketInUseEntity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/WrappedPacketInUseEntity.java index 5ab2ceeb..e91583b4 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/WrappedPacketInUseEntity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/WrappedPacketInUseEntity.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.use; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInUseEntity extends PacketUseEntityWrapper { - public WrappedPacketInUseEntity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInUseEntity", - networkProtocolGame + "PacketPlayInUseEntity" - ) - ); - } + public WrappedPacketInUseEntity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInUseEntity", + networkProtocolGame + "PacketPlayInUseEntity" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/PacketWindowClickWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/PacketWindowClickWrapper.java index d2f37d91..9c7fa82e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/PacketWindowClickWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/PacketWindowClickWrapper.java @@ -1,71 +1,70 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.click; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketWindowClickWrapper extends PacketWrapper { - - Field containerId; - Field slotNum; - Field buttonNum; - Field uid; - PacketWindowClickWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - slotNum = getFirstField( - "slotNum", - "b" - ); - buttonNum = getFirstField( - "buttonNum", - "c" - ); - uid = getFirstField( - "uid", - "d" - ); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public void setSlotNum(int slotNum) { - setField(this.slotNum, slotNum); - } - - public void setButtonNum(int buttonNum) { - setField(this.buttonNum, buttonNum); - } - - public void setUID(short uid) { - setField(this.uid, uid); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public int getSlotNum() { - return getFieldValue(slotNum); - } - - public int getButtonNum() { - return getFieldValue(buttonNum); - } - - public short getUID() { - return getFieldValue(uid); - } + Field containerId; + Field slotNum; + Field buttonNum; + Field uid; + + PacketWindowClickWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + slotNum = getFirstField( + "slotNum", + "b" + ); + buttonNum = getFirstField( + "buttonNum", + "c" + ); + uid = getFirstField( + "uid", + "d" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } + + public int getSlotNum() { + return getFieldValue(slotNum); + } + + public void setSlotNum(int slotNum) { + setField(this.slotNum, slotNum); + } + + public int getButtonNum() { + return getFieldValue(buttonNum); + } + + public void setButtonNum(int buttonNum) { + setField(this.buttonNum, buttonNum); + } + + public short getUID() { + return getFieldValue(uid); + } + + public void setUID(short uid) { + setField(this.uid, uid); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/WrappedPacketInWindowClick.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/WrappedPacketInWindowClick.java index 6fcb5e34..14d94b5c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/WrappedPacketInWindowClick.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/WrappedPacketInWindowClick.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.click; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketInWindowClick extends PacketWindowClickWrapper { - public WrappedPacketInWindowClick(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInWindowClick", - networkProtocolGame + "PacketPlayInWindowClick" - ) - ); - } + public WrappedPacketInWindowClick(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInWindowClick", + networkProtocolGame + "PacketPlayInWindowClick" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/PacketWindowDataWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/PacketWindowDataWrapper.java index c521b72a..4d5bb297 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/PacketWindowDataWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/PacketWindowDataWrapper.java @@ -1,58 +1,57 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.data; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketWindowDataWrapper extends PacketWrapper { - - Field containerId; - Field id; - Field value; - - PacketWindowDataWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - id = getFirstField( - "id", - "b" - ); - value = getFirstField( - "value", - "c" - ); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public void setId(int id) { - setField(this.id, id); - } - - public void setValue(int value) { - setField(this.value, value); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public int getId() { - return getFieldValue(id); - } - - public int getValue() { - return getFieldValue(value); - } + + Field containerId; + Field id; + Field value; + + PacketWindowDataWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + id = getFirstField( + "id", + "b" + ); + value = getFirstField( + "value", + "c" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public int getValue() { + return getFieldValue(value); + } + + public void setValue(int value) { + setField(this.value, value); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/WrappedPacketOutWindowData.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/WrappedPacketOutWindowData.java index 1d13bc38..dd1f5c89 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/WrappedPacketOutWindowData.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/WrappedPacketOutWindowData.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.data; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutWindowData extends PacketWindowDataWrapper { - public WrappedPacketOutWindowData(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWindowData", - networkProtocolGame + "PacketPlayOutWindowData" - ) - ); - } + public WrappedPacketOutWindowData(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWindowData", + networkProtocolGame + "PacketPlayOutWindowData" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/PacketWindowItemsWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/PacketWindowItemsWrapper.java index fb761c6b..405c0330 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/PacketWindowItemsWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/PacketWindowItemsWrapper.java @@ -1,32 +1,31 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.items; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + @FieldDefaults(makeFinal = true) abstract class PacketWindowItemsWrapper extends PacketWrapper { - - Field containerId; - - PacketWindowItemsWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public int getContainerId() { - return getFieldValue(containerId); - } + + Field containerId; + + PacketWindowItemsWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/WrappedPacketOutWindowItems.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/WrappedPacketOutWindowItems.java index 213cb73a..c8a99b6c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/WrappedPacketOutWindowItems.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/WrappedPacketOutWindowItems.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.items; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutWindowItems extends PacketWindowItemsWrapper { - public WrappedPacketOutWindowItems(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWindowItems", - networkProtocolGame + "PacketPlayOutWindowItems" - ) - ); - } + public WrappedPacketOutWindowItems(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWindowItems", + networkProtocolGame + "PacketPlayOutWindowItems" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/PacketWorldEventWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/PacketWorldEventWrapper.java index 7c741f03..60df5226 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/PacketWorldEventWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/PacketWorldEventWrapper.java @@ -1,78 +1,77 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.world.event; -import java.lang.reflect.Field; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - import lombok.NonNull; import lombok.experimental.FieldDefaults; +import java.lang.reflect.Field; +import java.util.Set; + // TODO: add PacketPlayOutWorldParticles wrapper @FieldDefaults(makeFinal = true) abstract class PacketWorldEventWrapper extends PacketWrapper { - - Field type; - Field pos; - Field data; - Field globalEvent; - PacketWorldEventWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - type = getFirstField( - "type", - "a" - ); - pos = getFirstField( - "pos", - "b" - ); - data = getFirstField( - "data", - "c" - ); - globalEvent = getFirstField( - "globalEvent", - "d" - ); - } - - public void setType(int type) { - setField(this.type, type); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - public void setData(int data) { - setField(this.data, data); - } - - public void setGlobalEvent(boolean globalEvent) { - setField(this.globalEvent, globalEvent); - } - - public int getType() { - return getFieldValue(type); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(type); - } - - public int getData() { - return getFieldValue(data); - } - - public boolean isGlobalEvent() { - return getFieldValue(globalEvent); - } + Field type; + Field pos; + Field data; + Field globalEvent; + + PacketWorldEventWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + type = getFirstField( + "type", + "a" + ); + pos = getFirstField( + "pos", + "b" + ); + data = getFirstField( + "data", + "c" + ); + globalEvent = getFirstField( + "globalEvent", + "d" + ); + } + + public int getType() { + return getFieldValue(type); + } + + public void setType(int type) { + setField(this.type, type); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(type); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } + + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } + + public boolean isGlobalEvent() { + return getFieldValue(globalEvent); + } + + public void setGlobalEvent(boolean globalEvent) { + setField(this.globalEvent, globalEvent); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/WrappedPacketOutWorldEvent.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/WrappedPacketOutWorldEvent.java index afaa669a..a6d8a8fc 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/WrappedPacketOutWorldEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/WrappedPacketOutWorldEvent.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.world.event; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public class WrappedPacketOutWorldEvent extends PacketWorldEventWrapper { - public WrappedPacketOutWorldEvent(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWorldEvent", - networkProtocolGame + "PacketPlayOutWorldEvent" - ) - ); - } + public WrappedPacketOutWorldEvent(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWorldEvent", + networkProtocolGame + "PacketPlayOutWorldEvent" + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/PlayerElement.java b/src/com/falchus/lib/minecraft/spigot/player/elements/PlayerElement.java index 477b67e6..4fa4f7aa 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/PlayerElement.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/PlayerElement.java @@ -1,18 +1,16 @@ package com.falchus.lib.minecraft.spigot.player.elements; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.falchus.lib.task.Task; import com.falchus.lib.utils.builder.ClassInstanceBuilder; - import lombok.NonNull; import lombok.RequiredArgsConstructor; +import org.bukkit.entity.Player; + +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; /** * Abstract base class for player-related elements. @@ -20,100 +18,98 @@ @RequiredArgsConstructor public abstract class PlayerElement { - protected final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - protected final Player player; - private static final Map, Map> instances = new ConcurrentHashMap<>(); private static final Map, Map> tasks = new ConcurrentHashMap<>(); - + protected final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + protected final Player player; protected Runnable updateRunnable; - - /** - * Updates the element manually. - */ - public void update() { - if (updateRunnable == null) return; - - if (!player.isOnline()) { - remove(); - return; - } - updateRunnable.run(); - } - - /** - * Updates all online players manually. - */ - public static void updateAll(@NonNull Class clazz) { - Map map = instances.get(clazz); - if (map == null) return; - - map.values().forEach(PlayerElement::update); - } - - /** - * Sends the element to the player repeatedly with a fixed interval (in {@link TimeUnit#MILLISECONDS}). - */ - public void sendUpdating(long intervalTicks, @NonNull Runnable runnable) { - Map map = tasks.computeIfAbsent(getClass(), c -> new ConcurrentHashMap<>()); - - Task oldTask = map.get(player.getUniqueId()); - if (oldTask != null) { - remove(); - } - - Task task = Task.runTaskTimer(() -> { - if (!player.isOnline()) { - remove(); - return; - } - runnable.run(); - }, intervalTicks, TimeUnit.MILLISECONDS); - - map.put(player.getUniqueId(), task); - } - - /** - * Removes this element and cancels any schedules repeating tasks. - */ - public void remove() { - Map map = tasks.get(getClass()); - if (map != null) { - Task task = map.remove(player.getUniqueId()); - if (task != null) { - task.end(); - } - } - - Map instance = instances.get(getClass()); - if (instance != null) { - instance.remove(player.getUniqueId()); - } - } - - /** - * Retrieves a singleton instance of a PlayerElement subclass for a given player. - * If it does not exist, it is created via reflection using a constructor that accepts a Player parameter. - */ - @SuppressWarnings("unchecked") - public static T get(@NonNull Class clazz, @NonNull Player player) { - if (!PlayerElement.class.isAssignableFrom(clazz)) return null; - Map map = instances.computeIfAbsent(clazz, c -> new ConcurrentHashMap<>()); - - return (T) map.computeIfAbsent(player.getUniqueId(), uuid -> { - try { - return (T) new ClassInstanceBuilder(clazz) - .withParams( - Map.of( - Player.class, - player - ) - ) - .build(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - }); - } + + /** + * Updates all online players manually. + */ + public static void updateAll(@NonNull Class clazz) { + Map map = instances.get(clazz); + if (map == null) return; + + map.values().forEach(PlayerElement::update); + } + + /** + * Retrieves a singleton instance of a PlayerElement subclass for a given player. + * If it does not exist, it is created via reflection using a constructor that accepts a Player parameter. + */ + @SuppressWarnings("unchecked") + public static T get(@NonNull Class clazz, @NonNull Player player) { + if (!PlayerElement.class.isAssignableFrom(clazz)) return null; + Map map = instances.computeIfAbsent(clazz, c -> new ConcurrentHashMap<>()); + + return (T) map.computeIfAbsent(player.getUniqueId(), uuid -> { + try { + return (T) new ClassInstanceBuilder(clazz) + .withParams( + Map.of( + Player.class, + player + ) + ) + .build(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + }); + } + + /** + * Updates the element manually. + */ + public void update() { + if (updateRunnable == null) return; + + if (!player.isOnline()) { + remove(); + return; + } + updateRunnable.run(); + } + + /** + * Sends the element to the player repeatedly with a fixed interval (in {@link TimeUnit#MILLISECONDS}). + */ + public void sendUpdating(long intervalTicks, @NonNull Runnable runnable) { + Map map = tasks.computeIfAbsent(getClass(), c -> new ConcurrentHashMap<>()); + + Task oldTask = map.get(player.getUniqueId()); + if (oldTask != null) { + remove(); + } + + Task task = Task.runTaskTimer(() -> { + if (!player.isOnline()) { + remove(); + return; + } + runnable.run(); + }, intervalTicks, TimeUnit.MILLISECONDS); + + map.put(player.getUniqueId(), task); + } + + /** + * Removes this element and cancels any schedules repeating tasks. + */ + public void remove() { + Map map = tasks.get(getClass()); + if (map != null) { + Task task = map.remove(player.getUniqueId()); + if (task != null) { + task.end(); + } + } + + Map instance = instances.get(getClass()); + if (instance != null) { + instance.remove(player.getUniqueId()); + } + } } diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Actionbar.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Actionbar.java index 938970ed..8f8d4ed8 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Actionbar.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Actionbar.java @@ -1,44 +1,42 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import java.util.function.Supplier; - -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; - import lombok.NonNull; +import org.bukkit.entity.Player; + +import java.util.function.Supplier; public class Actionbar extends PlayerElement { - - private Supplier messageSupplier; - - private Actionbar(@NonNull Player player) { - super(player); - } - - /** - * Sends a one-time action bar message. - */ - public void send(@NonNull Supplier message) { - messageSupplier = message; - - updateRunnable = () -> { - String newMessage = messageSupplier.get(); - - PlayerUtils.sendActionbar(player, newMessage); - }; - update(); - } - - /** - * Sends an action bar message repeatedly at a fixed interval. - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier message) { - super.sendUpdating(intervalTicks, () -> - send( - message - ) - ); - } + + private Supplier messageSupplier; + + private Actionbar(@NonNull Player player) { + super(player); + } + + /** + * Sends a one-time action bar message. + */ + public void send(@NonNull Supplier message) { + messageSupplier = message; + + updateRunnable = () -> { + String newMessage = messageSupplier.get(); + + PlayerUtils.sendActionbar(player, newMessage); + }; + update(); + } + + /** + * Sends an action bar message repeatedly at a fixed interval. + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier message) { + super.sendUpdating(intervalTicks, () -> + send( + message + ) + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Bossbar.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Bossbar.java index e706562d..3c573c3d 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Bossbar.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Bossbar.java @@ -1,77 +1,75 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import java.util.function.Supplier; - -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.enums.Version; import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; import com.falchus.lib.minecraft.spigot.utils.ServerUtils; - import lombok.NonNull; +import org.bukkit.entity.Player; + +import java.util.function.Supplier; public class Bossbar extends PlayerElement { - private Supplier messageSupplier; - private Supplier progressSupplier; - - private Bossbar(@NonNull Player player) { - super(player); + private Supplier messageSupplier; + private Supplier progressSupplier; + + private Bossbar(@NonNull Player player) { + super(player); } - - /** - * Sends a one-time Bossbar message. - */ - public void send(@NonNull Supplier message, @NonNull Supplier progress) { + + /** + * Sends a one-time Bossbar message. + */ + public void send(@NonNull Supplier message, @NonNull Supplier progress) { messageSupplier = message; progressSupplier = progress; - + updateRunnable = () -> { - String newMessage = messageSupplier.get(); - double newProgress = progressSupplier.get(); - - PlayerUtils.sendBossbar(player, newMessage, newProgress); + String newMessage = messageSupplier.get(); + double newProgress = progressSupplier.get(); + + PlayerUtils.sendBossbar(player, newMessage, newProgress); }; update(); - } - - /** - * Sends a Bossbar message repeatedly at a fixed interval. - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier message, @NonNull Supplier progress) { - if (ServerUtils.getVersion().isBefore(Version.v1_17)) { - super.sendUpdating(intervalTicks, () -> - send( - message, - progress - ) - ); - } else { - send( - message, - progress - ); - } - } - - /** - * Removes the Bossbar, cancelling any ongoing update tasks. - */ - @Override - public void remove() { - super.remove(); - - PlayerUtils.removeBossbar(player); - } - - /** - * Sets the health/progress of the Bossbar. - */ - public void setProgress(double progress) { - send( - messageSupplier, - () -> progress - ); - } + } + + /** + * Sends a Bossbar message repeatedly at a fixed interval. + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier message, @NonNull Supplier progress) { + if (ServerUtils.getVersion().isBefore(Version.v1_17)) { + super.sendUpdating(intervalTicks, () -> + send( + message, + progress + ) + ); + } else { + send( + message, + progress + ); + } + } + + /** + * Removes the Bossbar, cancelling any ongoing update tasks. + */ + @Override + public void remove() { + super.remove(); + + PlayerUtils.removeBossbar(player); + } + + /** + * Sets the health/progress of the Bossbar. + */ + public void setProgress(double progress) { + send( + messageSupplier, + () -> progress + ); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Chat.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Chat.java index 876dd08a..a0e8f091 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Chat.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Chat.java @@ -1,87 +1,145 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.function.Supplier; - +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; +import io.papermc.paper.event.player.AsyncChatEvent; +import lombok.NonNull; +import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.jetbrains.annotations.NotNull; -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; - -import lombok.NonNull; +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Supplier; +/** + * Sets a custom chat prefix for a player. + *

+ * On servers that expose the Paper 26.x {@code AsyncChatEvent}, + * that event is preferred because {@link AsyncPlayerChatEvent} is deprecated there. + * The detection is done at runtime via reflection so the library can still compile + * against plain Spigot. + */ public class Chat extends PlayerElement implements Listener { - private static final Map> prefixSuppliers = new HashMap<>(); - private static final Map lastPrefixes = new HashMap<>(); - - private static final List registered = new ArrayList<>(); - - private Chat(@NonNull Player player) { - super(player); - } - - /** - * Sets one-time. - */ - public void send(@NonNull Supplier prefix) { - if (registered.size() == 0) { - Bukkit.getPluginManager().registerEvents(this, plugin); - registered.add(true); - } - - prefixSuppliers.put(player.getUniqueId(), prefix); - - updateRunnable = () -> { - String lastPrefix = lastPrefixes.get(player.getUniqueId()); - String newPrefix = prefixSuppliers.get(player.getUniqueId()).get(); - - if (lastPrefix == null || !newPrefix.equals(lastPrefix)) { - lastPrefixes.put(player.getUniqueId(), newPrefix); - } - }; - update(); - } - - /** - * Updates periodically. - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier prefix) { - super.sendUpdating(intervalTicks, () -> - send( - prefix - ) - ); - } - - /** - * Removes the chat element. - */ - public void remove() { - super.remove(); - - prefixSuppliers.remove(player.getUniqueId()); - lastPrefixes.remove(player.getUniqueId()); - - if (registered.size() == 1 && registered.getFirst() == true) { - HandlerList.unregisterAll(this); - registered.clear(); - } - } - - @EventHandler(ignoreCancelled = true) - public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { - String prefix = prefixSuppliers.get(event.getPlayer().getUniqueId()).get(); - if (prefix == null) return; - - event.setFormat(prefix + "%2$s"); - } -} + private static final Map> prefixSuppliers = new HashMap<>(); + private static final Map lastPrefixes = new HashMap<>(); + private static final List registered = new ArrayList<>(); + + /** + * {@code true} when Paper's new {@code AsyncChatEvent} is on the classpath. + */ + private static final boolean USE_PAPER_CHAT_EVENT = detectPaperChatEvent(); + + private Chat(@NonNull Player player) { + super(player); + } + + private static boolean detectPaperChatEvent() { + try { + Class.forName("io.papermc.paper.event.player.AsyncChatEvent"); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } + + /** + * Applies a one-time prefix supplier. + */ + public void send(@NonNull Supplier prefix) { + if (registered.isEmpty()) { + Bukkit.getPluginManager().registerEvents(this, plugin); + registered.add(true); + } + + prefixSuppliers.put(player.getUniqueId(), prefix); + + updateRunnable = () -> { + String lastPrefix = lastPrefixes.get(player.getUniqueId()); + String newPrefix = prefixSuppliers.get(player.getUniqueId()).get(); + if (lastPrefix == null || !newPrefix.equals(lastPrefix)) { + lastPrefixes.put(player.getUniqueId(), newPrefix); + } + }; + update(); + } + + /** + * Applies a prefix supplier that refreshes at the given interval (ms). + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier prefix) { + super.sendUpdating(intervalTicks, () -> send(prefix)); + } + + @Override + public void remove() { + super.remove(); + prefixSuppliers.remove(player.getUniqueId()); + lastPrefixes.remove(player.getUniqueId()); + + if (!registered.isEmpty()) { + HandlerList.unregisterAll(this); + registered.clear(); + } + } + + /** + * Legacy handler — active on Spigot / Paper ≤ 25.x. + *

+ * On Paper 26.x this event is deprecated but still fires, so the handler + * remains as a fallback; the Paper-native handler below takes precedence + * when {@link #USE_PAPER_CHAT_EVENT} is {@code true}. + */ + @EventHandler(ignoreCancelled = true) + public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { + if (USE_PAPER_CHAT_EVENT) return; // let the Paper handler deal with it + + applyPrefix(event.getPlayer(), prefix -> event.setFormat(prefix + "%2$s")); + } + + /** + * Paper 26.x handler — registered reflectively at runtime so the class + * compiles against plain Spigot without the Paper dependency. + *

+ * The method is package-private to allow reflective invocation from the + * {@link PaperChatEventBridge} registered below. + */ + void onPaperAsyncChat(Player player, AsyncChatEvent event) { + applyPrefix(player, prefix -> + event.renderer((source, displayName, message, viewer) -> + Component.text(prefix) + .append(message) + ) + ); + } + + private void applyPrefix(@NonNull @NotNull Player player, @NonNull Consumer apply) { + Supplier supplier = prefixSuppliers.get(player.getUniqueId()); + if (supplier == null) return; + apply.accept(supplier.get()); + } + + /** + * Separate listener class registered only when Paper's {@code AsyncChatEvent} + * is present. Keeping it in a nested class avoids a {@link NoClassDefFoundError} + * on plain Spigot where the Paper event class does not exist. + */ + public static class PaperChatEventBridge implements Listener { + + private final Chat chat; + + public PaperChatEventBridge(@NonNull Chat chat) { + this.chat = chat; + } + + @EventHandler(ignoreCancelled = true) + public void onAsyncChat(AsyncChatEvent event) { + chat.onPaperAsyncChat(event.getPlayer(), event); + } + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Nametag.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Nametag.java index 5787a100..93c3dd3a 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Nametag.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Nametag.java @@ -1,54 +1,52 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import java.util.function.Supplier; - -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; - import lombok.NonNull; +import org.bukkit.entity.Player; + +import java.util.function.Supplier; public class Nametag extends PlayerElement { - - private Supplier prefixSupplier; - private Supplier suffixSupplier; - - private Nametag(@NonNull Player player) { - super(player); - } - - /** - * Sets a one-time prefix and suffix. - */ - public void send(@NonNull Supplier prefix, @NonNull Supplier suffix) { - prefixSupplier = prefix; - suffixSupplier = suffix; - - updateRunnable = () -> { - String newPrefix = prefixSupplier.get(); - String newSuffix = suffixSupplier.get(); - - PlayerUtils.sendNametag(player, newPrefix, newSuffix); - }; - update(); - } - - /** - * Updates prefix and suffiy periodically. - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier prefix, @NonNull Supplier suffix) { - super.sendUpdating(intervalTicks, () -> - send( - prefix, - suffix - ) - ); - } - - public void remove() { - super.remove(); - - PlayerUtils.removeNametag(player); - } + + private Supplier prefixSupplier; + private Supplier suffixSupplier; + + private Nametag(@NonNull Player player) { + super(player); + } + + /** + * Sets a one-time prefix and suffix. + */ + public void send(@NonNull Supplier prefix, @NonNull Supplier suffix) { + prefixSupplier = prefix; + suffixSupplier = suffix; + + updateRunnable = () -> { + String newPrefix = prefixSupplier.get(); + String newSuffix = suffixSupplier.get(); + + PlayerUtils.sendNametag(player, newPrefix, newSuffix); + }; + update(); + } + + /** + * Updates prefix and suffiy periodically. + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier prefix, @NonNull Supplier suffix) { + super.sendUpdating(intervalTicks, () -> + send( + prefix, + suffix + ) + ); + } + + public void remove() { + super.remove(); + + PlayerUtils.removeNametag(player); + } } \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Scoreboard.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Scoreboard.java index bd5da84e..cc34a81d 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Scoreboard.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Scoreboard.java @@ -1,8 +1,8 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import java.util.List; -import java.util.function.Supplier; - +import com.falchus.lib.FalchusLib; +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; +import lombok.NonNull; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -10,159 +10,156 @@ import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Team; -import com.falchus.lib.FalchusLib; -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; - -import lombok.NonNull; +import java.util.List; +import java.util.function.Supplier; public class Scoreboard extends PlayerElement { - private Supplier> linesSupplier; - private List lastLines; - - public final org.bukkit.scoreboard.Scoreboard scoreboard; - private final Objective objective; + public final org.bukkit.scoreboard.Scoreboard scoreboard; + private final Objective objective; + private Supplier> linesSupplier; + private List lastLines; private int frame = 0; - - private Scoreboard(@NonNull Player player) { - super(player); - org.bukkit.scoreboard.Scoreboard scoreboard = player.getScoreboard(); - if (scoreboard == null || scoreboard == Bukkit.getScoreboardManager().getMainScoreboard()) { - scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); - } - + + private Scoreboard(@NonNull Player player) { + super(player); + org.bukkit.scoreboard.Scoreboard scoreboard = player.getScoreboard(); + if (scoreboard == null || scoreboard == Bukkit.getScoreboardManager().getMainScoreboard()) { + scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); + } + Objective objective = scoreboard.getObjective(FalchusLib.nameFull); if (objective == null) { - objective = scoreboard.registerNewObjective(FalchusLib.nameFull, "dummy"); + objective = scoreboard.registerNewObjective(FalchusLib.nameFull, "dummy"); } objective.setDisplaySlot(DisplaySlot.SIDEBAR); - + player.setScoreboard(scoreboard); - - this.scoreboard = scoreboard; + + this.scoreboard = scoreboard; this.objective = objective; - } - - /** - * Updates the scoreboard immediately. - */ - public void send(@NonNull Supplier> lines) { - linesSupplier = lines; - - updateRunnable = () -> { - List newLines = linesSupplier.get(); - - if (lastLines == null || lastLines.size() != newLines.size()) { - for (Team team : scoreboard.getTeams()) { - team.unregister(); - } - for (String entry : scoreboard.getEntries()) { - scoreboard.resetScores(entry); - } - } - lastLines = newLines; - - int score = newLines.size(); - for (String line : newLines) { - if (line.isEmpty()) { - line = "§r"; - } else if (line.length() > 32) { - line = line.substring(0, 32); - } - - String teamName = getClass().getSimpleName() + "_" + score; - Team team = scoreboard.getTeam(teamName); - if (team == null) { - team = scoreboard.registerNewTeam(teamName); - } - - String entry = "§" + Integer.toHexString(score); - if (!team.hasEntry(entry)) { - team.addEntry(entry); - } - - int maxLength = 16; - String prefix = line; - String suffix = ""; - if (prefix.length() > 16) { - int index = line.charAt(maxLength - 1) == ChatColor.COLOR_CHAR - ? (maxLength - 1) : maxLength; - prefix = line.substring(0, index); - String suffixTmp = line.substring(index); - ChatColor chatColor = null; - - if (suffixTmp.length() >= 2 && suffixTmp.charAt(0) == ChatColor.COLOR_CHAR) { - chatColor = ChatColor.getByChar(suffixTmp.charAt(1)); - } - - String color = ChatColor.getLastColors(prefix); - boolean addColor = chatColor == null || chatColor.isFormat(); - suffix = (addColor ? (color.isEmpty() ? ChatColor.RESET.toString() : color) : "") + suffixTmp; - } - team.setPrefix(prefix); - team.setSuffix(suffix); - - objective.getScore(entry).setScore(score); - score--; - } - }; - update(); - } - - /** - * Updates the scoreboard periodically with dynamic content. - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier title, @NonNull Supplier titleColor, Supplier titleSecondColor, @NonNull Supplier> lines) { - super.sendUpdating(intervalTicks, () -> - send( - lines - ) - ); - } - - public void remove() { - super.remove(); - - player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()); - } - - /** - * Sets the title of the Scoreboard. - */ - public void setTitle(@NonNull String title, @NonNull String titleColor, String titleSecondColor) { - objective.setDisplayName(getTitle(title, titleColor, titleSecondColor)); - } - + } + + /** + * Updates the scoreboard immediately. + */ + public void send(@NonNull Supplier> lines) { + linesSupplier = lines; + + updateRunnable = () -> { + List newLines = linesSupplier.get(); + + if (lastLines == null || lastLines.size() != newLines.size()) { + for (Team team : scoreboard.getTeams()) { + team.unregister(); + } + for (String entry : scoreboard.getEntries()) { + scoreboard.resetScores(entry); + } + } + lastLines = newLines; + + int score = newLines.size(); + for (String line : newLines) { + if (line.isEmpty()) { + line = "§r"; + } else if (line.length() > 32) { + line = line.substring(0, 32); + } + + String teamName = getClass().getSimpleName() + "_" + score; + Team team = scoreboard.getTeam(teamName); + if (team == null) { + team = scoreboard.registerNewTeam(teamName); + } + + String entry = "§" + Integer.toHexString(score); + if (!team.hasEntry(entry)) { + team.addEntry(entry); + } + + int maxLength = 16; + String prefix = line; + String suffix = ""; + if (prefix.length() > 16) { + int index = line.charAt(maxLength - 1) == ChatColor.COLOR_CHAR + ? (maxLength - 1) : maxLength; + prefix = line.substring(0, index); + String suffixTmp = line.substring(index); + ChatColor chatColor = null; + + if (suffixTmp.length() >= 2 && suffixTmp.charAt(0) == ChatColor.COLOR_CHAR) { + chatColor = ChatColor.getByChar(suffixTmp.charAt(1)); + } + + String color = ChatColor.getLastColors(prefix); + boolean addColor = chatColor == null || chatColor.isFormat(); + suffix = (addColor ? (color.isEmpty() ? ChatColor.RESET.toString() : color) : "") + suffixTmp; + } + team.setPrefix(prefix); + team.setSuffix(suffix); + + objective.getScore(entry).setScore(score); + score--; + } + }; + update(); + } + + /** + * Updates the scoreboard periodically with dynamic content. + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier title, @NonNull Supplier titleColor, Supplier titleSecondColor, @NonNull Supplier> lines) { + super.sendUpdating(intervalTicks, () -> + send( + lines + ) + ); + } + + public void remove() { + super.remove(); + + player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()); + } + + /** + * Sets the title of the Scoreboard. + */ + public void setTitle(@NonNull String title, @NonNull String titleColor, String titleSecondColor) { + objective.setDisplayName(getTitle(title, titleColor, titleSecondColor)); + } + private String getTitle(@NonNull String title, @NonNull String titleColor, String titleSecondColor) { - title = ChatColor.stripColor(title); - if (title.isEmpty()) return ""; - + title = ChatColor.stripColor(title); + if (title.isEmpty()) return ""; + if (titleSecondColor == null) return titleColor + title; int length = title.length(); int cycleLength = length * 2; int pos = frame % length; - + StringBuilder sb = new StringBuilder(); if (frame < length) { sb.append(titleSecondColor) - .append(title.substring(0, pos + 1)) - .append(titleColor) - .append(title.substring(pos + 1)); + .append(title.substring(0, pos + 1)) + .append(titleColor) + .append(title.substring(pos + 1)); } else { sb.append(titleColor) - .append(title.substring(0, pos + 1)) - .append(titleSecondColor) - .append(title.substring(pos + 1)); + .append(title.substring(0, pos + 1)) + .append(titleSecondColor) + .append(title.substring(pos + 1)); } frame = (frame + 1) % cycleLength; title = sb.toString(); - if (title.length() > 32) { - title = title.substring(0, 32); - } + if (title.length() > 32) { + title = title.substring(0, 32); + } return title; } } diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Tablist.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Tablist.java index 0b974530..4ec57e68 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Tablist.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Tablist.java @@ -1,59 +1,57 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; +import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; +import lombok.NonNull; +import org.bukkit.entity.Player; + import java.util.List; import java.util.function.Supplier; -import org.bukkit.entity.Player; +public class Tablist extends PlayerElement { -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; -import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; + private Supplier> headerSupplier; + private Supplier> footerSupplier; + private Supplier nameSupplier; -import lombok.NonNull; + private Tablist(@NonNull Player player) { + super(player); + } -public class Tablist extends PlayerElement { - - private Supplier> headerSupplier; - private Supplier> footerSupplier; - private Supplier nameSupplier; - - private Tablist(@NonNull Player player) { - super(player); - } - - /** - * Sends a custom header and footer. - */ - public void send(Supplier> header, Supplier> footer, Supplier name) { - headerSupplier = header; - footerSupplier = footer; - nameSupplier = name; - - updateRunnable = () -> { - List newHeader = headerSupplier != null ? headerSupplier.get() : null; - List newFooter = footerSupplier != null ? footerSupplier.get() : null; - String newName = nameSupplier != null ? nameSupplier.get() : null; - - PlayerUtils.sendTablist(player, newHeader, newFooter, newName); - }; - update(); - } - - /** - * Updates the tablist periodically with dynamic content. - */ - public void sendUpdating(long intervalTicks, Supplier> header, Supplier> footer, Supplier name) { - super.sendUpdating(intervalTicks, () -> - send( - header, - footer, - name - ) - ); - } - - public void remove() { - super.remove(); - - send(null, null, null); - } + /** + * Sends a custom header and footer. + */ + public void send(Supplier> header, Supplier> footer, Supplier name) { + headerSupplier = header; + footerSupplier = footer; + nameSupplier = name; + + updateRunnable = () -> { + List newHeader = headerSupplier != null ? headerSupplier.get() : null; + List newFooter = footerSupplier != null ? footerSupplier.get() : null; + String newName = nameSupplier != null ? nameSupplier.get() : null; + + PlayerUtils.sendTablist(player, newHeader, newFooter, newName); + }; + update(); + } + + /** + * Updates the tablist periodically with dynamic content. + */ + public void sendUpdating(long intervalTicks, Supplier> header, Supplier> footer, Supplier name) { + super.sendUpdating(intervalTicks, () -> + send( + header, + footer, + name + ) + ); + } + + public void remove() { + super.remove(); + + send(null, null, null); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/EntityUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/EntityUtils.java index a66f3948..aefe660c 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/EntityUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/EntityUtils.java @@ -1,26 +1,24 @@ package com.falchus.lib.minecraft.spigot.utils; -import org.bukkit.entity.Entity; - import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; - import lombok.NonNull; import lombok.experimental.UtilityClass; +import org.bukkit.entity.Entity; @UtilityClass public class EntityUtils { - /** - * @return {@link Entity} - */ - public static Entity getBukkitEntity(@NonNull Object entity) { - return VersionProvider.get().getBukkitEntity(entity); - } - - /** - * Sets yaw and pitch. - */ - public static void setYawPitch(@NonNull Object entity, float yaw, float pitch) { - VersionProvider.get().setYawPitch(entity, yaw, pitch); - } + /** + * @return {@link Entity} + */ + public static Entity getBukkitEntity(@NonNull Object entity) { + return VersionProvider.get().getBukkitEntity(entity); + } + + /** + * Sets yaw and pitch. + */ + public static void setYawPitch(@NonNull Object entity, float yaw, float pitch) { + VersionProvider.get().setYawPitch(entity, yaw, pitch); + } } \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/ItemUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/ItemUtils.java index 7e55464e..7c2db13c 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/ItemUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/ItemUtils.java @@ -1,10 +1,9 @@ package com.falchus.lib.minecraft.spigot.utils; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.util.*; -import java.util.function.Consumer; - +import com.falchus.lib.interfaces.consumer.TriConsumer; +import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; +import lombok.NonNull; +import lombok.experimental.UtilityClass; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -14,16 +13,17 @@ import org.bukkit.util.io.BukkitObjectOutputStream; import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; -import com.falchus.lib.interfaces.consumer.TriConsumer; -import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; - -import lombok.NonNull; -import lombok.experimental.UtilityClass; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.function.Consumer; @UtilityClass public class ItemUtils { - - public static final Map> itemActions = new HashMap<>(); + + public static final Map> itemActions = new HashMap<>(); public static final Map> itemActionsInventory = new HashMap<>(); public static final Map> inventoryCallbacks = new HashMap<>(); @@ -33,60 +33,60 @@ public class ItemUtils { /** * Sets a UUID on the given item via NBT. */ - public static ItemStack setUUID(@NonNull ItemStack item, UUID uuid) { - return VersionProvider.get().setUUID(item, uuid); + public static ItemStack setUUID(@NonNull ItemStack item, UUID uuid) { + return VersionProvider.get().setUUID(item, uuid); } /** * Retrieves the UUID stores on the given item. */ public static UUID getUUID(@NonNull ItemStack item) { - return VersionProvider.get().getUUID(item); + return VersionProvider.get().getUUID(item); } - + /** * Removes all NBT tags from the item. */ public static ItemStack clearNBT(@NonNull ItemStack item) { - return VersionProvider.get().clearNBT(item); + return VersionProvider.get().clearNBT(item); } - + /** * Gets an array of ItemStacks from a Base64 String. */ public static ItemStack[] itemStackArrayFromBase64(String base64) { - try { - ByteArrayInputStream stream = new ByteArrayInputStream(Base64Coder.decodeLines(base64)); - BukkitObjectInputStream input = new BukkitObjectInputStream(stream); - - ItemStack[] items = new ItemStack[input.readInt()]; - for (int i = 0; i < items.length; i++) { - items[i] = (ItemStack) input.readObject(); - } - return items; - } catch (Exception e) { - e.printStackTrace(); - } - return new ItemStack[0]; + try { + ByteArrayInputStream stream = new ByteArrayInputStream(Base64Coder.decodeLines(base64)); + BukkitObjectInputStream input = new BukkitObjectInputStream(stream); + + ItemStack[] items = new ItemStack[input.readInt()]; + for (int i = 0; i < items.length; i++) { + items[i] = (ItemStack) input.readObject(); + } + return items; + } catch (Exception e) { + e.printStackTrace(); + } + return new ItemStack[0]; } - + /** * Converts an array of ItemStacks to a Base64 String. */ public static String itemStackArrayToBase64(ItemStack[] items) { - try { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - BukkitObjectOutputStream output = new BukkitObjectOutputStream(stream); - - output.writeInt(items.length); - for (ItemStack item : items) { - output.writeObject(item); + try { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + BukkitObjectOutputStream output = new BukkitObjectOutputStream(stream); + + output.writeInt(items.length); + for (ItemStack item : items) { + output.writeObject(item); } - return Base64Coder.encodeLines(stream.toByteArray()); - } catch (Exception e) { - e.printStackTrace(); - } - return null; + return Base64Coder.encodeLines(stream.toByteArray()); + } catch (Exception e) { + e.printStackTrace(); + } + return null; } /** diff --git a/src/com/falchus/lib/minecraft/spigot/utils/Metrics.java b/src/com/falchus/lib/minecraft/spigot/utils/Metrics.java index 9b84fe86..d1010696 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/Metrics.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/Metrics.java @@ -14,22 +14,17 @@ */ package com.falchus.lib.minecraft.spigot.utils; -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import javax.net.ssl.HttpsURLConnection; +import java.io.*; import java.lang.reflect.Method; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.concurrent.Callable; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -40,866 +35,867 @@ import java.util.logging.Level; import java.util.stream.Collectors; import java.util.zip.GZIPOutputStream; -import javax.net.ssl.HttpsURLConnection; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; public class Metrics { - private final Plugin plugin; - - private final MetricsBase metricsBase; - - /** - * Creates a new Metrics instance. - * - * @param plugin Your plugin instance. - * @param serviceId The id of the service. It can be found at What is my plugin id? - */ - public Metrics(Plugin plugin, int serviceId) { - this.plugin = plugin; - // Get the config file - File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats"); - File configFile = new File(bStatsFolder, "config.yml"); - YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); - if (!config.isSet("serverUuid")) { - config.addDefault("enabled", true); - config.addDefault("serverUuid", UUID.randomUUID().toString()); - config.addDefault("logFailedRequests", false); - config.addDefault("logSentData", false); - config.addDefault("logResponseStatusText", false); - // Inform the server owners about bStats - config - .options() - .header( - "bStats (https://bStats.org) collects some basic information for plugin authors, like how\n" - + "many people use their plugin and their total player count. It's recommended to keep bStats\n" - + "enabled, but if you're not comfortable with this, you can turn this setting off. There is no\n" - + "performance penalty associated with having metrics enabled, and data sent to bStats is fully\n" - + "anonymous.") - .copyDefaults(true); - try { - config.save(configFile); - } catch (IOException ignored) { - } - } - // Load the data - boolean enabled = config.getBoolean("enabled", true); - String serverUUID = config.getString("serverUuid"); - boolean logErrors = config.getBoolean("logFailedRequests", false); - boolean logSentData = config.getBoolean("logSentData", false); - boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false); - boolean isFolia = false; - try { - isFolia = Class.forName("io.papermc.paper.threadedregions.RegionizedServer") != null; - } catch (Exception e) { - } - metricsBase = - new // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - MetricsBase( - "bukkit", - serverUUID, - serviceId, - enabled, - this::appendPlatformData, - this::appendServiceData, - isFolia - ? null - : submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask), - plugin::isEnabled, - (message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error), - (message) -> this.plugin.getLogger().log(Level.INFO, message), - logErrors, - logSentData, - logResponseStatusText, - false); - } - - /** Shuts down the underlying scheduler service. */ - public void shutdown() { - metricsBase.shutdown(); - } - - /** - * Adds a custom chart. - * - * @param chart The chart to add. - */ - public void addCustomChart(CustomChart chart) { - metricsBase.addCustomChart(chart); - } - - private void appendPlatformData(JsonObjectBuilder builder) { - builder.appendField("playerAmount", getPlayerAmount()); - builder.appendField("onlineMode", Bukkit.getOnlineMode() ? 1 : 0); - builder.appendField("bukkitVersion", Bukkit.getVersion()); - builder.appendField("bukkitName", Bukkit.getName()); - builder.appendField("javaVersion", System.getProperty("java.version")); - builder.appendField("osName", System.getProperty("os.name")); - builder.appendField("osArch", System.getProperty("os.arch")); - builder.appendField("osVersion", System.getProperty("os.version")); - builder.appendField("coreCount", Runtime.getRuntime().availableProcessors()); - } - - private void appendServiceData(JsonObjectBuilder builder) { - builder.appendField("pluginVersion", plugin.getDescription().getVersion()); - } - - private int getPlayerAmount() { - try { - // Around MC 1.8 the return type was changed from an array to a collection, - // This fixes java.lang.NoSuchMethodError: - // org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection; - Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers"); - return onlinePlayersMethod.getReturnType().equals(Collection.class) - ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() - : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; - } catch (Exception e) { - // Just use the new method if the reflection failed - return Bukkit.getOnlinePlayers().size(); - } - } - - public static class MetricsBase { - - /** The version of the Metrics class. */ - public static final String METRICS_VERSION = "3.1.0"; - - private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s"; - - private final ScheduledExecutorService scheduler; - - private final String platform; - - private final String serverUuid; - - private final int serviceId; - - private final Consumer appendPlatformDataConsumer; - - private final Consumer appendServiceDataConsumer; - - private final Consumer submitTaskConsumer; - - private final Supplier checkServiceEnabledSupplier; - - private final BiConsumer errorLogger; + private final Plugin plugin; - private final Consumer infoLogger; - - private final boolean logErrors; - - private final boolean logSentData; - - private final boolean logResponseStatusText; - - private final Set customCharts = new HashSet<>(); - - private final boolean enabled; + private final MetricsBase metricsBase; /** - * Creates a new MetricsBase class instance. + * Creates a new Metrics instance. * - * @param platform The platform of the service. - * @param serviceId The id of the service. - * @param serverUuid The server uuid. - * @param enabled Whether or not data sending is enabled. - * @param appendPlatformDataConsumer A consumer that receives a {@code JsonObjectBuilder} and - * appends all platform-specific data. - * @param appendServiceDataConsumer A consumer that receives a {@code JsonObjectBuilder} and - * appends all service-specific data. - * @param submitTaskConsumer A consumer that takes a runnable with the submit task. This can be - * used to delegate the data collection to a another thread to prevent errors caused by - * concurrency. Can be {@code null}. - * @param checkServiceEnabledSupplier A supplier to check if the service is still enabled. - * @param errorLogger A consumer that accepts log message and an error. - * @param infoLogger A consumer that accepts info log messages. - * @param logErrors Whether or not errors should be logged. - * @param logSentData Whether or not the sent data should be logged. - * @param logResponseStatusText Whether or not the response status text should be logged. - * @param skipRelocateCheck Whether or not the relocate check should be skipped. + * @param plugin Your plugin instance. + * @param serviceId The id of the service. It can be found at What is my plugin id? */ - public MetricsBase( - String platform, - String serverUuid, - int serviceId, - boolean enabled, - Consumer appendPlatformDataConsumer, - Consumer appendServiceDataConsumer, - Consumer submitTaskConsumer, - Supplier checkServiceEnabledSupplier, - BiConsumer errorLogger, - Consumer infoLogger, - boolean logErrors, - boolean logSentData, - boolean logResponseStatusText, - boolean skipRelocateCheck) { - ScheduledThreadPoolExecutor scheduler = - new ScheduledThreadPoolExecutor( - 1, - task -> { - Thread thread = new Thread(task, "bStats-Metrics"); - thread.setDaemon(true); - return thread; - }); - // We want delayed tasks (non-periodic) that will execute in the future to be - // cancelled when the scheduler is shutdown. - // Otherwise, we risk preventing the server from shutting down even when - // MetricsBase#shutdown() is called - scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); - this.scheduler = scheduler; - this.platform = platform; - this.serverUuid = serverUuid; - this.serviceId = serviceId; - this.enabled = enabled; - this.appendPlatformDataConsumer = appendPlatformDataConsumer; - this.appendServiceDataConsumer = appendServiceDataConsumer; - this.submitTaskConsumer = submitTaskConsumer; - this.checkServiceEnabledSupplier = checkServiceEnabledSupplier; - this.errorLogger = errorLogger; - this.infoLogger = infoLogger; - this.logErrors = logErrors; - this.logSentData = logSentData; - this.logResponseStatusText = logResponseStatusText; - if (!skipRelocateCheck) { - checkRelocation(); - } - if (enabled) { - // WARNING: Removing the option to opt-out will get your plugin banned from - // bStats - startSubmitting(); - } - } - - public void addCustomChart(CustomChart chart) { - this.customCharts.add(chart); + public Metrics(Plugin plugin, int serviceId) { + this.plugin = plugin; + // Get the config file + File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats"); + File configFile = new File(bStatsFolder, "config.yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); + if (!config.isSet("serverUuid")) { + config.addDefault("enabled", true); + config.addDefault("serverUuid", UUID.randomUUID().toString()); + config.addDefault("logFailedRequests", false); + config.addDefault("logSentData", false); + config.addDefault("logResponseStatusText", false); + // Inform the server owners about bStats + config + .options() + .header( + "bStats (https://bStats.org) collects some basic information for plugin authors, like how\n" + + "many people use their plugin and their total player count. It's recommended to keep bStats\n" + + "enabled, but if you're not comfortable with this, you can turn this setting off. There is no\n" + + "performance penalty associated with having metrics enabled, and data sent to bStats is fully\n" + + "anonymous.") + .copyDefaults(true); + try { + config.save(configFile); + } catch (IOException ignored) { + } + } + // Load the data + boolean enabled = config.getBoolean("enabled", true); + String serverUUID = config.getString("serverUuid"); + boolean logErrors = config.getBoolean("logFailedRequests", false); + boolean logSentData = config.getBoolean("logSentData", false); + boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false); + boolean isFolia = false; + try { + isFolia = Class.forName("io.papermc.paper.threadedregions.RegionizedServer") != null; + } catch (Exception e) { + } + metricsBase = + new // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + MetricsBase( + "bukkit", + serverUUID, + serviceId, + enabled, + this::appendPlatformData, + this::appendServiceData, + isFolia + ? null + : submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask), + plugin::isEnabled, + (message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error), + (message) -> this.plugin.getLogger().log(Level.INFO, message), + logErrors, + logSentData, + logResponseStatusText, + false); } + /** + * Shuts down the underlying scheduler service. + */ public void shutdown() { - scheduler.shutdown(); + metricsBase.shutdown(); } - private void startSubmitting() { - final Runnable submitTask = - () -> { - if (!enabled || !checkServiceEnabledSupplier.get()) { - // Submitting data or service is disabled - scheduler.shutdown(); - return; - } - if (submitTaskConsumer != null) { - submitTaskConsumer.accept(this::submitData); - } else { - this.submitData(); - } - }; - // Many servers tend to restart at a fixed time at xx:00 which causes an uneven - // distribution of requests on the - // bStats backend. To circumvent this problem, we introduce some randomness into - // the initial and second delay. - // WARNING: You must not modify and part of this Metrics class, including the - // submit delay or frequency! - // WARNING: Modifying this code will get your plugin banned on bStats. Just - // don't do it! - long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3)); - long secondDelay = (long) (1000 * 60 * (Math.random() * 30)); - scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS); - scheduler.scheduleAtFixedRate( - submitTask, initialDelay + secondDelay, 1000 * 60 * 30, TimeUnit.MILLISECONDS); + /** + * Adds a custom chart. + * + * @param chart The chart to add. + */ + public void addCustomChart(CustomChart chart) { + metricsBase.addCustomChart(chart); + } + + private void appendPlatformData(JsonObjectBuilder builder) { + builder.appendField("playerAmount", getPlayerAmount()); + builder.appendField("onlineMode", Bukkit.getOnlineMode() ? 1 : 0); + builder.appendField("bukkitVersion", Bukkit.getVersion()); + builder.appendField("bukkitName", Bukkit.getName()); + builder.appendField("javaVersion", System.getProperty("java.version")); + builder.appendField("osName", System.getProperty("os.name")); + builder.appendField("osArch", System.getProperty("os.arch")); + builder.appendField("osVersion", System.getProperty("os.version")); + builder.appendField("coreCount", Runtime.getRuntime().availableProcessors()); + } + + private void appendServiceData(JsonObjectBuilder builder) { + builder.appendField("pluginVersion", plugin.getDescription().getVersion()); + } + + private int getPlayerAmount() { + try { + // Around MC 1.8 the return type was changed from an array to a collection, + // This fixes java.lang.NoSuchMethodError: + // org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection; + Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers"); + return onlinePlayersMethod.getReturnType().equals(Collection.class) + ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() + : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; + } catch (Exception e) { + // Just use the new method if the reflection failed + return Bukkit.getOnlinePlayers().size(); + } } - private void submitData() { - final JsonObjectBuilder baseJsonBuilder = new JsonObjectBuilder(); - appendPlatformDataConsumer.accept(baseJsonBuilder); - final JsonObjectBuilder serviceJsonBuilder = new JsonObjectBuilder(); - appendServiceDataConsumer.accept(serviceJsonBuilder); - JsonObjectBuilder.JsonObject[] chartData = - customCharts.stream() - .map(customChart -> customChart.getRequestJsonObject(errorLogger, logErrors)) - .filter(Objects::nonNull) - .toArray(JsonObjectBuilder.JsonObject[]::new); - serviceJsonBuilder.appendField("id", serviceId); - serviceJsonBuilder.appendField("customCharts", chartData); - baseJsonBuilder.appendField("service", serviceJsonBuilder.build()); - baseJsonBuilder.appendField("serverUUID", serverUuid); - baseJsonBuilder.appendField("metricsVersion", METRICS_VERSION); - JsonObjectBuilder.JsonObject data = baseJsonBuilder.build(); - scheduler.execute( - () -> { - try { - // Send the data - sendData(data); - } catch (Exception e) { - // Something went wrong! :( - if (logErrors) { - errorLogger.accept("Could not submit bStats metrics data", e); - } - } - }); - } + public static class MetricsBase { + + /** + * The version of the Metrics class. + */ + public static final String METRICS_VERSION = "3.1.0"; + + private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s"; + + private final ScheduledExecutorService scheduler; + + private final String platform; + + private final String serverUuid; + + private final int serviceId; + + private final Consumer appendPlatformDataConsumer; + + private final Consumer appendServiceDataConsumer; + + private final Consumer submitTaskConsumer; + + private final Supplier checkServiceEnabledSupplier; + + private final BiConsumer errorLogger; + + private final Consumer infoLogger; + + private final boolean logErrors; + + private final boolean logSentData; + + private final boolean logResponseStatusText; + + private final Set customCharts = new HashSet<>(); + + private final boolean enabled; + + /** + * Creates a new MetricsBase class instance. + * + * @param platform The platform of the service. + * @param serviceId The id of the service. + * @param serverUuid The server uuid. + * @param enabled Whether or not data sending is enabled. + * @param appendPlatformDataConsumer A consumer that receives a {@code JsonObjectBuilder} and + * appends all platform-specific data. + * @param appendServiceDataConsumer A consumer that receives a {@code JsonObjectBuilder} and + * appends all service-specific data. + * @param submitTaskConsumer A consumer that takes a runnable with the submit task. This can be + * used to delegate the data collection to a another thread to prevent errors caused by + * concurrency. Can be {@code null}. + * @param checkServiceEnabledSupplier A supplier to check if the service is still enabled. + * @param errorLogger A consumer that accepts log message and an error. + * @param infoLogger A consumer that accepts info log messages. + * @param logErrors Whether or not errors should be logged. + * @param logSentData Whether or not the sent data should be logged. + * @param logResponseStatusText Whether or not the response status text should be logged. + * @param skipRelocateCheck Whether or not the relocate check should be skipped. + */ + public MetricsBase( + String platform, + String serverUuid, + int serviceId, + boolean enabled, + Consumer appendPlatformDataConsumer, + Consumer appendServiceDataConsumer, + Consumer submitTaskConsumer, + Supplier checkServiceEnabledSupplier, + BiConsumer errorLogger, + Consumer infoLogger, + boolean logErrors, + boolean logSentData, + boolean logResponseStatusText, + boolean skipRelocateCheck) { + ScheduledThreadPoolExecutor scheduler = + new ScheduledThreadPoolExecutor( + 1, + task -> { + Thread thread = new Thread(task, "bStats-Metrics"); + thread.setDaemon(true); + return thread; + }); + // We want delayed tasks (non-periodic) that will execute in the future to be + // cancelled when the scheduler is shutdown. + // Otherwise, we risk preventing the server from shutting down even when + // MetricsBase#shutdown() is called + scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); + this.scheduler = scheduler; + this.platform = platform; + this.serverUuid = serverUuid; + this.serviceId = serviceId; + this.enabled = enabled; + this.appendPlatformDataConsumer = appendPlatformDataConsumer; + this.appendServiceDataConsumer = appendServiceDataConsumer; + this.submitTaskConsumer = submitTaskConsumer; + this.checkServiceEnabledSupplier = checkServiceEnabledSupplier; + this.errorLogger = errorLogger; + this.infoLogger = infoLogger; + this.logErrors = logErrors; + this.logSentData = logSentData; + this.logResponseStatusText = logResponseStatusText; + if (!skipRelocateCheck) { + checkRelocation(); + } + if (enabled) { + // WARNING: Removing the option to opt-out will get your plugin banned from + // bStats + startSubmitting(); + } + } - private void sendData(JsonObjectBuilder.JsonObject data) throws Exception { - if (logSentData) { - infoLogger.accept("Sent bStats metrics data: " + data.toString()); - } - String url = String.format(REPORT_URL, platform); - HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection(); - // Compress the data to save bandwidth - byte[] compressedData = compress(data.toString()); - connection.setRequestMethod("POST"); - connection.addRequestProperty("Accept", "application/json"); - connection.addRequestProperty("Connection", "close"); - connection.addRequestProperty("Content-Encoding", "gzip"); - connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length)); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestProperty("User-Agent", "Metrics-Service/1"); - connection.setDoOutput(true); - try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { - outputStream.write(compressedData); - } - StringBuilder builder = new StringBuilder(); - try (BufferedReader bufferedReader = - new BufferedReader(new InputStreamReader(connection.getInputStream()))) { - String line; - while ((line = bufferedReader.readLine()) != null) { - builder.append(line); - } - } - if (logResponseStatusText) { - infoLogger.accept("Sent data to bStats and received response: " + builder); - } - } + /** + * Gzips the given string. + * + * @param str The string to gzip. + * @return The gzipped string. + */ + private static byte[] compress(final String str) throws IOException { + if (str == null) { + return null; + } + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) { + gzip.write(str.getBytes(StandardCharsets.UTF_8)); + } + return outputStream.toByteArray(); + } - /** Checks that the class was properly relocated. */ - private void checkRelocation() { - // You can use the property to disable the check in your test environment - if (System.getProperty("bstats.relocatecheck") == null - || !System.getProperty("bstats.relocatecheck").equals("false")) { - // Maven's Relocate is clever and changes strings, too. So we have to use this - // little "trick" ... :D - final String defaultPackage = - new String(new byte[] {'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'}); - final String examplePackage = - new String(new byte[] {'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); - // We want to make sure no one just copy & pastes the example and uses the wrong - // package names - if (MetricsBase.class.getPackage().getName().startsWith(defaultPackage) - || MetricsBase.class.getPackage().getName().startsWith(examplePackage)) { - throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); - } - } - } + public void addCustomChart(CustomChart chart) { + this.customCharts.add(chart); + } - /** - * Gzips the given string. - * - * @param str The string to gzip. - * @return The gzipped string. - */ - private static byte[] compress(final String str) throws IOException { - if (str == null) { - return null; - } - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) { - gzip.write(str.getBytes(StandardCharsets.UTF_8)); - } - return outputStream.toByteArray(); - } - } + public void shutdown() { + scheduler.shutdown(); + } - public static class AdvancedBarChart extends CustomChart { + private void startSubmitting() { + final Runnable submitTask = + () -> { + if (!enabled || !checkServiceEnabledSupplier.get()) { + // Submitting data or service is disabled + scheduler.shutdown(); + return; + } + if (submitTaskConsumer != null) { + submitTaskConsumer.accept(this::submitData); + } else { + this.submitData(); + } + }; + // Many servers tend to restart at a fixed time at xx:00 which causes an uneven + // distribution of requests on the + // bStats backend. To circumvent this problem, we introduce some randomness into + // the initial and second delay. + // WARNING: You must not modify and part of this Metrics class, including the + // submit delay or frequency! + // WARNING: Modifying this code will get your plugin banned on bStats. Just + // don't do it! + long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3)); + long secondDelay = (long) (1000 * 60 * (Math.random() * 30)); + scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS); + scheduler.scheduleAtFixedRate( + submitTask, initialDelay + secondDelay, 1000 * 60 * 30, TimeUnit.MILLISECONDS); + } - private final Callable> callable; + private void submitData() { + final JsonObjectBuilder baseJsonBuilder = new JsonObjectBuilder(); + appendPlatformDataConsumer.accept(baseJsonBuilder); + final JsonObjectBuilder serviceJsonBuilder = new JsonObjectBuilder(); + appendServiceDataConsumer.accept(serviceJsonBuilder); + JsonObjectBuilder.JsonObject[] chartData = + customCharts.stream() + .map(customChart -> customChart.getRequestJsonObject(errorLogger, logErrors)) + .filter(Objects::nonNull) + .toArray(JsonObjectBuilder.JsonObject[]::new); + serviceJsonBuilder.appendField("id", serviceId); + serviceJsonBuilder.appendField("customCharts", chartData); + baseJsonBuilder.appendField("service", serviceJsonBuilder.build()); + baseJsonBuilder.appendField("serverUUID", serverUuid); + baseJsonBuilder.appendField("metricsVersion", METRICS_VERSION); + JsonObjectBuilder.JsonObject data = baseJsonBuilder.build(); + scheduler.execute( + () -> { + try { + // Send the data + sendData(data); + } catch (Exception e) { + // Something went wrong! :( + if (logErrors) { + errorLogger.accept("Could not submit bStats metrics data", e); + } + } + }); + } - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public AdvancedBarChart(String chartId, Callable> callable) { - super(chartId); - this.callable = callable; - } + private void sendData(JsonObjectBuilder.JsonObject data) throws Exception { + if (logSentData) { + infoLogger.accept("Sent bStats metrics data: " + data.toString()); + } + String url = String.format(REPORT_URL, platform); + HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection(); + // Compress the data to save bandwidth + byte[] compressedData = compress(data.toString()); + connection.setRequestMethod("POST"); + connection.addRequestProperty("Accept", "application/json"); + connection.addRequestProperty("Connection", "close"); + connection.addRequestProperty("Content-Encoding", "gzip"); + connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length)); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setRequestProperty("User-Agent", "Metrics-Service/1"); + connection.setDoOutput(true); + try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { + outputStream.write(compressedData); + } + StringBuilder builder = new StringBuilder(); + try (BufferedReader bufferedReader = + new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + String line; + while ((line = bufferedReader.readLine()) != null) { + builder.append(line); + } + } + if (logResponseStatusText) { + infoLogger.accept("Sent data to bStats and received response: " + builder); + } + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - boolean allSkipped = true; - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue().length == 0) { - // Skip this invalid - continue; - } - allSkipped = false; - valuesBuilder.appendField(entry.getKey(), entry.getValue()); - } - if (allSkipped) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + /** + * Checks that the class was properly relocated. + */ + private void checkRelocation() { + // You can use the property to disable the check in your test environment + if (System.getProperty("bstats.relocatecheck") == null + || !System.getProperty("bstats.relocatecheck").equals("false")) { + // Maven's Relocate is clever and changes strings, too. So we have to use this + // little "trick" ... :D + final String defaultPackage = + new String(new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'}); + final String examplePackage = + new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); + // We want to make sure no one just copy & pastes the example and uses the wrong + // package names + if (MetricsBase.class.getPackage().getName().startsWith(defaultPackage) + || MetricsBase.class.getPackage().getName().startsWith(examplePackage)) { + throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); + } + } + } } - } - public static class SimplePie extends CustomChart { + public static class AdvancedBarChart extends CustomChart { - private final Callable callable; + private final Callable> callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public SimplePie(String chartId, Callable callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public AdvancedBarChart(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - String value = callable.call(); - if (value == null || value.isEmpty()) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("value", value).build(); + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean allSkipped = true; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue().length == 0) { + // Skip this invalid + continue; + } + allSkipped = false; + valuesBuilder.appendField(entry.getKey(), entry.getValue()); + } + if (allSkipped) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + } } - } - public static class DrilldownPie extends CustomChart { + public static class SimplePie extends CustomChart { - private final Callable>> callable; + private final Callable callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public DrilldownPie(String chartId, Callable>> callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public SimplePie(String chartId, Callable callable) { + super(chartId); + this.callable = callable; + } - @Override - public JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map> map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - boolean reallyAllSkipped = true; - for (Map.Entry> entryValues : map.entrySet()) { - JsonObjectBuilder valueBuilder = new JsonObjectBuilder(); - boolean allSkipped = true; - for (Map.Entry valueEntry : map.get(entryValues.getKey()).entrySet()) { - valueBuilder.appendField(valueEntry.getKey(), valueEntry.getValue()); - allSkipped = false; - } - if (!allSkipped) { - reallyAllSkipped = false; - valuesBuilder.appendField(entryValues.getKey(), valueBuilder.build()); - } - } - if (reallyAllSkipped) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + String value = callable.call(); + if (value == null || value.isEmpty()) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("value", value).build(); + } } - } - public static class SingleLineChart extends CustomChart { + public static class DrilldownPie extends CustomChart { - private final Callable callable; + private final Callable>> callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public SingleLineChart(String chartId, Callable callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public DrilldownPie(String chartId, Callable>> callable) { + super(chartId); + this.callable = callable; + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - int value = callable.call(); - if (value == 0) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("value", value).build(); + @Override + public JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map> map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean reallyAllSkipped = true; + for (Map.Entry> entryValues : map.entrySet()) { + JsonObjectBuilder valueBuilder = new JsonObjectBuilder(); + boolean allSkipped = true; + for (Map.Entry valueEntry : map.get(entryValues.getKey()).entrySet()) { + valueBuilder.appendField(valueEntry.getKey(), valueEntry.getValue()); + allSkipped = false; + } + if (!allSkipped) { + reallyAllSkipped = false; + valuesBuilder.appendField(entryValues.getKey(), valueBuilder.build()); + } + } + if (reallyAllSkipped) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + } } - } - public static class MultiLineChart extends CustomChart { + public static class SingleLineChart extends CustomChart { - private final Callable> callable; + private final Callable callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public MultiLineChart(String chartId, Callable> callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public SingleLineChart(String chartId, Callable callable) { + super(chartId); + this.callable = callable; + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - boolean allSkipped = true; - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() == 0) { - // Skip this invalid - continue; - } - allSkipped = false; - valuesBuilder.appendField(entry.getKey(), entry.getValue()); - } - if (allSkipped) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + int value = callable.call(); + if (value == 0) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("value", value).build(); + } } - } - public static class AdvancedPie extends CustomChart { + public static class MultiLineChart extends CustomChart { - private final Callable> callable; + private final Callable> callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public AdvancedPie(String chartId, Callable> callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public MultiLineChart(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - boolean allSkipped = true; - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() == 0) { - // Skip this invalid - continue; - } - allSkipped = false; - valuesBuilder.appendField(entry.getKey(), entry.getValue()); - } - if (allSkipped) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean allSkipped = true; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue() == 0) { + // Skip this invalid + continue; + } + allSkipped = false; + valuesBuilder.appendField(entry.getKey(), entry.getValue()); + } + if (allSkipped) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + } } - } - public abstract static class CustomChart { + public static class AdvancedPie extends CustomChart { - private final String chartId; + private final Callable> callable; - protected CustomChart(String chartId) { - if (chartId == null) { - throw new IllegalArgumentException("chartId must not be null"); - } - this.chartId = chartId; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public AdvancedPie(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } - public JsonObjectBuilder.JsonObject getRequestJsonObject( - BiConsumer errorLogger, boolean logErrors) { - JsonObjectBuilder builder = new JsonObjectBuilder(); - builder.appendField("chartId", chartId); - try { - JsonObjectBuilder.JsonObject data = getChartData(); - if (data == null) { - // If the data is null we don't send the chart. - return null; - } - builder.appendField("data", data); - } catch (Throwable t) { - if (logErrors) { - errorLogger.accept("Failed to get data for custom chart with id " + chartId, t); - } - return null; - } - return builder.build(); + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean allSkipped = true; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue() == 0) { + // Skip this invalid + continue; + } + allSkipped = false; + valuesBuilder.appendField(entry.getKey(), entry.getValue()); + } + if (allSkipped) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + } } - protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception; - } + public abstract static class CustomChart { - public static class SimpleBarChart extends CustomChart { + private final String chartId; - private final Callable> callable; + protected CustomChart(String chartId) { + if (chartId == null) { + throw new IllegalArgumentException("chartId must not be null"); + } + this.chartId = chartId; + } - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public SimpleBarChart(String chartId, Callable> callable) { - super(chartId); - this.callable = callable; - } + public JsonObjectBuilder.JsonObject getRequestJsonObject( + BiConsumer errorLogger, boolean logErrors) { + JsonObjectBuilder builder = new JsonObjectBuilder(); + builder.appendField("chartId", chartId); + try { + JsonObjectBuilder.JsonObject data = getChartData(); + if (data == null) { + // If the data is null we don't send the chart. + return null; + } + builder.appendField("data", data); + } catch (Throwable t) { + if (logErrors) { + errorLogger.accept("Failed to get data for custom chart with id " + chartId, t); + } + return null; + } + return builder.build(); + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - for (Map.Entry entry : map.entrySet()) { - valuesBuilder.appendField(entry.getKey(), new int[] {entry.getValue()}); - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception; } - } - /** - * An extremely simple JSON builder. - * - *

While this class is neither feature-rich nor the most performant one, it's sufficient enough - * for its use-case. - */ - public static class JsonObjectBuilder { + public static class SimpleBarChart extends CustomChart { - private StringBuilder builder = new StringBuilder(); + private final Callable> callable; - private boolean hasAtLeastOneField = false; + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public SimpleBarChart(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } - public JsonObjectBuilder() { - builder.append("{"); + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + for (Map.Entry entry : map.entrySet()) { + valuesBuilder.appendField(entry.getKey(), new int[]{entry.getValue()}); + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); + } } /** - * Appends a null field to the JSON. + * An extremely simple JSON builder. * - * @param key The key of the field. - * @return A reference to this object. + *

While this class is neither feature-rich nor the most performant one, it's sufficient enough + * for its use-case. */ - public JsonObjectBuilder appendNull(String key) { - appendFieldUnescaped(key, "null"); - return this; - } + public static class JsonObjectBuilder { - /** - * Appends a string field to the JSON. - * - * @param key The key of the field. - * @param value The value of the field. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, String value) { - if (value == null) { - throw new IllegalArgumentException("JSON value must not be null"); - } - appendFieldUnescaped(key, "\"" + escape(value) + "\""); - return this; - } + private StringBuilder builder = new StringBuilder(); - /** - * Appends an integer field to the JSON. - * - * @param key The key of the field. - * @param value The value of the field. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, int value) { - appendFieldUnescaped(key, String.valueOf(value)); - return this; - } + private boolean hasAtLeastOneField = false; - /** - * Appends an object to the JSON. - * - * @param key The key of the field. - * @param object The object. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, JsonObject object) { - if (object == null) { - throw new IllegalArgumentException("JSON object must not be null"); - } - appendFieldUnescaped(key, object.toString()); - return this; - } + public JsonObjectBuilder() { + builder.append("{"); + } - /** - * Appends a string array to the JSON. - * - * @param key The key of the field. - * @param values The string array. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, String[] values) { - if (values == null) { - throw new IllegalArgumentException("JSON values must not be null"); - } - String escapedValues = - Arrays.stream(values) - .map(value -> "\"" + escape(value) + "\"") - .collect(Collectors.joining(",")); - appendFieldUnescaped(key, "[" + escapedValues + "]"); - return this; - } + /** + * Escapes the given string like stated in https://www.ietf.org/rfc/rfc4627.txt. + * + *

This method escapes only the necessary characters '"', '\'. and '\u0000' - '\u001F'. + * Compact escapes are not used (e.g., '\n' is escaped as "\u000a" and not as "\n"). + * + * @param value The value to escape. + * @return The escaped value. + */ + private static String escape(String value) { + final StringBuilder builder = new StringBuilder(); + for (int i = 0; i < value.length(); i++) { + char c = value.charAt(i); + if (c == '"') { + builder.append("\\\""); + } else if (c == '\\') { + builder.append("\\\\"); + } else if (c <= '\u000F') { + builder.append("\\u000").append(Integer.toHexString(c)); + } else if (c <= '\u001F') { + builder.append("\\u00").append(Integer.toHexString(c)); + } else { + builder.append(c); + } + } + return builder.toString(); + } - /** - * Appends an integer array to the JSON. - * - * @param key The key of the field. - * @param values The integer array. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, int[] values) { - if (values == null) { - throw new IllegalArgumentException("JSON values must not be null"); - } - String escapedValues = - Arrays.stream(values).mapToObj(String::valueOf).collect(Collectors.joining(",")); - appendFieldUnescaped(key, "[" + escapedValues + "]"); - return this; - } + /** + * Appends a null field to the JSON. + * + * @param key The key of the field. + * @return A reference to this object. + */ + public JsonObjectBuilder appendNull(String key) { + appendFieldUnescaped(key, "null"); + return this; + } - /** - * Appends an object array to the JSON. - * - * @param key The key of the field. - * @param values The integer array. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, JsonObject[] values) { - if (values == null) { - throw new IllegalArgumentException("JSON values must not be null"); - } - String escapedValues = - Arrays.stream(values).map(JsonObject::toString).collect(Collectors.joining(",")); - appendFieldUnescaped(key, "[" + escapedValues + "]"); - return this; - } + /** + * Appends a string field to the JSON. + * + * @param key The key of the field. + * @param value The value of the field. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, String value) { + if (value == null) { + throw new IllegalArgumentException("JSON value must not be null"); + } + appendFieldUnescaped(key, "\"" + escape(value) + "\""); + return this; + } - /** - * Appends a field to the object. - * - * @param key The key of the field. - * @param escapedValue The escaped value of the field. - */ - private void appendFieldUnescaped(String key, String escapedValue) { - if (builder == null) { - throw new IllegalStateException("JSON has already been built"); - } - if (key == null) { - throw new IllegalArgumentException("JSON key must not be null"); - } - if (hasAtLeastOneField) { - builder.append(","); - } - builder.append("\"").append(escape(key)).append("\":").append(escapedValue); - hasAtLeastOneField = true; - } + /** + * Appends an integer field to the JSON. + * + * @param key The key of the field. + * @param value The value of the field. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, int value) { + appendFieldUnescaped(key, String.valueOf(value)); + return this; + } - /** - * Builds the JSON string and invalidates this builder. - * - * @return The built JSON string. - */ - public JsonObject build() { - if (builder == null) { - throw new IllegalStateException("JSON has already been built"); - } - JsonObject object = new JsonObject(builder.append("}").toString()); - builder = null; - return object; - } + /** + * Appends an object to the JSON. + * + * @param key The key of the field. + * @param object The object. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, JsonObject object) { + if (object == null) { + throw new IllegalArgumentException("JSON object must not be null"); + } + appendFieldUnescaped(key, object.toString()); + return this; + } - /** - * Escapes the given string like stated in https://www.ietf.org/rfc/rfc4627.txt. - * - *

This method escapes only the necessary characters '"', '\'. and '\u0000' - '\u001F'. - * Compact escapes are not used (e.g., '\n' is escaped as "\u000a" and not as "\n"). - * - * @param value The value to escape. - * @return The escaped value. - */ - private static String escape(String value) { - final StringBuilder builder = new StringBuilder(); - for (int i = 0; i < value.length(); i++) { - char c = value.charAt(i); - if (c == '"') { - builder.append("\\\""); - } else if (c == '\\') { - builder.append("\\\\"); - } else if (c <= '\u000F') { - builder.append("\\u000").append(Integer.toHexString(c)); - } else if (c <= '\u001F') { - builder.append("\\u00").append(Integer.toHexString(c)); - } else { - builder.append(c); - } - } - return builder.toString(); - } + /** + * Appends a string array to the JSON. + * + * @param key The key of the field. + * @param values The string array. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, String[] values) { + if (values == null) { + throw new IllegalArgumentException("JSON values must not be null"); + } + String escapedValues = + Arrays.stream(values) + .map(value -> "\"" + escape(value) + "\"") + .collect(Collectors.joining(",")); + appendFieldUnescaped(key, "[" + escapedValues + "]"); + return this; + } - /** - * A super simple representation of a JSON object. - * - *

This class only exists to make methods of the {@link JsonObjectBuilder} type-safe and not - * allow a raw string inputs for methods like {@link JsonObjectBuilder#appendField(String, - * JsonObject)}. - */ - public static class JsonObject { + /** + * Appends an integer array to the JSON. + * + * @param key The key of the field. + * @param values The integer array. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, int[] values) { + if (values == null) { + throw new IllegalArgumentException("JSON values must not be null"); + } + String escapedValues = + Arrays.stream(values).mapToObj(String::valueOf).collect(Collectors.joining(",")); + appendFieldUnescaped(key, "[" + escapedValues + "]"); + return this; + } - private final String value; + /** + * Appends an object array to the JSON. + * + * @param key The key of the field. + * @param values The integer array. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, JsonObject[] values) { + if (values == null) { + throw new IllegalArgumentException("JSON values must not be null"); + } + String escapedValues = + Arrays.stream(values).map(JsonObject::toString).collect(Collectors.joining(",")); + appendFieldUnescaped(key, "[" + escapedValues + "]"); + return this; + } - private JsonObject(String value) { - this.value = value; - } + /** + * Appends a field to the object. + * + * @param key The key of the field. + * @param escapedValue The escaped value of the field. + */ + private void appendFieldUnescaped(String key, String escapedValue) { + if (builder == null) { + throw new IllegalStateException("JSON has already been built"); + } + if (key == null) { + throw new IllegalArgumentException("JSON key must not be null"); + } + if (hasAtLeastOneField) { + builder.append(","); + } + builder.append("\"").append(escape(key)).append("\":").append(escapedValue); + hasAtLeastOneField = true; + } + + /** + * Builds the JSON string and invalidates this builder. + * + * @return The built JSON string. + */ + public JsonObject build() { + if (builder == null) { + throw new IllegalStateException("JSON has already been built"); + } + JsonObject object = new JsonObject(builder.append("}").toString()); + builder = null; + return object; + } - @Override - public String toString() { - return value; - } + /** + * A super simple representation of a JSON object. + * + *

This class only exists to make methods of the {@link JsonObjectBuilder} type-safe and not + * allow a raw string inputs for methods like {@link JsonObjectBuilder#appendField(String, + * JsonObject)}. + */ + public static class JsonObject { + + private final String value; + + private JsonObject(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } + } } - } } \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/PlayerUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/PlayerUtils.java index 032bcc7d..e45edfdb 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/PlayerUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/PlayerUtils.java @@ -1,16 +1,5 @@ package com.falchus.lib.minecraft.spigot.utils; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.falchus.lib.minecraft.spigot.enums.Sound; import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; @@ -18,219 +7,230 @@ import com.google.common.io.ByteStreams; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; - import lombok.NonNull; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; +import net.luckperms.api.LuckPerms; +import net.luckperms.api.LuckPermsProvider; +import net.luckperms.api.model.user.User; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.*; @UtilityClass public class PlayerUtils { - - private static final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - public static final Set vanished = new HashSet<>(); - public static final Map skins = new HashMap<>(); - public static final Map names = new HashMap<>(); - - /** - * Sends a raw NMS packet to a player. - */ - public static void sendPacket(@NonNull Player player, @NonNull Object packet) { - VersionProvider.get().sendPacket(player, packet); - } - - /** - * Sends a title and/or subtitle to a player. - */ - public static void sendTitle(@NonNull Player player, String title, String subtitle) { - VersionProvider.get().sendTitle(player, title, subtitle); - } - - /** - * Sends a tablist to a player. - */ - public static void sendTablist(@NonNull Player player, List header, List footer, String name) { - VersionProvider.get().sendTablist(player, header, footer, name); - } - - /** - * Sends a bossbar to a player. - */ - public static void sendBossbar(@NonNull Player player, @NonNull String title, double progress) { - VersionProvider.get().sendBossbar(player, title, progress); - } - - /** - * Removes a bossbar from a player. - */ - public static void removeBossbar(@NonNull Player player) { - VersionProvider.get().removeBossbar(player); - } - - /** - * Sends a actionbar to a player. - */ - public static void sendActionbar(@NonNull Player player, @NonNull String message) { - VersionProvider.get().sendActionbar(player, message); - } - - /** - * Sends a nametag for a player. - */ - public static void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { - VersionProvider.get().sendNametag(player, prefix, suffix); - } - - /** - * Removes a nametag from a player. - */ - public static void removeNametag(@NonNull Player player) { - VersionProvider.get().removeNametag(player); - } - - /** - * Plays a sound to a player. - */ - public static void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch) { - VersionProvider.get().playSound(player, location, sound, volume, pitch); - } - - /** - * Freezes a player. - */ - public static void freeze(@NonNull Player player) { - plugin.getFreezeListener().players.add(player.getUniqueId()); - } - - /** - * Unfreezes a player. - */ - public static void unfreeze(@NonNull Player player) { - plugin.getFreezeListener().players.remove(player.getUniqueId()); - } - - /** - * Retrieves the LuckPerms rank prefix of a player. - */ - public static String getLuckPermsRankPrefix(@NonNull Player player) { - if (!Bukkit.getPluginManager().isPluginEnabled("LuckPerms")) return ""; - - net.luckperms.api.LuckPerms luckPerms = net.luckperms.api.LuckPermsProvider.get(); - net.luckperms.api.model.user.User user = luckPerms.getPlayerAdapter(Player.class).getUser(player); - net.luckperms.api.cacheddata.CachedMetaData metaData = user.getCachedData().getMetaData(); - String prefix = metaData.getPrefix(); - return prefix != null ? prefix : ""; - } - - /** - * Vanishes a player. - */ - public static void vanish(@NonNull Player player) { - if (vanished.add(player.getUniqueId())) { - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - onlinePlayer.hidePlayer(player); - } - } - } - - /** - * Unvanishes a player. - */ - public static void unvanish(@NonNull Player player) { - if (vanished.remove(player.getUniqueId())) { - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - onlinePlayer.showPlayer(player); - } - } - } - - /** - * @return EntityPlayer from Player - */ - public static Object getEntityPlayer(@NonNull Player player) { - return VersionProvider.get().getEntityPlayer(player); - } - - /** - * @return GameProfile from EntityPlayer - */ - public static GameProfile getProfile(@NonNull Object entityPlayer) { - return VersionProvider.get().getProfile(entityPlayer); - } - - /** - * @return ping from a player. - */ - public static int getPing(@NonNull Player player) { - return VersionProvider.get().getPing(player); - } - - /** - * Sets a custom skin. - */ - public static void setSkin(@NonNull Player player, @NonNull UUID uuid) { - VersionProvider.get().setSkin(player, uuid); - } - - /** - * Resets the skin back to the original. - */ - public static void resetSkin(@NonNull Player player) { - VersionProvider.get().resetSkin(player); - } - - /** - * Sets a custom name. - */ - public static void setName(@NonNull Player player, @NonNull String name) { - VersionProvider.get().setName(player, name); - } - - /** - * Resets the name back to the original. - */ - public static void resetName(@NonNull Player player) { - VersionProvider.get().resetName(player); - } - - /** - * Forces clients to reload the player's GameProfile. - */ - public static void refresh(@NonNull Player player) { - VersionProvider.get().refresh(player); - } - - /** - * Adds a EntityPlayer. - */ - public static void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - VersionProvider.get().addEntityPlayer(player, entityPlayer); - } - - /** - * Removes a EntityPlayer. - */ - public static void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - VersionProvider.get().removeEntityPlayer(player, entityPlayer); - } - - /** - * Spawns a EntityPlayer. - */ - public static void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - VersionProvider.get().spawnEntityPlayer(player, entityPlayer); - } - - /** - * Connects the player to a proxy server. - * via BungeeCord messaging - */ - @SneakyThrows - public static void connectToServer(@NonNull Player player, @NonNull String server) { - ByteArrayDataOutput out = ByteStreams.newDataOutput(); - - out.writeUTF("Connect"); - out.writeUTF(server); - - player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); - } + + public static final Set vanished = new HashSet<>(); + public static final Map skins = new HashMap<>(); + public static final Map names = new HashMap<>(); + private static final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + /** + * Sends a raw NMS packet to a player. + */ + public static void sendPacket(@NonNull Player player, @NonNull Object packet) { + VersionProvider.get().sendPacket(player, packet); + } + + /** + * Sends a title and/or subtitle to a player. + */ + public static void sendTitle(@NonNull Player player, String title, String subtitle) { + VersionProvider.get().sendTitle(player, title, subtitle); + } + + /** + * Sends a tablist header/footer and display name to a player. + */ + public static void sendTablist(@NonNull Player player, List header, List footer, String name) { + VersionProvider.get().sendTablist(player, header, footer, name); + } + + /** + * Sends a bossbar to a player. + */ + public static void sendBossbar(@NonNull Player player, @NonNull String title, double progress) { + VersionProvider.get().sendBossbar(player, title, progress); + } + + /** + * Removes the bossbar from a player. + */ + public static void removeBossbar(@NonNull Player player) { + VersionProvider.get().removeBossbar(player); + } + + /** + * Sends an action-bar message to a player. + */ + public static void sendActionbar(@NonNull Player player, @NonNull String message) { + VersionProvider.get().sendActionbar(player, message); + } + + /** + * Sends a nametag (prefix + suffix) for a player visible to all online players. + */ + public static void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { + VersionProvider.get().sendNametag(player, prefix, suffix); + } + + /** + * Removes the nametag of a player for all online players. + */ + public static void removeNametag(@NonNull Player player) { + VersionProvider.get().removeNametag(player); + } + + /** + * Plays a sound to a player at the given location. + */ + public static void playSound(@NonNull Player player, @NonNull Location location, + @NonNull Sound sound, float volume, float pitch) { + VersionProvider.get().playSound(player, location, sound, volume, pitch); + } + + /** + * Freezes a player (prevents movement and interaction). + */ + public static void freeze(@NonNull Player player) { + plugin.getFreezeListener().players.add(player.getUniqueId()); + } + + /** + * Unfreezes a player. + */ + public static void unfreeze(@NonNull Player player) { + plugin.getFreezeListener().players.remove(player.getUniqueId()); + } + + /** + * Returns the LuckPerms rank prefix of a player, or an empty string. + */ + public static @NotNull String getLuckPermsRankPrefix(@NonNull Player player) { + if (!Bukkit.getPluginManager().isPluginEnabled("LuckPerms")) return ""; + + LuckPerms lp = LuckPermsProvider.get(); + User user = lp.getPlayerAdapter(Player.class).getUser(player); + String prefix = user.getCachedData().getMetaData().getPrefix(); + return prefix != null ? prefix : ""; + } + + /** + * Vanishes a player from all online players. + *

+ * Uses {@code hidePlayer(Plugin, Player)} — the non-deprecated overload + * available since Paper 1.18 and the only one in Paper 26.x. + */ + public static void vanish(@NonNull Player player) { + if (vanished.add(player.getUniqueId())) { + for (Player online : Bukkit.getOnlinePlayers()) { + online.hidePlayer(plugin, player); + } + } + } + + /** + * Un-vanishes a player so all online players can see them again. + *

+ * Uses {@code showPlayer(Plugin, Player)} — consistent with the + * {@link #vanish} counterpart. + */ + public static void unvanish(@NonNull Player player) { + if (vanished.remove(player.getUniqueId())) { + for (Player online : Bukkit.getOnlinePlayers()) { + online.showPlayer(plugin, player); + } + } + } + + /** + * @return the NMS {@code EntityPlayer} for the given Bukkit {@link Player}. + */ + public static Object getEntityPlayer(@NonNull Player player) { + return VersionProvider.get().getEntityPlayer(player); + } + + /** + * @return the {@link GameProfile} from an NMS {@code EntityPlayer}. + */ + public static GameProfile getProfile(@NonNull Object entityPlayer) { + return VersionProvider.get().getProfile(entityPlayer); + } + + /** + * @return the current ping (ms) of a player. + */ + public static int getPing(@NonNull Player player) { + return VersionProvider.get().getPing(player); + } + + /** + * Sets a custom skin on a player (by UUID of the skin owner). + */ + public static void setSkin(@NonNull Player player, @NonNull UUID uuid) { + VersionProvider.get().setSkin(player, uuid); + } + + /** + * Resets a player's skin to their original one. + */ + public static void resetSkin(@NonNull Player player) { + VersionProvider.get().resetSkin(player); + } + + /** + * Sets a custom display name on a player. + */ + public static void setName(@NonNull Player player, @NonNull String name) { + VersionProvider.get().setName(player, name); + } + + /** + * Resets a player's display name to their original username. + */ + public static void resetName(@NonNull Player player) { + VersionProvider.get().resetName(player); + } + + /** + * Forces all clients to reload the player's {@link GameProfile}. + */ + public static void refresh(@NonNull Player player) { + VersionProvider.get().refresh(player); + } + + /** + * Adds a fake {@code EntityPlayer} to a player's player-info list. + */ + public static void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + VersionProvider.get().addEntityPlayer(player, entityPlayer); + } + + /** + * Removes a fake {@code EntityPlayer} from a player's player-info list. + */ + public static void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + VersionProvider.get().removeEntityPlayer(player, entityPlayer); + } + + /** + * Spawns a fake {@code EntityPlayer} entity for a player. + */ + public static void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + VersionProvider.get().spawnEntityPlayer(player, entityPlayer); + } + + /** + * Connects the player to a proxy server via BungeeCord plugin messaging. + */ + @SneakyThrows + public static void connectToServer(@NonNull Player player, @NonNull String server) { + ByteArrayDataOutput out = ByteStreams.newDataOutput(); + out.writeUTF("Connect"); + out.writeUTF(server); + player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); + } } \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java new file mode 100644 index 00000000..286126e5 --- /dev/null +++ b/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java @@ -0,0 +1,83 @@ +package com.falchus.lib.minecraft.spigot.utils; + +import com.falchus.lib.minecraft.FalchusLibMinecraft; +import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; +import lombok.NonNull; +import lombok.experimental.UtilityClass; +import org.bukkit.Bukkit; +import org.bukkit.entity.Entity; + +/** + * Abstraction layer over Bukkit's and Folia's scheduler APIs. + *

+ * Folia distributes world regions across threads, so synchronous tasks + * must target a specific region. Use the appropriate method based on context: + *

    + *
  • {@link #runTask} — global main thread (Bukkit) / global region (Folia)
  • + *
  • {@link #runTaskAsync} — async on both platforms
  • + *
  • {@link #runTaskForEntity} — entity's own region (Folia) / main thread (Bukkit)
  • + *
+ */ +@UtilityClass +public class SchedulerUtils { + + /** + * Runs a task on the main thread (Bukkit) or the global region thread (Folia). + */ + public static void runTask(@NonNull Runnable runnable) { + FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + if (FalchusLibMinecraft.isFolia()) { + Bukkit.getGlobalRegionScheduler().run(plugin, task -> runnable.run()); + } else { + Bukkit.getScheduler().runTask(plugin, runnable); + } + } + + /** + * Runs a task asynchronously on both Bukkit and Folia. + */ + public static void runTaskAsync(@NonNull Runnable runnable) { + FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + if (FalchusLibMinecraft.isFolia()) { + Bukkit.getAsyncScheduler().runNow(plugin, task -> runnable.run()); + } else { + Bukkit.getScheduler().runTaskAsynchronously(plugin, runnable); + } + } + + /** + * Runs a task on the thread that owns the entity's region (Folia) + * or the main thread (Bukkit). + *

+ * On Folia, {@code EntityScheduler#run} returns {@code null} when the entity + * has already been removed from the world — in that case the task is silently + * dropped, which is the correct behaviour (nothing to update for a dead entity). + * + * @param entity the entity whose region thread to target + * @param runnable the task to execute + */ + public static void runTaskForEntity(@NonNull Entity entity, @NonNull Runnable runnable) { + FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + if (FalchusLibMinecraft.isFolia()) { + // Returns null if the entity is no longer valid — safe to ignore. + entity.getScheduler().run(plugin, task -> runnable.run(), null); + } else { + Bukkit.getScheduler().runTask(plugin, runnable); + } + } + + /** + * Runs a delayed task. + * + * @param runnable the task + * @param delayTicks delay in server ticks (1 tick ≈ 50 ms) + */ + public static void runTaskLater(@NonNull Runnable runnable, long delayTicks) { + FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + if (FalchusLibMinecraft.isFolia()) { + Bukkit.getGlobalRegionScheduler().runDelayed(plugin, task -> runnable.run(), Math.max(1, delayTicks)); + } else { + Bukkit.getScheduler().runTaskLater(plugin, runnable, Math.max(1, delayTicks)); + } + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/ServerUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/ServerUtils.java index 6f928905..f74af6be 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/ServerUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/ServerUtils.java @@ -1,90 +1,88 @@ package com.falchus.lib.minecraft.spigot.utils; -import org.bukkit.Bukkit; -import org.bukkit.Server; - import com.falchus.lib.minecraft.spigot.enums.Version; import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; - import lombok.experimental.UtilityClass; +import org.bukkit.Bukkit; +import org.bukkit.Server; @UtilityClass public class ServerUtils { - /** - * @return MinecraftServer - */ - public static Object getMcServer() { - return VersionProvider.get().getMcServer(); - } - - /** - * @return {@link Server} - */ - public static Object getBukkitServer() { - return VersionProvider.get().getBukkitServer(); - } - - /** - * @return {@link Version} - */ - public static Version getVersion() { - int major = getMajorVersion(); - int minor = getMinorVersion(); - - Version version = null; - for (Version v : Version.values()) { - if (v.getMajor() < major || (v.getMajor() == major && v.getMinor() <= minor)) { - if (version == null || v.isAfter(version)) { - version = v; - } - } - } - if (version == null) { - throw new IllegalStateException("Unsupported server version: " + getVersionString()); - } - return version; - } - - /** - * @return e.g. "1.8.8" - */ - public static String getVersionString() { - return VersionProvider.get().getVersion(); - } - - /** - * @return e.g. 26 for 26.1 - */ - public static int getMajorVersion() { - String bukkitVersion = Bukkit.getBukkitVersion(); - String mc = bukkitVersion.split("-")[0]; - - try { - return Integer.parseInt(mc.split("\\.")[0]); - } catch (Exception e) { - throw new RuntimeException(e); + /** + * @return MinecraftServer + */ + public static Object getMcServer() { + return VersionProvider.get().getMcServer(); + } + + /** + * @return {@link Server} + */ + public static Object getBukkitServer() { + return VersionProvider.get().getBukkitServer(); + } + + /** + * @return {@link Version} + */ + public static Version getVersion() { + int major = getMajorVersion(); + int minor = getMinorVersion(); + + Version version = null; + for (Version v : Version.values()) { + if (v.getMajor() < major || (v.getMajor() == major && v.getMinor() <= minor)) { + if (version == null || v.isAfter(version)) { + version = v; + } + } } - } - - /** - * @return e.g. 8 for 1.8.8 - */ - public static int getMinorVersion() { - String bukkitVersion = Bukkit.getBukkitVersion(); - String mc = bukkitVersion.split("-")[0]; - - try { - return Integer.parseInt(mc.split("\\.")[1]); - } catch (Exception e) { - throw new RuntimeException(e); + if (version == null) { + throw new IllegalStateException("Unsupported server version: " + getVersionString()); } - } - - /** - * @return recent TPS - */ - public static double[] getRecentTps() { - return VersionProvider.get().getRecentTps(); - } + return version; + } + + /** + * @return e.g. "1.8.8" + */ + public static String getVersionString() { + return VersionProvider.get().getVersion(); + } + + /** + * @return e.g. 26 for 26.1 + */ + public static int getMajorVersion() { + String bukkitVersion = Bukkit.getBukkitVersion(); + String mc = bukkitVersion.split("-")[0]; + + try { + return Integer.parseInt(mc.split("\\.")[0]); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * @return e.g. 8 for 1.8.8 + */ + public static int getMinorVersion() { + String bukkitVersion = Bukkit.getBukkitVersion(); + String mc = bukkitVersion.split("-")[0]; + + try { + return Integer.parseInt(mc.split("\\.")[1]); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * @return recent TPS + */ + public static double[] getRecentTps() { + return VersionProvider.get().getRecentTps(); + } } \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/WorldUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/WorldUtils.java index 2d523a8e..6b5eaf8a 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/WorldUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/WorldUtils.java @@ -1,71 +1,98 @@ package com.falchus.lib.minecraft.spigot.utils; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.block.Biome; - import com.falchus.lib.minecraft.spigot.enums.GameRule; import com.falchus.lib.minecraft.spigot.enums.Version; import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; - import lombok.NonNull; import lombok.experimental.UtilityClass; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Biome; @UtilityClass public class WorldUtils { - /** - * Sets a game rule for the given world. - */ - public static void setGameRule(@NonNull World world, @NonNull GameRule gameRule, @NonNull String value) { - world.setGameRuleValue(gameRule.getKey(), value); - } - - /** - * @return World Biomes - */ - public static Object[] getWorldBiomes(@NonNull World world) { - return VersionProvider.get().getWorldBiomes(world); - } - - /** - * @return BiomeBase from a Biome - */ - public static Object getNmsBiome(Biome biome) { + /** + * Sets a game rule for the given world. + *

+ * {@code World.setGameRuleValue(String, String)} was deprecated in Paper 1.18 + * and removed in Paper 26.x. On 1.13+ we resolve the typed + * {@link org.bukkit.GameRule} constant by name and use the non-deprecated + * {@code World.setGameRule(GameRule, T)} overload. On 1.8–1.12 the legacy + * String overload is still used because the typed API does not exist there. + */ + @SuppressWarnings({"unchecked", "rawtypes"}) + public static void setGameRule(@NonNull World world, @NonNull GameRule gameRule, @NonNull String value) { + if (ServerUtils.getVersion().isAfter(Version.v1_12)) { + org.bukkit.GameRule rule = org.bukkit.GameRule.getByName(gameRule.getKey()); + if (rule == null) { + throw new IllegalArgumentException("Unknown game rule: " + gameRule.getKey()); + } + + Class type = rule.getType(); + if (type == Boolean.class) { + world.setGameRule((org.bukkit.GameRule) rule, Boolean.parseBoolean(value)); + } else if (type == Integer.class) { + world.setGameRule((org.bukkit.GameRule) rule, Integer.parseInt(value)); + } else { + // Fallback for any future typed game rules — attempt the String cast. + // This will throw a ClassCastException at runtime if the type truly + // cannot accept a String, which is a programmer error. + world.setGameRule((org.bukkit.GameRule) rule, value); + } + } else { + // 1.8–1.12: typed API unavailable, legacy String overload is fine. + world.setGameRuleValue(gameRule.getKey(), value); + } + } + + /** + * @return the NMS {@code BiomeBase[]} array for the given world. + */ + public static Object[] getWorldBiomes(@NonNull World world) { + return VersionProvider.get().getWorldBiomes(world); + } + + /** + * @return the NMS {@code BiomeBase} for the given Bukkit {@link Biome}. + */ + public static Object getNmsBiome(Biome biome) { return VersionProvider.get().getNmsBiome(biome); } - - /** - * @return id from a Biome - */ - public static int getBiomeId(Biome biome) { - return VersionProvider.get().getBiomeId(biome); - } - - /** - * @return WorldServer from a World - */ - public static Object getWorldServer(World world) { - return VersionProvider.get().getWorldServer(world); - } - - /** - * @return {@link Biome} - */ - public static Biome getBiome(com.falchus.lib.minecraft.spigot.enums.Biome biome) { - if (ServerUtils.getVersion().isBefore(Version.v1_17)) { - return Biome.valueOf(biome.name()); - } - return Biome.valueOf(biome.getModernName()); - } - - /** - * @return {@link Material} - */ - public static Material getMaterial(com.falchus.lib.minecraft.spigot.enums.Material material) { - if (ServerUtils.getVersion().isBefore(Version.v1_13)) { - return Material.valueOf(material.getLegacyName()); - } - return Material.valueOf(material.name()); - } -} + + /** + * @return the numeric biome id for the given Bukkit {@link Biome}. + */ + public static int getBiomeId(Biome biome) { + return VersionProvider.get().getBiomeId(biome); + } + + /** + * @return the NMS {@code WorldServer} for the given Bukkit {@link World}. + */ + public static Object getWorldServer(World world) { + return VersionProvider.get().getWorldServer(world); + } + + /** + * @return the Bukkit {@link Biome} matching the library's cross-version + * {@link com.falchus.lib.minecraft.spigot.enums.Biome} enum. + */ + public static Biome getBiome(@NonNull com.falchus.lib.minecraft.spigot.enums.Biome biome) { + if (ServerUtils.getVersion().isBefore(Version.v1_17)) { + return Biome.valueOf(biome.name()); + } + return Biome.valueOf(biome.getModernName()); + } + + /** + * @return the Bukkit {@link Material} matching the library's cross-version + * {@link com.falchus.lib.minecraft.spigot.enums.Material} enum. + */ + public static Material getMaterial(@NonNull com.falchus.lib.minecraft.spigot.enums.Material material) { + if (ServerUtils.getVersion().isBefore(Version.v1_13)) { + return Material.valueOf(material.getLegacyName()); + } + return Material.valueOf(material.name()); + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/builder/EntityPlayerBuilder.java b/src/com/falchus/lib/minecraft/spigot/utils/builder/EntityPlayerBuilder.java index 700f2c4f..47d004aa 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/builder/EntityPlayerBuilder.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/builder/EntityPlayerBuilder.java @@ -1,17 +1,8 @@ package com.falchus.lib.minecraft.spigot.utils.builder; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.falchus.lib.minecraft.spigot.utils.EntityUtils; +import com.falchus.lib.minecraft.spigot.utils.SchedulerUtils; import com.falchus.lib.minecraft.spigot.utils.ServerUtils; import com.falchus.lib.minecraft.spigot.utils.WorldUtils; import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; @@ -19,165 +10,178 @@ import com.falchus.lib.utils.builder.ClassInstanceBuilder; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; - import lombok.Getter; import lombok.NonNull; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; @Getter public class EntityPlayerBuilder { - - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - private String name = ""; - private UUID uuid = UUID.randomUUID(); - private String skinValue; - private String skinSignature; - private boolean invisible = false; - private Location location; - private boolean lookAtPlayer = false; - - public EntityPlayerBuilder setName(@NonNull String name) { - this.name = name; - return this; - } - - public EntityPlayerBuilder setUUID(@NonNull UUID uuid) { - this.uuid = uuid; - return this; - } - - public EntityPlayerBuilder setSkin(@NonNull String skinValue, @NonNull String skinSignature) { - this.skinValue = skinValue; - this.skinSignature = skinSignature; - return this; - } - - public EntityPlayerBuilder setInvisible(boolean invisible) { - this.invisible = invisible; - return this; - } - - public EntityPlayerBuilder setLocation(@NonNull Location location) { - this.location = location; - return this; - } - - /** - * Registers a callback to be executed when a player interacts with this EntityPlayer. - */ - public EntityPlayerBuilder withInteractListener(@NonNull Consumer onPlayerInteract) { - plugin.getEntityPlayerListener().actions.put(uuid, onPlayerInteract); - return this; - } - - /** - * Makes the EntityPlayer look at the player. - */ - public EntityPlayerBuilder lookAtPlayer(boolean lookAtPlayer) { - this.lookAtPlayer = lookAtPlayer; - return this; - } - - /** - * Builds and returns the final EntityPlayer. - */ - public Object build() { - try { - Object server = ServerUtils.getMcServer(); - - Object world = WorldUtils.getWorldServer(location != null ? location.getWorld() : Bukkit.getWorlds().get(0)); - - GameProfile profile = new GameProfile(uuid, name); - if (skinValue != null && skinSignature != null) { - profile.getProperties().put("textures", new Property("textures", skinValue, skinSignature)); - } - - Object playerInteractManager = new ClassInstanceBuilder( - VersionProvider.get().getPlayerInteractManager() - ).withParams( - Map.of( - VersionProvider.get().getWorld(), - world - ) - ).build(); - - Object entityPlayer = new ClassInstanceBuilder( - VersionProvider.get().getEntityPlayer() - ).withParams( - Map.of( - VersionProvider.get().getMinecraftServer(), - server - ), - Map.of( - VersionProvider.get().getWorldServer(), - world - ), - Map.of( - GameProfile.class, - profile - ), - Map.of( - VersionProvider.get().getPlayerInteractManager(), - playerInteractManager - ) - ).build(); - - if (location != null) { - VersionProvider.get().getEntity_setLocation().invoke(entityPlayer, - location.getX(), - location.getY(), - location.getZ(), - location.getYaw(), - location.getPitch() - ); - } - VersionProvider.get().getEntity_setInvisible().invoke(entityPlayer, - invisible - ); - - plugin.getEntityPlayerListener().players.put(uuid, entityPlayer); - - if (lookAtPlayer) { - new Task() { - @Override - public void onRun(int tick) { - Entity entity = EntityUtils.getBukkitEntity(entityPlayer); - if (entity == null || !entity.isValid()) { - end(); - return; - } - - Player nearest = null; - double nearestDist = Double.MAX_VALUE; - - for (Player player : entity.getWorld().getPlayers()) { - double dist = player.getLocation().distanceSquared(entity.getLocation()); - if (dist < nearestDist) { - nearestDist = dist; - nearest = player; - } - } - - if (nearest != null) { - Location from = entity.getLocation().add(0, 1.6, 0); - Location to = nearest.getLocation().add(0, 1.6, 0); - - double dx = to.getX() - from.getX(); - double dy = to.getY() - from.getY(); - double dz = to.getZ() - from.getZ(); - - double distanceXZ = Math.sqrt(dx * dx + dz * dz); - - float yaw = (float) Math.toDegrees(Math.atan2(-dx, dz)); - float pitch = (float) -Math.toDegrees(Math.atan2(dy, distanceXZ)); - EntityUtils.setYawPitch(entityPlayer, yaw, pitch); - } - } - }.runTaskTimer(100, TimeUnit.MILLISECONDS); - } - return entityPlayer; - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} + + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + private String name = ""; + private UUID uuid = UUID.randomUUID(); + private String skinValue; + private String skinSignature; + private boolean invisible = false; + private Location location; + private boolean lookAtPlayer = false; + + public EntityPlayerBuilder setName(@NonNull String name) { + this.name = name; + return this; + } + + public EntityPlayerBuilder setUUID(@NonNull UUID uuid) { + this.uuid = uuid; + return this; + } + + public EntityPlayerBuilder setSkin(@NonNull String skinValue, @NonNull String skinSignature) { + this.skinValue = skinValue; + this.skinSignature = skinSignature; + return this; + } + + public EntityPlayerBuilder setInvisible(boolean invisible) { + this.invisible = invisible; + return this; + } + + public EntityPlayerBuilder setLocation(@NonNull Location location) { + this.location = location; + return this; + } + + /** + * Registers a callback to be executed when a player interacts with this EntityPlayer. + */ + public EntityPlayerBuilder withInteractListener(@NonNull Consumer onPlayerInteract) { + plugin.getEntityPlayerListener().actions.put(uuid, onPlayerInteract); + return this; + } + + /** + * Makes the EntityPlayer continuously face the nearest player. + *

+ * On Folia the per-tick update runs through the entity's own region scheduler + * (via {@link SchedulerUtils#runTaskForEntity}) so it is always on the correct + * thread. On plain Bukkit/Spigot the same code path falls back to the main thread. + */ + public EntityPlayerBuilder lookAtPlayer(boolean lookAtPlayer) { + this.lookAtPlayer = lookAtPlayer; + return this; + } + + /** + * Builds and returns the final EntityPlayer NMS object. + */ + public Object build() { + try { + Object server = ServerUtils.getMcServer(); + Object world = WorldUtils.getWorldServer( + location != null ? location.getWorld() : Bukkit.getWorlds().get(0) + ); + + GameProfile profile = new GameProfile(uuid, name); + if (skinValue != null && skinSignature != null) { + profile.getProperties().put("textures", new Property("textures", skinValue, skinSignature)); + } + + Object playerInteractManager = new ClassInstanceBuilder( + VersionProvider.get().getPlayerInteractManager() + ).withParams( + Map.of(VersionProvider.get().getWorld(), world) + ).build(); + + Object entityPlayer = new ClassInstanceBuilder( + VersionProvider.get().getEntityPlayer() + ).withParams( + Map.of(VersionProvider.get().getMinecraftServer(), server), + Map.of(VersionProvider.get().getWorldServer(), world), + Map.of(GameProfile.class, profile), + Map.of(VersionProvider.get().getPlayerInteractManager(), playerInteractManager) + ).build(); + + if (location != null) { + VersionProvider.get().getEntity_setLocation().invoke(entityPlayer, + location.getX(), location.getY(), location.getZ(), + location.getYaw(), location.getPitch() + ); + } + VersionProvider.get().getEntity_setInvisible().invoke(entityPlayer, invisible); + + plugin.getEntityPlayerListener().players.put(uuid, entityPlayer); + + if (lookAtPlayer) { + scheduleLookAtPlayer(entityPlayer); + } + + return entityPlayer; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Schedules a repeating task that rotates the EntityPlayer toward the nearest + * online player. + *

+ * The task itself runs on {@link Task}'s own {@link java.util.concurrent.ScheduledExecutorService}, + * which is off the main/region thread. All world reads inside the task + * ({@code entity.getLocation()}, {@code entity.getWorld().getPlayers()}) are + * performed within a {@link SchedulerUtils#runTaskForEntity} call, so they land + * on the entity's owning region thread on Folia — or the main thread on Bukkit. + * The actual yaw/pitch write ({@link EntityUtils#setYawPitch}) is done inside + * that same callback, keeping everything thread-safe. + */ + private void scheduleLookAtPlayer(Object entityPlayer) { + new Task() { + @Override + public void onRun(int tick) { + Entity entity = EntityUtils.getBukkitEntity(entityPlayer); + if (entity == null || !entity.isValid()) { + end(); + return; + } + + SchedulerUtils.runTaskForEntity(entity, () -> { + if (!entity.isValid()) return; + + Player nearest = null; + double nearestDist = Double.MAX_VALUE; + + for (Player player : entity.getWorld().getPlayers()) { + double dist = player.getLocation().distanceSquared(entity.getLocation()); + if (dist < nearestDist) { + nearestDist = dist; + nearest = player; + } + } + + if (nearest == null) return; + + Location from = entity.getLocation().add(0, 1.6, 0); + Location to = nearest.getLocation().add(0, 1.6, 0); + + double dx = to.getX() - from.getX(); + double dy = to.getY() - from.getY(); + double dz = to.getZ() - from.getZ(); + double distXZ = Math.sqrt(dx * dx + dz * dz); + + float yaw = (float) Math.toDegrees(Math.atan2(-dx, dz)); + float pitch = (float) -Math.toDegrees(Math.atan2(dy, distXZ)); + EntityUtils.setYawPitch(entityPlayer, yaw, pitch); + }); + } + }.runTaskTimer(100, TimeUnit.MILLISECONDS); + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/builder/GameProfileBuilder.java b/src/com/falchus/lib/minecraft/spigot/utils/builder/GameProfileBuilder.java index b19b20b9..b16ae450 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/builder/GameProfileBuilder.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/builder/GameProfileBuilder.java @@ -6,9 +6,7 @@ import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; import com.mojang.util.UUIDTypeAdapter; - import lombok.AllArgsConstructor; - import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; import java.lang.reflect.Type; @@ -55,10 +53,10 @@ public static GameProfile fetch(UUID uuid, boolean forceNew) { if (!forceNew && cache.containsKey(uuid) && cache.get(uuid).isValid()) { return cache.get(uuid).profile; } - + String json = HTTPRequest.get(String.format(url, UUIDTypeAdapter.fromUUID(uuid))); if (json == null) return null; - + GameProfile result = gson.fromJson(json, GameProfile.class); cache.put(uuid, new CachedProfile(result)); return result; @@ -97,7 +95,7 @@ public static GameProfile getProfile(UUID uuid, String name, String skinUrl, Str args.add(name); args.add(skinUrl); if (cape) { - args.add(capeUrl); + args.add(capeUrl); } profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString(String.format(cape ? jsonCape : jsonSkin, args.toArray(new Object[0]))))); diff --git a/src/com/falchus/lib/minecraft/spigot/utils/builder/InventoryBuilder.java b/src/com/falchus/lib/minecraft/spigot/utils/builder/InventoryBuilder.java index 55101df4..df6504e1 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/builder/InventoryBuilder.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/builder/InventoryBuilder.java @@ -1,31 +1,29 @@ package com.falchus.lib.minecraft.spigot.utils.builder; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.function.Consumer; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - import com.falchus.lib.interfaces.consumer.TriConsumer; import com.falchus.lib.minecraft.spigot.enums.Material; import com.falchus.lib.minecraft.spigot.utils.ItemUtils; import com.falchus.lib.minecraft.spigot.utils.inventory.animation.open.InventoryOpenAnimation; - import lombok.Getter; import lombok.NonNull; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.function.Consumer; @Getter public class InventoryBuilder { private final String title; private final int size; - private boolean dynamicSize = false; private final List items = new ArrayList<>(); + private boolean dynamicSize = false; private TriConsumer globalClickListener; private ItemStack filler; private InventoryOpenAnimation openAnimation; @@ -37,14 +35,14 @@ public InventoryBuilder(@NonNull String title, @NonNull Integer size) { this.title = title; this.size = size; } - + /** * When enabled, the inventory size auto-adjusts to the number of items * but never exceeds the initially set size. */ public InventoryBuilder dynamicSize(boolean dynamicSize) { - this.dynamicSize = dynamicSize; - return this; + this.dynamicSize = dynamicSize; + return this; } /** @@ -73,15 +71,15 @@ public InventoryBuilder setItem(int slot, @NonNull ItemStack item, @NonNull TriC items.add(new ItemUtils.InventoryItem(slot, itemWithUUID, null)); return this; } - + /** * Sets the animation to play when opening the inventory. */ public InventoryBuilder setOpenAnimation(@NonNull InventoryOpenAnimation openAnimation) { - this.openAnimation = openAnimation; + this.openAnimation = openAnimation; return this; } - + /** * Adds an item without a click listener. */ @@ -116,7 +114,7 @@ public InventoryBuilder withClickListener(@NonNull TriConsumer pages = buildPages(); - if (pages.isEmpty()) return; - - Inventory inventory = pages.get(page); - player.openInventory(inventory); - - if (openAnimation != null) { - openAnimation.play(player, inventory); - } + List pages = buildPages(); + if (pages.isEmpty()) return; + + Inventory inventory = pages.get(page); + player.openInventory(inventory); + + if (openAnimation != null) { + openAnimation.play(player, inventory); + } } /** * Builds and returns the final {@link Inventory}. */ public Inventory build() { - return buildInventory(items, title, size); + return buildInventory(items, title, size); } - + /** * Builds multiple pages if items exceed inventory size. * The last row is reserved. */ public List buildPages() { - List pages = new ArrayList<>(); - int pageSize = size - 9; - - int calcPages = (int) Math.ceil(items.size() / (double) pageSize); - final int totalPages = calcPages == 0 ? 1 : calcPages; - - for (int page = 0; page < totalPages; page++) { + List pages = new ArrayList<>(); + int pageSize = size - 9; + + int calcPages = (int) Math.ceil(items.size() / (double) pageSize); + final int totalPages = calcPages == 0 ? 1 : calcPages; + + for (int page = 0; page < totalPages; page++) { int start = page * pageSize; int end = Math.min(start + pageSize, items.size()); List pageItems = items.subList(start, end); - - Inventory inv = buildInventory(pageItems, title, size); - - final int currentPage = page; - - inv.setItem(size - 9, new ItemBuilder(Material.PLAYER_HEAD).setName("§ePrevious page").setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWYxMzNlOTE5MTlkYjBhY2VmZGMyNzJkNjdmZDg3YjRiZTg4ZGM0NGE5NTg5NTg4MjQ0NzRlMjFlMDZkNTNlNiJ9fX0=").withInventoryClickListener( - (player, item, event) -> { - if (currentPage > 0) { - player.openInventory(pages.get(currentPage - 1)); - } - }) - .build()); - inv.setItem(size - 1, new ItemBuilder(Material.PLAYER_HEAD).setName("§eNext page").setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTNmYzUyMjY0ZDhhZDllNjU0ZjQxNWJlZjAxYTIzOTQ3ZWRiY2NjY2Y2NDkzNzMyODliZWE0ZDE0OTU0MWY3MCJ9fX0=").withInventoryClickListener( - (player, item, event) -> { - if (currentPage < totalPages - 1) { - player.openInventory(pages.get(currentPage + 1)); - } - }) - .build()); - - pages.add(inv); - } - - return pages; + + Inventory inv = buildInventory(pageItems, title, size); + + final int currentPage = page; + + inv.setItem(size - 9, new ItemBuilder(Material.PLAYER_HEAD).setName("§ePrevious page").setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWYxMzNlOTE5MTlkYjBhY2VmZGMyNzJkNjdmZDg3YjRiZTg4ZGM0NGE5NTg5NTg4MjQ0NzRlMjFlMDZkNTNlNiJ9fX0=").withInventoryClickListener( + (player, item, event) -> { + if (currentPage > 0) { + player.openInventory(pages.get(currentPage - 1)); + } + }) + .build()); + inv.setItem(size - 1, new ItemBuilder(Material.PLAYER_HEAD).setName("§eNext page").setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTNmYzUyMjY0ZDhhZDllNjU0ZjQxNWJlZjAxYTIzOTQ3ZWRiY2NjY2Y2NDkzNzMyODliZWE0ZDE0OTU0MWY3MCJ9fX0=").withInventoryClickListener( + (player, item, event) -> { + if (currentPage < totalPages - 1) { + player.openInventory(pages.get(currentPage + 1)); + } + }) + .build()); + + pages.add(inv); + } + + return pages; } - + private Inventory buildInventory(List items, String inventoryTitle, int inventorySize) { int itemCount = items.size(); int size = inventorySize; - + if (dynamicSize) { size = ((itemCount + 8) / 9) * 9; if (filler != null) { - size += 9; + size += 9; } if (size > inventorySize) { - size = inventorySize; + size = inventorySize; } } Inventory inventory = Bukkit.createInventory(null, size, inventoryTitle); - - int autoSlot = 0; - for (ItemUtils.InventoryItem item : items) { - int targetSlot = item.slot == -1 ? autoSlot++ : item.slot; - - UUID uuid = ItemUtils.getUUID(item.item); - if (uuid == null) { - uuid = UUID.randomUUID(); - } - ItemStack itemWithUUID = ItemUtils.setUUID(item.item, uuid); - - inventory.setItem(targetSlot, itemWithUUID); - - if (item.onInventoryClick != null) { - ItemUtils.itemActionsInventory.put(uuid, (pl, clickedItem, event) -> item.onInventoryClick.accept(pl)); - } else if (globalClickListener != null) { - ItemUtils.itemActionsInventory.put(uuid, (pl, clickedItem, event) -> globalClickListener.accept(pl, clickedItem, event)); - } - } - + + int autoSlot = 0; + for (ItemUtils.InventoryItem item : items) { + int targetSlot = item.slot == -1 ? autoSlot++ : item.slot; + + UUID uuid = ItemUtils.getUUID(item.item); + if (uuid == null) { + uuid = UUID.randomUUID(); + } + ItemStack itemWithUUID = ItemUtils.setUUID(item.item, uuid); + + inventory.setItem(targetSlot, itemWithUUID); + + if (item.onInventoryClick != null) { + ItemUtils.itemActionsInventory.put(uuid, (pl, clickedItem, event) -> item.onInventoryClick.accept(pl)); + } else if (globalClickListener != null) { + ItemUtils.itemActionsInventory.put(uuid, (pl, clickedItem, event) -> globalClickListener.accept(pl, clickedItem, event)); + } + } + if (filler != null) { for (int i = 0; i < inventorySize; i++) { if (inventory.getItem(i) == null) { @@ -250,7 +248,7 @@ private Inventory buildInventory(List items, String inv } } } - + if (globalClickListener != null) { ItemUtils.inventoryCallbacks.put(inventory, globalClickListener); } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/builder/ItemBuilder.java b/src/com/falchus/lib/minecraft/spigot/utils/builder/ItemBuilder.java index d1985a37..22f40e13 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/builder/ItemBuilder.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/builder/ItemBuilder.java @@ -1,19 +1,5 @@ package com.falchus.lib.minecraft.spigot.utils.builder; -import java.lang.reflect.Field; -import java.util.List; -import java.util.UUID; -import java.util.function.Consumer; - -import org.bukkit.Material; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.SkullMeta; - import com.falchus.lib.interfaces.consumer.TriConsumer; import com.falchus.lib.minecraft.spigot.enums.Version; import com.falchus.lib.minecraft.spigot.utils.ItemUtils; @@ -22,180 +8,192 @@ import com.falchus.lib.utils.reflection.ReflectionUtils; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; - import lombok.NonNull; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.SkullMeta; + +import java.lang.reflect.Field; +import java.util.List; +import java.util.UUID; +import java.util.function.Consumer; public class ItemBuilder { - private ItemStack item; - - /** - * Creates an ItemBuilder for the given material and amount. - */ - public ItemBuilder(@NonNull Material material, int amount) { - this.item = new ItemStack(material, amount); - } - - /** - * Creates an ItemBuilder for the given material. - */ - public ItemBuilder(@NonNull Material material) { - this(material, 1); - } - - /** - * Creates an ItemBuilder for the given material and amount. - */ - public ItemBuilder(@NonNull com.falchus.lib.minecraft.spigot.enums.Material material, int amount) { - Material mat = WorldUtils.getMaterial(material); - if (ServerUtils.getVersion().isBefore(Version.v1_13)) { - this.item = new ItemStack(mat, amount, (short) material.getLegacyDurability()); - } else { - this.item = new ItemStack(mat, amount); - } - } - - /** - * Creates an ItemBuilder for the given material. - */ - public ItemBuilder(@NonNull com.falchus.lib.minecraft.spigot.enums.Material material) { - this(material, 1); - } - - /** - * Creates an ItemBuilder from an existing ItemStack. - */ - public ItemBuilder(@NonNull ItemStack item) { - this.item = item.clone(); - } - - /** - * Sets the display name. - */ - public ItemBuilder setName(@NonNull String name) { - ItemMeta meta = item.getItemMeta(); - if (meta != null) { - meta.setDisplayName(name); - item.setItemMeta(meta); - } - return this; - } - - /** - * Sets the lore. - */ - public ItemBuilder setLore(@NonNull List lore) { - ItemMeta meta = item.getItemMeta(); - if (meta != null) { - meta.setLore(lore); - item.setItemMeta(meta); - } - return this; - } - - /** - * Adds an unsafe enchantment. - */ - public ItemBuilder addEnchantment(@NonNull Enchantment enchantment, int level) { - item.addUnsafeEnchantment(enchantment, level); - return this; - } - - /** - * Adds a item flag. - */ - public ItemBuilder addItemFlag(@NonNull ItemFlag itemFlag) { - ItemMeta meta = item.getItemMeta(); - if (meta != null) { - meta.addItemFlags(itemFlag); - item.setItemMeta(meta); - } - return this; - } - - /** - * Sets the durability. - */ - public ItemBuilder setDurability(short durability) { - item.setDurability(durability); - return this; - } - - /** - * Sets the skull owner. - */ - public ItemBuilder setSkullOwner(@NonNull String owner) { - if (item.getType() == WorldUtils.getMaterial(com.falchus.lib.minecraft.spigot.enums.Material.PLAYER_HEAD)) { - SkullMeta meta = (SkullMeta) item.getItemMeta(); - if (meta != null) { - meta.setOwner(owner); - item.setItemMeta(meta); - } - } - return this; - } - - /** - * Sets a custom skull texture using a Base64 texture string. - */ - public ItemBuilder setSkullTexture(@NonNull String texture) { - if (item.getType() == WorldUtils.getMaterial(com.falchus.lib.minecraft.spigot.enums.Material.PLAYER_HEAD)) { - SkullMeta meta = (SkullMeta) item.getItemMeta(); - if (meta != null) { - try { - GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null); - gameProfile.getProperties().put("textures", new Property("textures", texture)); - - Field gameProfile_profile = ReflectionUtils.getField(meta.getClass(), "profile"); - gameProfile_profile.set(meta, gameProfile); - - item.setItemMeta(meta); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - return this; - } - - /** - * Sets a custom UUID (stored in NBT). - */ - public ItemBuilder setUUID(@NonNull UUID uuid) { - ItemUtils.setUUID(item, uuid); - return this; - } - - /** - * Registers a callback to be executed when a player interacts. - */ - public ItemBuilder withInteractListener(@NonNull Consumer onPlayerInteract) { - UUID uuid = ItemUtils.getUUID(item); - if (uuid == null) { - uuid = UUID.randomUUID(); - item = ItemUtils.setUUID(item, uuid); - } - ItemUtils.itemActions.put(uuid, onPlayerInteract); - return this; - } - - /** - * Registers a callback to be executed when a player clicks in an inventory. - */ - public ItemBuilder withInventoryClickListener(@NonNull TriConsumer onInventoryClick) { - UUID uuid = ItemUtils.getUUID(item); - if (uuid == null) { - uuid = UUID.randomUUID(); - item = ItemUtils.setUUID(item, uuid); - } - ItemUtils.itemActionsInventory.put(uuid, onInventoryClick); - return this; - } - - /** - * Builds and returns the final {@link ItemStack}. - */ - public ItemStack build() { - return item; - } + private ItemStack item; + + /** + * Creates an ItemBuilder for the given material and amount. + */ + public ItemBuilder(@NonNull Material material, int amount) { + this.item = new ItemStack(material, amount); + } + + /** + * Creates an ItemBuilder for the given material. + */ + public ItemBuilder(@NonNull Material material) { + this(material, 1); + } + + /** + * Creates an ItemBuilder for the given material and amount. + */ + public ItemBuilder(@NonNull com.falchus.lib.minecraft.spigot.enums.Material material, int amount) { + Material mat = WorldUtils.getMaterial(material); + if (ServerUtils.getVersion().isBefore(Version.v1_13)) { + this.item = new ItemStack(mat, amount, (short) material.getLegacyDurability()); + } else { + this.item = new ItemStack(mat, amount); + } + } + + /** + * Creates an ItemBuilder for the given material. + */ + public ItemBuilder(@NonNull com.falchus.lib.minecraft.spigot.enums.Material material) { + this(material, 1); + } + + /** + * Creates an ItemBuilder from an existing ItemStack. + */ + public ItemBuilder(@NonNull ItemStack item) { + this.item = item.clone(); + } + + /** + * Sets the display name. + */ + public ItemBuilder setName(@NonNull String name) { + ItemMeta meta = item.getItemMeta(); + if (meta != null) { + meta.setDisplayName(name); + item.setItemMeta(meta); + } + return this; + } + + /** + * Sets the lore. + */ + public ItemBuilder setLore(@NonNull List lore) { + ItemMeta meta = item.getItemMeta(); + if (meta != null) { + meta.setLore(lore); + item.setItemMeta(meta); + } + return this; + } + + /** + * Adds an unsafe enchantment. + */ + public ItemBuilder addEnchantment(@NonNull Enchantment enchantment, int level) { + item.addUnsafeEnchantment(enchantment, level); + return this; + } + + /** + * Adds a item flag. + */ + public ItemBuilder addItemFlag(@NonNull ItemFlag itemFlag) { + ItemMeta meta = item.getItemMeta(); + if (meta != null) { + meta.addItemFlags(itemFlag); + item.setItemMeta(meta); + } + return this; + } + + /** + * Sets the durability. + */ + public ItemBuilder setDurability(short durability) { + item.setDurability(durability); + return this; + } + + /** + * Sets the skull owner. + */ + public ItemBuilder setSkullOwner(@NonNull String owner) { + if (item.getType() == WorldUtils.getMaterial(com.falchus.lib.minecraft.spigot.enums.Material.PLAYER_HEAD)) { + SkullMeta meta = (SkullMeta) item.getItemMeta(); + if (meta != null) { + meta.setOwner(owner); + item.setItemMeta(meta); + } + } + return this; + } + + /** + * Sets a custom skull texture using a Base64 texture string. + */ + public ItemBuilder setSkullTexture(@NonNull String texture) { + if (item.getType() == WorldUtils.getMaterial(com.falchus.lib.minecraft.spigot.enums.Material.PLAYER_HEAD)) { + SkullMeta meta = (SkullMeta) item.getItemMeta(); + if (meta != null) { + try { + GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null); + gameProfile.getProperties().put("textures", new Property("textures", texture)); + + Field gameProfile_profile = ReflectionUtils.getField(meta.getClass(), "profile"); + gameProfile_profile.set(meta, gameProfile); + + item.setItemMeta(meta); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return this; + } + + /** + * Sets a custom UUID (stored in NBT). + */ + public ItemBuilder setUUID(@NonNull UUID uuid) { + ItemUtils.setUUID(item, uuid); + return this; + } + + /** + * Registers a callback to be executed when a player interacts. + */ + public ItemBuilder withInteractListener(@NonNull Consumer onPlayerInteract) { + UUID uuid = ItemUtils.getUUID(item); + if (uuid == null) { + uuid = UUID.randomUUID(); + item = ItemUtils.setUUID(item, uuid); + } + ItemUtils.itemActions.put(uuid, onPlayerInteract); + return this; + } + + /** + * Registers a callback to be executed when a player clicks in an inventory. + */ + public ItemBuilder withInventoryClickListener(@NonNull TriConsumer onInventoryClick) { + UUID uuid = ItemUtils.getUUID(item); + if (uuid == null) { + uuid = UUID.randomUUID(); + item = ItemUtils.setUUID(item, uuid); + } + ItemUtils.itemActionsInventory.put(uuid, onInventoryClick); + return this; + } + + /** + * Builds and returns the final {@link ItemStack}. + */ + public ItemStack build() { + return item; + } } \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/inventory/InventoryBackup.java b/src/com/falchus/lib/minecraft/spigot/utils/inventory/InventoryBackup.java index 9289ad4d..9f558fce 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/inventory/InventoryBackup.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/inventory/InventoryBackup.java @@ -1,61 +1,53 @@ package com.falchus.lib.minecraft.spigot.utils.inventory; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NonNull; import lombok.experimental.UtilityClass; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; @UtilityClass public class InventoryBackup { private static final Map> playerInventories = new HashMap<>(); - @AllArgsConstructor - @Getter - public static class BackupData { - ItemStack[] inventory; - ItemStack[] armor; - } - /** * Creates or overwrites a backup with the given ID for a player. */ public static void backupInventory(@NonNull Player player, int id) { - Map backups = playerInventories.computeIfAbsent( - player.getUniqueId(), - k -> new HashMap<>() - ); + Map backups = playerInventories.computeIfAbsent( + player.getUniqueId(), + k -> new HashMap<>() + ); ItemStack[] inventory = player.getInventory().getContents().clone(); ItemStack[] armor = player.getInventory().getArmorContents().clone(); backups.put(id, new BackupData(inventory, armor)); } - + /** * Creates a backup using the next available ID. */ public static void backupInventory(@NonNull Player player) { - int id = getNextBackupId(player); - backupInventory(player, id); + int id = getNextBackupId(player); + backupInventory(player, id); } /** * Restores a specific backup by its ID. * The backup is removed after restoration. - * + * * @return true if restored successfully */ public static boolean loadInventory(@NonNull Player player, int id) { - Map backups = playerInventories.get(player.getUniqueId()); - if (backups == null || !backups.containsKey(id)) return false; + Map backups = playerInventories.get(player.getUniqueId()); + if (backups == null || !backups.containsKey(id)) return false; BackupData backup = backups.get(id); player.getInventory().setContents(backup.inventory); @@ -63,14 +55,14 @@ public static boolean loadInventory(@NonNull Player player, int id) { backups.remove(id); if (backups.isEmpty()) { - playerInventories.remove(player.getUniqueId()); + playerInventories.remove(player.getUniqueId()); } return true; } - + /** * Loads the newest (highest ID) backup. - * + * * @return true if loaded successfully */ public static boolean loadInventory(@NonNull Player player) { @@ -88,7 +80,7 @@ public static boolean hasBackup(@NonNull Player player, int id) { Map backups = playerInventories.get(player.getUniqueId()); return backups != null && backups.containsKey(id); } - + /** * Returns true if the player has at least one backup. */ @@ -96,38 +88,45 @@ public static boolean hasBackup(@NonNull Player player) { Map backups = playerInventories.get(player.getUniqueId()); return backups != null && !backups.isEmpty(); } - + /** * Returns all backups for a player. */ public static Map getBackups(@NonNull Player player) { - return playerInventories.getOrDefault(player.getUniqueId(), Map.of()); + return playerInventories.getOrDefault(player.getUniqueId(), Map.of()); } - + /** * Deletes a specific backup. - * + * * @return true if deleted */ public static boolean deleteBackup(@NonNull Player player, int id) { - Map backups = playerInventories.get(player.getUniqueId()); - if (backups != null && backups.remove(id) != null) { - if (backups.isEmpty()) { - playerInventories.remove(player.getUniqueId()); - } - return true; - } - return false; + Map backups = playerInventories.get(player.getUniqueId()); + if (backups != null && backups.remove(id) != null) { + if (backups.isEmpty()) { + playerInventories.remove(player.getUniqueId()); + } + return true; + } + return false; } - + /** * Creates the next available backup ID for a player. */ public static int getNextBackupId(@NonNull Player player) { - Map backups = playerInventories.get(player.getUniqueId()); - if (backups == null || backups.isEmpty()) { - return 1; - } - return backups.keySet().stream().max(Integer::compareTo).orElse(0) + 1; + Map backups = playerInventories.get(player.getUniqueId()); + if (backups == null || backups.isEmpty()) { + return 1; + } + return backups.keySet().stream().max(Integer::compareTo).orElse(0) + 1; + } + + @AllArgsConstructor + @Getter + public static class BackupData { + ItemStack[] inventory; + ItemStack[] armor; } } \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/InventoryAnimation.java b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/InventoryAnimation.java index 5919fb66..be32ddb4 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/InventoryAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/InventoryAnimation.java @@ -1,17 +1,15 @@ package com.falchus.lib.minecraft.spigot.utils.inventory.animation; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - +import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; +import com.falchus.lib.task.Task; +import lombok.Getter; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; -import com.falchus.lib.task.Task; - -import lombok.Getter; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; @Getter public abstract class InventoryAnimation { @@ -19,45 +17,45 @@ public abstract class InventoryAnimation { protected final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); protected int delayTicks = 2; protected List excludedItems = new ArrayList<>(); - - /** - * Called to implement animation logic. - * This will be scheduled automatically after delayTicks. - */ - protected abstract void animate(Player player, Inventory inventory, ItemStack[] items, int tick); - - /** - * Plays the animation with automatic scheduling using delayTicks (in {@link TimeUnit#MILLISECONDS}). - */ - public final void play(Player player, Inventory inventory) { - ItemStack[] items = inventory.getContents(); - for (ItemStack item : items) { - if (!excludedItems.contains(item)) { - inventory.removeItem(item); - } - } - - new Task() { - @Override - public void onRun(int tick) { - if (!player.getOpenInventory().getTopInventory().equals(inventory)) { - end(); - return; - } - - if (tick >= items.length) { - end(); - return; - } - - ItemStack item = items[tick]; - if (excludedItems.contains(item)) { - run(); - return; - } - - animate(player, inventory, items, tick); - } - }.runTaskTimer(delayTicks, TimeUnit.MILLISECONDS); + + /** + * Called to implement animation logic. + * This will be scheduled automatically after delayTicks. + */ + protected abstract void animate(Player player, Inventory inventory, ItemStack[] items, int tick); + + /** + * Plays the animation with automatic scheduling using delayTicks (in {@link TimeUnit#MILLISECONDS}). + */ + public final void play(Player player, Inventory inventory) { + ItemStack[] items = inventory.getContents(); + for (ItemStack item : items) { + if (!excludedItems.contains(item)) { + inventory.removeItem(item); + } + } + + new Task() { + @Override + public void onRun(int tick) { + if (!player.getOpenInventory().getTopInventory().equals(inventory)) { + end(); + return; + } + + if (tick >= items.length) { + end(); + return; + } + + ItemStack item = items[tick]; + if (excludedItems.contains(item)) { + run(); + return; + } + + animate(player, inventory, items, tick); + } + }.runTaskTimer(delayTicks, TimeUnit.MILLISECONDS); } } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/InventoryOpenAnimation.java b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/InventoryOpenAnimation.java index a32c9df0..805780ad 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/InventoryOpenAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/InventoryOpenAnimation.java @@ -3,5 +3,5 @@ import com.falchus.lib.minecraft.spigot.utils.inventory.animation.InventoryAnimation; public abstract class InventoryOpenAnimation extends InventoryAnimation { - + } \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/impl/ItemFillAnimation.java b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/impl/ItemFillAnimation.java index 712cb7bd..7869d6ac 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/impl/ItemFillAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/impl/ItemFillAnimation.java @@ -1,28 +1,27 @@ package com.falchus.lib.minecraft.spigot.utils.inventory.animation.open.impl; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - import com.falchus.lib.minecraft.spigot.enums.Sound; import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; import com.falchus.lib.minecraft.spigot.utils.inventory.animation.open.InventoryOpenAnimation; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; /** * Fills the items in order. */ public class ItemFillAnimation extends InventoryOpenAnimation { - - public ItemFillAnimation(int delayTicks) { - this.delayTicks = delayTicks; - } - - @Override - protected void animate(Player player, Inventory inventory, ItemStack[] items, int tick) { - ItemStack item = items[tick]; - if (item != null) { - inventory.setItem(tick, item); - PlayerUtils.playSound(player, player.getLocation(), Sound.CHICKEN_EGG_POP, 1, 2); - } - } + + public ItemFillAnimation(int delayTicks) { + this.delayTicks = delayTicks; + } + + @Override + protected void animate(Player player, Inventory inventory, ItemStack[] items, int tick) { + ItemStack item = items[tick]; + if (item != null) { + inventory.setItem(tick, item); + PlayerUtils.playSound(player, player.getLocation(), Sound.CHICKEN_EGG_POP, 1, 2); + } + } } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyMod.java b/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyMod.java index dc216e2a..7007e125 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyMod.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyMod.java @@ -1,185 +1,183 @@ package com.falchus.lib.minecraft.spigot.utils.labymod; -import java.util.Collection; -import java.util.UUID; - -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.google.gson.JsonArray; import com.google.gson.JsonObject; - import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NonNull; import lombok.experimental.UtilityClass; +import org.bukkit.entity.Player; + +import java.util.Collection; +import java.util.UUID; @UtilityClass public class LabyMod { - - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - @AllArgsConstructor - @Getter - public enum BalanceType { - CASH("cash"), - BANK("bank"); - - private final String key; - } - - /** - * Just send this packet to update the value of the balance or to show/hide it - */ - public static void updateBalanceDisplay(@NonNull Player player, BalanceType type, boolean visible, int balance) { - JsonObject economyObject = new JsonObject(); - JsonObject cashObject = new JsonObject(); - - // Visibility - cashObject.addProperty("visible", visible); - - // Amount - cashObject.addProperty("balance", balance); + + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + /** + * Just send this packet to update the value of the balance or to show/hide it + */ + public static void updateBalanceDisplay(@NonNull Player player, BalanceType type, boolean visible, int balance) { + JsonObject economyObject = new JsonObject(); + JsonObject cashObject = new JsonObject(); + + // Visibility + cashObject.addProperty("visible", visible); + + // Amount + cashObject.addProperty("balance", balance); /* // Icon (Optional) cashObject.addProperty("icon", ""); - // Decimal number (Optional) + // Decimal number (Optional) JsonObject decimalObject = new JsonObject(); decimalObject.addProperty("format", "##.##"); // Decimal format decimalObject.addProperty("divisor", 100); // The value that divides the balance cashObject.add("decimal", decimalObject); */ - // The display type can be "cash" or "bank". - economyObject.add(type.getKey(), cashObject); - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "economy", economyObject); - } - - public static void setSubtitle(@NonNull Player receiver, UUID subtitlePlayer, String value) { - // List of all subtitles - JsonArray array = new JsonArray(); - - // Add subtitle - JsonObject subtitle = new JsonObject(); - subtitle.addProperty("uuid", subtitlePlayer.toString()); - - // Optional: Size of the subtitle - subtitle.addProperty("size", 0.8d); // Range is 0.8 - 1.6 (1.6 is Minecraft default) - - // no value = remove the subtitle - if (value != null) { - subtitle.addProperty("value", value); - } - - // If you want to use the new text format in 1.16+ - // subtitle.add("raw_json_text", textObject); - - // You can set multiple subtitles in one packet - array.add(subtitle); - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, receiver, "account_subtitle", array); - } - - public static void sendFlag(@NonNull Player receiver, UUID uuid, String countryCode) { - JsonObject flagPacket = new JsonObject(); - - // Create array - JsonArray users = new JsonArray(); - - // Add user to array - JsonObject userObject = new JsonObject(); - userObject.addProperty("uuid", uuid.toString()); // UUID of the flag player - userObject.addProperty("code", countryCode); // The country code (e.g. "us", "de") - users.add(userObject); - - // Add array to flag object packet - flagPacket.add("users", users); - - LabyModProtocol.sendMessage(plugin, receiver, "language_flag", flagPacket); - } - - public enum ActionType { - NONE, - CLIPBOARD, - RUN_COMMAND, - SUGGEST_COMMAND, - OPEN_BROWSER - } - - public static void setMiddleClickActions(@NonNull Player player, Collection entries) { - // List of all action menu entries - JsonArray array = new JsonArray(); - - // Add entries - for (JsonObject entry : entries) { - array.add(entry); - } - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "user_menu_actions", array); - } - - public static void sendCurrentPlayingGamemode(@NonNull Player player, boolean visible, String gamemodeName) { - JsonObject object = new JsonObject(); - object.addProperty("show_gamemode", visible); // Gamemode visible for everyone - object.addProperty("gamemode_name", gamemodeName); // Name of the current playing gamemode - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "server_gamemode", object); - } - - /** - * @param player The input prompt receiver - * @param promptSessionId A unique id for each packet, use a static number and increase it for each prompt request - * @param message The message above the text field - * @param value The value inside of the text field - * @param placeholder A placeholder text inside of the text field if there is no value given - * @param maxLength Max amount of characters of the text field value - */ - public static void sendInputPrompt(@NonNull Player player, int promptSessionId, String message, String value, String placeholder, int maxLength) { - JsonObject object = new JsonObject(); - object.addProperty("id", promptSessionId); - object.addProperty("message", message); - object.addProperty("value", value); - object.addProperty("placeholder", placeholder); - object.addProperty("max_length", maxLength); - - // If you want to use the new text format in 1.16+ - // object.add("raw_json_text", textObject); - - LabyModProtocol.sendMessage(plugin, player, "input_prompt", object); - } - - public static void sendClientToServer(@NonNull Player player, String title, String address, boolean preview) { - JsonObject object = new JsonObject(); - object.addProperty("title", title); // Title of the warning - object.addProperty("address", address); // Destination server address - object.addProperty("preview", preview); // Display the server icon, motd and user count - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "server_switch", object); - } - - /** - * Just send this packet to set the cinescope coverage - * 0% - Disabled - * 50% - Fully blind - */ - public static void sendCineScope(@NonNull Player player, int coveragePercent, long duration) { - JsonObject object = new JsonObject(); - - // Cinescope height (0% - 50%) - object.addProperty("coverage", coveragePercent); - - // Duration - object.addProperty("duration", duration); - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "cinescopes", object); - } + // The display type can be "cash" or "bank". + economyObject.add(type.getKey(), cashObject); + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "economy", economyObject); + } + + public static void setSubtitle(@NonNull Player receiver, UUID subtitlePlayer, String value) { + // List of all subtitles + JsonArray array = new JsonArray(); + + // Add subtitle + JsonObject subtitle = new JsonObject(); + subtitle.addProperty("uuid", subtitlePlayer.toString()); + + // Optional: Size of the subtitle + subtitle.addProperty("size", 0.8d); // Range is 0.8 - 1.6 (1.6 is Minecraft default) + + // no value = remove the subtitle + if (value != null) { + subtitle.addProperty("value", value); + } + + // If you want to use the new text format in 1.16+ + // subtitle.add("raw_json_text", textObject); + + // You can set multiple subtitles in one packet + array.add(subtitle); + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, receiver, "account_subtitle", array); + } + + public static void sendFlag(@NonNull Player receiver, UUID uuid, String countryCode) { + JsonObject flagPacket = new JsonObject(); + + // Create array + JsonArray users = new JsonArray(); + + // Add user to array + JsonObject userObject = new JsonObject(); + userObject.addProperty("uuid", uuid.toString()); // UUID of the flag player + userObject.addProperty("code", countryCode); // The country code (e.g. "us", "de") + users.add(userObject); + + // Add array to flag object packet + flagPacket.add("users", users); + + LabyModProtocol.sendMessage(plugin, receiver, "language_flag", flagPacket); + } + + public static void setMiddleClickActions(@NonNull Player player, Collection entries) { + // List of all action menu entries + JsonArray array = new JsonArray(); + + // Add entries + for (JsonObject entry : entries) { + array.add(entry); + } + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "user_menu_actions", array); + } + + public static void sendCurrentPlayingGamemode(@NonNull Player player, boolean visible, String gamemodeName) { + JsonObject object = new JsonObject(); + object.addProperty("show_gamemode", visible); // Gamemode visible for everyone + object.addProperty("gamemode_name", gamemodeName); // Name of the current playing gamemode + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "server_gamemode", object); + } + + /** + * @param player The input prompt receiver + * @param promptSessionId A unique id for each packet, use a static number and increase it for each prompt request + * @param message The message above the text field + * @param value The value inside of the text field + * @param placeholder A placeholder text inside of the text field if there is no value given + * @param maxLength Max amount of characters of the text field value + */ + public static void sendInputPrompt(@NonNull Player player, int promptSessionId, String message, String value, String placeholder, int maxLength) { + JsonObject object = new JsonObject(); + object.addProperty("id", promptSessionId); + object.addProperty("message", message); + object.addProperty("value", value); + object.addProperty("placeholder", placeholder); + object.addProperty("max_length", maxLength); + + // If you want to use the new text format in 1.16+ + // object.add("raw_json_text", textObject); + + LabyModProtocol.sendMessage(plugin, player, "input_prompt", object); + } + + public static void sendClientToServer(@NonNull Player player, String title, String address, boolean preview) { + JsonObject object = new JsonObject(); + object.addProperty("title", title); // Title of the warning + object.addProperty("address", address); // Destination server address + object.addProperty("preview", preview); // Display the server icon, motd and user count + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "server_switch", object); + } + + /** + * Just send this packet to set the cinescope coverage + * 0% - Disabled + * 50% - Fully blind + */ + public static void sendCineScope(@NonNull Player player, int coveragePercent, long duration) { + JsonObject object = new JsonObject(); + + // Cinescope height (0% - 50%) + object.addProperty("coverage", coveragePercent); + + // Duration + object.addProperty("duration", duration); + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "cinescopes", object); + } + + @AllArgsConstructor + @Getter + public enum BalanceType { + CASH("cash"), + BANK("bank"); + + private final String key; + } + + public enum ActionType { + NONE, + CLIPBOARD, + RUN_COMMAND, + SUGGEST_COMMAND, + OPEN_BROWSER + } } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyModProtocol.java b/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyModProtocol.java index 18ecf5a5..12e401be 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyModProtocol.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyModProtocol.java @@ -1,34 +1,33 @@ package com.falchus.lib.minecraft.spigot.utils.labymod; -import java.nio.charset.Charset; - -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - import com.google.gson.JsonElement; - import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.EncoderException; import lombok.NonNull; import lombok.experimental.UtilityClass; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import java.nio.charset.Charset; @UtilityClass public class LabyModProtocol { - + /** * Send a message to LabyMod - * @param player Minecraft Client - * @param key LabyMod message key + * + * @param player Minecraft Client + * @param key LabyMod message key * @param messageContent json object content */ - public static void sendMessage(@NonNull Plugin plugin, @NonNull Player player, String key, JsonElement messageContent) { - byte[] data = LabyModProtocol.getBytesToSend(key, messageContent.toString()); - - player.sendPluginMessage(plugin, "labymod3:main", data); - } - + public static void sendMessage(@NonNull Plugin plugin, @NonNull Player player, String key, JsonElement messageContent) { + byte[] data = LabyModProtocol.getBytesToSend(key, messageContent.toString()); + + player.sendPluginMessage(plugin, "labymod3:main", data); + } + /** * Gets the bytes that are required to send the given message * @@ -36,79 +35,79 @@ public static void sendMessage(@NonNull Plugin plugin, @NonNull Player player, S * @param messageContents the message's contents * @return the byte array that should be the payload */ - public static byte[] getBytesToSend(String messageKey, String messageContents) { + public static byte[] getBytesToSend(String messageKey, String messageContents) { // Getting an empty buffer - ByteBuf byteBuf = Unpooled.buffer(); - + ByteBuf byteBuf = Unpooled.buffer(); + // Writing the message-key to the buffer - writeString(byteBuf, messageKey); - + writeString(byteBuf, messageKey); + // Writing the contents to the buffer - writeString(byteBuf, messageContents); - - // Copying the buffer's bytes to the byte array - byte[] bytes = new byte[byteBuf.readableBytes()]; - byteBuf.readBytes(bytes); - - // Release the buffer - byteBuf.release(); - - // Returning the byte array - return bytes; - } - + writeString(byteBuf, messageContents); + + // Copying the buffer's bytes to the byte array + byte[] bytes = new byte[byteBuf.readableBytes()]; + byteBuf.readBytes(bytes); + + // Release the buffer + byteBuf.release(); + + // Returning the byte array + return bytes; + } + /** * Writes a varint to the given byte buffer * * @param buf the byte buffer the int should be written to * @param input the int that should be written to the buffer */ - private static void writeVarIntToBuffer(ByteBuf buf, int input) { - while ((input & -128) != 0) { - buf.writeByte(input & 127 | 128); - input >>>= 7; - } - buf.writeByte(input); - } - + private static void writeVarIntToBuffer(ByteBuf buf, int input) { + while ((input & -128) != 0) { + buf.writeByte(input & 127 | 128); + input >>>= 7; + } + buf.writeByte(input); + } + /** * Writes a string to the given byte buffer * * @param buf the byte buffer the string should be written to * @param string the string that should be written to the buffer */ - private static void writeString(ByteBuf buf, String string) { - byte[] abyte = string.getBytes(Charset.forName("UTF-8")); - - if (abyte.length > Short.MAX_VALUE) { - throw new EncoderException("String too big (was " + string.length() + " bytes encoded, max " + Short.MAX_VALUE + ")"); - } else { - writeVarIntToBuffer(buf, abyte.length); - buf.writeBytes(abyte); - } - } - + private static void writeString(ByteBuf buf, String string) { + byte[] abyte = string.getBytes(Charset.forName("UTF-8")); + + if (abyte.length > Short.MAX_VALUE) { + throw new EncoderException("String too big (was " + string.length() + " bytes encoded, max " + Short.MAX_VALUE + ")"); + } else { + writeVarIntToBuffer(buf, abyte.length); + buf.writeBytes(abyte); + } + } + /** * Reads a varint from the given byte buffer * * @param buf the byte buffer the varint should be read from * @return the int read */ - public static int readVarIntFromBuffer(ByteBuf buf) { - int i = 0; - int j = 0; - - byte b0; - do { - b0 = buf.readByte(); - i |= (b0 & 127) << j++ * 7; - if (j > 5) { - throw new RuntimeException("VarInt too big"); - } - } while ((b0 & 128) == 128); - return i; - } - + public static int readVarIntFromBuffer(ByteBuf buf) { + int i = 0; + int j = 0; + + byte b0; + do { + b0 = buf.readByte(); + i |= (b0 & 127) << j++ * 7; + if (j > 5) { + throw new RuntimeException("VarInt too big"); + } + } while ((b0 & 128) == 128); + return i; + } + /** * Reads a string from the given byte buffer * @@ -116,23 +115,23 @@ public static int readVarIntFromBuffer(ByteBuf buf) { * @param maxLength the string's max-length * @return the string read */ - public static String readString(ByteBuf buf, int maxLength) { - int i = readVarIntFromBuffer(buf); - - if (i > maxLength * 4) { + public static String readString(ByteBuf buf, int maxLength) { + int i = readVarIntFromBuffer(buf); + + if (i > maxLength * 4) { throw new DecoderException("The received encoded string buffer length is longer than maximum allowed (" + i + " > " + maxLength * 4 + ")"); - } else if (i < 0) { - throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!"); - } else { - byte[] bytes = new byte[i]; - buf.readBytes(bytes); - - String s = new String(bytes, Charset.forName("UTF-8")); + } else if (i < 0) { + throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!"); + } else { + byte[] bytes = new byte[i]; + buf.readBytes(bytes); + + String s = new String(bytes, Charset.forName("UTF-8")); if (s.length() > maxLength) { throw new DecoderException("The received string length is longer than maximum allowed (" + i + " > " + maxLength + ")"); } else { return s; } - } - } + } + } } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonObjectUtil.java b/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonObjectUtil.java index 515247e3..3e4c7b79 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonObjectUtil.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonObjectUtil.java @@ -1,68 +1,66 @@ package com.falchus.lib.minecraft.spigot.utils.lunar; -import java.awt.Color; +import com.google.gson.JsonObject; +import lombok.NonNull; +import lombok.experimental.UtilityClass; +import org.bukkit.entity.Entity; + +import java.awt.*; import java.time.Duration; import java.util.Map; import java.util.UUID; -import org.bukkit.entity.Entity; +@UtilityClass +public class LunarJsonObjectUtil { -import com.google.gson.JsonObject; + public static JsonObject createEnableModuleObjectWithType(@NonNull String module, Map properties) { + JsonObject enableModuleObject = LunarJsonPacketUtil.createEnableModuleObject(module, properties); + enableModuleObject.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.ConfigurableSettings"); + return enableModuleObject; + } -import lombok.NonNull; -import lombok.experimental.UtilityClass; + public static JsonObject createUuidObject(@NonNull UUID uuid) { + JsonObject uuidObject = new JsonObject(); + uuidObject.addProperty("high64", Long.toUnsignedString(uuid.getMostSignificantBits())); + uuidObject.addProperty("low64", Long.toUnsignedString(uuid.getLeastSignificantBits())); + return uuidObject; + } -@UtilityClass -public class LunarJsonObjectUtil { + public static JsonObject createColorObject(@NonNull Color color) { + JsonObject colorObject = new JsonObject(); + colorObject.addProperty("color", color.getRGB()); + return colorObject; + } + + public static String createDurationObject(@NonNull Duration duration) { + long seconds = duration.getSeconds(); + int nanos = duration.getNano(); + + String durationString; + if (nanos == 0) { + durationString = seconds + "s"; + } else { + durationString = String.format("%d.%09ds", seconds, nanos) + .replaceAll("0+$", "") + .replaceAll("\\.$", ""); + } + + return durationString; + } + + public static JsonObject createCuboid2DObject(double minX, double minZ, double maxX, double maxZ) { + JsonObject cuboid2DObject = new JsonObject(); + cuboid2DObject.addProperty("min_x", minX); + cuboid2DObject.addProperty("min_z", minZ); + cuboid2DObject.addProperty("max_x", maxX); + cuboid2DObject.addProperty("max_z", maxZ); + return cuboid2DObject; + } - public static JsonObject createEnableModuleObjectWithType(@NonNull String module, Map properties) { - JsonObject enableModuleObject = LunarJsonPacketUtil.createEnableModuleObject(module, properties); - enableModuleObject.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.ConfigurableSettings"); - return enableModuleObject; - } - - public static JsonObject createUuidObject(@NonNull UUID uuid) { - JsonObject uuidObject = new JsonObject(); - uuidObject.addProperty("high64", Long.toUnsignedString(uuid.getMostSignificantBits())); - uuidObject.addProperty("low64", Long.toUnsignedString(uuid.getLeastSignificantBits())); - return uuidObject; - } - - public static JsonObject createColorObject(@NonNull Color color) { - JsonObject colorObject = new JsonObject(); - colorObject.addProperty("color", color.getRGB()); - return colorObject; - } - - public static String createDurationObject(@NonNull Duration duration) { - long seconds = duration.getSeconds(); - int nanos = duration.getNano(); - - String durationString; - if (nanos == 0) { - durationString = seconds + "s"; - } else { - durationString = String.format("%d.%09ds", seconds, nanos) - .replaceAll("0+$", "") - .replaceAll("\\.$", ""); - } - - return durationString; - } - - public static JsonObject createCuboid2DObject(double minX, double minZ, double maxX, double maxZ) { - JsonObject cuboid2DObject = new JsonObject(); - cuboid2DObject.addProperty("min_x", minX); - cuboid2DObject.addProperty("min_z", minZ); - cuboid2DObject.addProperty("max_x", maxX); - cuboid2DObject.addProperty("max_z", maxZ); - return cuboid2DObject; - } - - public static JsonObject createEntityIdObject(@NonNull Entity entity) { - JsonObject entityIdObject = new JsonObject(); - entityIdObject.addProperty("entity_id", entity.getEntityId()); - entityIdObject.add("entity_uuid", createUuidObject(entity.getUniqueId())); - return entityIdObject; - } + public static JsonObject createEntityIdObject(@NonNull Entity entity) { + JsonObject entityIdObject = new JsonObject(); + entityIdObject.addProperty("entity_id", entity.getEntityId()); + entityIdObject.add("entity_uuid", createUuidObject(entity.getUniqueId())); + return entityIdObject; + } } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonPacketUtil.java b/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonPacketUtil.java index 47df4590..42c0cc6e 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonPacketUtil.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonPacketUtil.java @@ -1,83 +1,77 @@ package com.falchus.lib.minecraft.spigot.utils.lunar; -import java.util.List; -import java.util.Map; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.google.common.collect.Table; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonNull; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; - +import com.google.gson.*; import lombok.NonNull; import lombok.experimental.UtilityClass; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.Map; @UtilityClass public class LunarJsonPacketUtil { - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - public static void sendPacket(Player player, JsonObject message) { - player.sendPluginMessage(plugin, "apollo:json", message.toString().getBytes()); - } - - public static void broadcastPacket(JsonObject message) { - byte[] data = message.toString().getBytes(); - - Bukkit.getOnlinePlayers().forEach(player -> player.sendPluginMessage(plugin, "apollo:json", data)); - } - - public static JsonObject createEnableModuleObject(@NonNull String module, Map properties) { - JsonObject enableModuleObject = new JsonObject(); - enableModuleObject.addProperty("apollo_module", module); - enableModuleObject.addProperty("enable", true); - - if (properties != null) { - JsonObject propertiesObject = new JsonObject(); - for (Map.Entry entry : properties.entrySet()) { - propertiesObject.add(entry.getKey(), convertToJsonElement(entry.getValue())); - } - - enableModuleObject.add("properties", propertiesObject); - } - - return enableModuleObject; - } - - private static JsonElement convertToJsonElement(Object value) { - if (value == null) { - return JsonNull.INSTANCE; - } else if (value instanceof String valueString) { - return new JsonPrimitive(valueString); - } else if (value instanceof Number valueNumber) { - return new JsonPrimitive(valueNumber); - } else if (value instanceof Boolean valueBoolean) { - return new JsonPrimitive(valueBoolean); - } else if (value instanceof List valueList) { - JsonArray jsonArray = new JsonArray(); - for (Object item : valueList) { - jsonArray.add(convertToJsonElement(item)); - } - return jsonArray; - } - - throw new RuntimeException("Unable to wrap value of type '" + value.getClass().getSimpleName() + "'!"); - } - - public static void enableModules(Player player, List modules, Table moduleProperties) { - JsonArray settings = modules.stream() - .map(module -> createEnableModuleObject(module, moduleProperties.row(module))) - .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); - - JsonObject message = new JsonObject(); - message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage"); - message.add("configurable_settings", settings); - - sendPacket(player, message); - } + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + public static void sendPacket(Player player, JsonObject message) { + player.sendPluginMessage(plugin, "apollo:json", message.toString().getBytes()); + } + + public static void broadcastPacket(JsonObject message) { + byte[] data = message.toString().getBytes(); + + Bukkit.getOnlinePlayers().forEach(player -> player.sendPluginMessage(plugin, "apollo:json", data)); + } + + public static JsonObject createEnableModuleObject(@NonNull String module, Map properties) { + JsonObject enableModuleObject = new JsonObject(); + enableModuleObject.addProperty("apollo_module", module); + enableModuleObject.addProperty("enable", true); + + if (properties != null) { + JsonObject propertiesObject = new JsonObject(); + for (Map.Entry entry : properties.entrySet()) { + propertiesObject.add(entry.getKey(), convertToJsonElement(entry.getValue())); + } + + enableModuleObject.add("properties", propertiesObject); + } + + return enableModuleObject; + } + + private static JsonElement convertToJsonElement(Object value) { + if (value == null) { + return JsonNull.INSTANCE; + } else if (value instanceof String valueString) { + return new JsonPrimitive(valueString); + } else if (value instanceof Number valueNumber) { + return new JsonPrimitive(valueNumber); + } else if (value instanceof Boolean valueBoolean) { + return new JsonPrimitive(valueBoolean); + } else if (value instanceof List valueList) { + JsonArray jsonArray = new JsonArray(); + for (Object item : valueList) { + jsonArray.add(convertToJsonElement(item)); + } + return jsonArray; + } + + throw new RuntimeException("Unable to wrap value of type '" + value.getClass().getSimpleName() + "'!"); + } + + public static void enableModules(Player player, List modules, Table moduleProperties) { + JsonArray settings = modules.stream() + .map(module -> createEnableModuleObject(module, moduleProperties.row(module))) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage"); + message.add("configurable_settings", settings); + + sendPacket(player, message); + } } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/IVersionAdapter.java b/src/com/falchus/lib/minecraft/spigot/utils/version/IVersionAdapter.java index 4223bb6c..2d9dc967 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/IVersionAdapter.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/IVersionAdapter.java @@ -1,10 +1,8 @@ package com.falchus.lib.minecraft.spigot.utils.version; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; -import java.util.UUID; - +import com.falchus.lib.minecraft.spigot.enums.Sound; +import com.mojang.authlib.GameProfile; +import lombok.NonNull; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; @@ -13,204 +11,217 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import com.falchus.lib.minecraft.spigot.enums.Sound; -import com.mojang.authlib.GameProfile; - -import lombok.NonNull; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.UUID; public interface IVersionAdapter { - String getPackageOb(); - String getPackageObc(); - String getPackageNm(); - String getPackageNms(); - - Class getBlockPosition(); - Class getEntityPlayer(); - Field getEntityPlayer_playerConnection(); - Field getPlayerConnection_networkManager(); - Field getNetworkManager_channel(); - Class getPlayerInteractManager(); - Method getEntity_setLocation(); - Method getEntity_setInvisible(); - Class getWorld(); - Class getMinecraftServer(); - Class getWorldServer(); - - Object createChatComponentText(@NonNull String text); - - /** - * @return {@link Entity} - */ - Entity getBukkitEntity(@NonNull Object entity); - - /** - * Sets yaw and pitch. - */ - void setYawPitch(@NonNull Object entity, float yaw, float pitch); - + String getPackageOb(); + + String getPackageObc(); + + String getPackageNm(); + + String getPackageNms(); + + Class getBlockPosition(); + + Class getEntityPlayer(); + + Field getEntityPlayer_playerConnection(); + + Field getPlayerConnection_networkManager(); + + Field getNetworkManager_channel(); + + Class getPlayerInteractManager(); + + Method getEntity_setLocation(); + + Method getEntity_setInvisible(); + + Class getWorld(); + + Class getMinecraftServer(); + + Class getWorldServer(); + + Object createChatComponentText(@NonNull String text); + + /** + * @return {@link Entity} + */ + Entity getBukkitEntity(@NonNull Object entity); + + /** + * Sets yaw and pitch. + */ + void setYawPitch(@NonNull Object entity, float yaw, float pitch); + /** * Sets a UUID on the given item via NBT. */ - ItemStack setUUID(@NonNull ItemStack item, UUID uuid); - + ItemStack setUUID(@NonNull ItemStack item, UUID uuid); + /** * Retrieves the UUID stores on the given item. */ - UUID getUUID(@NonNull ItemStack item); - + UUID getUUID(@NonNull ItemStack item); + /** * Removes all NBT tags from the item. */ - ItemStack clearNBT(@NonNull ItemStack item); - - /** - * Sends a raw NMS packet to a player. - */ - void sendPacket(@NonNull Player player, @NonNull Object packet); - - /** - * Sends a title and/or subtitle to a player. - */ - void sendTitle(@NonNull Player player, String title, String subtitle); - - /** - * Sends a tablist to a player. - */ - void sendTablist(@NonNull Player player, List header, List footer, String name); - - /** - * Sends a bossbar to a player. - */ - void sendBossbar(@NonNull Player player, @NonNull String title, double progress); - - /** - * Removes a bossbar from a player. - */ - void removeBossbar(@NonNull Player player); - - /** - * Sends a actionbar to a player. - */ - void sendActionbar(@NonNull Player player, @NonNull String message); - - /** - * Sends a nametag for a player. - */ - void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix); - - /** - * Removes a nametag from a player. - */ - void removeNametag(@NonNull Player player); - - /** - * Plays a sound to a player. - */ - void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch); - - /** - * @return CraftPlayer from Player - */ - Object getCraftPlayer(@NonNull Player player); - - /** - * @return EntityPlayer from Player - */ - Object getEntityPlayer(@NonNull Player player); - - /** - * @return Player.Spigot from Player - */ - Object getPlayerSpigot(@NonNull Player player); - - /** - * @return {@link GameProfile} from EntityPlayer - */ - GameProfile getProfile(@NonNull Object entityPlayer); - - /** - * @return ping from a player. - */ - int getPing(@NonNull Player player); - - /** - * Sets a custom skin. - */ - void setSkin(@NonNull Player player, @NonNull UUID uuid); - - /** - * Resets the skin back to the original. - */ - void resetSkin(@NonNull Player player); - - /** - * Sets a custom name. - */ - void setName(@NonNull Player player, @NonNull String name); - - /** - * Resets the name back to the original. - */ - void resetName(@NonNull Player player); - - /** - * Forces clients to reload the player's GameProfile. - */ - void refresh(@NonNull Player player); - - /** - * Adds a EntityPlayer. - */ - void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); - - /** - * Removes a EntityPlayer. - */ - void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); - - /** - * Spawns a EntityPlayer. - */ - void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); - - /** - * @return MinecraftServer - */ - Object getMcServer(); - - /** - * @return {@link Server} - */ - Object getBukkitServer(); - - /** - * @return e.g. "1.8.8" - */ - String getVersion(); - - /** - * @return recent TPS - */ - double[] getRecentTps(); - - /** - * @return BiomeBase[] from a World - */ - Object[] getWorldBiomes(@NonNull World world); - - /** - * @return BiomeBase from a Biome - */ - Object getNmsBiome(Biome biome); - - /** - * @return id from a Biome - */ - int getBiomeId(Biome biome); - - /** - * @return WorldServer from a World - */ - Object getWorldServer(World world); + ItemStack clearNBT(@NonNull ItemStack item); + + /** + * Sends a raw NMS packet to a player. + */ + void sendPacket(@NonNull Player player, @NonNull Object packet); + + /** + * Sends a title and/or subtitle to a player. + */ + void sendTitle(@NonNull Player player, String title, String subtitle); + + /** + * Sends a tablist to a player. + */ + void sendTablist(@NonNull Player player, List header, List footer, String name); + + /** + * Sends a bossbar to a player. + */ + void sendBossbar(@NonNull Player player, @NonNull String title, double progress); + + /** + * Removes a bossbar from a player. + */ + void removeBossbar(@NonNull Player player); + + /** + * Sends a actionbar to a player. + */ + void sendActionbar(@NonNull Player player, @NonNull String message); + + /** + * Sends a nametag for a player. + */ + void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix); + + /** + * Removes a nametag from a player. + */ + void removeNametag(@NonNull Player player); + + /** + * Plays a sound to a player. + */ + void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch); + + /** + * @return CraftPlayer from Player + */ + Object getCraftPlayer(@NonNull Player player); + + /** + * @return EntityPlayer from Player + */ + Object getEntityPlayer(@NonNull Player player); + + /** + * @return Player.Spigot from Player + */ + Object getPlayerSpigot(@NonNull Player player); + + /** + * @return {@link GameProfile} from EntityPlayer + */ + GameProfile getProfile(@NonNull Object entityPlayer); + + /** + * @return ping from a player. + */ + int getPing(@NonNull Player player); + + /** + * Sets a custom skin. + */ + void setSkin(@NonNull Player player, @NonNull UUID uuid); + + /** + * Resets the skin back to the original. + */ + void resetSkin(@NonNull Player player); + + /** + * Sets a custom name. + */ + void setName(@NonNull Player player, @NonNull String name); + + /** + * Resets the name back to the original. + */ + void resetName(@NonNull Player player); + + /** + * Forces clients to reload the player's GameProfile. + */ + void refresh(@NonNull Player player); + + /** + * Adds a EntityPlayer. + */ + void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); + + /** + * Removes a EntityPlayer. + */ + void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); + + /** + * Spawns a EntityPlayer. + */ + void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); + + /** + * @return MinecraftServer + */ + Object getMcServer(); + + /** + * @return {@link Server} + */ + Object getBukkitServer(); + + /** + * @return e.g. "1.8.8" + */ + String getVersion(); + + /** + * @return recent TPS + */ + double[] getRecentTps(); + + /** + * @return BiomeBase[] from a World + */ + Object[] getWorldBiomes(@NonNull World world); + + /** + * @return BiomeBase from a Biome + */ + Object getNmsBiome(Biome biome); + + /** + * @return id from a Biome + */ + int getBiomeId(Biome biome); + + /** + * @return WorldServer from a World + */ + Object getWorldServer(World world); } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapter.java b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapter.java index 5e2366ca..a64b9e95 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapter.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapter.java @@ -1,22 +1,5 @@ package com.falchus.lib.minecraft.spigot.utils.version; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.falchus.lib.minecraft.spigot.enums.Sound; import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; @@ -25,59 +8,84 @@ import com.falchus.lib.utils.reflection.ReflectionUtils; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; - import lombok.AccessLevel; import lombok.Getter; import lombok.NonNull; import lombok.SneakyThrows; import lombok.experimental.FieldDefaults; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.*; /** * Adapter for all versions. (tested with 1.8.8) */ @FieldDefaults(level = AccessLevel.PROTECTED) public class VersionAdapter implements IVersionAdapter { - - final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - final Map bossBars = new HashMap<>(); - - @Getter String packageOb = "org.bukkit."; - @Getter String packageObc = packageOb + "craftbukkit."; - @Getter String packageNm = "net.minecraft."; - @Getter String packageNms = packageNm + "server."; - - @Getter Class blockPosition; - @Getter Class entityPlayer; - @Getter Field entityPlayer_playerConnection; + + final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + final Map bossBars = new HashMap<>(); + + @Getter + String packageOb = "org.bukkit."; + @Getter + String packageObc = packageOb + "craftbukkit."; + @Getter + String packageNm = "net.minecraft."; + @Getter + String packageNms = packageNm + "server."; + + @Getter + Class blockPosition; + @Getter + Class entityPlayer; + @Getter + Field entityPlayer_playerConnection; Class playerConnection; - @Getter Field playerConnection_networkManager; + @Getter + Field playerConnection_networkManager; Class networkManager; - @Getter Field networkManager_channel; - @Getter Class playerInteractManager; + @Getter + Field networkManager_channel; + @Getter + Class playerInteractManager; Class entity; - @Getter Method entity_setLocation; - @Getter Method entity_setInvisible; - @Getter Class world; - @Getter Class minecraftServer; - @Getter Class worldServer; - - Class chatComponentText; - + @Getter + Method entity_setLocation; + @Getter + Method entity_setInvisible; + @Getter + Class world; + @Getter + Class minecraftServer; + @Getter + Class worldServer; + + protected Class chatComponentText; + Method entity_getBukkitEntity; Method entity_setYawPitch; - - Class craftItemStack; - Class nmsItemStack; - Class nbtTagCompound; - Method craftItemStack_asNMSCopy; - Method craftItemStack_asBukkitCopy; - Method nbtTagCompound_setString; - Method nbtTagCompound_remove; - Method nbtTagCompound_hasKey; - Method nbtTagCompound_getString; - - Class packet; + + Class craftItemStack; + Class nmsItemStack; + Class nbtTagCompound; + Method craftItemStack_asNMSCopy; + Method craftItemStack_asBukkitCopy; + Method nbtTagCompound_setString; + Method nbtTagCompound_remove; + Method nbtTagCompound_hasKey; + Method nbtTagCompound_getString; + + Class packet; Method playerConnection_sendPacket; Class iChatBaseComponent; Class scoreboardTeam; @@ -94,249 +102,164 @@ public class VersionAdapter implements IVersionAdapter { Class packetPlayOutPlayerInfo$enumPlayerInfoAction; Object packetPlayOutPlayerInfo$enumPlayerInfoAction_UPDATE_DISPLAY_NAME; Object packetPlayOutPlayerInfo$enumPlayerInfoAction_ADD_PLAYER; - + Class craftServer; Method craftServer_getServer; Class bukkitServer; Method minecraftServer_getVersion; Field minecraftServer_recentTps; - + Class biomeBase; Field biomeBase_biomes; Method biomeBase_getBiome; - - private Method nmsItemStack_getTag() { - return ReflectionUtils.getMethod(nmsItemStack, "getTag"); - } - private Method nmsItemStack_setTag() { - return ReflectionUtils.getMethod(nmsItemStack, "setTag", - nbtTagCompound - ); - } - private Method nmsItemStack_hasTag() { - return ReflectionUtils.getMethod(nmsItemStack, "hasTag"); - } - - @SneakyThrows - private Object packetPlayOutPlayerInfo$enumPlayerInfoAction_REMOVE_PLAYER() { - return ReflectionUtils.getField(packetPlayOutPlayerInfo$enumPlayerInfoAction, "REMOVE_PLAYER").get(null); - } - private Class packetPlayOutTitle$enumTitleAction() { - return ReflectionUtils.getClass(packageNms + "PacketPlayOutTitle$EnumTitleAction"); - } - @SneakyThrows - private Object packetPlayOutTitle$enumTitleAction_TITLE() { - return ReflectionUtils.getField(packetPlayOutTitle$enumTitleAction(), "TITLE").get(null); - } - @SneakyThrows - private Object packetPlayOutTitle$enumTitleAction_SUBTITLE() { - return ReflectionUtils.getField(packetPlayOutTitle$enumTitleAction(), "SUBTITLE").get(null); - } - private Class craftWorld() { - return ReflectionUtils.getClass(packageObc + "CraftWorld"); - } - private Method craftWorld_getHandle() { - return ReflectionUtils.getMethod(craftWorld(), "getHandle"); - } - private Method entity_setCustomName() { - return ReflectionUtils.getMethod(entity, "setCustomName", - String.class - ); - } - private Method entity_setCustomNameVisible() { - return ReflectionUtils.getMethod(entity, "setCustomNameVisible", - boolean.class - ); - } - private Method entity_getId() { - return ReflectionUtils.getMethod(entity, "getId"); - } - private Class dataWatcher() { - return ReflectionUtils.getClass(packageNms + "DataWatcher"); - } - private Method entity_getDataWatcher() { - return ReflectionUtils.getMethod(entity, "getDataWatcher"); - } - private Class entityLiving() { - return ReflectionUtils.getClass(packageNms + "EntityLiving"); - } - private Method entityLiving_setHealth() { - return ReflectionUtils.getMethod(entityLiving(), "setHealth", - float.class - ); - } - private Method entityLiving_getMaxHealth() { - return ReflectionUtils.getMethod(entityLiving(), "getMaxHealth"); - } - private Class entityWither() { - return ReflectionUtils.getClass(packageNms + "EntityWither"); - } - private Field packetPlayOutScoreboardTeam_name() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "a"); - } - private Field packetPlayOutScoreboardTeam_displayName() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "b"); - } - private Field packetPlayOutScoreboardTeam_prefix() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "c"); - } - private Field packetPlayOutScoreboardTeam_suffix() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "d"); - } - private Field packetPlayOutScoreboardTeam_players() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "g"); - } - private Field packetPlayOutScoreboardTeam_mode() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "h"); - } - - public VersionAdapter() { - try { - String version; + + public VersionAdapter() { + try { + String version; String packageName = Bukkit.getServer().getClass().getPackageName(); String[] parts = packageName.split("\\."); version = parts.length >= 4 ? parts[3] : "Unknown"; - - packageObc = packageObc + (!version.equals("Unknown") ? version + "." : ""); - packageNms = packageNms + (!version.equals("Unknown") ? version + "." : ""); - + + packageObc = packageObc + (!version.equals("Unknown") ? version + "." : ""); + packageNms = packageNms + (!version.equals("Unknown") ? version + "." : ""); + blockPosition = ReflectionUtils.getFirstClass( - packageNms + "BlockPosition", - packageNm + "core.BlockPosition" + packageNms + "BlockPosition", + packageNm + "core.BlockPosition" ); entityPlayer = ReflectionUtils.getFirstClass( - packageNms + "EntityPlayer", - packageNms + "level.EntityPlayer" + packageNms + "EntityPlayer", + packageNms + "level.EntityPlayer" ); entityPlayer_playerConnection = ReflectionUtils.getFirstField(entityPlayer, - "playerConnection", - "connection" + "playerConnection", + "connection" ); playerConnection = ReflectionUtils.getFirstClass( - packageNms + "PlayerConnection", - packageNms + "network.PlayerConnection" + packageNms + "PlayerConnection", + packageNms + "network.PlayerConnection" ); playerConnection_networkManager = ReflectionUtils.getFirstField(playerConnection, - "networkManager" + "networkManager" ); networkManager = ReflectionUtils.getFirstClass( - packageNms + "NetworkManager", - packageNm + "network.NetworkManager" + packageNms + "NetworkManager", + packageNm + "network.NetworkManager" ); networkManager_channel = ReflectionUtils.getField(networkManager, "channel"); playerInteractManager = ReflectionUtils.getFirstClass( - packageNms + "PlayerInteractManager", - packageNms + "level.PlayerInteractManager" + packageNms + "PlayerInteractManager", + packageNms + "level.PlayerInteractManager" ); entity = ReflectionUtils.getFirstClass( - packageNms + "Entity", - packageNm + "world.entity.Entity" + packageNms + "Entity", + packageNm + "world.entity.Entity" ); entity_setLocation = ReflectionUtils.getFirstMethod(entity, - List.of( - double.class, - double.class, - double.class, - float.class, - float.class - ), - "setLocation", - "a" + List.of( + double.class, + double.class, + double.class, + float.class, + float.class + ), + "setLocation", + "a" ); entity_setInvisible = ReflectionUtils.getMethod(entity, "setInvisible", - boolean.class + boolean.class ); world = ReflectionUtils.getFirstClass( - packageNms + "World", - packageNm + "world.level.World" + packageNms + "World", + packageNm + "world.level.World" ); minecraftServer = ReflectionUtils.getClass(packageNms + "MinecraftServer"); - worldServer = ReflectionUtils.getFirstClass( - packageNms + "WorldServer", - packageNms + "level.WorldServer" - ); - + worldServer = ReflectionUtils.getFirstClass( + packageNms + "WorldServer", + packageNms + "level.WorldServer" + ); + chatComponentText = ReflectionUtils.getFirstClass( - packageNms + "ChatComponentText", - packageNm + "network.chat.ChatComponentText" + packageNms + "ChatComponentText", + packageNm + "network.chat.ChatComponentText" ); - + entity_getBukkitEntity = ReflectionUtils.getMethod(entity, "getBukkitEntity"); entity_setYawPitch = ReflectionUtils.getFirstMethod(entity, - List.of( - float.class, - float.class - ), - "setYawPitch", - "setRot" + List.of( + float.class, + float.class + ), + "setYawPitch", + "setRot" ); - + craftItemStack = ReflectionUtils.getClass(packageObc + "inventory.CraftItemStack"); nmsItemStack = ReflectionUtils.getFirstClass( - packageNms + "ItemStack", - packageNm + "world.item.ItemStack" + packageNms + "ItemStack", + packageNm + "world.item.ItemStack" ); nbtTagCompound = ReflectionUtils.getFirstClass( - packageNms + "NBTTagCompound", - packageNm + "nbt.NBTTagCompound" + packageNms + "NBTTagCompound", + packageNm + "nbt.NBTTagCompound" ); craftItemStack_asNMSCopy = ReflectionUtils.getMethod(craftItemStack, "asNMSCopy", - ItemStack.class + ItemStack.class ); craftItemStack_asBukkitCopy = ReflectionUtils.getMethod(craftItemStack, "asBukkitCopy", - nmsItemStack + nmsItemStack ); nbtTagCompound_setString = ReflectionUtils.getFirstMethod(nbtTagCompound, - List.of( - String.class, - String.class - ), - "setString", - "putString" - ); + List.of( + String.class, + String.class + ), + "setString", + "putString" + ); nbtTagCompound_remove = ReflectionUtils.getMethod(nbtTagCompound, "remove", - String.class + String.class ); nbtTagCompound_hasKey = ReflectionUtils.getFirstMethod(nbtTagCompound, - List.of( - String.class - ), - "hasKey", - "contains" + List.of( + String.class + ), + "hasKey", + "contains" ); nbtTagCompound_getString = ReflectionUtils.getMethod(nbtTagCompound, "getString", - String.class + String.class ); - + packet = ReflectionUtils.getFirstClass( - packageNms + "Packet", - packageNm + "network.protocol.Packet" + packageNms + "Packet", + packageNm + "network.protocol.Packet" ); playerConnection_sendPacket = ReflectionUtils.getFirstMethod(playerConnection, - List.of( - packet - ), - "sendPacket", - "send" + List.of( + packet + ), + "sendPacket", + "send" ); iChatBaseComponent = ReflectionUtils.getFirstClass( - packageNms + "IChatBaseComponent", - packageNm + "network.chat.IChatBaseComponent" + packageNms + "IChatBaseComponent", + packageNm + "network.chat.IChatBaseComponent" ); scoreboardTeam = ReflectionUtils.getFirstClass( - packageNms + "ScoreboardTeam", - packageNm + "world.scores.ScoreboardTeam" + packageNms + "ScoreboardTeam", + packageNm + "world.scores.ScoreboardTeam" ); scoreboard = ReflectionUtils.getFirstClass( - packageNms + "Scoreboard", - packageNm + "world.scores.Scoreboard" + packageNms + "Scoreboard", + packageNm + "world.scores.Scoreboard" ); scoreboardINST = new ClassInstanceBuilder( - scoreboard + scoreboard ).build(); packetPlayOutScoreboardTeam = ReflectionUtils.getFirstClass( - packageNms + "PacketPlayOutScoreboardTeam", - packageNm + "network.protocol.game.PacketPlayOutScoreboardTeam" + packageNms + "PacketPlayOutScoreboardTeam", + packageNm + "network.protocol.game.PacketPlayOutScoreboardTeam" ); craftPlayer = ReflectionUtils.getClass(packageObc + "entity.CraftPlayer"); craftPlayer_getHandle = ReflectionUtils.getMethod(craftPlayer, "getHandle"); @@ -344,831 +267,983 @@ public VersionAdapter() { player_spigot = ReflectionUtils.getMethod(Player.class, "spigot"); entityHuman = entityPlayer.getSuperclass(); entityHuman_profile = ReflectionUtils.getFirstField(entityHuman, - "bH", - "gameProfile" + "bH", + "gameProfile" ); entityPlayer_ping = ReflectionUtils.getField(entityPlayer, "ping"); packetPlayOutPlayerInfo$enumPlayerInfoAction = ReflectionUtils.getFirstClass( - packageNms + "PacketPlayOutPlayerInfo$EnumPlayerInfoAction", - packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket$Action" + packageNms + "PacketPlayOutPlayerInfo$EnumPlayerInfoAction", + packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket$Action" ); packetPlayOutPlayerInfo$enumPlayerInfoAction_UPDATE_DISPLAY_NAME = ReflectionUtils.getField(packetPlayOutPlayerInfo$enumPlayerInfoAction, "UPDATE_DISPLAY_NAME").get(null); packetPlayOutPlayerInfo$enumPlayerInfoAction_ADD_PLAYER = ReflectionUtils.getField(packetPlayOutPlayerInfo$enumPlayerInfoAction, "ADD_PLAYER").get(null); - + craftServer = ReflectionUtils.getClass(packageObc + "CraftServer"); craftServer_getServer = ReflectionUtils.getMethod(craftServer, "getServer"); bukkitServer = ReflectionUtils.getClass(packageOb + "Server"); minecraftServer_getVersion = ReflectionUtils.getMethod(minecraftServer, "getVersion"); minecraftServer_recentTps = ReflectionUtils.getField(minecraftServer, "recentTps"); - - biomeBase = ReflectionUtils.getFirstClass( - packageNms + "BiomeBase", - packageNm + "world.level.biome.BiomeBase" - ); + + biomeBase = ReflectionUtils.getFirstClass( + packageNms + "BiomeBase", + packageNm + "world.level.biome.BiomeBase" + ); biomeBase_biomes = ReflectionUtils.getField(biomeBase, "biomes"); biomeBase_getBiome = ReflectionUtils.getMethod(biomeBase, "getBiome", - int.class + int.class ); - } catch (Exception e) { - throw new IllegalStateException("Failed to initialize " + getClass().getSimpleName(), e); - } - } - - @Override - public Object createChatComponentText(@NonNull String text) { - try { - return new ClassInstanceBuilder( - chatComponentText - ).withParams( - Map.of( - String.class, - text - ) - ).build(); - } catch (Exception e) { + } catch (Exception e) { + throw new IllegalStateException("Failed to initialize " + getClass().getSimpleName(), e); + } + } + + private Method nmsItemStack_getTag() { + return ReflectionUtils.getMethod(nmsItemStack, "getTag"); + } + + private Method nmsItemStack_setTag() { + return ReflectionUtils.getMethod(nmsItemStack, "setTag", + nbtTagCompound + ); + } + + private Method nmsItemStack_hasTag() { + return ReflectionUtils.getMethod(nmsItemStack, "hasTag"); + } + + @SneakyThrows + private Object packetPlayOutPlayerInfo$enumPlayerInfoAction_REMOVE_PLAYER() { + return ReflectionUtils.getField(packetPlayOutPlayerInfo$enumPlayerInfoAction, "REMOVE_PLAYER").get(null); + } + + private Class packetPlayOutTitle$enumTitleAction() { + return ReflectionUtils.getClass(packageNms + "PacketPlayOutTitle$EnumTitleAction"); + } + + @SneakyThrows + private Object packetPlayOutTitle$enumTitleAction_TITLE() { + return ReflectionUtils.getField(packetPlayOutTitle$enumTitleAction(), "TITLE").get(null); + } + + @SneakyThrows + private Object packetPlayOutTitle$enumTitleAction_SUBTITLE() { + return ReflectionUtils.getField(packetPlayOutTitle$enumTitleAction(), "SUBTITLE").get(null); + } + + private Class craftWorld() { + return ReflectionUtils.getClass(packageObc + "CraftWorld"); + } + + private Method craftWorld_getHandle() { + return ReflectionUtils.getMethod(craftWorld(), "getHandle"); + } + + private Method entity_setCustomName() { + return ReflectionUtils.getMethod(entity, "setCustomName", + String.class + ); + } + + private Method entity_setCustomNameVisible() { + return ReflectionUtils.getMethod(entity, "setCustomNameVisible", + boolean.class + ); + } + + private Method entity_getId() { + return ReflectionUtils.getMethod(entity, "getId"); + } + + private Class dataWatcher() { + return ReflectionUtils.getClass(packageNms + "DataWatcher"); + } + + private Method entity_getDataWatcher() { + return ReflectionUtils.getMethod(entity, "getDataWatcher"); + } + + private Class entityLiving() { + return ReflectionUtils.getClass(packageNms + "EntityLiving"); + } + + private Method entityLiving_setHealth() { + return ReflectionUtils.getMethod(entityLiving(), "setHealth", + float.class + ); + } + + private Method entityLiving_getMaxHealth() { + return ReflectionUtils.getMethod(entityLiving(), "getMaxHealth"); + } + + private Class entityWither() { + return ReflectionUtils.getClass(packageNms + "EntityWither"); + } + + private Field packetPlayOutScoreboardTeam_name() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "a"); + } + + private Field packetPlayOutScoreboardTeam_displayName() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "b"); + } + + private Field packetPlayOutScoreboardTeam_prefix() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "c"); + } + + private Field packetPlayOutScoreboardTeam_suffix() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "d"); + } + + private Field packetPlayOutScoreboardTeam_players() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "g"); + } + + private Field packetPlayOutScoreboardTeam_mode() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "h"); + } + + @Override + public Object createChatComponentText(@NonNull String text) { + try { + return new ClassInstanceBuilder( + chatComponentText + ).withParams( + Map.of( + String.class, + text + ) + ).build(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public Entity getBukkitEntity(@NonNull Object entity) { + try { + return (Entity) entity_getBukkitEntity.invoke(entity); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void setYawPitch(@NonNull Object entity, float yaw, float pitch) { + try { + entity_setYawPitch.invoke(entity, + yaw, + pitch + ); + } catch (Exception e) { throw new RuntimeException(e); } - } - - @Override - public Entity getBukkitEntity(@NonNull Object entity) { - try { - return (Entity) entity_getBukkitEntity.invoke(entity); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public void setYawPitch(@NonNull Object entity, float yaw, float pitch) { - try { - entity_setYawPitch.invoke(entity, - yaw, - pitch - ); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - + } + @Override public ItemStack setUUID(@NonNull ItemStack item, UUID uuid) { - try { - Object nmsItem = craftItemStack_asNMSCopy.invoke(null, - item - ); - if (nmsItem == null) return item; - - Object tag = (boolean) nmsItemStack_hasTag().invoke(nmsItem) - ? nmsItemStack_getTag().invoke(nmsItem) - : nbtTagCompound.getConstructor().newInstance(); - if (uuid == null) { - nbtTagCompound_remove.invoke(tag, - "UUID" - ); - } else { - nbtTagCompound_setString.invoke(tag, - "UUID", - uuid.toString() - ); - } + try { + Object nmsItem = craftItemStack_asNMSCopy.invoke(null, + item + ); + if (nmsItem == null) return item; + + Object tag = (boolean) nmsItemStack_hasTag().invoke(nmsItem) + ? nmsItemStack_getTag().invoke(nmsItem) + : nbtTagCompound.getConstructor().newInstance(); + if (uuid == null) { + nbtTagCompound_remove.invoke(tag, + "UUID" + ); + } else { + nbtTagCompound_setString.invoke(tag, + "UUID", + uuid.toString() + ); + } nmsItemStack_setTag().invoke(nmsItem, - tag + tag ); return (ItemStack) craftItemStack_asBukkitCopy.invoke(null, - nmsItem + nmsItem ); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public UUID getUUID(@NonNull ItemStack item) { - try { - Object nmsItem = craftItemStack_asNMSCopy.invoke(null, - item - ); - if (nmsItem == null) return null; - - if ((boolean) nmsItemStack_hasTag().invoke(nmsItem)) { - Object tag = nmsItemStack_getTag().invoke(nmsItem); - if ((boolean) nbtTagCompound_hasKey.invoke(tag, - "UUID" - )) { - return UUID.fromString((String) nbtTagCompound_getString.invoke(tag, - "UUID" - )); - } - } - return null; - } catch (Exception e) { + try { + Object nmsItem = craftItemStack_asNMSCopy.invoke(null, + item + ); + if (nmsItem == null) return null; + + if ((boolean) nmsItemStack_hasTag().invoke(nmsItem)) { + Object tag = nmsItemStack_getTag().invoke(nmsItem); + if ((boolean) nbtTagCompound_hasKey.invoke(tag, + "UUID" + )) { + return UUID.fromString((String) nbtTagCompound_getString.invoke(tag, + "UUID" + )); + } + } + return null; + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public ItemStack clearNBT(@NonNull ItemStack item) { - try { - Object nmsItem = craftItemStack_asNMSCopy.invoke(null, - item - ); - if (nmsItem == null) return item; - - Object tag = new ClassInstanceBuilder( - nbtTagCompound - ).build(); - nmsItemStack_setTag().invoke(nmsItem, - tag - ); - - return (ItemStack) craftItemStack_asBukkitCopy.invoke(null, - nmsItem - ); - } catch (Exception e) { + try { + Object nmsItem = craftItemStack_asNMSCopy.invoke(null, + item + ); + if (nmsItem == null) return item; + + Object tag = new ClassInstanceBuilder( + nbtTagCompound + ).build(); + nmsItemStack_setTag().invoke(nmsItem, + tag + ); + + return (ItemStack) craftItemStack_asBukkitCopy.invoke(null, + nmsItem + ); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendPacket(@NonNull Player player, @NonNull Object packet) { - try { - Object entityPlayer = getEntityPlayer(player); - Object connection = entityPlayer_playerConnection.get(entityPlayer); - playerConnection_sendPacket.invoke(connection, - packet - ); - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + Object connection = entityPlayer_playerConnection.get(entityPlayer); + playerConnection_sendPacket.invoke(connection, + packet + ); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendTitle(@NonNull Player player, String title, String subtitle) { - try { - title = title != null ? title : ""; - subtitle = subtitle != null ? subtitle : ""; - - Object titleComponent = createChatComponentText(title); - Object titlePacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutTitle" - ).withParams( - Map.of( - packetPlayOutTitle$enumTitleAction(), - packetPlayOutTitle$enumTitleAction_TITLE() - ), - Map.of( - iChatBaseComponent, - titleComponent - ) - ).build(); - sendPacket(player, titlePacket); - - Object subtitleComponent = createChatComponentText(subtitle); - Object subtitlePacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutTitle" - ).withParams( - Map.of( - packetPlayOutTitle$enumTitleAction(), - packetPlayOutTitle$enumTitleAction_SUBTITLE() - ), - Map.of( - iChatBaseComponent, - subtitleComponent - ) - ).build(); - sendPacket(player, subtitlePacket); - } catch (Exception e) { + try { + title = title != null ? title : ""; + subtitle = subtitle != null ? subtitle : ""; + + Object titleComponent = createChatComponentText(title); + Object titlePacket = new ClassInstanceBuilder( + packageNms + "PacketPlayOutTitle" + ).withParams( + Map.of( + packetPlayOutTitle$enumTitleAction(), + packetPlayOutTitle$enumTitleAction_TITLE() + ), + Map.of( + iChatBaseComponent, + titleComponent + ) + ).build(); + sendPacket(player, titlePacket); + + Object subtitleComponent = createChatComponentText(subtitle); + Object subtitlePacket = new ClassInstanceBuilder( + packageNms + "PacketPlayOutTitle" + ).withParams( + Map.of( + packetPlayOutTitle$enumTitleAction(), + packetPlayOutTitle$enumTitleAction_SUBTITLE() + ), + Map.of( + iChatBaseComponent, + subtitleComponent + ) + ).build(); + sendPacket(player, subtitlePacket); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendTablist(@NonNull Player player, List header, List footer, String name) { - try { - String headerText = header != null ? String.join("\n", header) : ""; - String footerText = footer != null ? String.join("\n", footer) : ""; + try { + String headerText = header != null ? String.join("\n", header) : ""; + String footerText = footer != null ? String.join("\n", footer) : ""; + + Object headerComponent = createChatComponentText(headerText); + Object footerComponent = createChatComponentText(footerText); - Object headerComponent = createChatComponentText(headerText); - Object footerComponent = createChatComponentText(footerText); - Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutPlayerListHeaderFooter" + packageNms + "PacketPlayOutPlayerListHeaderFooter" ).withParams( - Map.of( - iChatBaseComponent, - headerComponent - ) + Map.of( + iChatBaseComponent, + headerComponent + ) ).build(); - + ReflectionUtils.setField(packet, "b", footerComponent); - + sendPacket(player, packet); player.setPlayerListName(name); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendBossbar(@NonNull Player player, @NonNull String title, double progress) { - try { - removeBossbar(player); - + try { + removeBossbar(player); + Location eye = player.getEyeLocation().clone(); Location location = eye.add(eye.getDirection().multiply(45)); - + float yaw = eye.getYaw(); float pitch = Math.max(-15, Math.min(15, eye.getPitch())); - + Object worldServer = getWorldServer(player.getWorld()); Object wither = new ClassInstanceBuilder( - entityWither() + entityWither() ).withParams( - Map.of( - world, - worldServer - ) + Map.of( + world, + worldServer + ) ).build(); - + entity_setInvisible.invoke(wither, - true + true ); entity_setCustomName().invoke(wither, - title + title ); entity_setCustomNameVisible().invoke(wither, - true + true ); - + float maxHealth = (float) entityLiving_getMaxHealth().invoke(wither); float newHealth = (float) Math.max(1, Math.min(maxHealth, progress * maxHealth)); entityLiving_setHealth().invoke(wither, - newHealth + newHealth ); - + entity_setLocation.invoke(wither, - location.getX(), - location.getY(), - location.getZ(), - yaw, - pitch + location.getX(), + location.getY(), + location.getZ(), + yaw, + pitch ); - + Object spawnPacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutSpawnEntityLiving" + packageNms + "PacketPlayOutSpawnEntityLiving" ).withParams( - Map.of( - entityLiving(), - wither - ) + Map.of( + entityLiving(), + wither + ) ).build(); sendPacket(player, spawnPacket); - + Object metadataPacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutEntityMetadata" + packageNms + "PacketPlayOutEntityMetadata" ).withParams( - Map.of( - int.class, - entity_getId().invoke(wither) - ), - Map.of( - dataWatcher(), - entity_getDataWatcher().invoke(wither) - ), - Map.of( - boolean.class, - true - ) + Map.of( + int.class, + entity_getId().invoke(wither) + ), + Map.of( + dataWatcher(), + entity_getDataWatcher().invoke(wither) + ), + Map.of( + boolean.class, + true + ) ).build(); sendPacket(player, metadataPacket); - + bossBars.put(player, wither); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void removeBossbar(@NonNull Player player) { - try { - Object wither = bossBars.remove(player); - if (wither != null) { - int id = (int) entity_getId().invoke(wither); - Object destroyPacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutEntityDestroy" - ).withParams( - Map.of( - int[].class, - new int[] { id } - ) - ).build(); - sendPacket(player, destroyPacket); - } - } catch (Exception e) { + try { + Object wither = bossBars.remove(player); + if (wither != null) { + int id = (int) entity_getId().invoke(wither); + Object destroyPacket = new ClassInstanceBuilder( + packageNms + "PacketPlayOutEntityDestroy" + ).withParams( + Map.of( + int[].class, + new int[]{id} + ) + ).build(); + sendPacket(player, destroyPacket); + } + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendActionbar(@NonNull Player player, @NonNull String message) { - try { - Object chatMessage = createChatComponentText(message); - Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutChat" - ).withParams( - Map.of( - iChatBaseComponent, - chatMessage - ), - Map.of( - byte.class, - (byte) 2 - ) - ).build(); - sendPacket(player, packet); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Object chatMessage = createChatComponentText(message); + Object packet = new ClassInstanceBuilder( + packageNms + "PacketPlayOutChat" + ).withParams( + Map.of( + iChatBaseComponent, + chatMessage + ), + Map.of( + byte.class, + (byte) 2 + ) + ).build(); + sendPacket(player, packet); + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { - try { - Set players = Set.of(player.getName()); - - Object createPacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).build(); - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_name(), player.getName()); - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_displayName(), player.getName()); - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_players(), players); - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_mode(), 0); - - Object updatePacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).build(); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_name(), player.getName()); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_displayName(), player.getName()); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_players(), players); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_mode(), 2); - - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_prefix(), prefix); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_prefix(), prefix); - - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_suffix(), suffix); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_suffix(), suffix); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, createPacket); - sendPacket(onlinePlayer, updatePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Set players = Set.of(player.getName()); + + Object createPacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).build(); + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_name(), player.getName()); + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_displayName(), player.getName()); + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_players(), players); + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_mode(), 0); + + Object updatePacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).build(); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_name(), player.getName()); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_displayName(), player.getName()); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_players(), players); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_mode(), 2); + + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_prefix(), prefix); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_prefix(), prefix); + + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_suffix(), suffix); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_suffix(), suffix); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, createPacket); + sendPacket(onlinePlayer, updatePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public void removeNametag(@NonNull Player player) { - try { - Set players = Set.of(player.getName()); - - Object removePacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).build(); - ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_name(), player.getName()); - ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_players(), players); - ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_mode(), 4); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, removePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Set players = Set.of(player.getName()); + + Object removePacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).build(); + ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_name(), player.getName()); + ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_players(), players); + ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_mode(), 4); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, removePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch) { - player.playSound(location, org.bukkit.Sound.valueOf(sound.name()), volume, pitch); + player.playSound(location, org.bukkit.Sound.valueOf(sound.name()), volume, pitch); } - + @Override public Object getCraftPlayer(@NonNull Player player) { - return craftPlayer.cast(player); + return craftPlayer.cast(player); } - + @Override public Object getEntityPlayer(@NonNull Player player) { - try { - Object craftPlayer = getCraftPlayer(player); - return craftPlayer_getHandle.invoke(craftPlayer); - } catch (Exception e) { + try { + Object craftPlayer = getCraftPlayer(player); + return craftPlayer_getHandle.invoke(craftPlayer); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public Object getPlayerSpigot(@NonNull Player player) { - try { - return player_spigot.invoke(player); - } catch (Exception e) { + try { + return player_spigot.invoke(player); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public GameProfile getProfile(@NonNull Object entityPlayer) { - try { + try { return (GameProfile) entityHuman_profile.get(entityPlayer); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public int getPing(@NonNull Player player) { - try { - Object entityPlayer = getEntityPlayer(player); - return (int) entityPlayer_ping.get(entityPlayer); - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + return (int) entityPlayer_ping.get(entityPlayer); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void setSkin(@NonNull Player player, @NonNull UUID uuid) { - try { - Object entityPlayer = getEntityPlayer(player); - GameProfile profile = getProfile(entityPlayer); - - Collection textures = profile.getProperties().get("textures"); - if (!PlayerUtils.skins.containsKey(player.getUniqueId()) && textures != null && !textures.isEmpty()) { - PlayerUtils.skins.put(player.getUniqueId(), textures.iterator().next()); - } - - GameProfile skinProfile = GameProfileBuilder.fetch(uuid); - - profile.getProperties().removeAll("textures"); - for (Property property : skinProfile.getProperties().get("textures")) { - profile.getProperties().put("textures", property); - } - - refresh(player); - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + GameProfile profile = getProfile(entityPlayer); + + Collection textures = profile.getProperties().get("textures"); + if (!PlayerUtils.skins.containsKey(player.getUniqueId()) && textures != null && !textures.isEmpty()) { + PlayerUtils.skins.put(player.getUniqueId(), textures.iterator().next()); + } + + GameProfile skinProfile = GameProfileBuilder.fetch(uuid); + + profile.getProperties().removeAll("textures"); + for (Property property : skinProfile.getProperties().get("textures")) { + profile.getProperties().put("textures", property); + } + + refresh(player); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void resetSkin(@NonNull Player player) { - try { - Object entityPlayer = getEntityPlayer(player); - GameProfile profile = getProfile(entityPlayer); + try { + Object entityPlayer = getEntityPlayer(player); + GameProfile profile = getProfile(entityPlayer); - Property original = PlayerUtils.skins.get(player.getUniqueId()); - if (original != null) { - profile.getProperties().removeAll("textures"); - profile.getProperties().put("textures", original); + Property original = PlayerUtils.skins.get(player.getUniqueId()); + if (original != null) { + profile.getProperties().removeAll("textures"); + profile.getProperties().put("textures", original); - refresh(player); + refresh(player); - PlayerUtils.skins.remove(player.getUniqueId()); - } - } catch (Exception e) { + PlayerUtils.skins.remove(player.getUniqueId()); + } + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void setName(@NonNull Player player, @NonNull String name) { - try { - Object entityPlayer = getEntityPlayer(player); - GameProfile profile = getProfile(entityPlayer); - - PlayerUtils.names.put(player.getUniqueId(), profile.getName()); - - player.setCustomName(name); - player.setCustomNameVisible(true); - player.setDisplayName(name); - - ReflectionUtils.setField(ReflectionUtils.getField(GameProfile.class, "name"), name); - - refresh(player); - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + GameProfile profile = getProfile(entityPlayer); + + PlayerUtils.names.put(player.getUniqueId(), profile.getName()); + + player.setCustomName(name); + player.setCustomNameVisible(true); + player.setDisplayName(name); + + ReflectionUtils.setField(ReflectionUtils.getField(GameProfile.class, "name"), name); + + refresh(player); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void resetName(@NonNull Player player) { - try { - String original = PlayerUtils.names.get(player.getUniqueId()); - if (original == null) return; - - player.setCustomName(original); - player.setCustomNameVisible(true); - player.setDisplayName(original); + try { + String original = PlayerUtils.names.get(player.getUniqueId()); + if (original == null) return; + + player.setCustomName(original); + player.setCustomNameVisible(true); + player.setDisplayName(original); - ReflectionUtils.setField(ReflectionUtils.getField(GameProfile.class, "name"), original); + ReflectionUtils.setField(ReflectionUtils.getField(GameProfile.class, "name"), original); - refresh(player); + refresh(player); - PlayerUtils.names.remove(player.getUniqueId()); - } catch (Exception e) { + PlayerUtils.names.remove(player.getUniqueId()); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void refresh(@NonNull Player player) { - try { - Object entityPlayer = getEntityPlayer(player); - - Object update = packetPlayOutPlayerInfo$enumPlayerInfoAction_UPDATE_DISPLAY_NAME; - Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutPlayerInfo", - packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket" - ).withParams( - Map.of( - packetPlayOutPlayerInfo$enumPlayerInfoAction, - update - ), - Map.of( - Iterable.class, - List.of(entityPlayer) - ) - ).build(); - for (Player online : Bukkit.getOnlinePlayers()) { - sendPacket(online, packet); - } - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + + Object update = packetPlayOutPlayerInfo$enumPlayerInfoAction_UPDATE_DISPLAY_NAME; + Object packet = new ClassInstanceBuilder( + packageNms + "PacketPlayOutPlayerInfo", + packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket" + ).withParams( + Map.of( + packetPlayOutPlayerInfo$enumPlayerInfoAction, + update + ), + Map.of( + Iterable.class, + List.of(entityPlayer) + ) + ).build(); + for (Player online : Bukkit.getOnlinePlayers()) { + sendPacket(online, packet); + } + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - try { - Object add = packetPlayOutPlayerInfo$enumPlayerInfoAction_ADD_PLAYER; - Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutPlayerInfo", - packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket" - ).withParams( - Map.of( - packetPlayOutPlayerInfo$enumPlayerInfoAction, - add - ), - Map.of( - Iterable.class, - List.of(entityPlayer) - ) - ).build(); + try { + Object add = packetPlayOutPlayerInfo$enumPlayerInfoAction_ADD_PLAYER; + Object packet = new ClassInstanceBuilder( + packageNms + "PacketPlayOutPlayerInfo", + packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket" + ).withParams( + Map.of( + packetPlayOutPlayerInfo$enumPlayerInfoAction, + add + ), + Map.of( + Iterable.class, + List.of(entityPlayer) + ) + ).build(); sendPacket(player, packet); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - try { - Object remove = packetPlayOutPlayerInfo$enumPlayerInfoAction_REMOVE_PLAYER(); - Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutPlayerInfo" - ).withParams( - Map.of( - packetPlayOutPlayerInfo$enumPlayerInfoAction, - remove - ), - Map.of( - Iterable.class, - List.of(entityPlayer) - ) - ).build(); + try { + Object remove = packetPlayOutPlayerInfo$enumPlayerInfoAction_REMOVE_PLAYER(); + Object packet = new ClassInstanceBuilder( + packageNms + "PacketPlayOutPlayerInfo" + ).withParams( + Map.of( + packetPlayOutPlayerInfo$enumPlayerInfoAction, + remove + ), + Map.of( + Iterable.class, + List.of(entityPlayer) + ) + ).build(); sendPacket(player, packet); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - try { - addEntityPlayer(player, entityPlayer); - - Object spawn = new ClassInstanceBuilder( - packageNms + "PacketPlayOutNamedEntitySpawn", - packageNm + "network.protocol.game.ClientboundAddPlayerPacket" - ).withParams( - Map.of( - entityHuman, - entityPlayer - ) - ).build(); - sendPacket(player, spawn); - - Object teleport = new ClassInstanceBuilder( - packageNms + "PacketPlayOutEntityTeleport", - packageNm + "network.protocol.game.ClientboundPlayerPositionPacket" - ).withParams( - Map.of( - entity, - entityPlayer - ) - ).build(); - sendPacket(player, teleport); - - Bukkit.getScheduler().runTask(FalchusLibMinecraftSpigot.getInstance(), () -> removeEntityPlayer(player, entityPlayer)); - } catch (Exception e) { + try { + addEntityPlayer(player, entityPlayer); + + Object spawn = new ClassInstanceBuilder( + packageNms + "PacketPlayOutNamedEntitySpawn", + packageNm + "network.protocol.game.ClientboundAddPlayerPacket" + ).withParams( + Map.of( + entityHuman, + entityPlayer + ) + ).build(); + sendPacket(player, spawn); + + Object teleport = new ClassInstanceBuilder( + packageNms + "PacketPlayOutEntityTeleport", + packageNm + "network.protocol.game.ClientboundPlayerPositionPacket" + ).withParams( + Map.of( + entity, + entityPlayer + ) + ).build(); + sendPacket(player, teleport); + + Bukkit.getScheduler().runTask(FalchusLibMinecraftSpigot.getInstance(), () -> removeEntityPlayer(player, entityPlayer)); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public Object getMcServer() { - try { - Object server = craftServer.cast(Bukkit.getServer()); - return craftServer_getServer.invoke(server); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Object server = craftServer.cast(Bukkit.getServer()); + return craftServer_getServer.invoke(server); + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public Object getBukkitServer() { - return bukkitServer.cast(Bukkit.getServer()); + return bukkitServer.cast(Bukkit.getServer()); } - + @Override public String getVersion() { - try { - Object server = getMcServer(); - return (String) minecraftServer_getVersion.invoke(server); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Object server = getMcServer(); + return (String) minecraftServer_getVersion.invoke(server); + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public double[] getRecentTps() { - try { - Object server = getMcServer(); - return (double[]) minecraftServer_recentTps.get(server); - } catch (Exception e) { - throw new RuntimeException(e); + try { + Object server = getMcServer(); + return (double[]) minecraftServer_recentTps.get(server); + } catch (Exception e) { + throw new RuntimeException(e); } } - + @Override public Object[] getWorldBiomes(@NonNull World world) { - try { + try { return (Object[]) biomeBase_biomes.get(null); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public Object getNmsBiome(Biome biome) { - try { - int id; - if (biome == null) { - id = 1; - } else { - switch (biome.name()) { - case "BEACH": id = 16; break; - - case "BIRCH_FOREST": - case "BIRCH_FOREST_MOUNTAINS": - id = 27; - break; - - case "BIRCH_FOREST_HILLS": - case "BIRCH_FOREST_HILLS_MOUNTAINS": - id = 28; - break; - - case "COLD_BEACH": id = 26; break; - case "COLD_TAIGA": id = 30; break; - - case "COLD_TAIGA_HILLS": - case "COLD_TAIGA_MOUNTAINS": - id = 31; - break; - - case "DEEP_OCEAN": id = 24; break; - case "DESERT": id = 2; break; - - case "DESERT_HILLS": - case "DESERT_MOUNTAINS": - id = 17; - break; - - case "EXTREME_HILLS": - case "EXTREME_HILLS_MOUNTAINS": - id = 3; - break; - - case "EXTREME_HILLS_PLUS": - case "EXTREME_HILLS_PLUS_MOUNTAINS": - id = 20; - break; - - case "FOREST": - case "FLOWER_FOREST": - id = 4; - break; - - case "FOREST_HILLS": id = 18; break; - case "FROZEN_OCEAN": id = 10; break; - case "FROZEN_RIVER": id = 11; break; - case "HELL": id = 8; break; - case "ICE_MOUNTAINS": id = 13; break; - - case "ICE_PLAINS": - case "ICE_PLAINS_SPIKES": - id = 12; - break; - - case "JUNGLE": id = 21; break; - - case "JUNGLE_EDGE": - case "JUNGLE_EDGE_MOUNTAINS": - id = 23; - break; - - case "JUNGLE_HILLS": - case "JUNGLE_MOUNTAINS": - id = 22; - break; - - case "MEGA_TAIGA": id = 32; break; - case "MEGA_TAIGA_HILLS": id = 33; break; - - case "MESA": - case "MESA_BRYCE": - case "MESA_PLATEAU": - case "MESA_PLATEAU_FOREST": - case "MESA_PLATEAU_FOREST_MOUNTAINS": - case "MESA_PLATEAU_MOUNTAINS": - id = 37; - break; - - case "MUSHROOM_ISLAND": id = 14; break; - case "MUSHROOM_SHORE": id = 15; break; - case "OCEAN": id = 0; break; - - case "PLAINS": - case "SUNFLOWER_PLAINS": - id = 1; - break; - - case "RIVER": id = 7; break; - - case "ROOFED_FOREST": - case "ROOFED_FOREST_MOUNTAINS": - id = 29; - break; - - case "SAVANNA": - case "SAVANNA_MOUNTAINS": - id = 35; - break; - - case "SAVANNA_PLATEAU": - case "SAVANNA_PLATEAU_MOUNTAINS": - id = 36; - break; - - case "SKY": id = 9; break; - case "SMALL_MOUNTAINS": id = 34; break; - case "STONE_BEACH": id = 25; break; - - case "SWAMPLAND": - case "SWAMPLAND_MOUNTAINS": - id = 6; break; - - case "TAIGA": - case "MEGA_SPRUCE_TAIGA": - case "MEGA_SPRUCE_TAIGA_HILLS": - id = 5; break; - - case "TAIGA_HILLS": - case "TAIGA_MOUNTAINS": - id = 19; break; - - default: id = 1; break; - } - } - return biomeBase_getBiome.invoke(null, - id - ); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + int id; + if (biome == null) { + id = 1; + } else { + switch (biome.name()) { + case "BEACH": + id = 16; + break; + + case "BIRCH_FOREST": + case "BIRCH_FOREST_MOUNTAINS": + id = 27; + break; + + case "BIRCH_FOREST_HILLS": + case "BIRCH_FOREST_HILLS_MOUNTAINS": + id = 28; + break; + + case "COLD_BEACH": + id = 26; + break; + case "COLD_TAIGA": + id = 30; + break; + + case "COLD_TAIGA_HILLS": + case "COLD_TAIGA_MOUNTAINS": + id = 31; + break; + + case "DEEP_OCEAN": + id = 24; + break; + case "DESERT": + id = 2; + break; + + case "DESERT_HILLS": + case "DESERT_MOUNTAINS": + id = 17; + break; + + case "EXTREME_HILLS": + case "EXTREME_HILLS_MOUNTAINS": + id = 3; + break; + + case "EXTREME_HILLS_PLUS": + case "EXTREME_HILLS_PLUS_MOUNTAINS": + id = 20; + break; + + case "FOREST": + case "FLOWER_FOREST": + id = 4; + break; + + case "FOREST_HILLS": + id = 18; + break; + case "FROZEN_OCEAN": + id = 10; + break; + case "FROZEN_RIVER": + id = 11; + break; + case "HELL": + id = 8; + break; + case "ICE_MOUNTAINS": + id = 13; + break; + + case "ICE_PLAINS": + case "ICE_PLAINS_SPIKES": + id = 12; + break; + + case "JUNGLE": + id = 21; + break; + + case "JUNGLE_EDGE": + case "JUNGLE_EDGE_MOUNTAINS": + id = 23; + break; + + case "JUNGLE_HILLS": + case "JUNGLE_MOUNTAINS": + id = 22; + break; + + case "MEGA_TAIGA": + id = 32; + break; + case "MEGA_TAIGA_HILLS": + id = 33; + break; + + case "MESA": + case "MESA_BRYCE": + case "MESA_PLATEAU": + case "MESA_PLATEAU_FOREST": + case "MESA_PLATEAU_FOREST_MOUNTAINS": + case "MESA_PLATEAU_MOUNTAINS": + id = 37; + break; + + case "MUSHROOM_ISLAND": + id = 14; + break; + case "MUSHROOM_SHORE": + id = 15; + break; + case "OCEAN": + id = 0; + break; + + case "PLAINS": + case "SUNFLOWER_PLAINS": + id = 1; + break; + + case "RIVER": + id = 7; + break; + + case "ROOFED_FOREST": + case "ROOFED_FOREST_MOUNTAINS": + id = 29; + break; + + case "SAVANNA": + case "SAVANNA_MOUNTAINS": + id = 35; + break; + + case "SAVANNA_PLATEAU": + case "SAVANNA_PLATEAU_MOUNTAINS": + id = 36; + break; + + case "SKY": + id = 9; + break; + case "SMALL_MOUNTAINS": + id = 34; + break; + case "STONE_BEACH": + id = 25; + break; + + case "SWAMPLAND": + case "SWAMPLAND_MOUNTAINS": + id = 6; + break; + + case "TAIGA": + case "MEGA_SPRUCE_TAIGA": + case "MEGA_SPRUCE_TAIGA_HILLS": + id = 5; + break; + + case "TAIGA_HILLS": + case "TAIGA_MOUNTAINS": + id = 19; + break; + + default: + id = 1; + break; + } + } + return biomeBase_getBiome.invoke(null, + id + ); + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public int getBiomeId(Biome biome) { Object target = getNmsBiome(biome); @@ -1176,7 +1251,7 @@ public int getBiomeId(Biome biome) { Object[] biomes = (Object[]) biomeBase_biomes.get(null); for (int i = 0; i < biomes.length; i++) { if (biomes[i] == target) { - return i; + return i; } } return 1; @@ -1184,12 +1259,12 @@ public int getBiomeId(Biome biome) { throw new RuntimeException(e); } } - + @Override public Object getWorldServer(@NonNull World world) { - try { - return craftWorld_getHandle().invoke(world); - } catch (Exception e) { + try { + return craftWorld_getHandle().invoke(world); + } catch (Exception e) { throw new RuntimeException(e); } } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterFolia.java b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterFolia.java new file mode 100644 index 00000000..2e72db3a --- /dev/null +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterFolia.java @@ -0,0 +1,57 @@ +package com.falchus.lib.minecraft.spigot.utils.version; + +import com.falchus.lib.minecraft.spigot.utils.SchedulerUtils; +import com.falchus.lib.minecraft.spigot.utils.version.v26_1_R1.VersionAdapter_v26_1_R1; +import com.falchus.lib.utils.builder.ClassInstanceBuilder; +import lombok.NonNull; +import org.bukkit.entity.Player; + +import java.util.Map; + +/** + * Adapter for Folia 1.21.11. + *

+ * Folia distributes chunk regions across multiple threads. Any task that + * touches world state must run on the owning region's thread. This adapter + * extends {@link VersionAdapter_v26_1_R1} and overrides every method that + * previously relied on {@code Bukkit.getScheduler()}, replacing them with + * the appropriate Folia scheduler via {@link SchedulerUtils}. + *

+ * The {@link com.falchus.lib.task.Task} class already uses a plain + * {@link java.util.concurrent.ScheduledExecutorService}, so it works on + * Folia without changes. + */ +public class VersionAdapterFolia extends VersionAdapter_v26_1_R1 { + + /** + * Spawns a fake {@code EntityPlayer} for {@code player} and schedules the + * deferred player-info removal using Folia's global region scheduler so the + * task lands on the correct thread. + */ + @Override + public void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + try { + addEntityPlayer(player, entityPlayer); + + Object spawn = new ClassInstanceBuilder( + packageNms + "PacketPlayOutNamedEntitySpawn", + packageNm + "network.protocol.game.ClientboundAddPlayerPacket" + ).withParams( + Map.of(entityHuman, entityPlayer) + ).build(); + sendPacket(player, spawn); + + Object teleport = new ClassInstanceBuilder( + packageNms + "PacketPlayOutEntityTeleport", + packageNm + "network.protocol.game.ClientboundPlayerPositionPacket" + ).withParams( + Map.of(entity, entityPlayer) + ).build(); + sendPacket(player, teleport); + + SchedulerUtils.runTask(() -> removeEntityPlayer(player, entityPlayer)); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterModern.java b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterModern.java index b9db0e8f..78cbb834 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterModern.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterModern.java @@ -1,396 +1,350 @@ package com.falchus.lib.minecraft.spigot.utils.version; -import java.lang.reflect.Array; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; - import com.falchus.lib.minecraft.spigot.enums.Sound; import com.falchus.lib.minecraft.spigot.utils.version.v_1_13_R1.VersionAdapter_v_1_13_R1; import com.falchus.lib.utils.builder.ClassInstanceBuilder; import com.falchus.lib.utils.reflection.ReflectionUtils; - import lombok.NonNull; import lombok.SneakyThrows; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +import java.lang.reflect.Array; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.UUID; /** - * Default adapter for all versions over 1.17. (tested with 1.21.11) + * Default adapter for all versions 1.17 – 1.20.x. (tested with 1.21.11) + *

+ * 1.21.11 and 26.1.1 are handled by dedicated subclasses. */ public class VersionAdapterModern extends VersionAdapter_v_1_13_R1 { - + private Class itemMeta() { - return ReflectionUtils.getClass(packageOb + "inventory.meta.ItemMeta"); + return ReflectionUtils.getClass(packageOb + "inventory.meta.ItemMeta"); } + private Method itemStack_getItemMeta() { - return ReflectionUtils.getMethod(ItemStack.class, "getItemMeta"); + return ReflectionUtils.getMethod(ItemStack.class, "getItemMeta"); } + private Method itemStack_setItemMeta() { - return ReflectionUtils.getMethod(ItemStack.class, "setItemMeta", - itemMeta() - ); + return ReflectionUtils.getMethod(ItemStack.class, "setItemMeta", + itemMeta() + ); } + private Method itemMeta_getPDC() { - return ReflectionUtils.getMethod(itemMeta(), "getPersistentDataContainer"); + return ReflectionUtils.getMethod(itemMeta(), "getPersistentDataContainer"); } + private Class namespacedKey() { - return ReflectionUtils.getClass(packageOb + "NamespacedKey"); + return ReflectionUtils.getClass(packageOb + "NamespacedKey"); } + private Class persistentDataType() { - return ReflectionUtils.getClass(packageOb + "persistence.PersistentDataType"); + return ReflectionUtils.getClass(packageOb + "persistence.PersistentDataType"); } + @SneakyThrows - private Object persistentDataType_STRING() { - return ReflectionUtils.getField(persistentDataType(), "STRING").get(null); + private Object persistentDataType_STRING() throws IllegalAccessException { + return ReflectionUtils.getField(persistentDataType(), "STRING").get(null); } + private Class persistentDataContainer() { - return ReflectionUtils.getClass(packageOb + "persistence.PersistentDataContainer"); + return ReflectionUtils.getClass(packageOb + "persistence.PersistentDataContainer"); } + private Method persistentDataContainer_set() { - return ReflectionUtils.getMethod(persistentDataContainer(), "set", - namespacedKey(), - persistentDataType(), - Object.class - ); + return ReflectionUtils.getMethod(persistentDataContainer(), "set", + namespacedKey(), + persistentDataType(), + Object.class + ); } + private Method persistentDataContainer_get() { - return ReflectionUtils.getMethod(persistentDataContainer(), "get", - namespacedKey(), - persistentDataType() - ); + return ReflectionUtils.getMethod(persistentDataContainer(), "get", + namespacedKey(), + persistentDataType() + ); } + private Method persistentDataContainer_remove() { - return ReflectionUtils.getMethod(persistentDataContainer(), "remove", - namespacedKey() - ); + return ReflectionUtils.getMethod(persistentDataContainer(), "remove", + namespacedKey() + ); } - + private Class clientboundPlayerInfoRemovePacket() { - return ReflectionUtils.getClass(packageNm + "network.protocol.game.ClientboundPlayerInfoRemovePacket"); + return ReflectionUtils.getClass(packageNm + "network.protocol.game.ClientboundPlayerInfoRemovePacket"); } private Method chatComponentText_literal() { - return ReflectionUtils.getMethod(chatComponentText, "literal", - String.class - ); + return ReflectionUtils.getMethod(chatComponentText, "literal", + String.class + ); } + private Class bossBar() { - return ReflectionUtils.getClass(packageOb + "boss.BossBar"); + return ReflectionUtils.getClass(packageOb + "boss.BossBar"); } + private Method bossBar_setProgress() { - return ReflectionUtils.getMethod(bossBar(), "setProgress", - double.class - ); + return ReflectionUtils.getMethod(bossBar(), "setProgress", + double.class + ); } + private Method bossBar_addPlayer() { - return ReflectionUtils.getMethod(bossBar(), "addPlayer", - Player.class - ); + return ReflectionUtils.getMethod(bossBar(), "addPlayer", + Player.class + ); } + private Method bossBar_removeBossBar() { - return ReflectionUtils.getMethod(bukkitServer, "removeBossBar", - namespacedKey() - ); + return ReflectionUtils.getMethod(bukkitServer, "removeBossBar", + namespacedKey() + ); } + private Class barColor() { - return ReflectionUtils.getClass(packageOb + "boss.BarColor"); + return ReflectionUtils.getClass(packageOb + "boss.BarColor"); } + @SneakyThrows - private Object barColor_WHITE() { - return ReflectionUtils.getField(barColor(), "WHITE").get(null); + private Object barColor_WHITE() throws IllegalAccessException { + return ReflectionUtils.getField(barColor(), "WHITE").get(null); } + private Class barStyle() { - return ReflectionUtils.getClass(packageOb + "boss.BarStyle"); + return ReflectionUtils.getClass(packageOb + "boss.BarStyle"); } + @SneakyThrows - private Object barStyle_SOLID() { - return ReflectionUtils.getField(barStyle(), "SOLID").get(null); + private Object barStyle_SOLID() throws IllegalAccessException { + return ReflectionUtils.getField(barStyle(), "SOLID").get(null); } + private Class bossFlag() { - return ReflectionUtils.getClass(packageOb + "boss.BarFlag"); + return ReflectionUtils.getClass(packageOb + "boss.BarFlag"); } + private Method bukkitServer_createBossBar() { - return ReflectionUtils.getMethod(bukkitServer, "createBossBar", - namespacedKey(), - String.class, - barColor(), - barStyle(), - Array.newInstance(bossFlag(), 0).getClass() - ); + return ReflectionUtils.getMethod(bukkitServer, "createBossBar", + namespacedKey(), + String.class, + barColor(), + barStyle(), + Array.newInstance(bossFlag(), 0).getClass() + ); } + private Method packetPlayOutScoreboardTeam_createAddOrModifyPacket() { - return ReflectionUtils.getMethod(packetPlayOutScoreboardTeam, "createAddOrModifyPacket", - scoreboardTeam, - boolean.class - ); + return ReflectionUtils.getMethod(packetPlayOutScoreboardTeam, "createAddOrModifyPacket", + scoreboardTeam, + boolean.class + ); } + private Method packetPlayOutScoreboardTeam_createRemovePacket() { - return ReflectionUtils.getMethod(packetPlayOutScoreboardTeam, "createRemovePacket", - scoreboardTeam - ); - } - - @Override - public Object createChatComponentText(@NonNull String text) { - try { - return chatComponentText_literal().invoke(null, - text - ); - } catch (Exception e) { + return ReflectionUtils.getMethod(packetPlayOutScoreboardTeam, "createRemovePacket", + scoreboardTeam + ); + } + + private Class clientboundSetTitleTextPacket() { + return ReflectionUtils.getClass(packageNm + "network.protocol.game.ClientboundSetTitleTextPacket"); + } + + private Class clientboundSetSubtitleTextPacket() { + return ReflectionUtils.getClass(packageNm + "network.protocol.game.ClientboundSetSubtitleTextPacket"); + } + + @Override + public Object createChatComponentText(@NonNull String text) { + try { + return chatComponentText_literal().invoke(null, text); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void sendTitle(@NonNull Player player, String title, String subtitle) { + try { + title = title != null ? title : ""; + subtitle = subtitle != null ? subtitle : ""; + + Object titlePacket = new ClassInstanceBuilder( + clientboundSetTitleTextPacket() + ).withParams( + Map.of(iChatBaseComponent, createChatComponentText(title)) + ).build(); + sendPacket(player, titlePacket); + + Object subtitlePacket = new ClassInstanceBuilder( + clientboundSetSubtitleTextPacket() + ).withParams( + Map.of(iChatBaseComponent, createChatComponentText(subtitle)) + ).build(); + sendPacket(player, subtitlePacket); + } catch (Exception e) { throw new RuntimeException(e); } - } - - @Override + } + + @Override public ItemStack setUUID(@NonNull ItemStack item, UUID uuid) { - try { - Object meta = itemStack_getItemMeta().invoke(item); - if (meta == null) return item; - + try { + Object meta = itemStack_getItemMeta().invoke(item); + if (meta == null) return item; + Object pdc = itemMeta_getPDC().invoke(meta); - Object key = new ClassInstanceBuilder( - namespacedKey() - ).withParams( - Map.of( - Plugin.class, - plugin - ), - Map.of( - String.class, - "UUID" - ) + Object key = new ClassInstanceBuilder(namespacedKey()).withParams( + Map.of(Plugin.class, plugin), + Map.of(String.class, "UUID") ).build(); - - if (uuid == null) { - persistentDataContainer_remove().invoke(pdc, - key - ); - } else { - persistentDataContainer_set().invoke(pdc, - key, - persistentDataType_STRING(), - uuid.toString() - ); - } - itemStack_setItemMeta().invoke(item, - meta - ); + + if (uuid == null) { + persistentDataContainer_remove().invoke(pdc, key); + } else { + persistentDataContainer_set().invoke(pdc, key, persistentDataType_STRING(), uuid.toString()); + } + itemStack_setItemMeta().invoke(item, meta); return item; - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public UUID getUUID(@NonNull ItemStack item) { - try { + try { Object meta = itemStack_getItemMeta().invoke(item); if (meta == null) return null; - + Object pdc = itemMeta_getPDC().invoke(meta); - Object key = new ClassInstanceBuilder( - namespacedKey() - ).withParams( - Map.of( - Plugin.class, - plugin - ), - Map.of( - String.class, - "UUID" - ) + Object key = new ClassInstanceBuilder(namespacedKey()).withParams( + Map.of(Plugin.class, plugin), + Map.of(String.class, "UUID") ).build(); - Object uuid = persistentDataContainer_get().invoke(pdc, - key, - persistentDataType_STRING() - ); - + Object uuid = persistentDataContainer_get().invoke(pdc, key, persistentDataType_STRING()); return uuid != null ? UUID.fromString((String) uuid) : null; - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public ItemStack clearNBT(@NonNull ItemStack item) { - try { + try { Object meta = itemStack_getItemMeta().invoke(item); if (meta == null) return item; - + Object pdc = itemMeta_getPDC().invoke(meta); - Object key = new ClassInstanceBuilder( - namespacedKey() - ).withParams( - Map.of( - Plugin.class, - plugin - ), - Map.of( - String.class, - "UUID" - ) + Object key = new ClassInstanceBuilder(namespacedKey()).withParams( + Map.of(Plugin.class, plugin), + Map.of(String.class, "UUID") ).build(); - persistentDataContainer_remove().invoke(pdc, - key - ); - - itemStack_setItemMeta().invoke(item, - meta - ); + persistentDataContainer_remove().invoke(pdc, key); + itemStack_setItemMeta().invoke(item, meta); return item; - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendBossbar(@NonNull Player player, @NonNull String title, double progress) { - try { - removeBossbar(player); - - Object key = new ClassInstanceBuilder( - namespacedKey() - ).withParams( - Map.of( - Plugin.class, - plugin - ), - Map.of( - String.class, - "Bossbar_" + player.getUniqueId() - ) + try { + removeBossbar(player); + + Object key = new ClassInstanceBuilder(namespacedKey()).withParams( + Map.of(Plugin.class, plugin), + Map.of(String.class, "Bossbar_" + player.getUniqueId()) ).build(); - - Object bossBar = bukkitServer_createBossBar().invoke(getBukkitServer(), - key, - title, - barColor_WHITE(), - barStyle_SOLID(), - Array.newInstance(bossFlag(), 0) - ); - - bossBar_setProgress().invoke(bossBar, - progress - ); - bossBar_addPlayer().invoke(bossBar, - player - ); - - bossBars.put(player, key); - } catch (Exception e) { + + Object bossBar = bukkitServer_createBossBar().invoke(getBukkitServer(), + key, title, barColor_WHITE(), barStyle_SOLID(), Array.newInstance(bossFlag(), 0) + ); + bossBar_setProgress().invoke(bossBar, progress); + bossBar_addPlayer().invoke(bossBar, player); + bossBars.put(player, key); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void removeBossbar(@NonNull Player player) { - try { - Object key = bossBars.remove(player); - if (key == null) return; - - bossBar_removeBossBar().invoke(getBukkitServer(), - key - ); - } catch (Exception e) { + try { + Object key = bossBars.remove(player); + if (key == null) return; + bossBar_removeBossBar().invoke(getBukkitServer(), key); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { - try { - Object team = new ClassInstanceBuilder( - scoreboardTeam - ).withParams( - Map.of( - scoreboard, - scoreboardINST - ), - Map.of( - String.class, - player.getName() - ) - ).build(); - scoreboardTeam_setDisplayName().invoke(team, - createChatComponentText(player.getName()) - ); - scoreboardTeam_setPrefix().invoke(team, - createChatComponentText(prefix) - ); - scoreboardTeam_setSuffix().invoke(team, - createChatComponentText(suffix) - ); - - Object createPacket = packetPlayOutScoreboardTeam_createAddOrModifyPacket().invoke(null, - team, - false - ); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, createPacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - + try { + Object team = new ClassInstanceBuilder(scoreboardTeam).withParams( + Map.of(scoreboard, scoreboardINST), + Map.of(String.class, player.getName()) + ).build(); + scoreboardTeam_setDisplayName().invoke(team, createChatComponentText(player.getName())); + scoreboardTeam_setPrefix().invoke(team, createChatComponentText(prefix)); + scoreboardTeam_setSuffix().invoke(team, createChatComponentText(suffix)); + + Object createPacket = packetPlayOutScoreboardTeam_createAddOrModifyPacket().invoke(null, team, false); + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, createPacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Override public void removeNametag(@NonNull Player player) { - try { - Object team = new ClassInstanceBuilder( - scoreboardTeam - ).withParams( - Map.of( - scoreboard, - scoreboardINST - ), - Map.of( - String.class, - player.getName() - ) - ).build(); - scoreboardTeam_setDisplayName().invoke(team, - createChatComponentText(player.getName()) - ); - - Object removePacket = packetPlayOutScoreboardTeam_createRemovePacket().invoke(null, - team - ); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, removePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - + try { + Object team = new ClassInstanceBuilder(scoreboardTeam).withParams( + Map.of(scoreboard, scoreboardINST), + Map.of(String.class, player.getName()) + ).build(); + scoreboardTeam_setDisplayName().invoke(team, createChatComponentText(player.getName())); + + Object removePacket = packetPlayOutScoreboardTeam_createRemovePacket().invoke(null, team); + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, removePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Override public void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch) { - player.playSound(location, org.bukkit.Sound.valueOf(sound.getModernName()), volume, pitch); - } - - @Override - public void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - try { - UUID uuid = getProfile(entityPlayer).getId(); - Object packet = new ClassInstanceBuilder( - clientboundPlayerInfoRemovePacket() - ).withParams( - Map.of( - List.class, - List.of(uuid) - ) - ).build(); - sendPacket(player, packet); - } catch (Exception e) { + player.playSound(location, org.bukkit.Sound.valueOf(sound.getModernName()), volume, pitch); + } + + @Override + public void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + try { + UUID uuid = getProfile(entityPlayer).getId(); + Object packet = new ClassInstanceBuilder(clientboundPlayerInfoRemovePacket()).withParams( + Map.of(List.class, List.of(uuid)) + ).build(); + sendPacket(player, packet); + } catch (Exception e) { throw new RuntimeException(e); } - } -} + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java index e1431b6b..6b11c369 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java @@ -1,47 +1,93 @@ package com.falchus.lib.minecraft.spigot.utils.version; -import org.bukkit.Bukkit; - +import com.falchus.lib.minecraft.FalchusLibMinecraft; import com.falchus.lib.minecraft.spigot.enums.Version; import com.falchus.lib.minecraft.spigot.utils.ServerUtils; +import com.falchus.lib.minecraft.spigot.utils.version.v1_21_R1.VersionAdapter_v1_21_R1; import com.falchus.lib.minecraft.spigot.utils.version.v1_9_R1.VersionAdapter_v1_9_R1; +import com.falchus.lib.minecraft.spigot.utils.version.v26_1_R1.VersionAdapter_v26_1_R1; import com.falchus.lib.minecraft.spigot.utils.version.v_1_13_R1.VersionAdapter_v_1_13_R1; import com.falchus.lib.utils.builder.ClassInstanceBuilder; - import lombok.experimental.UtilityClass; +import org.bukkit.Bukkit; /** * Provides the {@link IVersionAdapter} for the current server version. - * By default, returns {@link VersionAdapter}. + *

+ * Selection order (most specific → least specific): + *

    + *
  1. Folia on any supported version → {@link VersionAdapterFolia}
  2. + *
  3. Paper 26.x.x → {@link VersionAdapter_v26_1_R1}
  4. + *
  5. 1.21.x → {@link VersionAdapter_v1_21_R1}
  6. + *
  7. 1.17–1.20 → {@link VersionAdapterModern}
  8. + *
  9. 1.13–1.16 → {@link VersionAdapter_v_1_13_R1}
  10. + *
  11. 1.9–1.12 → {@link VersionAdapter_v1_9_R1}
  12. + *
  13. 1.8 → {@link VersionAdapter}
  14. + *
*/ @UtilityClass public class VersionProvider { - private static IVersionAdapter adapter; - - private static IVersionAdapter load() { - Version version = ServerUtils.getVersion(); - if (version.isAfter(Version.v1_16)) return new VersionAdapterModern(); - if (version.isAfter(Version.v1_12)) return new VersionAdapter_v_1_13_R1(); - if (version.isAfter(Version.v1_8)) return new VersionAdapter_v1_9_R1(); - if (version.isBefore(Version.v1_9)) return new VersionAdapter(); - - try { - String[] parts = Bukkit.getServer().getClass().getPackageName().split("\\."); - if (parts.length >= 4) { - String ver = parts[3]; - return (IVersionAdapter) new ClassInstanceBuilder( - VersionProvider.class.getPackageName() + "." + ver + "." + VersionAdapter.class.getSimpleName() + "_" + ver - ).build(); - } - } catch (Exception ignored) {} - return new VersionAdapter(); - } - - public static IVersionAdapter get() { - if (adapter == null) { - adapter = load(); - } - return adapter; - } -} + private static IVersionAdapter adapter; + + private static IVersionAdapter load() { + if (FalchusLibMinecraft.isFolia()) { + return new VersionAdapterFolia(); + } + + Version version = ServerUtils.getVersion(); + int major = ServerUtils.getMajorVersion(); + + if (major >= 26) { + return new VersionAdapter_v26_1_R1(); + } + + if (version.isAfter(Version.v1_20)) { + return new VersionAdapter_v1_21_R1(); + } + + if (version.isAfter(Version.v1_16)) { + return new VersionAdapterModern(); + } + + if (version.isAfter(Version.v1_12)) { + return new VersionAdapter_v_1_13_R1(); + } + + if (version.isAfter(Version.v1_8)) { + return new VersionAdapter_v1_9_R1(); + } + + if (version.isBefore(Version.v1_9)) { + return new VersionAdapter(); + } + + try { + String[] parts = Bukkit.getServer().getClass().getPackageName().split("\\."); + if (parts.length >= 4) { + String ver = parts[3]; + return (IVersionAdapter) new ClassInstanceBuilder( + VersionProvider.class.getPackageName() + "." + ver + + "." + VersionAdapter.class.getSimpleName() + "_" + ver + ).build(); + } + } catch (Exception ignored) { + } + + return new VersionAdapter(); + } + + public static IVersionAdapter get() { + if (adapter == null) { + adapter = load(); + } + return adapter; + } + + /** + * Resets the cached adapter — useful in tests or hot-reload scenarios. + */ + public static void reset() { + adapter = null; + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/v1_21_R1/VersionAdapter_v1_21_R1.java b/src/com/falchus/lib/minecraft/spigot/utils/version/v1_21_R1/VersionAdapter_v1_21_R1.java new file mode 100644 index 00000000..0aae77d5 --- /dev/null +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/v1_21_R1/VersionAdapter_v1_21_R1.java @@ -0,0 +1,114 @@ +package com.falchus.lib.minecraft.spigot.utils.version.v1_21_R1; + +import com.falchus.lib.minecraft.spigot.utils.SchedulerUtils; +import com.falchus.lib.minecraft.spigot.utils.version.VersionAdapterModern; +import com.falchus.lib.utils.builder.ClassInstanceBuilder; +import com.falchus.lib.utils.reflection.ReflectionUtils; +import lombok.NonNull; +import org.bukkit.entity.Player; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; + +/** + * Adapter for Minecraft 1.21.11. + *

+ * Changes vs. {@link VersionAdapterModern}: + *

    + *
  • Uses {@link SchedulerUtils} for {@link #spawnEntityPlayer} so the + * delayed removal is safe on both Bukkit and Folia.
  • + *
  • Resolves the {@code recentTps} field with additional fallback names + * introduced in Paper 1.21.x.
  • + *
  • Handles the renamed {@code PlayerConnection} → {@code ServerGamePacketListenerImpl} + * path used by Mojang-mapped Paper builds.
  • + *
+ */ +public class VersionAdapter_v1_21_R1 extends VersionAdapterModern { + + private static final String PACKET_LISTENER_CLASS = + "net.minecraft.server.network.ServerGamePacketListenerImpl"; + + /** + * Returns recent TPS, resolving the field name used in 1.21.x Paper builds + * ({@code recentTps} still present; {@code tickTimes} added as alternative). + */ + @Override + public double[] getRecentTps() { + try { + Object server = getMcServer(); + Field tpsField = ReflectionUtils.getFirstField( + server.getClass(), + "recentTps", + "tickTimes" + ); + Object value = tpsField.get(server); + // tickTimes stores nanoseconds per tick; convert to TPS approximation when needed + if (value instanceof long[] times) { + double[] tps = new double[times.length]; + for (int i = 0; i < times.length; i++) { + double mspt = times[i] / 1_000_000.0; + tps[i] = mspt == 0 ? 20.0 : Math.min(20.0, 1000.0 / mspt); + } + return tps; + } + return (double[]) value; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Resolves the send-packet method on 1.21.x where the connection class + * may be at a Mojang-mapped path. + */ + @Override + public void sendPacket(@NonNull Player player, @NonNull Object packet) { + try { + Object entityPlayer = getEntityPlayer(player); + Object connection = entityPlayer_playerConnection.get(entityPlayer); + Method send = ReflectionUtils.getFirstMethod( + connection.getClass(), + List.of(this.packet), + "send", + "sendPacket" + ); + send.invoke(connection, packet); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Overrides {@link VersionAdapterModern#spawnEntityPlayer} to use + * {@link SchedulerUtils#runTask} so the deferred player-info removal + * is scheduled correctly on both Bukkit and Folia. + */ + @Override + public void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + try { + addEntityPlayer(player, entityPlayer); + + Object spawn = new ClassInstanceBuilder( + packageNms + "PacketPlayOutNamedEntitySpawn", + packageNm + "network.protocol.game.ClientboundAddPlayerPacket" + ).withParams( + Map.of(entityHuman, entityPlayer) + ).build(); + sendPacket(player, spawn); + + Object teleport = new ClassInstanceBuilder( + packageNms + "PacketPlayOutEntityTeleport", + packageNm + "network.protocol.game.ClientboundPlayerPositionPacket" + ).withParams( + Map.of(entity, entityPlayer) + ).build(); + sendPacket(player, teleport); + + SchedulerUtils.runTask(() -> removeEntityPlayer(player, entityPlayer)); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/v1_9_R1/VersionAdapter_v1_9_R1.java b/src/com/falchus/lib/minecraft/spigot/utils/version/v1_9_R1/VersionAdapter_v1_9_R1.java index e8d99100..d566a977 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/v1_9_R1/VersionAdapter_v1_9_R1.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/v1_9_R1/VersionAdapter_v1_9_R1.java @@ -1,59 +1,58 @@ package com.falchus.lib.minecraft.spigot.utils.version.v1_9_R1; -import java.lang.reflect.Method; - -import org.bukkit.entity.Player; - import com.falchus.lib.minecraft.spigot.utils.version.VersionAdapter; import com.falchus.lib.utils.reflection.ReflectionUtils; - import lombok.NonNull; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; +import org.bukkit.entity.Player; + +import java.lang.reflect.Method; public class VersionAdapter_v1_9_R1 extends VersionAdapter { - - private Method player_sendTitle() { - return ReflectionUtils.getMethod(Player.class, "sendTitle", - String.class, - String.class - ); - } - private Method player$Spigot_sendMessage() { - return ReflectionUtils.getMethod(player$Spigot, "sendMessage", - ChatMessageType.class, - BaseComponent[].class - ); - } - + + private Method player_sendTitle() { + return ReflectionUtils.getMethod(Player.class, "sendTitle", + String.class, + String.class + ); + } + + private Method player$Spigot_sendMessage() { + return ReflectionUtils.getMethod(player$Spigot, "sendMessage", + ChatMessageType.class, + BaseComponent[].class + ); + } + @Override public void sendTitle(@NonNull Player player, String title, String subtitle) { - try { - title = title != null ? title : ""; - subtitle = subtitle != null ? subtitle : ""; - - player_sendTitle().invoke(player, - title, - subtitle - ); - } catch (Exception e) { + try { + title = title != null ? title : ""; + subtitle = subtitle != null ? subtitle : ""; + + player_sendTitle().invoke(player, + title, + subtitle + ); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendActionbar(@NonNull Player player, @NonNull String message) { - try { - Object spigot = getPlayerSpigot(player); - Object chatMessage = TextComponent.fromLegacyText(message); - - player$Spigot_sendMessage().invoke(spigot, - ChatMessageType.ACTION_BAR, - chatMessage - ); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Object spigot = getPlayerSpigot(player); + Object chatMessage = TextComponent.fromLegacyText(message); + + player$Spigot_sendMessage().invoke(spigot, + ChatMessageType.ACTION_BAR, + chatMessage + ); + } catch (Exception e) { + throw new RuntimeException(e); + } } } diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/v26_1_R1/VersionAdapter_v26_1_R1.java b/src/com/falchus/lib/minecraft/spigot/utils/version/v26_1_R1/VersionAdapter_v26_1_R1.java new file mode 100644 index 00000000..6533d1e1 --- /dev/null +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/v26_1_R1/VersionAdapter_v26_1_R1.java @@ -0,0 +1,70 @@ +package com.falchus.lib.minecraft.spigot.utils.version.v26_1_R1; + +import com.falchus.lib.minecraft.spigot.enums.Sound; +import com.falchus.lib.minecraft.spigot.utils.version.v1_21_R1.VersionAdapter_v1_21_R1; +import com.falchus.lib.minecraft.utils.AdventureUtils; +import lombok.NonNull; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.title.Title; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import java.util.List; + +/** + * Adapter for Paper 26.1.1 (Minecraft 1.21.x, Paper API v5+). + *

+ * Paper 26.1.1 deprecates most legacy {@code String}-based player API in favour + * of Adventure {@link Component}s. This adapter replaces the affected methods + * with their Adventure equivalents available directly on {@link Player}: + *

    + *
  • {@code sendTitle(String, String)} → {@link Player#showTitle(Title)}
  • + *
  • Tab-list header/footer → {@link Player#sendPlayerListHeaderAndFooter(Component, Component)}
  • + *
  • Player list name → {@link Player#playerListName(Component)}
  • + *
+ * NMS packet sending is inherited unchanged from {@link VersionAdapter_v1_21_R1}. + */ +public class VersionAdapter_v26_1_R1 extends VersionAdapter_v1_21_R1 { + + /** + * Uses the Adventure {@link Player#showTitle(Title)} API. + */ + @Override + public void sendTitle(@NonNull Player player, String title, String subtitle) { + String t = title != null ? title : ""; + String st = subtitle != null ? subtitle : ""; + + player.showTitle(Title.title( + AdventureUtils.legacy(t), + AdventureUtils.legacy(st) + )); + } + + /** + * Uses {@link Player#sendPlayerListHeaderAndFooter(Component, Component)} and + * {@link Player#playerListName(Component)}, replacing the deprecated + * {@code setPlayerListHeaderFooter} / {@code setPlayerListName} String overloads. + */ + @Override + public void sendTablist(@NonNull Player player, List header, List footer, String name) { + String headerText = header != null ? String.join("\n", header) : ""; + String footerText = footer != null ? String.join("\n", footer) : ""; + + player.sendPlayerListHeaderAndFooter( + AdventureUtils.legacy(headerText), + AdventureUtils.legacy(footerText) + ); + player.playerListName(name != null ? AdventureUtils.legacy(name) : null); + } + + /** + * In Paper 26.1.1 some legacy sound enum names differ; routing through + * {@link Sound#getModernName()} covers this. Method body is identical + * to the parent but kept explicit for traceability. + */ + @Override + public void playSound(@NonNull Player player, @NonNull Location location, + @NonNull Sound sound, float volume, float pitch) { + player.playSound(location, org.bukkit.Sound.valueOf(sound.getModernName()), volume, pitch); + } +} \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/v_1_13_R1/VersionAdapter_v_1_13_R1.java b/src/com/falchus/lib/minecraft/spigot/utils/version/v_1_13_R1/VersionAdapter_v_1_13_R1.java index 699a6b7f..d6fab131 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/v_1_13_R1/VersionAdapter_v_1_13_R1.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/v_1_13_R1/VersionAdapter_v_1_13_R1.java @@ -1,181 +1,182 @@ package com.falchus.lib.minecraft.spigot.utils.version.v_1_13_R1; +import com.falchus.lib.minecraft.spigot.utils.version.VersionAdapter; +import com.falchus.lib.utils.builder.ClassInstanceBuilder; +import com.falchus.lib.utils.reflection.ReflectionUtils; +import lombok.NonNull; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import com.falchus.lib.minecraft.spigot.utils.version.VersionAdapter; -import com.falchus.lib.utils.builder.ClassInstanceBuilder; -import com.falchus.lib.utils.reflection.ReflectionUtils; - -import lombok.NonNull; - public class VersionAdapter_v_1_13_R1 extends VersionAdapter { - private Method player_setPlayerListHeaderFooter() { - return ReflectionUtils.getMethod(Player.class, "setPlayerListHeaderFooter", - String.class, - String.class - ); - } - protected Method scoreboardTeam_setDisplayName() { - return ReflectionUtils.getMethod(scoreboardTeam, "setDisplayName", - iChatBaseComponent - ); + private Method player_setPlayerListHeaderFooter() { + return ReflectionUtils.getMethod(Player.class, "setPlayerListHeaderFooter", + String.class, + String.class + ); } - protected Method scoreboardTeam_setPrefix() { - return ReflectionUtils.getFirstMethod(scoreboardTeam, - List.of( - iChatBaseComponent - ), - "setPrefix", - "setPlayerPrefix" - ); + + protected Method scoreboardTeam_setDisplayName() { + return ReflectionUtils.getMethod(scoreboardTeam, "setDisplayName", + iChatBaseComponent + ); } - protected Method scoreboardTeam_setSuffix() { - return ReflectionUtils.getFirstMethod(scoreboardTeam, - List.of( - iChatBaseComponent - ), - "setSuffix", - "setPlayerSuffix" - ); + + protected Method scoreboardTeam_setPrefix() { + return ReflectionUtils.getFirstMethod(scoreboardTeam, + List.of( + iChatBaseComponent + ), + "setPrefix", + "setPlayerPrefix" + ); + } + + protected Method scoreboardTeam_setSuffix() { + return ReflectionUtils.getFirstMethod(scoreboardTeam, + List.of( + iChatBaseComponent + ), + "setSuffix", + "setPlayerSuffix" + ); } - + @Override public void sendTablist(@NonNull Player player, List header, List footer, String name) { - try { - String headerText = header != null ? String.join("\n", header) : ""; - String footerText = footer != null ? String.join("\n", footer) : ""; - + try { + String headerText = header != null ? String.join("\n", header) : ""; + String footerText = footer != null ? String.join("\n", footer) : ""; + player_setPlayerListHeaderFooter().invoke(player, - headerText, - footerText + headerText, + footerText ); player.setPlayerListName(name); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { - try { - Set players = Set.of(player.getName()); - - Object team = new ClassInstanceBuilder( - scoreboardTeam - ).withParams( - Map.of( - scoreboard, - scoreboardINST - ), - Map.of( - String.class, - player.getName() - ) - ).build(); - scoreboardTeam_setDisplayName().invoke(team, - createChatComponentText(player.getName()) - ); - scoreboardTeam_setPrefix().invoke(team, - createChatComponentText(prefix) - ); - scoreboardTeam_setSuffix().invoke(team, - createChatComponentText(suffix) - ); - - Object createPacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).withParams( - Map.of( - scoreboardTeam, - team - ), - Map.of( - Collection.class, - players - ), - Map.of( - int.class, - 0 - ) - ).build(); - - Object updatePacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).withParams( - Map.of( - scoreboardTeam, - team - ), - Map.of( - Collection.class, - players - ), - Map.of( - int.class, - 2 - ) - ).build(); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, createPacket); - sendPacket(onlinePlayer, updatePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Set players = Set.of(player.getName()); + + Object team = new ClassInstanceBuilder( + scoreboardTeam + ).withParams( + Map.of( + scoreboard, + scoreboardINST + ), + Map.of( + String.class, + player.getName() + ) + ).build(); + scoreboardTeam_setDisplayName().invoke(team, + createChatComponentText(player.getName()) + ); + scoreboardTeam_setPrefix().invoke(team, + createChatComponentText(prefix) + ); + scoreboardTeam_setSuffix().invoke(team, + createChatComponentText(suffix) + ); + + Object createPacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).withParams( + Map.of( + scoreboardTeam, + team + ), + Map.of( + Collection.class, + players + ), + Map.of( + int.class, + 0 + ) + ).build(); + + Object updatePacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).withParams( + Map.of( + scoreboardTeam, + team + ), + Map.of( + Collection.class, + players + ), + Map.of( + int.class, + 2 + ) + ).build(); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, createPacket); + sendPacket(onlinePlayer, updatePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public void removeNametag(@NonNull Player player) { - try { - Set players = Set.of(player.getName()); - - Object team = new ClassInstanceBuilder( - scoreboardTeam - ).withParams( - Map.of( - scoreboard, - scoreboardINST - ), - Map.of( - String.class, - player.getName() - ) - ).build(); - scoreboardTeam_setDisplayName().invoke(team, - createChatComponentText(player.getName()) - ); - - Object removePacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).withParams( - Map.of( - scoreboardTeam, - team - ), - Map.of( - Collection.class, - players - ), - Map.of( - int.class, - 4 - ) - ).build(); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, removePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Set players = Set.of(player.getName()); + + Object team = new ClassInstanceBuilder( + scoreboardTeam + ).withParams( + Map.of( + scoreboard, + scoreboardINST + ), + Map.of( + String.class, + player.getName() + ) + ).build(); + scoreboardTeam_setDisplayName().invoke(team, + createChatComponentText(player.getName()) + ); + + Object removePacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).withParams( + Map.of( + scoreboardTeam, + team + ), + Map.of( + Collection.class, + players + ), + Map.of( + int.class, + 4 + ) + ).build(); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, removePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } } diff --git a/src/com/falchus/lib/minecraft/utils/APIUtils.java b/src/com/falchus/lib/minecraft/utils/APIUtils.java index 61288810..ace9a1d1 100644 --- a/src/com/falchus/lib/minecraft/utils/APIUtils.java +++ b/src/com/falchus/lib/minecraft/utils/APIUtils.java @@ -1,46 +1,45 @@ package com.falchus.lib.minecraft.utils; -import java.util.UUID; - import com.falchus.lib.utils.http.HTTPRequest; import com.google.gson.JsonObject; import com.google.gson.JsonParser; - import lombok.NonNull; import lombok.experimental.UtilityClass; +import java.util.UUID; + @UtilityClass public class APIUtils { - /** - * Gets the UUID of a player. - * - * @return the player's {@link UUID} - */ + /** + * Gets the UUID of a player. + * + * @return the player's {@link UUID} + */ public static UUID getUUID(@NonNull String username) { - String body = HTTPRequest.get("https://api.mojang.com/users/profiles/minecraft/" + username); + String body = HTTPRequest.get("https://api.mojang.com/users/profiles/minecraft/" + username); if (body == null) return null; - JsonObject json = JsonParser.parseString(body).getAsJsonObject(); - String id = json.get("id").getAsString(); - + JsonObject json = JsonParser.parseString(body).getAsJsonObject(); + String id = json.get("id").getAsString(); + String uuid = id.replaceFirst( - "(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w+)", - "$1-$2-$3-$4-$5" + "(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w+)", + "$1-$2-$3-$4-$5" ); return UUID.fromString(uuid); } - + /** * Gets the name of a player by UUID. - * + * * @return the player's username {@link String} - */ + */ public static String getName(@NonNull String uuid) { String body = HTTPRequest.get("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.replace("-", "")); if (body == null) return null; - JsonObject json = JsonParser.parseString(body).getAsJsonObject(); - return json.get("name").getAsString(); + JsonObject json = JsonParser.parseString(body).getAsJsonObject(); + return json.get("name").getAsString(); } } \ No newline at end of file diff --git a/src/com/falchus/lib/minecraft/utils/AdventureUtils.java b/src/com/falchus/lib/minecraft/utils/AdventureUtils.java index 5938f07d..b6cf0ff7 100644 --- a/src/com/falchus/lib/minecraft/utils/AdventureUtils.java +++ b/src/com/falchus/lib/minecraft/utils/AdventureUtils.java @@ -8,11 +8,11 @@ public class AdventureUtils { - public static String toJson(@NonNull Component component) { - return GsonComponentSerializer.gson().serialize(component); - } - - public static TextComponent legacy(@NonNull String input) { - return LegacyComponentSerializer.legacySection().deserialize(input); - } + public static String toJson(@NonNull Component component) { + return GsonComponentSerializer.gson().serialize(component); + } + + public static TextComponent legacy(@NonNull String input) { + return LegacyComponentSerializer.legacySection().deserialize(input); + } } diff --git a/src/com/falchus/lib/minecraft/utils/CloudNet.java b/src/com/falchus/lib/minecraft/utils/CloudNet.java index 4f7acf01..1b4d8254 100644 --- a/src/com/falchus/lib/minecraft/utils/CloudNet.java +++ b/src/com/falchus/lib/minecraft/utils/CloudNet.java @@ -1,9 +1,5 @@ package com.falchus.lib.minecraft.utils; -import java.util.Collection; -import java.util.List; -import java.util.UUID; - import eu.cloudnetservice.driver.document.property.DocProperty; import eu.cloudnetservice.driver.event.EventManager; import eu.cloudnetservice.driver.inject.InjectionLayer; @@ -22,150 +18,154 @@ import lombok.NonNull; import lombok.experimental.UtilityClass; +import java.util.Collection; +import java.util.List; +import java.util.UUID; + @UtilityClass public class CloudNet { - public static final BridgeServiceHelper bridgeServiceHelper = InjectionLayer.ext().instance(BridgeServiceHelper.class); - public static final PlayerManager playerManager = InjectionLayer.ext().instance(ServiceRegistry.class).defaultInstance(PlayerManager.class); - public static final CloudServiceFactory cloudServiceFactory = InjectionLayer.ext().instance(CloudServiceFactory.class); - public static final CloudServiceProvider cloudServiceProvider = InjectionLayer.ext().instance(CloudServiceProvider.class); - public static final ServiceInfoHolder serviceInfoHolder = InjectionLayer.ext().instance(ServiceInfoHolder.class); - public static final EventManager eventManager = InjectionLayer.ext().instance(EventManager.class); - - /** - * Broadcasts a message to all players globally. - */ - public static void broadcastMessage(@NonNull List messages) { - String message = String.join("\n", messages); + public static final BridgeServiceHelper bridgeServiceHelper = InjectionLayer.ext().instance(BridgeServiceHelper.class); + public static final PlayerManager playerManager = InjectionLayer.ext().instance(ServiceRegistry.class).defaultInstance(PlayerManager.class); + public static final CloudServiceFactory cloudServiceFactory = InjectionLayer.ext().instance(CloudServiceFactory.class); + public static final CloudServiceProvider cloudServiceProvider = InjectionLayer.ext().instance(CloudServiceProvider.class); + public static final ServiceInfoHolder serviceInfoHolder = InjectionLayer.ext().instance(ServiceInfoHolder.class); + public static final EventManager eventManager = InjectionLayer.ext().instance(EventManager.class); + + /** + * Broadcasts a message to all players globally. + */ + public static void broadcastMessage(@NonNull List messages) { + String message = String.join("\n", messages); playerManager.globalPlayerExecutor().sendChatMessage(AdventureUtils.legacy(message)); - } - - /** - * Publishes an update for the current service. - */ - public static void publishServiceInfoUpdate() { + } + + /** + * Publishes an update for the current service. + */ + public static void publishServiceInfoUpdate() { serviceInfoHolder.publishServiceInfoUpdate(); - } - - /** - * Creates and starts a new service. - */ - public static void createAndStartService(@NonNull ServiceConfiguration serviceConfig) { - cloudServiceFactory.createCloudServiceAsync(serviceConfig) - .thenAccept(result -> { - if (result.state() == ServiceCreateResult.State.CREATED) { - UUID uuid = result.serviceInfo().serviceId().uniqueId(); - ServiceInfoSnapshot service = cloudServiceProvider.service(uuid); - service.provider().startAsync(); - } - }); - } - - /** - * @return player count for the group - */ - public static int getPlayerCountFromGroup(@NonNull String group) { - return playerManager.groupOnlinePlayers(group).count(); - } - - /** - * @return player count for the task - */ - public static int getPlayerCountFromTask(@NonNull String task) { - return playerManager.taskOnlinePlayers(task).count(); - } - - /** - * @return player count for the service - */ - public static int getPlayerCountFromService(@NonNull String service) { - return getService(service).readProperty(BridgeDocProperties.ONLINE_COUNT); - } - - /** - * @return service by name - */ - public static ServiceInfoSnapshot getService(@NonNull String service) { - return cloudServiceProvider.serviceByName(service); - } - - /** - * @return services by group - */ - public static Collection getServicesByGroup(@NonNull String group) { - return cloudServiceProvider.servicesByGroup(group); - } - - /** - * @return services by task - */ - public static Collection getServicesByTask(@NonNull String task) { - return cloudServiceProvider.servicesByTask(task); - } + } /** - * Sets the "extra" field for the current service. + * Creates and starts a new service. */ - public static void setExtra(@NonNull String newExtra) { - bridgeServiceHelper.extra().set(newExtra); + public static void createAndStartService(@NonNull ServiceConfiguration serviceConfig) { + cloudServiceFactory.createCloudServiceAsync(serviceConfig) + .thenAccept(result -> { + if (result.state() == ServiceCreateResult.State.CREATED) { + UUID uuid = result.serviceInfo().serviceId().uniqueId(); + ServiceInfoSnapshot service = cloudServiceProvider.service(uuid); + service.provider().startAsync(); + } + }); } /** - * Sets the MOTD for the current service. + * @return player count for the group */ - public static void setMotd(@NonNull String newMotd) { - bridgeServiceHelper.motd().set(newMotd); + public static int getPlayerCountFromGroup(@NonNull String group) { + return playerManager.groupOnlinePlayers(group).count(); + } + + /** + * @return player count for the task + */ + public static int getPlayerCountFromTask(@NonNull String task) { + return playerManager.taskOnlinePlayers(task).count(); + } + + /** + * @return player count for the service + */ + public static int getPlayerCountFromService(@NonNull String service) { + return getService(service).readProperty(BridgeDocProperties.ONLINE_COUNT); + } + + /** + * @return service by name + */ + public static ServiceInfoSnapshot getService(@NonNull String service) { + return cloudServiceProvider.serviceByName(service); } - + + /** + * @return services by group + */ + public static Collection getServicesByGroup(@NonNull String group) { + return cloudServiceProvider.servicesByGroup(group); + } + + /** + * @return services by task + */ + public static Collection getServicesByTask(@NonNull String task) { + return cloudServiceProvider.servicesByTask(task); + } + /** * @return the "extra" of the current service */ public static String getExtra() { - return bridgeServiceHelper.extra().get(); + return bridgeServiceHelper.extra().get(); } - + + /** + * Sets the "extra" field for the current service. + */ + public static void setExtra(@NonNull String newExtra) { + bridgeServiceHelper.extra().set(newExtra); + } + /** * @return the "extra" of the given service */ public static String getExtra(@NonNull String service) { - return getService(service).readProperty(BridgeDocProperties.EXTRA); + return getService(service).readProperty(BridgeDocProperties.EXTRA); } - + /** * @return the MOTD of the current service */ public static String getMotd() { return bridgeServiceHelper.motd().get(); } - + + /** + * Sets the MOTD for the current service. + */ + public static void setMotd(@NonNull String newMotd) { + bridgeServiceHelper.motd().set(newMotd); + } + /** * @return the MOTD of the given service */ public static String getMotd(@NonNull String service) { - return getService(service).readProperty(BridgeDocProperties.MOTD); + return getService(service).readProperty(BridgeDocProperties.MOTD); } - + /** * @return the state of the current service */ public static String getState() { - return bridgeServiceHelper.state().get(); + return bridgeServiceHelper.state().get(); } - + /** * @return the state of the given service */ public static String getState(@NonNull String service) { - return getService(service).readProperty(BridgeDocProperties.STATE); + return getService(service).readProperty(BridgeDocProperties.STATE); } - + /** * @return the property of the given service */ public static Object getProperty(@NonNull String service, @NonNull DocProperty property) { - return getService(service).readProperty(property); + return getService(service).readProperty(property); } - + /** * Changes the service state to "ingame" and publishes the update. */ @@ -178,7 +178,7 @@ public static void changeToIngame(boolean autoStartService) { * Changes the service state to "ingame" and publishes the update. */ public static void changeToIngame() { - changeToIngame(true); + changeToIngame(true); } /** @@ -194,32 +194,32 @@ public static void connectPlayerToTask(@NonNull UUID uuid, @NonNull String task, public static void connectPlayerToService(@NonNull UUID uuid, @NonNull String service) { playerManager.playerExecutor(uuid).connect(service); } - + /** * @return {@link PlayerExecutor} by UUID */ public static PlayerExecutor getPlayerExecutor(@NonNull UUID uuid) { - return playerManager.playerExecutor(uuid); + return playerManager.playerExecutor(uuid); } - + /** * Registers a listener. */ public static void registerListener(@NonNull Class listenerClass) { - eventManager.registerListener(listenerClass); + eventManager.registerListener(listenerClass); } - + /** * Registers a listener. */ public static void registerListener(@NonNull Object listener) { - eventManager.registerListener(listener); + eventManager.registerListener(listener); } - + /** * Registers listeners. */ public static void registerListeners(@NonNull Object... listeners) { - eventManager.registerListeners(listeners); + eventManager.registerListeners(listeners); } } diff --git a/src/com/falchus/lib/minecraft/velocity/FalchusLibMinecraftVelocity.java b/src/com/falchus/lib/minecraft/velocity/FalchusLibMinecraftVelocity.java index 14cecd4c..1fbc63eb 100644 --- a/src/com/falchus/lib/minecraft/velocity/FalchusLibMinecraftVelocity.java +++ b/src/com/falchus/lib/minecraft/velocity/FalchusLibMinecraftVelocity.java @@ -33,23 +33,23 @@ public class FalchusLibMinecraftVelocity { final File dataFolder; final File file; final Metrics.Factory metricsFactory; - + @Getter static FalchusLibMinecraftVelocity instance; - + @Inject public FalchusLibMinecraftVelocity(ProxyServer server, Logger logger, @DataDirectory Path dataFolder, Metrics.Factory metricsFactory) { this.server = server; this.logger = logger; this.dataFolder = new File(dataFolder.toFile().getParentFile(), this.getClass().getAnnotation(Plugin.class).name()); this.metricsFactory = metricsFactory; - + try { file = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI()); } catch (URISyntaxException e) { throw new RuntimeException(e); } } - + @Subscribe public void onProxyInitialize(ProxyInitializeEvent event) { instance = this; diff --git a/src/com/falchus/lib/storage/Storage.java b/src/com/falchus/lib/storage/Storage.java index 137e4dc9..a0a21bd4 100644 --- a/src/com/falchus/lib/storage/Storage.java +++ b/src/com/falchus/lib/storage/Storage.java @@ -1,65 +1,65 @@ package com.falchus.lib.storage; +import com.falchus.lib.storage.serializer.Serializer; + import java.io.File; import java.nio.file.Files; import java.nio.file.Path; -import com.falchus.lib.storage.serializer.Serializer; - public class Storage { - private final Serializer serializer; - private final File file; - private final String defaultContent; - - public Storage(Serializer serializer, Path folder, String fileName, String defaultContent) { - this.serializer = serializer; - this.defaultContent = defaultContent; - - try { - Files.createDirectories(folder); - file = folder.resolve(fileName).toFile(); - - if (!file.exists() || file.length() == 0) { - Files.writeString(file.toPath(), defaultContent); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @SuppressWarnings("unchecked") - public void save(T value) { + private final Serializer serializer; + private final File file; + private final String defaultContent; + + public Storage(Serializer serializer, Path folder, String fileName, String defaultContent) { + this.serializer = serializer; + this.defaultContent = defaultContent; + + try { + Files.createDirectories(folder); + file = folder.resolve(fileName).toFile(); + + if (!file.exists() || file.length() == 0) { + Files.writeString(file.toPath(), defaultContent); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @SuppressWarnings("unchecked") + public void save(T value) { + try { + String content = ((Serializer) serializer).serialize(value); + Files.writeString(file.toPath(), content); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @SuppressWarnings("unchecked") + public T load() { + try { + if (!file.exists() || file.length() == 0) { + return ((Serializer) serializer).deserialize(defaultContent); + } + + String content = Files.readString(file.toPath()); + if (content == null || content.isBlank()) { + return ((Serializer) serializer).deserialize(defaultContent); + } + return ((Serializer) serializer).deserialize(content); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public void delete() { try { - String content = ((Serializer) serializer).serialize(value); - Files.writeString(file.toPath(), content); + Files.deleteIfExists(file.toPath()); } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @SuppressWarnings("unchecked") - public T load() { - try { - if (!file.exists() || file.length() == 0) { - return ((Serializer) serializer).deserialize(defaultContent); - } - - String content = Files.readString(file.toPath()); - if (content == null || content.isBlank()) { - return ((Serializer) serializer).deserialize(defaultContent); - } - return ((Serializer) serializer).deserialize(content); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public void delete() { - try { - Files.deleteIfExists(file.toPath()); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + throw new RuntimeException(e); + } + } } diff --git a/src/com/falchus/lib/storage/impl/json/JsonArrayStorage.java b/src/com/falchus/lib/storage/impl/json/JsonArrayStorage.java index 7e4010c5..703a74ee 100644 --- a/src/com/falchus/lib/storage/impl/json/JsonArrayStorage.java +++ b/src/com/falchus/lib/storage/impl/json/JsonArrayStorage.java @@ -1,14 +1,13 @@ package com.falchus.lib.storage.impl.json; -import java.nio.file.Path; - +import com.falchus.lib.storage.serializer.Serializer; import org.json.simple.JSONArray; -import com.falchus.lib.storage.serializer.Serializer; +import java.nio.file.Path; public class JsonArrayStorage extends JsonStorage { - public JsonArrayStorage(Serializer serializer, Path folder, String fileName) { - super(serializer, folder, fileName, new JSONArray().toJSONString()); - } + public JsonArrayStorage(Serializer serializer, Path folder, String fileName) { + super(serializer, folder, fileName, new JSONArray().toJSONString()); + } } diff --git a/src/com/falchus/lib/storage/impl/json/JsonObjectStorage.java b/src/com/falchus/lib/storage/impl/json/JsonObjectStorage.java index 1a13c2df..7a8a8046 100644 --- a/src/com/falchus/lib/storage/impl/json/JsonObjectStorage.java +++ b/src/com/falchus/lib/storage/impl/json/JsonObjectStorage.java @@ -1,14 +1,13 @@ package com.falchus.lib.storage.impl.json; -import java.nio.file.Path; - +import com.falchus.lib.storage.serializer.Serializer; import org.json.simple.JSONObject; -import com.falchus.lib.storage.serializer.Serializer; +import java.nio.file.Path; public class JsonObjectStorage extends JsonStorage { - public JsonObjectStorage(Serializer serializer, Path folder, String fileName) { - super(serializer, folder, fileName, new JSONObject().toJSONString()); - } + public JsonObjectStorage(Serializer serializer, Path folder, String fileName) { + super(serializer, folder, fileName, new JSONObject().toJSONString()); + } } diff --git a/src/com/falchus/lib/storage/impl/json/JsonStorage.java b/src/com/falchus/lib/storage/impl/json/JsonStorage.java index da88405d..63de4365 100644 --- a/src/com/falchus/lib/storage/impl/json/JsonStorage.java +++ b/src/com/falchus/lib/storage/impl/json/JsonStorage.java @@ -1,13 +1,13 @@ package com.falchus.lib.storage.impl.json; -import java.nio.file.Path; - import com.falchus.lib.storage.Storage; import com.falchus.lib.storage.serializer.Serializer; +import java.nio.file.Path; + class JsonStorage extends Storage { - JsonStorage(Serializer serializer, Path folder, String fileName, String defaultContent) { - super(serializer, folder, fileName + ".json", defaultContent); - } + JsonStorage(Serializer serializer, Path folder, String fileName, String defaultContent) { + super(serializer, folder, fileName + ".json", defaultContent); + } } diff --git a/src/com/falchus/lib/storage/serializer/Serializer.java b/src/com/falchus/lib/storage/serializer/Serializer.java index 4f2dc108..906ebc6b 100644 --- a/src/com/falchus/lib/storage/serializer/Serializer.java +++ b/src/com/falchus/lib/storage/serializer/Serializer.java @@ -2,7 +2,7 @@ public interface Serializer { - String serialize(T value); - - T deserialize(String content); + String serialize(T value); + + T deserialize(String content); } diff --git a/src/com/falchus/lib/storage/serializer/json/JsonArraySerializer.java b/src/com/falchus/lib/storage/serializer/json/JsonArraySerializer.java index 9b057201..8cc41175 100644 --- a/src/com/falchus/lib/storage/serializer/json/JsonArraySerializer.java +++ b/src/com/falchus/lib/storage/serializer/json/JsonArraySerializer.java @@ -3,26 +3,26 @@ import org.json.simple.JSONArray; public abstract class JsonArraySerializer extends JsonSerializer { - - @Override - public String serialize(T value) { - return to(value).toJSONString(); - } - - @Override - public T deserialize(String content) { - if (content == null || content.isBlank()) { - return from(new JSONArray()); - } - - try { - Object raw = parser.parse(content); - if (raw instanceof JSONArray json) { - return from(json); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - return from(new JSONArray()); - } + + @Override + public String serialize(T value) { + return to(value).toJSONString(); + } + + @Override + public T deserialize(String content) { + if (content == null || content.isBlank()) { + return from(new JSONArray()); + } + + try { + Object raw = parser.parse(content); + if (raw instanceof JSONArray json) { + return from(json); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + return from(new JSONArray()); + } } diff --git a/src/com/falchus/lib/storage/serializer/json/JsonObjectSerializer.java b/src/com/falchus/lib/storage/serializer/json/JsonObjectSerializer.java index 3c71fc75..457d1c60 100644 --- a/src/com/falchus/lib/storage/serializer/json/JsonObjectSerializer.java +++ b/src/com/falchus/lib/storage/serializer/json/JsonObjectSerializer.java @@ -3,26 +3,26 @@ import org.json.simple.JSONObject; public abstract class JsonObjectSerializer extends JsonSerializer { - - @Override - public String serialize(T value) { - return to(value).toJSONString(); - } - - @Override - public T deserialize(String content) { - if (content == null || content.isBlank()) { - return from(new JSONObject()); - } - - try { - Object raw = parser.parse(content); - if (raw instanceof JSONObject json) { - return from(json); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - return from(new JSONObject()); - } + + @Override + public String serialize(T value) { + return to(value).toJSONString(); + } + + @Override + public T deserialize(String content) { + if (content == null || content.isBlank()) { + return from(new JSONObject()); + } + + try { + Object raw = parser.parse(content); + if (raw instanceof JSONObject json) { + return from(json); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + return from(new JSONObject()); + } } diff --git a/src/com/falchus/lib/storage/serializer/json/JsonSerializer.java b/src/com/falchus/lib/storage/serializer/json/JsonSerializer.java index 9ec88300..781e1ba4 100644 --- a/src/com/falchus/lib/storage/serializer/json/JsonSerializer.java +++ b/src/com/falchus/lib/storage/serializer/json/JsonSerializer.java @@ -1,11 +1,10 @@ package com.falchus.lib.storage.serializer.json; -import org.json.simple.parser.JSONParser; - import com.falchus.lib.interfaces.Mapper; import com.falchus.lib.storage.serializer.Serializer; +import org.json.simple.parser.JSONParser; abstract class JsonSerializer implements Mapper, Serializer { - - final JSONParser parser = new JSONParser(); + + final JSONParser parser = new JSONParser(); } diff --git a/src/com/falchus/lib/task/Task.java b/src/com/falchus/lib/task/Task.java index 93f7ee06..a3fdb792 100644 --- a/src/com/falchus/lib/task/Task.java +++ b/src/com/falchus/lib/task/Task.java @@ -1,105 +1,106 @@ package com.falchus.lib.task; +import lombok.Getter; + import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; -import lombok.Getter; - public abstract class Task implements Runnable { - - private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors()); - private static final ExecutorService worker = Executors.newCachedThreadPool(); - - private static final Map tasks = new ConcurrentHashMap<>(); - private static final Map> taskFutures = new ConcurrentHashMap<>(); - private static final AtomicInteger ids = new AtomicInteger(0); - - @Getter private final int id = ids.incrementAndGet(); - @Getter private boolean ended; - @Getter private int tick; - - @Override - public final void run() { - if (ended) return; - - worker.submit(() -> onRun(tick++)); - } - - public static final Task runTask(Runnable runnable) { - Task task; - if (runnable instanceof Task t) { - task = t; - } else { - task = new Task() { - @Override - public void onRun(int tick) { - runnable.run(); - } - }; - } - return task; - } - - public static final Task runTaskTimer(Runnable runnable, long period, TimeUnit unit) { - return runTaskTimer(runnable, 0, period, unit); - } - - public final T runTaskTimer(long period, TimeUnit unit) { - return runTaskTimer(0, period, unit); - } - - public static final Task runTaskTimer(Runnable runnable, long delay, long period, TimeUnit unit) { - return runTask(runnable).runTaskTimer(delay, period, unit); - } - - @SuppressWarnings("unchecked") - public final T runTaskTimer(long delay, long period, TimeUnit unit) { - ScheduledFuture future = scheduler.scheduleAtFixedRate(this, delay, period, unit); - tasks.put(id, this); - taskFutures.put(id, future); - return (T) this; - } - - public static final Task runTaskLater(Runnable runnable, long delay, TimeUnit unit) { - return runTask(runnable).runTaskLater(delay, unit); - } - - @SuppressWarnings("unchecked") - public final T runTaskLater(long delay, TimeUnit unit) { - ScheduledFuture future = scheduler.schedule(() -> { - run(); - end(); - }, delay, unit); - tasks.put(id, this); - taskFutures.put(id, future); - return (T) this; - } - - public static final void end(int id) { - Task task = tasks.remove(id); - if (task == null) return; - - ScheduledFuture future = taskFutures.remove(id); - if (future != null) { - future.cancel(false); - } - task.end(); - } - - public final void end() { - if (ended) return; - ended = true; - - end(id); - onEnd(); - } - - protected void onRun(int tick) {} - protected void onEnd() {} + + private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors()); + private static final ExecutorService worker = Executors.newCachedThreadPool(); + + private static final Map tasks = new ConcurrentHashMap<>(); + private static final Map> taskFutures = new ConcurrentHashMap<>(); + private static final AtomicInteger ids = new AtomicInteger(0); + + @Getter + private final int id = ids.incrementAndGet(); + @Getter + private boolean ended; + @Getter + private int tick; + + public static final Task runTask(Runnable runnable) { + Task task; + if (runnable instanceof Task t) { + task = t; + } else { + task = new Task() { + @Override + public void onRun(int tick) { + runnable.run(); + } + }; + } + return task; + } + + public static final Task runTaskTimer(Runnable runnable, long period, TimeUnit unit) { + return runTaskTimer(runnable, 0, period, unit); + } + + public static final Task runTaskTimer(Runnable runnable, long delay, long period, TimeUnit unit) { + return runTask(runnable).runTaskTimer(delay, period, unit); + } + + public static final Task runTaskLater(Runnable runnable, long delay, TimeUnit unit) { + return runTask(runnable).runTaskLater(delay, unit); + } + + public static final void end(int id) { + Task task = tasks.remove(id); + if (task == null) return; + + ScheduledFuture future = taskFutures.remove(id); + if (future != null) { + future.cancel(false); + } + task.end(); + } + + @Override + public final void run() { + if (ended) return; + + worker.submit(() -> onRun(tick++)); + } + + public final T runTaskTimer(long period, TimeUnit unit) { + return runTaskTimer(0, period, unit); + } + + @SuppressWarnings("unchecked") + public final T runTaskTimer(long delay, long period, TimeUnit unit) { + ScheduledFuture future = scheduler.scheduleAtFixedRate(this, delay, period, unit); + tasks.put(id, this); + taskFutures.put(id, future); + return (T) this; + } + + @SuppressWarnings("unchecked") + public final T runTaskLater(long delay, TimeUnit unit) { + ScheduledFuture future = scheduler.schedule(() -> { + run(); + end(); + }, delay, unit); + tasks.put(id, this); + taskFutures.put(id, future); + return (T) this; + } + + public final void end() { + if (ended) return; + ended = true; + + end(id); + onEnd(); + } + + protected void onRun(int tick) { + } + + protected void onEnd() { + } } diff --git a/src/com/falchus/lib/task/impl/CountdownTask.java b/src/com/falchus/lib/task/impl/CountdownTask.java index 544d9012..42a1feff 100644 --- a/src/com/falchus/lib/task/impl/CountdownTask.java +++ b/src/com/falchus/lib/task/impl/CountdownTask.java @@ -1,7 +1,6 @@ package com.falchus.lib.task.impl; import com.falchus.lib.task.Task; - import lombok.AllArgsConstructor; import lombok.Getter; @@ -11,18 +10,19 @@ @Getter @AllArgsConstructor public abstract class CountdownTask extends Task { - - private int remaining; - - @Override - public final void onRun(int tick) { - if (remaining <= 0) { - end(); - return; - } - onCountdown(remaining); - remaining--; - } - - protected void onCountdown(int remaining) {} + + private int remaining; + + @Override + public final void onRun(int tick) { + if (remaining <= 0) { + end(); + return; + } + onCountdown(remaining); + remaining--; + } + + protected void onCountdown(int remaining) { + } } diff --git a/src/com/falchus/lib/utils/DiscordWebhook.java b/src/com/falchus/lib/utils/DiscordWebhook.java index bb9c02ea..e1f03435 100644 --- a/src/com/falchus/lib/utils/DiscordWebhook.java +++ b/src/com/falchus/lib/utils/DiscordWebhook.java @@ -1,14 +1,14 @@ package com.falchus.lib.utils; +import lombok.NonNull; +import lombok.experimental.UtilityClass; + import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.concurrent.CompletableFuture; -import lombok.NonNull; -import lombok.experimental.UtilityClass; - /** * @deprecated since 1.0.0, use JDA instead! */ @@ -16,92 +16,92 @@ @Deprecated(since = "1.0.0") public class DiscordWebhook { - public static void sendMessage(@NonNull String message, @NonNull String webhookUrl) { - CompletableFuture.runAsync(() -> { - try { - URL url = new URL(webhookUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestProperty("User-Agent", "Java-DiscordWebhook/1.0"); - connection.setDoOutput(true); - - String payload = "{\"content\":\"" + escapeJson(message) + "\"}"; - - try (OutputStream outputStream = connection.getOutputStream()) { - outputStream.write(payload.getBytes(StandardCharsets.UTF_8)); - outputStream.flush(); - } - - int responseCode = connection.getResponseCode(); - if (responseCode != 204) { - System.err.println(responseCode); - System.err.println(connection.getResponseMessage()); - } - } catch (Exception e) { - e.printStackTrace(); - } - }); - } + public static void sendMessage(@NonNull String message, @NonNull String webhookUrl) { + CompletableFuture.runAsync(() -> { + try { + URL url = new URL(webhookUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setRequestProperty("User-Agent", "Java-DiscordWebhook/1.0"); + connection.setDoOutput(true); + + String payload = "{\"content\":\"" + escapeJson(message) + "\"}"; + + try (OutputStream outputStream = connection.getOutputStream()) { + outputStream.write(payload.getBytes(StandardCharsets.UTF_8)); + outputStream.flush(); + } + + int responseCode = connection.getResponseCode(); + if (responseCode != 204) { + System.err.println(responseCode); + System.err.println(connection.getResponseMessage()); + } + } catch (Exception e) { + e.printStackTrace(); + } + }); + } public static void sendEmbedMessage(String title, String description, int red, int green, int blue, String footerText, String footerImageUrl, String thumbnailUrl, @NonNull String webhookUrl) { - CompletableFuture.runAsync(() -> { - try { - URL url = new URL(webhookUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); - connection.setRequestProperty("User-Agent", "Java-DiscordWebhook/1.0"); - connection.setDoOutput(true); - - int color = (red << 16) + (green << 8) + blue; - - StringBuilder payload = new StringBuilder(); - payload.append("{\"embeds\":[{"); - - if (title != null) { - payload.append("\"title\":\"").append(escapeJson(title)).append("\","); - } - if (description != null) { - payload.append("\"description\":\"").append(escapeJson(description)).append("\","); - } - payload.append("\"color\":").append(color); - - if (footerText != null) { - payload.append(",\"footer\":{\"text\":\"").append(escapeJson(footerText)).append("\""); - if (footerImageUrl != null) { - payload.append(",\"icon_url\":\"").append(footerImageUrl).append("\""); - } - payload.append("}"); - } - - if (thumbnailUrl != null) { - payload.append(",\"thumbnail\":{\"url\":\"").append(thumbnailUrl).append("\"}"); - } - - payload.append("}]}"); - - try (OutputStream outputStream = connection.getOutputStream()) { - outputStream.write(payload.toString().getBytes(StandardCharsets.UTF_8)); - outputStream.flush(); - } - - int responseCode = connection.getResponseCode(); - if (responseCode != 204) { - System.err.println(responseCode); - System.err.println(connection.getResponseMessage()); - } - } catch (Exception e) { - e.printStackTrace(); - } - }); + CompletableFuture.runAsync(() -> { + try { + URL url = new URL(webhookUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); + connection.setRequestProperty("User-Agent", "Java-DiscordWebhook/1.0"); + connection.setDoOutput(true); + + int color = (red << 16) + (green << 8) + blue; + + StringBuilder payload = new StringBuilder(); + payload.append("{\"embeds\":[{"); + + if (title != null) { + payload.append("\"title\":\"").append(escapeJson(title)).append("\","); + } + if (description != null) { + payload.append("\"description\":\"").append(escapeJson(description)).append("\","); + } + payload.append("\"color\":").append(color); + + if (footerText != null) { + payload.append(",\"footer\":{\"text\":\"").append(escapeJson(footerText)).append("\""); + if (footerImageUrl != null) { + payload.append(",\"icon_url\":\"").append(footerImageUrl).append("\""); + } + payload.append("}"); + } + + if (thumbnailUrl != null) { + payload.append(",\"thumbnail\":{\"url\":\"").append(thumbnailUrl).append("\"}"); + } + + payload.append("}]}"); + + try (OutputStream outputStream = connection.getOutputStream()) { + outputStream.write(payload.toString().getBytes(StandardCharsets.UTF_8)); + outputStream.flush(); + } + + int responseCode = connection.getResponseCode(); + if (responseCode != 204) { + System.err.println(responseCode); + System.err.println(connection.getResponseMessage()); + } + } catch (Exception e) { + e.printStackTrace(); + } + }); } private static String escapeJson(@NonNull String text) { return text.replace("\\", "\\\\") - .replace("\"", "\\\"") - .replace("\n", "\\n"); + .replace("\"", "\\\"") + .replace("\n", "\\n"); } } \ No newline at end of file diff --git a/src/com/falchus/lib/utils/FastRandom.java b/src/com/falchus/lib/utils/FastRandom.java index 929547c8..bec3634d 100644 --- a/src/com/falchus/lib/utils/FastRandom.java +++ b/src/com/falchus/lib/utils/FastRandom.java @@ -1,85 +1,84 @@ package com.falchus.lib.utils; -import java.util.Random; +import lombok.AllArgsConstructor; import javax.annotation.concurrent.ThreadSafe; - -import lombok.AllArgsConstructor; +import java.util.Random; /** - * Implementation of George Marsaglia's elegant Xorshift random generator which is + * Implementation of George Marsaglia's elegant Xorshift random generator which is * 30% faster and better quality than the built-in java.util.random see also see * http://www.javamex.com/tutorials/random_numbers/xorshift.shtml */ @AllArgsConstructor @ThreadSafe // The fast random can be used with multiple threads public class FastRandom extends Random implements Cloneable { - + private static final long serialVersionUID = 1L; - protected long seed; + protected long seed; + + /** + * Creates a new pseudo random number generator. The seed is initialized to the + * current time, as if by setSeed(System.currentTimeMillis());. + */ + public FastRandom() { + this(System.nanoTime()); + } - /** - * Creates a new pseudo random number generator. The seed is initialized to the - * current time, as if by setSeed(System.currentTimeMillis());. - */ - public FastRandom() { - this(System.nanoTime()); - } + /** + * Returns the current state of the seed, can be used to clone the object + * + * @returns the current seed + */ + public synchronized long getSeed() { + return seed; + } - /** - * Returns the current state of the seed, can be used to clone the object - * - * @returns the current seed - */ - public synchronized long getSeed() { - return seed; - } + /** + * Sets the seed for this pseudo random number generator. As described above, + * two instances of the same random class, starting with the same seed, produce + * the same results, if the same methods are called. + * + * @param seed the new seed + */ + public synchronized void setSeed(long seed) { + this.seed = seed; + super.setSeed(seed); + } - /** - * Sets the seed for this pseudo random number generator. As described above, - * two instances of the same random class, starting with the same seed, produce - * the same results, if the same methods are called. - * - * @param seed the new seed - */ - public synchronized void setSeed(long seed) { - this.seed = seed; - super.setSeed(seed); - } + /** + * Sets the specified seed value from the specified int[] + * + * @param array + */ + synchronized public void setSeed(int[] array) { + if (array.length == 0) + throw new IllegalArgumentException("Array length must be greater than zero"); + setSeed(array.hashCode()); + } - /** - * Returns an XSRandom object with the same state as the original - */ - public FastRandom clone() { - return new FastRandom(getSeed()); - } + /** + * Returns an XSRandom object with the same state as the original + */ + public FastRandom clone() { + return new FastRandom(getSeed()); + } - /** - * Implementation of George Marsaglia's elegant Xorshift random generator 30% - * faster and better quality than the built-in java.util.random see also see - * http://www.javamex.com/tutorials/random_numbers/xorshift.shtml - */ - @Override - protected int next(int nbits) { - long x = seed; - x ^= (x << 21); - x ^= (x >>> 35); - x ^= (x << 4); - seed = x; - x &= ((1L << nbits) - 1); - - return (int) x; - } + /** + * Implementation of George Marsaglia's elegant Xorshift random generator 30% + * faster and better quality than the built-in java.util.random see also see + * http://www.javamex.com/tutorials/random_numbers/xorshift.shtml + */ + @Override + protected int next(int nbits) { + long x = seed; + x ^= (x << 21); + x ^= (x >>> 35); + x ^= (x << 4); + seed = x; + x &= ((1L << nbits) - 1); - /** - * Sets the specified seed value from the specified int[] - * - * @param array - */ - synchronized public void setSeed(int[] array) { - if (array.length == 0) - throw new IllegalArgumentException("Array length must be greater than zero"); - setSeed(array.hashCode()); - } + return (int) x; + } } \ No newline at end of file diff --git a/src/com/falchus/lib/utils/FileUtils.java b/src/com/falchus/lib/utils/FileUtils.java index 297e6505..5969100d 100644 --- a/src/com/falchus/lib/utils/FileUtils.java +++ b/src/com/falchus/lib/utils/FileUtils.java @@ -1,23 +1,23 @@ package com.falchus.lib.utils; -import java.io.File; - import lombok.experimental.UtilityClass; +import java.io.File; + @UtilityClass public class FileUtils { - public static void deleteFolder(File folder) { - File[] files = folder.listFiles(); - if (files != null) { - for (File file : files) { - if (file.isDirectory()) { - deleteFolder(file); - } else { - file.delete(); - } - } - } - folder.delete(); - } + public static void deleteFolder(File folder) { + File[] files = folder.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isDirectory()) { + deleteFolder(file); + } else { + file.delete(); + } + } + } + folder.delete(); + } } diff --git a/src/com/falchus/lib/utils/MySQL.java b/src/com/falchus/lib/utils/MySQL.java index 0b64a505..f6ca08ef 100644 --- a/src/com/falchus/lib/utils/MySQL.java +++ b/src/com/falchus/lib/utils/MySQL.java @@ -1,72 +1,76 @@ package com.falchus.lib.utils; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - @RequiredArgsConstructor public class MySQL { - @NonNull private final String host; - private final int port; - @NonNull private final String database; - @NonNull private final String username; - private final String password; - + @NonNull + private final String host; + private final int port; + @NonNull + private final String database; + @NonNull + private final String username; + private final String password; + private final ThreadLocal connection = new ThreadLocal<>(); - - /** - * Establishes a new connection if none is currently open. - * - * @throws SQLException - */ - public void connect() throws SQLException { - if (isConnected()) return; - String url = "jdbc:mysql://" + host + ":" + port + "/" + database - + "?useSSL=false&autoReconnect=true&characterEncoding=UTF-8&useUnicode=true"; - Connection connection = (password == null) - ? DriverManager.getConnection(url, username, "") - : DriverManager.getConnection(url, username, password); - this.connection.set(connection); - } - - /** - * Checks whether the connection is active and not closed. - * - * @return true if a valid connection is open - */ - public boolean isConnected() { - try { - Connection connection = this.connection.get(); - return connection != null && !connection.isClosed(); - } catch (SQLException e) { - return false; - } - } - - /** - * Closes the current connection if it exists. - */ - public void disconnect() { - Connection connection = this.connection.get(); - if (connection != null) { - try { - connection.close(); - } catch (SQLException ignored) {} - this.connection.remove(); - } - } - - /** - * Returns the active connection, reconnecting if necessary. - * - * @return an open {@link Connection} instance (may be newly created) - * @throws SQLException - */ + /** + * Establishes a new connection if none is currently open. + * + * @throws SQLException + */ + public void connect() throws SQLException { + if (isConnected()) return; + String url = "jdbc:mysql://" + host + ":" + port + "/" + database + + "?useSSL=false&autoReconnect=true&characterEncoding=UTF-8&useUnicode=true"; + + Connection connection = (password == null) + ? DriverManager.getConnection(url, username, "") + : DriverManager.getConnection(url, username, password); + this.connection.set(connection); + } + + /** + * Checks whether the connection is active and not closed. + * + * @return true if a valid connection is open + */ + public boolean isConnected() { + try { + Connection connection = this.connection.get(); + return connection != null && !connection.isClosed(); + } catch (SQLException e) { + return false; + } + } + + /** + * Closes the current connection if it exists. + */ + public void disconnect() { + Connection connection = this.connection.get(); + if (connection != null) { + try { + connection.close(); + } catch (SQLException ignored) { + } + this.connection.remove(); + } + } + + /** + * Returns the active connection, reconnecting if necessary. + * + * @return an open {@link Connection} instance (may be newly created) + * @throws SQLException + */ public Connection getConnection() throws SQLException { if (!isConnected()) { connect(); diff --git a/src/com/falchus/lib/utils/VPNApi.java b/src/com/falchus/lib/utils/VPNApi.java index e7c1a733..c43dd137 100644 --- a/src/com/falchus/lib/utils/VPNApi.java +++ b/src/com/falchus/lib/utils/VPNApi.java @@ -3,31 +3,30 @@ import com.falchus.lib.utils.http.HTTPRequest; import com.google.gson.JsonObject; import com.google.gson.JsonParser; - import lombok.NonNull; import lombok.experimental.UtilityClass; @UtilityClass public class VPNApi { - /** - * Checks if the given IP is a VPN. - * via vpnapi.io - * - * @return {@code true} if it is, {@code false} otherwise. - */ - public static boolean isVPN(@NonNull String ip, String apiKey) { - String url = "https://vpnapi.io/api/" + ip; - if (apiKey != null && !apiKey.isEmpty()) { - url += "?key=" + apiKey; - } - - String body = HTTPRequest.get(url); - if (body == null) return false; - - JsonObject json = JsonParser.parseString(body).getAsJsonObject(); - return json.has("security") && - json.getAsJsonObject("security").has("vpn") && - json.getAsJsonObject("security").get("vpn").getAsBoolean(); - } + /** + * Checks if the given IP is a VPN. + * via vpnapi.io + * + * @return {@code true} if it is, {@code false} otherwise. + */ + public static boolean isVPN(@NonNull String ip, String apiKey) { + String url = "https://vpnapi.io/api/" + ip; + if (apiKey != null && !apiKey.isEmpty()) { + url += "?key=" + apiKey; + } + + String body = HTTPRequest.get(url); + if (body == null) return false; + + JsonObject json = JsonParser.parseString(body).getAsJsonObject(); + return json.has("security") && + json.getAsJsonObject("security").has("vpn") && + json.getAsJsonObject("security").get("vpn").getAsBoolean(); + } } diff --git a/src/com/falchus/lib/utils/builder/ClassInstanceBuilder.java b/src/com/falchus/lib/utils/builder/ClassInstanceBuilder.java index b3819e9c..a451a51b 100644 --- a/src/com/falchus/lib/utils/builder/ClassInstanceBuilder.java +++ b/src/com/falchus/lib/utils/builder/ClassInstanceBuilder.java @@ -1,87 +1,86 @@ package com.falchus.lib.utils.builder; -import java.lang.reflect.Constructor; -import java.util.List; -import java.util.Map; -import java.util.Set; - import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.falchus.lib.utils.reflection.ReflectionUtils; - import lombok.Getter; import lombok.NonNull; +import java.lang.reflect.Constructor; +import java.util.List; +import java.util.Map; +import java.util.Set; + @Getter public class ClassInstanceBuilder { - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - private Class clazz; - private Class[] parents = new Class[0]; - private Object[] children = new Object[0]; - - /** - * Creates a new {@link ClassInstanceBuilder} by class. - */ - public ClassInstanceBuilder(@NonNull Class clazz) { - this.clazz = clazz; - } - - /** - * Creates a new {@link ClassInstanceBuilder} by class name. - */ - public ClassInstanceBuilder(@NonNull String name) { - this.clazz = ReflectionUtils.getClass(name); - } - - /** - * Creates a new {@link ClassInstanceBuilder} by first class. - */ - public ClassInstanceBuilder(@NonNull String... names) { - this.clazz = ReflectionUtils.getFirstClass( - names - ); - } - - /** - * Sets constructor parameters for the class. - */ - @SafeVarargs - public final ClassInstanceBuilder withParams(@NonNull Map, Object>... params) { - parents = new Class[params.length]; - children = new Object[params.length]; - - for (int i = 0; i < params.length; i++) { - Map, Object> map = params[i]; - if (map.size() != 1) { - throw new IllegalArgumentException("Each map must contain exactly one entry: {Class -> value}"); - } - - Map.Entry, Object> entry = map.entrySet().iterator().next(); - parents[i] = entry.getKey(); - children[i] = entry.getValue(); - } - return this; - } - - /** - * Builds and returns the final class instance. - */ - public Object build() { - if (clazz == null) { - throw new IllegalStateException("Class must be set"); - } - - try { - Constructor ctor = ReflectionUtils.getFirstConstructor(clazz, - Set.of( - List.of(parents) - ) - ); - return ctor.newInstance( - children - ); - } catch (Exception e) { + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + private Class clazz; + private Class[] parents = new Class[0]; + private Object[] children = new Object[0]; + + /** + * Creates a new {@link ClassInstanceBuilder} by class. + */ + public ClassInstanceBuilder(@NonNull Class clazz) { + this.clazz = clazz; + } + + /** + * Creates a new {@link ClassInstanceBuilder} by class name. + */ + public ClassInstanceBuilder(@NonNull String name) { + this.clazz = ReflectionUtils.getClass(name); + } + + /** + * Creates a new {@link ClassInstanceBuilder} by first class. + */ + public ClassInstanceBuilder(@NonNull String... names) { + this.clazz = ReflectionUtils.getFirstClass( + names + ); + } + + /** + * Sets constructor parameters for the class. + */ + @SafeVarargs + public final ClassInstanceBuilder withParams(@NonNull Map, Object>... params) { + parents = new Class[params.length]; + children = new Object[params.length]; + + for (int i = 0; i < params.length; i++) { + Map, Object> map = params[i]; + if (map.size() != 1) { + throw new IllegalArgumentException("Each map must contain exactly one entry: {Class -> value}"); + } + + Map.Entry, Object> entry = map.entrySet().iterator().next(); + parents[i] = entry.getKey(); + children[i] = entry.getValue(); + } + return this; + } + + /** + * Builds and returns the final class instance. + */ + public Object build() { + if (clazz == null) { + throw new IllegalStateException("Class must be set"); + } + + try { + Constructor ctor = ReflectionUtils.getFirstConstructor(clazz, + Set.of( + List.of(parents) + ) + ); + return ctor.newInstance( + children + ); + } catch (Exception e) { throw new RuntimeException("Failed to create class instance: " + clazz.getName(), e); } - } + } } diff --git a/src/com/falchus/lib/utils/builder/HTTPServerBuilder.java b/src/com/falchus/lib/utils/builder/HTTPServerBuilder.java index 42c3a31f..eaf6feb7 100644 --- a/src/com/falchus/lib/utils/builder/HTTPServerBuilder.java +++ b/src/com/falchus/lib/utils/builder/HTTPServerBuilder.java @@ -1,5 +1,10 @@ package com.falchus.lib.utils.builder; +import com.falchus.lib.utils.http.HTTPServer; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpServer; +import lombok.NonNull; + import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.InetSocketAddress; @@ -8,23 +13,17 @@ import java.util.Map; import java.util.function.BiConsumer; -import com.falchus.lib.utils.http.HTTPServer; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpServer; - -import lombok.NonNull; - public class HTTPServerBuilder { - - private int port = 8080; + private final Map<@NonNull String, @NonNull BiConsumer<@NonNull HttpExchange, @NonNull Map>> routes = new HashMap<>(); + private int port = 8080; private BiConsumer<@NonNull HttpExchange, @NonNull Map> defaultHandler; - + public HTTPServerBuilder port(int port) { - this.port = port; - return this; + this.port = port; + return this; } - + /** * Adds a route. */ @@ -32,7 +31,7 @@ public HTTPServerBuilder route(@NonNull String path, @NonNull BiConsumer parseQuery(String query) { Map map = new HashMap<>(); diff --git a/src/com/falchus/lib/utils/http/HTTPRequest.java b/src/com/falchus/lib/utils/http/HTTPRequest.java index aa3fc407..98952a3f 100644 --- a/src/com/falchus/lib/utils/http/HTTPRequest.java +++ b/src/com/falchus/lib/utils/http/HTTPRequest.java @@ -1,35 +1,35 @@ package com.falchus.lib.utils.http; +import lombok.NonNull; +import lombok.experimental.UtilityClass; + import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; -import lombok.NonNull; -import lombok.experimental.UtilityClass; - @UtilityClass public class HTTPRequest { - private static final HttpClient client = HttpClient.newHttpClient(); - - /** - * @return the response body as a {@link String}, or {@code null} - */ - public static String get(@NonNull String url) { - try { - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(url)) - .GET() - .build(); - + private static final HttpClient client = HttpClient.newHttpClient(); + + /** + * @return the response body as a {@link String}, or {@code null} + */ + public static String get(@NonNull String url) { + try { + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(url)) + .GET() + .build(); + HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() != 200) return null; - + return response.body(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } } diff --git a/src/com/falchus/lib/utils/http/HTTPServer.java b/src/com/falchus/lib/utils/http/HTTPServer.java index f97ecd79..24401ba4 100644 --- a/src/com/falchus/lib/utils/http/HTTPServer.java +++ b/src/com/falchus/lib/utils/http/HTTPServer.java @@ -1,44 +1,37 @@ package com.falchus.lib.utils.http; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Map; -import java.util.function.BiConsumer; - import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpServer; - import lombok.AllArgsConstructor; import lombok.NonNull; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Map; +import java.util.function.BiConsumer; + @AllArgsConstructor public class HTTPServer { - @NonNull private final HttpServer server; - @NonNull private final Map>> routes; - - public void start() { - server.start(); - } - - public void stop(int delay) { - server.stop(delay); - } - - /** - * Sends a plain text response to the client. - */ + @NonNull + private final HttpServer server; + @NonNull + private final Map>> routes; + + /** + * Sends a plain text response to the client. + */ public static void sendText(@NonNull HttpExchange exchange, @NonNull String text, int statusCode) { sendResponse(exchange, text, statusCode, "text/plain; charset=UTF-8"); } - + /** * Sends a JSON response to the client. */ public static void sendJson(@NonNull HttpExchange exchange, @NonNull String json, int statusCode) { sendResponse(exchange, json, statusCode, "application/json; charset=UTF-8"); } - + private static void sendResponse(@NonNull HttpExchange exchange, @NonNull String content, int statusCode, @NonNull String contentType) { try { byte[] bytes = content.getBytes("UTF-8"); @@ -52,4 +45,12 @@ private static void sendResponse(@NonNull HttpExchange exchange, @NonNull String e.printStackTrace(); } } + + public void start() { + server.start(); + } + + public void stop(int delay) { + server.stop(delay); + } } diff --git a/src/com/falchus/lib/utils/reflection/Dummy.java b/src/com/falchus/lib/utils/reflection/Dummy.java index 3fd6a945..3dbbfe0c 100644 --- a/src/com/falchus/lib/utils/reflection/Dummy.java +++ b/src/com/falchus/lib/utils/reflection/Dummy.java @@ -2,7 +2,8 @@ public final class Dummy { - public static final Dummy instance = new Dummy(); - - private Dummy() {} + public static final Dummy instance = new Dummy(); + + private Dummy() { + } } diff --git a/src/com/falchus/lib/utils/reflection/ReflectionUtils.java b/src/com/falchus/lib/utils/reflection/ReflectionUtils.java index 245d9406..3a0658ce 100644 --- a/src/com/falchus/lib/utils/reflection/ReflectionUtils.java +++ b/src/com/falchus/lib/utils/reflection/ReflectionUtils.java @@ -1,5 +1,12 @@ package com.falchus.lib.utils.reflection; +import com.falchus.lib.utils.reflection.keys.ClassKey; +import com.falchus.lib.utils.reflection.keys.ConstructorKey; +import com.falchus.lib.utils.reflection.keys.FieldKey; +import com.falchus.lib.utils.reflection.keys.MethodKey; +import lombok.NonNull; +import lombok.experimental.UtilityClass; + import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -9,126 +16,124 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import com.falchus.lib.utils.reflection.keys.*; - -import lombok.NonNull; -import lombok.experimental.UtilityClass; - @UtilityClass public class ReflectionUtils { - - private final Map>> classes = new ConcurrentHashMap<>(); - private final Map>> firstClasses = new ConcurrentHashMap<>(); - - private final Map> fields = new ConcurrentHashMap<>(); - private final Map> firstFields = new ConcurrentHashMap<>(); - private final Map> firstFieldsClasses = new ConcurrentHashMap<>(); - - private final Map> methods = new ConcurrentHashMap<>(); - private final Map> firstMethods = new ConcurrentHashMap<>(); - private final Map> firstMethodsClasses = new ConcurrentHashMap<>(); - - private final Map>> constructors = new ConcurrentHashMap<>(); - private final Map>> firstConstructors = new ConcurrentHashMap<>(); - private final Map>> firstConstructorsClasses = new ConcurrentHashMap<>(); + + private final Map>> classes = new ConcurrentHashMap<>(); + private final Map>> firstClasses = new ConcurrentHashMap<>(); + + private final Map> fields = new ConcurrentHashMap<>(); + private final Map> firstFields = new ConcurrentHashMap<>(); + private final Map> firstFieldsClasses = new ConcurrentHashMap<>(); + + private final Map> methods = new ConcurrentHashMap<>(); + private final Map> firstMethods = new ConcurrentHashMap<>(); + private final Map> firstMethodsClasses = new ConcurrentHashMap<>(); + + private final Map>> constructors = new ConcurrentHashMap<>(); + private final Map>> firstConstructors = new ConcurrentHashMap<>(); + private final Map>> firstConstructorsClasses = new ConcurrentHashMap<>(); public static Class getClass(@NonNull String name) { - return classes.computeIfAbsent(new ClassKey(name), k -> { + return classes.computeIfAbsent(new ClassKey(name), k -> { try { return Optional.of(Class.forName(name)); } catch (ClassNotFoundException e) { - return Optional.empty(); + return Optional.empty(); } - }).orElseThrow(() -> - new RuntimeException() - ); + }).orElseThrow(() -> + new RuntimeException() + ); } - + public static Class getFirstClass(@NonNull String... names) { - return firstClasses.computeIfAbsent(new ClassKey(names), k -> { + return firstClasses.computeIfAbsent(new ClassKey(names), k -> { for (String name : names) { - Class found = getClass(name); - if (found != null) { - return Optional.of(found); - } + Class found = getClass(name); + if (found != null) { + return Optional.of(found); + } } return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the classes exist: " + String.join(", ", names)) - ); + }).orElseThrow(() -> + new RuntimeException("None of the classes exist: " + String.join(", ", names)) + ); } - + public static Field getField(@NonNull Class clazz, @NonNull String name) { - return fields.computeIfAbsent(new FieldKey(clazz, name), k -> { - Class current = clazz; - - while (current != null) { - try { - Field field = current.getField(name); - field.setAccessible(true); - return Optional.of(field); - } catch (NoSuchFieldException ignored) {} - - try { - Field field = current.getDeclaredField(name); - field.setAccessible(true); - return Optional.of(field); - } catch (NoSuchFieldException ignored) {} - - current = current.getSuperclass(); - } - return Optional.empty(); - }).orElse(null); + return fields.computeIfAbsent(new FieldKey(clazz, name), k -> { + Class current = clazz; + + while (current != null) { + try { + Field field = current.getField(name); + field.setAccessible(true); + return Optional.of(field); + } catch (NoSuchFieldException ignored) { + } + + try { + Field field = current.getDeclaredField(name); + field.setAccessible(true); + return Optional.of(field); + } catch (NoSuchFieldException ignored) { + } + + current = current.getSuperclass(); + } + return Optional.empty(); + }).orElse(null); } - + public static Field getField(@NonNull Object instance, @NonNull String name) { - return getField(instance.getClass(), name); + return getField(instance.getClass(), name); } - + public static Field getFirstField(@NonNull Class clazz, @NonNull String... names) { - return firstFields.computeIfAbsent(new FieldKey(clazz, names), k -> { + return firstFields.computeIfAbsent(new FieldKey(clazz, names), k -> { for (String name : names) { Field found = getField(clazz, name); if (found != null) { - return Optional.of(found); + return Optional.of(found); } } return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the fields exist: " + String.join(", ", names)) - ); + }).orElseThrow(() -> + new RuntimeException("None of the fields exist: " + String.join(", ", names)) + ); } - + public static Field getFirstField(@NonNull Object instance, @NonNull String... names) { return getFirstField(instance.getClass(), names); } - + public static Field getFirstField(@NonNull Set> classes, @NonNull String... names) { - return firstFieldsClasses.computeIfAbsent(new FieldKey(classes, names), k -> { - for (Class clazz : classes) { - try { - return Optional.of(getFirstField(clazz, names)); - } catch (RuntimeException ignored) {} - } - return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the fields exist in classes: " + classes + " - " + String.join(", ", names)) - ); + return firstFieldsClasses.computeIfAbsent(new FieldKey(classes, names), k -> { + for (Class clazz : classes) { + try { + return Optional.of(getFirstField(clazz, names)); + } catch (RuntimeException ignored) { + } + } + return Optional.empty(); + }).orElseThrow(() -> + new RuntimeException("None of the fields exist in classes: " + classes + " - " + String.join(", ", names)) + ); } - + @SuppressWarnings("unchecked") - public static T getFieldValue(Object instance, @NonNull Field field) { - try { - return (T) field.get(instance); - } catch (Exception e) { - throw new RuntimeException(e); - } + public static T getFieldValue(Object instance, @NonNull Field field) { + try { + return (T) field.get(instance); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public static T getFieldValue(@NonNull Field field) { + return getFieldValue(null, field); } - - public static T getFieldValue(@NonNull Field field) { - return getFieldValue(null, field); - } - + public static void setField(Object instance, @NonNull Field field, Object value) { try { field.set(instance, value); @@ -136,7 +141,7 @@ public static void setField(Object instance, @NonNull Field field, Object value) throw new RuntimeException(e); } } - + public static void setField(Object instance, @NonNull String name, Object value) { try { setField(instance, getField(instance.getClass(), name), value); @@ -144,11 +149,11 @@ public static void setField(Object instance, @NonNull String name, Object value) throw new RuntimeException(e); } } - + public static void setField(@NonNull Field field, Object value) { - setField(null, field, value); + setField(null, field, value); } - + public static void setField(@NonNull Class clazz, @NonNull String name, Object value) { try { setField(getField(clazz, name), value); @@ -156,54 +161,57 @@ public static void setField(@NonNull Class clazz, @NonNull String name, Objec throw new RuntimeException(e); } } - + public static void setFirstField(Object instance, Object value, @NonNull String... names) { - setField(instance, getFirstField(instance, names), value); + setField(instance, getFirstField(instance, names), value); } - + public static void setFirstField(@NonNull Class clazz, Object value, @NonNull String... names) { - setField(getFirstField(clazz, names), value); + setField(getFirstField(clazz, names), value); } - + public static void setFirstField(Object instance, @NonNull Set> classes, Object value, @NonNull String... names) { - for (Class clazz : classes) { - try { - setField(instance, getFirstField(clazz, names), value); - return; - } catch (RuntimeException ignored) {} - } + for (Class clazz : classes) { + try { + setField(instance, getFirstField(clazz, names), value); + return; + } catch (RuntimeException ignored) { + } + } throw new RuntimeException("None of the fields exist in classes: " + classes + " - " + String.join(", ", names)); } - + public static Method getMethod(@NonNull Class clazz, @NonNull String name, Class... params) { - return methods.computeIfAbsent(new MethodKey(clazz, name, params), k -> { - Class current = clazz; - - while (current != null) { + return methods.computeIfAbsent(new MethodKey(clazz, name, params), k -> { + Class current = clazz; + + while (current != null) { try { Method method = current.getMethod(name, params); method.setAccessible(true); return Optional.of(method); - } catch (NoSuchMethodException ignored) {} - + } catch (NoSuchMethodException ignored) { + } + try { Method method = current.getDeclaredMethod(name, params); method.setAccessible(true); return Optional.of(method); - } catch (NoSuchMethodException ignored) {} - - current = current.getSuperclass(); - } - return Optional.empty(); - }).orElse(null); + } catch (NoSuchMethodException ignored) { + } + + current = current.getSuperclass(); + } + return Optional.empty(); + }).orElse(null); } - + public static Method getMethod(@NonNull Object instance, @NonNull String name, Class... params) { - return getMethod(instance.getClass(), name, params); + return getMethod(instance.getClass(), name, params); } - + public static Method getFirstMethod(@NonNull Class clazz, List> params, @NonNull String... names) { - return firstMethods.computeIfAbsent(new MethodKey(clazz, params, names), k -> { + return firstMethods.computeIfAbsent(new MethodKey(clazz, params, names), k -> { for (String name : names) { Method found = getMethod(clazz, name, params.toArray(new Class[0])); if (found != null) { @@ -211,74 +219,76 @@ public static Method getFirstMethod(@NonNull Class clazz, List> para } } return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the methods exist: " + String.join(", ", names)) - ); + }).orElseThrow(() -> + new RuntimeException("None of the methods exist: " + String.join(", ", names)) + ); } - + public static Method getFirstMethod(@NonNull Object instance, List> params, @NonNull String... names) { - return getFirstMethod(instance.getClass(), params, names); + return getFirstMethod(instance.getClass(), params, names); } - + public static Method getFirstMethod(@NonNull Set> classes, List> params, @NonNull String... names) { - return firstMethodsClasses.computeIfAbsent(new MethodKey(classes, params, names), k -> { - for (Class clazz : classes) { - try { - return Optional.of(getFirstMethod(clazz, params, names)); - } catch (RuntimeException ignored) {} - } - return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the methods exist in classes: " + classes + " - " + String.join(", ", names)) - ); + return firstMethodsClasses.computeIfAbsent(new MethodKey(classes, params, names), k -> { + for (Class clazz : classes) { + try { + return Optional.of(getFirstMethod(clazz, params, names)); + } catch (RuntimeException ignored) { + } + } + return Optional.empty(); + }).orElseThrow(() -> + new RuntimeException("None of the methods exist in classes: " + classes + " - " + String.join(", ", names)) + ); } - + public static Constructor getConstructor(@NonNull Class clazz, Class... params) { - return constructors.computeIfAbsent(new ConstructorKey(clazz, params), k -> { + return constructors.computeIfAbsent(new ConstructorKey(clazz, params), k -> { try { Constructor ctor = clazz.getDeclaredConstructor(params); ctor.setAccessible(true); return Optional.of(ctor); } catch (NoSuchMethodException e) { - return Optional.empty(); + return Optional.empty(); } - }).orElseThrow(() -> - new RuntimeException() - ); + }).orElseThrow(() -> + new RuntimeException() + ); } - + public static Constructor getConstructor(@NonNull Object instance, Class... params) { - return getConstructor(instance.getClass(), params); + return getConstructor(instance.getClass(), params); } - + public static Constructor getFirstConstructor(@NonNull Class clazz, Set>> params) { - return firstConstructors.computeIfAbsent(new ConstructorKey(clazz, params), k -> { + return firstConstructors.computeIfAbsent(new ConstructorKey(clazz, params), k -> { for (List> list : params) { - Constructor found = getConstructor(clazz, list.toArray(new Class[0])); + Constructor found = getConstructor(clazz, list.toArray(new Class[0])); if (found != null) { return Optional.of(found); } } return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("No matching constructor found for class: " + clazz.getName()) - ); + }).orElseThrow(() -> + new RuntimeException("No matching constructor found for class: " + clazz.getName()) + ); } - + public static Constructor getFirstConstructor(@NonNull Object instance, Set>> params) { - return getFirstConstructor(instance.getClass(), params); + return getFirstConstructor(instance.getClass(), params); } - + public static Constructor getFirstConstructor(@NonNull Set> classes, Set>> params) { - return firstConstructorsClasses.computeIfAbsent(new ConstructorKey(classes, params), k -> { - for (Class clazz : classes) { - try { - return Optional.of(getFirstConstructor(clazz, params)); - } catch (RuntimeException ignored) {} - } - return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("No matching constructor found for classes: " + classes) - ); + return firstConstructorsClasses.computeIfAbsent(new ConstructorKey(classes, params), k -> { + for (Class clazz : classes) { + try { + return Optional.of(getFirstConstructor(clazz, params)); + } catch (RuntimeException ignored) { + } + } + return Optional.empty(); + }).orElseThrow(() -> + new RuntimeException("No matching constructor found for classes: " + classes) + ); } } diff --git a/src/com/falchus/lib/utils/reflection/keys/ClassKey.java b/src/com/falchus/lib/utils/reflection/keys/ClassKey.java index cad73826..f1fea4e1 100644 --- a/src/com/falchus/lib/utils/reflection/keys/ClassKey.java +++ b/src/com/falchus/lib/utils/reflection/keys/ClassKey.java @@ -1,12 +1,12 @@ package com.falchus.lib.utils.reflection.keys; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public record ClassKey(@NonNull Set names) { - - public ClassKey(@NonNull String... names) { - this(Set.of(names)); - } + + public ClassKey(@NonNull String... names) { + this(Set.of(names)); + } } diff --git a/src/com/falchus/lib/utils/reflection/keys/ConstructorKey.java b/src/com/falchus/lib/utils/reflection/keys/ConstructorKey.java index f0229aa3..055073ae 100644 --- a/src/com/falchus/lib/utils/reflection/keys/ConstructorKey.java +++ b/src/com/falchus/lib/utils/reflection/keys/ConstructorKey.java @@ -1,17 +1,17 @@ package com.falchus.lib.utils.reflection.keys; +import lombok.NonNull; + import java.util.List; import java.util.Set; -import lombok.NonNull; - public record ConstructorKey(@NonNull Set> classes, Set>> params) { - - public ConstructorKey(@NonNull Class clazz, Class... params) { - this(Set.of(clazz), Set.of(List.of(params))); - } - - public ConstructorKey(@NonNull Class clazz, Set>> params) { - this(Set.of(clazz), params); - } + + public ConstructorKey(@NonNull Class clazz, Class... params) { + this(Set.of(clazz), Set.of(List.of(params))); + } + + public ConstructorKey(@NonNull Class clazz, Set>> params) { + this(Set.of(clazz), params); + } } diff --git a/src/com/falchus/lib/utils/reflection/keys/FieldKey.java b/src/com/falchus/lib/utils/reflection/keys/FieldKey.java index 1f28d9ab..f1d00235 100644 --- a/src/com/falchus/lib/utils/reflection/keys/FieldKey.java +++ b/src/com/falchus/lib/utils/reflection/keys/FieldKey.java @@ -1,20 +1,20 @@ package com.falchus.lib.utils.reflection.keys; -import java.util.Set; - import lombok.NonNull; +import java.util.Set; + public record FieldKey(@NonNull Set> classes, @NonNull Set names) { - - public FieldKey(@NonNull Class clazz, @NonNull String name) { - this(Set.of(clazz), Set.of(name)); - } - - public FieldKey(@NonNull Class clazz, @NonNull String... names) { - this(Set.of(clazz), Set.of(names)); - } - - public FieldKey(@NonNull Set> classes, @NonNull String... names) { - this(classes, Set.of(names)); - } + + public FieldKey(@NonNull Class clazz, @NonNull String name) { + this(Set.of(clazz), Set.of(name)); + } + + public FieldKey(@NonNull Class clazz, @NonNull String... names) { + this(Set.of(clazz), Set.of(names)); + } + + public FieldKey(@NonNull Set> classes, @NonNull String... names) { + this(classes, Set.of(names)); + } } diff --git a/src/com/falchus/lib/utils/reflection/keys/MethodKey.java b/src/com/falchus/lib/utils/reflection/keys/MethodKey.java index 98de71e4..61b46ab1 100644 --- a/src/com/falchus/lib/utils/reflection/keys/MethodKey.java +++ b/src/com/falchus/lib/utils/reflection/keys/MethodKey.java @@ -1,21 +1,21 @@ package com.falchus.lib.utils.reflection.keys; +import lombok.NonNull; + import java.util.List; import java.util.Set; -import lombok.NonNull; - public record MethodKey(@NonNull Set> classes, List> params, @NonNull Set names) { - - public MethodKey(@NonNull Class clazz, @NonNull String name, @NonNull Class... params) { - this(Set.of(clazz), List.of(params), Set.of(name)); - } - - public MethodKey(@NonNull Class clazz, List> params, @NonNull String... names) { - this(Set.of(clazz), params, Set.of(names)); - } - - public MethodKey(@NonNull Set> classes, List> params, @NonNull String... names) { - this(classes, params, Set.of(names)); - } + + public MethodKey(@NonNull Class clazz, @NonNull String name, @NonNull Class... params) { + this(Set.of(clazz), List.of(params), Set.of(name)); + } + + public MethodKey(@NonNull Class clazz, List> params, @NonNull String... names) { + this(Set.of(clazz), params, Set.of(names)); + } + + public MethodKey(@NonNull Set> classes, List> params, @NonNull String... names) { + this(classes, params, Set.of(names)); + } } diff --git a/src/com/falchus/lib/utils/wrapper/Wrapper.java b/src/com/falchus/lib/utils/wrapper/Wrapper.java index 84cc171a..a409f8c1 100644 --- a/src/com/falchus/lib/utils/wrapper/Wrapper.java +++ b/src/com/falchus/lib/utils/wrapper/Wrapper.java @@ -1,82 +1,82 @@ package com.falchus.lib.utils.wrapper; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; -import java.util.Set; - import com.falchus.lib.utils.builder.ClassInstanceBuilder; import com.falchus.lib.utils.reflection.ReflectionUtils; - import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NonNull; import lombok.Setter; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.Set; + @Getter @Setter @AllArgsConstructor public class Wrapper { - @NonNull protected T handle; - - protected Field getField(@NonNull String name) { - return ReflectionUtils.getField(handle, name); - } - - protected Field getFirstField(@NonNull String... names) { - return ReflectionUtils.getFirstField(handle, names); - } - - protected U getFieldValue(@NonNull Field field) { - return ReflectionUtils.getFieldValue(handle, field); - } - - protected void setField(@NonNull Field field, Object value) { - ReflectionUtils.setField(handle, field, value); - } - - protected void setFirstField(Object value, @NonNull String... names) { - ReflectionUtils.setFirstField(handle, value, names); - } - - protected Method getMethod(@NonNull String name, Class... params) { - return ReflectionUtils.getMethod(handle, name, params); - } - - protected Method getFirstMethod(List> params, @NonNull String... names) { - return ReflectionUtils.getFirstMethod(handle, params, names); - } - - protected Constructor getConstructor(Class... params) { - return ReflectionUtils.getConstructor(handle, params); + @NonNull + protected T handle; + + protected Field getField(@NonNull String name) { + return ReflectionUtils.getField(handle, name); + } + + protected Field getFirstField(@NonNull String... names) { + return ReflectionUtils.getFirstField(handle, names); + } + + protected U getFieldValue(@NonNull Field field) { + return ReflectionUtils.getFieldValue(handle, field); + } + + protected void setField(@NonNull Field field, Object value) { + ReflectionUtils.setField(handle, field, value); + } + + protected void setFirstField(Object value, @NonNull String... names) { + ReflectionUtils.setFirstField(handle, value, names); + } + + protected Method getMethod(@NonNull String name, Class... params) { + return ReflectionUtils.getMethod(handle, name, params); + } + + protected Method getFirstMethod(List> params, @NonNull String... names) { + return ReflectionUtils.getFirstMethod(handle, params, names); + } + + protected Constructor getConstructor(Class... params) { + return ReflectionUtils.getConstructor(handle, params); + } + + protected Constructor getFirstConstructor(Set>> params) { + return ReflectionUtils.getFirstConstructor(handle, params); + } + + @SuppressWarnings("unchecked") + public > U as(@NonNull Class clazz, Class... params) { + if (clazz.isInstance(this)) { + return (U) this; + } + + try { + Map, Object>[] paramMaps = new Map[params.length]; + for (int i = 0; i < params.length; i++) { + paramMaps[i] = Map.of(params[i], handle); + } + + return (U) new ClassInstanceBuilder( + clazz + ).withParams( + paramMaps + ).build(); + } catch (Exception e) { + return null; + } } - - protected Constructor getFirstConstructor(Set>> params) { - return ReflectionUtils.getFirstConstructor(handle, params); - } - - @SuppressWarnings("unchecked") - public > U as(@NonNull Class clazz, Class... params) { - if (clazz.isInstance(this)) { - return (U) this; - } - - try { - Map, Object>[] paramMaps = new Map[params.length]; - for (int i = 0; i < params.length; i++) { - paramMaps[i] = Map.of(params[i], handle); - } - - return (U) new ClassInstanceBuilder( - clazz - ).withParams( - paramMaps - ).build(); - } catch (Exception e) { - return null; - } - } } diff --git a/src/com/falchus/lib/utils/wrapper/impl/ClassWrapper.java b/src/com/falchus/lib/utils/wrapper/impl/ClassWrapper.java index b1777946..ffd333d2 100644 --- a/src/com/falchus/lib/utils/wrapper/impl/ClassWrapper.java +++ b/src/com/falchus/lib/utils/wrapper/impl/ClassWrapper.java @@ -1,50 +1,49 @@ package com.falchus.lib.utils.wrapper.impl; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Set; - import com.falchus.lib.utils.reflection.Dummy; import com.falchus.lib.utils.reflection.ReflectionUtils; import com.falchus.lib.utils.wrapper.Wrapper; - import lombok.Getter; import lombok.NonNull; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Set; + @Getter public class ClassWrapper extends Wrapper { - protected final Set> classes; - - public ClassWrapper(@NonNull T handle, @NonNull Set> classes) { - super(handle); - this.classes = classes; - - if (handle instanceof Dummy) return; - if (!classes.stream().anyMatch(clazz -> clazz.isAssignableFrom(handle.getClass()))) { - throw new RuntimeException("Handle " + handle.getClass().getName() + " is not assignable to any of: " + classes.stream().map(Class::getName).toList()); - } - } - - @Override - protected Field getFirstField(@NonNull String... names) { - return ReflectionUtils.getFirstField(classes, names); - } - - @Override - protected void setFirstField(Object value, @NonNull String... names) { - ReflectionUtils.setFirstField(handle, classes, value, names); - } - - @Override - protected Method getFirstMethod(List> params, @NonNull String... names) { - return ReflectionUtils.getFirstMethod(classes, params, names); - } - - @Override - protected Constructor getFirstConstructor(Set>> params) { - return ReflectionUtils.getFirstConstructor(classes, params); - } + protected final Set> classes; + + public ClassWrapper(@NonNull T handle, @NonNull Set> classes) { + super(handle); + this.classes = classes; + + if (handle instanceof Dummy) return; + if (!classes.stream().anyMatch(clazz -> clazz.isAssignableFrom(handle.getClass()))) { + throw new RuntimeException("Handle " + handle.getClass().getName() + " is not assignable to any of: " + classes.stream().map(Class::getName).toList()); + } + } + + @Override + protected Field getFirstField(@NonNull String... names) { + return ReflectionUtils.getFirstField(classes, names); + } + + @Override + protected void setFirstField(Object value, @NonNull String... names) { + ReflectionUtils.setFirstField(handle, classes, value, names); + } + + @Override + protected Method getFirstMethod(List> params, @NonNull String... names) { + return ReflectionUtils.getFirstMethod(classes, params, names); + } + + @Override + protected Constructor getFirstConstructor(Set>> params) { + return ReflectionUtils.getFirstConstructor(classes, params); + } } diff --git a/src/com/falchus/lib/utils/wrapper/impl/FirstClassWrapper.java b/src/com/falchus/lib/utils/wrapper/impl/FirstClassWrapper.java index 1f9d0769..26b51c8f 100644 --- a/src/com/falchus/lib/utils/wrapper/impl/FirstClassWrapper.java +++ b/src/com/falchus/lib/utils/wrapper/impl/FirstClassWrapper.java @@ -1,25 +1,24 @@ package com.falchus.lib.utils.wrapper.impl; -import java.util.Set; -import java.util.stream.Collectors; - import com.falchus.lib.utils.reflection.ReflectionUtils; - import lombok.NonNull; +import java.util.Set; +import java.util.stream.Collectors; + public class FirstClassWrapper extends ClassWrapper { - public FirstClassWrapper(@NonNull T handle, @NonNull Set names) { - super(handle, names.stream() - .map(name -> { - try { - return ReflectionUtils.getFirstClass(name); - } catch (RuntimeException e) { - return null; - } - }) - .filter(c -> c != null) - .collect(Collectors.toSet()) - ); - } + public FirstClassWrapper(@NonNull T handle, @NonNull Set names) { + super(handle, names.stream() + .map(name -> { + try { + return ReflectionUtils.getFirstClass(name); + } catch (RuntimeException e) { + return null; + } + }) + .filter(c -> c != null) + .collect(Collectors.toSet()) + ); + } } diff --git a/src/plugin.yml b/src/plugin.yml index 21851a99..b3da093c 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -3,9 +3,10 @@ version: ${project.version} api-version: 1.13 description: A library designed to simplify & speed up software development. main: com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot +folia-supported: true author: Falchus -authors: [Kalibrier] +authors: [Kalibrier, sun-dev] website: lib-java.falchus.com -load: startup +load: STARTUP softdepend: [LuckPerms] \ No newline at end of file diff --git a/src/velocity-plugin.json b/src/velocity-plugin.json index 9541bfca..f3b5a5bf 100644 --- a/src/velocity-plugin.json +++ b/src/velocity-plugin.json @@ -3,7 +3,7 @@ "name": "FalchusLib", "version": "${project.version}", "main": "com.falchus.lib.minecraft.velocity.FalchusLibMinecraftVelocity", - "authors": ["Falchus", "Kalibrier"], + "authors": ["Falchus", "Kalibrier", "sun-dev"], "description": "A library designed to simplify & speed up software development.", "url": "https://lib-java.falchus.com" } \ No newline at end of file From a4fc3198aced115861f40883460016dba0070af5 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 21:59:19 +0200 Subject: [PATCH 002/260] Update Listener.java --- src/com/falchus/lib/events/listener/Listener.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/falchus/lib/events/listener/Listener.java b/src/com/falchus/lib/events/listener/Listener.java index 6fdd73ba..448c9318 100644 --- a/src/com/falchus/lib/events/listener/Listener.java +++ b/src/com/falchus/lib/events/listener/Listener.java @@ -1,4 +1,3 @@ package com.falchus.lib.events.listener; -public interface Listener { -} +public interface Listener {} From b5434e58506f6546083795f7910947dd6279f3fd Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 21:59:45 +0200 Subject: [PATCH 003/260] Update RegisteredListener.java --- src/com/falchus/lib/events/listener/RegisteredListener.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/falchus/lib/events/listener/RegisteredListener.java b/src/com/falchus/lib/events/listener/RegisteredListener.java index 851e15ba..aa7e5a1e 100644 --- a/src/com/falchus/lib/events/listener/RegisteredListener.java +++ b/src/com/falchus/lib/events/listener/RegisteredListener.java @@ -4,6 +4,7 @@ import com.falchus.lib.events.Event; import com.falchus.lib.events.EventExecutor; import com.falchus.lib.events.EventHandler; + import lombok.AccessLevel; import lombok.Getter; import lombok.experimental.FieldDefaults; From 5d4845286210c9f2e890f04eb8588458caacfebb Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:00:18 +0200 Subject: [PATCH 004/260] Update Event.java --- src/com/falchus/lib/events/Event.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/falchus/lib/events/Event.java b/src/com/falchus/lib/events/Event.java index 93c8e7ab..152f9c93 100644 --- a/src/com/falchus/lib/events/Event.java +++ b/src/com/falchus/lib/events/Event.java @@ -1,6 +1,7 @@ package com.falchus.lib.events; import com.falchus.lib.manager.EventManager; + import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; From 94ebad8d7df5100c62175f56bddaaace900cdfe3 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:00:46 +0200 Subject: [PATCH 005/260] Update EventHandler.java --- src/com/falchus/lib/events/EventHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/falchus/lib/events/EventHandler.java b/src/com/falchus/lib/events/EventHandler.java index cad8a264..e6ed22a5 100644 --- a/src/com/falchus/lib/events/EventHandler.java +++ b/src/com/falchus/lib/events/EventHandler.java @@ -1,12 +1,12 @@ package com.falchus.lib.events; -import com.falchus.lib.enums.EventPriority; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import com.falchus.lib.enums.EventPriority; + @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface EventHandler { From 2401fe356fc8bff41dfb46a161d6dadb9cc8097d Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:01:19 +0200 Subject: [PATCH 006/260] Update EventManager.java --- src/com/falchus/lib/manager/EventManager.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/com/falchus/lib/manager/EventManager.java b/src/com/falchus/lib/manager/EventManager.java index f7b5005f..4856c1cb 100644 --- a/src/com/falchus/lib/manager/EventManager.java +++ b/src/com/falchus/lib/manager/EventManager.java @@ -1,12 +1,5 @@ package com.falchus.lib.manager; -import com.falchus.lib.events.Cancellable; -import com.falchus.lib.events.Event; -import com.falchus.lib.events.EventHandler; -import com.falchus.lib.events.listener.Listener; -import com.falchus.lib.events.listener.RegisteredListener; -import lombok.experimental.UtilityClass; - import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Comparator; @@ -16,6 +9,14 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; +import com.falchus.lib.events.Cancellable; +import com.falchus.lib.events.Event; +import com.falchus.lib.events.EventHandler; +import com.falchus.lib.events.listener.Listener; +import com.falchus.lib.events.listener.RegisteredListener; + +import lombok.experimental.UtilityClass; + @UtilityClass public class EventManager { From 5ee35568dadf102387e1a0876b7c78f93bb3427e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:03:13 +0200 Subject: [PATCH 007/260] Update CODEOWNERS --- CODEOWNERS | 1 - 1 file changed, 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 6d2c2192..229391dd 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,2 +1 @@ * @eliasfalch -* @sun-mc-dev \ No newline at end of file From b0a1fd097096453d2714119c5d50fd14763deaad Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:04:40 +0200 Subject: [PATCH 008/260] Update Version.java --- .../falchus/lib/minecraft/spigot/enums/Version.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Version.java b/src/com/falchus/lib/minecraft/spigot/enums/Version.java index 13da3592..36cafd8b 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Version.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Version.java @@ -2,8 +2,6 @@ import lombok.AllArgsConstructor; import lombok.Getter; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; @Getter @AllArgsConstructor @@ -28,13 +26,11 @@ public enum Version { private final int major; private final int minor; - @Contract(pure = true) - public boolean isAfter(@NotNull Version version) { + public boolean isAfter(Version version) { return major > version.major || (major == version.major && minor > version.minor); } - @Contract(pure = true) - public boolean isBefore(@NotNull Version version) { + public boolean isBefore(Version version) { return major < version.major || (major == version.major && minor < version.minor); } -} \ No newline at end of file +} From b113cbf66928d4d6bfc3e041acfa05afb33e3a12 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:05:59 +0200 Subject: [PATCH 009/260] Update PlayerPacketEvent.java --- .../spigot/events/player/PlayerPacketEvent.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java index 405d57bf..d4f68768 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java @@ -8,18 +8,22 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + +import lombok.Getter; +import lombok.Setter; + /** * Called when a player receives/sends a packet. */ @Getter public class PlayerPacketEvent extends Event implements Cancellable { - @Getter - private static final HandlerList handlerList = new HandlerList(); + @Getter private static final HandlerList handlerList = new HandlerList(); + @Setter private boolean cancelled; + private final Player player; private final PacketWrapper packet; - @Setter - private boolean cancelled; public PlayerPacketEvent(boolean async, Player player, PacketWrapper packet) { super(async); From 81230b602dcfc4ab74bc6ede4c51c75a66574b36 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:06:32 +0200 Subject: [PATCH 010/260] Update PlayerClientJoinEvent.java --- .../minecraft/spigot/events/player/PlayerClientJoinEvent.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java index 234d6e93..b686a4c4 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java @@ -14,8 +14,7 @@ @Getter public class PlayerClientJoinEvent extends Event { - @Getter - private static final HandlerList handlerList = new HandlerList(); + @Getter private static final HandlerList handlerList = new HandlerList(); private final Player player; private final Client client; From 9a6255b58dbdf0ad7c6a04cf99a84080763cad49 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:07:33 +0200 Subject: [PATCH 011/260] Update PlayerClientJoinEvent.java --- .../spigot/events/player/PlayerClientJoinEvent.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java index b686a4c4..09e089b0 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java @@ -1,12 +1,14 @@ package com.falchus.lib.minecraft.spigot.events.player; -import com.falchus.lib.minecraft.spigot.enums.Client; -import lombok.AllArgsConstructor; -import lombok.Getter; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import com.falchus.lib.minecraft.spigot.enums.Client; + +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * Called when a player's client has been identified after joining. */ From 75412767938472c18ad6e6a13c9adfb9e14bc126 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:10:36 +0200 Subject: [PATCH 012/260] Update PlayerPacketEvent.java --- .../lib/minecraft/spigot/events/player/PlayerPacketEvent.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java index d4f68768..35ec91cf 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java @@ -1,8 +1,5 @@ package com.falchus.lib.minecraft.spigot.events.player; -import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.Getter; -import lombok.Setter; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; From 5686abc9620bdf661b04b97f22e8343943c0539b Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:11:54 +0200 Subject: [PATCH 013/260] Update EventPriority.java --- src/com/falchus/lib/enums/EventPriority.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/falchus/lib/enums/EventPriority.java b/src/com/falchus/lib/enums/EventPriority.java index a9f3651d..6e44e3a9 100644 --- a/src/com/falchus/lib/enums/EventPriority.java +++ b/src/com/falchus/lib/enums/EventPriority.java @@ -1,10 +1,10 @@ package com.falchus.lib.enums; public enum EventPriority { - LOWEST, - LOW, - NORMAL, - HIGH, - HIGHEST, - MONITOR + LOWEST, + LOW, + NORMAL, + HIGH, + HIGHEST, + MONITOR } From e0b3ba8a6faf2d474f734bf880f7882753b5733f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:12:36 +0200 Subject: [PATCH 014/260] Update EventPriority.java From c4f2a243603cf36df3ecac00238b63be397ecaec Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:13:08 +0200 Subject: [PATCH 015/260] Update RegisteredListener.java --- .../events/listener/RegisteredListener.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/com/falchus/lib/events/listener/RegisteredListener.java b/src/com/falchus/lib/events/listener/RegisteredListener.java index aa7e5a1e..594912f5 100644 --- a/src/com/falchus/lib/events/listener/RegisteredListener.java +++ b/src/com/falchus/lib/events/listener/RegisteredListener.java @@ -12,20 +12,20 @@ @Getter @FieldDefaults(level = AccessLevel.PRIVATE) public class RegisteredListener { - - final Listener listener; - final EventExecutor executor; - final EventPriority priority; - final boolean ignoreCancelled; - - public RegisteredListener(Listener listener, EventExecutor executor, EventHandler handler) { - this.listener = listener; - this.executor = executor; - priority = handler.priority(); - ignoreCancelled = handler.ignoreCancelled(); - } - - public void execute(Event event) { - executor.execute(event); - } + + final Listener listener; + final EventExecutor executor; + final EventPriority priority; + final boolean ignoreCancelled; + + public RegisteredListener(Listener listener, EventExecutor executor, EventHandler handler) { + this.listener = listener; + this.executor = executor; + priority = handler.priority(); + ignoreCancelled = handler.ignoreCancelled(); + } + + public void execute(Event event) { + executor.execute(event); + } } From 049d6e5b9f3db443944ea1f23f443acd20f697cf Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:13:48 +0200 Subject: [PATCH 016/260] Update Event.java --- src/com/falchus/lib/events/Event.java | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/com/falchus/lib/events/Event.java b/src/com/falchus/lib/events/Event.java index 152f9c93..20d2168a 100644 --- a/src/com/falchus/lib/events/Event.java +++ b/src/com/falchus/lib/events/Event.java @@ -13,18 +13,18 @@ @FieldDefaults(level = AccessLevel.PRIVATE) @RequiredArgsConstructor public class Event { - - final boolean async; - - public Event() { - this(false); - } - - public boolean callEvent() { - EventManager.callEvent(this); - if (this instanceof Cancellable cancellable) { - return !cancellable.isCancelled(); - } - return true; - } + + final boolean async; + + public Event() { + this(false); + } + + public boolean callEvent() { + EventManager.callEvent(this); + if (this instanceof Cancellable cancellable) { + return !cancellable.isCancelled(); + } + return true; + } } From 99c52888a245e5851958b5580dafd0661de8e5cb Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:14:06 +0200 Subject: [PATCH 017/260] Update EventExecutor.java --- src/com/falchus/lib/events/EventExecutor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/falchus/lib/events/EventExecutor.java b/src/com/falchus/lib/events/EventExecutor.java index dff04ce3..578a6cd9 100644 --- a/src/com/falchus/lib/events/EventExecutor.java +++ b/src/com/falchus/lib/events/EventExecutor.java @@ -3,5 +3,5 @@ @FunctionalInterface public interface EventExecutor { - void execute(Event event); + void execute(Event event); } From 1b2dadf45e8063397eddb08317177f372671d710 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:14:22 +0200 Subject: [PATCH 018/260] Update EventHandler.java --- src/com/falchus/lib/events/EventHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/falchus/lib/events/EventHandler.java b/src/com/falchus/lib/events/EventHandler.java index e6ed22a5..fe0bd31c 100644 --- a/src/com/falchus/lib/events/EventHandler.java +++ b/src/com/falchus/lib/events/EventHandler.java @@ -10,8 +10,8 @@ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface EventHandler { - - EventPriority priority() default EventPriority.NORMAL; - - boolean ignoreCancelled() default false; + + EventPriority priority() default EventPriority.NORMAL; + + boolean ignoreCancelled() default false; } From f150e136aa48daf28ac8f47c0cca86e941356ac8 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:14:43 +0200 Subject: [PATCH 019/260] Update TriConsumer.java --- src/com/falchus/lib/interfaces/consumer/TriConsumer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/falchus/lib/interfaces/consumer/TriConsumer.java b/src/com/falchus/lib/interfaces/consumer/TriConsumer.java index 363e15e3..06ca0d8f 100644 --- a/src/com/falchus/lib/interfaces/consumer/TriConsumer.java +++ b/src/com/falchus/lib/interfaces/consumer/TriConsumer.java @@ -5,17 +5,17 @@ /** * A functional interface similar to {@link BiConsumer}, * but accepts three input arguments instead of two. - * + * * @param the type of the first argument * @param the type of the second argument * @param the type of the third argument */ @FunctionalInterface public interface TriConsumer { - + /** * Performs this operation on the given arguments. - * + * * @param t the first input argument * @param u the second input argument * @param v the third input argument From dfb4e36b0e8e9e0354c8c0ffcdfa0883562dc423 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:15:10 +0200 Subject: [PATCH 020/260] Update Mapper.java --- src/com/falchus/lib/interfaces/Mapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/falchus/lib/interfaces/Mapper.java b/src/com/falchus/lib/interfaces/Mapper.java index 5a657556..940cc63b 100644 --- a/src/com/falchus/lib/interfaces/Mapper.java +++ b/src/com/falchus/lib/interfaces/Mapper.java @@ -3,6 +3,6 @@ public interface Mapper { U to(T value); - + T from(U value); } From 545d9727d22914034860e13b68bd29e40fe030e0 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:15:55 +0200 Subject: [PATCH 021/260] Update EventManager.java --- src/com/falchus/lib/manager/EventManager.java | 136 +++++++++--------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/com/falchus/lib/manager/EventManager.java b/src/com/falchus/lib/manager/EventManager.java index 4856c1cb..7ff5f863 100644 --- a/src/com/falchus/lib/manager/EventManager.java +++ b/src/com/falchus/lib/manager/EventManager.java @@ -20,73 +20,73 @@ @UtilityClass public class EventManager { - private final Map, List> listeners = new ConcurrentHashMap<>(); - - @SuppressWarnings("unchecked") - public static void registerListener(Listener listener) { - for (Method method : listener.getClass().getDeclaredMethods()) { - if (!method.isAnnotationPresent(EventHandler.class)) continue; - - Class[] params = method.getParameterTypes(); - if (params.length != 1 || !Event.class.isAssignableFrom(params[0])) continue; - - Class clazz = (Class) params[0]; - EventHandler handler = method.getAnnotation(EventHandler.class); - - method.setAccessible(true); - - List listeners = EventManager.listeners.computeIfAbsent(clazz, k -> new CopyOnWriteArrayList<>()); - listeners.add(new RegisteredListener( - listener, - event -> { - try { - method.invoke(listener, event); - } catch (Exception e) { - throw new RuntimeException(e); - } - }, - handler - )); - listeners.sort(Comparator.comparingInt(k -> k.getPriority().ordinal())); - } - } - - public static void unregisterListener(Listener listener) { - for (List list : listeners.values()) { - list.removeIf(registered -> registered.getListener().equals(listener)); - } - } - - public static void callEvent(Event event) { - List listeners = new ArrayList<>(); - - Class clazz = event.getClass(); - while (clazz != null && Event.class.isAssignableFrom(clazz)) { - List list = EventManager.listeners.get(clazz); - if (list != null) { - listeners.addAll(list); - } - clazz = clazz.getSuperclass(); - } - - if (listeners.isEmpty()) return; - - listeners.sort(Comparator.comparingInt(k -> k.getPriority().ordinal())); - - for (RegisteredListener listener : listeners) { - if (event instanceof Cancellable cancellable) { - if (cancellable.isCancelled() && listener.isIgnoreCancelled()) continue; - } - - if (event.isAsync()) { - CompletableFuture.runAsync(() -> listener.execute(event)); - } else { - try { - listener.execute(event); - } catch (Exception e) { - e.printStackTrace(); - } - } + private final Map, List> listeners = new ConcurrentHashMap<>(); + + @SuppressWarnings("unchecked") + public static void registerListener(Listener listener) { + for (Method method : listener.getClass().getDeclaredMethods()) { + if (!method.isAnnotationPresent(EventHandler.class)) continue; + + Class[] params = method.getParameterTypes(); + if (params.length != 1 || !Event.class.isAssignableFrom(params[0])) continue; + + Class clazz = (Class) params[0]; + EventHandler handler = method.getAnnotation(EventHandler.class); + + method.setAccessible(true); + + List listeners = EventManager.listeners.computeIfAbsent(clazz, k -> new CopyOnWriteArrayList<>()); + listeners.add(new RegisteredListener( + listener, + event -> { + try { + method.invoke(listener, event); + } catch (Exception e) { + throw new RuntimeException(e); + } + }, + handler + )); + listeners.sort(Comparator.comparingInt(k -> k.getPriority().ordinal())); + } + } + + public static void unregisterListener(Listener listener) { + for (List list : listeners.values()) { + list.removeIf(registered -> registered.getListener().equals(listener)); } - } + } + + public static void callEvent(Event event) { + List listeners = new ArrayList<>(); + + Class clazz = event.getClass(); + while (clazz != null && Event.class.isAssignableFrom(clazz)) { + List list = EventManager.listeners.get(clazz); + if (list != null) { + listeners.addAll(list); + } + clazz = clazz.getSuperclass(); + } + + if (listeners.isEmpty()) return; + + listeners.sort(Comparator.comparingInt(k -> k.getPriority().ordinal())); + + for (RegisteredListener listener : listeners) { + if (event instanceof Cancellable cancellable) { + if (cancellable.isCancelled() && listener.isIgnoreCancelled()) continue; + } + + if (event.isAsync()) { + CompletableFuture.runAsync(() -> listener.execute(event)); + } else { + try { + listener.execute(event); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } } From 5f24a3c95e13d62a927f164036113a32695f8c63 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:16:17 +0200 Subject: [PATCH 022/260] Update SpigotCommandAdapter.java --- .../minecraft/command/impl/SpigotCommandAdapter.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/falchus/lib/minecraft/command/impl/SpigotCommandAdapter.java b/src/com/falchus/lib/minecraft/command/impl/SpigotCommandAdapter.java index 07c88701..6a7ff59e 100644 --- a/src/com/falchus/lib/minecraft/command/impl/SpigotCommandAdapter.java +++ b/src/com/falchus/lib/minecraft/command/impl/SpigotCommandAdapter.java @@ -21,13 +21,13 @@ public abstract class SpigotCommandAdapter implements BaseCommand, CommandExecut private final String permission; private final String noPermissionMessage; private final String usageMessage; - + public SpigotCommandAdapter(String permission, String noPermissionMessage, String usageMessage) { this.permission = permission; this.noPermissionMessage = noPermissionMessage != null ? noPermissionMessage : FalchusLib.noPermissionMessage; this.usageMessage = usageMessage != null ? usageMessage : FalchusLib.prefix + "§cWrong usage."; } - + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!hasPermission(sender)) { @@ -37,14 +37,14 @@ public boolean onCommand(CommandSender sender, Command command, String label, St executeCommand(sender, args); return true; } - + @Override public List onTabComplete(CommandSender sender, Command command, String label, String[] args) { if (!hasPermission(sender)) return Collections.emptyList(); List list = tabComplete(sender, args); return list != null ? list : Collections.emptyList(); } - + @Override public boolean hasPermission(@NonNull Object sender) { if (permission != null) { @@ -54,11 +54,11 @@ public boolean hasPermission(@NonNull Object sender) { } return true; } - + @Override public void sendMessage(@NonNull Object s, @NonNull String message) { if (s instanceof CommandSender sender) { sender.sendMessage(message); } } -} \ No newline at end of file +} From 1d8e5f48136a7b8c6c22842904d0eb91f7fe956f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:16:33 +0200 Subject: [PATCH 023/260] Update VelocityCommandAdapter.java --- .../command/impl/VelocityCommandAdapter.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/falchus/lib/minecraft/command/impl/VelocityCommandAdapter.java b/src/com/falchus/lib/minecraft/command/impl/VelocityCommandAdapter.java index b43f22ae..44bafdb9 100644 --- a/src/com/falchus/lib/minecraft/command/impl/VelocityCommandAdapter.java +++ b/src/com/falchus/lib/minecraft/command/impl/VelocityCommandAdapter.java @@ -20,13 +20,13 @@ public abstract class VelocityCommandAdapter implements BaseCommand, SimpleComma private final String permission; private final String noPermissionMessage; private final String usageMessage; - + public VelocityCommandAdapter(String permission, String noPermissionMessage, String usageMessage) { this.permission = permission; this.noPermissionMessage = noPermissionMessage != null ? noPermissionMessage : FalchusLib.noPermissionMessage; this.usageMessage = usageMessage != null ? usageMessage : FalchusLib.prefix + "§cWrong usage."; } - + @Override public void execute(Invocation invocation) { CommandSource sender = invocation.source(); @@ -37,7 +37,7 @@ public void execute(Invocation invocation) { } executeCommand(sender, args); } - + @Override public List suggest(Invocation invocation) { CommandSource sender = invocation.source(); @@ -46,22 +46,22 @@ public List suggest(Invocation invocation) { List list = tabComplete(sender, args); return list != null ? list : Collections.emptyList(); } - + @Override public CompletableFuture> suggestAsync(Invocation invocation) { return CompletableFuture.completedFuture(suggest(invocation)); } - + @Override public boolean hasPermission(@NonNull Object sender) { if (permission != null) { if (sender instanceof Player player) { return player.hasPermission(permission); - } + } } return true; } - + @Override public void sendMessage(@NonNull Object s, @NonNull String message) { if (s instanceof CommandSource sender) { From 391caa1e1d16c1f776ed1ffba88532d05b17fcb6 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:16:51 +0200 Subject: [PATCH 024/260] Update BaseCommand.java --- src/com/falchus/lib/minecraft/command/BaseCommand.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/command/BaseCommand.java b/src/com/falchus/lib/minecraft/command/BaseCommand.java index f9e1e42f..42bec61d 100644 --- a/src/com/falchus/lib/minecraft/command/BaseCommand.java +++ b/src/com/falchus/lib/minecraft/command/BaseCommand.java @@ -6,27 +6,27 @@ import lombok.NonNull; public interface BaseCommand { - + /** * Returns the permission required. */ String getPermission(); - + /** * Returns the message to send when a sender does not have permission. */ String getNoPermissionMessage(); - + /** * Returns the usage message for the command. */ String getUsageMessage(); - + /** * Executes the command logic. */ void executeCommand(@NonNull Object sender, @NonNull String[] args); - + /** * Tab completion. */ From df5624d8fc6647bd57cc5adb3f00c06f5520ccbc Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:17:12 +0200 Subject: [PATCH 025/260] Update SpigotCommandAdapter.java From 7fc5c043bb59b79f826997155072752752dd132b Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:17:46 +0200 Subject: [PATCH 026/260] Update Biome.java --- src/com/falchus/lib/minecraft/spigot/enums/Biome.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Biome.java b/src/com/falchus/lib/minecraft/spigot/enums/Biome.java index bbecf5cc..93d516ce 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Biome.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Biome.java @@ -6,7 +6,7 @@ @AllArgsConstructor @Getter public enum Biome { - HELL("NETHER_WASTES"); - - private final String modernName; + HELL("NETHER_WASTES"); + + private final String modernName; } From 149765e68fe14a2b8ef08e7cc7b2cccc52cd4d54 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:18:01 +0200 Subject: [PATCH 027/260] Update Client.java --- src/com/falchus/lib/minecraft/spigot/enums/Client.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Client.java b/src/com/falchus/lib/minecraft/spigot/enums/Client.java index ce33b0fc..de770449 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Client.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Client.java @@ -1,7 +1,7 @@ package com.falchus.lib.minecraft.spigot.enums; public enum Client { - LABYMOD, - LUNAR, - OTHER + LABYMOD, + LUNAR, + OTHER } From 4c378ffb5337b9ea301b8063b65d666e4fa5bfd8 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:18:16 +0200 Subject: [PATCH 028/260] Update GameRule.java --- .../lib/minecraft/spigot/enums/GameRule.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/enums/GameRule.java b/src/com/falchus/lib/minecraft/spigot/enums/GameRule.java index 3a7ad0a9..d3a25485 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/GameRule.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/GameRule.java @@ -6,21 +6,21 @@ @AllArgsConstructor @Getter public enum GameRule { - COMMAND_BLOCK_OUTPUT("commandBlockOutput"), - DO_DAYLIGHT_CYCLE("doDaylightCycle"), - DO_ENTITY_DROPS("doEntityDrops"), - DO_FIRE_TICK("doFireTick"), - DO_MOB_LOOT("doMobLoot"), - DO_MOB_SPAWNING("doMobSpawning"), - DO_TILE_DROPS("doTileDrops"), - KEEP_INVENTORY("keepInventory"), - LOG_ADMIN_COMMANDS("logAdminCommands"), - MOB_GRIEFING("mobGriefing"), - NATURAL_REGENERATION("naturalRegeneration"), - RANDOM_TICK_SPEED("randomTickSpeed"), - REDUCED_DEBUG_INFO("reducedDebugInfo"), - SEND_COMMAND_FEEDBACK("sendCommandFeedback"), - SHOW_DEATH_MESSAGES("showDeathMessages"); - - private final String key; + COMMAND_BLOCK_OUTPUT("commandBlockOutput"), + DO_DAYLIGHT_CYCLE("doDaylightCycle"), + DO_ENTITY_DROPS("doEntityDrops"), + DO_FIRE_TICK("doFireTick"), + DO_MOB_LOOT("doMobLoot"), + DO_MOB_SPAWNING("doMobSpawning"), + DO_TILE_DROPS("doTileDrops"), + KEEP_INVENTORY("keepInventory"), + LOG_ADMIN_COMMANDS("logAdminCommands"), + MOB_GRIEFING("mobGriefing"), + NATURAL_REGENERATION("naturalRegeneration"), + RANDOM_TICK_SPEED("randomTickSpeed"), + REDUCED_DEBUG_INFO("reducedDebugInfo"), + SEND_COMMAND_FEEDBACK("sendCommandFeedback"), + SHOW_DEATH_MESSAGES("showDeathMessages"); + + private final String key; } From 5a319c0996d93e16f18be33b7b050e0c27e362be Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:18:35 +0200 Subject: [PATCH 029/260] Update Material.java --- .../lib/minecraft/spigot/enums/Material.java | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Material.java b/src/com/falchus/lib/minecraft/spigot/enums/Material.java index ec6b8702..1926d418 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Material.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Material.java @@ -6,52 +6,52 @@ @AllArgsConstructor @Getter public enum Material { - BLACK_WOOL(15, "WOOL"), - BLUE_WOOL(11, "WOOL"), - CAULDRON("CAULDRON_ITEM"), - CLOCK("WATCH"), - COBBLESTONE_WALL("COBBLE_WALL"), - COBWEB("WEB"), - DANDELION("YELLOW_FLOWER"), - ENCHANTING_TABLE("ENCHANTMENT_TABLE"), - ENDER_EYE("EYE_OF_ENDER"), - END_STONE("ENDER_STONE"), - EXPERIENCE_BOTTLE("EXP_BOTTLE"), - GRASS_BLOCK("GRASS"), - GRAY_STAINED_GLASS_PANE(7, "STAINED_GLASS_PANE"), - GRAY_WOOL(7, "WOOL"), - GREEN_WOOL(13, "WOOL"), - LAPIS_LAZULI(4, "INK_SACK"), - LAVA("STATIONARY_LAVA"), - LIGHT_BLUE_WOOL(3, "WOOL"), - LIME_STAINED_GLASS_PANE(5, "STAINED_GLASS_PANE"), - LIME_WOOL(5, "WOOL"), - NETHER_BRICKS("NETHER_BRICK"), - OAK_FENCE("FENCE"), - OAK_FENCE_GATE("FENCE_GATE"), - OAK_LOG("LOG"), - OAK_PLANKS("WOOD"), - ORANGE_WOOL(1, "WOOL"), - PINK_WOOL(6, "WOOL"), - PLAYER_HEAD(3, "SKULL_ITEM"), - POPPY("RED_ROSE"), - PURPLE_WOOL(10, "WOOL"), - QUARTZ_SLAB(7, "STEP"), - RED_BED("BED"), - RED_DYE(1, "INK_SACK"), - RED_STAINED_GLASS_PANE(14, "STAINED_GLASS_PANE"), - RED_WOOL(14, "WOOL"), - SNOWBALL("SNOW_BALL"), - WATER("STATIONARY_WATER"), - WOODEN_AXE("WOOD_AXE"), - WOODEN_SWORD("WOOD_SWORD"), - YELLOW_STAINED_GLASS_PANE(4, "STAINED_GLASS_PANE"), - YELLOW_WOOL(4, "WOOL"); - - private final int legacyDurability; - private final String legacyName; - - Material(String legacyName) { - this(0, legacyName); - } + BLACK_WOOL(15, "WOOL"), + BLUE_WOOL(11, "WOOL"), + CAULDRON("CAULDRON_ITEM"), + CLOCK("WATCH"), + COBBLESTONE_WALL("COBBLE_WALL"), + COBWEB("WEB"), + DANDELION("YELLOW_FLOWER"), + ENCHANTING_TABLE("ENCHANTMENT_TABLE"), + ENDER_EYE("EYE_OF_ENDER"), + END_STONE("ENDER_STONE"), + EXPERIENCE_BOTTLE("EXP_BOTTLE"), + GRASS_BLOCK("GRASS"), + GRAY_STAINED_GLASS_PANE(7, "STAINED_GLASS_PANE"), + GRAY_WOOL(7, "WOOL"), + GREEN_WOOL(13, "WOOL"), + LAPIS_LAZULI(4, "INK_SACK"), + LAVA("STATIONARY_LAVA"), + LIGHT_BLUE_WOOL(3, "WOOL"), + LIME_STAINED_GLASS_PANE(5, "STAINED_GLASS_PANE"), + LIME_WOOL(5, "WOOL"), + NETHER_BRICKS("NETHER_BRICK"), + OAK_FENCE("FENCE"), + OAK_FENCE_GATE("FENCE_GATE"), + OAK_LOG("LOG"), + OAK_PLANKS("WOOD"), + ORANGE_WOOL(1, "WOOL"), + PINK_WOOL(6, "WOOL"), + PLAYER_HEAD(3, "SKULL_ITEM"), + POPPY("RED_ROSE"), + PURPLE_WOOL(10, "WOOL"), + QUARTZ_SLAB(7, "STEP"), + RED_BED("BED"), + RED_DYE(1, "INK_SACK"), + RED_STAINED_GLASS_PANE(14, "STAINED_GLASS_PANE"), + RED_WOOL(14, "WOOL"), + SNOWBALL("SNOW_BALL"), + WATER("STATIONARY_WATER"), + WOODEN_AXE("WOOD_AXE"), + WOODEN_SWORD("WOOD_SWORD"), + YELLOW_STAINED_GLASS_PANE(4, "STAINED_GLASS_PANE"), + YELLOW_WOOL(4, "WOOL"); + + private final int legacyDurability; + private final String legacyName; + + Material(String legacyName) { + this(0, legacyName); + } } From 6311865dda191d9d5202cc3dc57f440a11462c7a Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:19:02 +0200 Subject: [PATCH 030/260] Update Sound.java --- .../lib/minecraft/spigot/enums/Sound.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Sound.java b/src/com/falchus/lib/minecraft/spigot/enums/Sound.java index 4e523c13..78e05c21 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Sound.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Sound.java @@ -6,20 +6,20 @@ @AllArgsConstructor @Getter public enum Sound { - LEVEL_UP("ENTITY_PLAYER_LEVELUP"), - VILLAGER_NO("ENTITY_VILLAGER_NO"), - NOTE_PLING("BLOCK_NOTE_BLOCK_PLING"), - NOTE_BASS("BLOCK_NOTE_BLOCK_BASS"), - NOTE_BASS_DRUM("BLOCK_NOTE_BLOCK_BASEDRUM"), - AMBIENCE_THUNDER("ENTITY_LIGHTNING_BOLT_THUNDER"), - CHEST_OPEN("BLOCK_CHEST_OPEN"), - CHEST_CLOSE("BLOCK_CHEST_CLOSE"), - CHICKEN_EGG_POP("ENTITY_CHICKEN_EGG"), - ENDERDRAGON_GROWL("ENTITY_ENDER_DRAGON_GROWL"), - BURP("ENTITY_PLAYER_BURP"), - FIREWORK_LARGE_BLAST2("ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR"), - ANVIL_LAND("BLOCK_ANVIL_LAND"), - BAT_TAKEOFF("ENTITY_BAT_TAKEOFF"); - - public final String modernName; + LEVEL_UP("ENTITY_PLAYER_LEVELUP"), + VILLAGER_NO("ENTITY_VILLAGER_NO"), + NOTE_PLING("BLOCK_NOTE_BLOCK_PLING"), + NOTE_BASS("BLOCK_NOTE_BLOCK_BASS"), + NOTE_BASS_DRUM("BLOCK_NOTE_BLOCK_BASEDRUM"), + AMBIENCE_THUNDER("ENTITY_LIGHTNING_BOLT_THUNDER"), + CHEST_OPEN("BLOCK_CHEST_OPEN"), + CHEST_CLOSE("BLOCK_CHEST_CLOSE"), + CHICKEN_EGG_POP("ENTITY_CHICKEN_EGG"), + ENDERDRAGON_GROWL("ENTITY_ENDER_DRAGON_GROWL"), + BURP("ENTITY_PLAYER_BURP"), + FIREWORK_LARGE_BLAST2("ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR"), + ANVIL_LAND("BLOCK_ANVIL_LAND"), + BAT_TAKEOFF("ENTITY_BAT_TAKEOFF"); + + public final String modernName; } From a47c51a64573ca585b8fe60c25187a8dbf6ff0cb Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:19:19 +0200 Subject: [PATCH 031/260] Update Version.java --- .../lib/minecraft/spigot/enums/Version.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Version.java b/src/com/falchus/lib/minecraft/spigot/enums/Version.java index 36cafd8b..91fc3cf1 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Version.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Version.java @@ -6,31 +6,31 @@ @Getter @AllArgsConstructor public enum Version { - v1_7(1, 7), - v1_8(1, 8), - v1_9(1, 9), - v1_10(1, 10), - v1_11(1, 11), - v1_12(1, 12), - v1_13(1, 13), - v1_14(1, 14), - v1_15(1, 15), - v1_16(1, 16), - v1_17(1, 17), - v1_18(1, 18), - v1_19(1, 19), - v1_20(1, 20), - v1_21(1, 21), - v26_1(26, 1); - - private final int major; - private final int minor; - - public boolean isAfter(Version version) { - return major > version.major || (major == version.major && minor > version.minor); - } - - public boolean isBefore(Version version) { - return major < version.major || (major == version.major && minor < version.minor); - } + v1_7(1, 7), + v1_8(1, 8), + v1_9(1, 9), + v1_10(1, 10), + v1_11(1, 11), + v1_12(1, 12), + v1_13(1, 13), + v1_14(1, 14), + v1_15(1, 15), + v1_16(1, 16), + v1_17(1, 17), + v1_18(1, 18), + v1_19(1, 19), + v1_20(1, 20), + v1_21(1, 21), + v26_1(26, 1); + + private final int major; + private final int minor; + + public boolean isAfter(Version version) { + return major > version.major || (major == version.major && minor > version.minor); + } + + public boolean isBefore(Version version) { + return major < version.major || (major == version.major && minor < version.minor); + } } From b1fe606f5fc109957adec5f70318eb80a87a2c36 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:19:41 +0200 Subject: [PATCH 032/260] Update PlayerClientJoinEvent.java --- .../events/player/PlayerClientJoinEvent.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java index 09e089b0..e4749a70 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerClientJoinEvent.java @@ -16,13 +16,13 @@ @Getter public class PlayerClientJoinEvent extends Event { - @Getter private static final HandlerList handlerList = new HandlerList(); - - private final Player player; - private final Client client; - - @Override - public HandlerList getHandlers() { - return handlerList; - } + @Getter private static final HandlerList handlerList = new HandlerList(); + + private final Player player; + private final Client client; + + @Override + public HandlerList getHandlers() { + return handlerList; + } } From 53a3304f0c3b90d2f5c412fb18cebee41208149f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:19:56 +0200 Subject: [PATCH 033/260] Update PlayerPacketEvent.java --- .../events/player/PlayerPacketEvent.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java index 35ec91cf..153bef5f 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketEvent.java @@ -16,20 +16,20 @@ @Getter public class PlayerPacketEvent extends Event implements Cancellable { - @Getter private static final HandlerList handlerList = new HandlerList(); - @Setter private boolean cancelled; - - private final Player player; - private final PacketWrapper packet; - - public PlayerPacketEvent(boolean async, Player player, PacketWrapper packet) { - super(async); - this.player = player; - this.packet = packet; - } - - @Override - public HandlerList getHandlers() { - return handlerList; - } + @Getter private static final HandlerList handlerList = new HandlerList(); + @Setter private boolean cancelled; + + private final Player player; + private final PacketWrapper packet; + + public PlayerPacketEvent(boolean async, Player player, PacketWrapper packet) { + super(async); + this.player = player; + this.packet = packet; + } + + @Override + public HandlerList getHandlers() { + return handlerList; + } } From 62cc41bb2cbd7cf3600a436bb7c8314763bf0d3e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:20:10 +0200 Subject: [PATCH 034/260] Update PlayerPacketInEvent.java --- .../spigot/events/player/PlayerPacketInEvent.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketInEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketInEvent.java index 52ceff7f..5aaf93bd 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketInEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketInEvent.java @@ -1,16 +1,18 @@ package com.falchus.lib.minecraft.spigot.events.player; +import org.bukkit.entity.Player; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.Getter; -import org.bukkit.entity.Player; /** * Called when a player receives a packet. */ @Getter public class PlayerPacketInEvent extends PlayerPacketEvent { - - public PlayerPacketInEvent(boolean async, Player player, PacketWrapper packet) { - super(async, player, packet); - } + + public PlayerPacketInEvent(boolean async, Player player, PacketWrapper packet) { + super(async, player, packet); + } } From 90a137ef58101195e9e5637cc08b31f5a640e5ff Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:20:23 +0200 Subject: [PATCH 035/260] Update PlayerPacketOutEvent.java --- .../spigot/events/player/PlayerPacketOutEvent.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketOutEvent.java b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketOutEvent.java index f8ac09ca..b79e5880 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketOutEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/player/PlayerPacketOutEvent.java @@ -1,16 +1,18 @@ package com.falchus.lib.minecraft.spigot.events.player; +import org.bukkit.entity.Player; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.Getter; -import org.bukkit.entity.Player; /** * Called when a player sends a packet. */ @Getter public class PlayerPacketOutEvent extends PlayerPacketEvent { - - public PlayerPacketOutEvent(boolean async, Player player, PacketWrapper packet) { - super(async, player, packet); - } + + public PlayerPacketOutEvent(boolean async, Player player, PacketWrapper packet) { + super(async, player, packet); + } } From ca666cb09b590591f9f93c389966a2956aabf791 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:20:35 +0200 Subject: [PATCH 036/260] Update LobbyCancelEvent.java --- .../spigot/events/LobbyCancelEvent.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/events/LobbyCancelEvent.java b/src/com/falchus/lib/minecraft/spigot/events/LobbyCancelEvent.java index ff234019..161ab79a 100644 --- a/src/com/falchus/lib/minecraft/spigot/events/LobbyCancelEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/events/LobbyCancelEvent.java @@ -1,12 +1,13 @@ package com.falchus.lib.minecraft.spigot.events; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.Setter; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + /** * Called when there's a event that should be cancelled in a Lobby. */ @@ -14,14 +15,13 @@ @RequiredArgsConstructor public class LobbyCancelEvent extends Event implements Cancellable { - @Getter - private static final HandlerList handlerList = new HandlerList(); - private final Event event; - @Setter - private boolean cancelled; - - @Override - public HandlerList getHandlers() { - return handlerList; - } + @Getter private static final HandlerList handlerList = new HandlerList(); + @Setter private boolean cancelled; + + private final Event event; + + @Override + public HandlerList getHandlers() { + return handlerList; + } } From 24bc93487fc00e131a24e91458a4ab571aa40e62 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:20:54 +0200 Subject: [PATCH 037/260] Update LabyModMessageListener.java --- .../spigot/listeners/message/LabyModMessageListener.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/message/LabyModMessageListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/message/LabyModMessageListener.java index e72419a2..02a2c4e0 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/message/LabyModMessageListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/message/LabyModMessageListener.java @@ -13,9 +13,9 @@ import io.netty.buffer.Unpooled; public class LabyModMessageListener implements PluginMessageListener { - + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - + public LabyModMessageListener() { plugin.getServer().getMessenger().registerIncomingPluginChannel(plugin, "labymod3:main", this); plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "labymod3:main"); @@ -24,10 +24,10 @@ public LabyModMessageListener() { @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { if (!channel.equals("labymod3:main")) return; - + ByteBuf buf = Unpooled.wrappedBuffer(message); String key = LabyModProtocol.readString(buf, Short.MAX_VALUE); - + // LabyMod user joins the server if (key.equals("INFO")) { plugin.getClientManager().set(player, Client.LABYMOD); From 4315a8536084e863d833b34296ad4d924293995a Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:21:07 +0200 Subject: [PATCH 038/260] Update LunarMessageListener.java --- .../message/LunarMessageListener.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/message/LunarMessageListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/message/LunarMessageListener.java index 1697ab71..27ff0ef4 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/message/LunarMessageListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/message/LunarMessageListener.java @@ -15,39 +15,39 @@ import com.google.gson.JsonObject; public class LunarMessageListener implements Listener { - + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - + public LunarMessageListener() { Messenger messenger = Bukkit.getServer().getMessenger(); messenger.registerIncomingPluginChannel(plugin, "lunar:apollo", (s, player, bytes) -> { }); messenger.registerIncomingPluginChannel(plugin, "apollo:json", (s, player, bytes) -> { }); messenger.registerOutgoingPluginChannel(plugin, "apollo:json"); - + Bukkit.getPluginManager().registerEvents(this, plugin); } @EventHandler private void onRegisterChannel(PlayerRegisterChannelEvent event) { if (!event.getChannel().equalsIgnoreCase("lunar:apollo")) return; - + Player player = event.getPlayer(); - + // Sending the player's world name to the client is required for some modules LunarJsonPacketUtil.sendPacket(player, createUpdatePlayerWorldMessage(player)); - + plugin.getClientManager().set(player, Client.LUNAR); Bukkit.getPluginManager().callEvent(new PlayerClientJoinEvent(player, Client.LUNAR)); } - + @EventHandler private void onPlayerChangedWorld(PlayerChangedWorldEvent event) { Player player = event.getPlayer(); - + // Sending the player's world name to the client is required for some modules LunarJsonPacketUtil.sendPacket(player, this.createUpdatePlayerWorldMessage(player)); } - + private JsonObject createUpdatePlayerWorldMessage(Player player) { JsonObject message = new JsonObject(); message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.player.v1.UpdatePlayerWorldMessage"); From 16d32ac7cd3396308bba15ff421cf0a279e35e1f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:21:20 +0200 Subject: [PATCH 039/260] Update EntityPlayerListener.java --- .../minecraft/spigot/listeners/EntityPlayerListener.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/EntityPlayerListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/EntityPlayerListener.java index b39c3156..9c7b9860 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/EntityPlayerListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/EntityPlayerListener.java @@ -18,16 +18,16 @@ public class EntityPlayerListener implements Listener { private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); public final Map players = new HashMap<>(); public final Map> actions = new HashMap<>(); - + public EntityPlayerListener() { Bukkit.getPluginManager().registerEvents(this, plugin); } - + @EventHandler public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { if (!(event.getRightClicked() instanceof Player player)) return; UUID uuid = player.getUniqueId(); - + if (players.containsKey(uuid)) { Consumer action = actions.get(uuid); if (action != null) { From 4a5f0835404fb7a80a45df7c2742b4c09fb4fdbd Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:21:38 +0200 Subject: [PATCH 040/260] Update FreezeListener.java --- .../spigot/listeners/FreezeListener.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/FreezeListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/FreezeListener.java index 7052720c..ab00a3b8 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/FreezeListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/FreezeListener.java @@ -35,59 +35,59 @@ public class FreezeListener implements Listener { private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); public final Set players = new HashSet<>(); - + public FreezeListener() { Bukkit.getPluginManager().registerEvents(this, plugin); } - + @EventHandler public void onPlayerMove(PlayerMoveEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; - + Location from = event.getFrom(); Location to = event.getTo(); if (from.getBlockX() != to.getBlockX() || from.getBlockZ() != to.getBlockZ()) { event.setTo(from); } } - + @EventHandler(ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) - public void onInventoryClick(InventoryClickEvent event) { + public void onInventoryClick(InventoryClickEvent event) { if (!players.contains(event.getWhoClicked().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { if (!players.contains(event.getEntity().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof Player player) { if (players.contains(player.getUniqueId())) { event.setCancelled(true); } - + if (event.getDamager() instanceof Player damager) { if (players.contains(damager.getUniqueId())) { event.setCancelled(true); @@ -95,73 +95,73 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { } } } - + @EventHandler(ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerDropItem(PlayerDropItemEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerPickupItem(PlayerPickupItemEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) - public void onFoodLevelChange(FoodLevelChangeEvent event) { + public void onFoodLevelChange(FoodLevelChangeEvent event) { if (!players.contains(event.getEntity().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onHangingBreak(HangingBreakEvent event) { if (!players.contains(event.getEntity().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerBucketFill(PlayerBucketFillEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerShearEntity(PlayerShearEntityEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerArmorStandManipulate(PlayerArmorStandManipulateEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerChat(AsyncPlayerChatEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; event.setCancelled(true); } - + @EventHandler(ignoreCancelled = true) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { if (!players.contains(event.getPlayer().getUniqueId())) return; From d549f8344b99c4783648605658120652f14ba006 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:21:50 +0200 Subject: [PATCH 041/260] Update ItemListener.java --- .../lib/minecraft/spigot/listeners/ItemListener.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/ItemListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/ItemListener.java index ea94da22..5575b989 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/ItemListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/ItemListener.java @@ -20,16 +20,16 @@ public class ItemListener implements Listener { private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - + public ItemListener() { Bukkit.getPluginManager().registerEvents(this, plugin); } - + @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { ItemStack item = event.getItem(); if (item == null) return; - + UUID uuid = ItemUtils.getUUID(item); if (uuid != null) { Consumer action = ItemUtils.itemActions.get(uuid); @@ -46,7 +46,7 @@ public void onInventoryClick(InventoryClickEvent event) { ItemStack item = event.getCurrentItem(); if (item == null) return; - + UUID uuid = ItemUtils.getUUID(item); if (uuid != null) { TriConsumer action = ItemUtils.itemActionsInventory.get(uuid); @@ -63,7 +63,7 @@ public void onInventoryClick(InventoryClickEvent event) { callback.accept(player, item, event); } } - + // TODO: search for a better, more bulletproof solution // @EventHandler // public void onInventoryClose(InventoryCloseEvent event) { From 5c037cbd6662a7e805e6e1783e6044fffe107e0f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:22:24 +0200 Subject: [PATCH 042/260] Update JoinQuitListener.java --- .../spigot/listeners/JoinQuitListener.java | 126 +++++++++--------- 1 file changed, 65 insertions(+), 61 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/JoinQuitListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/JoinQuitListener.java index e57d5542..89d8725b 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/JoinQuitListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/JoinQuitListener.java @@ -1,10 +1,5 @@ package com.falchus.lib.minecraft.spigot.listeners; -import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; -import com.falchus.lib.minecraft.spigot.packets.PacketInjector; -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; -import com.falchus.lib.minecraft.spigot.player.elements.impl.*; -import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -12,62 +7,71 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.jetbrains.annotations.NotNull; - -public class JoinQuitListener implements Listener { - - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - public JoinQuitListener() { - Bukkit.getPluginManager().registerEvents(this, plugin); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void onPlayerJoin_LOWEST(@NotNull PlayerJoinEvent event) { - PacketInjector.inject(event.getPlayer()); - } - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) { - PlayerElement.updateAll(Actionbar.class); - PlayerElement.updateAll(Bossbar.class); - PlayerElement.updateAll(Chat.class); - PlayerElement.updateAll(Nametag.class); - PlayerElement.updateAll(Scoreboard.class); - PlayerElement.updateAll(Tablist.class); - } - - @EventHandler(priority = EventPriority.HIGH) - public void onPlayerJoin_HIGH(@NotNull PlayerJoinEvent event) { - Player joining = event.getPlayer(); - - for (Player online : Bukkit.getOnlinePlayers()) { - if (PlayerUtils.vanished.contains(joining.getUniqueId())) { - online.hidePlayer(plugin, joining); - } else { - online.showPlayer(plugin, joining); - } - - if (PlayerUtils.vanished.contains(online.getUniqueId())) { - joining.hidePlayer(plugin, online); - } else { - joining.showPlayer(plugin, online); - } - } - } +import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; +import com.falchus.lib.minecraft.spigot.packets.PacketInjector; +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; +import com.falchus.lib.minecraft.spigot.player.elements.impl.Actionbar; +import com.falchus.lib.minecraft.spigot.player.elements.impl.Bossbar; +import com.falchus.lib.minecraft.spigot.player.elements.impl.Chat; +import com.falchus.lib.minecraft.spigot.player.elements.impl.Nametag; +import com.falchus.lib.minecraft.spigot.player.elements.impl.Scoreboard; +import com.falchus.lib.minecraft.spigot.player.elements.impl.Tablist; +import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - PlayerElement.updateAll(Actionbar.class); - PlayerElement.updateAll(Bossbar.class); - PlayerElement.updateAll(Chat.class); - PlayerElement.updateAll(Nametag.class); - PlayerElement.updateAll(Scoreboard.class); - PlayerElement.updateAll(Tablist.class); - } +public class JoinQuitListener implements Listener { - @EventHandler(priority = EventPriority.HIGHEST) - public void onPlayerQuit_HIGHEST(@NotNull PlayerQuitEvent event) { - PacketInjector.uninject(event.getPlayer()); - } -} \ No newline at end of file + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + public JoinQuitListener() { + Bukkit.getPluginManager().registerEvents(this, plugin); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void onPlayerJoin_LOWEST(PlayerJoinEvent event) { + PacketInjector.inject(event.getPlayer()); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) { + PlayerElement.updateAll(Actionbar.class); + PlayerElement.updateAll(Bossbar.class); + PlayerElement.updateAll(Chat.class); + PlayerElement.updateAll(Nametag.class); + PlayerElement.updateAll(Scoreboard.class); + PlayerElement.updateAll(Tablist.class); + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerJoin_HIGH(PlayerJoinEvent event) { + Player player = event.getPlayer(); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + if (PlayerUtils.vanished.contains(player.getUniqueId())) { + onlinePlayer.hidePlayer(player); + } else { + onlinePlayer.showPlayer(player); + } + if (PlayerUtils.vanished.contains(onlinePlayer.getUniqueId())) { + player.hidePlayer(onlinePlayer); + } else { + player.showPlayer(onlinePlayer); + } + } + } + + @EventHandler + public void onPlayerQuit(PlayerQuitEvent event) { + PlayerElement.updateAll(Actionbar.class); + PlayerElement.updateAll(Bossbar.class); + PlayerElement.updateAll(Chat.class); + PlayerElement.updateAll(Nametag.class); + PlayerElement.updateAll(Scoreboard.class); + PlayerElement.updateAll(Tablist.class); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onPlayerQuit_HIGHEST(PlayerQuitEvent event) { + PacketInjector.uninject(event.getPlayer()); + } +} From 55b856c265647f1083ca37cc46f8cbec1af43a79 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:22:36 +0200 Subject: [PATCH 043/260] Update LobbyCancelListener.java --- .../spigot/listeners/LobbyCancelListener.java | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/listeners/LobbyCancelListener.java b/src/com/falchus/lib/minecraft/spigot/listeners/LobbyCancelListener.java index f3be77d9..19be8239 100644 --- a/src/com/falchus/lib/minecraft/spigot/listeners/LobbyCancelListener.java +++ b/src/com/falchus/lib/minecraft/spigot/listeners/LobbyCancelListener.java @@ -38,188 +38,188 @@ public class LobbyCancelListener implements Listener { private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - + public LobbyCancelListener() { Bukkit.getPluginManager().registerEvents(this, plugin); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onInventoryClick(InventoryClickEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityDamage(EntityDamageEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityExplode(EntityExplodeEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockPlace(BlockPlaceEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockPhysics(BlockPhysicsEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockFade(BlockFadeEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onBlockForm(BlockFormEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerDropItem(PlayerDropItemEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerPickupItem(PlayerPickupItemEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onFoodLevelChange(FoodLevelChangeEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onHangingBreak(HangingBreakEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntitySpawn(EntitySpawnEvent event) { if (event.getEntityType() == EntityType.ARMOR_STAND) return; - + LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onItemSpawn(ItemSpawnEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerBucketFill(PlayerBucketFillEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerShearEntity(PlayerShearEntityEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerArmorStandManipulate(PlayerArmorStandManipulateEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onEntityTarget(EntityTargetEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleDamage(VehicleDamageEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleDestroy(VehicleDestroyEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); Bukkit.getPluginManager().callEvent(e); event.setCancelled(e.isCancelled()); } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) { LobbyCancelEvent e = new LobbyCancelEvent(event); From 6d85c6309db679dc58a6e81c6d5dbbb07e235e93 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:23:10 +0200 Subject: [PATCH 044/260] Update ClientManager.java --- .../spigot/manager/ClientManager.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/manager/ClientManager.java b/src/com/falchus/lib/minecraft/spigot/manager/ClientManager.java index 997d6ccb..e6e3f21a 100644 --- a/src/com/falchus/lib/minecraft/spigot/manager/ClientManager.java +++ b/src/com/falchus/lib/minecraft/spigot/manager/ClientManager.java @@ -1,20 +1,21 @@ package com.falchus.lib.minecraft.spigot.manager; -import com.falchus.lib.minecraft.spigot.enums.Client; -import org.bukkit.entity.Player; - import java.util.HashMap; import java.util.Map; -public class ClientManager { +import org.bukkit.entity.Player; - private static final Map clients = new HashMap<>(); +import com.falchus.lib.minecraft.spigot.enums.Client; - public static Client get(Player player) { - return clients.getOrDefault(player, Client.OTHER); - } +public class ClientManager { - public void set(Player player, Client client) { - clients.put(player, client); - } + private static final Map clients = new HashMap<>(); + + public static Client get(Player player) { + return clients.getOrDefault(player, Client.OTHER); + } + + public void set(Player player, Client client) { + clients.put(player, client); + } } From d85e8e2cdf9cfaec3abe567c158252821c407e6f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:23:57 +0200 Subject: [PATCH 045/260] Update PacketAbilitiesWrapper.java --- .../abilities/PacketAbilitiesWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/PacketAbilitiesWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/PacketAbilitiesWrapper.java index 95546d13..4cf7689f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/PacketAbilitiesWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/PacketAbilitiesWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.abilities; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketAbilitiesWrapper extends PacketWrapper { - - Field flying; - - PacketAbilitiesWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - flying = getFirstField( - "isFlying", - "b" - ); - } - - public boolean isFlying() { - return getFieldValue(flying); - } - - public void setFlying(boolean isFlying) { - setField(this.flying, isFlying); - } + + Field flying; + + PacketAbilitiesWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + flying = getFirstField( + "isFlying", + "b" + ); + } + + public boolean isFlying() { + return getFieldValue(flying); + } + + public void setFlying(boolean isFlying) { + setField(this.flying, isFlying); + } } From d63b9cb12e0fe4204f085bad7c4ca66222c5da78 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:24:15 +0200 Subject: [PATCH 046/260] Update WrappedPacketInAbilities.java --- .../abilities/WrappedPacketInAbilities.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketInAbilities.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketInAbilities.java index 3a9376a3..85fe2335 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketInAbilities.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketInAbilities.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.abilities; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInAbilities extends PacketAbilitiesWrapper { - public WrappedPacketInAbilities(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInAbilities", - networkProtocolGame + "PacketPlayInAbilities" - ) - ); - } + public WrappedPacketInAbilities(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInAbilities", + networkProtocolGame + "PacketPlayInAbilities" + ) + ); + } } From cde40426385f660e1ddb9c7dfa494f1fa3a7adb6 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:25:23 +0200 Subject: [PATCH 047/260] Update WrappedPacketOutAbilities.java --- .../abilities/WrappedPacketOutAbilities.java | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketOutAbilities.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketOutAbilities.java index cf30da25..cc0b8868 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketOutAbilities.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/abilities/WrappedPacketOutAbilities.java @@ -1,84 +1,84 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.abilities; -import lombok.NonNull; - import java.lang.reflect.Field; import java.util.Set; -public class WrappedPacketOutAbilities extends PacketAbilitiesWrapper { - - Field invulnerable; - Field canFly; - Field instabuild; - Field flyingSpeed; - Field walkingSpeed; - - public WrappedPacketOutAbilities(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutAbilities", - networkProtocolGame + "PacketPlayOutAbilities" - ) - ); - - invulnerable = getFirstField( - "invulnerable", - "a" - ); - canFly = getFirstField( - "canFly", - "c" - ); - instabuild = getFirstField( - "instabuild", - "d" - ); - flyingSpeed = getFirstField( - "flyingSpeed", - "e" - ); - walkingSpeed = getFirstField( - "walkingSpeed", - "f" - ); - } - - public boolean isInvulnerable() { - return getFieldValue(invulnerable); - } - - public void setInvulnerable(boolean invulnerable) { - setField(this.invulnerable, invulnerable); - } - - public boolean isCanFly() { - return getFieldValue(canFly); - } - - public void setCanFly(boolean canFly) { - setField(this.canFly, canFly); - } - - public boolean isInstabuild() { - return getFieldValue(instabuild); - } - - public void setInstabuild(boolean instabuild) { - setField(this.instabuild, instabuild); - } - - public float getFlyingSpeed() { - return getFieldValue(flyingSpeed); - } - - public void setFlyingSpeed(float flyingSpeed) { - setField(this.flyingSpeed, flyingSpeed); - } +import lombok.NonNull; - public float getWalkingSpeed() { - return getFieldValue(walkingSpeed); - } +public class WrappedPacketOutAbilities extends PacketAbilitiesWrapper { - public void setWalkingSpeed(float walkingSpeed) { - setField(this.walkingSpeed, walkingSpeed); - } + Field invulnerable; + Field canFly; + Field instabuild; + Field flyingSpeed; + Field walkingSpeed; + + public WrappedPacketOutAbilities(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutAbilities", + networkProtocolGame + "PacketPlayOutAbilities" + ) + ); + + invulnerable = getFirstField( + "invulnerable", + "a" + ); + canFly = getFirstField( + "canFly", + "c" + ); + instabuild = getFirstField( + "instabuild", + "d" + ); + flyingSpeed = getFirstField( + "flyingSpeed", + "e" + ); + walkingSpeed = getFirstField( + "walkingSpeed", + "f" + ); + } + + public boolean isInvulnerable() { + return getFieldValue(invulnerable); + } + + public void setInvulnerable(boolean invulnerable) { + setField(this.invulnerable, invulnerable); + } + + public boolean isCanFly() { + return getFieldValue(canFly); + } + + public void setCanFly(boolean canFly) { + setField(this.canFly, canFly); + } + + public boolean isInstabuild() { + return getFieldValue(instabuild); + } + + public void setInstabuild(boolean instabuild) { + setField(this.instabuild, instabuild); + } + + public float getFlyingSpeed() { + return getFieldValue(flyingSpeed); + } + + public void setFlyingSpeed(float flyingSpeed) { + setField(this.flyingSpeed, flyingSpeed); + } + + public float getWalkingSpeed() { + return getFieldValue(walkingSpeed); + } + + public void setWalkingSpeed(float walkingSpeed) { + setField(this.walkingSpeed, walkingSpeed); + } } From 2856d0330eb19ce457ba9b4f04bafd98df6c243f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:25:55 +0200 Subject: [PATCH 048/260] Update PacketAnimationWrapper.java --- .../animation/PacketAnimationWrapper.java | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/PacketAnimationWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/PacketAnimationWrapper.java index d342fa02..4cc2f82e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/PacketAnimationWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/PacketAnimationWrapper.java @@ -1,44 +1,45 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.animation; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketAnimationWrapper extends PacketWrapper { - - Field id; - Field action; - - PacketAnimationWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - id = getFirstField( - "id", - "a" - ); - action = getFirstField( - "action", - "b" - ); - } - - public int getId() { - return getFieldValue(id); - } - - public void setId(int id) { - setField(this.id, id); - } - - public int getAction() { - return getFieldValue(action); - } - - public void setAction(int action) { - setField(this.action, action); - } + + Field id; + Field action; + + PacketAnimationWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + id = getFirstField( + "id", + "a" + ); + action = getFirstField( + "action", + "b" + ); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public int getAction() { + return getFieldValue(action); + } + + public void setAction(int action) { + setField(this.action, action); + } } From cb0344f72d64cc3cfd9a6b66c53a33acf49c5829 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:26:08 +0200 Subject: [PATCH 049/260] Update WrappedPacketOutAnimation.java --- .../animation/WrappedPacketOutAnimation.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/WrappedPacketOutAnimation.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/WrappedPacketOutAnimation.java index 5265621f..1b59498f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/WrappedPacketOutAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/animation/WrappedPacketOutAnimation.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.animation; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutAnimation extends PacketAnimationWrapper { - public WrappedPacketOutAnimation(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutAnimation", - networkProtocolGame + "PacketPlayOutAnimation" - ) - ); - } + public WrappedPacketOutAnimation(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutAnimation", + networkProtocolGame + "PacketPlayOutAnimation" + ) + ); + } } From a75013b14409fbe80c2d9d22df93c90c4fc9bf2b Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:26:24 +0200 Subject: [PATCH 050/260] Update PacketArmAnimationWrapper.java --- .../armanimation/PacketArmAnimationWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/PacketArmAnimationWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/PacketArmAnimationWrapper.java index e5a84e3a..000c4d2f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/PacketArmAnimationWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/PacketArmAnimationWrapper.java @@ -1,13 +1,14 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.armanimation; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import java.util.Set; +import lombok.NonNull; abstract class PacketArmAnimationWrapper extends PacketWrapper { - PacketArmAnimationWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketArmAnimationWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From a25a81e7e0ccfff6c99929f0d8ebb7fb488dedde Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:26:35 +0200 Subject: [PATCH 051/260] Update WrappedPacketInArmAnimation.java --- .../WrappedPacketInArmAnimation.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/WrappedPacketInArmAnimation.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/WrappedPacketInArmAnimation.java index cc171ea8..705b8b07 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/WrappedPacketInArmAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/armanimation/WrappedPacketInArmAnimation.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.armanimation; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInArmAnimation extends PacketArmAnimationWrapper { - public WrappedPacketInArmAnimation(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInArmAnimation", - networkProtocolGame + "PacketPlayInArmAnimation" - ) - ); - } + public WrappedPacketInArmAnimation(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInArmAnimation", + networkProtocolGame + "PacketPlayInArmAnimation" + ) + ); + } } From 85abe2f4bd9b3f41ed6876ddf2fc5abc52c9fa8a Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:27:03 +0200 Subject: [PATCH 052/260] Update PacketAttachEntityWrapper.java --- .../PacketAttachEntityWrapper.java | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/PacketAttachEntityWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/PacketAttachEntityWrapper.java index 768e11ff..19a33d29 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/PacketAttachEntityWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/PacketAttachEntityWrapper.java @@ -1,44 +1,45 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.attachentity; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketAttachEntityWrapper extends PacketWrapper { - - Field sourceId; - Field destId; - - PacketAttachEntityWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - sourceId = getFirstField( - "sourceId", - "b" - ); - destId = getFirstField( - "destId", - "c" - ); - } - - public int getSourceId() { - return getFieldValue(sourceId); - } - - public void setSourceId(int sourceId) { - setField(this.sourceId, sourceId); - } - - public int getDestId() { - return getFieldValue(destId); - } - - public void setDestId(int destId) { - setField(this.destId, destId); - } + + Field sourceId; + Field destId; + + PacketAttachEntityWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + sourceId = getFirstField( + "sourceId", + "b" + ); + destId = getFirstField( + "destId", + "c" + ); + } + + public int getSourceId() { + return getFieldValue(sourceId); + } + + public void setSourceId(int sourceId) { + setField(this.sourceId, sourceId); + } + + public int getDestId() { + return getFieldValue(destId); + } + + public void setDestId(int destId) { + setField(this.destId, destId); + } } From b4f19312ad48fe29d04260e8928945d16e406968 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:27:16 +0200 Subject: [PATCH 053/260] Update WrappedPacketOutAttachEntity.java --- .../WrappedPacketOutAttachEntity.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/WrappedPacketOutAttachEntity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/WrappedPacketOutAttachEntity.java index f1ed59b2..799bf6e6 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/WrappedPacketOutAttachEntity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/attachentity/WrappedPacketOutAttachEntity.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.attachentity; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutAttachEntity extends PacketAttachEntityWrapper { - public WrappedPacketOutAttachEntity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutAttachEntity", - networkProtocolGame + "PacketPlayOutAttachEntity" - ) - ); - } + public WrappedPacketOutAttachEntity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutAttachEntity", + networkProtocolGame + "PacketPlayOutAttachEntity" + ) + ); + } } From 81fee6e0c255f76d972cf86b6f090191baa347da Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:28:05 +0200 Subject: [PATCH 054/260] Update PacketBlockActionWrapper.java --- .../action/PacketBlockActionWrapper.java | 126 +++++++++--------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/PacketBlockActionWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/PacketBlockActionWrapper.java index f35a6fea..274a44ce 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/PacketBlockActionWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/PacketBlockActionWrapper.java @@ -10,71 +10,71 @@ @FieldDefaults(makeFinal = true) abstract class PacketBlockActionWrapper extends PacketWrapper { + + Field pos; + Field type; + Field data; + Field block; + + PacketBlockActionWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + type = getFirstField( + "b0", + "b" + ); + data = getFirstField( + "b1", + "c" + ); + block = getFirstField( + "block", + "d" + ); + } - Field pos; - Field type; - Field data; - Field block; + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } - PacketBlockActionWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); + public int getType() { + return getFieldValue(type); + } + + public void setType(int type) { + setField(this.type, type); + } - pos = getFirstField( - "pos", - "a" - ); - type = getFirstField( - "b0", - "b" - ); - data = getFirstField( - "b1", - "c" - ); - block = getFirstField( - "block", - "d" - ); - } + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - public int getType() { - return getFieldValue(type); - } - - public void setType(int type) { - setField(this.type, type); - } - - public int getData() { - return getFieldValue(data); - } - - public void setData(int data) { - setField(this.data, data); - } - - public Object getBlock() { - return getFieldValue(block); - } - - /** - * @param block: Block - */ - public void setBlock(Object block) { - setField(this.block, block); - } + public Object getBlock() { + return getFieldValue(block); + } + + /** + * @param block: Block + */ + public void setBlock(Object block) { + setField(this.block, block); + } } From 0dffbb3a2737aa0f77f3bf1e5df33c9f023d8d44 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:28:19 +0200 Subject: [PATCH 055/260] Update WrappedPacketOutBlockAction.java --- .../block/action/WrappedPacketOutBlockAction.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/WrappedPacketOutBlockAction.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/WrappedPacketOutBlockAction.java index 3949c619..ce8e61c5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/WrappedPacketOutBlockAction.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/action/WrappedPacketOutBlockAction.java @@ -6,11 +6,11 @@ public class WrappedPacketOutBlockAction extends PacketBlockActionWrapper { - public WrappedPacketOutBlockAction(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutBlockAction", - networkProtocolGame + "PacketPlayOutBlockAction" - ) - ); - } + public WrappedPacketOutBlockAction(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutBlockAction", + networkProtocolGame + "PacketPlayOutBlockAction" + ) + ); + } } From 4eb406e17eb68b76ed11fa20d394fbf31d0d1bbd Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:28:52 +0200 Subject: [PATCH 056/260] Update PacketBlockBreakAnimationWrapper.java --- .../PacketBlockBreakAnimationWrapper.java | 103 +++++++++--------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/PacketBlockBreakAnimationWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/PacketBlockBreakAnimationWrapper.java index bfbb5d49..96509260 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/PacketBlockBreakAnimationWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/PacketBlockBreakAnimationWrapper.java @@ -1,63 +1,64 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.breakanimation; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketBlockBreakAnimationWrapper extends PacketWrapper { + + Field id; + Field pos; + Field progress; + + PacketBlockBreakAnimationWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + id = getFirstField( + "id", + "a" + ); + pos = getFirstField( + "pos", + "b" + ); + progress = getFirstField( + "progress", + "c" + ); + } - Field id; - Field pos; - Field progress; - - PacketBlockBreakAnimationWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - id = getFirstField( - "id", - "a" - ); - pos = getFirstField( - "pos", - "b" - ); - progress = getFirstField( - "progress", - "c" - ); - } - - public int getId() { - return getFieldValue(id); - } - - public void setId(int id) { - setField(this.id, id); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } - public int getProgress() { - return getFieldValue(progress); - } + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } - public void setProgress(int progress) { - setField(this.progress, progress); - } + public int getProgress() { + return getFieldValue(progress); + } + + public void setProgress(int progress) { + setField(this.progress, progress); + } } From 649f51b1d15e6244196eefc905225ed846d4606e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:29:04 +0200 Subject: [PATCH 057/260] Update WrappedPacketOutBlockBreakAnimation.java --- .../WrappedPacketOutBlockBreakAnimation.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/WrappedPacketOutBlockBreakAnimation.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/WrappedPacketOutBlockBreakAnimation.java index 8d6b4555..126caef9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/WrappedPacketOutBlockBreakAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/breakanimation/WrappedPacketOutBlockBreakAnimation.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.breakanimation; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutBlockBreakAnimation extends PacketBlockBreakAnimationWrapper { - public WrappedPacketOutBlockBreakAnimation(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutBlockBreakAnimation", - networkProtocolGame + "PacketPlayOutBlockBreakAnimation" - ) - ); - } + public WrappedPacketOutBlockBreakAnimation(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutBlockBreakAnimation", + networkProtocolGame + "PacketPlayOutBlockBreakAnimation" + ) + ); + } } From 408b5b380a74d8be97d3ffe55ea6e1e66ab4f47b Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:29:30 +0200 Subject: [PATCH 058/260] Update PacketBlockChangeWrapper.java --- .../change/PacketBlockChangeWrapper.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/PacketBlockChangeWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/PacketBlockChangeWrapper.java index eced5465..33305eca 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/PacketBlockChangeWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/PacketBlockChangeWrapper.java @@ -10,29 +10,29 @@ @FieldDefaults(makeFinal = true) abstract class PacketBlockChangeWrapper extends PacketWrapper { - - Field pos; - - PacketBlockChangeWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } + + Field pos; + + PacketBlockChangeWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } } From 4525d3f19e8c483052110381f5fc844145cba8ba Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:29:41 +0200 Subject: [PATCH 059/260] Update WrappedPacketOutBlockChange.java --- .../block/change/WrappedPacketOutBlockChange.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/WrappedPacketOutBlockChange.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/WrappedPacketOutBlockChange.java index 152f8f2e..6190f9d0 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/WrappedPacketOutBlockChange.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/change/WrappedPacketOutBlockChange.java @@ -6,11 +6,11 @@ public class WrappedPacketOutBlockChange extends PacketBlockChangeWrapper { - public WrappedPacketOutBlockChange(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutBlockChange", - networkProtocolGame + "PacketPlayOutBlockChange" - ) - ); - } + public WrappedPacketOutBlockChange(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutBlockChange", + networkProtocolGame + "PacketPlayOutBlockChange" + ) + ); + } } From c35331d6930e87e5df0d4a255cf94aeafa2d1ee4 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:30:14 +0200 Subject: [PATCH 060/260] Update PacketBlockDigWrapper.java --- .../block/dig/PacketBlockDigWrapper.java | 127 +++++++++--------- 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/PacketBlockDigWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/PacketBlockDigWrapper.java index c60c1da9..56c5796f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/PacketBlockDigWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/PacketBlockDigWrapper.java @@ -1,75 +1,76 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.dig; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketBlockDigWrapper extends PacketWrapper { + + Field pos; + Field direction; + Field action; + + PacketBlockDigWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + direction = getFirstField( + "direction", + "b" + ); + action = getFirstField( + "action", + "c" + ); + } - Field pos; - Field direction; - Field action; - - PacketBlockDigWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - direction = getFirstField( - "direction", - "b" - ); - action = getFirstField( - "action", - "c" - ); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - /** - * @return EnumDirection - */ - public Object getDirection() { - return getFieldValue(direction); - } - - /** - * @param pos: EnumDirection - */ - public void setDirection(Object direction) { - setField(this.direction, direction); - } + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } - /** - * @return EnumPlayerDigType - */ - public Object getAction() { - return getFieldValue(action); - } + /** + * @return EnumDirection + */ + public Object getDirection() { + return getFieldValue(direction); + } + + /** + * @param pos: EnumDirection + */ + public void setDirection(Object direction) { + setField(this.direction, direction); + } - /** - * @param pos: EnumPlayerDigType - */ - public void setAction(Object action) { - setField(this.action, action); - } + /** + * @return EnumPlayerDigType + */ + public Object getAction() { + return getFieldValue(action); + } + + /** + * @param pos: EnumPlayerDigType + */ + public void setAction(Object action) { + setField(this.action, action); + } } From e041a65c34c41a09e99cfd1fd9a397d68aa6dbd3 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:31:50 +0200 Subject: [PATCH 061/260] Update WrappedPacketInBlockDig.java --- .../block/dig/WrappedPacketInBlockDig.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/WrappedPacketInBlockDig.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/WrappedPacketInBlockDig.java index 59254ca7..f1fd44de 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/WrappedPacketInBlockDig.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/dig/WrappedPacketInBlockDig.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.dig; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInBlockDig extends PacketBlockDigWrapper { - public WrappedPacketInBlockDig(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInBlockDig", - networkProtocolGame + "PacketPlayInBlockDig" - ) - ); - } + public WrappedPacketInBlockDig(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInBlockDig", + networkProtocolGame + "PacketPlayInBlockDig" + ) + ); + } } From f32602dda8f02e94388af6f81b2bb2c94ff14798 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:32:27 +0200 Subject: [PATCH 062/260] Update PacketBlockPlaceWrapper.java --- .../block/place/PacketBlockPlaceWrapper.java | 133 +++++++++--------- 1 file changed, 67 insertions(+), 66 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/PacketBlockPlaceWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/PacketBlockPlaceWrapper.java index 9a862865..d1e1133c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/PacketBlockPlaceWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/PacketBlockPlaceWrapper.java @@ -1,79 +1,80 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.place; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketBlockPlaceWrapper extends PacketWrapper { + + Field pos; + Field type; + Field data; + Field block; + + PacketBlockPlaceWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + type = getFirstField( + "b0", + "b" + ); + data = getFirstField( + "b1", + "c" + ); + block = getFirstField( + "block", + "d" + ); + } - Field pos; - Field type; - Field data; - Field block; - - PacketBlockPlaceWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - type = getFirstField( - "b0", - "b" - ); - data = getFirstField( - "b1", - "c" - ); - block = getFirstField( - "block", - "d" - ); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - public int getType() { - return getFieldValue(type); - } - - public void setType(int type) { - setField(this.type, type); - } - - public int getData() { - return getFieldValue(data); - } + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } - public void setData(int data) { - setField(this.data, data); - } + public int getType() { + return getFieldValue(type); + } + + public void setType(int type) { + setField(this.type, type); + } - public Object getBlock() { - return getFieldValue(block); - } + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } - /** - * @param block: Block - */ - public void setBlock(Object block) { - setField(this.block, block); - } + public Object getBlock() { + return getFieldValue(block); + } + + /** + * @param block: Block + */ + public void setBlock(Object block) { + setField(this.block, block); + } } From feac3928cbb5966eab0ae38f6b859661685dbb7a Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:32:41 +0200 Subject: [PATCH 063/260] Update WrappedPacketInBlockPlace.java --- .../block/place/WrappedPacketInBlockPlace.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/WrappedPacketInBlockPlace.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/WrappedPacketInBlockPlace.java index b881b3bb..371ad5a5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/WrappedPacketInBlockPlace.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/place/WrappedPacketInBlockPlace.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.place; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInBlockPlace extends PacketBlockPlaceWrapper { - public WrappedPacketInBlockPlace(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInBlockPlace", - networkProtocolGame + "PacketPlayInBlockPlace" - ) - ); - } + public WrappedPacketInBlockPlace(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInBlockPlace", + networkProtocolGame + "PacketPlayInBlockPlace" + ) + ); + } } From e5569dbafb68d9800f0c603c6b38ef8ea8c16579 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:33:04 +0200 Subject: [PATCH 064/260] Update PacketBlockUpdateWrapper.java --- .../update/PacketBlockUpdateWrapper.java | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/PacketBlockUpdateWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/PacketBlockUpdateWrapper.java index b8ae9296..fca845ae 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/PacketBlockUpdateWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/PacketBlockUpdateWrapper.java @@ -10,48 +10,48 @@ @FieldDefaults(makeFinal = true) abstract class PacketBlockUpdateWrapper extends PacketWrapper { - - Field pos; - Field blockState; - - PacketBlockUpdateWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - blockState = getFirstField( - "blockState", - "b" - ); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - /** - * @return BlockState - */ - public Object getBlockState() { - return getFieldValue(blockState); - } - - /** - * @param block: BlockState - */ - public void setBlockState(Object blockState) { - setField(this.blockState, blockState); - } + + Field pos; + Field blockState; + + PacketBlockUpdateWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + blockState = getFirstField( + "blockState", + "b" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } + + /** + * @return BlockState + */ + public Object getBlockState() { + return getFieldValue(blockState); + } + + /** + * @param block: BlockState + */ + public void setBlockState(Object blockState) { + setField(this.blockState, blockState); + } } From 6f230cc741c8c8c8477ea58dd0c65d9a4d787b21 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:33:17 +0200 Subject: [PATCH 065/260] Update WrappedPacketOutBlockUpdate.java --- .../update/WrappedPacketOutBlockUpdate.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/WrappedPacketOutBlockUpdate.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/WrappedPacketOutBlockUpdate.java index f6f684eb..b2744b8f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/WrappedPacketOutBlockUpdate.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/block/update/WrappedPacketOutBlockUpdate.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.block.update; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutBlockUpdate extends PacketBlockUpdateWrapper { - public WrappedPacketOutBlockUpdate(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutBlockChange", - networkProtocolGame + "PacketPlayOutBlockChange" - ) - ); - } + public WrappedPacketOutBlockUpdate(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutBlockChange", + networkProtocolGame + "PacketPlayOutBlockChange" + ) + ); + } } From 63fbc638037e86e4d7dfbb84a28cb3c6f802fa93 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:33:34 +0200 Subject: [PATCH 066/260] Update PacketCameraWrapper.java --- .../wrapper/camera/PacketCameraWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/PacketCameraWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/PacketCameraWrapper.java index 29bfea12..08cd8dc1 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/PacketCameraWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/PacketCameraWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.camera; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketCameraWrapper extends PacketWrapper { - - Field cameraId; - - PacketCameraWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - cameraId = getFirstField( - "cameraId", - "a" - ); - } - - public int getCameraId() { - return getFieldValue(cameraId); - } - - public void setCameraId(int cameraId) { - setField(this.cameraId, cameraId); - } + + Field cameraId; + + PacketCameraWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + cameraId = getFirstField( + "cameraId", + "a" + ); + } + + public int getCameraId() { + return getFieldValue(cameraId); + } + + public void setCameraId(int cameraId) { + setField(this.cameraId, cameraId); + } } From 0370674da080431fdb00a9b1c11abc85deb35cfe Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:33:45 +0200 Subject: [PATCH 067/260] Update WrappedPacketOutCamera.java --- .../wrapper/camera/WrappedPacketOutCamera.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/WrappedPacketOutCamera.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/WrappedPacketOutCamera.java index 9b3bc031..1e818dac 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/WrappedPacketOutCamera.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/camera/WrappedPacketOutCamera.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.camera; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutCamera extends PacketCameraWrapper { - public WrappedPacketOutCamera(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutCamera", - networkProtocolGame + "PacketPlayOutCamera" - ) - ); - } + public WrappedPacketOutCamera(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutCamera", + networkProtocolGame + "PacketPlayOutCamera" + ) + ); + } } From 74ca99196d77d4f232b13cf7684b35590acd4f15 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:34:09 +0200 Subject: [PATCH 068/260] Update PacketChatWrapper.java --- .../wrapper/chat/PacketChatWrapper.java | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/PacketChatWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/PacketChatWrapper.java index ea5cbc31..f2f3e54e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/PacketChatWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/PacketChatWrapper.java @@ -1,35 +1,36 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.chat; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketChatWrapper extends PacketWrapper { - - Field message; - - PacketChatWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - message = getFirstField( - "unsignedContent", - "content", - "message", - "a" - ); - } - - /** - * In: {@link String} - * Out: IChatBaseComponent - */ - public Object getMessage() { - return getFieldValue(message); - } - - public abstract void setMessage(String message); + + Field message; + + PacketChatWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + message = getFirstField( + "unsignedContent", + "content", + "message", + "a" + ); + } + + /** + * In: {@link String} + * Out: IChatBaseComponent + */ + public Object getMessage() { + return getFieldValue(message); + } + + public abstract void setMessage(String message); } From a740d0ea9c5e3f1e878478b36290eccc7fb7e30e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:34:26 +0200 Subject: [PATCH 069/260] Update WrappedPacketInChat.java --- .../wrapper/chat/WrappedPacketInChat.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketInChat.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketInChat.java index 6e9cb146..ba427fcd 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketInChat.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketInChat.java @@ -1,26 +1,26 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.chat; -import lombok.NonNull; - import java.util.Set; -public class WrappedPacketInChat extends PacketChatWrapper { +import lombok.NonNull; - public WrappedPacketInChat(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInChat", - networkProtocolGame + "ServerboundChatPacket" - ) - ); - } +public class WrappedPacketInChat extends PacketChatWrapper { - @Override - public String getMessage() { - return (String) super.getMessage(); - } + public WrappedPacketInChat(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInChat", + networkProtocolGame + "ServerboundChatPacket" + ) + ); + } - @Override - public void setMessage(String message) { - setField(this.message, message); - } + @Override + public String getMessage() { + return (String) super.getMessage(); + } + + @Override + public void setMessage(String message) { + setField(this.message, message); + } } From 7a9b6757094e9d56e6fc2a74ff6b2591839b660b Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:34:39 +0200 Subject: [PATCH 070/260] Update WrappedPacketOutChat.java --- .../wrapper/chat/WrappedPacketOutChat.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketOutChat.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketOutChat.java index cd0d113b..abb1bb7d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketOutChat.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/chat/WrappedPacketOutChat.java @@ -1,23 +1,23 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.chat; -import lombok.NonNull; - import java.util.Set; -public class WrappedPacketOutChat extends PacketChatWrapper { +import lombok.NonNull; - public WrappedPacketOutChat(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutChat", - networkProtocolGame + "ClientboundSystemChatPacket", - networkProtocolGame + "ClientboundPlayerChatPacket", - networkProtocolGame + "ClientboundDisguisedChatPacket" - ) - ); - } +public class WrappedPacketOutChat extends PacketChatWrapper { - @Override - public void setMessage(String message) { - setField(this.message, version.createChatComponentText(message)); - } + public WrappedPacketOutChat(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutChat", + networkProtocolGame + "ClientboundSystemChatPacket", + networkProtocolGame + "ClientboundPlayerChatPacket", + networkProtocolGame + "ClientboundDisguisedChatPacket" + ) + ); + } + + @Override + public void setMessage(String message) { + setField(this.message, version.createChatComponentText(message)); + } } From c0bee1d5a580dd34904fbbc726a69918b686d884 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:34:59 +0200 Subject: [PATCH 071/260] Update PacketClientCommandWrapper.java --- .../PacketClientCommandWrapper.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/PacketClientCommandWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/PacketClientCommandWrapper.java index 9d8d4afc..2269f59d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/PacketClientCommandWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/PacketClientCommandWrapper.java @@ -10,29 +10,29 @@ @FieldDefaults(makeFinal = true) abstract class PacketClientCommandWrapper extends PacketWrapper { - - Field action; - - PacketClientCommandWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - action = getFirstField( - "action", - "a" - ); - } - - /** - * @return PacketPlayInClientCommand$EnumClientCommand - */ - public Object getAction() { - return getFieldValue(action); - } - - /** - * @param action: PacketPlayInClientCommand$EnumClientCommand - */ - public void setAction(Object action) { - setField(this.action, action); - } + + Field action; + + PacketClientCommandWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + action = getFirstField( + "action", + "a" + ); + } + + /** + * @return PacketPlayInClientCommand$EnumClientCommand + */ + public Object getAction() { + return getFieldValue(action); + } + + /** + * @param action: PacketPlayInClientCommand$EnumClientCommand + */ + public void setAction(Object action) { + setField(this.action, action); + } } From 376ba379c19421a346e6ae040f2b6af2d5364947 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:35:10 +0200 Subject: [PATCH 072/260] Update WrappedPacketInClientCommand.java --- .../WrappedPacketInClientCommand.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/WrappedPacketInClientCommand.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/WrappedPacketInClientCommand.java index eaa27182..e86e297f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/WrappedPacketInClientCommand.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/clientcommand/WrappedPacketInClientCommand.java @@ -6,11 +6,11 @@ public class WrappedPacketInClientCommand extends PacketClientCommandWrapper { - public WrappedPacketInClientCommand(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInClientCommand", - networkProtocolGame + "PacketPlayInClientCommand" - ) - ); - } + public WrappedPacketInClientCommand(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInClientCommand", + networkProtocolGame + "PacketPlayInClientCommand" + ) + ); + } } From e222875f87e0ebe0e1309b72a0fb58fa44e2a251 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:35:31 +0200 Subject: [PATCH 073/260] Update PacketCloseWindowWrapper.java --- .../closewindow/PacketCloseWindowWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/PacketCloseWindowWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/PacketCloseWindowWrapper.java index 2b2a438d..52814eca 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/PacketCloseWindowWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/PacketCloseWindowWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.closewindow; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketCloseWindowWrapper extends PacketWrapper { - - Field containerId; - - PacketCloseWindowWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } + + Field containerId; + + PacketCloseWindowWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } } From 2f6bf5d3157a236072bf8e802b6fdd3d43c01477 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:35:42 +0200 Subject: [PATCH 074/260] Update WrappedPacketInCloseWindow.java --- .../WrappedPacketInCloseWindow.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketInCloseWindow.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketInCloseWindow.java index dfc56181..51a436b7 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketInCloseWindow.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketInCloseWindow.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.closewindow; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInCloseWindow extends PacketCloseWindowWrapper { - public WrappedPacketInCloseWindow(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInCloseWindow", - networkProtocolGame + "PacketPlayInCloseWindow" - ) - ); - } + public WrappedPacketInCloseWindow(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInCloseWindow", + networkProtocolGame + "PacketPlayInCloseWindow" + ) + ); + } } From aa3ac2f2c8a440309a1adee2156de548870c8fbe Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:35:55 +0200 Subject: [PATCH 075/260] Update WrappedPacketOutCloseWindow.java --- .../WrappedPacketOutCloseWindow.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketOutCloseWindow.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketOutCloseWindow.java index acbd7579..61688c73 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketOutCloseWindow.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/closewindow/WrappedPacketOutCloseWindow.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.closewindow; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutCloseWindow extends PacketCloseWindowWrapper { - public WrappedPacketOutCloseWindow(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutCloseWindow", - networkProtocolGame + "PacketPlayOutCloseWindow" - ) - ); - } + public WrappedPacketOutCloseWindow(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutCloseWindow", + networkProtocolGame + "PacketPlayOutCloseWindow" + ) + ); + } } From fc115e2dc7ddaf1e48bed42a2bdac987d04eb6a2 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:36:16 +0200 Subject: [PATCH 076/260] Update PacketCollectWrapper.java --- .../wrapper/collect/PacketCollectWrapper.java | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/PacketCollectWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/PacketCollectWrapper.java index 1d0ee9d5..85235284 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/PacketCollectWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/PacketCollectWrapper.java @@ -1,44 +1,45 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.collect; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketCollectWrapper extends PacketWrapper { - - Field itemId; - Field playerId; - - PacketCollectWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - itemId = getFirstField( - "itemId", - "a" - ); - playerId = getFirstField( - "playerId", - "b" - ); - } - - public int getItemId() { - return getFieldValue(itemId); - } - - public void setItemId(int itemId) { - setField(this.itemId, itemId); - } - - public int getPlayerId() { - return getFieldValue(playerId); - } - - public void setPlayerId(int playerId) { - setField(this.playerId, playerId); - } + + Field itemId; + Field playerId; + + PacketCollectWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + itemId = getFirstField( + "itemId", + "a" + ); + playerId = getFirstField( + "playerId", + "b" + ); + } + + public int getItemId() { + return getFieldValue(itemId); + } + + public void setItemId(int itemId) { + setField(this.itemId, itemId); + } + + public int getPlayerId() { + return getFieldValue(playerId); + } + + public void setPlayerId(int playerId) { + setField(this.playerId, playerId); + } } From fcfc097faabb976f9561292da9c5f3bc8b5ab1d7 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:36:28 +0200 Subject: [PATCH 077/260] Update WrappedPacketOutCollect.java --- .../collect/WrappedPacketOutCollect.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/WrappedPacketOutCollect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/WrappedPacketOutCollect.java index 79fcc9a4..cf1013c5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/WrappedPacketOutCollect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/collect/WrappedPacketOutCollect.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.collect; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutCollect extends PacketCollectWrapper { - public WrappedPacketOutCollect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutCollect", - networkProtocolGame + "PacketPlayOutCollect" - ) - ); - } + public WrappedPacketOutCollect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutCollect", + networkProtocolGame + "PacketPlayOutCollect" + ) + ); + } } From d222f8994f3df28ebb6eca0adb618432d31d2852 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:36:43 +0200 Subject: [PATCH 078/260] Update PacketCustomPayloadWrapper.java --- .../wrapper/custompayload/PacketCustomPayloadWrapper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/PacketCustomPayloadWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/PacketCustomPayloadWrapper.java index 246bd50e..b540e5af 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/PacketCustomPayloadWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/PacketCustomPayloadWrapper.java @@ -8,7 +8,7 @@ abstract class PacketCustomPayloadWrapper extends PacketWrapper { - PacketCustomPayloadWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketCustomPayloadWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From ee74f6000ec218e92b80c77c550206f8d6be4914 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:36:54 +0200 Subject: [PATCH 079/260] Update WrappedPacketInCustomPayload.java --- .../WrappedPacketInCustomPayload.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketInCustomPayload.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketInCustomPayload.java index e2daa28d..5024af86 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketInCustomPayload.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketInCustomPayload.java @@ -6,11 +6,11 @@ public class WrappedPacketInCustomPayload extends PacketCustomPayloadWrapper { - public WrappedPacketInCustomPayload(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInCustomPayload", - networkProtocolCommon + "ServerboundCustomPayloadPacket" - ) - ); - } + public WrappedPacketInCustomPayload(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInCustomPayload", + networkProtocolCommon + "ServerboundCustomPayloadPacket" + ) + ); + } } From 7acefd258cbb3dd7ae48a463317833c505bf0bcc Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:37:05 +0200 Subject: [PATCH 080/260] Update WrappedPacketOutCustomPayload.java --- .../WrappedPacketOutCustomPayload.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketOutCustomPayload.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketOutCustomPayload.java index 5eb0d62a..bd365b65 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketOutCustomPayload.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/custompayload/WrappedPacketOutCustomPayload.java @@ -6,11 +6,11 @@ public class WrappedPacketOutCustomPayload extends PacketCustomPayloadWrapper { - public WrappedPacketOutCustomPayload(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutCustomPayload", - networkProtocolCommon + "ClientboundCustomPayloadPacket" - ) - ); - } + public WrappedPacketOutCustomPayload(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutCustomPayload", + networkProtocolCommon + "ClientboundCustomPayloadPacket" + ) + ); + } } From 8754f441246b03dee49e973f693ee8718a4c506d Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:37:29 +0200 Subject: [PATCH 081/260] Update PacketEnchantItemWrapper.java --- .../enchantitem/PacketEnchantItemWrapper.java | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/PacketEnchantItemWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/PacketEnchantItemWrapper.java index e805bde6..f4a2276f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/PacketEnchantItemWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/PacketEnchantItemWrapper.java @@ -1,44 +1,45 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.enchantitem; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketEnchantItemWrapper extends PacketWrapper { - - Field containerId; - Field buttonId; - - PacketEnchantItemWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - buttonId = getFirstField( - "buttonId", - "b" - ); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public int getButtonId() { - return getFieldValue(buttonId); - } - - public void setButtonId(int buttonId) { - setField(this.buttonId, buttonId); - } + + Field containerId; + Field buttonId; + + PacketEnchantItemWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + buttonId = getFirstField( + "buttonId", + "b" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } + + public int getButtonId() { + return getFieldValue(buttonId); + } + + public void setButtonId(int buttonId) { + setField(this.buttonId, buttonId); + } } From d03f9cd0fb8d8528be8dcb5911f47d09bca31a09 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:37:40 +0200 Subject: [PATCH 082/260] Update WrappedPacketInEnchantItem.java --- .../WrappedPacketInEnchantItem.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/WrappedPacketInEnchantItem.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/WrappedPacketInEnchantItem.java index f2a74ba5..cf3d2a5e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/WrappedPacketInEnchantItem.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/enchantitem/WrappedPacketInEnchantItem.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.enchantitem; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInEnchantItem extends PacketEnchantItemWrapper { - public WrappedPacketInEnchantItem(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInEnchantItem", - networkProtocolGame + "PacketPlayInEnchantItem" - ) - ); - } + public WrappedPacketInEnchantItem(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInEnchantItem", + networkProtocolGame + "PacketPlayInEnchantItem" + ) + ); + } } From 109a74f29f1c70c9e0c9cc76f84b96035f0f6db2 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:37:56 +0200 Subject: [PATCH 083/260] Update PacketEntityWrapper.java --- .../wrapper/entity/PacketEntityWrapper.java | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/PacketEntityWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/PacketEntityWrapper.java index 91f8b201..0199663f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/PacketEntityWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/PacketEntityWrapper.java @@ -1,33 +1,34 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketEntityWrapper extends PacketWrapper { - Field entityId; - - PacketEntityWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - entityId = getFirstField( - "entityId", - "entity", - "id", - "a" - ); - } - - public int getEntityId() { - return getFieldValue(entityId); - } - - public void setEntityId(int entityId) { - setField(this.entityId, entityId); - } + Field entityId; + + PacketEntityWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + entityId = getFirstField( + "entityId", + "entity", + "id", + "a" + ); + } + + public int getEntityId() { + return getFieldValue(entityId); + } + + public void setEntityId(int entityId) { + setField(this.entityId, entityId); + } } From 42806b59cef49efb2dac6095de1d044b366ceb5f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:38:17 +0200 Subject: [PATCH 084/260] Update WrappedPacketInEntityAction.java --- .../entity/WrappedPacketInEntityAction.java | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketInEntityAction.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketInEntityAction.java index 777f0687..0f64f909 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketInEntityAction.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketInEntityAction.java @@ -1,53 +1,53 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketInEntityAction extends PacketEntityWrapper { - Field action; - Field data; - - WrappedPacketInEntityAction(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInEntityAction", - networkProtocolGame + "PacketPlayInEntityAction" - ) - ); - - action = getFirstField( - "action", - "animation" - ); - data = getFirstField( - "data", - "c" - ); - } - - /** - * @return PacketPlayInEntityAction$EnumPlayerAction - */ - public Object getAction() { - return getFieldValue(action); - } - - /** - * @param action: PacketPlayInEntityAction$EnumPlayerAction - */ - public void setAction(Object action) { - setField(this.action, action); - } - - public int getData() { - return getFieldValue(data); - } - - public void setData(int data) { - setField(this.data, data); - } + Field action; + Field data; + + WrappedPacketInEntityAction(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInEntityAction", + networkProtocolGame + "PacketPlayInEntityAction" + ) + ); + + action = getFirstField( + "action", + "animation" + ); + data = getFirstField( + "data", + "c" + ); + } + + /** + * @return PacketPlayInEntityAction$EnumPlayerAction + */ + public Object getAction() { + return getFieldValue(action); + } + + /** + * @param action: PacketPlayInEntityAction$EnumPlayerAction + */ + public void setAction(Object action) { + setField(this.action, action); + } + + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } } From 1cf7e15b72d85412c8e581e83988e2a291fafbf3 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:38:51 +0200 Subject: [PATCH 085/260] Update WrappedPacketOutEntity.java --- .../entity/WrappedPacketOutEntity.java | 126 +++++++++--------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntity.java index 6e24acc0..4d0b2eab 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntity.java @@ -1,75 +1,75 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntity extends PacketEntityWrapper { + + Field yRot; + Field xRot; + Field onGround; + Field hasRot; + + WrappedPacketOutEntity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntity", + networkProtocolGame + "PacketPlayOutEntity" + ) + ); + + yRot = getFirstField( + "yRot", + "yHeadRot", + "e", + "b" + ); + xRot = getFirstField( + "xRot", + "f" + ); + onGround = getFirstField( + "onGround", + "g" + ); + hasRot = getFirstField( + "hasRot", + "h" + ); + } - Field yRot; - Field xRot; - Field onGround; - Field hasRot; - - WrappedPacketOutEntity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntity", - networkProtocolGame + "PacketPlayOutEntity" - ) - ); - - yRot = getFirstField( - "yRot", - "yHeadRot", - "e", - "b" - ); - xRot = getFirstField( - "xRot", - "f" - ); - onGround = getFirstField( - "onGround", - "g" - ); - hasRot = getFirstField( - "hasRot", - "h" - ); - } - - public byte getYRot() { - return getFieldValue(yRot); - } - - public void setYRot(byte yRot) { - setField(this.yRot, yRot); - } - - public byte getXRot() { - return getFieldValue(xRot); - } - - public void setXRot(byte xRot) { - setField(this.xRot, xRot); - } - - public boolean isOnGround() { - return getFieldValue(onGround); - } + public byte getYRot() { + return getFieldValue(yRot); + } + + public void setYRot(byte yRot) { + setField(this.yRot, yRot); + } - public void setOnGround(boolean onGround) { - setField(this.onGround, onGround); - } + public byte getXRot() { + return getFieldValue(xRot); + } + + public void setXRot(byte xRot) { + setField(this.xRot, xRot); + } - public boolean isHasRot() { - return getFieldValue(hasRot); - } + public boolean isOnGround() { + return getFieldValue(onGround); + } + + public void setOnGround(boolean onGround) { + setField(this.onGround, onGround); + } - public void setHasRot(boolean hasRot) { - setField(this.hasRot, hasRot); - } + public boolean isHasRot() { + return getFieldValue(hasRot); + } + + public void setHasRot(boolean hasRot) { + setField(this.hasRot, hasRot); + } } From 4216b9fc027908c574285eb671fd8bba76792e4a Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:39:04 +0200 Subject: [PATCH 086/260] Update WrappedPacketOutEntityDestroy.java --- .../entity/WrappedPacketOutEntityDestroy.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityDestroy.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityDestroy.java index ae1c99c2..a60f1a2b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityDestroy.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityDestroy.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; - import java.util.Set; -public class WrappedPacketOutEntityDestroy extends PacketEntityWrapper { +import lombok.NonNull; - WrappedPacketOutEntityDestroy(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityDestroy", - networkProtocolGame + "PacketPlayOutEntityDestroy" - ) - ); - } +public class WrappedPacketOutEntityDestroy extends PacketEntityWrapper { + + WrappedPacketOutEntityDestroy(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityDestroy", + networkProtocolGame + "PacketPlayOutEntityDestroy" + ) + ); + } } From 942f28ec49f73dd026adcd5f77290109f5d82c66 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:39:39 +0200 Subject: [PATCH 087/260] Update WrappedPacketOutEntityEffect.java --- .../entity/WrappedPacketOutEntityEffect.java | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEffect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEffect.java index 2a33ca93..e8498407 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEffect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEffect.java @@ -1,60 +1,60 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntityEffect extends PacketEntityWrapper { - Field effectAmplifier; - Field effectDurationTicks; - Field flags; - - WrappedPacketOutEntityEffect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityEffect", - networkProtocolGame + "PacketPlayOutEntityEffect" - ) - ); - - effectAmplifier = getFirstField( - "effectAmplifier", - "c" - ); - effectDurationTicks = getFirstField( - "effectDurationTicks", - "d" - ); - flags = getFirstField( - "flags", - "e" - ); - } - - public byte getEffectAmplifier() { - return getFieldValue(effectAmplifier); - } - - public void setEffectAmplifier(byte effectAmplifier) { - setField(this.effectAmplifier, effectAmplifier); - } - - public int getEffectDurationTicks() { - return getFieldValue(effectDurationTicks); - } - - public void setEffectDurationTicks(int effectDurationTicks) { - setField(this.effectDurationTicks, effectDurationTicks); - } - - public byte getFlags() { - return getFieldValue(flags); - } - - public void setFlags(byte flags) { - setField(this.flags, flags); - } + Field effectAmplifier; + Field effectDurationTicks; + Field flags; + + WrappedPacketOutEntityEffect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityEffect", + networkProtocolGame + "PacketPlayOutEntityEffect" + ) + ); + + effectAmplifier = getFirstField( + "effectAmplifier", + "c" + ); + effectDurationTicks = getFirstField( + "effectDurationTicks", + "d" + ); + flags = getFirstField( + "flags", + "e" + ); + } + + public byte getEffectAmplifier() { + return getFieldValue(effectAmplifier); + } + + public void setEffectAmplifier(byte effectAmplifier) { + setField(this.effectAmplifier, effectAmplifier); + } + + public int getEffectDurationTicks() { + return getFieldValue(effectDurationTicks); + } + + public void setEffectDurationTicks(int effectDurationTicks) { + setField(this.effectDurationTicks, effectDurationTicks); + } + + public byte getFlags() { + return getFieldValue(flags); + } + + public void setFlags(byte flags) { + setField(this.flags, flags); + } } From 2611832ac7bc5f85025181065bfa2a337817255f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:39:50 +0200 Subject: [PATCH 088/260] Update WrappedPacketOutEntityEquipment.java --- .../WrappedPacketOutEntityEquipment.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEquipment.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEquipment.java index fdd9df38..0351e131 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEquipment.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityEquipment.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; - import java.util.Set; -public class WrappedPacketOutEntityEquipment extends PacketEntityWrapper { +import lombok.NonNull; - WrappedPacketOutEntityEquipment(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityEquipment", - networkProtocolGame + "PacketPlayOutEntityEquipment" - ) - ); - } +public class WrappedPacketOutEntityEquipment extends PacketEntityWrapper { + + WrappedPacketOutEntityEquipment(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityEquipment", + networkProtocolGame + "PacketPlayOutEntityEquipment" + ) + ); + } } From 478c3513bf66601ae256eba705c618b8a7d8b749 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:40:04 +0200 Subject: [PATCH 089/260] Update WrappedPacketOutEntityHeadRotation.java --- .../WrappedPacketOutEntityHeadRotation.java | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityHeadRotation.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityHeadRotation.java index eea902bd..127965eb 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityHeadRotation.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityHeadRotation.java @@ -1,34 +1,34 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntityHeadRotation extends PacketEntityWrapper { - - Field yHeadRot; - - WrappedPacketOutEntityHeadRotation(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityHeadRotation", - networkProtocolGame + "PacketPlayOutEntityHeadRotation" - ) - ); - - yHeadRot = getFirstField( - "yHeadRot", - "b" - ); - } - - public byte getYHeadRot() { - return getFieldValue(yHeadRot); - } - - public void setYHeadRot(byte yHeadRot) { - setField(this.yHeadRot, yHeadRot); - } + + Field yHeadRot; + + WrappedPacketOutEntityHeadRotation(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityHeadRotation", + networkProtocolGame + "PacketPlayOutEntityHeadRotation" + ) + ); + + yHeadRot = getFirstField( + "yHeadRot", + "b" + ); + } + + public byte getYHeadRot() { + return getFieldValue(yHeadRot); + } + + public void setYHeadRot(byte yHeadRot) { + setField(this.yHeadRot, yHeadRot); + } } From 63110bb7f57397cda420a5ec2e98d902eff92f34 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:40:14 +0200 Subject: [PATCH 090/260] Update WrappedPacketOutEntityMetadata.java --- .../WrappedPacketOutEntityMetadata.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityMetadata.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityMetadata.java index 2d04b2cb..fb2eec19 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityMetadata.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityMetadata.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; - import java.util.Set; -public class WrappedPacketOutEntityMetadata extends PacketEntityWrapper { +import lombok.NonNull; - WrappedPacketOutEntityMetadata(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityMetadata", - networkProtocolGame + "PacketPlayOutEntityMetadata" - ) - ); - } +public class WrappedPacketOutEntityMetadata extends PacketEntityWrapper { + + WrappedPacketOutEntityMetadata(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityMetadata", + networkProtocolGame + "PacketPlayOutEntityMetadata" + ) + ); + } } From f5f416ede1f8b397ecf402eb2f2402a65391aa7e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:40:36 +0200 Subject: [PATCH 091/260] Update WrappedPacketOutEntityStatus.java --- .../entity/WrappedPacketOutEntityStatus.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityStatus.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityStatus.java index d4495a15..22b7ee6c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityStatus.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityStatus.java @@ -1,34 +1,34 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntityStatus extends PacketEntityWrapper { - Field eventId; - - WrappedPacketOutEntityStatus(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityStatus", - networkProtocolGame + "PacketPlayOutEntityStatus" - ) - ); - - eventId = getFirstField( - "eventId", - "b" - ); - } - - public byte getEventId() { - return getFieldValue(eventId); - } - - public void setEventId(byte eventId) { - setField(this.eventId, eventId); - } + Field eventId; + + WrappedPacketOutEntityStatus(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityStatus", + networkProtocolGame + "PacketPlayOutEntityStatus" + ) + ); + + eventId = getFirstField( + "eventId", + "b" + ); + } + + public byte getEventId() { + return getFieldValue(eventId); + } + + public void setEventId(byte eventId) { + setField(this.eventId, eventId); + } } From deb8091bd3eeaa7c968e1eee735e5269671c8a6f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:40:58 +0200 Subject: [PATCH 092/260] Update WrappedPacketOutEntityTeleport.java --- .../WrappedPacketOutEntityTeleport.java | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityTeleport.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityTeleport.java index f808cb98..a8045c8a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityTeleport.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityTeleport.java @@ -1,47 +1,47 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutEntityTeleport extends PacketEntityWrapper { - Field id; - Field onGround; - - WrappedPacketOutEntityTeleport(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityTeleport", - networkProtocolGame + "PacketPlayOutEntityTeleport" - ) - ); - - id = getFirstField( - "id", - "a" - ); - onGround = getFirstField( - "onGround", - "g" - ); - } - - public int getId() { - return getFieldValue(id); - } - - public void setId(int id) { - setField(this.id, id); - } - - public boolean isOnGround() { - return getFieldValue(onGround); - } - - public void setOnGround(boolean onGround) { - setField(this.onGround, onGround); - } + Field id; + Field onGround; + + WrappedPacketOutEntityTeleport(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityTeleport", + networkProtocolGame + "PacketPlayOutEntityTeleport" + ) + ); + + id = getFirstField( + "id", + "a" + ); + onGround = getFirstField( + "onGround", + "g" + ); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public boolean isOnGround() { + return getFieldValue(onGround); + } + + public void setOnGround(boolean onGround) { + setField(this.onGround, onGround); + } } From 1ee074167fecf1c3946455b6b63b995fc97d9d9c Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:41:08 +0200 Subject: [PATCH 093/260] Update WrappedPacketOutEntityVelocity.java --- .../WrappedPacketOutEntityVelocity.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityVelocity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityVelocity.java index 5f8c9358..b3499e85 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityVelocity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/entity/WrappedPacketOutEntityVelocity.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.entity; -import lombok.NonNull; - import java.util.Set; -public class WrappedPacketOutEntityVelocity extends PacketEntityWrapper { +import lombok.NonNull; - WrappedPacketOutEntityVelocity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutEntityVelocity", - networkProtocolGame + "PacketPlayOutEntityVelocity" - ) - ); - } +public class WrappedPacketOutEntityVelocity extends PacketEntityWrapper { + + WrappedPacketOutEntityVelocity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutEntityVelocity", + networkProtocolGame + "PacketPlayOutEntityVelocity" + ) + ); + } } From 1c3058432b7e3a96872e6ea5aa8e3d2b0b0bf527 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:41:35 +0200 Subject: [PATCH 094/260] Update PacketExperienceWrapper.java --- .../experience/PacketExperienceWrapper.java | 97 ++++++++++--------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/PacketExperienceWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/PacketExperienceWrapper.java index f39c8aa4..2621b490 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/PacketExperienceWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/PacketExperienceWrapper.java @@ -1,57 +1,58 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.experience; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketExperienceWrapper extends PacketWrapper { - - Field experienceProgress; - Field totalExperience; - Field experienceLevel; - - PacketExperienceWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - experienceProgress = getFirstField( - "experienceProgress", - "a" - ); - totalExperience = getFirstField( - "totalExperience", - "b" - ); - experienceLevel = getFirstField( - "experienceLevel", - "c" - ); - } - - public float getExperienceProgress() { - return getFieldValue(experienceProgress); - } - - public void setExperienceProgress(float experienceProgress) { - setField(this.experienceProgress, experienceProgress); - } - - public int getTotalExperience() { - return getFieldValue(totalExperience); - } - - public void setTotalExperience(int totalExperience) { - setField(this.totalExperience, totalExperience); - } - - public int getExperienceLevel() { - return getFieldValue(experienceLevel); - } - - public void setExperienceLevel(int experienceLevel) { - setField(this.experienceLevel, experienceLevel); - } + + Field experienceProgress; + Field totalExperience; + Field experienceLevel; + + PacketExperienceWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + experienceProgress = getFirstField( + "experienceProgress", + "a" + ); + totalExperience = getFirstField( + "totalExperience", + "b" + ); + experienceLevel = getFirstField( + "experienceLevel", + "c" + ); + } + + public float getExperienceProgress() { + return getFieldValue(experienceProgress); + } + + public void setExperienceProgress(float experienceProgress) { + setField(this.experienceProgress, experienceProgress); + } + + public int getTotalExperience() { + return getFieldValue(totalExperience); + } + + public void setTotalExperience(int totalExperience) { + setField(this.totalExperience, totalExperience); + } + + public int getExperienceLevel() { + return getFieldValue(experienceLevel); + } + + public void setExperienceLevel(int experienceLevel) { + setField(this.experienceLevel, experienceLevel); + } } From 837b2d94e368a31f275fa333517c772fbdfcb0d9 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:41:46 +0200 Subject: [PATCH 095/260] Update WrappedPacketOutExperience.java --- .../experience/WrappedPacketOutExperience.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/WrappedPacketOutExperience.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/WrappedPacketOutExperience.java index 428a83e5..3d5b4bd1 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/WrappedPacketOutExperience.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/experience/WrappedPacketOutExperience.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.experience; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutExperience extends PacketExperienceWrapper { - public WrappedPacketOutExperience(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutExperience", - networkProtocolGame + "PacketPlayOutExperience" - ) - ); - } + public WrappedPacketOutExperience(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutExperience", + networkProtocolGame + "PacketPlayOutExperience" + ) + ); + } } From 6b8140ecad5b0af48c0b7aad7f02755c2c189866 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:42:01 +0200 Subject: [PATCH 096/260] Update PacketExplosionWrapper.java --- .../explosion/PacketExplosionWrapper.java | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/PacketExplosionWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/PacketExplosionWrapper.java index 6468d567..84d5f7aa 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/PacketExplosionWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/PacketExplosionWrapper.java @@ -1,32 +1,33 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.explosion; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketExplosionWrapper extends PacketWrapper { - - Field radius; - - PacketExplosionWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - radius = getFirstField( - "radius", - "power", - "d" - ); - } - - public float getRadius() { - return getFieldValue(radius); - } - - public void setRadius(float radius) { - setField(this.radius, radius); - } + + Field radius; + + PacketExplosionWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + radius = getFirstField( + "radius", + "power", + "d" + ); + } + + public float getRadius() { + return getFieldValue(radius); + } + + public void setRadius(float radius) { + setField(this.radius, radius); + } } From ec273cab2c18e0be42d9f70a8a810ad4271982f0 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:42:13 +0200 Subject: [PATCH 097/260] Update WrappedPacketOutExplosion.java --- .../explosion/WrappedPacketOutExplosion.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/WrappedPacketOutExplosion.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/WrappedPacketOutExplosion.java index a8b1c953..0bc4425d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/WrappedPacketOutExplosion.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/explosion/WrappedPacketOutExplosion.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.explosion; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutExplosion extends PacketExplosionWrapper { - public WrappedPacketOutExplosion(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutExplosion", - networkProtocolGame + "PacketPlayOutExplosion" - ) - ); - } + public WrappedPacketOutExplosion(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutExplosion", + networkProtocolGame + "PacketPlayOutExplosion" + ) + ); + } } From 507b2844ba0f67c9d853235de20ad69d47f23a34 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:43:08 +0200 Subject: [PATCH 098/260] Update PacketFlyingWrapper.java --- .../wrapper/flying/PacketFlyingWrapper.java | 201 +++++++++--------- 1 file changed, 101 insertions(+), 100 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/PacketFlyingWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/PacketFlyingWrapper.java index 9ee8bd20..a875a85f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/PacketFlyingWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/PacketFlyingWrapper.java @@ -1,110 +1,111 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.flying; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketFlyingWrapper extends PacketWrapper { - Field x; - Field y; - Field z; - Field yaw; - Field pitch; - Field onGround; - Field hasPos; - Field hasRot; - - PacketFlyingWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - x = getField("x"); - y = getField("y"); - z = getField("z"); - yaw = getFirstField( - "yaw", - "yRot" - ); - pitch = getFirstField( - "pitch", - "xRot" - ); - onGround = getFirstField( - "onGround", - "f" - ); - hasPos = getField("hasPos"); - hasRot = getFirstField( - "hasRot", - "hasLook" - ); - } - - public double getX() { - return getFieldValue(x); - } - - public void setX(double x) { - setField(this.x, x); - } - - public double getY() { - return getFieldValue(y); - } - - public void setY(double y) { - setField(this.y, y); - } - - public double getZ() { - return getFieldValue(z); - } - - public void setZ(double z) { - setField(this.z, z); - } - - public float getYaw() { - return getFieldValue(yaw); - } - - public void setYaw(float yaw) { - setField(this.yaw, yaw); - } - - public float getPitch() { - return getFieldValue(pitch); - } - - public void setPitch(float pitch) { - setField(this.pitch, pitch); - } - - public boolean isOnGround() { - return getFieldValue(onGround); - } - - public void setOnGround(boolean onGround) { - setField(this.onGround, onGround); - } - - public boolean isHasPos() { - return getFieldValue(hasPos); - } - - public void setHasPos(boolean hasPos) { - setField(this.hasPos, hasPos); - } - - public boolean isHasRot() { - return getFieldValue(hasRot); - } - - public void setHasRot(boolean hasRot) { - setField(this.hasRot, hasRot); - } + Field x; + Field y; + Field z; + Field yaw; + Field pitch; + Field onGround; + Field hasPos; + Field hasRot; + + PacketFlyingWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + x = getField("x"); + y = getField("y"); + z = getField("z"); + yaw = getFirstField( + "yaw", + "yRot" + ); + pitch = getFirstField( + "pitch", + "xRot" + ); + onGround = getFirstField( + "onGround", + "f" + ); + hasPos = getField("hasPos"); + hasRot = getFirstField( + "hasRot", + "hasLook" + ); + } + + public double getX() { + return getFieldValue(x); + } + + public void setX(double x) { + setField(this.x, x); + } + + public double getY() { + return getFieldValue(y); + } + + public void setY(double y) { + setField(this.y, y); + } + + public double getZ() { + return getFieldValue(z); + } + + public void setZ(double z) { + setField(this.z, z); + } + + public float getYaw() { + return getFieldValue(yaw); + } + + public void setYaw(float yaw) { + setField(this.yaw, yaw); + } + + public float getPitch() { + return getFieldValue(pitch); + } + + public void setPitch(float pitch) { + setField(this.pitch, pitch); + } + + public boolean isOnGround() { + return getFieldValue(onGround); + } + + public void setOnGround(boolean onGround) { + setField(this.onGround, onGround); + } + + public boolean isHasPos() { + return getFieldValue(hasPos); + } + + public void setHasPos(boolean hasPos) { + setField(this.hasPos, hasPos); + } + + public boolean isHasRot() { + return getFieldValue(hasRot); + } + + public void setHasRot(boolean hasRot) { + setField(this.hasRot, hasRot); + } } From e5c3eb09511545fea6d08c2bd3ea43be1d2a2e27 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:43:19 +0200 Subject: [PATCH 099/260] Update WrappedPacketInFlying.java --- .../wrapper/flying/WrappedPacketInFlying.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/WrappedPacketInFlying.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/WrappedPacketInFlying.java index 3c65e695..799d052a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/WrappedPacketInFlying.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/flying/WrappedPacketInFlying.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.flying; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInFlying extends PacketFlyingWrapper { - WrappedPacketInFlying(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInFlying", - networkProtocolGame + "PacketPlayInFlying" - ) - ); - } + WrappedPacketInFlying(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInFlying", + networkProtocolGame + "PacketPlayInFlying" + ) + ); + } } From 2dfd1e6f38c3dff52bb11f72cd4f4538dc92a4d2 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:43:34 +0200 Subject: [PATCH 100/260] Update PacketGameStateChangeWrapper.java --- .../PacketGameStateChangeWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/PacketGameStateChangeWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/PacketGameStateChangeWrapper.java index f8c5186b..e61e6215 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/PacketGameStateChangeWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/PacketGameStateChangeWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.gamestatechange; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketGameStateChangeWrapper extends PacketWrapper { - - Field param; - - PacketGameStateChangeWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - param = getFirstField( - "param", - "c" - ); - } - - public float getParam() { - return getFieldValue(param); - } - - public void setParam(float param) { - setField(this.param, param); - } + + Field param; + + PacketGameStateChangeWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + param = getFirstField( + "param", + "c" + ); + } + + public float getParam() { + return getFieldValue(param); + } + + public void setParam(float param) { + setField(this.param, param); + } } From fbc063cceefae5289b9491de24300c1150647fe5 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:43:45 +0200 Subject: [PATCH 101/260] Update WrappedPacketOutGameStateChange.java --- .../WrappedPacketOutGameStateChange.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/WrappedPacketOutGameStateChange.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/WrappedPacketOutGameStateChange.java index 4a5cf68c..a869f86d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/WrappedPacketOutGameStateChange.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/gamestatechange/WrappedPacketOutGameStateChange.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.gamestatechange; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutGameStateChange extends PacketGameStateChangeWrapper { - WrappedPacketOutGameStateChange(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutGameStateChange", - networkProtocolGame + "PacketPlayOutGameStateChange" - ) - ); - } + WrappedPacketOutGameStateChange(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutGameStateChange", + networkProtocolGame + "PacketPlayOutGameStateChange" + ) + ); + } } From a3663b81325fdc2045e334e0626cacb4babc8a1e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:45:06 +0200 Subject: [PATCH 102/260] Update PacketHeldItemSlotWrapper.java --- .../PacketHeldItemSlotWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/PacketHeldItemSlotWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/PacketHeldItemSlotWrapper.java index 0ed911b0..44ed45f8 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/PacketHeldItemSlotWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/PacketHeldItemSlotWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.helditemslot; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketHeldItemSlotWrapper extends PacketWrapper { - - Field slot; - - PacketHeldItemSlotWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - slot = getFirstField( - "slot", - "a" - ); - } - - public int getSlot() { - return getFieldValue(slot); - } - - public void setSlot(int slot) { - setField(this.slot, slot); - } + + Field slot; + + PacketHeldItemSlotWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + slot = getFirstField( + "slot", + "a" + ); + } + + public int getSlot() { + return getFieldValue(slot); + } + + public void setSlot(int slot) { + setField(this.slot, slot); + } } From 01e4adc810bd279ce3298c3ea819df5ef8af4a77 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:45:19 +0200 Subject: [PATCH 103/260] Update WrappedPacketInHeldItemSlot.java --- .../WrappedPacketInHeldItemSlot.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketInHeldItemSlot.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketInHeldItemSlot.java index c4f7dc30..8526ae6e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketInHeldItemSlot.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketInHeldItemSlot.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.helditemslot; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInHeldItemSlot extends PacketHeldItemSlotWrapper { - public WrappedPacketInHeldItemSlot(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInHeldItemSlot", - networkProtocolGame + "PacketPlayInHeldItemSlot" - ) - ); - } + public WrappedPacketInHeldItemSlot(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInHeldItemSlot", + networkProtocolGame + "PacketPlayInHeldItemSlot" + ) + ); + } } From 4b704a2af84e06b33a2cba6acaf3aef10dbb6107 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:45:30 +0200 Subject: [PATCH 104/260] Update WrappedPacketOutHeldItemSlot.java --- .../WrappedPacketOutHeldItemSlot.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketOutHeldItemSlot.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketOutHeldItemSlot.java index d1106c8d..b75c06c3 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketOutHeldItemSlot.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/helditemslot/WrappedPacketOutHeldItemSlot.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.helditemslot; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutHeldItemSlot extends PacketHeldItemSlotWrapper { - public WrappedPacketOutHeldItemSlot(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutHeldItemSlot", - networkProtocolGame + "PacketPlayOutHeldItemSlot" - ) - ); - } + public WrappedPacketOutHeldItemSlot(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutHeldItemSlot", + networkProtocolGame + "PacketPlayOutHeldItemSlot" + ) + ); + } } From 2e738568412815e02cafc85643a14e87940b3bec Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:45:46 +0200 Subject: [PATCH 105/260] Update PacketKickDisconnectWrapper.java --- .../PacketKickDisconnectWrapper.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/PacketKickDisconnectWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/PacketKickDisconnectWrapper.java index 9226a178..87717aab 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/PacketKickDisconnectWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/PacketKickDisconnectWrapper.java @@ -10,29 +10,29 @@ @FieldDefaults(makeFinal = true) abstract class PacketKickDisconnectWrapper extends PacketWrapper { - - Field reason; - - PacketKickDisconnectWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - reason = getFirstField( - "reason", - "a" - ); - } - - /** - * @return IChatBaseComponent - */ - public Object getReason() { - return getFieldValue(reason); - } - - /** - * @param reason: IChatBaseComponent - */ - public void setReason(Object reason) { - setField(this.reason, reason); - } + + Field reason; + + PacketKickDisconnectWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + reason = getFirstField( + "reason", + "a" + ); + } + + /** + * @return IChatBaseComponent + */ + public Object getReason() { + return getFieldValue(reason); + } + + /** + * @param reason: IChatBaseComponent + */ + public void setReason(Object reason) { + setField(this.reason, reason); + } } From 5ad15a59c76f0cd2b543afb0ad015e3d29c1cc11 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:45:58 +0200 Subject: [PATCH 106/260] Update WrappedPacketOutKickDisconnect.java --- .../WrappedPacketOutKickDisconnect.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/WrappedPacketOutKickDisconnect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/WrappedPacketOutKickDisconnect.java index 5774162d..55aba901 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/WrappedPacketOutKickDisconnect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/kickdisconnect/WrappedPacketOutKickDisconnect.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.kickdisconnect; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutKickDisconnect extends PacketKickDisconnectWrapper { - WrappedPacketOutKickDisconnect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutKickDisconnect", - networkProtocolCommon + "ClientboundDisconnectPacket" - ) - ); - } + WrappedPacketOutKickDisconnect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutKickDisconnect", + networkProtocolCommon + "ClientboundDisconnectPacket" + ) + ); + } } From cbf45a7b3f3f0acc374e56c4ef6b1eea1d7d7b4b Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:46:27 +0200 Subject: [PATCH 107/260] Update PacketLoginWrapper.java --- .../wrapper/login/PacketLoginWrapper.java | 113 +++++++++--------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/PacketLoginWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/PacketLoginWrapper.java index 45788115..887da59b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/PacketLoginWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/PacketLoginWrapper.java @@ -1,70 +1,71 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.login; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketLoginWrapper extends PacketWrapper { + + Field playerId; + Field hardcore; + Field maxPlayers; + Field reducedDebugInfo; - Field playerId; - Field hardcore; - Field maxPlayers; - Field reducedDebugInfo; - - PacketLoginWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - playerId = getFirstField( - "playerId", - "a" - ); - hardcore = getFirstField( - "hardcore", - "b" - ); - maxPlayers = getFirstField( - "maxPlayers", - "f" - ); - reducedDebugInfo = getFirstField( - "reducedDebugInfo", - "h" - ); - } - - public int getPlayerId() { - return getFieldValue(playerId); - } - - public void setPlayerId(int playerId) { - setField(this.playerId, playerId); - } - - public boolean getHardcore() { - return getFieldValue(hardcore); - } - - public void setHardcore(boolean hardcore) { - setField(this.hardcore, hardcore); - } + PacketLoginWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + playerId = getFirstField( + "playerId", + "a" + ); + hardcore = getFirstField( + "hardcore", + "b" + ); + maxPlayers = getFirstField( + "maxPlayers", + "f" + ); + reducedDebugInfo = getFirstField( + "reducedDebugInfo", + "h" + ); + } - public int getMaxPlayers() { - return getFieldValue(maxPlayers); - } + public int getPlayerId() { + return getFieldValue(playerId); + } + + public void setPlayerId(int playerId) { + setField(this.playerId, playerId); + } - public void setMaxPlayers(int maxPlayers) { - setField(this.maxPlayers, maxPlayers); - } + public boolean getHardcore() { + return getFieldValue(hardcore); + } + + public void setHardcore(boolean hardcore) { + setField(this.hardcore, hardcore); + } - public boolean isReducedDebugInfo() { - return getFieldValue(reducedDebugInfo); - } + public int getMaxPlayers() { + return getFieldValue(maxPlayers); + } + + public void setMaxPlayers(int maxPlayers) { + setField(this.maxPlayers, maxPlayers); + } - public void setReducedDebugInfo(boolean reducedDebugInfo) { - setField(this.reducedDebugInfo, reducedDebugInfo); - } + public boolean isReducedDebugInfo() { + return getFieldValue(reducedDebugInfo); + } + + public void setReducedDebugInfo(boolean reducedDebugInfo) { + setField(this.reducedDebugInfo, reducedDebugInfo); + } } From 675b6053bd8fe44ad8e168119ef2163febfe8820 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:46:37 +0200 Subject: [PATCH 108/260] Update WrappedPacketOutLogin.java --- .../wrapper/login/WrappedPacketOutLogin.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/WrappedPacketOutLogin.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/WrappedPacketOutLogin.java index 056d0ccd..54ed0985 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/WrappedPacketOutLogin.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/login/WrappedPacketOutLogin.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.login; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutLogin extends PacketLoginWrapper { - WrappedPacketOutLogin(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutLogin", - networkProtocolGame + "PacketPlayOutLogin" - ) - ); - } + WrappedPacketOutLogin(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutLogin", + networkProtocolGame + "PacketPlayOutLogin" + ) + ); + } } From 0553c02826e07dec8fb28502ec0deb2a554b7620 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:46:53 +0200 Subject: [PATCH 109/260] Update PacketMapWrapper.java --- .../packets/wrapper/map/PacketMapWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/PacketMapWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/PacketMapWrapper.java index 87535cb1..0e729adc 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/PacketMapWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/PacketMapWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.map; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketMapWrapper extends PacketWrapper { - - Field scale; - - PacketMapWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - scale = getFirstField( - "scale", - "b" - ); - } - - public byte getScale() { - return getFieldValue(scale); - } - - public void setScale(byte scale) { - setField(this.scale, scale); - } + + Field scale; + + PacketMapWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + scale = getFirstField( + "scale", + "b" + ); + } + + public byte getScale() { + return getFieldValue(scale); + } + + public void setScale(byte scale) { + setField(this.scale, scale); + } } From a8ed510e9ca55df4f051686b0291ab9630af772e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:47:05 +0200 Subject: [PATCH 110/260] Update WrappedPacketOutMap.java --- .../wrapper/map/WrappedPacketOutMap.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/WrappedPacketOutMap.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/WrappedPacketOutMap.java index e5f333f3..cacaa567 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/WrappedPacketOutMap.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/map/WrappedPacketOutMap.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.map; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutMap extends PacketMapWrapper { - public WrappedPacketOutMap(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutMap", - networkProtocolGame + "PacketPlayOutMap" - ) - ); - } + public WrappedPacketOutMap(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutMap", + networkProtocolGame + "PacketPlayOutMap" + ) + ); + } } From f448b918ac2f6e00ec84bb19048f9b915fb72e9c Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:47:30 +0200 Subject: [PATCH 111/260] Update PacketMultiBlockChangeWrapper.java --- .../PacketMultiBlockChangeWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/PacketMultiBlockChangeWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/PacketMultiBlockChangeWrapper.java index 12b9690c..aa7c0652 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/PacketMultiBlockChangeWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/PacketMultiBlockChangeWrapper.java @@ -1,13 +1,14 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.multiblockchange; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import java.util.Set; +import lombok.NonNull; abstract class PacketMultiBlockChangeWrapper extends PacketWrapper { - PacketMultiBlockChangeWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketMultiBlockChangeWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From d14b1757d4158064361dcce11fae46256bda9a05 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:47:44 +0200 Subject: [PATCH 112/260] Update WrappedPacketOutMultiBlockChange.java --- .../WrappedPacketOutMultiBlockChange.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/WrappedPacketOutMultiBlockChange.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/WrappedPacketOutMultiBlockChange.java index 17b1e4a5..9b60cc9f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/WrappedPacketOutMultiBlockChange.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/multiblockchange/WrappedPacketOutMultiBlockChange.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.multiblockchange; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutMultiBlockChange extends PacketMultiBlockChangeWrapper { - public WrappedPacketOutMultiBlockChange(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutMultiBlockChange", - networkProtocolGame + "PacketPlayOutMultiBlockChange" - ) - ); - } + public WrappedPacketOutMultiBlockChange(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutMultiBlockChange", + networkProtocolGame + "PacketPlayOutMultiBlockChange" + ) + ); + } } From 7f5be899854949d4a27bcf3d1f96f48534dd9e60 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:48:18 +0200 Subject: [PATCH 113/260] Update PacketNamedSoundEffectWrapper.java --- .../PacketNamedSoundEffectWrapper.java | 113 +++++++++--------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/PacketNamedSoundEffectWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/PacketNamedSoundEffectWrapper.java index 25564680..a3e8a086 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/PacketNamedSoundEffectWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/PacketNamedSoundEffectWrapper.java @@ -1,70 +1,71 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.namedsoundeffect; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketNamedSoundEffectWrapper extends PacketWrapper { + + Field x; + Field y; + Field z; + Field volume; - Field x; - Field y; - Field z; - Field volume; - - PacketNamedSoundEffectWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - x = getFirstField( - "x", - "b" - ); - y = getFirstField( - "y", - "c" - ); - z = getFirstField( - "z", - "d" - ); - volume = getFirstField( - "volume", - "e" - ); - } - - public int getX() { - return getFieldValue(x); - } - - public void setX(int x) { - setField(this.x, x); - } - - public int getY() { - return getFieldValue(y); - } - - public void setY(int y) { - setField(this.y, y); - } + PacketNamedSoundEffectWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + x = getFirstField( + "x", + "b" + ); + y = getFirstField( + "y", + "c" + ); + z = getFirstField( + "z", + "d" + ); + volume = getFirstField( + "volume", + "e" + ); + } - public int getZ() { - return getFieldValue(z); - } + public int getX() { + return getFieldValue(x); + } + + public void setX(int x) { + setField(this.x, x); + } - public void setZ(int z) { - setField(this.z, z); - } + public int getY() { + return getFieldValue(y); + } + + public void setY(int y) { + setField(this.y, y); + } - public float getVolume() { - return getFieldValue(volume); - } + public int getZ() { + return getFieldValue(z); + } + + public void setZ(int z) { + setField(this.z, z); + } - public void setVolume(float volume) { - setField(this.volume, volume); - } + public float getVolume() { + return getFieldValue(volume); + } + + public void setVolume(float volume) { + setField(this.volume, volume); + } } From 1b40700de32c2258d7cb17fcb6a5ec7da31f6e5f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:48:28 +0200 Subject: [PATCH 114/260] Update WrappedPacketOutNamedSoundEffect.java --- .../WrappedPacketOutNamedSoundEffect.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/WrappedPacketOutNamedSoundEffect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/WrappedPacketOutNamedSoundEffect.java index d7d6c9c2..60980411 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/WrappedPacketOutNamedSoundEffect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/namedsoundeffect/WrappedPacketOutNamedSoundEffect.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.namedsoundeffect; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutNamedSoundEffect extends PacketNamedSoundEffectWrapper { - public WrappedPacketOutNamedSoundEffect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutNamedSoundEffect", - networkProtocolGame + "PacketPlayOutNamedSoundEffect" - ) - ); - } + public WrappedPacketOutNamedSoundEffect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutNamedSoundEffect", + networkProtocolGame + "PacketPlayOutNamedSoundEffect" + ) + ); + } } From cdd972f7175044418711d32fec2ccb168b4bbd24 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:48:43 +0200 Subject: [PATCH 115/260] Update PacketOpenSignEditorWrapper.java --- .../PacketOpenSignEditorWrapper.java | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/PacketOpenSignEditorWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/PacketOpenSignEditorWrapper.java index 3d773651..41b6b4dd 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/PacketOpenSignEditorWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/PacketOpenSignEditorWrapper.java @@ -1,37 +1,38 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.open.signeditor; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketOpenSignEditorWrapper extends PacketWrapper { - - Field pos; - - PacketOpenSignEditorWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } + + Field pos; + + PacketOpenSignEditorWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } } From f2fb1717027af402f90646b5322b9ae526313d05 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:48:55 +0200 Subject: [PATCH 116/260] Update WrappedPacketOutOpenSignEditor.java --- .../WrappedPacketOutOpenSignEditor.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/WrappedPacketOutOpenSignEditor.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/WrappedPacketOutOpenSignEditor.java index de4b5630..fdf74ce0 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/WrappedPacketOutOpenSignEditor.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/signeditor/WrappedPacketOutOpenSignEditor.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.open.signeditor; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutOpenSignEditor extends PacketOpenSignEditorWrapper { - public WrappedPacketOutOpenSignEditor(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutOpenSignEditor", - networkProtocolGame + "PacketPlayOutOpenSignEditor" - ) - ); - } + public WrappedPacketOutOpenSignEditor(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutOpenSignEditor", + networkProtocolGame + "PacketPlayOutOpenSignEditor" + ) + ); + } } From b541edfc44c631db4fb7bb69e60f79cdd5bc4190 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:49:16 +0200 Subject: [PATCH 117/260] Update PacketOpenWindowWrapper.java --- .../open/window/PacketOpenWindowWrapper.java | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/PacketOpenWindowWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/PacketOpenWindowWrapper.java index d5d1a851..a555633c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/PacketOpenWindowWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/PacketOpenWindowWrapper.java @@ -1,50 +1,51 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.open.window; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketOpenWindowWrapper extends PacketWrapper { - - Field containerId; - Field title; - - PacketOpenWindowWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - title = getFirstField( - "title", - "c" - ); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - /** - * @return IChatBaseComponent - */ - public Object getTitle() { - return getFieldValue(title); - } - - /** - * @param title: IChatBaseComponent - */ - public void setTitle(Object title) { - setField(this.title, title); - } + + Field containerId; + Field title; + + PacketOpenWindowWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + title = getFirstField( + "title", + "c" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } + + /** + * @return IChatBaseComponent + */ + public Object getTitle() { + return getFieldValue(title); + } + + /** + * @param title: IChatBaseComponent + */ + public void setTitle(Object title) { + setField(this.title, title); + } } From 2c01a34e167e7fdb655cd9314575e54b4bb972ca Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:49:27 +0200 Subject: [PATCH 118/260] Update WrappedPacketOutOpenWindow.java --- .../window/WrappedPacketOutOpenWindow.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/WrappedPacketOutOpenWindow.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/WrappedPacketOutOpenWindow.java index 806251d7..a2fd0db5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/WrappedPacketOutOpenWindow.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/open/window/WrappedPacketOutOpenWindow.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.open.window; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutOpenWindow extends PacketOpenWindowWrapper { - public WrappedPacketOutOpenWindow(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutOpenWindow", - networkProtocolGame + "PacketPlayOutOpenWindow" - ) - ); - } + public WrappedPacketOutOpenWindow(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutOpenWindow", + networkProtocolGame + "PacketPlayOutOpenWindow" + ) + ); + } } From 1173d6be471fa33e9939b05f9f0a546800b0370e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:49:49 +0200 Subject: [PATCH 119/260] Update PacketPlayerListHeaderFooterWrapper.java --- .../PacketPlayerListHeaderFooterWrapper.java | 95 ++++++++++--------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/PacketPlayerListHeaderFooterWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/PacketPlayerListHeaderFooterWrapper.java index 8e9a2f76..8be4643a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/PacketPlayerListHeaderFooterWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/PacketPlayerListHeaderFooterWrapper.java @@ -1,56 +1,57 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.playerlistheaderfooter; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketPlayerListHeaderFooterWrapper extends PacketWrapper { - - Field header; - Field footer; - - PacketPlayerListHeaderFooterWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - header = getFirstField( - "header", - "a" - ); - footer = getFirstField( - "footer", - "b" - ); - } - - /** - * @return IChatBaseComponent - */ - public Object getHeader() { - return getFieldValue(header); - } - - /** - * @param header: IChatBaseComponent - */ - public void setHeader(Object header) { - setField(this.header, header); - } - - /** - * @return IChatBaseComponent - */ - public Object getFooter() { - return getFieldValue(footer); - } - - /** - * @param footer: IChatBaseComponent - */ - public void setFooter(Object footer) { - setField(this.footer, footer); - } + + Field header; + Field footer; + + PacketPlayerListHeaderFooterWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + header = getFirstField( + "header", + "a" + ); + footer = getFirstField( + "footer", + "b" + ); + } + + /** + * @return IChatBaseComponent + */ + public Object getHeader() { + return getFieldValue(header); + } + + /** + * @param header: IChatBaseComponent + */ + public void setHeader(Object header) { + setField(this.header, header); + } + + /** + * @return IChatBaseComponent + */ + public Object getFooter() { + return getFieldValue(footer); + } + + /** + * @param footer: IChatBaseComponent + */ + public void setFooter(Object footer) { + setField(this.footer, footer); + } } From 2bc375d64c50293170a59fab55fa0b04f7069495 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:50:27 +0200 Subject: [PATCH 120/260] Update WrappedPacketOutPlayerListHeaderFooter.java --- ...WrappedPacketOutPlayerListHeaderFooter.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/WrappedPacketOutPlayerListHeaderFooter.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/WrappedPacketOutPlayerListHeaderFooter.java index 93550198..bf2788c6 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/WrappedPacketOutPlayerListHeaderFooter.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/playerlistheaderfooter/WrappedPacketOutPlayerListHeaderFooter.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.playerlistheaderfooter; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutPlayerListHeaderFooter extends PacketPlayerListHeaderFooterWrapper { - public WrappedPacketOutPlayerListHeaderFooter(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutPlayerListHeaderFooter", - networkProtocolGame + "PacketPlayOutPlayerListHeaderFooter" - ) - ); - } + public WrappedPacketOutPlayerListHeaderFooter(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutPlayerListHeaderFooter", + networkProtocolGame + "PacketPlayOutPlayerListHeaderFooter" + ) + ); + } } From a7aa8df019c43e2682d19d2c30f35288536a6bb9 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:50:38 +0200 Subject: [PATCH 121/260] Update PacketPositionWrapper.java --- .../wrapper/position/PacketPositionWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/PacketPositionWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/PacketPositionWrapper.java index b1c5f32b..c94fb2d9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/PacketPositionWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/PacketPositionWrapper.java @@ -1,13 +1,14 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.position; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import java.util.Set; +import lombok.NonNull; abstract class PacketPositionWrapper extends PacketWrapper { - PacketPositionWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketPositionWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From cc5de68d2628cc6bd3ca24fa632e615c5515a4c3 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:50:49 +0200 Subject: [PATCH 122/260] Update WrappedPacketOutPosition.java --- .../position/WrappedPacketOutPosition.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/WrappedPacketOutPosition.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/WrappedPacketOutPosition.java index b73e848d..2d2b5c06 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/WrappedPacketOutPosition.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/position/WrappedPacketOutPosition.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.position; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutPosition extends PacketPositionWrapper { - WrappedPacketOutPosition(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutPosition", - networkProtocolCommon + "PacketPlayOutPosition" - ) - ); - } + WrappedPacketOutPosition(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutPosition", + networkProtocolCommon + "PacketPlayOutPosition" + ) + ); + } } From d5b0693cc0ce751f0425e9c059dae8567ca79933 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:51:05 +0200 Subject: [PATCH 123/260] Update PacketRemoveEntityEffectWrapper.java --- .../PacketRemoveEntityEffectWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/PacketRemoveEntityEffectWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/PacketRemoveEntityEffectWrapper.java index 3440127c..f0bf5225 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/PacketRemoveEntityEffectWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/PacketRemoveEntityEffectWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.removeentityeffect; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketRemoveEntityEffectWrapper extends PacketWrapper { - - Field entityId; - - PacketRemoveEntityEffectWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - entityId = getFirstField( - "entityId", - "a" - ); - } - - public int getEntityId() { - return getFieldValue(entityId); - } - - public void setEntityId(int entityId) { - setField(this.entityId, entityId); - } + + Field entityId; + + PacketRemoveEntityEffectWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + entityId = getFirstField( + "entityId", + "a" + ); + } + + public int getEntityId() { + return getFieldValue(entityId); + } + + public void setEntityId(int entityId) { + setField(this.entityId, entityId); + } } From d985e07b3715b7d67622778ce18d6c3a934889b5 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:51:16 +0200 Subject: [PATCH 124/260] Update WrappedPacketOutRemoveEntityEffect.java --- .../WrappedPacketOutRemoveEntityEffect.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/WrappedPacketOutRemoveEntityEffect.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/WrappedPacketOutRemoveEntityEffect.java index 05915946..276ad92b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/WrappedPacketOutRemoveEntityEffect.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/removeentityeffect/WrappedPacketOutRemoveEntityEffect.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.removeentityeffect; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutRemoveEntityEffect extends PacketRemoveEntityEffectWrapper { - WrappedPacketOutRemoveEntityEffect(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutRemoveEntityEffect", - networkProtocolCommon + "PacketPlayOutRemoveEntityEffect" - ) - ); - } + WrappedPacketOutRemoveEntityEffect(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutRemoveEntityEffect", + networkProtocolCommon + "PacketPlayOutRemoveEntityEffect" + ) + ); + } } From 566c3991accde8765943300638550c4d2bd9bf8c Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:51:35 +0200 Subject: [PATCH 125/260] Update PacketResourcePackStatusWrapper.java --- .../PacketResourcePackStatusWrapper.java | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/PacketResourcePackStatusWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/PacketResourcePackStatusWrapper.java index 7e8a9a59..7782f710 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/PacketResourcePackStatusWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/PacketResourcePackStatusWrapper.java @@ -1,38 +1,39 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.resourcepackstatus; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketResourcePackStatusWrapper extends PacketWrapper { - - Field status; - - PacketResourcePackStatusWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - status = getFirstField( - "status", - "action", - "b" - ); - } - - /** - * @return PacketPlayInResourcePackStatus$EnumResourcePackStatus - */ - public Object getStatus() { - return getFieldValue(status); - } - - /** - * @param status: PacketPlayInResourcePackStatus$EnumResourcePackStatus - */ - public void setStatus(Object status) { - setField(this.status, status); - } + + Field status; + + PacketResourcePackStatusWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + status = getFirstField( + "status", + "action", + "b" + ); + } + + /** + * @return PacketPlayInResourcePackStatus$EnumResourcePackStatus + */ + public Object getStatus() { + return getFieldValue(status); + } + + /** + * @param status: PacketPlayInResourcePackStatus$EnumResourcePackStatus + */ + public void setStatus(Object status) { + setField(this.status, status); + } } From 7ae09004ebf2df069a6a7c112d2540c9d02fa9e8 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:52:20 +0200 Subject: [PATCH 126/260] Update WrappedPacketInResourcePackStatus.java --- .../WrappedPacketInResourcePackStatus.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/WrappedPacketInResourcePackStatus.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/WrappedPacketInResourcePackStatus.java index 71871d35..7cec3919 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/WrappedPacketInResourcePackStatus.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/resourcepackstatus/WrappedPacketInResourcePackStatus.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.resourcepackstatus; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInResourcePackStatus extends PacketResourcePackStatusWrapper { - WrappedPacketInResourcePackStatus(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInResourcePackStatus", - networkProtocolCommon + "ServerboundResourcePackPacket" - ) - ); - } + WrappedPacketInResourcePackStatus(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInResourcePackStatus", + networkProtocolCommon + "ServerboundResourcePackPacket" + ) + ); + } } From e628efdb46e7d3f92881b86a99025df1033e6898 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:52:34 +0200 Subject: [PATCH 127/260] Update PacketRespawnWrapper.java --- .../wrapper/respawn/PacketRespawnWrapper.java | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/PacketRespawnWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/PacketRespawnWrapper.java index 0cd00643..a882c634 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/PacketRespawnWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/PacketRespawnWrapper.java @@ -1,37 +1,38 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.respawn; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketRespawnWrapper extends PacketWrapper { - - Field levelType; - - PacketRespawnWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - levelType = getFirstField( - "levelType", - "d" - ); - } - - /** - * @return WorldType - */ - public Object getLevelType() { - return getFieldValue(levelType); - } - - /** - * @param levelType: WorldType - */ - public void setLevelType(Object levelType) { - setField(this.levelType, levelType); - } + + Field levelType; + + PacketRespawnWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + levelType = getFirstField( + "levelType", + "d" + ); + } + + /** + * @return WorldType + */ + public Object getLevelType() { + return getFieldValue(levelType); + } + + /** + * @param levelType: WorldType + */ + public void setLevelType(Object levelType) { + setField(this.levelType, levelType); + } } From 453fa8be41015b51c5edb2d5e8d3a66de22d0e39 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:52:45 +0200 Subject: [PATCH 128/260] Update WrappedPacketOutRespawn.java --- .../respawn/WrappedPacketOutRespawn.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/WrappedPacketOutRespawn.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/WrappedPacketOutRespawn.java index 13b328a4..b9b2f584 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/WrappedPacketOutRespawn.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/respawn/WrappedPacketOutRespawn.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.respawn; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutRespawn extends PacketRespawnWrapper { - WrappedPacketOutRespawn(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutRespawn", - networkProtocolGame + "PacketPlayOutRespawn" - ) - ); - } + WrappedPacketOutRespawn(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutRespawn", + networkProtocolGame + "PacketPlayOutRespawn" + ) + ); + } } From 4418a2cdae45198bafe6c815da8edaea9e2f4fe4 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:53:00 +0200 Subject: [PATCH 129/260] Update PacketScoreboardDisplayObjectiveWrapper.java --- ...cketScoreboardDisplayObjectiveWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/PacketScoreboardDisplayObjectiveWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/PacketScoreboardDisplayObjectiveWrapper.java index 67043b4e..60943408 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/PacketScoreboardDisplayObjectiveWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/PacketScoreboardDisplayObjectiveWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.display.objective; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketScoreboardDisplayObjectiveWrapper extends PacketWrapper { - - Field objectiveName; - - PacketScoreboardDisplayObjectiveWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - objectiveName = getFirstField( - "objectiveName", - "b" - ); - } - - public String getObjectiveName() { - return getFieldValue(objectiveName); - } - - public void setObjectiveName(String objectiveName) { - setField(this.objectiveName, objectiveName); - } + + Field objectiveName; + + PacketScoreboardDisplayObjectiveWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + objectiveName = getFirstField( + "objectiveName", + "b" + ); + } + + public String getObjectiveName() { + return getFieldValue(objectiveName); + } + + public void setObjectiveName(String objectiveName) { + setField(this.objectiveName, objectiveName); + } } From 71279d51b0ffb282f67aa57fe882ebc651264c86 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:53:12 +0200 Subject: [PATCH 130/260] Update WrappedPacketOutScoreboardDisplayObjective.java --- ...pedPacketOutScoreboardDisplayObjective.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/WrappedPacketOutScoreboardDisplayObjective.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/WrappedPacketOutScoreboardDisplayObjective.java index 0091fc15..a2232a2f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/WrappedPacketOutScoreboardDisplayObjective.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/display/objective/WrappedPacketOutScoreboardDisplayObjective.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.display.objective; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutScoreboardDisplayObjective extends PacketScoreboardDisplayObjectiveWrapper { - WrappedPacketOutScoreboardDisplayObjective(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutScoreboardDisplayObjective", - networkProtocolGame + "PacketPlayOutScoreboardDisplayObjective" - ) - ); - } + WrappedPacketOutScoreboardDisplayObjective(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutScoreboardDisplayObjective", + networkProtocolGame + "PacketPlayOutScoreboardDisplayObjective" + ) + ); + } } From a7e138cc2d82eb095dd521f837b6b30834bd16d8 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:53:40 +0200 Subject: [PATCH 131/260] Update PacketScoreboardObjectiveWrapper.java --- .../PacketScoreboardObjectiveWrapper.java | 107 +++++++++--------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/PacketScoreboardObjectiveWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/PacketScoreboardObjectiveWrapper.java index c065e882..cb095a03 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/PacketScoreboardObjectiveWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/PacketScoreboardObjectiveWrapper.java @@ -1,63 +1,64 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.objective; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketScoreboardObjectiveWrapper extends PacketWrapper { + + Field objectiveName; + Field renderType; + Field method; + + PacketScoreboardObjectiveWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + objectiveName = getFirstField( + "objectiveName", + "a" + ); + renderType = getFirstField( + "renderType", + "c" + ); + method = getFirstField( + "method", + "d" + ); + } + + public String getObjectiveName() { + return getFieldValue(objectiveName); + } + + public void setObjectiveName(String objectiveName) { + setField(this.objectiveName, objectiveName); + } + + /** + * @return IScoreboardCriteria$EnumScoreboardHealthDisplay + */ + public Object getRenderType() { + return getFieldValue(renderType); + } + + /** + * @param renderType: IScoreboardCriteria$EnumScoreboardHealthDisplay + */ + public void setRenderType(Object renderType) { + setField(this.renderType, renderType); + } - Field objectiveName; - Field renderType; - Field method; - - PacketScoreboardObjectiveWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - objectiveName = getFirstField( - "objectiveName", - "a" - ); - renderType = getFirstField( - "renderType", - "c" - ); - method = getFirstField( - "method", - "d" - ); - } - - public String getObjectiveName() { - return getFieldValue(objectiveName); - } - - public void setObjectiveName(String objectiveName) { - setField(this.objectiveName, objectiveName); - } - - /** - * @return IScoreboardCriteria$EnumScoreboardHealthDisplay - */ - public Object getRenderType() { - return getFieldValue(renderType); - } - - /** - * @param renderType: IScoreboardCriteria$EnumScoreboardHealthDisplay - */ - public void setRenderType(Object renderType) { - setField(this.renderType, renderType); - } - - public int getMethod() { - return getFieldValue(method); - } - - public void setMethod(int method) { - setField(this.method, method); - } + public int getMethod() { + return getFieldValue(method); + } + + public void setMethod(int method) { + setField(this.method, method); + } } From ff2a0dca70fb2242ec7d5bf57992eaa23fe43c30 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:53:54 +0200 Subject: [PATCH 132/260] Update WrappedPacketOutScoreboardObjective.java --- .../WrappedPacketOutScoreboardObjective.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/WrappedPacketOutScoreboardObjective.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/WrappedPacketOutScoreboardObjective.java index 34721dde..5df9db2e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/WrappedPacketOutScoreboardObjective.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/objective/WrappedPacketOutScoreboardObjective.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.objective; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutScoreboardObjective extends PacketScoreboardObjectiveWrapper { - WrappedPacketOutScoreboardObjective(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutScoreboardObjective", - networkProtocolGame + "PacketPlayOutScoreboardObjective" - ) - ); - } + WrappedPacketOutScoreboardObjective(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutScoreboardObjective", + networkProtocolGame + "PacketPlayOutScoreboardObjective" + ) + ); + } } From 45927ff5fbdc7e085fae37d74482c2c2a1efe7f6 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:54:18 +0200 Subject: [PATCH 133/260] Update PacketScoreboardScoreWrapper.java --- .../score/PacketScoreboardScoreWrapper.java | 97 ++++++++++--------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/PacketScoreboardScoreWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/PacketScoreboardScoreWrapper.java index f2139fb8..f71f1382 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/PacketScoreboardScoreWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/PacketScoreboardScoreWrapper.java @@ -1,57 +1,58 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.score; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketScoreboardScoreWrapper extends PacketWrapper { - - Field owner; - Field objectiveName; - Field score; - - PacketScoreboardScoreWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - owner = getFirstField( - "owner", - "a" - ); - objectiveName = getFirstField( - "objectiveName", - "b" - ); - score = getFirstField( - "score", - "c" - ); - } - - public String getOwner() { - return getFieldValue(owner); - } - - public void setOwner(String owner) { - setField(this.owner, owner); - } - - public String getObjectiveName() { - return getFieldValue(objectiveName); - } - - public void setObjectiveName(String objectiveName) { - setField(this.objectiveName, objectiveName); - } - - public int getScore() { - return getFieldValue(score); - } - - public void setScore(int score) { - setField(this.score, score); - } + + Field owner; + Field objectiveName; + Field score; + + PacketScoreboardScoreWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + owner = getFirstField( + "owner", + "a" + ); + objectiveName = getFirstField( + "objectiveName", + "b" + ); + score = getFirstField( + "score", + "c" + ); + } + + public String getOwner() { + return getFieldValue(owner); + } + + public void setOwner(String owner) { + setField(this.owner, owner); + } + + public String getObjectiveName() { + return getFieldValue(objectiveName); + } + + public void setObjectiveName(String objectiveName) { + setField(this.objectiveName, objectiveName); + } + + public int getScore() { + return getFieldValue(score); + } + + public void setScore(int score) { + setField(this.score, score); + } } From 5a56307006f061496e4209e4dafa780a2bc81bc6 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:54:38 +0200 Subject: [PATCH 134/260] Update WrappedPacketOutScoreboardScore.java --- .../score/WrappedPacketOutScoreboardScore.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/WrappedPacketOutScoreboardScore.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/WrappedPacketOutScoreboardScore.java index 65b067dd..7a4697e3 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/WrappedPacketOutScoreboardScore.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/score/WrappedPacketOutScoreboardScore.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.score; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutScoreboardScore extends PacketScoreboardScoreWrapper { - WrappedPacketOutScoreboardScore(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutScoreboardScore", - networkProtocolGame + "PacketPlayOutScoreboardScore" - ) - ); - } + WrappedPacketOutScoreboardScore(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutScoreboardScore", + networkProtocolGame + "PacketPlayOutScoreboardScore" + ) + ); + } } From 68208ab85282006c34a121963e4609c73f3c240d Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:55:03 +0200 Subject: [PATCH 135/260] Update PacketScoreboardTeamWrapper.java --- .../team/PacketScoreboardTeamWrapper.java | 99 ++++++++++--------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/PacketScoreboardTeamWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/PacketScoreboardTeamWrapper.java index 0c5b4d34..22493f7d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/PacketScoreboardTeamWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/PacketScoreboardTeamWrapper.java @@ -1,58 +1,59 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.team; -import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Collection; import java.util.Set; +import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) abstract class PacketScoreboardTeamWrapper extends PacketWrapper { - - Field name; - Field players; - Field method; - - PacketScoreboardTeamWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - name = getFirstField( - "name", - "a" - ); - players = getFirstField( - "players", - "g" - ); - method = getFirstField( - "method", - "h" - ); - } - - public String getName() { - return getFieldValue(name); - } - - public void setName(String name) { - setField(this.name, name); - } - - public Collection getPlayers() { - return getFieldValue(players); - } - - public void setPlayers(Collection players) { - setField(this.players, players); - } - - public int getMethod() { - return getFieldValue(method); - } - - public void setMethod(int method) { - setField(this.method, method); - } + + Field name; + Field players; + Field method; + + PacketScoreboardTeamWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + name = getFirstField( + "name", + "a" + ); + players = getFirstField( + "players", + "g" + ); + method = getFirstField( + "method", + "h" + ); + } + + public String getName() { + return getFieldValue(name); + } + + public void setName(String name) { + setField(this.name, name); + } + + public Collection getPlayers() { + return getFieldValue(players); + } + + public void setPlayers(Collection players) { + setField(this.players, players); + } + + public int getMethod() { + return getFieldValue(method); + } + + public void setMethod(int method) { + setField(this.method, method); + } } From 9f35a6e4e232d40da302382528572c518c1df65c Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:55:15 +0200 Subject: [PATCH 136/260] Update WrappedPacketOutScoreboardTeam.java --- .../team/WrappedPacketOutScoreboardTeam.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/WrappedPacketOutScoreboardTeam.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/WrappedPacketOutScoreboardTeam.java index 80df5d00..df802b3d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/WrappedPacketOutScoreboardTeam.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/scoreboard/team/WrappedPacketOutScoreboardTeam.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.scoreboard.team; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutScoreboardTeam extends PacketScoreboardTeamWrapper { - WrappedPacketOutScoreboardTeam(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutScoreboardTeam", - networkProtocolGame + "PacketPlayOutScoreboardTeam" - ) - ); - } + WrappedPacketOutScoreboardTeam(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutScoreboardTeam", + networkProtocolGame + "PacketPlayOutScoreboardTeam" + ) + ); + } } From c272abd8e369f4c881b95b9e76a62011a1a4bfab Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:55:33 +0200 Subject: [PATCH 137/260] Update PacketServerDifficultyWrapper.java --- .../PacketServerDifficultyWrapper.java | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/PacketServerDifficultyWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/PacketServerDifficultyWrapper.java index dfe1c05c..1b339588 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/PacketServerDifficultyWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/PacketServerDifficultyWrapper.java @@ -1,50 +1,51 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.serverdifficulty; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketServerDifficultyWrapper extends PacketWrapper { - - Field difficulty; - Field locked; - - PacketServerDifficultyWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - difficulty = getFirstField( - "difficulty", - "a" - ); - locked = getFirstField( - "locked", - "b" - ); - } - - /** - * @return EnumDifficulty - */ - public Object getDifficulty() { - return getFieldValue(difficulty); - } - - /** - * @param difficulty: EnumDifficulty - */ - public void setDifficulty(Object difficulty) { - setField(this.difficulty, difficulty); - } - - public boolean isLocked() { - return getFieldValue(locked); - } - - public void setLocked(boolean locked) { - setField(this.locked, locked); - } + + Field difficulty; + Field locked; + + PacketServerDifficultyWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + difficulty = getFirstField( + "difficulty", + "a" + ); + locked = getFirstField( + "locked", + "b" + ); + } + + /** + * @return EnumDifficulty + */ + public Object getDifficulty() { + return getFieldValue(difficulty); + } + + /** + * @param difficulty: EnumDifficulty + */ + public void setDifficulty(Object difficulty) { + setField(this.difficulty, difficulty); + } + + public boolean isLocked() { + return getFieldValue(locked); + } + + public void setLocked(boolean locked) { + setField(this.locked, locked); + } } From 519bbcbf16102480f38c62b241f0dfeb4cfa4a26 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:55:43 +0200 Subject: [PATCH 138/260] Update WrappedPacketOutServerDifficulty.java --- .../WrappedPacketOutServerDifficulty.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/WrappedPacketOutServerDifficulty.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/WrappedPacketOutServerDifficulty.java index c2f91979..0e44a516 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/WrappedPacketOutServerDifficulty.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/serverdifficulty/WrappedPacketOutServerDifficulty.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.serverdifficulty; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutServerDifficulty extends PacketServerDifficultyWrapper { - WrappedPacketOutServerDifficulty(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutServerDifficulty", - networkProtocolGame + "PacketPlayOutServerDifficulty" - ) - ); - } + WrappedPacketOutServerDifficulty(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutServerDifficulty", + networkProtocolGame + "PacketPlayOutServerDifficulty" + ) + ); + } } From c9d616859ead2cc696c57d7e92f5b4a852d71bad Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:56:00 +0200 Subject: [PATCH 139/260] Update PacketSetCreativeSlotWrapper.java --- .../PacketSetCreativeSlotWrapper.java | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/PacketSetCreativeSlotWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/PacketSetCreativeSlotWrapper.java index 9d6b5d34..e97d4d3a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/PacketSetCreativeSlotWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/PacketSetCreativeSlotWrapper.java @@ -1,37 +1,38 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.set.creativeslot; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketSetCreativeSlotWrapper extends PacketWrapper { - - Field itemStack; - - PacketSetCreativeSlotWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - itemStack = getFirstField( - "itemStack", - "b" - ); - } - - /** - * @return ItemStack - */ - public Object getItemStack() { - return getFieldValue(itemStack); - } - - /** - * @param itemStack: ItemStack - */ - public void setItemStack(Object itemStack) { - setField(this.itemStack, itemStack); - } + + Field itemStack; + + PacketSetCreativeSlotWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + itemStack = getFirstField( + "itemStack", + "b" + ); + } + + /** + * @return ItemStack + */ + public Object getItemStack() { + return getFieldValue(itemStack); + } + + /** + * @param itemStack: ItemStack + */ + public void setItemStack(Object itemStack) { + setField(this.itemStack, itemStack); + } } From 63b11b084d4fb3891c6b9fdd4a95b03508bb1fcc Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:56:10 +0200 Subject: [PATCH 140/260] Update WrappedPacketInSetCreativeSlot.java --- .../WrappedPacketInSetCreativeSlot.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/WrappedPacketInSetCreativeSlot.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/WrappedPacketInSetCreativeSlot.java index e20fa6d8..3c89a1af 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/WrappedPacketInSetCreativeSlot.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/creativeslot/WrappedPacketInSetCreativeSlot.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.set.creativeslot; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInSetCreativeSlot extends PacketSetCreativeSlotWrapper { - public WrappedPacketInSetCreativeSlot(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInSetCreativeSlot", - networkProtocolGame + "PacketPlayInSetCreativeSlot" - ) - ); - } + public WrappedPacketInSetCreativeSlot(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInSetCreativeSlot", + networkProtocolGame + "PacketPlayInSetCreativeSlot" + ) + ); + } } From fd6cb63166b35f8c617099bd1dc661e4ef883f66 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:56:36 +0200 Subject: [PATCH 141/260] Update PacketSetSlotWrapper.java --- .../set/slot/PacketSetSlotWrapper.java | 107 +++++++++--------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/PacketSetSlotWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/PacketSetSlotWrapper.java index 34b7e254..41eb5a62 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/PacketSetSlotWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/PacketSetSlotWrapper.java @@ -1,63 +1,64 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.set.slot; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketSetSlotWrapper extends PacketWrapper { + + Field containerId; + Field slot; + Field itemStack; + + PacketSetSlotWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + slot = getFirstField( + "slot", + "b" + ); + itemStack = getFirstField( + "itemStack", + "c" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } + + public int getSlot() { + return getFieldValue(slot); + } + + public void setSlot(int slot) { + setField(this.slot, slot); + } - Field containerId; - Field slot; - Field itemStack; - - PacketSetSlotWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - slot = getFirstField( - "slot", - "b" - ); - itemStack = getFirstField( - "itemStack", - "c" - ); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public int getSlot() { - return getFieldValue(slot); - } - - public void setSlot(int slot) { - setField(this.slot, slot); - } - - /** - * @return ItemStack - */ - public Object getItemStack() { - return getFieldValue(itemStack); - } - - /** - * @param itemStack: ItemStack - */ - public void setItemStack(Object itemStack) { - setField(this.itemStack, itemStack); - } + /** + * @return ItemStack + */ + public Object getItemStack() { + return getFieldValue(itemStack); + } + + /** + * @param itemStack: ItemStack + */ + public void setItemStack(Object itemStack) { + setField(this.itemStack, itemStack); + } } From c6a238c309d3b58616e7f2effe7456e8abb23b55 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:56:47 +0200 Subject: [PATCH 142/260] Update WrappedPacketOutSetSlot.java --- .../set/slot/WrappedPacketOutSetSlot.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/WrappedPacketOutSetSlot.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/WrappedPacketOutSetSlot.java index 89fcecc0..7215712f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/WrappedPacketOutSetSlot.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/set/slot/WrappedPacketOutSetSlot.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.set.slot; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutSetSlot extends PacketSetSlotWrapper { - public WrappedPacketOutSetSlot(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutSetSlot", - networkProtocolGame + "PacketPlayOutSetSlot" - ) - ); - } + public WrappedPacketOutSetSlot(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutSetSlot", + networkProtocolGame + "PacketPlayOutSetSlot" + ) + ); + } } From 53ad04e2d892a43d9eacc33da514dded928144ce Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:56:59 +0200 Subject: [PATCH 143/260] Update PacketSettingsWrapper.java --- .../wrapper/settings/PacketSettingsWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/PacketSettingsWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/PacketSettingsWrapper.java index 4f7c2072..16c9cd61 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/PacketSettingsWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/PacketSettingsWrapper.java @@ -1,13 +1,14 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.settings; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import java.util.Set; +import lombok.NonNull; abstract class PacketSettingsWrapper extends PacketWrapper { - PacketSettingsWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketSettingsWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From 1ed75d3f79c884d2db1a841423fc1ef209af8193 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:57:09 +0200 Subject: [PATCH 144/260] Update WrappedPacketInSettings.java --- .../settings/WrappedPacketInSettings.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/WrappedPacketInSettings.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/WrappedPacketInSettings.java index 743fda8f..21024b20 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/WrappedPacketInSettings.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/settings/WrappedPacketInSettings.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.settings; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInSettings extends PacketSettingsWrapper { - public WrappedPacketInSettings(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInSettings", - networkProtocolCommon + "ServerboundClientInformationPacket" - ) - ); - } + public WrappedPacketInSettings(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInSettings", + networkProtocolCommon + "ServerboundClientInformationPacket" + ) + ); + } } From 95b3866973176c449fd5383c590d7ea0ee72ff35 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:57:36 +0200 Subject: [PATCH 145/260] Update PacketSpawnEntityWrapper.java --- .../entity/PacketSpawnEntityWrapper.java | 69 ++++++++++--------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/PacketSpawnEntityWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/PacketSpawnEntityWrapper.java index 7c2739fa..7c40912f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/PacketSpawnEntityWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/PacketSpawnEntityWrapper.java @@ -1,44 +1,45 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spawn.entity; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketSpawnEntityWrapper extends PacketWrapper { - Field id; - Field data; - - PacketSpawnEntityWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - id = getFirstField( - "id", - "a" - ); - data = getFirstField( - "data", - "k" - ); - } - - public int getId() { - return getFieldValue(id); - } - - public void setId(int id) { - setField(this.id, id); - } - - public int getData() { - return getFieldValue(data); - } - - public void setData(int data) { - setField(this.data, data); - } + Field id; + Field data; + + PacketSpawnEntityWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + id = getFirstField( + "id", + "a" + ); + data = getFirstField( + "data", + "k" + ); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } } From 9b599d14a62eaa1dd6c7dc5813318309e2a80ab7 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:57:50 +0200 Subject: [PATCH 146/260] Update WrappedPacketOutSpawnEntity.java --- .../entity/WrappedPacketOutSpawnEntity.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/WrappedPacketOutSpawnEntity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/WrappedPacketOutSpawnEntity.java index 2b863dbb..a1f36926 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/WrappedPacketOutSpawnEntity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/entity/WrappedPacketOutSpawnEntity.java @@ -1,17 +1,17 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spawn.entity; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + // TODO: add all entity spawn packets public class WrappedPacketOutSpawnEntity extends PacketSpawnEntityWrapper { - public WrappedPacketOutSpawnEntity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutSpawnEntity", - networkProtocolGame + "PacketPlayOutSpawnEntity" - ) - ); - } + public WrappedPacketOutSpawnEntity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutSpawnEntity", + networkProtocolGame + "PacketPlayOutSpawnEntity" + ) + ); + } } From 49bb5c9b05389a37093c7f16ff095d8fd64fe577 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:58:00 +0200 Subject: [PATCH 147/260] Update PacketSpawnPositionWrapper.java --- .../spawn/position/PacketSpawnPositionWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/PacketSpawnPositionWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/PacketSpawnPositionWrapper.java index 09eac289..3c22432d 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/PacketSpawnPositionWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/PacketSpawnPositionWrapper.java @@ -1,13 +1,14 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spawn.position; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import java.util.Set; +import lombok.NonNull; abstract class PacketSpawnPositionWrapper extends PacketWrapper { - PacketSpawnPositionWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketSpawnPositionWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From de622a964ac167f0797e56c8591f12ed91769fd7 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:58:12 +0200 Subject: [PATCH 148/260] Update WrappedPacketOutSpawnPosition.java --- .../WrappedPacketOutSpawnPosition.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/WrappedPacketOutSpawnPosition.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/WrappedPacketOutSpawnPosition.java index d2d014ac..0bf9808c 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/WrappedPacketOutSpawnPosition.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spawn/position/WrappedPacketOutSpawnPosition.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spawn.position; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutSpawnPosition extends PacketSpawnPositionWrapper { - public WrappedPacketOutSpawnPosition(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutSpawnPosition", - networkProtocolGame + "PacketPlayOutSpawnPosition" - ) - ); - } + public WrappedPacketOutSpawnPosition(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutSpawnPosition", + networkProtocolGame + "PacketPlayOutSpawnPosition" + ) + ); + } } From 0920ec2579a16557585a6bb7bdefd34188566436 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:58:26 +0200 Subject: [PATCH 149/260] Update PacketSpectateWrapper.java --- .../spectate/PacketSpectateWrapper.java | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java index 0d2c4a4a..6503f6a7 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java @@ -1,32 +1,33 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spectate; -import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; import java.util.UUID; -@FieldDefaults(makeFinal = true) -abstract class PacketSpectateWrapper extends PacketWrapper { - - Field uuid; - - PacketSpectateWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - uuid = getFirstField( - "uuid", - "a" - ); - } +import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; - public UUID getUUID() { - return getFieldValue(uuid); - } +import lombok.NonNull; +import lombok.experimental.FieldDefaults; - public void setUUID(int cameraId) { - setField(this.uuid, cameraId); - } +@FieldDefaults(makeFinal = true) +abstract class PacketSpectateWrapper extends PacketWrapper { + + Field uuid; + + PacketSpectateWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + uuid = getFirstField( + "uuid", + "a" + ); + } + + public UUID getUUID() { + return getFieldValue(uuid); + } + + public void setUUID(int cameraId) { + setField(this.uuid, cameraId); + } } From 3721c65a16fd685bcd60e1a91c9f253a5313618c Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:58:52 +0200 Subject: [PATCH 150/260] Update PacketSpectateWrapper.java --- .../packets/wrapper/spectate/PacketSpectateWrapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java index 6503f6a7..b5631853 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/PacketSpectateWrapper.java @@ -27,7 +27,7 @@ public UUID getUUID() { return getFieldValue(uuid); } - public void setUUID(int cameraId) { - setField(this.uuid, cameraId); + public void setUUID(int uuid) { + setField(this.uuid, uuid); } } From fe8248dbb4745d160bb8849b9b5b453c9a67604f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:59:02 +0200 Subject: [PATCH 151/260] Update WrappedPacketInSpectate.java --- .../spectate/WrappedPacketInSpectate.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/WrappedPacketInSpectate.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/WrappedPacketInSpectate.java index 8e0ea36f..67487f0b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/WrappedPacketInSpectate.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/spectate/WrappedPacketInSpectate.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.spectate; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInSpectate extends PacketSpectateWrapper { - public WrappedPacketInSpectate(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInSpectate", - networkProtocolGame + "PacketPlayInSpectate" - ) - ); - } + public WrappedPacketInSpectate(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInSpectate", + networkProtocolGame + "PacketPlayInSpectate" + ) + ); + } } From 0b7e32c16545cf36af86cfe07a4a07989d5a57ae Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:59:12 +0200 Subject: [PATCH 152/260] Update PacketStatisticWrapper.java --- .../wrapper/statistic/PacketStatisticWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/PacketStatisticWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/PacketStatisticWrapper.java index d3d986d2..bf444f0e 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/PacketStatisticWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/PacketStatisticWrapper.java @@ -1,13 +1,14 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.statistic; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import java.util.Set; +import lombok.NonNull; abstract class PacketStatisticWrapper extends PacketWrapper { - PacketStatisticWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketStatisticWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From 099e9a7483ca896276bd8b07a358b633bb6c4ecd Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:59:23 +0200 Subject: [PATCH 153/260] Update WrappedPacketOutStatistic.java --- .../statistic/WrappedPacketOutStatistic.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/WrappedPacketOutStatistic.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/WrappedPacketOutStatistic.java index 521d04b9..0d5f30f5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/WrappedPacketOutStatistic.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/statistic/WrappedPacketOutStatistic.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.statistic; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutStatistic extends PacketStatisticWrapper { - public WrappedPacketOutStatistic(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutStatistic", - networkProtocolGame + "PacketPlayOutStatistic" - ) - ); - } + public WrappedPacketOutStatistic(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutStatistic", + networkProtocolGame + "PacketPlayOutStatistic" + ) + ); + } } From be12e25ab4ac4c533ef8cb5233e26a7b494f7d59 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:59:35 +0200 Subject: [PATCH 154/260] Update PacketSteerVehicleWrapper.java --- .../steervehicle/PacketSteerVehicleWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/PacketSteerVehicleWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/PacketSteerVehicleWrapper.java index 06c6be60..6b4110ef 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/PacketSteerVehicleWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/PacketSteerVehicleWrapper.java @@ -1,13 +1,14 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.steervehicle; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import java.util.Set; +import lombok.NonNull; abstract class PacketSteerVehicleWrapper extends PacketWrapper { - PacketSteerVehicleWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketSteerVehicleWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From 497621114aca8606893308508d24cf2396d392d0 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:59:45 +0200 Subject: [PATCH 155/260] Update WrappedPacketInSteerVehicle.java --- .../WrappedPacketInSteerVehicle.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/WrappedPacketInSteerVehicle.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/WrappedPacketInSteerVehicle.java index 96d8f4f3..9484d311 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/WrappedPacketInSteerVehicle.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/steervehicle/WrappedPacketInSteerVehicle.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.steervehicle; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInSteerVehicle extends PacketSteerVehicleWrapper { - public WrappedPacketInSteerVehicle(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInSteerVehicle", - networkProtocolGame + "PacketPlayInSteerVehicle" - ) - ); - } + public WrappedPacketInSteerVehicle(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInSteerVehicle", + networkProtocolGame + "PacketPlayInSteerVehicle" + ) + ); + } } From e0667f1e744a001edc95e4897dc8c1ad50fada7d Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 22:59:55 +0200 Subject: [PATCH 156/260] Update PacketTabCompleteWrapper.java --- .../wrapper/tabcomplete/PacketTabCompleteWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/PacketTabCompleteWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/PacketTabCompleteWrapper.java index d9836b12..5e7cf2f5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/PacketTabCompleteWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/PacketTabCompleteWrapper.java @@ -1,13 +1,14 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tabcomplete; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import java.util.Set; +import lombok.NonNull; abstract class PacketTabCompleteWrapper extends PacketWrapper { - PacketTabCompleteWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketTabCompleteWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From 3dddc04b1897e9d93b78779dbfec0ac2a55243dd Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:00:10 +0200 Subject: [PATCH 157/260] Update WrappedPacketInTabComplete.java --- .../WrappedPacketInTabComplete.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketInTabComplete.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketInTabComplete.java index 7f9ff433..e312d7da 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketInTabComplete.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketInTabComplete.java @@ -1,34 +1,34 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tabcomplete; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketInTabComplete extends PacketTabCompleteWrapper { - Field command; - - public WrappedPacketInTabComplete(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInTabComplete", - networkProtocolGame + "PacketPlayInTabComplete" - ) - ); - - command = getFirstField( - "command", - "b" - ); - } - - public String getCommand() { - return getFieldValue(command); - } - - public void setCommand(int command) { - setField(this.command, command); - } + Field command; + + public WrappedPacketInTabComplete(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInTabComplete", + networkProtocolGame + "PacketPlayInTabComplete" + ) + ); + + command = getFirstField( + "command", + "b" + ); + } + + public String getCommand() { + return getFieldValue(command); + } + + public void setCommand(int command) { + setField(this.command, command); + } } From 68e3038fe77ed410ab702f44e2b4564c012b4e3b Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:00:42 +0200 Subject: [PATCH 158/260] Update WrappedPacketOutTabComplete.java --- .../WrappedPacketOutTabComplete.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketOutTabComplete.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketOutTabComplete.java index 7f5e5262..a84a0db5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketOutTabComplete.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tabcomplete/WrappedPacketOutTabComplete.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tabcomplete; -import lombok.NonNull; - import java.util.Set; -public class WrappedPacketOutTabComplete extends PacketTabCompleteWrapper { +import lombok.NonNull; - public WrappedPacketOutTabComplete(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTabComplete", - networkProtocolGame + "PacketPlayOutTabComplete" - ) - ); - } +public class WrappedPacketOutTabComplete extends PacketTabCompleteWrapper { + + public WrappedPacketOutTabComplete(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTabComplete", + networkProtocolGame + "PacketPlayOutTabComplete" + ) + ); + } } From 657d4cd261e372d7a1e4df2ebd8ec73e5a342670 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:01:07 +0200 Subject: [PATCH 159/260] Update PacketTileEntityDataWrapper.java --- .../PacketTileEntityDataWrapper.java | 113 +++++++++--------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/PacketTileEntityDataWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/PacketTileEntityDataWrapper.java index 180398ca..2c1ad1b9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/PacketTileEntityDataWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/PacketTileEntityDataWrapper.java @@ -1,69 +1,70 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tileentitydata; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketTileEntityDataWrapper extends PacketWrapper { + + Field pos; + Field type; + Field tag; - Field pos; - Field type; - Field tag; - - PacketTileEntityDataWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - type = getFirstField( - "type", - "b" - ); - tag = getFirstField( - "tag", - "c" - ); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } - - public int getType() { - return getFieldValue(type); - } + PacketTileEntityDataWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + type = getFirstField( + "type", + "b" + ); + tag = getFirstField( + "tag", + "c" + ); + } - public void setType(int type) { - setField(this.type, type); - } + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } - /** - * @return NBTTagCompound - */ - public Object getTag() { - return getFieldValue(tag); - } + public int getType() { + return getFieldValue(type); + } + + public void setType(int type) { + setField(this.type, type); + } - /** - * @param tag: NBTTagCompound - */ - public void setTag(Object tag) { - setField(this.tag, tag); - } + /** + * @return NBTTagCompound + */ + public Object getTag() { + return getFieldValue(tag); + } + + /** + * @param tag: NBTTagCompound + */ + public void setTag(Object tag) { + setField(this.tag, tag); + } } From cfc568514f9aef7d5fe11f5f2776deb69337a4aa Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:01:18 +0200 Subject: [PATCH 160/260] Update WrappedPacketOutTileEntityData.java --- .../WrappedPacketOutTileEntityData.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/WrappedPacketOutTileEntityData.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/WrappedPacketOutTileEntityData.java index 6962ede9..c682b0c3 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/WrappedPacketOutTileEntityData.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/tileentitydata/WrappedPacketOutTileEntityData.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.tileentitydata; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutTileEntityData extends PacketTileEntityDataWrapper { - public WrappedPacketOutTileEntityData(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTileEntityData", - networkProtocolGame + "PacketPlayOutTileEntityData" - ) - ); - } + public WrappedPacketOutTileEntityData(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTileEntityData", + networkProtocolGame + "PacketPlayOutTileEntityData" + ) + ); + } } From 777180486848ae6e93b1c8f3932b0ad22447570e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:01:30 +0200 Subject: [PATCH 161/260] Update PacketTitleWrapper.java --- .../packets/wrapper/title/PacketTitleWrapper.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/PacketTitleWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/PacketTitleWrapper.java index be2e66f2..7f3ee5d9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/PacketTitleWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/PacketTitleWrapper.java @@ -1,13 +1,14 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.title; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; -import lombok.NonNull; -import java.util.Set; +import lombok.NonNull; abstract class PacketTitleWrapper extends PacketWrapper { - PacketTitleWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketTitleWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From f3c89d1a1de2a87301f853dee9323a5198efeacd Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:01:54 +0200 Subject: [PATCH 162/260] Update WrappedPacketOutAnimationTitle.java --- .../title/WrappedPacketOutAnimationTitle.java | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutAnimationTitle.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutAnimationTitle.java index 7b5e3fa0..679e0016 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutAnimationTitle.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutAnimationTitle.java @@ -1,63 +1,63 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.title; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutAnimationTitle extends PacketTitleWrapper { - Field fadeInTime; - Field stayTime; - Field fadeOutTime; - - WrappedPacketOutAnimationTitle(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTitle", - networkProtocolGame + "ClientboundSetTitlesAnimationPacket" - ) - ); - - fadeInTime = getFirstField( - "fadeInTime", - "fadeIn", - "c" - ); - stayTime = getFirstField( - "stayTime", - "stay", - "d" - ); - fadeOutTime = getFirstField( - "fadeOutTime", - "fadeOut", - "e" - ); - } - - public int getFadeInTime() { - return getFieldValue(fadeInTime); - } - - public void setFadeInTime(int fadeInTime) { - setField(this.fadeInTime, fadeInTime); - } - - public int getStayTime() { - return getFieldValue(stayTime); - } - - public void setStayTime(int stayTime) { - setField(this.stayTime, stayTime); - } - - public int getFadeOutTime() { - return getFieldValue(fadeOutTime); - } - - public void setFadeOutTime(int fadeOutTime) { - setField(this.fadeOutTime, fadeOutTime); - } + Field fadeInTime; + Field stayTime; + Field fadeOutTime; + + WrappedPacketOutAnimationTitle(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTitle", + networkProtocolGame + "ClientboundSetTitlesAnimationPacket" + ) + ); + + fadeInTime = getFirstField( + "fadeInTime", + "fadeIn", + "c" + ); + stayTime = getFirstField( + "stayTime", + "stay", + "d" + ); + fadeOutTime = getFirstField( + "fadeOutTime", + "fadeOut", + "e" + ); + } + + public int getFadeInTime() { + return getFieldValue(fadeInTime); + } + + public void setFadeInTime(int fadeInTime) { + setField(this.fadeInTime, fadeInTime); + } + + public int getStayTime() { + return getFieldValue(stayTime); + } + + public void setStayTime(int stayTime) { + setField(this.stayTime, stayTime); + } + + public int getFadeOutTime() { + return getFieldValue(fadeOutTime); + } + + public void setFadeOutTime(int fadeOutTime) { + setField(this.fadeOutTime, fadeOutTime); + } } From f698e73cd0f2704518dd7e01cbe6252ba2b3c1fd Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:02:09 +0200 Subject: [PATCH 163/260] Update WrappedPacketOutSubtitleTitle.java --- .../title/WrappedPacketOutSubtitleTitle.java | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutSubtitleTitle.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutSubtitleTitle.java index 6e2f446f..ff5f1f5a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutSubtitleTitle.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutSubtitleTitle.java @@ -1,40 +1,40 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.title; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutSubtitleTitle extends PacketTitleWrapper { - - Field text; - - WrappedPacketOutSubtitleTitle(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTitle", - networkProtocolGame + "ClientboundSetSubtitleTextPacket" - ) - ); - - text = getFirstField( - "text", - "b" - ); - } - - /** - * @return IChatBaseComponent - */ - public Object getText() { - return getFieldValue(text); - } - - /** - * @param text: IChatBaseComponent - */ - public void setText(Object text) { - setField(this.text, text); - } + + Field text; + + WrappedPacketOutSubtitleTitle(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTitle", + networkProtocolGame + "ClientboundSetSubtitleTextPacket" + ) + ); + + text = getFirstField( + "text", + "b" + ); + } + + /** + * @return IChatBaseComponent + */ + public Object getText() { + return getFieldValue(text); + } + + /** + * @param text: IChatBaseComponent + */ + public void setText(Object text) { + setField(this.text, text); + } } From b0eaac6c101226fa3d6ac26211020fa4d175331a Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:02:23 +0200 Subject: [PATCH 164/260] Update WrappedPacketOutTitleTitle.java --- .../title/WrappedPacketOutTitleTitle.java | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutTitleTitle.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutTitleTitle.java index 76606d54..471236a7 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutTitleTitle.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/title/WrappedPacketOutTitleTitle.java @@ -1,40 +1,40 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.title; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) public class WrappedPacketOutTitleTitle extends PacketTitleWrapper { - - Field text; - - WrappedPacketOutTitleTitle(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutTitle", - networkProtocolGame + "ClientboundSetTitleTextPacket" - ) - ); - - text = getFirstField( - "text", - "b" - ); - } - - /** - * @return IChatBaseComponent - */ - public Object getText() { - return getFieldValue(text); - } - - /** - * @param text: IChatBaseComponent - */ - public void setText(Object text) { - setField(this.text, text); - } + + Field text; + + WrappedPacketOutTitleTitle(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutTitle", + networkProtocolGame + "ClientboundSetTitleTextPacket" + ) + ); + + text = getFirstField( + "text", + "b" + ); + } + + /** + * @return IChatBaseComponent + */ + public Object getText() { + return getFieldValue(text); + } + + /** + * @param text: IChatBaseComponent + */ + public void setText(Object text) { + setField(this.text, text); + } } From 6316d3fcdf3b671926e06628c3f1bb428d4e97af Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:02:39 +0200 Subject: [PATCH 165/260] Update PacketUpdateAttributesWrapper.java --- .../PacketUpdateAttributesWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/PacketUpdateAttributesWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/PacketUpdateAttributesWrapper.java index 96b2ac05..5e69e849 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/PacketUpdateAttributesWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/PacketUpdateAttributesWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.attributes; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketUpdateAttributesWrapper extends PacketWrapper { - - Field entityId; - - PacketUpdateAttributesWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - entityId = getFirstField( - "entityId", - "a" - ); - } - - public void setPos(int entityId) { - setField(this.entityId, entityId); - } - - public int getEntityId() { - return getFieldValue(entityId); - } + + Field entityId; + + PacketUpdateAttributesWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + entityId = getFirstField( + "entityId", + "a" + ); + } + + public int getEntityId() { + return getFieldValue(entityId); + } + + public void setPos(int entityId) { + setField(this.entityId, entityId); + } } From 52e4b51c917e9ce174eb4e0250fbd3570d9d4b32 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:02:49 +0200 Subject: [PATCH 166/260] Update WrappedPacketOutUpdateAttributes.java --- .../WrappedPacketOutUpdateAttributes.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/WrappedPacketOutUpdateAttributes.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/WrappedPacketOutUpdateAttributes.java index dc8b317e..c7535f73 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/WrappedPacketOutUpdateAttributes.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/attributes/WrappedPacketOutUpdateAttributes.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.attributes; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutUpdateAttributes extends PacketUpdateAttributesWrapper { - public WrappedPacketOutUpdateAttributes(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutUpdateAttributes", - networkProtocolGame + "PacketPlayOutUpdateAttributes" - ) - ); - } + public WrappedPacketOutUpdateAttributes(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutUpdateAttributes", + networkProtocolGame + "PacketPlayOutUpdateAttributes" + ) + ); + } } From 3620a7b0e9864039752cd1950804979f150651d3 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:03:13 +0200 Subject: [PATCH 167/260] Update PacketUpdateHealthWrapper.java --- .../health/PacketUpdateHealthWrapper.java | 97 ++++++++++--------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/PacketUpdateHealthWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/PacketUpdateHealthWrapper.java index 4ab06c9b..7bdcb70b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/PacketUpdateHealthWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/PacketUpdateHealthWrapper.java @@ -1,57 +1,58 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.health; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketUpdateHealthWrapper extends PacketWrapper { - - Field health; - Field food; - Field saturation; - - PacketUpdateHealthWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - health = getFirstField( - "health", - "a" - ); - food = getFirstField( - "food", - "b" - ); - saturation = getFirstField( - "saturation", - "c" - ); - } - - public float getHealth() { - return getFieldValue(health); - } - - public void setHealth(float health) { - setField(this.health, health); - } - - public int getFood() { - return getFieldValue(food); - } - - public void setFood(int food) { - setField(this.food, food); - } - - public float getSaturation() { - return getFieldValue(saturation); - } - - public void setSaturation(int saturation) { - setField(this.saturation, saturation); - } + + Field health; + Field food; + Field saturation; + + PacketUpdateHealthWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + health = getFirstField( + "health", + "a" + ); + food = getFirstField( + "food", + "b" + ); + saturation = getFirstField( + "saturation", + "c" + ); + } + + public float getHealth() { + return getFieldValue(health); + } + + public void setHealth(float health) { + setField(this.health, health); + } + + public int getFood() { + return getFieldValue(food); + } + + public void setFood(int food) { + setField(this.food, food); + } + + public float getSaturation() { + return getFieldValue(saturation); + } + + public void setSaturation(int saturation) { + setField(this.saturation, saturation); + } } From 04e75d07bb869729131cea474f698cfcb87060cf Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:03:25 +0200 Subject: [PATCH 168/260] Update WrappedPacketOutUpdateHealth.java --- .../health/WrappedPacketOutUpdateHealth.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/WrappedPacketOutUpdateHealth.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/WrappedPacketOutUpdateHealth.java index eb8e53e7..c40f47a5 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/WrappedPacketOutUpdateHealth.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/health/WrappedPacketOutUpdateHealth.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.health; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutUpdateHealth extends PacketUpdateHealthWrapper { - public WrappedPacketOutUpdateHealth(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutUpdateHealth", - networkProtocolGame + "PacketPlayOutUpdateHealth" - ) - ); - } + public WrappedPacketOutUpdateHealth(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutUpdateHealth", + networkProtocolGame + "PacketPlayOutUpdateHealth" + ) + ); + } } From 72b1cafd067874fccb6d2d8de366788f687408b1 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:03:42 +0200 Subject: [PATCH 169/260] Update PacketUpdateSignWrapper.java --- .../update/sign/PacketUpdateSignWrapper.java | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/PacketUpdateSignWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/PacketUpdateSignWrapper.java index 7b2c511a..08491cc3 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/PacketUpdateSignWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/PacketUpdateSignWrapper.java @@ -1,37 +1,38 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.sign; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketUpdateSignWrapper extends PacketWrapper { - - Field pos; - - PacketUpdateSignWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - pos = getFirstField( - "pos", - "a" - ); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(pos); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } + + Field pos; + + PacketUpdateSignWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + pos = getFirstField( + "pos", + "a" + ); + } + + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(pos); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } } From 9e6d840ad368b72dc78e67ea66aa95512a5b0bdb Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:03:53 +0200 Subject: [PATCH 170/260] Update WrappedPacketInUpdateSign.java --- .../update/sign/WrappedPacketInUpdateSign.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/WrappedPacketInUpdateSign.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/WrappedPacketInUpdateSign.java index 1e311817..0e07780b 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/WrappedPacketInUpdateSign.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/sign/WrappedPacketInUpdateSign.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.sign; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInUpdateSign extends PacketUpdateSignWrapper { - public WrappedPacketInUpdateSign(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInUpdateSign", - networkProtocolGame + "PacketPlayInUpdateSign" - ) - ); - } + public WrappedPacketInUpdateSign(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInUpdateSign", + networkProtocolGame + "PacketPlayInUpdateSign" + ) + ); + } } From 03aa3755d197b4f572b9821ce3bfd52aca61bda6 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:04:15 +0200 Subject: [PATCH 171/260] Update PacketUpdateTimeWrapper.java --- .../update/time/PacketUpdateTimeWrapper.java | 71 ++++++++++--------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/PacketUpdateTimeWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/PacketUpdateTimeWrapper.java index addae0cc..66201cb7 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/PacketUpdateTimeWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/PacketUpdateTimeWrapper.java @@ -1,44 +1,45 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.time; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketUpdateTimeWrapper extends PacketWrapper { - - Field gameTime; - Field dayTime; - - PacketUpdateTimeWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - gameTime = getFirstField( - "gameTime", - "a" - ); - dayTime = getFirstField( - "dayTime", - "b" - ); - } - - public long getGameTime() { - return getFieldValue(gameTime); - } - - public void setGameTime(long gameTime) { - setField(this.gameTime, gameTime); - } - - public long getDayTime() { - return getFieldValue(dayTime); - } - - public void setDayTime(long dayTime) { - setField(this.dayTime, dayTime); - } + + Field gameTime; + Field dayTime; + + PacketUpdateTimeWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + gameTime = getFirstField( + "gameTime", + "a" + ); + dayTime = getFirstField( + "dayTime", + "b" + ); + } + + public long getGameTime() { + return getFieldValue(gameTime); + } + + public void setGameTime(long gameTime) { + setField(this.gameTime, gameTime); + } + + public long getDayTime() { + return getFieldValue(dayTime); + } + + public void setDayTime(long dayTime) { + setField(this.dayTime, dayTime); + } } From 7857cd7f94be59a46d60a6a5cf5a5424d23ad7a7 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:04:25 +0200 Subject: [PATCH 172/260] Update WrappedPacketOutUpdateTime.java --- .../time/WrappedPacketOutUpdateTime.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/WrappedPacketOutUpdateTime.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/WrappedPacketOutUpdateTime.java index 29b78790..744f6138 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/WrappedPacketOutUpdateTime.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/time/WrappedPacketOutUpdateTime.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.time; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutUpdateTime extends PacketUpdateTimeWrapper { - public WrappedPacketOutUpdateTime(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutUpdateTime", - networkProtocolGame + "PacketPlayOutUpdateTime" - ) - ); - } + public WrappedPacketOutUpdateTime(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutUpdateTime", + networkProtocolGame + "PacketPlayOutUpdateTime" + ) + ); + } } From f1dfb5cc372a985eedb16035a3805b3fce24b48c Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:04:40 +0200 Subject: [PATCH 173/260] Update PacketUpdateWindow.java --- .../update/window/PacketUpdateWindow.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindow.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindow.java index a245c33c..2b838eb3 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindow.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindow.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketUpdateWindow extends PacketWrapper { - - Field containerId; - - PacketUpdateWindow(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } + + Field containerId; + + PacketUpdateWindow(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } } From 0ac83a6fec7db3d55ffe4b6c4fc833817121cd55 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:05:01 +0200 Subject: [PATCH 174/260] Update PacketUpdateWindowData.java --- .../update/window/PacketUpdateWindowData.java | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowData.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowData.java index 79fe70cf..5dd6a3e9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowData.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowData.java @@ -1,43 +1,43 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; -import lombok.NonNull; -import lombok.experimental.FieldDefaults; - import java.lang.reflect.Field; import java.util.Set; +import lombok.NonNull; +import lombok.experimental.FieldDefaults; + @FieldDefaults(makeFinal = true) abstract class PacketUpdateWindowData extends PacketUpdateWindow { - - Field id; - Field value; - - PacketUpdateWindowData(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - id = getFirstField( - "id", - "b" - ); - value = getFirstField( - "value", - "c" - ); - } - - public int getId() { - return getFieldValue(id); - } - - public void setId(int id) { - setField(this.id, id); - } - - public int getValue() { - return getFieldValue(value); - } - - public void setValue(int value) { - setField(this.value, value); - } + + Field id; + Field value; + + PacketUpdateWindowData(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + id = getFirstField( + "id", + "b" + ); + value = getFirstField( + "value", + "c" + ); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public int getValue() { + return getFieldValue(value); + } + + public void setValue(int value) { + setField(this.value, value); + } } From 2df3907d5f4af74534461a3c72d1a323591dc33a Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:05:11 +0200 Subject: [PATCH 175/260] Update PacketUpdateWindowItems.java --- .../wrapper/update/window/PacketUpdateWindowItems.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowItems.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowItems.java index 30a7ab4e..434839f9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowItems.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/PacketUpdateWindowItems.java @@ -1,12 +1,12 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + abstract class PacketUpdateWindowItems extends PacketUpdateWindow { - PacketUpdateWindowItems(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } + PacketUpdateWindowItems(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } } From 872b54453d1f3a8ba24fa057dc3fd6524029df3a Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:05:24 +0200 Subject: [PATCH 176/260] Update WrappedPacketOutWindowData.java --- .../window/WrappedPacketOutWindowData.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowData.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowData.java index 7d43075e..d08c7bba 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowData.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowData.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutWindowData extends PacketUpdateWindowData { - public WrappedPacketOutWindowData(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWindowData", - networkProtocolGame + "PacketPlayOutWindowData" - ) - ); - } + public WrappedPacketOutWindowData(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWindowData", + networkProtocolGame + "PacketPlayOutWindowData" + ) + ); + } } From 05e44f2156e4b732cd3e65b1b41744ddafe92b9d Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:05:34 +0200 Subject: [PATCH 177/260] Update WrappedPacketOutWindowItems.java --- .../window/WrappedPacketOutWindowItems.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowItems.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowItems.java index 9b7eca30..bb3494f9 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowItems.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/update/window/WrappedPacketOutWindowItems.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.update.window; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutWindowItems extends PacketUpdateWindowItems { - public WrappedPacketOutWindowItems(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWindowItems", - networkProtocolGame + "PacketPlayOutWindowItems" - ) - ); - } + public WrappedPacketOutWindowItems(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWindowItems", + networkProtocolGame + "PacketPlayOutWindowItems" + ) + ); + } } From 8d7ec30a78affe21de4ce8efb8b6c54dbbb55ff7 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:05:56 +0200 Subject: [PATCH 178/260] Update PacketUseEntityWrapper.java --- .../wrapper/use/PacketUseEntityWrapper.java | 77 ++++++++++--------- 1 file changed, 39 insertions(+), 38 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/PacketUseEntityWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/PacketUseEntityWrapper.java index 5b7953f1..77527262 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/PacketUseEntityWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/PacketUseEntityWrapper.java @@ -1,47 +1,48 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.use; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketUseEntityWrapper extends PacketWrapper { - - Field entityId; - Field action; - - PacketUseEntityWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - entityId = getFirstField( - "entityId", - "a" - ); - action = getField("action"); - } - - public int getEntityId() { - return getFieldValue(entityId); - } - - public void setEntityId(int entityId) { - setField(this.entityId, entityId); - } - - /** - * @return PacketPlayInUseEntity$EnumEntityUseAction - */ - public Object getAction() { - return getFieldValue(action); - } - - /** - * @param action: PacketPlayInUseEntity$EnumEntityUseAction - */ - public void setAction(Object action) { - setField(this.action, action); - } + + Field entityId; + Field action; + + PacketUseEntityWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + entityId = getFirstField( + "entityId", + "a" + ); + action = getField("action"); + } + + public int getEntityId() { + return getFieldValue(entityId); + } + + public void setEntityId(int entityId) { + setField(this.entityId, entityId); + } + + /** + * @return PacketPlayInUseEntity$EnumEntityUseAction + */ + public Object getAction() { + return getFieldValue(action); + } + + /** + * @param action: PacketPlayInUseEntity$EnumEntityUseAction + */ + public void setAction(Object action) { + setField(this.action, action); + } } From 3043b22625fdbe0809cc57fa1a24b5730e9422b1 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:06:06 +0200 Subject: [PATCH 179/260] Update WrappedPacketInUseEntity.java --- .../wrapper/use/WrappedPacketInUseEntity.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/WrappedPacketInUseEntity.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/WrappedPacketInUseEntity.java index e91583b4..5ab2ceeb 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/WrappedPacketInUseEntity.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/use/WrappedPacketInUseEntity.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.use; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInUseEntity extends PacketUseEntityWrapper { - public WrappedPacketInUseEntity(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInUseEntity", - networkProtocolGame + "PacketPlayInUseEntity" - ) - ); - } + public WrappedPacketInUseEntity(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInUseEntity", + networkProtocolGame + "PacketPlayInUseEntity" + ) + ); + } } From 138266d6b6fad3991d11d6351da5b7187c150ae8 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:06:36 +0200 Subject: [PATCH 180/260] Update PacketWindowClickWrapper.java --- .../click/PacketWindowClickWrapper.java | 113 +++++++++--------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/PacketWindowClickWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/PacketWindowClickWrapper.java index 9c7fa82e..1bd23c06 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/PacketWindowClickWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/PacketWindowClickWrapper.java @@ -1,70 +1,71 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.click; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketWindowClickWrapper extends PacketWrapper { + + Field containerId; + Field slotNum; + Field buttonNum; + Field uid; - Field containerId; - Field slotNum; - Field buttonNum; - Field uid; - - PacketWindowClickWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - slotNum = getFirstField( - "slotNum", - "b" - ); - buttonNum = getFirstField( - "buttonNum", - "c" - ); - uid = getFirstField( - "uid", - "d" - ); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public int getSlotNum() { - return getFieldValue(slotNum); - } - - public void setSlotNum(int slotNum) { - setField(this.slotNum, slotNum); - } + PacketWindowClickWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + slotNum = getFirstField( + "slotNum", + "b" + ); + buttonNum = getFirstField( + "buttonNum", + "c" + ); + uid = getFirstField( + "uid", + "d" + ); + } - public int getButtonNum() { - return getFieldValue(buttonNum); - } + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } - public void setButtonNum(int buttonNum) { - setField(this.buttonNum, buttonNum); - } + public int getSlotNum() { + return getFieldValue(slotNum); + } + + public void setSlotNum(int slotNum) { + setField(this.slotNum, slotNum); + } - public short getUID() { - return getFieldValue(uid); - } + public int getButtonNum() { + return getFieldValue(buttonNum); + } + + public void setButtonNum(int buttonNum) { + setField(this.buttonNum, buttonNum); + } - public void setUID(short uid) { - setField(this.uid, uid); - } + public short getUID() { + return getFieldValue(uid); + } + + public void setUID(short uid) { + setField(this.uid, uid); + } } From a6d97c0c6d7c8c45b07b2c85761a92f8e927c71f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:06:46 +0200 Subject: [PATCH 181/260] Update WrappedPacketInWindowClick.java --- .../click/WrappedPacketInWindowClick.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/WrappedPacketInWindowClick.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/WrappedPacketInWindowClick.java index 14d94b5c..6fcb5e34 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/WrappedPacketInWindowClick.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/click/WrappedPacketInWindowClick.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.click; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketInWindowClick extends PacketWindowClickWrapper { - public WrappedPacketInWindowClick(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayInWindowClick", - networkProtocolGame + "PacketPlayInWindowClick" - ) - ); - } + public WrappedPacketInWindowClick(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayInWindowClick", + networkProtocolGame + "PacketPlayInWindowClick" + ) + ); + } } From 4dc5e598cad0d41c5f45aa28aec117814aef2a63 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:07:13 +0200 Subject: [PATCH 182/260] Update PacketWindowDataWrapper.java --- .../window/data/PacketWindowDataWrapper.java | 97 ++++++++++--------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/PacketWindowDataWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/PacketWindowDataWrapper.java index 4d5bb297..aa7f014f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/PacketWindowDataWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/PacketWindowDataWrapper.java @@ -1,57 +1,58 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.data; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketWindowDataWrapper extends PacketWrapper { - - Field containerId; - Field id; - Field value; - - PacketWindowDataWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - id = getFirstField( - "id", - "b" - ); - value = getFirstField( - "value", - "c" - ); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } - - public int getId() { - return getFieldValue(id); - } - - public void setId(int id) { - setField(this.id, id); - } - - public int getValue() { - return getFieldValue(value); - } - - public void setValue(int value) { - setField(this.value, value); - } + + Field containerId; + Field id; + Field value; + + PacketWindowDataWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + id = getFirstField( + "id", + "b" + ); + value = getFirstField( + "value", + "c" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } + + public int getId() { + return getFieldValue(id); + } + + public void setId(int id) { + setField(this.id, id); + } + + public int getValue() { + return getFieldValue(value); + } + + public void setValue(int value) { + setField(this.value, value); + } } From 52468f57c262e20e9b90a7bc05b40233c816e632 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:07:22 +0200 Subject: [PATCH 183/260] Update WrappedPacketOutWindowData.java --- .../data/WrappedPacketOutWindowData.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/WrappedPacketOutWindowData.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/WrappedPacketOutWindowData.java index dd1f5c89..1d13bc38 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/WrappedPacketOutWindowData.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/data/WrappedPacketOutWindowData.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.data; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutWindowData extends PacketWindowDataWrapper { - public WrappedPacketOutWindowData(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWindowData", - networkProtocolGame + "PacketPlayOutWindowData" - ) - ); - } + public WrappedPacketOutWindowData(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWindowData", + networkProtocolGame + "PacketPlayOutWindowData" + ) + ); + } } From d903c2f46c256f6cc93e3a06005fb72d3a47a8e4 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:07:36 +0200 Subject: [PATCH 184/260] Update PacketWindowItemsWrapper.java --- .../items/PacketWindowItemsWrapper.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/PacketWindowItemsWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/PacketWindowItemsWrapper.java index 405c0330..fc696b14 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/PacketWindowItemsWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/PacketWindowItemsWrapper.java @@ -1,31 +1,32 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.items; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - @FieldDefaults(makeFinal = true) abstract class PacketWindowItemsWrapper extends PacketWrapper { - - Field containerId; - - PacketWindowItemsWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - containerId = getFirstField( - "containerId", - "a" - ); - } - - public int getContainerId() { - return getFieldValue(containerId); - } - - public void setContainerId(int containerId) { - setField(this.containerId, containerId); - } + + Field containerId; + + PacketWindowItemsWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + containerId = getFirstField( + "containerId", + "a" + ); + } + + public int getContainerId() { + return getFieldValue(containerId); + } + + public void setContainerId(int containerId) { + setField(this.containerId, containerId); + } } From 55913a389fac0ac31f2f8e4963be5a6dfda7c71d Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:07:49 +0200 Subject: [PATCH 185/260] Update WrappedPacketOutWindowItems.java --- .../items/WrappedPacketOutWindowItems.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/WrappedPacketOutWindowItems.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/WrappedPacketOutWindowItems.java index c8a99b6c..213cb73a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/WrappedPacketOutWindowItems.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/window/items/WrappedPacketOutWindowItems.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.window.items; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutWindowItems extends PacketWindowItemsWrapper { - public WrappedPacketOutWindowItems(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWindowItems", - networkProtocolGame + "PacketPlayOutWindowItems" - ) - ); - } + public WrappedPacketOutWindowItems(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWindowItems", + networkProtocolGame + "PacketPlayOutWindowItems" + ) + ); + } } From 5659fc8438bccce77b8c189ac644a16df0fcdc27 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:08:25 +0200 Subject: [PATCH 186/260] Update PacketWorldEventWrapper.java --- .../world/event/PacketWorldEventWrapper.java | 125 +++++++++--------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/PacketWorldEventWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/PacketWorldEventWrapper.java index 60df5226..824fd067 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/PacketWorldEventWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/PacketWorldEventWrapper.java @@ -1,77 +1,78 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.world.event; +import java.lang.reflect.Field; +import java.util.Set; + import com.falchus.lib.minecraft.spigot.packets.wrapper.PacketWrapper; + import lombok.NonNull; import lombok.experimental.FieldDefaults; -import java.lang.reflect.Field; -import java.util.Set; - // TODO: add PacketPlayOutWorldParticles wrapper @FieldDefaults(makeFinal = true) abstract class PacketWorldEventWrapper extends PacketWrapper { + + Field type; + Field pos; + Field data; + Field globalEvent; - Field type; - Field pos; - Field data; - Field globalEvent; - - PacketWorldEventWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - - type = getFirstField( - "type", - "a" - ); - pos = getFirstField( - "pos", - "b" - ); - data = getFirstField( - "data", - "c" - ); - globalEvent = getFirstField( - "globalEvent", - "d" - ); - } - - public int getType() { - return getFieldValue(type); - } - - public void setType(int type) { - setField(this.type, type); - } - - /** - * @return BlockPosition - */ - public Object getPos() { - return getFieldValue(type); - } - - /** - * @param pos: BlockPosition - */ - public void setPos(Object pos) { - setField(this.pos, pos); - } + PacketWorldEventWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + + type = getFirstField( + "type", + "a" + ); + pos = getFirstField( + "pos", + "b" + ); + data = getFirstField( + "data", + "c" + ); + globalEvent = getFirstField( + "globalEvent", + "d" + ); + } - public int getData() { - return getFieldValue(data); - } + public int getType() { + return getFieldValue(type); + } + + public void setType(int type) { + setField(this.type, type); + } - public void setData(int data) { - setField(this.data, data); - } + /** + * @return BlockPosition + */ + public Object getPos() { + return getFieldValue(type); + } + + /** + * @param pos: BlockPosition + */ + public void setPos(Object pos) { + setField(this.pos, pos); + } - public boolean isGlobalEvent() { - return getFieldValue(globalEvent); - } + public int getData() { + return getFieldValue(data); + } + + public void setData(int data) { + setField(this.data, data); + } - public void setGlobalEvent(boolean globalEvent) { - setField(this.globalEvent, globalEvent); - } + public boolean isGlobalEvent() { + return getFieldValue(globalEvent); + } + + public void setGlobalEvent(boolean globalEvent) { + setField(this.globalEvent, globalEvent); + } } From c71db3ae09c4d0e9986ad38b80e0fa864277524a Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:08:35 +0200 Subject: [PATCH 187/260] Update WrappedPacketOutWorldEvent.java --- .../event/WrappedPacketOutWorldEvent.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/WrappedPacketOutWorldEvent.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/WrappedPacketOutWorldEvent.java index a6d8a8fc..afaa669a 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/WrappedPacketOutWorldEvent.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/world/event/WrappedPacketOutWorldEvent.java @@ -1,16 +1,16 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper.world.event; -import lombok.NonNull; - import java.util.Set; +import lombok.NonNull; + public class WrappedPacketOutWorldEvent extends PacketWorldEventWrapper { - public WrappedPacketOutWorldEvent(@NonNull Object handle) { - super(handle, Set.of( - version.getPackageNms() + "PacketPlayOutWorldEvent", - networkProtocolGame + "PacketPlayOutWorldEvent" - ) - ); - } + public WrappedPacketOutWorldEvent(@NonNull Object handle) { + super(handle, Set.of( + version.getPackageNms() + "PacketPlayOutWorldEvent", + networkProtocolGame + "PacketPlayOutWorldEvent" + ) + ); + } } From 51dbdbe3b893ba50b63c6c831194209edef73ffb Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:08:52 +0200 Subject: [PATCH 188/260] Update PacketWrapper.java --- .../spigot/packets/wrapper/PacketWrapper.java | 142 +++++++++--------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/PacketWrapper.java b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/PacketWrapper.java index d1c196bc..1dc01e87 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/wrapper/PacketWrapper.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/wrapper/PacketWrapper.java @@ -1,83 +1,83 @@ package com.falchus.lib.minecraft.spigot.packets.wrapper; -import com.falchus.lib.minecraft.spigot.packets.wrapper.chat.WrappedPacketInChat; -import com.falchus.lib.minecraft.spigot.packets.wrapper.chat.WrappedPacketOutChat; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.Function; + +import com.falchus.lib.minecraft.spigot.packets.wrapper.chat.*; import com.falchus.lib.minecraft.spigot.utils.version.IVersionAdapter; import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; import com.falchus.lib.utils.builder.ClassInstanceBuilder; import com.falchus.lib.utils.reflection.Dummy; import com.falchus.lib.utils.wrapper.impl.FirstClassWrapper; -import lombok.NonNull; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.function.Function; +import lombok.NonNull; public class PacketWrapper extends FirstClassWrapper { + + protected static final IVersionAdapter version = VersionProvider.get(); + private static final String networkProtocol = version.getPackageNm() + "network.protocol."; + protected static final String networkProtocolCommon = networkProtocol + "common."; + protected static final String networkProtocolGame = networkProtocol + "game."; - protected static final IVersionAdapter version = VersionProvider.get(); - private static final String networkProtocol = version.getPackageNm() + "network.protocol."; - protected static final String networkProtocolCommon = networkProtocol + "common."; - protected static final String networkProtocolGame = networkProtocol + "game."; - - private static final Map, Function> registry = new HashMap<>(); - - public PacketWrapper(@NonNull Object handle, @NonNull Set names) { - super(handle, names); - } - - @SuppressWarnings("unchecked") - private static void register() { - if (!registry.isEmpty()) return; - Class[] wrappers = new Class[]{ - WrappedPacketInChat.class, - WrappedPacketOutChat.class - }; - - for (Class wrapper : wrappers) { - try { - PacketWrapper dummy = (T) new ClassInstanceBuilder( - wrapper - ).withParams( - Map.of( - Object.class, - Dummy.instance - ) - ).build(); - for (Class clazz : dummy.getClasses()) { - registry.put(clazz, obj -> { - try { - return (T) new ClassInstanceBuilder( - wrapper - ).withParams( - Map.of( - Object.class, - obj - ) - ).build(); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - public static PacketWrapper wrap(Object packet) { - register(); - - Function wrapper = registry.get(packet.getClass()); - if (wrapper != null) { - return wrapper.apply(packet); - } - return new PacketWrapper(packet, Set.of(packet.getClass().getName())); - } - - public T as(@NonNull Class clazz) { - return as(clazz, Object.class); - } + private static final Map, Function> registry = new HashMap<>(); + + public PacketWrapper(@NonNull Object handle, @NonNull Set names) { + super(handle, names); + } + + @SuppressWarnings("unchecked") + private static void register() { + if (!registry.isEmpty()) return; + Class[] wrappers = new Class[] { + WrappedPacketInChat.class, + WrappedPacketOutChat.class + }; + + for (Class wrapper : wrappers) { + try { + PacketWrapper dummy = (T) new ClassInstanceBuilder( + wrapper + ).withParams( + Map.of( + Object.class, + Dummy.instance + ) + ).build(); + for (Class clazz : dummy.getClasses()) { + registry.put(clazz, obj -> { + try { + return (T) new ClassInstanceBuilder( + wrapper + ).withParams( + Map.of( + Object.class, + obj + ) + ).build(); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + public static PacketWrapper wrap(Object packet) { + register(); + + Function wrapper = registry.get(packet.getClass()); + if (wrapper != null) { + return wrapper.apply(packet); + } + return new PacketWrapper(packet, Set.of(packet.getClass().getName())); + } + + public T as(@NonNull Class clazz) { + return as(clazz, Object.class); + } } From 5ffe3088ad774ab96fd60d7fd179ae10ddfb007c Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:09:03 +0200 Subject: [PATCH 189/260] Update PacketChannelHandler.java --- .../minecraft/spigot/packets/PacketChannelHandler.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/PacketChannelHandler.java b/src/com/falchus/lib/minecraft/spigot/packets/PacketChannelHandler.java index 2fdc18c2..f09a276f 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/PacketChannelHandler.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/PacketChannelHandler.java @@ -17,22 +17,22 @@ public class PacketChannelHandler extends ChannelDuplexHandler { private final Player player; - + @Override public void channelRead(ChannelHandlerContext ctx, Object packet) throws Exception { PlayerPacketEvent event = new PlayerPacketInEvent(!Bukkit.isPrimaryThread(), player, PacketWrapper.wrap(packet)); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; - + super.channelRead(ctx, packet); } - + @Override public void write(ChannelHandlerContext ctx, Object packet, ChannelPromise promise) throws Exception { PlayerPacketEvent event = new PlayerPacketOutEvent(!Bukkit.isPrimaryThread(), player, PacketWrapper.wrap(packet)); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; - + super.write(ctx, packet, promise); } } From 13bfc5a340c21072e1d6a6095dddf2874a6d0c43 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:09:17 +0200 Subject: [PATCH 190/260] Update PacketInjector.java --- .../spigot/packets/PacketInjector.java | 102 +++++++++--------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/packets/PacketInjector.java b/src/com/falchus/lib/minecraft/spigot/packets/PacketInjector.java index 9bd9aa73..0a940bb6 100644 --- a/src/com/falchus/lib/minecraft/spigot/packets/PacketInjector.java +++ b/src/com/falchus/lib/minecraft/spigot/packets/PacketInjector.java @@ -1,60 +1,62 @@ package com.falchus.lib.minecraft.spigot.packets; -import com.falchus.lib.FalchusLib; -import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; -import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; -import io.netty.channel.Channel; -import org.bukkit.entity.Player; - import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -public class PacketInjector { - - private static final Set injected = ConcurrentHashMap.newKeySet(); - - public static void inject(Player player) { - UUID uuid = player.getUniqueId(); - if (!injected.add(uuid)) return; - - try { - Object entityPlayer = PlayerUtils.getEntityPlayer(player); - - Object connection = VersionProvider.get().getEntityPlayer_playerConnection().get(entityPlayer); - Object networkManager = VersionProvider.get().getPlayerConnection_networkManager().get(connection); - Object ch = VersionProvider.get().getNetworkManager_channel().get(networkManager); - - Channel channel = (Channel) ch; - if (channel.pipeline().get(FalchusLib.nameFull + "_" + uuid) != null) return; - - channel.pipeline().addBefore("packet_handler", FalchusLib.nameFull + "_" + uuid, new PacketChannelHandler(player)); - } catch (Exception e) { - injected.remove(uuid); - throw new RuntimeException(e); - } - } - - public static void uninject(Player player) { - UUID uuid = player.getUniqueId(); - if (!injected.remove(uuid)) return; - - try { - Object entityPlayer = PlayerUtils.getEntityPlayer(player); +import org.bukkit.entity.Player; - Object connection = VersionProvider.get().getEntityPlayer_playerConnection().get(entityPlayer); - Object networkManager = VersionProvider.get().getPlayerConnection_networkManager().get(connection); - Object ch = VersionProvider.get().getNetworkManager_channel().get(networkManager); +import com.falchus.lib.FalchusLib; +import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; +import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; - Channel channel = (Channel) ch; - if (channel.pipeline().get(FalchusLib.nameFull + "_" + uuid) == null) return; +import io.netty.channel.Channel; - channel.eventLoop().submit(() -> { - channel.pipeline().remove(FalchusLib.nameFull + "_" + uuid); - return null; - }); - } catch (Exception e) { - throw new RuntimeException(e); - } - } +public class PacketInjector { + + private static final Set injected = ConcurrentHashMap.newKeySet(); + + public static void inject(Player player) { + UUID uuid = player.getUniqueId(); + if (!injected.add(uuid)) return; + + try { + Object entityPlayer = PlayerUtils.getEntityPlayer(player); + + Object connection = VersionProvider.get().getEntityPlayer_playerConnection().get(entityPlayer); + Object networkManager = VersionProvider.get().getPlayerConnection_networkManager().get(connection); + Object ch = VersionProvider.get().getNetworkManager_channel().get(networkManager); + + Channel channel = (Channel) ch; + if (channel.pipeline().get(FalchusLib.nameFull + "_" + uuid) != null) return; + + channel.pipeline().addBefore("packet_handler", FalchusLib.nameFull + "_" + uuid, new PacketChannelHandler(player)); + } catch (Exception e) { + injected.remove(uuid); + throw new RuntimeException(e); + } + } + + public static void uninject(Player player) { + UUID uuid = player.getUniqueId(); + if (!injected.remove(uuid)) return; + + try { + Object entityPlayer = PlayerUtils.getEntityPlayer(player); + + Object connection = VersionProvider.get().getEntityPlayer_playerConnection().get(entityPlayer); + Object networkManager = VersionProvider.get().getPlayerConnection_networkManager().get(connection); + Object ch = VersionProvider.get().getNetworkManager_channel().get(networkManager); + + Channel channel = (Channel) ch; + if (channel.pipeline().get(FalchusLib.nameFull + "_" + uuid) == null) return; + + channel.eventLoop().submit(() -> { + channel.pipeline().remove(FalchusLib.nameFull + "_" + uuid); + return null; + }); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } From 9273b48df063a1b0af19f141ffb25d9af3c43281 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:09:30 +0200 Subject: [PATCH 191/260] Update Actionbar.java --- .../player/elements/impl/Actionbar.java | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Actionbar.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Actionbar.java index 8f8d4ed8..938970ed 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Actionbar.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Actionbar.java @@ -1,42 +1,44 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; -import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; -import lombok.NonNull; -import org.bukkit.entity.Player; - import java.util.function.Supplier; -public class Actionbar extends PlayerElement { - - private Supplier messageSupplier; - - private Actionbar(@NonNull Player player) { - super(player); - } - - /** - * Sends a one-time action bar message. - */ - public void send(@NonNull Supplier message) { - messageSupplier = message; +import org.bukkit.entity.Player; - updateRunnable = () -> { - String newMessage = messageSupplier.get(); +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; +import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; - PlayerUtils.sendActionbar(player, newMessage); - }; - update(); - } +import lombok.NonNull; - /** - * Sends an action bar message repeatedly at a fixed interval. - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier message) { - super.sendUpdating(intervalTicks, () -> - send( - message - ) - ); - } +public class Actionbar extends PlayerElement { + + private Supplier messageSupplier; + + private Actionbar(@NonNull Player player) { + super(player); + } + + /** + * Sends a one-time action bar message. + */ + public void send(@NonNull Supplier message) { + messageSupplier = message; + + updateRunnable = () -> { + String newMessage = messageSupplier.get(); + + PlayerUtils.sendActionbar(player, newMessage); + }; + update(); + } + + /** + * Sends an action bar message repeatedly at a fixed interval. + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier message) { + super.sendUpdating(intervalTicks, () -> + send( + message + ) + ); + } } From e138416c4b4bfb152bd3cb5037e931328902c1bb Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:09:42 +0200 Subject: [PATCH 192/260] Update Bossbar.java --- .../spigot/player/elements/impl/Bossbar.java | 118 +++++++++--------- 1 file changed, 60 insertions(+), 58 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Bossbar.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Bossbar.java index 3c573c3d..e706562d 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Bossbar.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Bossbar.java @@ -1,75 +1,77 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; +import java.util.function.Supplier; + +import org.bukkit.entity.Player; + import com.falchus.lib.minecraft.spigot.enums.Version; import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; import com.falchus.lib.minecraft.spigot.utils.ServerUtils; -import lombok.NonNull; -import org.bukkit.entity.Player; -import java.util.function.Supplier; +import lombok.NonNull; public class Bossbar extends PlayerElement { - private Supplier messageSupplier; - private Supplier progressSupplier; - - private Bossbar(@NonNull Player player) { - super(player); + private Supplier messageSupplier; + private Supplier progressSupplier; + + private Bossbar(@NonNull Player player) { + super(player); } - - /** - * Sends a one-time Bossbar message. - */ - public void send(@NonNull Supplier message, @NonNull Supplier progress) { + + /** + * Sends a one-time Bossbar message. + */ + public void send(@NonNull Supplier message, @NonNull Supplier progress) { messageSupplier = message; progressSupplier = progress; - + updateRunnable = () -> { - String newMessage = messageSupplier.get(); - double newProgress = progressSupplier.get(); - - PlayerUtils.sendBossbar(player, newMessage, newProgress); + String newMessage = messageSupplier.get(); + double newProgress = progressSupplier.get(); + + PlayerUtils.sendBossbar(player, newMessage, newProgress); }; update(); - } - - /** - * Sends a Bossbar message repeatedly at a fixed interval. - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier message, @NonNull Supplier progress) { - if (ServerUtils.getVersion().isBefore(Version.v1_17)) { - super.sendUpdating(intervalTicks, () -> - send( - message, - progress - ) - ); - } else { - send( - message, - progress - ); - } - } - - /** - * Removes the Bossbar, cancelling any ongoing update tasks. - */ - @Override - public void remove() { - super.remove(); - - PlayerUtils.removeBossbar(player); - } - - /** - * Sets the health/progress of the Bossbar. - */ - public void setProgress(double progress) { - send( - messageSupplier, - () -> progress - ); - } + } + + /** + * Sends a Bossbar message repeatedly at a fixed interval. + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier message, @NonNull Supplier progress) { + if (ServerUtils.getVersion().isBefore(Version.v1_17)) { + super.sendUpdating(intervalTicks, () -> + send( + message, + progress + ) + ); + } else { + send( + message, + progress + ); + } + } + + /** + * Removes the Bossbar, cancelling any ongoing update tasks. + */ + @Override + public void remove() { + super.remove(); + + PlayerUtils.removeBossbar(player); + } + + /** + * Sets the health/progress of the Bossbar. + */ + public void setProgress(double progress) { + send( + messageSupplier, + () -> progress + ); + } } From b45a6c681634f36f5c9bf882ed812165972f0c6c Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:09:53 +0200 Subject: [PATCH 193/260] Update Chat.java --- .../spigot/player/elements/impl/Chat.java | 208 +++++++----------- 1 file changed, 75 insertions(+), 133 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Chat.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Chat.java index a0e8f091..876dd08a 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Chat.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Chat.java @@ -1,145 +1,87 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; -import io.papermc.paper.event.player.AsyncChatEvent; -import lombok.NonNull; -import net.kyori.adventure.text.Component; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.function.Supplier; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; -import org.jetbrains.annotations.NotNull; - -import java.util.*; -import java.util.function.Consumer; -import java.util.function.Supplier; - -/** - * Sets a custom chat prefix for a player. - *

- * On servers that expose the Paper 26.x {@code AsyncChatEvent}, - * that event is preferred because {@link AsyncPlayerChatEvent} is deprecated there. - * The detection is done at runtime via reflection so the library can still compile - * against plain Spigot. - */ -public class Chat extends PlayerElement implements Listener { - - private static final Map> prefixSuppliers = new HashMap<>(); - private static final Map lastPrefixes = new HashMap<>(); - private static final List registered = new ArrayList<>(); - - /** - * {@code true} when Paper's new {@code AsyncChatEvent} is on the classpath. - */ - private static final boolean USE_PAPER_CHAT_EVENT = detectPaperChatEvent(); - - private Chat(@NonNull Player player) { - super(player); - } - - private static boolean detectPaperChatEvent() { - try { - Class.forName("io.papermc.paper.event.player.AsyncChatEvent"); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } - - /** - * Applies a one-time prefix supplier. - */ - public void send(@NonNull Supplier prefix) { - if (registered.isEmpty()) { - Bukkit.getPluginManager().registerEvents(this, plugin); - registered.add(true); - } - prefixSuppliers.put(player.getUniqueId(), prefix); - - updateRunnable = () -> { - String lastPrefix = lastPrefixes.get(player.getUniqueId()); - String newPrefix = prefixSuppliers.get(player.getUniqueId()).get(); - if (lastPrefix == null || !newPrefix.equals(lastPrefix)) { - lastPrefixes.put(player.getUniqueId(), newPrefix); - } - }; - update(); - } - - /** - * Applies a prefix supplier that refreshes at the given interval (ms). - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier prefix) { - super.sendUpdating(intervalTicks, () -> send(prefix)); - } - - @Override - public void remove() { - super.remove(); - prefixSuppliers.remove(player.getUniqueId()); - lastPrefixes.remove(player.getUniqueId()); - - if (!registered.isEmpty()) { - HandlerList.unregisterAll(this); - registered.clear(); - } - } - - /** - * Legacy handler — active on Spigot / Paper ≤ 25.x. - *

- * On Paper 26.x this event is deprecated but still fires, so the handler - * remains as a fallback; the Paper-native handler below takes precedence - * when {@link #USE_PAPER_CHAT_EVENT} is {@code true}. - */ - @EventHandler(ignoreCancelled = true) - public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { - if (USE_PAPER_CHAT_EVENT) return; // let the Paper handler deal with it - - applyPrefix(event.getPlayer(), prefix -> event.setFormat(prefix + "%2$s")); - } - - /** - * Paper 26.x handler — registered reflectively at runtime so the class - * compiles against plain Spigot without the Paper dependency. - *

- * The method is package-private to allow reflective invocation from the - * {@link PaperChatEventBridge} registered below. - */ - void onPaperAsyncChat(Player player, AsyncChatEvent event) { - applyPrefix(player, prefix -> - event.renderer((source, displayName, message, viewer) -> - Component.text(prefix) - .append(message) - ) - ); - } - - private void applyPrefix(@NonNull @NotNull Player player, @NonNull Consumer apply) { - Supplier supplier = prefixSuppliers.get(player.getUniqueId()); - if (supplier == null) return; - apply.accept(supplier.get()); - } - - /** - * Separate listener class registered only when Paper's {@code AsyncChatEvent} - * is present. Keeping it in a nested class avoids a {@link NoClassDefFoundError} - * on plain Spigot where the Paper event class does not exist. - */ - public static class PaperChatEventBridge implements Listener { +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; - private final Chat chat; +import lombok.NonNull; - public PaperChatEventBridge(@NonNull Chat chat) { - this.chat = chat; - } +public class Chat extends PlayerElement implements Listener { - @EventHandler(ignoreCancelled = true) - public void onAsyncChat(AsyncChatEvent event) { - chat.onPaperAsyncChat(event.getPlayer(), event); - } - } -} \ No newline at end of file + private static final Map> prefixSuppliers = new HashMap<>(); + private static final Map lastPrefixes = new HashMap<>(); + + private static final List registered = new ArrayList<>(); + + private Chat(@NonNull Player player) { + super(player); + } + + /** + * Sets one-time. + */ + public void send(@NonNull Supplier prefix) { + if (registered.size() == 0) { + Bukkit.getPluginManager().registerEvents(this, plugin); + registered.add(true); + } + + prefixSuppliers.put(player.getUniqueId(), prefix); + + updateRunnable = () -> { + String lastPrefix = lastPrefixes.get(player.getUniqueId()); + String newPrefix = prefixSuppliers.get(player.getUniqueId()).get(); + + if (lastPrefix == null || !newPrefix.equals(lastPrefix)) { + lastPrefixes.put(player.getUniqueId(), newPrefix); + } + }; + update(); + } + + /** + * Updates periodically. + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier prefix) { + super.sendUpdating(intervalTicks, () -> + send( + prefix + ) + ); + } + + /** + * Removes the chat element. + */ + public void remove() { + super.remove(); + + prefixSuppliers.remove(player.getUniqueId()); + lastPrefixes.remove(player.getUniqueId()); + + if (registered.size() == 1 && registered.getFirst() == true) { + HandlerList.unregisterAll(this); + registered.clear(); + } + } + + @EventHandler(ignoreCancelled = true) + public void onAsyncPlayerChat(AsyncPlayerChatEvent event) { + String prefix = prefixSuppliers.get(event.getPlayer().getUniqueId()).get(); + if (prefix == null) return; + + event.setFormat(prefix + "%2$s"); + } +} From 339ad123d83607ed3bf7ca12ca08201488685de3 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:10:05 +0200 Subject: [PATCH 194/260] Update Nametag.java --- .../spigot/player/elements/impl/Nametag.java | 92 ++++++++++--------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Nametag.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Nametag.java index 93c3dd3a..2affb2f4 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Nametag.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Nametag.java @@ -1,52 +1,54 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; -import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; -import lombok.NonNull; -import org.bukkit.entity.Player; - import java.util.function.Supplier; -public class Nametag extends PlayerElement { - - private Supplier prefixSupplier; - private Supplier suffixSupplier; - - private Nametag(@NonNull Player player) { - super(player); - } - - /** - * Sets a one-time prefix and suffix. - */ - public void send(@NonNull Supplier prefix, @NonNull Supplier suffix) { - prefixSupplier = prefix; - suffixSupplier = suffix; - - updateRunnable = () -> { - String newPrefix = prefixSupplier.get(); - String newSuffix = suffixSupplier.get(); - - PlayerUtils.sendNametag(player, newPrefix, newSuffix); - }; - update(); - } +import org.bukkit.entity.Player; - /** - * Updates prefix and suffiy periodically. - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier prefix, @NonNull Supplier suffix) { - super.sendUpdating(intervalTicks, () -> - send( - prefix, - suffix - ) - ); - } +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; +import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; - public void remove() { - super.remove(); +import lombok.NonNull; - PlayerUtils.removeNametag(player); - } -} \ No newline at end of file +public class Nametag extends PlayerElement { + + private Supplier prefixSupplier; + private Supplier suffixSupplier; + + private Nametag(@NonNull Player player) { + super(player); + } + + /** + * Sets a one-time prefix and suffix. + */ + public void send(@NonNull Supplier prefix, @NonNull Supplier suffix) { + prefixSupplier = prefix; + suffixSupplier = suffix; + + updateRunnable = () -> { + String newPrefix = prefixSupplier.get(); + String newSuffix = suffixSupplier.get(); + + PlayerUtils.sendNametag(player, newPrefix, newSuffix); + }; + update(); + } + + /** + * Updates prefix and suffiy periodically. + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier prefix, @NonNull Supplier suffix) { + super.sendUpdating(intervalTicks, () -> + send( + prefix, + suffix + ) + ); + } + + public void remove() { + super.remove(); + + PlayerUtils.removeNametag(player); + } +} From 5558ac707ef45f09f19a47f8f9020b87e722e5a1 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:10:16 +0200 Subject: [PATCH 195/260] Update Scoreboard.java --- .../player/elements/impl/Scoreboard.java | 255 +++++++++--------- 1 file changed, 129 insertions(+), 126 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Scoreboard.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Scoreboard.java index cc34a81d..bd5da84e 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Scoreboard.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Scoreboard.java @@ -1,8 +1,8 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import com.falchus.lib.FalchusLib; -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; -import lombok.NonNull; +import java.util.List; +import java.util.function.Supplier; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -10,156 +10,159 @@ import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.Team; -import java.util.List; -import java.util.function.Supplier; +import com.falchus.lib.FalchusLib; +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; + +import lombok.NonNull; public class Scoreboard extends PlayerElement { - public final org.bukkit.scoreboard.Scoreboard scoreboard; - private final Objective objective; - private Supplier> linesSupplier; - private List lastLines; + private Supplier> linesSupplier; + private List lastLines; + + public final org.bukkit.scoreboard.Scoreboard scoreboard; + private final Objective objective; private int frame = 0; - - private Scoreboard(@NonNull Player player) { - super(player); - org.bukkit.scoreboard.Scoreboard scoreboard = player.getScoreboard(); - if (scoreboard == null || scoreboard == Bukkit.getScoreboardManager().getMainScoreboard()) { - scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); - } - + + private Scoreboard(@NonNull Player player) { + super(player); + org.bukkit.scoreboard.Scoreboard scoreboard = player.getScoreboard(); + if (scoreboard == null || scoreboard == Bukkit.getScoreboardManager().getMainScoreboard()) { + scoreboard = Bukkit.getScoreboardManager().getNewScoreboard(); + } + Objective objective = scoreboard.getObjective(FalchusLib.nameFull); if (objective == null) { - objective = scoreboard.registerNewObjective(FalchusLib.nameFull, "dummy"); + objective = scoreboard.registerNewObjective(FalchusLib.nameFull, "dummy"); } objective.setDisplaySlot(DisplaySlot.SIDEBAR); - + player.setScoreboard(scoreboard); - - this.scoreboard = scoreboard; + + this.scoreboard = scoreboard; this.objective = objective; - } - - /** - * Updates the scoreboard immediately. - */ - public void send(@NonNull Supplier> lines) { - linesSupplier = lines; - - updateRunnable = () -> { - List newLines = linesSupplier.get(); - - if (lastLines == null || lastLines.size() != newLines.size()) { - for (Team team : scoreboard.getTeams()) { - team.unregister(); - } - for (String entry : scoreboard.getEntries()) { - scoreboard.resetScores(entry); - } - } - lastLines = newLines; - - int score = newLines.size(); - for (String line : newLines) { - if (line.isEmpty()) { - line = "§r"; - } else if (line.length() > 32) { - line = line.substring(0, 32); - } - - String teamName = getClass().getSimpleName() + "_" + score; - Team team = scoreboard.getTeam(teamName); - if (team == null) { - team = scoreboard.registerNewTeam(teamName); - } - - String entry = "§" + Integer.toHexString(score); - if (!team.hasEntry(entry)) { - team.addEntry(entry); - } - - int maxLength = 16; - String prefix = line; - String suffix = ""; - if (prefix.length() > 16) { - int index = line.charAt(maxLength - 1) == ChatColor.COLOR_CHAR - ? (maxLength - 1) : maxLength; - prefix = line.substring(0, index); - String suffixTmp = line.substring(index); - ChatColor chatColor = null; - - if (suffixTmp.length() >= 2 && suffixTmp.charAt(0) == ChatColor.COLOR_CHAR) { - chatColor = ChatColor.getByChar(suffixTmp.charAt(1)); - } - - String color = ChatColor.getLastColors(prefix); - boolean addColor = chatColor == null || chatColor.isFormat(); - suffix = (addColor ? (color.isEmpty() ? ChatColor.RESET.toString() : color) : "") + suffixTmp; - } - team.setPrefix(prefix); - team.setSuffix(suffix); - - objective.getScore(entry).setScore(score); - score--; - } - }; - update(); - } - - /** - * Updates the scoreboard periodically with dynamic content. - */ - public void sendUpdating(long intervalTicks, @NonNull Supplier title, @NonNull Supplier titleColor, Supplier titleSecondColor, @NonNull Supplier> lines) { - super.sendUpdating(intervalTicks, () -> - send( - lines - ) - ); - } - - public void remove() { - super.remove(); - - player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()); - } - - /** - * Sets the title of the Scoreboard. - */ - public void setTitle(@NonNull String title, @NonNull String titleColor, String titleSecondColor) { - objective.setDisplayName(getTitle(title, titleColor, titleSecondColor)); - } - + } + + /** + * Updates the scoreboard immediately. + */ + public void send(@NonNull Supplier> lines) { + linesSupplier = lines; + + updateRunnable = () -> { + List newLines = linesSupplier.get(); + + if (lastLines == null || lastLines.size() != newLines.size()) { + for (Team team : scoreboard.getTeams()) { + team.unregister(); + } + for (String entry : scoreboard.getEntries()) { + scoreboard.resetScores(entry); + } + } + lastLines = newLines; + + int score = newLines.size(); + for (String line : newLines) { + if (line.isEmpty()) { + line = "§r"; + } else if (line.length() > 32) { + line = line.substring(0, 32); + } + + String teamName = getClass().getSimpleName() + "_" + score; + Team team = scoreboard.getTeam(teamName); + if (team == null) { + team = scoreboard.registerNewTeam(teamName); + } + + String entry = "§" + Integer.toHexString(score); + if (!team.hasEntry(entry)) { + team.addEntry(entry); + } + + int maxLength = 16; + String prefix = line; + String suffix = ""; + if (prefix.length() > 16) { + int index = line.charAt(maxLength - 1) == ChatColor.COLOR_CHAR + ? (maxLength - 1) : maxLength; + prefix = line.substring(0, index); + String suffixTmp = line.substring(index); + ChatColor chatColor = null; + + if (suffixTmp.length() >= 2 && suffixTmp.charAt(0) == ChatColor.COLOR_CHAR) { + chatColor = ChatColor.getByChar(suffixTmp.charAt(1)); + } + + String color = ChatColor.getLastColors(prefix); + boolean addColor = chatColor == null || chatColor.isFormat(); + suffix = (addColor ? (color.isEmpty() ? ChatColor.RESET.toString() : color) : "") + suffixTmp; + } + team.setPrefix(prefix); + team.setSuffix(suffix); + + objective.getScore(entry).setScore(score); + score--; + } + }; + update(); + } + + /** + * Updates the scoreboard periodically with dynamic content. + */ + public void sendUpdating(long intervalTicks, @NonNull Supplier title, @NonNull Supplier titleColor, Supplier titleSecondColor, @NonNull Supplier> lines) { + super.sendUpdating(intervalTicks, () -> + send( + lines + ) + ); + } + + public void remove() { + super.remove(); + + player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()); + } + + /** + * Sets the title of the Scoreboard. + */ + public void setTitle(@NonNull String title, @NonNull String titleColor, String titleSecondColor) { + objective.setDisplayName(getTitle(title, titleColor, titleSecondColor)); + } + private String getTitle(@NonNull String title, @NonNull String titleColor, String titleSecondColor) { - title = ChatColor.stripColor(title); - if (title.isEmpty()) return ""; - + title = ChatColor.stripColor(title); + if (title.isEmpty()) return ""; + if (titleSecondColor == null) return titleColor + title; int length = title.length(); int cycleLength = length * 2; int pos = frame % length; - + StringBuilder sb = new StringBuilder(); if (frame < length) { sb.append(titleSecondColor) - .append(title.substring(0, pos + 1)) - .append(titleColor) - .append(title.substring(pos + 1)); + .append(title.substring(0, pos + 1)) + .append(titleColor) + .append(title.substring(pos + 1)); } else { sb.append(titleColor) - .append(title.substring(0, pos + 1)) - .append(titleSecondColor) - .append(title.substring(pos + 1)); + .append(title.substring(0, pos + 1)) + .append(titleSecondColor) + .append(title.substring(pos + 1)); } frame = (frame + 1) % cycleLength; title = sb.toString(); - if (title.length() > 32) { - title = title.substring(0, 32); - } + if (title.length() > 32) { + title = title.substring(0, 32); + } return title; } } From 8d35b9895d2cd29f39fea7892b14bbaca6c73c36 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:10:28 +0200 Subject: [PATCH 196/260] Update Tablist.java --- .../spigot/player/elements/impl/Tablist.java | 98 ++++++++++--------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Tablist.java b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Tablist.java index 4ec57e68..0b974530 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Tablist.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/impl/Tablist.java @@ -1,57 +1,59 @@ package com.falchus.lib.minecraft.spigot.player.elements.impl; -import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; -import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; -import lombok.NonNull; -import org.bukkit.entity.Player; - import java.util.List; import java.util.function.Supplier; -public class Tablist extends PlayerElement { - - private Supplier> headerSupplier; - private Supplier> footerSupplier; - private Supplier nameSupplier; - - private Tablist(@NonNull Player player) { - super(player); - } - - /** - * Sends a custom header and footer. - */ - public void send(Supplier> header, Supplier> footer, Supplier name) { - headerSupplier = header; - footerSupplier = footer; - nameSupplier = name; - - updateRunnable = () -> { - List newHeader = headerSupplier != null ? headerSupplier.get() : null; - List newFooter = footerSupplier != null ? footerSupplier.get() : null; - String newName = nameSupplier != null ? nameSupplier.get() : null; - - PlayerUtils.sendTablist(player, newHeader, newFooter, newName); - }; - update(); - } +import org.bukkit.entity.Player; - /** - * Updates the tablist periodically with dynamic content. - */ - public void sendUpdating(long intervalTicks, Supplier> header, Supplier> footer, Supplier name) { - super.sendUpdating(intervalTicks, () -> - send( - header, - footer, - name - ) - ); - } +import com.falchus.lib.minecraft.spigot.player.elements.PlayerElement; +import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; - public void remove() { - super.remove(); +import lombok.NonNull; - send(null, null, null); - } +public class Tablist extends PlayerElement { + + private Supplier> headerSupplier; + private Supplier> footerSupplier; + private Supplier nameSupplier; + + private Tablist(@NonNull Player player) { + super(player); + } + + /** + * Sends a custom header and footer. + */ + public void send(Supplier> header, Supplier> footer, Supplier name) { + headerSupplier = header; + footerSupplier = footer; + nameSupplier = name; + + updateRunnable = () -> { + List newHeader = headerSupplier != null ? headerSupplier.get() : null; + List newFooter = footerSupplier != null ? footerSupplier.get() : null; + String newName = nameSupplier != null ? nameSupplier.get() : null; + + PlayerUtils.sendTablist(player, newHeader, newFooter, newName); + }; + update(); + } + + /** + * Updates the tablist periodically with dynamic content. + */ + public void sendUpdating(long intervalTicks, Supplier> header, Supplier> footer, Supplier name) { + super.sendUpdating(intervalTicks, () -> + send( + header, + footer, + name + ) + ); + } + + public void remove() { + super.remove(); + + send(null, null, null); + } } From 982f0e7daadc2634cebe79d6d17f4a4c08b46ec3 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:10:51 +0200 Subject: [PATCH 197/260] Update PlayerElement.java --- .../spigot/player/elements/PlayerElement.java | 198 +++++++++--------- 1 file changed, 101 insertions(+), 97 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/player/elements/PlayerElement.java b/src/com/falchus/lib/minecraft/spigot/player/elements/PlayerElement.java index 4fa4f7aa..477b67e6 100644 --- a/src/com/falchus/lib/minecraft/spigot/player/elements/PlayerElement.java +++ b/src/com/falchus/lib/minecraft/spigot/player/elements/PlayerElement.java @@ -1,16 +1,18 @@ package com.falchus.lib.minecraft.spigot.player.elements; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; + +import org.bukkit.entity.Player; + import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.falchus.lib.task.Task; import com.falchus.lib.utils.builder.ClassInstanceBuilder; + import lombok.NonNull; import lombok.RequiredArgsConstructor; -import org.bukkit.entity.Player; - -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; /** * Abstract base class for player-related elements. @@ -18,98 +20,100 @@ @RequiredArgsConstructor public abstract class PlayerElement { + protected final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + protected final Player player; + private static final Map, Map> instances = new ConcurrentHashMap<>(); private static final Map, Map> tasks = new ConcurrentHashMap<>(); - protected final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - protected final Player player; + protected Runnable updateRunnable; - - /** - * Updates all online players manually. - */ - public static void updateAll(@NonNull Class clazz) { - Map map = instances.get(clazz); - if (map == null) return; - - map.values().forEach(PlayerElement::update); - } - - /** - * Retrieves a singleton instance of a PlayerElement subclass for a given player. - * If it does not exist, it is created via reflection using a constructor that accepts a Player parameter. - */ - @SuppressWarnings("unchecked") - public static T get(@NonNull Class clazz, @NonNull Player player) { - if (!PlayerElement.class.isAssignableFrom(clazz)) return null; - Map map = instances.computeIfAbsent(clazz, c -> new ConcurrentHashMap<>()); - - return (T) map.computeIfAbsent(player.getUniqueId(), uuid -> { - try { - return (T) new ClassInstanceBuilder(clazz) - .withParams( - Map.of( - Player.class, - player - ) - ) - .build(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - }); - } - - /** - * Updates the element manually. - */ - public void update() { - if (updateRunnable == null) return; - - if (!player.isOnline()) { - remove(); - return; - } - updateRunnable.run(); - } - - /** - * Sends the element to the player repeatedly with a fixed interval (in {@link TimeUnit#MILLISECONDS}). - */ - public void sendUpdating(long intervalTicks, @NonNull Runnable runnable) { - Map map = tasks.computeIfAbsent(getClass(), c -> new ConcurrentHashMap<>()); - - Task oldTask = map.get(player.getUniqueId()); - if (oldTask != null) { - remove(); - } - - Task task = Task.runTaskTimer(() -> { - if (!player.isOnline()) { - remove(); - return; - } - runnable.run(); - }, intervalTicks, TimeUnit.MILLISECONDS); - - map.put(player.getUniqueId(), task); - } - - /** - * Removes this element and cancels any schedules repeating tasks. - */ - public void remove() { - Map map = tasks.get(getClass()); - if (map != null) { - Task task = map.remove(player.getUniqueId()); - if (task != null) { - task.end(); - } - } - - Map instance = instances.get(getClass()); - if (instance != null) { - instance.remove(player.getUniqueId()); - } - } + + /** + * Updates the element manually. + */ + public void update() { + if (updateRunnable == null) return; + + if (!player.isOnline()) { + remove(); + return; + } + updateRunnable.run(); + } + + /** + * Updates all online players manually. + */ + public static void updateAll(@NonNull Class clazz) { + Map map = instances.get(clazz); + if (map == null) return; + + map.values().forEach(PlayerElement::update); + } + + /** + * Sends the element to the player repeatedly with a fixed interval (in {@link TimeUnit#MILLISECONDS}). + */ + public void sendUpdating(long intervalTicks, @NonNull Runnable runnable) { + Map map = tasks.computeIfAbsent(getClass(), c -> new ConcurrentHashMap<>()); + + Task oldTask = map.get(player.getUniqueId()); + if (oldTask != null) { + remove(); + } + + Task task = Task.runTaskTimer(() -> { + if (!player.isOnline()) { + remove(); + return; + } + runnable.run(); + }, intervalTicks, TimeUnit.MILLISECONDS); + + map.put(player.getUniqueId(), task); + } + + /** + * Removes this element and cancels any schedules repeating tasks. + */ + public void remove() { + Map map = tasks.get(getClass()); + if (map != null) { + Task task = map.remove(player.getUniqueId()); + if (task != null) { + task.end(); + } + } + + Map instance = instances.get(getClass()); + if (instance != null) { + instance.remove(player.getUniqueId()); + } + } + + /** + * Retrieves a singleton instance of a PlayerElement subclass for a given player. + * If it does not exist, it is created via reflection using a constructor that accepts a Player parameter. + */ + @SuppressWarnings("unchecked") + public static T get(@NonNull Class clazz, @NonNull Player player) { + if (!PlayerElement.class.isAssignableFrom(clazz)) return null; + Map map = instances.computeIfAbsent(clazz, c -> new ConcurrentHashMap<>()); + + return (T) map.computeIfAbsent(player.getUniqueId(), uuid -> { + try { + return (T) new ClassInstanceBuilder(clazz) + .withParams( + Map.of( + Player.class, + player + ) + ) + .build(); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + }); + } } From 6c4814980191727658c96f65c28a024ebd32a027 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:11:27 +0200 Subject: [PATCH 198/260] Update EntityPlayerBuilder.java --- .../utils/builder/EntityPlayerBuilder.java | 338 +++++++++--------- 1 file changed, 167 insertions(+), 171 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/builder/EntityPlayerBuilder.java b/src/com/falchus/lib/minecraft/spigot/utils/builder/EntityPlayerBuilder.java index 47d004aa..700f2c4f 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/builder/EntityPlayerBuilder.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/builder/EntityPlayerBuilder.java @@ -1,8 +1,17 @@ package com.falchus.lib.minecraft.spigot.utils.builder; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.falchus.lib.minecraft.spigot.utils.EntityUtils; -import com.falchus.lib.minecraft.spigot.utils.SchedulerUtils; import com.falchus.lib.minecraft.spigot.utils.ServerUtils; import com.falchus.lib.minecraft.spigot.utils.WorldUtils; import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; @@ -10,178 +19,165 @@ import com.falchus.lib.utils.builder.ClassInstanceBuilder; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; + import lombok.Getter; import lombok.NonNull; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; @Getter public class EntityPlayerBuilder { - - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - private String name = ""; - private UUID uuid = UUID.randomUUID(); - private String skinValue; - private String skinSignature; - private boolean invisible = false; - private Location location; - private boolean lookAtPlayer = false; - - public EntityPlayerBuilder setName(@NonNull String name) { - this.name = name; - return this; - } - - public EntityPlayerBuilder setUUID(@NonNull UUID uuid) { - this.uuid = uuid; - return this; - } - - public EntityPlayerBuilder setSkin(@NonNull String skinValue, @NonNull String skinSignature) { - this.skinValue = skinValue; - this.skinSignature = skinSignature; - return this; - } - - public EntityPlayerBuilder setInvisible(boolean invisible) { - this.invisible = invisible; - return this; - } - - public EntityPlayerBuilder setLocation(@NonNull Location location) { - this.location = location; - return this; - } - - /** - * Registers a callback to be executed when a player interacts with this EntityPlayer. - */ - public EntityPlayerBuilder withInteractListener(@NonNull Consumer onPlayerInteract) { - plugin.getEntityPlayerListener().actions.put(uuid, onPlayerInteract); - return this; - } - - /** - * Makes the EntityPlayer continuously face the nearest player. - *

- * On Folia the per-tick update runs through the entity's own region scheduler - * (via {@link SchedulerUtils#runTaskForEntity}) so it is always on the correct - * thread. On plain Bukkit/Spigot the same code path falls back to the main thread. - */ - public EntityPlayerBuilder lookAtPlayer(boolean lookAtPlayer) { - this.lookAtPlayer = lookAtPlayer; - return this; - } - - /** - * Builds and returns the final EntityPlayer NMS object. - */ - public Object build() { - try { - Object server = ServerUtils.getMcServer(); - Object world = WorldUtils.getWorldServer( - location != null ? location.getWorld() : Bukkit.getWorlds().get(0) - ); - - GameProfile profile = new GameProfile(uuid, name); - if (skinValue != null && skinSignature != null) { - profile.getProperties().put("textures", new Property("textures", skinValue, skinSignature)); - } - - Object playerInteractManager = new ClassInstanceBuilder( - VersionProvider.get().getPlayerInteractManager() - ).withParams( - Map.of(VersionProvider.get().getWorld(), world) - ).build(); - - Object entityPlayer = new ClassInstanceBuilder( - VersionProvider.get().getEntityPlayer() - ).withParams( - Map.of(VersionProvider.get().getMinecraftServer(), server), - Map.of(VersionProvider.get().getWorldServer(), world), - Map.of(GameProfile.class, profile), - Map.of(VersionProvider.get().getPlayerInteractManager(), playerInteractManager) - ).build(); - - if (location != null) { - VersionProvider.get().getEntity_setLocation().invoke(entityPlayer, - location.getX(), location.getY(), location.getZ(), - location.getYaw(), location.getPitch() - ); - } - VersionProvider.get().getEntity_setInvisible().invoke(entityPlayer, invisible); - - plugin.getEntityPlayerListener().players.put(uuid, entityPlayer); - - if (lookAtPlayer) { - scheduleLookAtPlayer(entityPlayer); - } - - return entityPlayer; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * Schedules a repeating task that rotates the EntityPlayer toward the nearest - * online player. - *

- * The task itself runs on {@link Task}'s own {@link java.util.concurrent.ScheduledExecutorService}, - * which is off the main/region thread. All world reads inside the task - * ({@code entity.getLocation()}, {@code entity.getWorld().getPlayers()}) are - * performed within a {@link SchedulerUtils#runTaskForEntity} call, so they land - * on the entity's owning region thread on Folia — or the main thread on Bukkit. - * The actual yaw/pitch write ({@link EntityUtils#setYawPitch}) is done inside - * that same callback, keeping everything thread-safe. - */ - private void scheduleLookAtPlayer(Object entityPlayer) { - new Task() { - @Override - public void onRun(int tick) { - Entity entity = EntityUtils.getBukkitEntity(entityPlayer); - if (entity == null || !entity.isValid()) { - end(); - return; - } - - SchedulerUtils.runTaskForEntity(entity, () -> { - if (!entity.isValid()) return; - - Player nearest = null; - double nearestDist = Double.MAX_VALUE; - - for (Player player : entity.getWorld().getPlayers()) { - double dist = player.getLocation().distanceSquared(entity.getLocation()); - if (dist < nearestDist) { - nearestDist = dist; - nearest = player; - } - } - - if (nearest == null) return; - - Location from = entity.getLocation().add(0, 1.6, 0); - Location to = nearest.getLocation().add(0, 1.6, 0); - - double dx = to.getX() - from.getX(); - double dy = to.getY() - from.getY(); - double dz = to.getZ() - from.getZ(); - double distXZ = Math.sqrt(dx * dx + dz * dz); - - float yaw = (float) Math.toDegrees(Math.atan2(-dx, dz)); - float pitch = (float) -Math.toDegrees(Math.atan2(dy, distXZ)); - EntityUtils.setYawPitch(entityPlayer, yaw, pitch); - }); - } - }.runTaskTimer(100, TimeUnit.MILLISECONDS); - } -} \ No newline at end of file + + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + private String name = ""; + private UUID uuid = UUID.randomUUID(); + private String skinValue; + private String skinSignature; + private boolean invisible = false; + private Location location; + private boolean lookAtPlayer = false; + + public EntityPlayerBuilder setName(@NonNull String name) { + this.name = name; + return this; + } + + public EntityPlayerBuilder setUUID(@NonNull UUID uuid) { + this.uuid = uuid; + return this; + } + + public EntityPlayerBuilder setSkin(@NonNull String skinValue, @NonNull String skinSignature) { + this.skinValue = skinValue; + this.skinSignature = skinSignature; + return this; + } + + public EntityPlayerBuilder setInvisible(boolean invisible) { + this.invisible = invisible; + return this; + } + + public EntityPlayerBuilder setLocation(@NonNull Location location) { + this.location = location; + return this; + } + + /** + * Registers a callback to be executed when a player interacts with this EntityPlayer. + */ + public EntityPlayerBuilder withInteractListener(@NonNull Consumer onPlayerInteract) { + plugin.getEntityPlayerListener().actions.put(uuid, onPlayerInteract); + return this; + } + + /** + * Makes the EntityPlayer look at the player. + */ + public EntityPlayerBuilder lookAtPlayer(boolean lookAtPlayer) { + this.lookAtPlayer = lookAtPlayer; + return this; + } + + /** + * Builds and returns the final EntityPlayer. + */ + public Object build() { + try { + Object server = ServerUtils.getMcServer(); + + Object world = WorldUtils.getWorldServer(location != null ? location.getWorld() : Bukkit.getWorlds().get(0)); + + GameProfile profile = new GameProfile(uuid, name); + if (skinValue != null && skinSignature != null) { + profile.getProperties().put("textures", new Property("textures", skinValue, skinSignature)); + } + + Object playerInteractManager = new ClassInstanceBuilder( + VersionProvider.get().getPlayerInteractManager() + ).withParams( + Map.of( + VersionProvider.get().getWorld(), + world + ) + ).build(); + + Object entityPlayer = new ClassInstanceBuilder( + VersionProvider.get().getEntityPlayer() + ).withParams( + Map.of( + VersionProvider.get().getMinecraftServer(), + server + ), + Map.of( + VersionProvider.get().getWorldServer(), + world + ), + Map.of( + GameProfile.class, + profile + ), + Map.of( + VersionProvider.get().getPlayerInteractManager(), + playerInteractManager + ) + ).build(); + + if (location != null) { + VersionProvider.get().getEntity_setLocation().invoke(entityPlayer, + location.getX(), + location.getY(), + location.getZ(), + location.getYaw(), + location.getPitch() + ); + } + VersionProvider.get().getEntity_setInvisible().invoke(entityPlayer, + invisible + ); + + plugin.getEntityPlayerListener().players.put(uuid, entityPlayer); + + if (lookAtPlayer) { + new Task() { + @Override + public void onRun(int tick) { + Entity entity = EntityUtils.getBukkitEntity(entityPlayer); + if (entity == null || !entity.isValid()) { + end(); + return; + } + + Player nearest = null; + double nearestDist = Double.MAX_VALUE; + + for (Player player : entity.getWorld().getPlayers()) { + double dist = player.getLocation().distanceSquared(entity.getLocation()); + if (dist < nearestDist) { + nearestDist = dist; + nearest = player; + } + } + + if (nearest != null) { + Location from = entity.getLocation().add(0, 1.6, 0); + Location to = nearest.getLocation().add(0, 1.6, 0); + + double dx = to.getX() - from.getX(); + double dy = to.getY() - from.getY(); + double dz = to.getZ() - from.getZ(); + + double distanceXZ = Math.sqrt(dx * dx + dz * dz); + + float yaw = (float) Math.toDegrees(Math.atan2(-dx, dz)); + float pitch = (float) -Math.toDegrees(Math.atan2(dy, distanceXZ)); + EntityUtils.setYawPitch(entityPlayer, yaw, pitch); + } + } + }.runTaskTimer(100, TimeUnit.MILLISECONDS); + } + return entityPlayer; + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} From 4b41db482e655aea092d1bc8ff368129c9998f89 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:11:40 +0200 Subject: [PATCH 199/260] Update GameProfileBuilder.java --- .../spigot/utils/builder/GameProfileBuilder.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/builder/GameProfileBuilder.java b/src/com/falchus/lib/minecraft/spigot/utils/builder/GameProfileBuilder.java index b16ae450..39c65fb7 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/builder/GameProfileBuilder.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/builder/GameProfileBuilder.java @@ -6,7 +6,9 @@ import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; import com.mojang.util.UUIDTypeAdapter; + import lombok.AllArgsConstructor; + import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; import java.lang.reflect.Type; @@ -53,10 +55,10 @@ public static GameProfile fetch(UUID uuid, boolean forceNew) { if (!forceNew && cache.containsKey(uuid) && cache.get(uuid).isValid()) { return cache.get(uuid).profile; } - + String json = HTTPRequest.get(String.format(url, UUIDTypeAdapter.fromUUID(uuid))); if (json == null) return null; - + GameProfile result = gson.fromJson(json, GameProfile.class); cache.put(uuid, new CachedProfile(result)); return result; @@ -95,7 +97,7 @@ public static GameProfile getProfile(UUID uuid, String name, String skinUrl, Str args.add(name); args.add(skinUrl); if (cape) { - args.add(capeUrl); + args.add(capeUrl); } profile.getProperties().put("textures", new Property("textures", Base64Coder.encodeString(String.format(cape ? jsonCape : jsonSkin, args.toArray(new Object[0]))))); @@ -153,4 +155,4 @@ public boolean isValid() { return cacheTime < 0 || (System.currentTimeMillis() - timestamp) < cacheTime; } } -} \ No newline at end of file +} From c0a5254b9acaa2507faea2390b01a46d1273f505 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:12:00 +0200 Subject: [PATCH 200/260] Update InventoryBuilder.java --- .../utils/builder/InventoryBuilder.java | 192 +++++++++--------- 1 file changed, 97 insertions(+), 95 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/builder/InventoryBuilder.java b/src/com/falchus/lib/minecraft/spigot/utils/builder/InventoryBuilder.java index df6504e1..abf0d6d6 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/builder/InventoryBuilder.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/builder/InventoryBuilder.java @@ -1,29 +1,31 @@ package com.falchus.lib.minecraft.spigot.utils.builder; -import com.falchus.lib.interfaces.consumer.TriConsumer; -import com.falchus.lib.minecraft.spigot.enums.Material; -import com.falchus.lib.minecraft.spigot.utils.ItemUtils; -import com.falchus.lib.minecraft.spigot.utils.inventory.animation.open.InventoryOpenAnimation; -import lombok.Getter; -import lombok.NonNull; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.function.Consumer; + import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; -import java.util.function.Consumer; +import com.falchus.lib.interfaces.consumer.TriConsumer; +import com.falchus.lib.minecraft.spigot.enums.Material; +import com.falchus.lib.minecraft.spigot.utils.ItemUtils; +import com.falchus.lib.minecraft.spigot.utils.inventory.animation.open.InventoryOpenAnimation; + +import lombok.Getter; +import lombok.NonNull; @Getter public class InventoryBuilder { private final String title; private final int size; - private final List items = new ArrayList<>(); private boolean dynamicSize = false; + private final List items = new ArrayList<>(); private TriConsumer globalClickListener; private ItemStack filler; private InventoryOpenAnimation openAnimation; @@ -35,14 +37,14 @@ public InventoryBuilder(@NonNull String title, @NonNull Integer size) { this.title = title; this.size = size; } - + /** * When enabled, the inventory size auto-adjusts to the number of items * but never exceeds the initially set size. */ public InventoryBuilder dynamicSize(boolean dynamicSize) { - this.dynamicSize = dynamicSize; - return this; + this.dynamicSize = dynamicSize; + return this; } /** @@ -71,15 +73,15 @@ public InventoryBuilder setItem(int slot, @NonNull ItemStack item, @NonNull TriC items.add(new ItemUtils.InventoryItem(slot, itemWithUUID, null)); return this; } - + /** * Sets the animation to play when opening the inventory. */ public InventoryBuilder setOpenAnimation(@NonNull InventoryOpenAnimation openAnimation) { - this.openAnimation = openAnimation; + this.openAnimation = openAnimation; return this; } - + /** * Adds an item without a click listener. */ @@ -114,7 +116,7 @@ public InventoryBuilder withClickListener(@NonNull TriConsumer pages = buildPages(); - if (pages.isEmpty()) return; - - Inventory inventory = pages.get(page); - player.openInventory(inventory); - - if (openAnimation != null) { - openAnimation.play(player, inventory); - } + List pages = buildPages(); + if (pages.isEmpty()) return; + + Inventory inventory = pages.get(page); + player.openInventory(inventory); + + if (openAnimation != null) { + openAnimation.play(player, inventory); + } } /** * Builds and returns the final {@link Inventory}. */ public Inventory build() { - return buildInventory(items, title, size); + return buildInventory(items, title, size); } - + /** * Builds multiple pages if items exceed inventory size. * The last row is reserved. */ public List buildPages() { - List pages = new ArrayList<>(); - int pageSize = size - 9; - - int calcPages = (int) Math.ceil(items.size() / (double) pageSize); - final int totalPages = calcPages == 0 ? 1 : calcPages; - - for (int page = 0; page < totalPages; page++) { + List pages = new ArrayList<>(); + int pageSize = size - 9; + + int calcPages = (int) Math.ceil(items.size() / (double) pageSize); + final int totalPages = calcPages == 0 ? 1 : calcPages; + + for (int page = 0; page < totalPages; page++) { int start = page * pageSize; int end = Math.min(start + pageSize, items.size()); List pageItems = items.subList(start, end); - - Inventory inv = buildInventory(pageItems, title, size); - - final int currentPage = page; - - inv.setItem(size - 9, new ItemBuilder(Material.PLAYER_HEAD).setName("§ePrevious page").setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWYxMzNlOTE5MTlkYjBhY2VmZGMyNzJkNjdmZDg3YjRiZTg4ZGM0NGE5NTg5NTg4MjQ0NzRlMjFlMDZkNTNlNiJ9fX0=").withInventoryClickListener( - (player, item, event) -> { - if (currentPage > 0) { - player.openInventory(pages.get(currentPage - 1)); - } - }) - .build()); - inv.setItem(size - 1, new ItemBuilder(Material.PLAYER_HEAD).setName("§eNext page").setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTNmYzUyMjY0ZDhhZDllNjU0ZjQxNWJlZjAxYTIzOTQ3ZWRiY2NjY2Y2NDkzNzMyODliZWE0ZDE0OTU0MWY3MCJ9fX0=").withInventoryClickListener( - (player, item, event) -> { - if (currentPage < totalPages - 1) { - player.openInventory(pages.get(currentPage + 1)); - } - }) - .build()); - - pages.add(inv); - } - - return pages; + + Inventory inv = buildInventory(pageItems, title, size); + + final int currentPage = page; + + inv.setItem(size - 9, new ItemBuilder(Material.PLAYER_HEAD).setName("§ePrevious page").setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWYxMzNlOTE5MTlkYjBhY2VmZGMyNzJkNjdmZDg3YjRiZTg4ZGM0NGE5NTg5NTg4MjQ0NzRlMjFlMDZkNTNlNiJ9fX0=").withInventoryClickListener( + (player, item, event) -> { + if (currentPage > 0) { + player.openInventory(pages.get(currentPage - 1)); + } + }) + .build()); + inv.setItem(size - 1, new ItemBuilder(Material.PLAYER_HEAD).setName("§eNext page").setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZTNmYzUyMjY0ZDhhZDllNjU0ZjQxNWJlZjAxYTIzOTQ3ZWRiY2NjY2Y2NDkzNzMyODliZWE0ZDE0OTU0MWY3MCJ9fX0=").withInventoryClickListener( + (player, item, event) -> { + if (currentPage < totalPages - 1) { + player.openInventory(pages.get(currentPage + 1)); + } + }) + .build()); + + pages.add(inv); + } + + return pages; } - + private Inventory buildInventory(List items, String inventoryTitle, int inventorySize) { int itemCount = items.size(); int size = inventorySize; - + if (dynamicSize) { size = ((itemCount + 8) / 9) * 9; if (filler != null) { - size += 9; + size += 9; } if (size > inventorySize) { - size = inventorySize; + size = inventorySize; } } Inventory inventory = Bukkit.createInventory(null, size, inventoryTitle); - - int autoSlot = 0; - for (ItemUtils.InventoryItem item : items) { - int targetSlot = item.slot == -1 ? autoSlot++ : item.slot; - - UUID uuid = ItemUtils.getUUID(item.item); - if (uuid == null) { - uuid = UUID.randomUUID(); - } - ItemStack itemWithUUID = ItemUtils.setUUID(item.item, uuid); - - inventory.setItem(targetSlot, itemWithUUID); - - if (item.onInventoryClick != null) { - ItemUtils.itemActionsInventory.put(uuid, (pl, clickedItem, event) -> item.onInventoryClick.accept(pl)); - } else if (globalClickListener != null) { - ItemUtils.itemActionsInventory.put(uuid, (pl, clickedItem, event) -> globalClickListener.accept(pl, clickedItem, event)); - } - } - + + int autoSlot = 0; + for (ItemUtils.InventoryItem item : items) { + int targetSlot = item.slot == -1 ? autoSlot++ : item.slot; + + UUID uuid = ItemUtils.getUUID(item.item); + if (uuid == null) { + uuid = UUID.randomUUID(); + } + ItemStack itemWithUUID = ItemUtils.setUUID(item.item, uuid); + + inventory.setItem(targetSlot, itemWithUUID); + + if (item.onInventoryClick != null) { + ItemUtils.itemActionsInventory.put(uuid, (pl, clickedItem, event) -> item.onInventoryClick.accept(pl)); + } else if (globalClickListener != null) { + ItemUtils.itemActionsInventory.put(uuid, (pl, clickedItem, event) -> globalClickListener.accept(pl, clickedItem, event)); + } + } + if (filler != null) { for (int i = 0; i < inventorySize; i++) { if (inventory.getItem(i) == null) { @@ -248,10 +250,10 @@ private Inventory buildInventory(List items, String inv } } } - + if (globalClickListener != null) { ItemUtils.inventoryCallbacks.put(inventory, globalClickListener); } return inventory; } -} \ No newline at end of file +} From 1b76d44f710a9ab60235af70cefb9cfe2b5b82bb Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:12:14 +0200 Subject: [PATCH 201/260] Update ItemBuilder.java --- .../spigot/utils/builder/ItemBuilder.java | 372 +++++++++--------- 1 file changed, 187 insertions(+), 185 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/builder/ItemBuilder.java b/src/com/falchus/lib/minecraft/spigot/utils/builder/ItemBuilder.java index 22f40e13..13a37007 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/builder/ItemBuilder.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/builder/ItemBuilder.java @@ -1,14 +1,10 @@ package com.falchus.lib.minecraft.spigot.utils.builder; -import com.falchus.lib.interfaces.consumer.TriConsumer; -import com.falchus.lib.minecraft.spigot.enums.Version; -import com.falchus.lib.minecraft.spigot.utils.ItemUtils; -import com.falchus.lib.minecraft.spigot.utils.ServerUtils; -import com.falchus.lib.minecraft.spigot.utils.WorldUtils; -import com.falchus.lib.utils.reflection.ReflectionUtils; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import lombok.NonNull; +import java.lang.reflect.Field; +import java.util.List; +import java.util.UUID; +import java.util.function.Consumer; + import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -18,182 +14,188 @@ import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; -import java.lang.reflect.Field; -import java.util.List; -import java.util.UUID; -import java.util.function.Consumer; - -public class ItemBuilder { - - private ItemStack item; - - /** - * Creates an ItemBuilder for the given material and amount. - */ - public ItemBuilder(@NonNull Material material, int amount) { - this.item = new ItemStack(material, amount); - } - - /** - * Creates an ItemBuilder for the given material. - */ - public ItemBuilder(@NonNull Material material) { - this(material, 1); - } - - /** - * Creates an ItemBuilder for the given material and amount. - */ - public ItemBuilder(@NonNull com.falchus.lib.minecraft.spigot.enums.Material material, int amount) { - Material mat = WorldUtils.getMaterial(material); - if (ServerUtils.getVersion().isBefore(Version.v1_13)) { - this.item = new ItemStack(mat, amount, (short) material.getLegacyDurability()); - } else { - this.item = new ItemStack(mat, amount); - } - } - - /** - * Creates an ItemBuilder for the given material. - */ - public ItemBuilder(@NonNull com.falchus.lib.minecraft.spigot.enums.Material material) { - this(material, 1); - } - - /** - * Creates an ItemBuilder from an existing ItemStack. - */ - public ItemBuilder(@NonNull ItemStack item) { - this.item = item.clone(); - } - - /** - * Sets the display name. - */ - public ItemBuilder setName(@NonNull String name) { - ItemMeta meta = item.getItemMeta(); - if (meta != null) { - meta.setDisplayName(name); - item.setItemMeta(meta); - } - return this; - } - - /** - * Sets the lore. - */ - public ItemBuilder setLore(@NonNull List lore) { - ItemMeta meta = item.getItemMeta(); - if (meta != null) { - meta.setLore(lore); - item.setItemMeta(meta); - } - return this; - } - - /** - * Adds an unsafe enchantment. - */ - public ItemBuilder addEnchantment(@NonNull Enchantment enchantment, int level) { - item.addUnsafeEnchantment(enchantment, level); - return this; - } - - /** - * Adds a item flag. - */ - public ItemBuilder addItemFlag(@NonNull ItemFlag itemFlag) { - ItemMeta meta = item.getItemMeta(); - if (meta != null) { - meta.addItemFlags(itemFlag); - item.setItemMeta(meta); - } - return this; - } - - /** - * Sets the durability. - */ - public ItemBuilder setDurability(short durability) { - item.setDurability(durability); - return this; - } - - /** - * Sets the skull owner. - */ - public ItemBuilder setSkullOwner(@NonNull String owner) { - if (item.getType() == WorldUtils.getMaterial(com.falchus.lib.minecraft.spigot.enums.Material.PLAYER_HEAD)) { - SkullMeta meta = (SkullMeta) item.getItemMeta(); - if (meta != null) { - meta.setOwner(owner); - item.setItemMeta(meta); - } - } - return this; - } - - /** - * Sets a custom skull texture using a Base64 texture string. - */ - public ItemBuilder setSkullTexture(@NonNull String texture) { - if (item.getType() == WorldUtils.getMaterial(com.falchus.lib.minecraft.spigot.enums.Material.PLAYER_HEAD)) { - SkullMeta meta = (SkullMeta) item.getItemMeta(); - if (meta != null) { - try { - GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null); - gameProfile.getProperties().put("textures", new Property("textures", texture)); - - Field gameProfile_profile = ReflectionUtils.getField(meta.getClass(), "profile"); - gameProfile_profile.set(meta, gameProfile); - - item.setItemMeta(meta); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - return this; - } - - /** - * Sets a custom UUID (stored in NBT). - */ - public ItemBuilder setUUID(@NonNull UUID uuid) { - ItemUtils.setUUID(item, uuid); - return this; - } +import com.falchus.lib.interfaces.consumer.TriConsumer; +import com.falchus.lib.minecraft.spigot.enums.Version; +import com.falchus.lib.minecraft.spigot.utils.ItemUtils; +import com.falchus.lib.minecraft.spigot.utils.ServerUtils; +import com.falchus.lib.minecraft.spigot.utils.WorldUtils; +import com.falchus.lib.utils.reflection.ReflectionUtils; +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; - /** - * Registers a callback to be executed when a player interacts. - */ - public ItemBuilder withInteractListener(@NonNull Consumer onPlayerInteract) { - UUID uuid = ItemUtils.getUUID(item); - if (uuid == null) { - uuid = UUID.randomUUID(); - item = ItemUtils.setUUID(item, uuid); - } - ItemUtils.itemActions.put(uuid, onPlayerInteract); - return this; - } +import lombok.NonNull; - /** - * Registers a callback to be executed when a player clicks in an inventory. - */ - public ItemBuilder withInventoryClickListener(@NonNull TriConsumer onInventoryClick) { - UUID uuid = ItemUtils.getUUID(item); - if (uuid == null) { - uuid = UUID.randomUUID(); - item = ItemUtils.setUUID(item, uuid); - } - ItemUtils.itemActionsInventory.put(uuid, onInventoryClick); - return this; - } +public class ItemBuilder { - /** - * Builds and returns the final {@link ItemStack}. - */ - public ItemStack build() { - return item; - } -} \ No newline at end of file + private ItemStack item; + + /** + * Creates an ItemBuilder for the given material and amount. + */ + public ItemBuilder(@NonNull Material material, int amount) { + this.item = new ItemStack(material, amount); + } + + /** + * Creates an ItemBuilder for the given material. + */ + public ItemBuilder(@NonNull Material material) { + this(material, 1); + } + + /** + * Creates an ItemBuilder for the given material and amount. + */ + public ItemBuilder(@NonNull com.falchus.lib.minecraft.spigot.enums.Material material, int amount) { + Material mat = WorldUtils.getMaterial(material); + if (ServerUtils.getVersion().isBefore(Version.v1_13)) { + this.item = new ItemStack(mat, amount, (short) material.getLegacyDurability()); + } else { + this.item = new ItemStack(mat, amount); + } + } + + /** + * Creates an ItemBuilder for the given material. + */ + public ItemBuilder(@NonNull com.falchus.lib.minecraft.spigot.enums.Material material) { + this(material, 1); + } + + /** + * Creates an ItemBuilder from an existing ItemStack. + */ + public ItemBuilder(@NonNull ItemStack item) { + this.item = item.clone(); + } + + /** + * Sets the display name. + */ + public ItemBuilder setName(@NonNull String name) { + ItemMeta meta = item.getItemMeta(); + if (meta != null) { + meta.setDisplayName(name); + item.setItemMeta(meta); + } + return this; + } + + /** + * Sets the lore. + */ + public ItemBuilder setLore(@NonNull List lore) { + ItemMeta meta = item.getItemMeta(); + if (meta != null) { + meta.setLore(lore); + item.setItemMeta(meta); + } + return this; + } + + /** + * Adds an unsafe enchantment. + */ + public ItemBuilder addEnchantment(@NonNull Enchantment enchantment, int level) { + item.addUnsafeEnchantment(enchantment, level); + return this; + } + + /** + * Adds a item flag. + */ + public ItemBuilder addItemFlag(@NonNull ItemFlag itemFlag) { + ItemMeta meta = item.getItemMeta(); + if (meta != null) { + meta.addItemFlags(itemFlag); + item.setItemMeta(meta); + } + return this; + } + + /** + * Sets the durability. + */ + public ItemBuilder setDurability(short durability) { + item.setDurability(durability); + return this; + } + + /** + * Sets the skull owner. + */ + public ItemBuilder setSkullOwner(@NonNull String owner) { + if (item.getType() == WorldUtils.getMaterial(com.falchus.lib.minecraft.spigot.enums.Material.PLAYER_HEAD)) { + SkullMeta meta = (SkullMeta) item.getItemMeta(); + if (meta != null) { + meta.setOwner(owner); + item.setItemMeta(meta); + } + } + return this; + } + + /** + * Sets a custom skull texture using a Base64 texture string. + */ + public ItemBuilder setSkullTexture(@NonNull String texture) { + if (item.getType() == WorldUtils.getMaterial(com.falchus.lib.minecraft.spigot.enums.Material.PLAYER_HEAD)) { + SkullMeta meta = (SkullMeta) item.getItemMeta(); + if (meta != null) { + try { + GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null); + gameProfile.getProperties().put("textures", new Property("textures", texture)); + + Field gameProfile_profile = ReflectionUtils.getField(meta.getClass(), "profile"); + gameProfile_profile.set(meta, gameProfile); + + item.setItemMeta(meta); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return this; + } + + /** + * Sets a custom UUID (stored in NBT). + */ + public ItemBuilder setUUID(@NonNull UUID uuid) { + ItemUtils.setUUID(item, uuid); + return this; + } + + /** + * Registers a callback to be executed when a player interacts. + */ + public ItemBuilder withInteractListener(@NonNull Consumer onPlayerInteract) { + UUID uuid = ItemUtils.getUUID(item); + if (uuid == null) { + uuid = UUID.randomUUID(); + item = ItemUtils.setUUID(item, uuid); + } + ItemUtils.itemActions.put(uuid, onPlayerInteract); + return this; + } + + /** + * Registers a callback to be executed when a player clicks in an inventory. + */ + public ItemBuilder withInventoryClickListener(@NonNull TriConsumer onInventoryClick) { + UUID uuid = ItemUtils.getUUID(item); + if (uuid == null) { + uuid = UUID.randomUUID(); + item = ItemUtils.setUUID(item, uuid); + } + ItemUtils.itemActionsInventory.put(uuid, onInventoryClick); + return this; + } + + /** + * Builds and returns the final {@link ItemStack}. + */ + public ItemStack build() { + return item; + } +} From a2267a18a372591b0108604333926c15c710ac75 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:12:32 +0200 Subject: [PATCH 202/260] Update ItemFillAnimation.java --- .../open/impl/ItemFillAnimation.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/impl/ItemFillAnimation.java b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/impl/ItemFillAnimation.java index 7869d6ac..712cb7bd 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/impl/ItemFillAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/impl/ItemFillAnimation.java @@ -1,27 +1,28 @@ package com.falchus.lib.minecraft.spigot.utils.inventory.animation.open.impl; -import com.falchus.lib.minecraft.spigot.enums.Sound; -import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; -import com.falchus.lib.minecraft.spigot.utils.inventory.animation.open.InventoryOpenAnimation; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import com.falchus.lib.minecraft.spigot.enums.Sound; +import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; +import com.falchus.lib.minecraft.spigot.utils.inventory.animation.open.InventoryOpenAnimation; + /** * Fills the items in order. */ public class ItemFillAnimation extends InventoryOpenAnimation { - - public ItemFillAnimation(int delayTicks) { - this.delayTicks = delayTicks; - } - - @Override - protected void animate(Player player, Inventory inventory, ItemStack[] items, int tick) { - ItemStack item = items[tick]; - if (item != null) { - inventory.setItem(tick, item); - PlayerUtils.playSound(player, player.getLocation(), Sound.CHICKEN_EGG_POP, 1, 2); - } - } + + public ItemFillAnimation(int delayTicks) { + this.delayTicks = delayTicks; + } + + @Override + protected void animate(Player player, Inventory inventory, ItemStack[] items, int tick) { + ItemStack item = items[tick]; + if (item != null) { + inventory.setItem(tick, item); + PlayerUtils.playSound(player, player.getLocation(), Sound.CHICKEN_EGG_POP, 1, 2); + } + } } From ea5cd1c20c3365abf00d80197cb26d015a5d9660 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:12:45 +0200 Subject: [PATCH 203/260] Update InventoryOpenAnimation.java --- .../inventory/animation/open/InventoryOpenAnimation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/InventoryOpenAnimation.java b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/InventoryOpenAnimation.java index 805780ad..cc6475a3 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/InventoryOpenAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/open/InventoryOpenAnimation.java @@ -3,5 +3,5 @@ import com.falchus.lib.minecraft.spigot.utils.inventory.animation.InventoryAnimation; public abstract class InventoryOpenAnimation extends InventoryAnimation { - -} \ No newline at end of file + +} From 8cf379dccb2db2e2161ef36b101df251a79e7908 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:13:00 +0200 Subject: [PATCH 204/260] Update InventoryAnimation.java --- .../animation/InventoryAnimation.java | 94 ++++++++++--------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/InventoryAnimation.java b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/InventoryAnimation.java index be32ddb4..5919fb66 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/InventoryAnimation.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/inventory/animation/InventoryAnimation.java @@ -1,15 +1,17 @@ package com.falchus.lib.minecraft.spigot.utils.inventory.animation; -import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; -import com.falchus.lib.task.Task; -import lombok.Getter; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; + import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; +import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; +import com.falchus.lib.task.Task; + +import lombok.Getter; @Getter public abstract class InventoryAnimation { @@ -17,45 +19,45 @@ public abstract class InventoryAnimation { protected final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); protected int delayTicks = 2; protected List excludedItems = new ArrayList<>(); - - /** - * Called to implement animation logic. - * This will be scheduled automatically after delayTicks. - */ - protected abstract void animate(Player player, Inventory inventory, ItemStack[] items, int tick); - - /** - * Plays the animation with automatic scheduling using delayTicks (in {@link TimeUnit#MILLISECONDS}). - */ - public final void play(Player player, Inventory inventory) { - ItemStack[] items = inventory.getContents(); - for (ItemStack item : items) { - if (!excludedItems.contains(item)) { - inventory.removeItem(item); - } - } - - new Task() { - @Override - public void onRun(int tick) { - if (!player.getOpenInventory().getTopInventory().equals(inventory)) { - end(); - return; - } - - if (tick >= items.length) { - end(); - return; - } - - ItemStack item = items[tick]; - if (excludedItems.contains(item)) { - run(); - return; - } - - animate(player, inventory, items, tick); - } - }.runTaskTimer(delayTicks, TimeUnit.MILLISECONDS); + + /** + * Called to implement animation logic. + * This will be scheduled automatically after delayTicks. + */ + protected abstract void animate(Player player, Inventory inventory, ItemStack[] items, int tick); + + /** + * Plays the animation with automatic scheduling using delayTicks (in {@link TimeUnit#MILLISECONDS}). + */ + public final void play(Player player, Inventory inventory) { + ItemStack[] items = inventory.getContents(); + for (ItemStack item : items) { + if (!excludedItems.contains(item)) { + inventory.removeItem(item); + } + } + + new Task() { + @Override + public void onRun(int tick) { + if (!player.getOpenInventory().getTopInventory().equals(inventory)) { + end(); + return; + } + + if (tick >= items.length) { + end(); + return; + } + + ItemStack item = items[tick]; + if (excludedItems.contains(item)) { + run(); + return; + } + + animate(player, inventory, items, tick); + } + }.runTaskTimer(delayTicks, TimeUnit.MILLISECONDS); } } From 492bda40179970bb21224ef84b6379c3bec5d778 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:13:18 +0200 Subject: [PATCH 205/260] Update InventoryBackup.java --- .../utils/inventory/InventoryBackup.java | 93 ++++++++++--------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/inventory/InventoryBackup.java b/src/com/falchus/lib/minecraft/spigot/utils/inventory/InventoryBackup.java index 9f558fce..c0d11b44 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/inventory/InventoryBackup.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/inventory/InventoryBackup.java @@ -1,53 +1,61 @@ package com.falchus.lib.minecraft.spigot.utils.inventory; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NonNull; import lombok.experimental.UtilityClass; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; @UtilityClass public class InventoryBackup { private static final Map> playerInventories = new HashMap<>(); + @AllArgsConstructor + @Getter + public static class BackupData { + ItemStack[] inventory; + ItemStack[] armor; + } + /** * Creates or overwrites a backup with the given ID for a player. */ public static void backupInventory(@NonNull Player player, int id) { - Map backups = playerInventories.computeIfAbsent( - player.getUniqueId(), - k -> new HashMap<>() - ); + Map backups = playerInventories.computeIfAbsent( + player.getUniqueId(), + k -> new HashMap<>() + ); ItemStack[] inventory = player.getInventory().getContents().clone(); ItemStack[] armor = player.getInventory().getArmorContents().clone(); backups.put(id, new BackupData(inventory, armor)); } - + /** * Creates a backup using the next available ID. */ public static void backupInventory(@NonNull Player player) { - int id = getNextBackupId(player); - backupInventory(player, id); + int id = getNextBackupId(player); + backupInventory(player, id); } /** * Restores a specific backup by its ID. * The backup is removed after restoration. - * + * * @return true if restored successfully */ public static boolean loadInventory(@NonNull Player player, int id) { - Map backups = playerInventories.get(player.getUniqueId()); - if (backups == null || !backups.containsKey(id)) return false; + Map backups = playerInventories.get(player.getUniqueId()); + if (backups == null || !backups.containsKey(id)) return false; BackupData backup = backups.get(id); player.getInventory().setContents(backup.inventory); @@ -55,14 +63,14 @@ public static boolean loadInventory(@NonNull Player player, int id) { backups.remove(id); if (backups.isEmpty()) { - playerInventories.remove(player.getUniqueId()); + playerInventories.remove(player.getUniqueId()); } return true; } - + /** * Loads the newest (highest ID) backup. - * + * * @return true if loaded successfully */ public static boolean loadInventory(@NonNull Player player) { @@ -80,7 +88,7 @@ public static boolean hasBackup(@NonNull Player player, int id) { Map backups = playerInventories.get(player.getUniqueId()); return backups != null && backups.containsKey(id); } - + /** * Returns true if the player has at least one backup. */ @@ -88,45 +96,38 @@ public static boolean hasBackup(@NonNull Player player) { Map backups = playerInventories.get(player.getUniqueId()); return backups != null && !backups.isEmpty(); } - + /** * Returns all backups for a player. */ public static Map getBackups(@NonNull Player player) { - return playerInventories.getOrDefault(player.getUniqueId(), Map.of()); + return playerInventories.getOrDefault(player.getUniqueId(), Map.of()); } - + /** * Deletes a specific backup. - * + * * @return true if deleted */ public static boolean deleteBackup(@NonNull Player player, int id) { - Map backups = playerInventories.get(player.getUniqueId()); - if (backups != null && backups.remove(id) != null) { - if (backups.isEmpty()) { - playerInventories.remove(player.getUniqueId()); - } - return true; - } - return false; + Map backups = playerInventories.get(player.getUniqueId()); + if (backups != null && backups.remove(id) != null) { + if (backups.isEmpty()) { + playerInventories.remove(player.getUniqueId()); + } + return true; + } + return false; } - + /** * Creates the next available backup ID for a player. */ public static int getNextBackupId(@NonNull Player player) { - Map backups = playerInventories.get(player.getUniqueId()); - if (backups == null || backups.isEmpty()) { - return 1; - } - return backups.keySet().stream().max(Integer::compareTo).orElse(0) + 1; - } - - @AllArgsConstructor - @Getter - public static class BackupData { - ItemStack[] inventory; - ItemStack[] armor; + Map backups = playerInventories.get(player.getUniqueId()); + if (backups == null || backups.isEmpty()) { + return 1; + } + return backups.keySet().stream().max(Integer::compareTo).orElse(0) + 1; } -} \ No newline at end of file +} From 1f47e44229377d1fe39997f11993a987e15d27f8 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:13:32 +0200 Subject: [PATCH 206/260] Update LabyMod.java --- .../spigot/utils/labymod/LabyMod.java | 320 +++++++++--------- 1 file changed, 161 insertions(+), 159 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyMod.java b/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyMod.java index 7007e125..dc216e2a 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyMod.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyMod.java @@ -1,183 +1,185 @@ package com.falchus.lib.minecraft.spigot.utils.labymod; +import java.util.Collection; +import java.util.UUID; + +import org.bukkit.entity.Player; + import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.google.gson.JsonArray; import com.google.gson.JsonObject; + import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NonNull; import lombok.experimental.UtilityClass; -import org.bukkit.entity.Player; - -import java.util.Collection; -import java.util.UUID; @UtilityClass public class LabyMod { - - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - /** - * Just send this packet to update the value of the balance or to show/hide it - */ - public static void updateBalanceDisplay(@NonNull Player player, BalanceType type, boolean visible, int balance) { - JsonObject economyObject = new JsonObject(); - JsonObject cashObject = new JsonObject(); - - // Visibility - cashObject.addProperty("visible", visible); - - // Amount - cashObject.addProperty("balance", balance); + + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + @AllArgsConstructor + @Getter + public enum BalanceType { + CASH("cash"), + BANK("bank"); + + private final String key; + } + + /** + * Just send this packet to update the value of the balance or to show/hide it + */ + public static void updateBalanceDisplay(@NonNull Player player, BalanceType type, boolean visible, int balance) { + JsonObject economyObject = new JsonObject(); + JsonObject cashObject = new JsonObject(); + + // Visibility + cashObject.addProperty("visible", visible); + + // Amount + cashObject.addProperty("balance", balance); /* // Icon (Optional) cashObject.addProperty("icon", ""); - // Decimal number (Optional) + // Decimal number (Optional) JsonObject decimalObject = new JsonObject(); decimalObject.addProperty("format", "##.##"); // Decimal format decimalObject.addProperty("divisor", 100); // The value that divides the balance cashObject.add("decimal", decimalObject); */ - // The display type can be "cash" or "bank". - economyObject.add(type.getKey(), cashObject); - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "economy", economyObject); - } - - public static void setSubtitle(@NonNull Player receiver, UUID subtitlePlayer, String value) { - // List of all subtitles - JsonArray array = new JsonArray(); - - // Add subtitle - JsonObject subtitle = new JsonObject(); - subtitle.addProperty("uuid", subtitlePlayer.toString()); - - // Optional: Size of the subtitle - subtitle.addProperty("size", 0.8d); // Range is 0.8 - 1.6 (1.6 is Minecraft default) - - // no value = remove the subtitle - if (value != null) { - subtitle.addProperty("value", value); - } - - // If you want to use the new text format in 1.16+ - // subtitle.add("raw_json_text", textObject); - - // You can set multiple subtitles in one packet - array.add(subtitle); - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, receiver, "account_subtitle", array); - } - - public static void sendFlag(@NonNull Player receiver, UUID uuid, String countryCode) { - JsonObject flagPacket = new JsonObject(); - - // Create array - JsonArray users = new JsonArray(); - - // Add user to array - JsonObject userObject = new JsonObject(); - userObject.addProperty("uuid", uuid.toString()); // UUID of the flag player - userObject.addProperty("code", countryCode); // The country code (e.g. "us", "de") - users.add(userObject); - - // Add array to flag object packet - flagPacket.add("users", users); - - LabyModProtocol.sendMessage(plugin, receiver, "language_flag", flagPacket); - } - - public static void setMiddleClickActions(@NonNull Player player, Collection entries) { - // List of all action menu entries - JsonArray array = new JsonArray(); - - // Add entries - for (JsonObject entry : entries) { - array.add(entry); - } - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "user_menu_actions", array); - } - - public static void sendCurrentPlayingGamemode(@NonNull Player player, boolean visible, String gamemodeName) { - JsonObject object = new JsonObject(); - object.addProperty("show_gamemode", visible); // Gamemode visible for everyone - object.addProperty("gamemode_name", gamemodeName); // Name of the current playing gamemode - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "server_gamemode", object); - } - - /** - * @param player The input prompt receiver - * @param promptSessionId A unique id for each packet, use a static number and increase it for each prompt request - * @param message The message above the text field - * @param value The value inside of the text field - * @param placeholder A placeholder text inside of the text field if there is no value given - * @param maxLength Max amount of characters of the text field value - */ - public static void sendInputPrompt(@NonNull Player player, int promptSessionId, String message, String value, String placeholder, int maxLength) { - JsonObject object = new JsonObject(); - object.addProperty("id", promptSessionId); - object.addProperty("message", message); - object.addProperty("value", value); - object.addProperty("placeholder", placeholder); - object.addProperty("max_length", maxLength); - - // If you want to use the new text format in 1.16+ - // object.add("raw_json_text", textObject); - - LabyModProtocol.sendMessage(plugin, player, "input_prompt", object); - } - - public static void sendClientToServer(@NonNull Player player, String title, String address, boolean preview) { - JsonObject object = new JsonObject(); - object.addProperty("title", title); // Title of the warning - object.addProperty("address", address); // Destination server address - object.addProperty("preview", preview); // Display the server icon, motd and user count - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "server_switch", object); - } - - /** - * Just send this packet to set the cinescope coverage - * 0% - Disabled - * 50% - Fully blind - */ - public static void sendCineScope(@NonNull Player player, int coveragePercent, long duration) { - JsonObject object = new JsonObject(); - - // Cinescope height (0% - 50%) - object.addProperty("coverage", coveragePercent); - - // Duration - object.addProperty("duration", duration); - - // Send to LabyMod using the API - LabyModProtocol.sendMessage(plugin, player, "cinescopes", object); - } - - @AllArgsConstructor - @Getter - public enum BalanceType { - CASH("cash"), - BANK("bank"); - - private final String key; - } - - public enum ActionType { - NONE, - CLIPBOARD, - RUN_COMMAND, - SUGGEST_COMMAND, - OPEN_BROWSER - } + // The display type can be "cash" or "bank". + economyObject.add(type.getKey(), cashObject); + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "economy", economyObject); + } + + public static void setSubtitle(@NonNull Player receiver, UUID subtitlePlayer, String value) { + // List of all subtitles + JsonArray array = new JsonArray(); + + // Add subtitle + JsonObject subtitle = new JsonObject(); + subtitle.addProperty("uuid", subtitlePlayer.toString()); + + // Optional: Size of the subtitle + subtitle.addProperty("size", 0.8d); // Range is 0.8 - 1.6 (1.6 is Minecraft default) + + // no value = remove the subtitle + if (value != null) { + subtitle.addProperty("value", value); + } + + // If you want to use the new text format in 1.16+ + // subtitle.add("raw_json_text", textObject); + + // You can set multiple subtitles in one packet + array.add(subtitle); + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, receiver, "account_subtitle", array); + } + + public static void sendFlag(@NonNull Player receiver, UUID uuid, String countryCode) { + JsonObject flagPacket = new JsonObject(); + + // Create array + JsonArray users = new JsonArray(); + + // Add user to array + JsonObject userObject = new JsonObject(); + userObject.addProperty("uuid", uuid.toString()); // UUID of the flag player + userObject.addProperty("code", countryCode); // The country code (e.g. "us", "de") + users.add(userObject); + + // Add array to flag object packet + flagPacket.add("users", users); + + LabyModProtocol.sendMessage(plugin, receiver, "language_flag", flagPacket); + } + + public enum ActionType { + NONE, + CLIPBOARD, + RUN_COMMAND, + SUGGEST_COMMAND, + OPEN_BROWSER + } + + public static void setMiddleClickActions(@NonNull Player player, Collection entries) { + // List of all action menu entries + JsonArray array = new JsonArray(); + + // Add entries + for (JsonObject entry : entries) { + array.add(entry); + } + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "user_menu_actions", array); + } + + public static void sendCurrentPlayingGamemode(@NonNull Player player, boolean visible, String gamemodeName) { + JsonObject object = new JsonObject(); + object.addProperty("show_gamemode", visible); // Gamemode visible for everyone + object.addProperty("gamemode_name", gamemodeName); // Name of the current playing gamemode + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "server_gamemode", object); + } + + /** + * @param player The input prompt receiver + * @param promptSessionId A unique id for each packet, use a static number and increase it for each prompt request + * @param message The message above the text field + * @param value The value inside of the text field + * @param placeholder A placeholder text inside of the text field if there is no value given + * @param maxLength Max amount of characters of the text field value + */ + public static void sendInputPrompt(@NonNull Player player, int promptSessionId, String message, String value, String placeholder, int maxLength) { + JsonObject object = new JsonObject(); + object.addProperty("id", promptSessionId); + object.addProperty("message", message); + object.addProperty("value", value); + object.addProperty("placeholder", placeholder); + object.addProperty("max_length", maxLength); + + // If you want to use the new text format in 1.16+ + // object.add("raw_json_text", textObject); + + LabyModProtocol.sendMessage(plugin, player, "input_prompt", object); + } + + public static void sendClientToServer(@NonNull Player player, String title, String address, boolean preview) { + JsonObject object = new JsonObject(); + object.addProperty("title", title); // Title of the warning + object.addProperty("address", address); // Destination server address + object.addProperty("preview", preview); // Display the server icon, motd and user count + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "server_switch", object); + } + + /** + * Just send this packet to set the cinescope coverage + * 0% - Disabled + * 50% - Fully blind + */ + public static void sendCineScope(@NonNull Player player, int coveragePercent, long duration) { + JsonObject object = new JsonObject(); + + // Cinescope height (0% - 50%) + object.addProperty("coverage", coveragePercent); + + // Duration + object.addProperty("duration", duration); + + // Send to LabyMod using the API + LabyModProtocol.sendMessage(plugin, player, "cinescopes", object); + } } From 46c647326ce5bda76b51b688954622ffbec2b42d Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:13:55 +0200 Subject: [PATCH 207/260] Update LabyModProtocol.java --- .../spigot/utils/labymod/LabyModProtocol.java | 159 +++++++++--------- 1 file changed, 80 insertions(+), 79 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyModProtocol.java b/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyModProtocol.java index 12e401be..18ecf5a5 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyModProtocol.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/labymod/LabyModProtocol.java @@ -1,33 +1,34 @@ package com.falchus.lib.minecraft.spigot.utils.labymod; +import java.nio.charset.Charset; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + import com.google.gson.JsonElement; + import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.EncoderException; import lombok.NonNull; import lombok.experimental.UtilityClass; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import java.nio.charset.Charset; @UtilityClass public class LabyModProtocol { - + /** * Send a message to LabyMod - * - * @param player Minecraft Client - * @param key LabyMod message key + * @param player Minecraft Client + * @param key LabyMod message key * @param messageContent json object content */ - public static void sendMessage(@NonNull Plugin plugin, @NonNull Player player, String key, JsonElement messageContent) { - byte[] data = LabyModProtocol.getBytesToSend(key, messageContent.toString()); - - player.sendPluginMessage(plugin, "labymod3:main", data); - } - + public static void sendMessage(@NonNull Plugin plugin, @NonNull Player player, String key, JsonElement messageContent) { + byte[] data = LabyModProtocol.getBytesToSend(key, messageContent.toString()); + + player.sendPluginMessage(plugin, "labymod3:main", data); + } + /** * Gets the bytes that are required to send the given message * @@ -35,79 +36,79 @@ public static void sendMessage(@NonNull Plugin plugin, @NonNull Player player, S * @param messageContents the message's contents * @return the byte array that should be the payload */ - public static byte[] getBytesToSend(String messageKey, String messageContents) { + public static byte[] getBytesToSend(String messageKey, String messageContents) { // Getting an empty buffer - ByteBuf byteBuf = Unpooled.buffer(); - + ByteBuf byteBuf = Unpooled.buffer(); + // Writing the message-key to the buffer - writeString(byteBuf, messageKey); - + writeString(byteBuf, messageKey); + // Writing the contents to the buffer - writeString(byteBuf, messageContents); - - // Copying the buffer's bytes to the byte array - byte[] bytes = new byte[byteBuf.readableBytes()]; - byteBuf.readBytes(bytes); - - // Release the buffer - byteBuf.release(); - - // Returning the byte array - return bytes; - } - + writeString(byteBuf, messageContents); + + // Copying the buffer's bytes to the byte array + byte[] bytes = new byte[byteBuf.readableBytes()]; + byteBuf.readBytes(bytes); + + // Release the buffer + byteBuf.release(); + + // Returning the byte array + return bytes; + } + /** * Writes a varint to the given byte buffer * * @param buf the byte buffer the int should be written to * @param input the int that should be written to the buffer */ - private static void writeVarIntToBuffer(ByteBuf buf, int input) { - while ((input & -128) != 0) { - buf.writeByte(input & 127 | 128); - input >>>= 7; - } - buf.writeByte(input); - } - + private static void writeVarIntToBuffer(ByteBuf buf, int input) { + while ((input & -128) != 0) { + buf.writeByte(input & 127 | 128); + input >>>= 7; + } + buf.writeByte(input); + } + /** * Writes a string to the given byte buffer * * @param buf the byte buffer the string should be written to * @param string the string that should be written to the buffer */ - private static void writeString(ByteBuf buf, String string) { - byte[] abyte = string.getBytes(Charset.forName("UTF-8")); - - if (abyte.length > Short.MAX_VALUE) { - throw new EncoderException("String too big (was " + string.length() + " bytes encoded, max " + Short.MAX_VALUE + ")"); - } else { - writeVarIntToBuffer(buf, abyte.length); - buf.writeBytes(abyte); - } - } - + private static void writeString(ByteBuf buf, String string) { + byte[] abyte = string.getBytes(Charset.forName("UTF-8")); + + if (abyte.length > Short.MAX_VALUE) { + throw new EncoderException("String too big (was " + string.length() + " bytes encoded, max " + Short.MAX_VALUE + ")"); + } else { + writeVarIntToBuffer(buf, abyte.length); + buf.writeBytes(abyte); + } + } + /** * Reads a varint from the given byte buffer * * @param buf the byte buffer the varint should be read from * @return the int read */ - public static int readVarIntFromBuffer(ByteBuf buf) { - int i = 0; - int j = 0; - - byte b0; - do { - b0 = buf.readByte(); - i |= (b0 & 127) << j++ * 7; - if (j > 5) { - throw new RuntimeException("VarInt too big"); - } - } while ((b0 & 128) == 128); - return i; - } - + public static int readVarIntFromBuffer(ByteBuf buf) { + int i = 0; + int j = 0; + + byte b0; + do { + b0 = buf.readByte(); + i |= (b0 & 127) << j++ * 7; + if (j > 5) { + throw new RuntimeException("VarInt too big"); + } + } while ((b0 & 128) == 128); + return i; + } + /** * Reads a string from the given byte buffer * @@ -115,23 +116,23 @@ public static int readVarIntFromBuffer(ByteBuf buf) { * @param maxLength the string's max-length * @return the string read */ - public static String readString(ByteBuf buf, int maxLength) { - int i = readVarIntFromBuffer(buf); - - if (i > maxLength * 4) { + public static String readString(ByteBuf buf, int maxLength) { + int i = readVarIntFromBuffer(buf); + + if (i > maxLength * 4) { throw new DecoderException("The received encoded string buffer length is longer than maximum allowed (" + i + " > " + maxLength * 4 + ")"); - } else if (i < 0) { - throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!"); - } else { - byte[] bytes = new byte[i]; - buf.readBytes(bytes); - - String s = new String(bytes, Charset.forName("UTF-8")); + } else if (i < 0) { + throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!"); + } else { + byte[] bytes = new byte[i]; + buf.readBytes(bytes); + + String s = new String(bytes, Charset.forName("UTF-8")); if (s.length() > maxLength) { throw new DecoderException("The received string length is longer than maximum allowed (" + i + " > " + maxLength + ")"); } else { return s; } - } - } + } + } } From 33c479bc48c32582d27efd4c8bf91ddd27a9c1b5 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:14:08 +0200 Subject: [PATCH 208/260] Update LunarJsonObjectUtil.java --- .../utils/lunar/LunarJsonObjectUtil.java | 112 +++++++++--------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonObjectUtil.java b/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonObjectUtil.java index 3e4c7b79..515247e3 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonObjectUtil.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonObjectUtil.java @@ -1,66 +1,68 @@ package com.falchus.lib.minecraft.spigot.utils.lunar; -import com.google.gson.JsonObject; -import lombok.NonNull; -import lombok.experimental.UtilityClass; -import org.bukkit.entity.Entity; - -import java.awt.*; +import java.awt.Color; import java.time.Duration; import java.util.Map; import java.util.UUID; -@UtilityClass -public class LunarJsonObjectUtil { - - public static JsonObject createEnableModuleObjectWithType(@NonNull String module, Map properties) { - JsonObject enableModuleObject = LunarJsonPacketUtil.createEnableModuleObject(module, properties); - enableModuleObject.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.ConfigurableSettings"); - return enableModuleObject; - } - - public static JsonObject createUuidObject(@NonNull UUID uuid) { - JsonObject uuidObject = new JsonObject(); - uuidObject.addProperty("high64", Long.toUnsignedString(uuid.getMostSignificantBits())); - uuidObject.addProperty("low64", Long.toUnsignedString(uuid.getLeastSignificantBits())); - return uuidObject; - } - - public static JsonObject createColorObject(@NonNull Color color) { - JsonObject colorObject = new JsonObject(); - colorObject.addProperty("color", color.getRGB()); - return colorObject; - } - - public static String createDurationObject(@NonNull Duration duration) { - long seconds = duration.getSeconds(); - int nanos = duration.getNano(); +import org.bukkit.entity.Entity; - String durationString; - if (nanos == 0) { - durationString = seconds + "s"; - } else { - durationString = String.format("%d.%09ds", seconds, nanos) - .replaceAll("0+$", "") - .replaceAll("\\.$", ""); - } +import com.google.gson.JsonObject; - return durationString; - } +import lombok.NonNull; +import lombok.experimental.UtilityClass; - public static JsonObject createCuboid2DObject(double minX, double minZ, double maxX, double maxZ) { - JsonObject cuboid2DObject = new JsonObject(); - cuboid2DObject.addProperty("min_x", minX); - cuboid2DObject.addProperty("min_z", minZ); - cuboid2DObject.addProperty("max_x", maxX); - cuboid2DObject.addProperty("max_z", maxZ); - return cuboid2DObject; - } +@UtilityClass +public class LunarJsonObjectUtil { - public static JsonObject createEntityIdObject(@NonNull Entity entity) { - JsonObject entityIdObject = new JsonObject(); - entityIdObject.addProperty("entity_id", entity.getEntityId()); - entityIdObject.add("entity_uuid", createUuidObject(entity.getUniqueId())); - return entityIdObject; - } + public static JsonObject createEnableModuleObjectWithType(@NonNull String module, Map properties) { + JsonObject enableModuleObject = LunarJsonPacketUtil.createEnableModuleObject(module, properties); + enableModuleObject.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.ConfigurableSettings"); + return enableModuleObject; + } + + public static JsonObject createUuidObject(@NonNull UUID uuid) { + JsonObject uuidObject = new JsonObject(); + uuidObject.addProperty("high64", Long.toUnsignedString(uuid.getMostSignificantBits())); + uuidObject.addProperty("low64", Long.toUnsignedString(uuid.getLeastSignificantBits())); + return uuidObject; + } + + public static JsonObject createColorObject(@NonNull Color color) { + JsonObject colorObject = new JsonObject(); + colorObject.addProperty("color", color.getRGB()); + return colorObject; + } + + public static String createDurationObject(@NonNull Duration duration) { + long seconds = duration.getSeconds(); + int nanos = duration.getNano(); + + String durationString; + if (nanos == 0) { + durationString = seconds + "s"; + } else { + durationString = String.format("%d.%09ds", seconds, nanos) + .replaceAll("0+$", "") + .replaceAll("\\.$", ""); + } + + return durationString; + } + + public static JsonObject createCuboid2DObject(double minX, double minZ, double maxX, double maxZ) { + JsonObject cuboid2DObject = new JsonObject(); + cuboid2DObject.addProperty("min_x", minX); + cuboid2DObject.addProperty("min_z", minZ); + cuboid2DObject.addProperty("max_x", maxX); + cuboid2DObject.addProperty("max_z", maxZ); + return cuboid2DObject; + } + + public static JsonObject createEntityIdObject(@NonNull Entity entity) { + JsonObject entityIdObject = new JsonObject(); + entityIdObject.addProperty("entity_id", entity.getEntityId()); + entityIdObject.add("entity_uuid", createUuidObject(entity.getUniqueId())); + return entityIdObject; + } } From 4a3569b06864299c45889e3e36e798344063eaf2 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:14:18 +0200 Subject: [PATCH 209/260] Update LunarJsonPacketUtil.java --- .../utils/lunar/LunarJsonPacketUtil.java | 138 +++++++++--------- 1 file changed, 72 insertions(+), 66 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonPacketUtil.java b/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonPacketUtil.java index 42c0cc6e..47df4590 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonPacketUtil.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/lunar/LunarJsonPacketUtil.java @@ -1,77 +1,83 @@ package com.falchus.lib.minecraft.spigot.utils.lunar; +import java.util.List; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.google.common.collect.Table; -import com.google.gson.*; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; + import lombok.NonNull; import lombok.experimental.UtilityClass; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.Map; @UtilityClass public class LunarJsonPacketUtil { - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - public static void sendPacket(Player player, JsonObject message) { - player.sendPluginMessage(plugin, "apollo:json", message.toString().getBytes()); - } - - public static void broadcastPacket(JsonObject message) { - byte[] data = message.toString().getBytes(); - - Bukkit.getOnlinePlayers().forEach(player -> player.sendPluginMessage(plugin, "apollo:json", data)); - } - - public static JsonObject createEnableModuleObject(@NonNull String module, Map properties) { - JsonObject enableModuleObject = new JsonObject(); - enableModuleObject.addProperty("apollo_module", module); - enableModuleObject.addProperty("enable", true); - - if (properties != null) { - JsonObject propertiesObject = new JsonObject(); - for (Map.Entry entry : properties.entrySet()) { - propertiesObject.add(entry.getKey(), convertToJsonElement(entry.getValue())); - } - - enableModuleObject.add("properties", propertiesObject); - } - - return enableModuleObject; - } - - private static JsonElement convertToJsonElement(Object value) { - if (value == null) { - return JsonNull.INSTANCE; - } else if (value instanceof String valueString) { - return new JsonPrimitive(valueString); - } else if (value instanceof Number valueNumber) { - return new JsonPrimitive(valueNumber); - } else if (value instanceof Boolean valueBoolean) { - return new JsonPrimitive(valueBoolean); - } else if (value instanceof List valueList) { - JsonArray jsonArray = new JsonArray(); - for (Object item : valueList) { - jsonArray.add(convertToJsonElement(item)); - } - return jsonArray; - } - - throw new RuntimeException("Unable to wrap value of type '" + value.getClass().getSimpleName() + "'!"); - } - - public static void enableModules(Player player, List modules, Table moduleProperties) { - JsonArray settings = modules.stream() - .map(module -> createEnableModuleObject(module, moduleProperties.row(module))) - .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); - - JsonObject message = new JsonObject(); - message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage"); - message.add("configurable_settings", settings); - - sendPacket(player, message); - } + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + public static void sendPacket(Player player, JsonObject message) { + player.sendPluginMessage(plugin, "apollo:json", message.toString().getBytes()); + } + + public static void broadcastPacket(JsonObject message) { + byte[] data = message.toString().getBytes(); + + Bukkit.getOnlinePlayers().forEach(player -> player.sendPluginMessage(plugin, "apollo:json", data)); + } + + public static JsonObject createEnableModuleObject(@NonNull String module, Map properties) { + JsonObject enableModuleObject = new JsonObject(); + enableModuleObject.addProperty("apollo_module", module); + enableModuleObject.addProperty("enable", true); + + if (properties != null) { + JsonObject propertiesObject = new JsonObject(); + for (Map.Entry entry : properties.entrySet()) { + propertiesObject.add(entry.getKey(), convertToJsonElement(entry.getValue())); + } + + enableModuleObject.add("properties", propertiesObject); + } + + return enableModuleObject; + } + + private static JsonElement convertToJsonElement(Object value) { + if (value == null) { + return JsonNull.INSTANCE; + } else if (value instanceof String valueString) { + return new JsonPrimitive(valueString); + } else if (value instanceof Number valueNumber) { + return new JsonPrimitive(valueNumber); + } else if (value instanceof Boolean valueBoolean) { + return new JsonPrimitive(valueBoolean); + } else if (value instanceof List valueList) { + JsonArray jsonArray = new JsonArray(); + for (Object item : valueList) { + jsonArray.add(convertToJsonElement(item)); + } + return jsonArray; + } + + throw new RuntimeException("Unable to wrap value of type '" + value.getClass().getSimpleName() + "'!"); + } + + public static void enableModules(Player player, List modules, Table moduleProperties) { + JsonArray settings = modules.stream() + .map(module -> createEnableModuleObject(module, moduleProperties.row(module))) + .collect(JsonArray::new, JsonArray::add, JsonArray::addAll); + + JsonObject message = new JsonObject(); + message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.configurable.v1.OverrideConfigurableSettingsMessage"); + message.add("configurable_settings", settings); + + sendPacket(player, message); + } } From dbf2ec73d03bc8d3e8a40c871ff8b94f4d073029 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:14:53 +0200 Subject: [PATCH 210/260] Update VersionAdapter_v1_9_R1.java --- .../v1_9_R1/VersionAdapter_v1_9_R1.java | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/v1_9_R1/VersionAdapter_v1_9_R1.java b/src/com/falchus/lib/minecraft/spigot/utils/version/v1_9_R1/VersionAdapter_v1_9_R1.java index d566a977..e8d99100 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/v1_9_R1/VersionAdapter_v1_9_R1.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/v1_9_R1/VersionAdapter_v1_9_R1.java @@ -1,58 +1,59 @@ package com.falchus.lib.minecraft.spigot.utils.version.v1_9_R1; +import java.lang.reflect.Method; + +import org.bukkit.entity.Player; + import com.falchus.lib.minecraft.spigot.utils.version.VersionAdapter; import com.falchus.lib.utils.reflection.ReflectionUtils; + import lombok.NonNull; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.entity.Player; - -import java.lang.reflect.Method; public class VersionAdapter_v1_9_R1 extends VersionAdapter { - - private Method player_sendTitle() { - return ReflectionUtils.getMethod(Player.class, "sendTitle", - String.class, - String.class - ); - } - - private Method player$Spigot_sendMessage() { - return ReflectionUtils.getMethod(player$Spigot, "sendMessage", - ChatMessageType.class, - BaseComponent[].class - ); - } - + + private Method player_sendTitle() { + return ReflectionUtils.getMethod(Player.class, "sendTitle", + String.class, + String.class + ); + } + private Method player$Spigot_sendMessage() { + return ReflectionUtils.getMethod(player$Spigot, "sendMessage", + ChatMessageType.class, + BaseComponent[].class + ); + } + @Override public void sendTitle(@NonNull Player player, String title, String subtitle) { - try { - title = title != null ? title : ""; - subtitle = subtitle != null ? subtitle : ""; - - player_sendTitle().invoke(player, - title, - subtitle - ); - } catch (Exception e) { + try { + title = title != null ? title : ""; + subtitle = subtitle != null ? subtitle : ""; + + player_sendTitle().invoke(player, + title, + subtitle + ); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendActionbar(@NonNull Player player, @NonNull String message) { - try { - Object spigot = getPlayerSpigot(player); - Object chatMessage = TextComponent.fromLegacyText(message); - - player$Spigot_sendMessage().invoke(spigot, - ChatMessageType.ACTION_BAR, - chatMessage - ); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Object spigot = getPlayerSpigot(player); + Object chatMessage = TextComponent.fromLegacyText(message); + + player$Spigot_sendMessage().invoke(spigot, + ChatMessageType.ACTION_BAR, + chatMessage + ); + } catch (Exception e) { + throw new RuntimeException(e); + } } } From 4e9f3973245f67657fa1806ddd46d223a7f717e6 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:15:24 +0200 Subject: [PATCH 211/260] Update VersionAdapter_v_1_13_R1.java --- .../v_1_13_R1/VersionAdapter_v_1_13_R1.java | 307 +++++++++--------- 1 file changed, 153 insertions(+), 154 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/v_1_13_R1/VersionAdapter_v_1_13_R1.java b/src/com/falchus/lib/minecraft/spigot/utils/version/v_1_13_R1/VersionAdapter_v_1_13_R1.java index d6fab131..699a6b7f 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/v_1_13_R1/VersionAdapter_v_1_13_R1.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/v_1_13_R1/VersionAdapter_v_1_13_R1.java @@ -1,182 +1,181 @@ package com.falchus.lib.minecraft.spigot.utils.version.v_1_13_R1; -import com.falchus.lib.minecraft.spigot.utils.version.VersionAdapter; -import com.falchus.lib.utils.builder.ClassInstanceBuilder; -import com.falchus.lib.utils.reflection.ReflectionUtils; -import lombok.NonNull; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import java.lang.reflect.Method; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Set; -public class VersionAdapter_v_1_13_R1 extends VersionAdapter { +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; - private Method player_setPlayerListHeaderFooter() { - return ReflectionUtils.getMethod(Player.class, "setPlayerListHeaderFooter", - String.class, - String.class - ); - } +import com.falchus.lib.minecraft.spigot.utils.version.VersionAdapter; +import com.falchus.lib.utils.builder.ClassInstanceBuilder; +import com.falchus.lib.utils.reflection.ReflectionUtils; - protected Method scoreboardTeam_setDisplayName() { - return ReflectionUtils.getMethod(scoreboardTeam, "setDisplayName", - iChatBaseComponent - ); - } +import lombok.NonNull; - protected Method scoreboardTeam_setPrefix() { - return ReflectionUtils.getFirstMethod(scoreboardTeam, - List.of( - iChatBaseComponent - ), - "setPrefix", - "setPlayerPrefix" - ); - } +public class VersionAdapter_v_1_13_R1 extends VersionAdapter { - protected Method scoreboardTeam_setSuffix() { - return ReflectionUtils.getFirstMethod(scoreboardTeam, - List.of( - iChatBaseComponent - ), - "setSuffix", - "setPlayerSuffix" - ); + private Method player_setPlayerListHeaderFooter() { + return ReflectionUtils.getMethod(Player.class, "setPlayerListHeaderFooter", + String.class, + String.class + ); + } + protected Method scoreboardTeam_setDisplayName() { + return ReflectionUtils.getMethod(scoreboardTeam, "setDisplayName", + iChatBaseComponent + ); } - + protected Method scoreboardTeam_setPrefix() { + return ReflectionUtils.getFirstMethod(scoreboardTeam, + List.of( + iChatBaseComponent + ), + "setPrefix", + "setPlayerPrefix" + ); + } + protected Method scoreboardTeam_setSuffix() { + return ReflectionUtils.getFirstMethod(scoreboardTeam, + List.of( + iChatBaseComponent + ), + "setSuffix", + "setPlayerSuffix" + ); + } + @Override public void sendTablist(@NonNull Player player, List header, List footer, String name) { - try { - String headerText = header != null ? String.join("\n", header) : ""; - String footerText = footer != null ? String.join("\n", footer) : ""; - + try { + String headerText = header != null ? String.join("\n", header) : ""; + String footerText = footer != null ? String.join("\n", footer) : ""; + player_setPlayerListHeaderFooter().invoke(player, - headerText, - footerText + headerText, + footerText ); player.setPlayerListName(name); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { - try { - Set players = Set.of(player.getName()); - - Object team = new ClassInstanceBuilder( - scoreboardTeam - ).withParams( - Map.of( - scoreboard, - scoreboardINST - ), - Map.of( - String.class, - player.getName() - ) - ).build(); - scoreboardTeam_setDisplayName().invoke(team, - createChatComponentText(player.getName()) - ); - scoreboardTeam_setPrefix().invoke(team, - createChatComponentText(prefix) - ); - scoreboardTeam_setSuffix().invoke(team, - createChatComponentText(suffix) - ); - - Object createPacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).withParams( - Map.of( - scoreboardTeam, - team - ), - Map.of( - Collection.class, - players - ), - Map.of( - int.class, - 0 - ) - ).build(); - - Object updatePacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).withParams( - Map.of( - scoreboardTeam, - team - ), - Map.of( - Collection.class, - players - ), - Map.of( - int.class, - 2 - ) - ).build(); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, createPacket); - sendPacket(onlinePlayer, updatePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Set players = Set.of(player.getName()); + + Object team = new ClassInstanceBuilder( + scoreboardTeam + ).withParams( + Map.of( + scoreboard, + scoreboardINST + ), + Map.of( + String.class, + player.getName() + ) + ).build(); + scoreboardTeam_setDisplayName().invoke(team, + createChatComponentText(player.getName()) + ); + scoreboardTeam_setPrefix().invoke(team, + createChatComponentText(prefix) + ); + scoreboardTeam_setSuffix().invoke(team, + createChatComponentText(suffix) + ); + + Object createPacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).withParams( + Map.of( + scoreboardTeam, + team + ), + Map.of( + Collection.class, + players + ), + Map.of( + int.class, + 0 + ) + ).build(); + + Object updatePacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).withParams( + Map.of( + scoreboardTeam, + team + ), + Map.of( + Collection.class, + players + ), + Map.of( + int.class, + 2 + ) + ).build(); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, createPacket); + sendPacket(onlinePlayer, updatePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public void removeNametag(@NonNull Player player) { - try { - Set players = Set.of(player.getName()); - - Object team = new ClassInstanceBuilder( - scoreboardTeam - ).withParams( - Map.of( - scoreboard, - scoreboardINST - ), - Map.of( - String.class, - player.getName() - ) - ).build(); - scoreboardTeam_setDisplayName().invoke(team, - createChatComponentText(player.getName()) - ); - - Object removePacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).withParams( - Map.of( - scoreboardTeam, - team - ), - Map.of( - Collection.class, - players - ), - Map.of( - int.class, - 4 - ) - ).build(); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, removePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Set players = Set.of(player.getName()); + + Object team = new ClassInstanceBuilder( + scoreboardTeam + ).withParams( + Map.of( + scoreboard, + scoreboardINST + ), + Map.of( + String.class, + player.getName() + ) + ).build(); + scoreboardTeam_setDisplayName().invoke(team, + createChatComponentText(player.getName()) + ); + + Object removePacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).withParams( + Map.of( + scoreboardTeam, + team + ), + Map.of( + Collection.class, + players + ), + Map.of( + int.class, + 4 + ) + ).build(); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, removePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } } From 9ddb8df8a73f8c1d126692dbde2fc05642d6cb57 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:15:44 +0200 Subject: [PATCH 212/260] Update IVersionAdapter.java --- .../spigot/utils/version/IVersionAdapter.java | 397 +++++++++--------- 1 file changed, 193 insertions(+), 204 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/IVersionAdapter.java b/src/com/falchus/lib/minecraft/spigot/utils/version/IVersionAdapter.java index 2d9dc967..4223bb6c 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/IVersionAdapter.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/IVersionAdapter.java @@ -1,8 +1,10 @@ package com.falchus.lib.minecraft.spigot.utils.version; -import com.falchus.lib.minecraft.spigot.enums.Sound; -import com.mojang.authlib.GameProfile; -import lombok.NonNull; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.UUID; + import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.World; @@ -11,217 +13,204 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; -import java.util.UUID; - -public interface IVersionAdapter { - - String getPackageOb(); - - String getPackageObc(); - - String getPackageNm(); - - String getPackageNms(); - - Class getBlockPosition(); - - Class getEntityPlayer(); - - Field getEntityPlayer_playerConnection(); - - Field getPlayerConnection_networkManager(); - - Field getNetworkManager_channel(); - - Class getPlayerInteractManager(); - - Method getEntity_setLocation(); - - Method getEntity_setInvisible(); - - Class getWorld(); - - Class getMinecraftServer(); - - Class getWorldServer(); - - Object createChatComponentText(@NonNull String text); +import com.falchus.lib.minecraft.spigot.enums.Sound; +import com.mojang.authlib.GameProfile; - /** - * @return {@link Entity} - */ - Entity getBukkitEntity(@NonNull Object entity); +import lombok.NonNull; - /** - * Sets yaw and pitch. - */ - void setYawPitch(@NonNull Object entity, float yaw, float pitch); +public interface IVersionAdapter { + String getPackageOb(); + String getPackageObc(); + String getPackageNm(); + String getPackageNms(); + + Class getBlockPosition(); + Class getEntityPlayer(); + Field getEntityPlayer_playerConnection(); + Field getPlayerConnection_networkManager(); + Field getNetworkManager_channel(); + Class getPlayerInteractManager(); + Method getEntity_setLocation(); + Method getEntity_setInvisible(); + Class getWorld(); + Class getMinecraftServer(); + Class getWorldServer(); + + Object createChatComponentText(@NonNull String text); + + /** + * @return {@link Entity} + */ + Entity getBukkitEntity(@NonNull Object entity); + + /** + * Sets yaw and pitch. + */ + void setYawPitch(@NonNull Object entity, float yaw, float pitch); + /** * Sets a UUID on the given item via NBT. */ - ItemStack setUUID(@NonNull ItemStack item, UUID uuid); - + ItemStack setUUID(@NonNull ItemStack item, UUID uuid); + /** * Retrieves the UUID stores on the given item. */ - UUID getUUID(@NonNull ItemStack item); - + UUID getUUID(@NonNull ItemStack item); + /** * Removes all NBT tags from the item. */ - ItemStack clearNBT(@NonNull ItemStack item); - - /** - * Sends a raw NMS packet to a player. - */ - void sendPacket(@NonNull Player player, @NonNull Object packet); - - /** - * Sends a title and/or subtitle to a player. - */ - void sendTitle(@NonNull Player player, String title, String subtitle); - - /** - * Sends a tablist to a player. - */ - void sendTablist(@NonNull Player player, List header, List footer, String name); - - /** - * Sends a bossbar to a player. - */ - void sendBossbar(@NonNull Player player, @NonNull String title, double progress); - - /** - * Removes a bossbar from a player. - */ - void removeBossbar(@NonNull Player player); - - /** - * Sends a actionbar to a player. - */ - void sendActionbar(@NonNull Player player, @NonNull String message); - - /** - * Sends a nametag for a player. - */ - void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix); - - /** - * Removes a nametag from a player. - */ - void removeNametag(@NonNull Player player); - - /** - * Plays a sound to a player. - */ - void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch); - - /** - * @return CraftPlayer from Player - */ - Object getCraftPlayer(@NonNull Player player); - - /** - * @return EntityPlayer from Player - */ - Object getEntityPlayer(@NonNull Player player); - - /** - * @return Player.Spigot from Player - */ - Object getPlayerSpigot(@NonNull Player player); - - /** - * @return {@link GameProfile} from EntityPlayer - */ - GameProfile getProfile(@NonNull Object entityPlayer); - - /** - * @return ping from a player. - */ - int getPing(@NonNull Player player); - - /** - * Sets a custom skin. - */ - void setSkin(@NonNull Player player, @NonNull UUID uuid); - - /** - * Resets the skin back to the original. - */ - void resetSkin(@NonNull Player player); - - /** - * Sets a custom name. - */ - void setName(@NonNull Player player, @NonNull String name); - - /** - * Resets the name back to the original. - */ - void resetName(@NonNull Player player); - - /** - * Forces clients to reload the player's GameProfile. - */ - void refresh(@NonNull Player player); - - /** - * Adds a EntityPlayer. - */ - void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); - - /** - * Removes a EntityPlayer. - */ - void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); - - /** - * Spawns a EntityPlayer. - */ - void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); - - /** - * @return MinecraftServer - */ - Object getMcServer(); - - /** - * @return {@link Server} - */ - Object getBukkitServer(); - - /** - * @return e.g. "1.8.8" - */ - String getVersion(); - - /** - * @return recent TPS - */ - double[] getRecentTps(); - - /** - * @return BiomeBase[] from a World - */ - Object[] getWorldBiomes(@NonNull World world); - - /** - * @return BiomeBase from a Biome - */ - Object getNmsBiome(Biome biome); - - /** - * @return id from a Biome - */ - int getBiomeId(Biome biome); - - /** - * @return WorldServer from a World - */ - Object getWorldServer(World world); + ItemStack clearNBT(@NonNull ItemStack item); + + /** + * Sends a raw NMS packet to a player. + */ + void sendPacket(@NonNull Player player, @NonNull Object packet); + + /** + * Sends a title and/or subtitle to a player. + */ + void sendTitle(@NonNull Player player, String title, String subtitle); + + /** + * Sends a tablist to a player. + */ + void sendTablist(@NonNull Player player, List header, List footer, String name); + + /** + * Sends a bossbar to a player. + */ + void sendBossbar(@NonNull Player player, @NonNull String title, double progress); + + /** + * Removes a bossbar from a player. + */ + void removeBossbar(@NonNull Player player); + + /** + * Sends a actionbar to a player. + */ + void sendActionbar(@NonNull Player player, @NonNull String message); + + /** + * Sends a nametag for a player. + */ + void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix); + + /** + * Removes a nametag from a player. + */ + void removeNametag(@NonNull Player player); + + /** + * Plays a sound to a player. + */ + void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch); + + /** + * @return CraftPlayer from Player + */ + Object getCraftPlayer(@NonNull Player player); + + /** + * @return EntityPlayer from Player + */ + Object getEntityPlayer(@NonNull Player player); + + /** + * @return Player.Spigot from Player + */ + Object getPlayerSpigot(@NonNull Player player); + + /** + * @return {@link GameProfile} from EntityPlayer + */ + GameProfile getProfile(@NonNull Object entityPlayer); + + /** + * @return ping from a player. + */ + int getPing(@NonNull Player player); + + /** + * Sets a custom skin. + */ + void setSkin(@NonNull Player player, @NonNull UUID uuid); + + /** + * Resets the skin back to the original. + */ + void resetSkin(@NonNull Player player); + + /** + * Sets a custom name. + */ + void setName(@NonNull Player player, @NonNull String name); + + /** + * Resets the name back to the original. + */ + void resetName(@NonNull Player player); + + /** + * Forces clients to reload the player's GameProfile. + */ + void refresh(@NonNull Player player); + + /** + * Adds a EntityPlayer. + */ + void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); + + /** + * Removes a EntityPlayer. + */ + void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); + + /** + * Spawns a EntityPlayer. + */ + void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer); + + /** + * @return MinecraftServer + */ + Object getMcServer(); + + /** + * @return {@link Server} + */ + Object getBukkitServer(); + + /** + * @return e.g. "1.8.8" + */ + String getVersion(); + + /** + * @return recent TPS + */ + double[] getRecentTps(); + + /** + * @return BiomeBase[] from a World + */ + Object[] getWorldBiomes(@NonNull World world); + + /** + * @return BiomeBase from a Biome + */ + Object getNmsBiome(Biome biome); + + /** + * @return id from a Biome + */ + int getBiomeId(Biome biome); + + /** + * @return WorldServer from a World + */ + Object getWorldServer(World world); } From e50a80d38d3e85f4f8450f79083a4323f668d057 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:16:24 +0200 Subject: [PATCH 213/260] Update VersionAdapter.java --- .../spigot/utils/version/VersionAdapter.java | 1787 ++++++++--------- 1 file changed, 856 insertions(+), 931 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapter.java b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapter.java index a64b9e95..5e2366ca 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapter.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapter.java @@ -1,5 +1,22 @@ package com.falchus.lib.minecraft.spigot.utils.version; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.block.Biome; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.falchus.lib.minecraft.spigot.enums.Sound; import com.falchus.lib.minecraft.spigot.utils.PlayerUtils; @@ -8,84 +25,59 @@ import com.falchus.lib.utils.reflection.ReflectionUtils; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; + import lombok.AccessLevel; import lombok.Getter; import lombok.NonNull; import lombok.SneakyThrows; import lombok.experimental.FieldDefaults; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.*; /** * Adapter for all versions. (tested with 1.8.8) */ @FieldDefaults(level = AccessLevel.PROTECTED) public class VersionAdapter implements IVersionAdapter { - - final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - final Map bossBars = new HashMap<>(); - - @Getter - String packageOb = "org.bukkit."; - @Getter - String packageObc = packageOb + "craftbukkit."; - @Getter - String packageNm = "net.minecraft."; - @Getter - String packageNms = packageNm + "server."; - - @Getter - Class blockPosition; - @Getter - Class entityPlayer; - @Getter - Field entityPlayer_playerConnection; + + final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + + final Map bossBars = new HashMap<>(); + + @Getter String packageOb = "org.bukkit."; + @Getter String packageObc = packageOb + "craftbukkit."; + @Getter String packageNm = "net.minecraft."; + @Getter String packageNms = packageNm + "server."; + + @Getter Class blockPosition; + @Getter Class entityPlayer; + @Getter Field entityPlayer_playerConnection; Class playerConnection; - @Getter - Field playerConnection_networkManager; + @Getter Field playerConnection_networkManager; Class networkManager; - @Getter - Field networkManager_channel; - @Getter - Class playerInteractManager; + @Getter Field networkManager_channel; + @Getter Class playerInteractManager; Class entity; - @Getter - Method entity_setLocation; - @Getter - Method entity_setInvisible; - @Getter - Class world; - @Getter - Class minecraftServer; - @Getter - Class worldServer; - - protected Class chatComponentText; - + @Getter Method entity_setLocation; + @Getter Method entity_setInvisible; + @Getter Class world; + @Getter Class minecraftServer; + @Getter Class worldServer; + + Class chatComponentText; + Method entity_getBukkitEntity; Method entity_setYawPitch; - - Class craftItemStack; - Class nmsItemStack; - Class nbtTagCompound; - Method craftItemStack_asNMSCopy; - Method craftItemStack_asBukkitCopy; - Method nbtTagCompound_setString; - Method nbtTagCompound_remove; - Method nbtTagCompound_hasKey; - Method nbtTagCompound_getString; - - Class packet; + + Class craftItemStack; + Class nmsItemStack; + Class nbtTagCompound; + Method craftItemStack_asNMSCopy; + Method craftItemStack_asBukkitCopy; + Method nbtTagCompound_setString; + Method nbtTagCompound_remove; + Method nbtTagCompound_hasKey; + Method nbtTagCompound_getString; + + Class packet; Method playerConnection_sendPacket; Class iChatBaseComponent; Class scoreboardTeam; @@ -102,164 +94,249 @@ public class VersionAdapter implements IVersionAdapter { Class packetPlayOutPlayerInfo$enumPlayerInfoAction; Object packetPlayOutPlayerInfo$enumPlayerInfoAction_UPDATE_DISPLAY_NAME; Object packetPlayOutPlayerInfo$enumPlayerInfoAction_ADD_PLAYER; - + Class craftServer; Method craftServer_getServer; Class bukkitServer; Method minecraftServer_getVersion; Field minecraftServer_recentTps; - + Class biomeBase; Field biomeBase_biomes; Method biomeBase_getBiome; - - public VersionAdapter() { - try { - String version; + + private Method nmsItemStack_getTag() { + return ReflectionUtils.getMethod(nmsItemStack, "getTag"); + } + private Method nmsItemStack_setTag() { + return ReflectionUtils.getMethod(nmsItemStack, "setTag", + nbtTagCompound + ); + } + private Method nmsItemStack_hasTag() { + return ReflectionUtils.getMethod(nmsItemStack, "hasTag"); + } + + @SneakyThrows + private Object packetPlayOutPlayerInfo$enumPlayerInfoAction_REMOVE_PLAYER() { + return ReflectionUtils.getField(packetPlayOutPlayerInfo$enumPlayerInfoAction, "REMOVE_PLAYER").get(null); + } + private Class packetPlayOutTitle$enumTitleAction() { + return ReflectionUtils.getClass(packageNms + "PacketPlayOutTitle$EnumTitleAction"); + } + @SneakyThrows + private Object packetPlayOutTitle$enumTitleAction_TITLE() { + return ReflectionUtils.getField(packetPlayOutTitle$enumTitleAction(), "TITLE").get(null); + } + @SneakyThrows + private Object packetPlayOutTitle$enumTitleAction_SUBTITLE() { + return ReflectionUtils.getField(packetPlayOutTitle$enumTitleAction(), "SUBTITLE").get(null); + } + private Class craftWorld() { + return ReflectionUtils.getClass(packageObc + "CraftWorld"); + } + private Method craftWorld_getHandle() { + return ReflectionUtils.getMethod(craftWorld(), "getHandle"); + } + private Method entity_setCustomName() { + return ReflectionUtils.getMethod(entity, "setCustomName", + String.class + ); + } + private Method entity_setCustomNameVisible() { + return ReflectionUtils.getMethod(entity, "setCustomNameVisible", + boolean.class + ); + } + private Method entity_getId() { + return ReflectionUtils.getMethod(entity, "getId"); + } + private Class dataWatcher() { + return ReflectionUtils.getClass(packageNms + "DataWatcher"); + } + private Method entity_getDataWatcher() { + return ReflectionUtils.getMethod(entity, "getDataWatcher"); + } + private Class entityLiving() { + return ReflectionUtils.getClass(packageNms + "EntityLiving"); + } + private Method entityLiving_setHealth() { + return ReflectionUtils.getMethod(entityLiving(), "setHealth", + float.class + ); + } + private Method entityLiving_getMaxHealth() { + return ReflectionUtils.getMethod(entityLiving(), "getMaxHealth"); + } + private Class entityWither() { + return ReflectionUtils.getClass(packageNms + "EntityWither"); + } + private Field packetPlayOutScoreboardTeam_name() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "a"); + } + private Field packetPlayOutScoreboardTeam_displayName() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "b"); + } + private Field packetPlayOutScoreboardTeam_prefix() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "c"); + } + private Field packetPlayOutScoreboardTeam_suffix() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "d"); + } + private Field packetPlayOutScoreboardTeam_players() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "g"); + } + private Field packetPlayOutScoreboardTeam_mode() { + return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "h"); + } + + public VersionAdapter() { + try { + String version; String packageName = Bukkit.getServer().getClass().getPackageName(); String[] parts = packageName.split("\\."); version = parts.length >= 4 ? parts[3] : "Unknown"; - - packageObc = packageObc + (!version.equals("Unknown") ? version + "." : ""); - packageNms = packageNms + (!version.equals("Unknown") ? version + "." : ""); - + + packageObc = packageObc + (!version.equals("Unknown") ? version + "." : ""); + packageNms = packageNms + (!version.equals("Unknown") ? version + "." : ""); + blockPosition = ReflectionUtils.getFirstClass( - packageNms + "BlockPosition", - packageNm + "core.BlockPosition" + packageNms + "BlockPosition", + packageNm + "core.BlockPosition" ); entityPlayer = ReflectionUtils.getFirstClass( - packageNms + "EntityPlayer", - packageNms + "level.EntityPlayer" + packageNms + "EntityPlayer", + packageNms + "level.EntityPlayer" ); entityPlayer_playerConnection = ReflectionUtils.getFirstField(entityPlayer, - "playerConnection", - "connection" + "playerConnection", + "connection" ); playerConnection = ReflectionUtils.getFirstClass( - packageNms + "PlayerConnection", - packageNms + "network.PlayerConnection" + packageNms + "PlayerConnection", + packageNms + "network.PlayerConnection" ); playerConnection_networkManager = ReflectionUtils.getFirstField(playerConnection, - "networkManager" + "networkManager" ); networkManager = ReflectionUtils.getFirstClass( - packageNms + "NetworkManager", - packageNm + "network.NetworkManager" + packageNms + "NetworkManager", + packageNm + "network.NetworkManager" ); networkManager_channel = ReflectionUtils.getField(networkManager, "channel"); playerInteractManager = ReflectionUtils.getFirstClass( - packageNms + "PlayerInteractManager", - packageNms + "level.PlayerInteractManager" + packageNms + "PlayerInteractManager", + packageNms + "level.PlayerInteractManager" ); entity = ReflectionUtils.getFirstClass( - packageNms + "Entity", - packageNm + "world.entity.Entity" + packageNms + "Entity", + packageNm + "world.entity.Entity" ); entity_setLocation = ReflectionUtils.getFirstMethod(entity, - List.of( - double.class, - double.class, - double.class, - float.class, - float.class - ), - "setLocation", - "a" + List.of( + double.class, + double.class, + double.class, + float.class, + float.class + ), + "setLocation", + "a" ); entity_setInvisible = ReflectionUtils.getMethod(entity, "setInvisible", - boolean.class + boolean.class ); world = ReflectionUtils.getFirstClass( - packageNms + "World", - packageNm + "world.level.World" + packageNms + "World", + packageNm + "world.level.World" ); minecraftServer = ReflectionUtils.getClass(packageNms + "MinecraftServer"); - worldServer = ReflectionUtils.getFirstClass( - packageNms + "WorldServer", - packageNms + "level.WorldServer" - ); - + worldServer = ReflectionUtils.getFirstClass( + packageNms + "WorldServer", + packageNms + "level.WorldServer" + ); + chatComponentText = ReflectionUtils.getFirstClass( - packageNms + "ChatComponentText", - packageNm + "network.chat.ChatComponentText" + packageNms + "ChatComponentText", + packageNm + "network.chat.ChatComponentText" ); - + entity_getBukkitEntity = ReflectionUtils.getMethod(entity, "getBukkitEntity"); entity_setYawPitch = ReflectionUtils.getFirstMethod(entity, - List.of( - float.class, - float.class - ), - "setYawPitch", - "setRot" + List.of( + float.class, + float.class + ), + "setYawPitch", + "setRot" ); - + craftItemStack = ReflectionUtils.getClass(packageObc + "inventory.CraftItemStack"); nmsItemStack = ReflectionUtils.getFirstClass( - packageNms + "ItemStack", - packageNm + "world.item.ItemStack" + packageNms + "ItemStack", + packageNm + "world.item.ItemStack" ); nbtTagCompound = ReflectionUtils.getFirstClass( - packageNms + "NBTTagCompound", - packageNm + "nbt.NBTTagCompound" + packageNms + "NBTTagCompound", + packageNm + "nbt.NBTTagCompound" ); craftItemStack_asNMSCopy = ReflectionUtils.getMethod(craftItemStack, "asNMSCopy", - ItemStack.class + ItemStack.class ); craftItemStack_asBukkitCopy = ReflectionUtils.getMethod(craftItemStack, "asBukkitCopy", - nmsItemStack + nmsItemStack ); nbtTagCompound_setString = ReflectionUtils.getFirstMethod(nbtTagCompound, - List.of( - String.class, - String.class - ), - "setString", - "putString" - ); + List.of( + String.class, + String.class + ), + "setString", + "putString" + ); nbtTagCompound_remove = ReflectionUtils.getMethod(nbtTagCompound, "remove", - String.class + String.class ); nbtTagCompound_hasKey = ReflectionUtils.getFirstMethod(nbtTagCompound, - List.of( - String.class - ), - "hasKey", - "contains" + List.of( + String.class + ), + "hasKey", + "contains" ); nbtTagCompound_getString = ReflectionUtils.getMethod(nbtTagCompound, "getString", - String.class + String.class ); - + packet = ReflectionUtils.getFirstClass( - packageNms + "Packet", - packageNm + "network.protocol.Packet" + packageNms + "Packet", + packageNm + "network.protocol.Packet" ); playerConnection_sendPacket = ReflectionUtils.getFirstMethod(playerConnection, - List.of( - packet - ), - "sendPacket", - "send" + List.of( + packet + ), + "sendPacket", + "send" ); iChatBaseComponent = ReflectionUtils.getFirstClass( - packageNms + "IChatBaseComponent", - packageNm + "network.chat.IChatBaseComponent" + packageNms + "IChatBaseComponent", + packageNm + "network.chat.IChatBaseComponent" ); scoreboardTeam = ReflectionUtils.getFirstClass( - packageNms + "ScoreboardTeam", - packageNm + "world.scores.ScoreboardTeam" + packageNms + "ScoreboardTeam", + packageNm + "world.scores.ScoreboardTeam" ); scoreboard = ReflectionUtils.getFirstClass( - packageNms + "Scoreboard", - packageNm + "world.scores.Scoreboard" + packageNms + "Scoreboard", + packageNm + "world.scores.Scoreboard" ); scoreboardINST = new ClassInstanceBuilder( - scoreboard + scoreboard ).build(); packetPlayOutScoreboardTeam = ReflectionUtils.getFirstClass( - packageNms + "PacketPlayOutScoreboardTeam", - packageNm + "network.protocol.game.PacketPlayOutScoreboardTeam" + packageNms + "PacketPlayOutScoreboardTeam", + packageNm + "network.protocol.game.PacketPlayOutScoreboardTeam" ); craftPlayer = ReflectionUtils.getClass(packageObc + "entity.CraftPlayer"); craftPlayer_getHandle = ReflectionUtils.getMethod(craftPlayer, "getHandle"); @@ -267,983 +344,831 @@ public VersionAdapter() { player_spigot = ReflectionUtils.getMethod(Player.class, "spigot"); entityHuman = entityPlayer.getSuperclass(); entityHuman_profile = ReflectionUtils.getFirstField(entityHuman, - "bH", - "gameProfile" + "bH", + "gameProfile" ); entityPlayer_ping = ReflectionUtils.getField(entityPlayer, "ping"); packetPlayOutPlayerInfo$enumPlayerInfoAction = ReflectionUtils.getFirstClass( - packageNms + "PacketPlayOutPlayerInfo$EnumPlayerInfoAction", - packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket$Action" + packageNms + "PacketPlayOutPlayerInfo$EnumPlayerInfoAction", + packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket$Action" ); packetPlayOutPlayerInfo$enumPlayerInfoAction_UPDATE_DISPLAY_NAME = ReflectionUtils.getField(packetPlayOutPlayerInfo$enumPlayerInfoAction, "UPDATE_DISPLAY_NAME").get(null); packetPlayOutPlayerInfo$enumPlayerInfoAction_ADD_PLAYER = ReflectionUtils.getField(packetPlayOutPlayerInfo$enumPlayerInfoAction, "ADD_PLAYER").get(null); - + craftServer = ReflectionUtils.getClass(packageObc + "CraftServer"); craftServer_getServer = ReflectionUtils.getMethod(craftServer, "getServer"); bukkitServer = ReflectionUtils.getClass(packageOb + "Server"); minecraftServer_getVersion = ReflectionUtils.getMethod(minecraftServer, "getVersion"); minecraftServer_recentTps = ReflectionUtils.getField(minecraftServer, "recentTps"); - - biomeBase = ReflectionUtils.getFirstClass( - packageNms + "BiomeBase", - packageNm + "world.level.biome.BiomeBase" - ); + + biomeBase = ReflectionUtils.getFirstClass( + packageNms + "BiomeBase", + packageNm + "world.level.biome.BiomeBase" + ); biomeBase_biomes = ReflectionUtils.getField(biomeBase, "biomes"); biomeBase_getBiome = ReflectionUtils.getMethod(biomeBase, "getBiome", - int.class + int.class ); - } catch (Exception e) { - throw new IllegalStateException("Failed to initialize " + getClass().getSimpleName(), e); - } - } - - private Method nmsItemStack_getTag() { - return ReflectionUtils.getMethod(nmsItemStack, "getTag"); - } - - private Method nmsItemStack_setTag() { - return ReflectionUtils.getMethod(nmsItemStack, "setTag", - nbtTagCompound - ); - } - - private Method nmsItemStack_hasTag() { - return ReflectionUtils.getMethod(nmsItemStack, "hasTag"); - } - - @SneakyThrows - private Object packetPlayOutPlayerInfo$enumPlayerInfoAction_REMOVE_PLAYER() { - return ReflectionUtils.getField(packetPlayOutPlayerInfo$enumPlayerInfoAction, "REMOVE_PLAYER").get(null); - } - - private Class packetPlayOutTitle$enumTitleAction() { - return ReflectionUtils.getClass(packageNms + "PacketPlayOutTitle$EnumTitleAction"); - } - - @SneakyThrows - private Object packetPlayOutTitle$enumTitleAction_TITLE() { - return ReflectionUtils.getField(packetPlayOutTitle$enumTitleAction(), "TITLE").get(null); - } - - @SneakyThrows - private Object packetPlayOutTitle$enumTitleAction_SUBTITLE() { - return ReflectionUtils.getField(packetPlayOutTitle$enumTitleAction(), "SUBTITLE").get(null); - } - - private Class craftWorld() { - return ReflectionUtils.getClass(packageObc + "CraftWorld"); - } - - private Method craftWorld_getHandle() { - return ReflectionUtils.getMethod(craftWorld(), "getHandle"); - } - - private Method entity_setCustomName() { - return ReflectionUtils.getMethod(entity, "setCustomName", - String.class - ); - } - - private Method entity_setCustomNameVisible() { - return ReflectionUtils.getMethod(entity, "setCustomNameVisible", - boolean.class - ); - } - - private Method entity_getId() { - return ReflectionUtils.getMethod(entity, "getId"); - } - - private Class dataWatcher() { - return ReflectionUtils.getClass(packageNms + "DataWatcher"); - } - - private Method entity_getDataWatcher() { - return ReflectionUtils.getMethod(entity, "getDataWatcher"); - } - - private Class entityLiving() { - return ReflectionUtils.getClass(packageNms + "EntityLiving"); - } - - private Method entityLiving_setHealth() { - return ReflectionUtils.getMethod(entityLiving(), "setHealth", - float.class - ); - } - - private Method entityLiving_getMaxHealth() { - return ReflectionUtils.getMethod(entityLiving(), "getMaxHealth"); - } - - private Class entityWither() { - return ReflectionUtils.getClass(packageNms + "EntityWither"); - } - - private Field packetPlayOutScoreboardTeam_name() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "a"); - } - - private Field packetPlayOutScoreboardTeam_displayName() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "b"); - } - - private Field packetPlayOutScoreboardTeam_prefix() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "c"); - } - - private Field packetPlayOutScoreboardTeam_suffix() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "d"); - } - - private Field packetPlayOutScoreboardTeam_players() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "g"); - } - - private Field packetPlayOutScoreboardTeam_mode() { - return ReflectionUtils.getField(packetPlayOutScoreboardTeam, "h"); - } - - @Override - public Object createChatComponentText(@NonNull String text) { - try { - return new ClassInstanceBuilder( - chatComponentText - ).withParams( - Map.of( - String.class, - text - ) - ).build(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public Entity getBukkitEntity(@NonNull Object entity) { - try { - return (Entity) entity_getBukkitEntity.invoke(entity); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public void setYawPitch(@NonNull Object entity, float yaw, float pitch) { - try { - entity_setYawPitch.invoke(entity, - yaw, - pitch - ); - } catch (Exception e) { + } catch (Exception e) { + throw new IllegalStateException("Failed to initialize " + getClass().getSimpleName(), e); + } + } + + @Override + public Object createChatComponentText(@NonNull String text) { + try { + return new ClassInstanceBuilder( + chatComponentText + ).withParams( + Map.of( + String.class, + text + ) + ).build(); + } catch (Exception e) { throw new RuntimeException(e); } - } - + } + + @Override + public Entity getBukkitEntity(@NonNull Object entity) { + try { + return (Entity) entity_getBukkitEntity.invoke(entity); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void setYawPitch(@NonNull Object entity, float yaw, float pitch) { + try { + entity_setYawPitch.invoke(entity, + yaw, + pitch + ); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Override public ItemStack setUUID(@NonNull ItemStack item, UUID uuid) { - try { - Object nmsItem = craftItemStack_asNMSCopy.invoke(null, - item - ); - if (nmsItem == null) return item; - - Object tag = (boolean) nmsItemStack_hasTag().invoke(nmsItem) - ? nmsItemStack_getTag().invoke(nmsItem) - : nbtTagCompound.getConstructor().newInstance(); - if (uuid == null) { - nbtTagCompound_remove.invoke(tag, - "UUID" - ); - } else { - nbtTagCompound_setString.invoke(tag, - "UUID", - uuid.toString() - ); - } + try { + Object nmsItem = craftItemStack_asNMSCopy.invoke(null, + item + ); + if (nmsItem == null) return item; + + Object tag = (boolean) nmsItemStack_hasTag().invoke(nmsItem) + ? nmsItemStack_getTag().invoke(nmsItem) + : nbtTagCompound.getConstructor().newInstance(); + if (uuid == null) { + nbtTagCompound_remove.invoke(tag, + "UUID" + ); + } else { + nbtTagCompound_setString.invoke(tag, + "UUID", + uuid.toString() + ); + } nmsItemStack_setTag().invoke(nmsItem, - tag + tag ); return (ItemStack) craftItemStack_asBukkitCopy.invoke(null, - nmsItem + nmsItem ); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public UUID getUUID(@NonNull ItemStack item) { - try { - Object nmsItem = craftItemStack_asNMSCopy.invoke(null, - item - ); - if (nmsItem == null) return null; - - if ((boolean) nmsItemStack_hasTag().invoke(nmsItem)) { - Object tag = nmsItemStack_getTag().invoke(nmsItem); - if ((boolean) nbtTagCompound_hasKey.invoke(tag, - "UUID" - )) { - return UUID.fromString((String) nbtTagCompound_getString.invoke(tag, - "UUID" - )); - } - } - return null; - } catch (Exception e) { + try { + Object nmsItem = craftItemStack_asNMSCopy.invoke(null, + item + ); + if (nmsItem == null) return null; + + if ((boolean) nmsItemStack_hasTag().invoke(nmsItem)) { + Object tag = nmsItemStack_getTag().invoke(nmsItem); + if ((boolean) nbtTagCompound_hasKey.invoke(tag, + "UUID" + )) { + return UUID.fromString((String) nbtTagCompound_getString.invoke(tag, + "UUID" + )); + } + } + return null; + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public ItemStack clearNBT(@NonNull ItemStack item) { - try { - Object nmsItem = craftItemStack_asNMSCopy.invoke(null, - item - ); - if (nmsItem == null) return item; - - Object tag = new ClassInstanceBuilder( - nbtTagCompound - ).build(); - nmsItemStack_setTag().invoke(nmsItem, - tag - ); - - return (ItemStack) craftItemStack_asBukkitCopy.invoke(null, - nmsItem - ); - } catch (Exception e) { + try { + Object nmsItem = craftItemStack_asNMSCopy.invoke(null, + item + ); + if (nmsItem == null) return item; + + Object tag = new ClassInstanceBuilder( + nbtTagCompound + ).build(); + nmsItemStack_setTag().invoke(nmsItem, + tag + ); + + return (ItemStack) craftItemStack_asBukkitCopy.invoke(null, + nmsItem + ); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendPacket(@NonNull Player player, @NonNull Object packet) { - try { - Object entityPlayer = getEntityPlayer(player); - Object connection = entityPlayer_playerConnection.get(entityPlayer); - playerConnection_sendPacket.invoke(connection, - packet - ); - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + Object connection = entityPlayer_playerConnection.get(entityPlayer); + playerConnection_sendPacket.invoke(connection, + packet + ); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendTitle(@NonNull Player player, String title, String subtitle) { - try { - title = title != null ? title : ""; - subtitle = subtitle != null ? subtitle : ""; - - Object titleComponent = createChatComponentText(title); - Object titlePacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutTitle" - ).withParams( - Map.of( - packetPlayOutTitle$enumTitleAction(), - packetPlayOutTitle$enumTitleAction_TITLE() - ), - Map.of( - iChatBaseComponent, - titleComponent - ) - ).build(); - sendPacket(player, titlePacket); - - Object subtitleComponent = createChatComponentText(subtitle); - Object subtitlePacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutTitle" - ).withParams( - Map.of( - packetPlayOutTitle$enumTitleAction(), - packetPlayOutTitle$enumTitleAction_SUBTITLE() - ), - Map.of( - iChatBaseComponent, - subtitleComponent - ) - ).build(); - sendPacket(player, subtitlePacket); - } catch (Exception e) { + try { + title = title != null ? title : ""; + subtitle = subtitle != null ? subtitle : ""; + + Object titleComponent = createChatComponentText(title); + Object titlePacket = new ClassInstanceBuilder( + packageNms + "PacketPlayOutTitle" + ).withParams( + Map.of( + packetPlayOutTitle$enumTitleAction(), + packetPlayOutTitle$enumTitleAction_TITLE() + ), + Map.of( + iChatBaseComponent, + titleComponent + ) + ).build(); + sendPacket(player, titlePacket); + + Object subtitleComponent = createChatComponentText(subtitle); + Object subtitlePacket = new ClassInstanceBuilder( + packageNms + "PacketPlayOutTitle" + ).withParams( + Map.of( + packetPlayOutTitle$enumTitleAction(), + packetPlayOutTitle$enumTitleAction_SUBTITLE() + ), + Map.of( + iChatBaseComponent, + subtitleComponent + ) + ).build(); + sendPacket(player, subtitlePacket); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendTablist(@NonNull Player player, List header, List footer, String name) { - try { - String headerText = header != null ? String.join("\n", header) : ""; - String footerText = footer != null ? String.join("\n", footer) : ""; - - Object headerComponent = createChatComponentText(headerText); - Object footerComponent = createChatComponentText(footerText); + try { + String headerText = header != null ? String.join("\n", header) : ""; + String footerText = footer != null ? String.join("\n", footer) : ""; + Object headerComponent = createChatComponentText(headerText); + Object footerComponent = createChatComponentText(footerText); + Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutPlayerListHeaderFooter" + packageNms + "PacketPlayOutPlayerListHeaderFooter" ).withParams( - Map.of( - iChatBaseComponent, - headerComponent - ) + Map.of( + iChatBaseComponent, + headerComponent + ) ).build(); - + ReflectionUtils.setField(packet, "b", footerComponent); - + sendPacket(player, packet); player.setPlayerListName(name); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendBossbar(@NonNull Player player, @NonNull String title, double progress) { - try { - removeBossbar(player); - + try { + removeBossbar(player); + Location eye = player.getEyeLocation().clone(); Location location = eye.add(eye.getDirection().multiply(45)); - + float yaw = eye.getYaw(); float pitch = Math.max(-15, Math.min(15, eye.getPitch())); - + Object worldServer = getWorldServer(player.getWorld()); Object wither = new ClassInstanceBuilder( - entityWither() + entityWither() ).withParams( - Map.of( - world, - worldServer - ) + Map.of( + world, + worldServer + ) ).build(); - + entity_setInvisible.invoke(wither, - true + true ); entity_setCustomName().invoke(wither, - title + title ); entity_setCustomNameVisible().invoke(wither, - true + true ); - + float maxHealth = (float) entityLiving_getMaxHealth().invoke(wither); float newHealth = (float) Math.max(1, Math.min(maxHealth, progress * maxHealth)); entityLiving_setHealth().invoke(wither, - newHealth + newHealth ); - + entity_setLocation.invoke(wither, - location.getX(), - location.getY(), - location.getZ(), - yaw, - pitch + location.getX(), + location.getY(), + location.getZ(), + yaw, + pitch ); - + Object spawnPacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutSpawnEntityLiving" + packageNms + "PacketPlayOutSpawnEntityLiving" ).withParams( - Map.of( - entityLiving(), - wither - ) + Map.of( + entityLiving(), + wither + ) ).build(); sendPacket(player, spawnPacket); - + Object metadataPacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutEntityMetadata" + packageNms + "PacketPlayOutEntityMetadata" ).withParams( - Map.of( - int.class, - entity_getId().invoke(wither) - ), - Map.of( - dataWatcher(), - entity_getDataWatcher().invoke(wither) - ), - Map.of( - boolean.class, - true - ) + Map.of( + int.class, + entity_getId().invoke(wither) + ), + Map.of( + dataWatcher(), + entity_getDataWatcher().invoke(wither) + ), + Map.of( + boolean.class, + true + ) ).build(); sendPacket(player, metadataPacket); - + bossBars.put(player, wither); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void removeBossbar(@NonNull Player player) { - try { - Object wither = bossBars.remove(player); - if (wither != null) { - int id = (int) entity_getId().invoke(wither); - Object destroyPacket = new ClassInstanceBuilder( - packageNms + "PacketPlayOutEntityDestroy" - ).withParams( - Map.of( - int[].class, - new int[]{id} - ) - ).build(); - sendPacket(player, destroyPacket); - } - } catch (Exception e) { + try { + Object wither = bossBars.remove(player); + if (wither != null) { + int id = (int) entity_getId().invoke(wither); + Object destroyPacket = new ClassInstanceBuilder( + packageNms + "PacketPlayOutEntityDestroy" + ).withParams( + Map.of( + int[].class, + new int[] { id } + ) + ).build(); + sendPacket(player, destroyPacket); + } + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendActionbar(@NonNull Player player, @NonNull String message) { - try { - Object chatMessage = createChatComponentText(message); - Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutChat" - ).withParams( - Map.of( - iChatBaseComponent, - chatMessage - ), - Map.of( - byte.class, - (byte) 2 - ) - ).build(); - sendPacket(player, packet); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Object chatMessage = createChatComponentText(message); + Object packet = new ClassInstanceBuilder( + packageNms + "PacketPlayOutChat" + ).withParams( + Map.of( + iChatBaseComponent, + chatMessage + ), + Map.of( + byte.class, + (byte) 2 + ) + ).build(); + sendPacket(player, packet); + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { - try { - Set players = Set.of(player.getName()); - - Object createPacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).build(); - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_name(), player.getName()); - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_displayName(), player.getName()); - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_players(), players); - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_mode(), 0); - - Object updatePacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).build(); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_name(), player.getName()); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_displayName(), player.getName()); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_players(), players); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_mode(), 2); - - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_prefix(), prefix); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_prefix(), prefix); - - ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_suffix(), suffix); - ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_suffix(), suffix); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, createPacket); - sendPacket(onlinePlayer, updatePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Set players = Set.of(player.getName()); + + Object createPacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).build(); + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_name(), player.getName()); + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_displayName(), player.getName()); + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_players(), players); + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_mode(), 0); + + Object updatePacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).build(); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_name(), player.getName()); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_displayName(), player.getName()); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_players(), players); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_mode(), 2); + + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_prefix(), prefix); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_prefix(), prefix); + + ReflectionUtils.setField(createPacket, packetPlayOutScoreboardTeam_suffix(), suffix); + ReflectionUtils.setField(updatePacket, packetPlayOutScoreboardTeam_suffix(), suffix); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, createPacket); + sendPacket(onlinePlayer, updatePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public void removeNametag(@NonNull Player player) { - try { - Set players = Set.of(player.getName()); - - Object removePacket = new ClassInstanceBuilder( - packetPlayOutScoreboardTeam - ).build(); - ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_name(), player.getName()); - ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_players(), players); - ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_mode(), 4); - - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, removePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Set players = Set.of(player.getName()); + + Object removePacket = new ClassInstanceBuilder( + packetPlayOutScoreboardTeam + ).build(); + ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_name(), player.getName()); + ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_players(), players); + ReflectionUtils.setField(removePacket, packetPlayOutScoreboardTeam_mode(), 4); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, removePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch) { - player.playSound(location, org.bukkit.Sound.valueOf(sound.name()), volume, pitch); + player.playSound(location, org.bukkit.Sound.valueOf(sound.name()), volume, pitch); } - + @Override public Object getCraftPlayer(@NonNull Player player) { - return craftPlayer.cast(player); + return craftPlayer.cast(player); } - + @Override public Object getEntityPlayer(@NonNull Player player) { - try { - Object craftPlayer = getCraftPlayer(player); - return craftPlayer_getHandle.invoke(craftPlayer); - } catch (Exception e) { + try { + Object craftPlayer = getCraftPlayer(player); + return craftPlayer_getHandle.invoke(craftPlayer); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public Object getPlayerSpigot(@NonNull Player player) { - try { - return player_spigot.invoke(player); - } catch (Exception e) { + try { + return player_spigot.invoke(player); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public GameProfile getProfile(@NonNull Object entityPlayer) { - try { + try { return (GameProfile) entityHuman_profile.get(entityPlayer); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public int getPing(@NonNull Player player) { - try { - Object entityPlayer = getEntityPlayer(player); - return (int) entityPlayer_ping.get(entityPlayer); - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + return (int) entityPlayer_ping.get(entityPlayer); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void setSkin(@NonNull Player player, @NonNull UUID uuid) { - try { - Object entityPlayer = getEntityPlayer(player); - GameProfile profile = getProfile(entityPlayer); - - Collection textures = profile.getProperties().get("textures"); - if (!PlayerUtils.skins.containsKey(player.getUniqueId()) && textures != null && !textures.isEmpty()) { - PlayerUtils.skins.put(player.getUniqueId(), textures.iterator().next()); - } - - GameProfile skinProfile = GameProfileBuilder.fetch(uuid); - - profile.getProperties().removeAll("textures"); - for (Property property : skinProfile.getProperties().get("textures")) { - profile.getProperties().put("textures", property); - } - - refresh(player); - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + GameProfile profile = getProfile(entityPlayer); + + Collection textures = profile.getProperties().get("textures"); + if (!PlayerUtils.skins.containsKey(player.getUniqueId()) && textures != null && !textures.isEmpty()) { + PlayerUtils.skins.put(player.getUniqueId(), textures.iterator().next()); + } + + GameProfile skinProfile = GameProfileBuilder.fetch(uuid); + + profile.getProperties().removeAll("textures"); + for (Property property : skinProfile.getProperties().get("textures")) { + profile.getProperties().put("textures", property); + } + + refresh(player); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void resetSkin(@NonNull Player player) { - try { - Object entityPlayer = getEntityPlayer(player); - GameProfile profile = getProfile(entityPlayer); + try { + Object entityPlayer = getEntityPlayer(player); + GameProfile profile = getProfile(entityPlayer); - Property original = PlayerUtils.skins.get(player.getUniqueId()); - if (original != null) { - profile.getProperties().removeAll("textures"); - profile.getProperties().put("textures", original); + Property original = PlayerUtils.skins.get(player.getUniqueId()); + if (original != null) { + profile.getProperties().removeAll("textures"); + profile.getProperties().put("textures", original); - refresh(player); + refresh(player); - PlayerUtils.skins.remove(player.getUniqueId()); - } - } catch (Exception e) { + PlayerUtils.skins.remove(player.getUniqueId()); + } + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void setName(@NonNull Player player, @NonNull String name) { - try { - Object entityPlayer = getEntityPlayer(player); - GameProfile profile = getProfile(entityPlayer); - - PlayerUtils.names.put(player.getUniqueId(), profile.getName()); - - player.setCustomName(name); - player.setCustomNameVisible(true); - player.setDisplayName(name); - - ReflectionUtils.setField(ReflectionUtils.getField(GameProfile.class, "name"), name); - - refresh(player); - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + GameProfile profile = getProfile(entityPlayer); + + PlayerUtils.names.put(player.getUniqueId(), profile.getName()); + + player.setCustomName(name); + player.setCustomNameVisible(true); + player.setDisplayName(name); + + ReflectionUtils.setField(ReflectionUtils.getField(GameProfile.class, "name"), name); + + refresh(player); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void resetName(@NonNull Player player) { - try { - String original = PlayerUtils.names.get(player.getUniqueId()); - if (original == null) return; - - player.setCustomName(original); - player.setCustomNameVisible(true); - player.setDisplayName(original); + try { + String original = PlayerUtils.names.get(player.getUniqueId()); + if (original == null) return; + + player.setCustomName(original); + player.setCustomNameVisible(true); + player.setDisplayName(original); - ReflectionUtils.setField(ReflectionUtils.getField(GameProfile.class, "name"), original); + ReflectionUtils.setField(ReflectionUtils.getField(GameProfile.class, "name"), original); - refresh(player); + refresh(player); - PlayerUtils.names.remove(player.getUniqueId()); - } catch (Exception e) { + PlayerUtils.names.remove(player.getUniqueId()); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void refresh(@NonNull Player player) { - try { - Object entityPlayer = getEntityPlayer(player); - - Object update = packetPlayOutPlayerInfo$enumPlayerInfoAction_UPDATE_DISPLAY_NAME; - Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutPlayerInfo", - packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket" - ).withParams( - Map.of( - packetPlayOutPlayerInfo$enumPlayerInfoAction, - update - ), - Map.of( - Iterable.class, - List.of(entityPlayer) - ) - ).build(); - for (Player online : Bukkit.getOnlinePlayers()) { - sendPacket(online, packet); - } - } catch (Exception e) { + try { + Object entityPlayer = getEntityPlayer(player); + + Object update = packetPlayOutPlayerInfo$enumPlayerInfoAction_UPDATE_DISPLAY_NAME; + Object packet = new ClassInstanceBuilder( + packageNms + "PacketPlayOutPlayerInfo", + packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket" + ).withParams( + Map.of( + packetPlayOutPlayerInfo$enumPlayerInfoAction, + update + ), + Map.of( + Iterable.class, + List.of(entityPlayer) + ) + ).build(); + for (Player online : Bukkit.getOnlinePlayers()) { + sendPacket(online, packet); + } + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - try { - Object add = packetPlayOutPlayerInfo$enumPlayerInfoAction_ADD_PLAYER; - Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutPlayerInfo", - packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket" - ).withParams( - Map.of( - packetPlayOutPlayerInfo$enumPlayerInfoAction, - add - ), - Map.of( - Iterable.class, - List.of(entityPlayer) - ) - ).build(); + try { + Object add = packetPlayOutPlayerInfo$enumPlayerInfoAction_ADD_PLAYER; + Object packet = new ClassInstanceBuilder( + packageNms + "PacketPlayOutPlayerInfo", + packageNm + "network.protocol.game.ClientboundPlayerInfoUpdatePacket" + ).withParams( + Map.of( + packetPlayOutPlayerInfo$enumPlayerInfoAction, + add + ), + Map.of( + Iterable.class, + List.of(entityPlayer) + ) + ).build(); sendPacket(player, packet); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - try { - Object remove = packetPlayOutPlayerInfo$enumPlayerInfoAction_REMOVE_PLAYER(); - Object packet = new ClassInstanceBuilder( - packageNms + "PacketPlayOutPlayerInfo" - ).withParams( - Map.of( - packetPlayOutPlayerInfo$enumPlayerInfoAction, - remove - ), - Map.of( - Iterable.class, - List.of(entityPlayer) - ) - ).build(); + try { + Object remove = packetPlayOutPlayerInfo$enumPlayerInfoAction_REMOVE_PLAYER(); + Object packet = new ClassInstanceBuilder( + packageNms + "PacketPlayOutPlayerInfo" + ).withParams( + Map.of( + packetPlayOutPlayerInfo$enumPlayerInfoAction, + remove + ), + Map.of( + Iterable.class, + List.of(entityPlayer) + ) + ).build(); sendPacket(player, packet); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - try { - addEntityPlayer(player, entityPlayer); - - Object spawn = new ClassInstanceBuilder( - packageNms + "PacketPlayOutNamedEntitySpawn", - packageNm + "network.protocol.game.ClientboundAddPlayerPacket" - ).withParams( - Map.of( - entityHuman, - entityPlayer - ) - ).build(); - sendPacket(player, spawn); - - Object teleport = new ClassInstanceBuilder( - packageNms + "PacketPlayOutEntityTeleport", - packageNm + "network.protocol.game.ClientboundPlayerPositionPacket" - ).withParams( - Map.of( - entity, - entityPlayer - ) - ).build(); - sendPacket(player, teleport); - - Bukkit.getScheduler().runTask(FalchusLibMinecraftSpigot.getInstance(), () -> removeEntityPlayer(player, entityPlayer)); - } catch (Exception e) { + try { + addEntityPlayer(player, entityPlayer); + + Object spawn = new ClassInstanceBuilder( + packageNms + "PacketPlayOutNamedEntitySpawn", + packageNm + "network.protocol.game.ClientboundAddPlayerPacket" + ).withParams( + Map.of( + entityHuman, + entityPlayer + ) + ).build(); + sendPacket(player, spawn); + + Object teleport = new ClassInstanceBuilder( + packageNms + "PacketPlayOutEntityTeleport", + packageNm + "network.protocol.game.ClientboundPlayerPositionPacket" + ).withParams( + Map.of( + entity, + entityPlayer + ) + ).build(); + sendPacket(player, teleport); + + Bukkit.getScheduler().runTask(FalchusLibMinecraftSpigot.getInstance(), () -> removeEntityPlayer(player, entityPlayer)); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public Object getMcServer() { - try { - Object server = craftServer.cast(Bukkit.getServer()); - return craftServer_getServer.invoke(server); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Object server = craftServer.cast(Bukkit.getServer()); + return craftServer_getServer.invoke(server); + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public Object getBukkitServer() { - return bukkitServer.cast(Bukkit.getServer()); + return bukkitServer.cast(Bukkit.getServer()); } - + @Override public String getVersion() { - try { - Object server = getMcServer(); - return (String) minecraftServer_getVersion.invoke(server); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Object server = getMcServer(); + return (String) minecraftServer_getVersion.invoke(server); + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public double[] getRecentTps() { - try { - Object server = getMcServer(); - return (double[]) minecraftServer_recentTps.get(server); - } catch (Exception e) { - throw new RuntimeException(e); + try { + Object server = getMcServer(); + return (double[]) minecraftServer_recentTps.get(server); + } catch (Exception e) { + throw new RuntimeException(e); } } - + @Override public Object[] getWorldBiomes(@NonNull World world) { - try { + try { return (Object[]) biomeBase_biomes.get(null); - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public Object getNmsBiome(Biome biome) { - try { - int id; - if (biome == null) { - id = 1; - } else { - switch (biome.name()) { - case "BEACH": - id = 16; - break; - - case "BIRCH_FOREST": - case "BIRCH_FOREST_MOUNTAINS": - id = 27; - break; - - case "BIRCH_FOREST_HILLS": - case "BIRCH_FOREST_HILLS_MOUNTAINS": - id = 28; - break; - - case "COLD_BEACH": - id = 26; - break; - case "COLD_TAIGA": - id = 30; - break; - - case "COLD_TAIGA_HILLS": - case "COLD_TAIGA_MOUNTAINS": - id = 31; - break; - - case "DEEP_OCEAN": - id = 24; - break; - case "DESERT": - id = 2; - break; - - case "DESERT_HILLS": - case "DESERT_MOUNTAINS": - id = 17; - break; - - case "EXTREME_HILLS": - case "EXTREME_HILLS_MOUNTAINS": - id = 3; - break; - - case "EXTREME_HILLS_PLUS": - case "EXTREME_HILLS_PLUS_MOUNTAINS": - id = 20; - break; - - case "FOREST": - case "FLOWER_FOREST": - id = 4; - break; - - case "FOREST_HILLS": - id = 18; - break; - case "FROZEN_OCEAN": - id = 10; - break; - case "FROZEN_RIVER": - id = 11; - break; - case "HELL": - id = 8; - break; - case "ICE_MOUNTAINS": - id = 13; - break; - - case "ICE_PLAINS": - case "ICE_PLAINS_SPIKES": - id = 12; - break; - - case "JUNGLE": - id = 21; - break; - - case "JUNGLE_EDGE": - case "JUNGLE_EDGE_MOUNTAINS": - id = 23; - break; - - case "JUNGLE_HILLS": - case "JUNGLE_MOUNTAINS": - id = 22; - break; - - case "MEGA_TAIGA": - id = 32; - break; - case "MEGA_TAIGA_HILLS": - id = 33; - break; - - case "MESA": - case "MESA_BRYCE": - case "MESA_PLATEAU": - case "MESA_PLATEAU_FOREST": - case "MESA_PLATEAU_FOREST_MOUNTAINS": - case "MESA_PLATEAU_MOUNTAINS": - id = 37; - break; - - case "MUSHROOM_ISLAND": - id = 14; - break; - case "MUSHROOM_SHORE": - id = 15; - break; - case "OCEAN": - id = 0; - break; - - case "PLAINS": - case "SUNFLOWER_PLAINS": - id = 1; - break; - - case "RIVER": - id = 7; - break; - - case "ROOFED_FOREST": - case "ROOFED_FOREST_MOUNTAINS": - id = 29; - break; - - case "SAVANNA": - case "SAVANNA_MOUNTAINS": - id = 35; - break; - - case "SAVANNA_PLATEAU": - case "SAVANNA_PLATEAU_MOUNTAINS": - id = 36; - break; - - case "SKY": - id = 9; - break; - case "SMALL_MOUNTAINS": - id = 34; - break; - case "STONE_BEACH": - id = 25; - break; - - case "SWAMPLAND": - case "SWAMPLAND_MOUNTAINS": - id = 6; - break; - - case "TAIGA": - case "MEGA_SPRUCE_TAIGA": - case "MEGA_SPRUCE_TAIGA_HILLS": - id = 5; - break; - - case "TAIGA_HILLS": - case "TAIGA_MOUNTAINS": - id = 19; - break; - - default: - id = 1; - break; - } - } - return biomeBase_getBiome.invoke(null, - id - ); - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + int id; + if (biome == null) { + id = 1; + } else { + switch (biome.name()) { + case "BEACH": id = 16; break; + + case "BIRCH_FOREST": + case "BIRCH_FOREST_MOUNTAINS": + id = 27; + break; + + case "BIRCH_FOREST_HILLS": + case "BIRCH_FOREST_HILLS_MOUNTAINS": + id = 28; + break; + + case "COLD_BEACH": id = 26; break; + case "COLD_TAIGA": id = 30; break; + + case "COLD_TAIGA_HILLS": + case "COLD_TAIGA_MOUNTAINS": + id = 31; + break; + + case "DEEP_OCEAN": id = 24; break; + case "DESERT": id = 2; break; + + case "DESERT_HILLS": + case "DESERT_MOUNTAINS": + id = 17; + break; + + case "EXTREME_HILLS": + case "EXTREME_HILLS_MOUNTAINS": + id = 3; + break; + + case "EXTREME_HILLS_PLUS": + case "EXTREME_HILLS_PLUS_MOUNTAINS": + id = 20; + break; + + case "FOREST": + case "FLOWER_FOREST": + id = 4; + break; + + case "FOREST_HILLS": id = 18; break; + case "FROZEN_OCEAN": id = 10; break; + case "FROZEN_RIVER": id = 11; break; + case "HELL": id = 8; break; + case "ICE_MOUNTAINS": id = 13; break; + + case "ICE_PLAINS": + case "ICE_PLAINS_SPIKES": + id = 12; + break; + + case "JUNGLE": id = 21; break; + + case "JUNGLE_EDGE": + case "JUNGLE_EDGE_MOUNTAINS": + id = 23; + break; + + case "JUNGLE_HILLS": + case "JUNGLE_MOUNTAINS": + id = 22; + break; + + case "MEGA_TAIGA": id = 32; break; + case "MEGA_TAIGA_HILLS": id = 33; break; + + case "MESA": + case "MESA_BRYCE": + case "MESA_PLATEAU": + case "MESA_PLATEAU_FOREST": + case "MESA_PLATEAU_FOREST_MOUNTAINS": + case "MESA_PLATEAU_MOUNTAINS": + id = 37; + break; + + case "MUSHROOM_ISLAND": id = 14; break; + case "MUSHROOM_SHORE": id = 15; break; + case "OCEAN": id = 0; break; + + case "PLAINS": + case "SUNFLOWER_PLAINS": + id = 1; + break; + + case "RIVER": id = 7; break; + + case "ROOFED_FOREST": + case "ROOFED_FOREST_MOUNTAINS": + id = 29; + break; + + case "SAVANNA": + case "SAVANNA_MOUNTAINS": + id = 35; + break; + + case "SAVANNA_PLATEAU": + case "SAVANNA_PLATEAU_MOUNTAINS": + id = 36; + break; + + case "SKY": id = 9; break; + case "SMALL_MOUNTAINS": id = 34; break; + case "STONE_BEACH": id = 25; break; + + case "SWAMPLAND": + case "SWAMPLAND_MOUNTAINS": + id = 6; break; + + case "TAIGA": + case "MEGA_SPRUCE_TAIGA": + case "MEGA_SPRUCE_TAIGA_HILLS": + id = 5; break; + + case "TAIGA_HILLS": + case "TAIGA_MOUNTAINS": + id = 19; break; + + default: id = 1; break; + } + } + return biomeBase_getBiome.invoke(null, + id + ); + } catch (Exception e) { + throw new RuntimeException(e); + } } - + @Override public int getBiomeId(Biome biome) { Object target = getNmsBiome(biome); @@ -1251,7 +1176,7 @@ public int getBiomeId(Biome biome) { Object[] biomes = (Object[]) biomeBase_biomes.get(null); for (int i = 0; i < biomes.length; i++) { if (biomes[i] == target) { - return i; + return i; } } return 1; @@ -1259,12 +1184,12 @@ public int getBiomeId(Biome biome) { throw new RuntimeException(e); } } - + @Override public Object getWorldServer(@NonNull World world) { - try { - return craftWorld_getHandle().invoke(world); - } catch (Exception e) { + try { + return craftWorld_getHandle().invoke(world); + } catch (Exception e) { throw new RuntimeException(e); } } From 051e2273b8fec84c222d48c5dfea37513f14eaeb Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:17:09 +0200 Subject: [PATCH 214/260] Update VersionAdapterModern.java --- .../utils/version/VersionAdapterModern.java | 526 ++++++++++-------- 1 file changed, 286 insertions(+), 240 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterModern.java b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterModern.java index 78cbb834..b9db0e8f 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterModern.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionAdapterModern.java @@ -1,350 +1,396 @@ package com.falchus.lib.minecraft.spigot.utils.version; -import com.falchus.lib.minecraft.spigot.enums.Sound; -import com.falchus.lib.minecraft.spigot.utils.version.v_1_13_R1.VersionAdapter_v_1_13_R1; -import com.falchus.lib.utils.builder.ClassInstanceBuilder; -import com.falchus.lib.utils.reflection.ReflectionUtils; -import lombok.NonNull; -import lombok.SneakyThrows; +import java.lang.reflect.Array; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; -import java.lang.reflect.Array; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import com.falchus.lib.minecraft.spigot.enums.Sound; +import com.falchus.lib.minecraft.spigot.utils.version.v_1_13_R1.VersionAdapter_v_1_13_R1; +import com.falchus.lib.utils.builder.ClassInstanceBuilder; +import com.falchus.lib.utils.reflection.ReflectionUtils; + +import lombok.NonNull; +import lombok.SneakyThrows; /** - * Default adapter for all versions 1.17 – 1.20.x. (tested with 1.21.11) - *

- * 1.21.11 and 26.1.1 are handled by dedicated subclasses. + * Default adapter for all versions over 1.17. (tested with 1.21.11) */ public class VersionAdapterModern extends VersionAdapter_v_1_13_R1 { - + private Class itemMeta() { - return ReflectionUtils.getClass(packageOb + "inventory.meta.ItemMeta"); + return ReflectionUtils.getClass(packageOb + "inventory.meta.ItemMeta"); } - private Method itemStack_getItemMeta() { - return ReflectionUtils.getMethod(ItemStack.class, "getItemMeta"); + return ReflectionUtils.getMethod(ItemStack.class, "getItemMeta"); } - private Method itemStack_setItemMeta() { - return ReflectionUtils.getMethod(ItemStack.class, "setItemMeta", - itemMeta() - ); + return ReflectionUtils.getMethod(ItemStack.class, "setItemMeta", + itemMeta() + ); } - private Method itemMeta_getPDC() { - return ReflectionUtils.getMethod(itemMeta(), "getPersistentDataContainer"); + return ReflectionUtils.getMethod(itemMeta(), "getPersistentDataContainer"); } - private Class namespacedKey() { - return ReflectionUtils.getClass(packageOb + "NamespacedKey"); + return ReflectionUtils.getClass(packageOb + "NamespacedKey"); } - private Class persistentDataType() { - return ReflectionUtils.getClass(packageOb + "persistence.PersistentDataType"); + return ReflectionUtils.getClass(packageOb + "persistence.PersistentDataType"); } - @SneakyThrows - private Object persistentDataType_STRING() throws IllegalAccessException { - return ReflectionUtils.getField(persistentDataType(), "STRING").get(null); + private Object persistentDataType_STRING() { + return ReflectionUtils.getField(persistentDataType(), "STRING").get(null); } - private Class persistentDataContainer() { - return ReflectionUtils.getClass(packageOb + "persistence.PersistentDataContainer"); + return ReflectionUtils.getClass(packageOb + "persistence.PersistentDataContainer"); } - private Method persistentDataContainer_set() { - return ReflectionUtils.getMethod(persistentDataContainer(), "set", - namespacedKey(), - persistentDataType(), - Object.class - ); + return ReflectionUtils.getMethod(persistentDataContainer(), "set", + namespacedKey(), + persistentDataType(), + Object.class + ); } - private Method persistentDataContainer_get() { - return ReflectionUtils.getMethod(persistentDataContainer(), "get", - namespacedKey(), - persistentDataType() - ); + return ReflectionUtils.getMethod(persistentDataContainer(), "get", + namespacedKey(), + persistentDataType() + ); } - private Method persistentDataContainer_remove() { - return ReflectionUtils.getMethod(persistentDataContainer(), "remove", - namespacedKey() - ); + return ReflectionUtils.getMethod(persistentDataContainer(), "remove", + namespacedKey() + ); } - + private Class clientboundPlayerInfoRemovePacket() { - return ReflectionUtils.getClass(packageNm + "network.protocol.game.ClientboundPlayerInfoRemovePacket"); + return ReflectionUtils.getClass(packageNm + "network.protocol.game.ClientboundPlayerInfoRemovePacket"); } private Method chatComponentText_literal() { - return ReflectionUtils.getMethod(chatComponentText, "literal", - String.class - ); + return ReflectionUtils.getMethod(chatComponentText, "literal", + String.class + ); } - private Class bossBar() { - return ReflectionUtils.getClass(packageOb + "boss.BossBar"); + return ReflectionUtils.getClass(packageOb + "boss.BossBar"); } - private Method bossBar_setProgress() { - return ReflectionUtils.getMethod(bossBar(), "setProgress", - double.class - ); + return ReflectionUtils.getMethod(bossBar(), "setProgress", + double.class + ); } - private Method bossBar_addPlayer() { - return ReflectionUtils.getMethod(bossBar(), "addPlayer", - Player.class - ); + return ReflectionUtils.getMethod(bossBar(), "addPlayer", + Player.class + ); } - private Method bossBar_removeBossBar() { - return ReflectionUtils.getMethod(bukkitServer, "removeBossBar", - namespacedKey() - ); + return ReflectionUtils.getMethod(bukkitServer, "removeBossBar", + namespacedKey() + ); } - private Class barColor() { - return ReflectionUtils.getClass(packageOb + "boss.BarColor"); + return ReflectionUtils.getClass(packageOb + "boss.BarColor"); } - @SneakyThrows - private Object barColor_WHITE() throws IllegalAccessException { - return ReflectionUtils.getField(barColor(), "WHITE").get(null); + private Object barColor_WHITE() { + return ReflectionUtils.getField(barColor(), "WHITE").get(null); } - private Class barStyle() { - return ReflectionUtils.getClass(packageOb + "boss.BarStyle"); + return ReflectionUtils.getClass(packageOb + "boss.BarStyle"); } - @SneakyThrows - private Object barStyle_SOLID() throws IllegalAccessException { - return ReflectionUtils.getField(barStyle(), "SOLID").get(null); + private Object barStyle_SOLID() { + return ReflectionUtils.getField(barStyle(), "SOLID").get(null); } - private Class bossFlag() { - return ReflectionUtils.getClass(packageOb + "boss.BarFlag"); + return ReflectionUtils.getClass(packageOb + "boss.BarFlag"); } - private Method bukkitServer_createBossBar() { - return ReflectionUtils.getMethod(bukkitServer, "createBossBar", - namespacedKey(), - String.class, - barColor(), - barStyle(), - Array.newInstance(bossFlag(), 0).getClass() - ); + return ReflectionUtils.getMethod(bukkitServer, "createBossBar", + namespacedKey(), + String.class, + barColor(), + barStyle(), + Array.newInstance(bossFlag(), 0).getClass() + ); } - private Method packetPlayOutScoreboardTeam_createAddOrModifyPacket() { - return ReflectionUtils.getMethod(packetPlayOutScoreboardTeam, "createAddOrModifyPacket", - scoreboardTeam, - boolean.class - ); + return ReflectionUtils.getMethod(packetPlayOutScoreboardTeam, "createAddOrModifyPacket", + scoreboardTeam, + boolean.class + ); } - private Method packetPlayOutScoreboardTeam_createRemovePacket() { - return ReflectionUtils.getMethod(packetPlayOutScoreboardTeam, "createRemovePacket", - scoreboardTeam - ); - } - - private Class clientboundSetTitleTextPacket() { - return ReflectionUtils.getClass(packageNm + "network.protocol.game.ClientboundSetTitleTextPacket"); - } - - private Class clientboundSetSubtitleTextPacket() { - return ReflectionUtils.getClass(packageNm + "network.protocol.game.ClientboundSetSubtitleTextPacket"); - } - - @Override - public Object createChatComponentText(@NonNull String text) { - try { - return chatComponentText_literal().invoke(null, text); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @Override - public void sendTitle(@NonNull Player player, String title, String subtitle) { - try { - title = title != null ? title : ""; - subtitle = subtitle != null ? subtitle : ""; - - Object titlePacket = new ClassInstanceBuilder( - clientboundSetTitleTextPacket() - ).withParams( - Map.of(iChatBaseComponent, createChatComponentText(title)) - ).build(); - sendPacket(player, titlePacket); - - Object subtitlePacket = new ClassInstanceBuilder( - clientboundSetSubtitleTextPacket() - ).withParams( - Map.of(iChatBaseComponent, createChatComponentText(subtitle)) - ).build(); - sendPacket(player, subtitlePacket); - } catch (Exception e) { + return ReflectionUtils.getMethod(packetPlayOutScoreboardTeam, "createRemovePacket", + scoreboardTeam + ); + } + + @Override + public Object createChatComponentText(@NonNull String text) { + try { + return chatComponentText_literal().invoke(null, + text + ); + } catch (Exception e) { throw new RuntimeException(e); } - } - - @Override + } + + @Override public ItemStack setUUID(@NonNull ItemStack item, UUID uuid) { - try { - Object meta = itemStack_getItemMeta().invoke(item); - if (meta == null) return item; - + try { + Object meta = itemStack_getItemMeta().invoke(item); + if (meta == null) return item; + Object pdc = itemMeta_getPDC().invoke(meta); - Object key = new ClassInstanceBuilder(namespacedKey()).withParams( - Map.of(Plugin.class, plugin), - Map.of(String.class, "UUID") + Object key = new ClassInstanceBuilder( + namespacedKey() + ).withParams( + Map.of( + Plugin.class, + plugin + ), + Map.of( + String.class, + "UUID" + ) ).build(); - - if (uuid == null) { - persistentDataContainer_remove().invoke(pdc, key); - } else { - persistentDataContainer_set().invoke(pdc, key, persistentDataType_STRING(), uuid.toString()); - } - itemStack_setItemMeta().invoke(item, meta); + + if (uuid == null) { + persistentDataContainer_remove().invoke(pdc, + key + ); + } else { + persistentDataContainer_set().invoke(pdc, + key, + persistentDataType_STRING(), + uuid.toString() + ); + } + itemStack_setItemMeta().invoke(item, + meta + ); return item; - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public UUID getUUID(@NonNull ItemStack item) { - try { + try { Object meta = itemStack_getItemMeta().invoke(item); if (meta == null) return null; - + Object pdc = itemMeta_getPDC().invoke(meta); - Object key = new ClassInstanceBuilder(namespacedKey()).withParams( - Map.of(Plugin.class, plugin), - Map.of(String.class, "UUID") + Object key = new ClassInstanceBuilder( + namespacedKey() + ).withParams( + Map.of( + Plugin.class, + plugin + ), + Map.of( + String.class, + "UUID" + ) ).build(); - Object uuid = persistentDataContainer_get().invoke(pdc, key, persistentDataType_STRING()); + Object uuid = persistentDataContainer_get().invoke(pdc, + key, + persistentDataType_STRING() + ); + return uuid != null ? UUID.fromString((String) uuid) : null; - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public ItemStack clearNBT(@NonNull ItemStack item) { - try { + try { Object meta = itemStack_getItemMeta().invoke(item); if (meta == null) return item; - + Object pdc = itemMeta_getPDC().invoke(meta); - Object key = new ClassInstanceBuilder(namespacedKey()).withParams( - Map.of(Plugin.class, plugin), - Map.of(String.class, "UUID") + Object key = new ClassInstanceBuilder( + namespacedKey() + ).withParams( + Map.of( + Plugin.class, + plugin + ), + Map.of( + String.class, + "UUID" + ) ).build(); - persistentDataContainer_remove().invoke(pdc, key); - itemStack_setItemMeta().invoke(item, meta); + persistentDataContainer_remove().invoke(pdc, + key + ); + + itemStack_setItemMeta().invoke(item, + meta + ); return item; - } catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendBossbar(@NonNull Player player, @NonNull String title, double progress) { - try { - removeBossbar(player); - - Object key = new ClassInstanceBuilder(namespacedKey()).withParams( - Map.of(Plugin.class, plugin), - Map.of(String.class, "Bossbar_" + player.getUniqueId()) + try { + removeBossbar(player); + + Object key = new ClassInstanceBuilder( + namespacedKey() + ).withParams( + Map.of( + Plugin.class, + plugin + ), + Map.of( + String.class, + "Bossbar_" + player.getUniqueId() + ) ).build(); - - Object bossBar = bukkitServer_createBossBar().invoke(getBukkitServer(), - key, title, barColor_WHITE(), barStyle_SOLID(), Array.newInstance(bossFlag(), 0) - ); - bossBar_setProgress().invoke(bossBar, progress); - bossBar_addPlayer().invoke(bossBar, player); - bossBars.put(player, key); - } catch (Exception e) { + + Object bossBar = bukkitServer_createBossBar().invoke(getBukkitServer(), + key, + title, + barColor_WHITE(), + barStyle_SOLID(), + Array.newInstance(bossFlag(), 0) + ); + + bossBar_setProgress().invoke(bossBar, + progress + ); + bossBar_addPlayer().invoke(bossBar, + player + ); + + bossBars.put(player, key); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void removeBossbar(@NonNull Player player) { - try { - Object key = bossBars.remove(player); - if (key == null) return; - bossBar_removeBossBar().invoke(getBukkitServer(), key); - } catch (Exception e) { + try { + Object key = bossBars.remove(player); + if (key == null) return; + + bossBar_removeBossBar().invoke(getBukkitServer(), + key + ); + } catch (Exception e) { throw new RuntimeException(e); } } - + @Override public void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { - try { - Object team = new ClassInstanceBuilder(scoreboardTeam).withParams( - Map.of(scoreboard, scoreboardINST), - Map.of(String.class, player.getName()) - ).build(); - scoreboardTeam_setDisplayName().invoke(team, createChatComponentText(player.getName())); - scoreboardTeam_setPrefix().invoke(team, createChatComponentText(prefix)); - scoreboardTeam_setSuffix().invoke(team, createChatComponentText(suffix)); - - Object createPacket = packetPlayOutScoreboardTeam_createAddOrModifyPacket().invoke(null, team, false); - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, createPacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - + try { + Object team = new ClassInstanceBuilder( + scoreboardTeam + ).withParams( + Map.of( + scoreboard, + scoreboardINST + ), + Map.of( + String.class, + player.getName() + ) + ).build(); + scoreboardTeam_setDisplayName().invoke(team, + createChatComponentText(player.getName()) + ); + scoreboardTeam_setPrefix().invoke(team, + createChatComponentText(prefix) + ); + scoreboardTeam_setSuffix().invoke(team, + createChatComponentText(suffix) + ); + + Object createPacket = packetPlayOutScoreboardTeam_createAddOrModifyPacket().invoke(null, + team, + false + ); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, createPacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Override public void removeNametag(@NonNull Player player) { - try { - Object team = new ClassInstanceBuilder(scoreboardTeam).withParams( - Map.of(scoreboard, scoreboardINST), - Map.of(String.class, player.getName()) - ).build(); - scoreboardTeam_setDisplayName().invoke(team, createChatComponentText(player.getName())); - - Object removePacket = packetPlayOutScoreboardTeam_createRemovePacket().invoke(null, team); - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - sendPacket(onlinePlayer, removePacket); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - + try { + Object team = new ClassInstanceBuilder( + scoreboardTeam + ).withParams( + Map.of( + scoreboard, + scoreboardINST + ), + Map.of( + String.class, + player.getName() + ) + ).build(); + scoreboardTeam_setDisplayName().invoke(team, + createChatComponentText(player.getName()) + ); + + Object removePacket = packetPlayOutScoreboardTeam_createRemovePacket().invoke(null, + team + ); + + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + sendPacket(onlinePlayer, removePacket); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Override public void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch) { - player.playSound(location, org.bukkit.Sound.valueOf(sound.getModernName()), volume, pitch); - } - - @Override - public void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - try { - UUID uuid = getProfile(entityPlayer).getId(); - Object packet = new ClassInstanceBuilder(clientboundPlayerInfoRemovePacket()).withParams( - Map.of(List.class, List.of(uuid)) - ).build(); - sendPacket(player, packet); - } catch (Exception e) { + player.playSound(location, org.bukkit.Sound.valueOf(sound.getModernName()), volume, pitch); + } + + @Override + public void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + try { + UUID uuid = getProfile(entityPlayer).getId(); + Object packet = new ClassInstanceBuilder( + clientboundPlayerInfoRemovePacket() + ).withParams( + Map.of( + List.class, + List.of(uuid) + ) + ).build(); + sendPacket(player, packet); + } catch (Exception e) { throw new RuntimeException(e); } - } -} \ No newline at end of file + } +} From 7df1826441876e6345c339266ca841c8dec22db1 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:17:33 +0200 Subject: [PATCH 215/260] Update EntityUtils.java --- .../minecraft/spigot/utils/EntityUtils.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/EntityUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/EntityUtils.java index aefe660c..8cddfe95 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/EntityUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/EntityUtils.java @@ -1,24 +1,26 @@ package com.falchus.lib.minecraft.spigot.utils; +import org.bukkit.entity.Entity; + import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; + import lombok.NonNull; import lombok.experimental.UtilityClass; -import org.bukkit.entity.Entity; @UtilityClass public class EntityUtils { - /** - * @return {@link Entity} - */ - public static Entity getBukkitEntity(@NonNull Object entity) { - return VersionProvider.get().getBukkitEntity(entity); - } - - /** - * Sets yaw and pitch. - */ - public static void setYawPitch(@NonNull Object entity, float yaw, float pitch) { - VersionProvider.get().setYawPitch(entity, yaw, pitch); - } -} \ No newline at end of file + /** + * @return {@link Entity} + */ + public static Entity getBukkitEntity(@NonNull Object entity) { + return VersionProvider.get().getBukkitEntity(entity); + } + + /** + * Sets yaw and pitch. + */ + public static void setYawPitch(@NonNull Object entity, float yaw, float pitch) { + VersionProvider.get().setYawPitch(entity, yaw, pitch); + } +} From 96dc9857e5ba03d4288d0e40086ffb5dd711a447 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:17:44 +0200 Subject: [PATCH 216/260] Update ItemUtils.java --- .../lib/minecraft/spigot/utils/ItemUtils.java | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/ItemUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/ItemUtils.java index 7c2db13c..78ed489f 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/ItemUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/ItemUtils.java @@ -1,9 +1,10 @@ package com.falchus.lib.minecraft.spigot.utils; -import com.falchus.lib.interfaces.consumer.TriConsumer; -import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; -import lombok.NonNull; -import lombok.experimental.UtilityClass; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.*; +import java.util.function.Consumer; + import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -13,17 +14,16 @@ import org.bukkit.util.io.BukkitObjectOutputStream; import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.function.Consumer; +import com.falchus.lib.interfaces.consumer.TriConsumer; +import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; + +import lombok.NonNull; +import lombok.experimental.UtilityClass; @UtilityClass public class ItemUtils { - - public static final Map> itemActions = new HashMap<>(); + + public static final Map> itemActions = new HashMap<>(); public static final Map> itemActionsInventory = new HashMap<>(); public static final Map> inventoryCallbacks = new HashMap<>(); @@ -33,60 +33,60 @@ public class ItemUtils { /** * Sets a UUID on the given item via NBT. */ - public static ItemStack setUUID(@NonNull ItemStack item, UUID uuid) { - return VersionProvider.get().setUUID(item, uuid); + public static ItemStack setUUID(@NonNull ItemStack item, UUID uuid) { + return VersionProvider.get().setUUID(item, uuid); } /** * Retrieves the UUID stores on the given item. */ public static UUID getUUID(@NonNull ItemStack item) { - return VersionProvider.get().getUUID(item); + return VersionProvider.get().getUUID(item); } - + /** * Removes all NBT tags from the item. */ public static ItemStack clearNBT(@NonNull ItemStack item) { - return VersionProvider.get().clearNBT(item); + return VersionProvider.get().clearNBT(item); } - + /** * Gets an array of ItemStacks from a Base64 String. */ public static ItemStack[] itemStackArrayFromBase64(String base64) { - try { - ByteArrayInputStream stream = new ByteArrayInputStream(Base64Coder.decodeLines(base64)); - BukkitObjectInputStream input = new BukkitObjectInputStream(stream); - - ItemStack[] items = new ItemStack[input.readInt()]; - for (int i = 0; i < items.length; i++) { - items[i] = (ItemStack) input.readObject(); - } - return items; - } catch (Exception e) { - e.printStackTrace(); - } - return new ItemStack[0]; + try { + ByteArrayInputStream stream = new ByteArrayInputStream(Base64Coder.decodeLines(base64)); + BukkitObjectInputStream input = new BukkitObjectInputStream(stream); + + ItemStack[] items = new ItemStack[input.readInt()]; + for (int i = 0; i < items.length; i++) { + items[i] = (ItemStack) input.readObject(); + } + return items; + } catch (Exception e) { + e.printStackTrace(); + } + return new ItemStack[0]; } - + /** * Converts an array of ItemStacks to a Base64 String. */ public static String itemStackArrayToBase64(ItemStack[] items) { - try { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - BukkitObjectOutputStream output = new BukkitObjectOutputStream(stream); - - output.writeInt(items.length); - for (ItemStack item : items) { - output.writeObject(item); + try { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + BukkitObjectOutputStream output = new BukkitObjectOutputStream(stream); + + output.writeInt(items.length); + for (ItemStack item : items) { + output.writeObject(item); } - return Base64Coder.encodeLines(stream.toByteArray()); - } catch (Exception e) { - e.printStackTrace(); - } - return null; + return Base64Coder.encodeLines(stream.toByteArray()); + } catch (Exception e) { + e.printStackTrace(); + } + return null; } /** @@ -106,4 +106,4 @@ public InventoryItem(int slot, @NonNull ItemStack item, Consumer onInven this.onInventoryClick = onInventoryClick; } } -} \ No newline at end of file +} From e186bf4509b8691ee3258696a682988cc55749b4 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:17:55 +0200 Subject: [PATCH 217/260] Update Metrics.java --- .../lib/minecraft/spigot/utils/Metrics.java | 1584 +++++++++-------- 1 file changed, 794 insertions(+), 790 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/Metrics.java b/src/com/falchus/lib/minecraft/spigot/utils/Metrics.java index d1010696..18d6bc45 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/Metrics.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/Metrics.java @@ -14,17 +14,22 @@ */ package com.falchus.lib.minecraft.spigot.utils; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import javax.net.ssl.HttpsURLConnection; -import java.io.*; +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; import java.lang.reflect.Method; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -35,867 +40,866 @@ import java.util.logging.Level; import java.util.stream.Collectors; import java.util.zip.GZIPOutputStream; +import javax.net.ssl.HttpsURLConnection; +import org.bukkit.Bukkit; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; public class Metrics { - private final Plugin plugin; + private final Plugin plugin; + + private final MetricsBase metricsBase; + + /** + * Creates a new Metrics instance. + * + * @param plugin Your plugin instance. + * @param serviceId The id of the service. It can be found at What is my plugin id? + */ + public Metrics(Plugin plugin, int serviceId) { + this.plugin = plugin; + // Get the config file + File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats"); + File configFile = new File(bStatsFolder, "config.yml"); + YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); + if (!config.isSet("serverUuid")) { + config.addDefault("enabled", true); + config.addDefault("serverUuid", UUID.randomUUID().toString()); + config.addDefault("logFailedRequests", false); + config.addDefault("logSentData", false); + config.addDefault("logResponseStatusText", false); + // Inform the server owners about bStats + config + .options() + .header( + "bStats (https://bStats.org) collects some basic information for plugin authors, like how\n" + + "many people use their plugin and their total player count. It's recommended to keep bStats\n" + + "enabled, but if you're not comfortable with this, you can turn this setting off. There is no\n" + + "performance penalty associated with having metrics enabled, and data sent to bStats is fully\n" + + "anonymous.") + .copyDefaults(true); + try { + config.save(configFile); + } catch (IOException ignored) { + } + } + // Load the data + boolean enabled = config.getBoolean("enabled", true); + String serverUUID = config.getString("serverUuid"); + boolean logErrors = config.getBoolean("logFailedRequests", false); + boolean logSentData = config.getBoolean("logSentData", false); + boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false); + boolean isFolia = false; + try { + isFolia = Class.forName("io.papermc.paper.threadedregions.RegionizedServer") != null; + } catch (Exception e) { + } + metricsBase = + new // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + // See https://github.com/Bastian/bstats-metrics/pull/126 + MetricsBase( + "bukkit", + serverUUID, + serviceId, + enabled, + this::appendPlatformData, + this::appendServiceData, + isFolia + ? null + : submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask), + plugin::isEnabled, + (message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error), + (message) -> this.plugin.getLogger().log(Level.INFO, message), + logErrors, + logSentData, + logResponseStatusText, + false); + } + + /** Shuts down the underlying scheduler service. */ + public void shutdown() { + metricsBase.shutdown(); + } + + /** + * Adds a custom chart. + * + * @param chart The chart to add. + */ + public void addCustomChart(CustomChart chart) { + metricsBase.addCustomChart(chart); + } + + private void appendPlatformData(JsonObjectBuilder builder) { + builder.appendField("playerAmount", getPlayerAmount()); + builder.appendField("onlineMode", Bukkit.getOnlineMode() ? 1 : 0); + builder.appendField("bukkitVersion", Bukkit.getVersion()); + builder.appendField("bukkitName", Bukkit.getName()); + builder.appendField("javaVersion", System.getProperty("java.version")); + builder.appendField("osName", System.getProperty("os.name")); + builder.appendField("osArch", System.getProperty("os.arch")); + builder.appendField("osVersion", System.getProperty("os.version")); + builder.appendField("coreCount", Runtime.getRuntime().availableProcessors()); + } + + private void appendServiceData(JsonObjectBuilder builder) { + builder.appendField("pluginVersion", plugin.getDescription().getVersion()); + } + + private int getPlayerAmount() { + try { + // Around MC 1.8 the return type was changed from an array to a collection, + // This fixes java.lang.NoSuchMethodError: + // org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection; + Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers"); + return onlinePlayersMethod.getReturnType().equals(Collection.class) + ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() + : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; + } catch (Exception e) { + // Just use the new method if the reflection failed + return Bukkit.getOnlinePlayers().size(); + } + } + + public static class MetricsBase { + + /** The version of the Metrics class. */ + public static final String METRICS_VERSION = "3.1.0"; + + private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s"; + + private final ScheduledExecutorService scheduler; + + private final String platform; + + private final String serverUuid; + + private final int serviceId; + + private final Consumer appendPlatformDataConsumer; + + private final Consumer appendServiceDataConsumer; + + private final Consumer submitTaskConsumer; + + private final Supplier checkServiceEnabledSupplier; + + private final BiConsumer errorLogger; - private final MetricsBase metricsBase; + private final Consumer infoLogger; + + private final boolean logErrors; + + private final boolean logSentData; + + private final boolean logResponseStatusText; + + private final Set customCharts = new HashSet<>(); + + private final boolean enabled; /** - * Creates a new Metrics instance. + * Creates a new MetricsBase class instance. * - * @param plugin Your plugin instance. - * @param serviceId The id of the service. It can be found at What is my plugin id? + * @param platform The platform of the service. + * @param serviceId The id of the service. + * @param serverUuid The server uuid. + * @param enabled Whether or not data sending is enabled. + * @param appendPlatformDataConsumer A consumer that receives a {@code JsonObjectBuilder} and + * appends all platform-specific data. + * @param appendServiceDataConsumer A consumer that receives a {@code JsonObjectBuilder} and + * appends all service-specific data. + * @param submitTaskConsumer A consumer that takes a runnable with the submit task. This can be + * used to delegate the data collection to a another thread to prevent errors caused by + * concurrency. Can be {@code null}. + * @param checkServiceEnabledSupplier A supplier to check if the service is still enabled. + * @param errorLogger A consumer that accepts log message and an error. + * @param infoLogger A consumer that accepts info log messages. + * @param logErrors Whether or not errors should be logged. + * @param logSentData Whether or not the sent data should be logged. + * @param logResponseStatusText Whether or not the response status text should be logged. + * @param skipRelocateCheck Whether or not the relocate check should be skipped. */ - public Metrics(Plugin plugin, int serviceId) { - this.plugin = plugin; - // Get the config file - File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats"); - File configFile = new File(bStatsFolder, "config.yml"); - YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); - if (!config.isSet("serverUuid")) { - config.addDefault("enabled", true); - config.addDefault("serverUuid", UUID.randomUUID().toString()); - config.addDefault("logFailedRequests", false); - config.addDefault("logSentData", false); - config.addDefault("logResponseStatusText", false); - // Inform the server owners about bStats - config - .options() - .header( - "bStats (https://bStats.org) collects some basic information for plugin authors, like how\n" - + "many people use their plugin and their total player count. It's recommended to keep bStats\n" - + "enabled, but if you're not comfortable with this, you can turn this setting off. There is no\n" - + "performance penalty associated with having metrics enabled, and data sent to bStats is fully\n" - + "anonymous.") - .copyDefaults(true); - try { - config.save(configFile); - } catch (IOException ignored) { - } - } - // Load the data - boolean enabled = config.getBoolean("enabled", true); - String serverUUID = config.getString("serverUuid"); - boolean logErrors = config.getBoolean("logFailedRequests", false); - boolean logSentData = config.getBoolean("logSentData", false); - boolean logResponseStatusText = config.getBoolean("logResponseStatusText", false); - boolean isFolia = false; - try { - isFolia = Class.forName("io.papermc.paper.threadedregions.RegionizedServer") != null; - } catch (Exception e) { - } - metricsBase = - new // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - // See https://github.com/Bastian/bstats-metrics/pull/126 - MetricsBase( - "bukkit", - serverUUID, - serviceId, - enabled, - this::appendPlatformData, - this::appendServiceData, - isFolia - ? null - : submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask), - plugin::isEnabled, - (message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error), - (message) -> this.plugin.getLogger().log(Level.INFO, message), - logErrors, - logSentData, - logResponseStatusText, - false); + public MetricsBase( + String platform, + String serverUuid, + int serviceId, + boolean enabled, + Consumer appendPlatformDataConsumer, + Consumer appendServiceDataConsumer, + Consumer submitTaskConsumer, + Supplier checkServiceEnabledSupplier, + BiConsumer errorLogger, + Consumer infoLogger, + boolean logErrors, + boolean logSentData, + boolean logResponseStatusText, + boolean skipRelocateCheck) { + ScheduledThreadPoolExecutor scheduler = + new ScheduledThreadPoolExecutor( + 1, + task -> { + Thread thread = new Thread(task, "bStats-Metrics"); + thread.setDaemon(true); + return thread; + }); + // We want delayed tasks (non-periodic) that will execute in the future to be + // cancelled when the scheduler is shutdown. + // Otherwise, we risk preventing the server from shutting down even when + // MetricsBase#shutdown() is called + scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); + this.scheduler = scheduler; + this.platform = platform; + this.serverUuid = serverUuid; + this.serviceId = serviceId; + this.enabled = enabled; + this.appendPlatformDataConsumer = appendPlatformDataConsumer; + this.appendServiceDataConsumer = appendServiceDataConsumer; + this.submitTaskConsumer = submitTaskConsumer; + this.checkServiceEnabledSupplier = checkServiceEnabledSupplier; + this.errorLogger = errorLogger; + this.infoLogger = infoLogger; + this.logErrors = logErrors; + this.logSentData = logSentData; + this.logResponseStatusText = logResponseStatusText; + if (!skipRelocateCheck) { + checkRelocation(); + } + if (enabled) { + // WARNING: Removing the option to opt-out will get your plugin banned from + // bStats + startSubmitting(); + } + } + + public void addCustomChart(CustomChart chart) { + this.customCharts.add(chart); } - /** - * Shuts down the underlying scheduler service. - */ public void shutdown() { - metricsBase.shutdown(); + scheduler.shutdown(); } - /** - * Adds a custom chart. - * - * @param chart The chart to add. - */ - public void addCustomChart(CustomChart chart) { - metricsBase.addCustomChart(chart); - } - - private void appendPlatformData(JsonObjectBuilder builder) { - builder.appendField("playerAmount", getPlayerAmount()); - builder.appendField("onlineMode", Bukkit.getOnlineMode() ? 1 : 0); - builder.appendField("bukkitVersion", Bukkit.getVersion()); - builder.appendField("bukkitName", Bukkit.getName()); - builder.appendField("javaVersion", System.getProperty("java.version")); - builder.appendField("osName", System.getProperty("os.name")); - builder.appendField("osArch", System.getProperty("os.arch")); - builder.appendField("osVersion", System.getProperty("os.version")); - builder.appendField("coreCount", Runtime.getRuntime().availableProcessors()); - } - - private void appendServiceData(JsonObjectBuilder builder) { - builder.appendField("pluginVersion", plugin.getDescription().getVersion()); - } - - private int getPlayerAmount() { - try { - // Around MC 1.8 the return type was changed from an array to a collection, - // This fixes java.lang.NoSuchMethodError: - // org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection; - Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers"); - return onlinePlayersMethod.getReturnType().equals(Collection.class) - ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() - : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; - } catch (Exception e) { - // Just use the new method if the reflection failed - return Bukkit.getOnlinePlayers().size(); - } + private void startSubmitting() { + final Runnable submitTask = + () -> { + if (!enabled || !checkServiceEnabledSupplier.get()) { + // Submitting data or service is disabled + scheduler.shutdown(); + return; + } + if (submitTaskConsumer != null) { + submitTaskConsumer.accept(this::submitData); + } else { + this.submitData(); + } + }; + // Many servers tend to restart at a fixed time at xx:00 which causes an uneven + // distribution of requests on the + // bStats backend. To circumvent this problem, we introduce some randomness into + // the initial and second delay. + // WARNING: You must not modify and part of this Metrics class, including the + // submit delay or frequency! + // WARNING: Modifying this code will get your plugin banned on bStats. Just + // don't do it! + long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3)); + long secondDelay = (long) (1000 * 60 * (Math.random() * 30)); + scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS); + scheduler.scheduleAtFixedRate( + submitTask, initialDelay + secondDelay, 1000 * 60 * 30, TimeUnit.MILLISECONDS); } - public static class MetricsBase { - - /** - * The version of the Metrics class. - */ - public static final String METRICS_VERSION = "3.1.0"; - - private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s"; - - private final ScheduledExecutorService scheduler; - - private final String platform; - - private final String serverUuid; - - private final int serviceId; - - private final Consumer appendPlatformDataConsumer; - - private final Consumer appendServiceDataConsumer; - - private final Consumer submitTaskConsumer; - - private final Supplier checkServiceEnabledSupplier; - - private final BiConsumer errorLogger; - - private final Consumer infoLogger; - - private final boolean logErrors; - - private final boolean logSentData; - - private final boolean logResponseStatusText; - - private final Set customCharts = new HashSet<>(); - - private final boolean enabled; - - /** - * Creates a new MetricsBase class instance. - * - * @param platform The platform of the service. - * @param serviceId The id of the service. - * @param serverUuid The server uuid. - * @param enabled Whether or not data sending is enabled. - * @param appendPlatformDataConsumer A consumer that receives a {@code JsonObjectBuilder} and - * appends all platform-specific data. - * @param appendServiceDataConsumer A consumer that receives a {@code JsonObjectBuilder} and - * appends all service-specific data. - * @param submitTaskConsumer A consumer that takes a runnable with the submit task. This can be - * used to delegate the data collection to a another thread to prevent errors caused by - * concurrency. Can be {@code null}. - * @param checkServiceEnabledSupplier A supplier to check if the service is still enabled. - * @param errorLogger A consumer that accepts log message and an error. - * @param infoLogger A consumer that accepts info log messages. - * @param logErrors Whether or not errors should be logged. - * @param logSentData Whether or not the sent data should be logged. - * @param logResponseStatusText Whether or not the response status text should be logged. - * @param skipRelocateCheck Whether or not the relocate check should be skipped. - */ - public MetricsBase( - String platform, - String serverUuid, - int serviceId, - boolean enabled, - Consumer appendPlatformDataConsumer, - Consumer appendServiceDataConsumer, - Consumer submitTaskConsumer, - Supplier checkServiceEnabledSupplier, - BiConsumer errorLogger, - Consumer infoLogger, - boolean logErrors, - boolean logSentData, - boolean logResponseStatusText, - boolean skipRelocateCheck) { - ScheduledThreadPoolExecutor scheduler = - new ScheduledThreadPoolExecutor( - 1, - task -> { - Thread thread = new Thread(task, "bStats-Metrics"); - thread.setDaemon(true); - return thread; - }); - // We want delayed tasks (non-periodic) that will execute in the future to be - // cancelled when the scheduler is shutdown. - // Otherwise, we risk preventing the server from shutting down even when - // MetricsBase#shutdown() is called - scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); - this.scheduler = scheduler; - this.platform = platform; - this.serverUuid = serverUuid; - this.serviceId = serviceId; - this.enabled = enabled; - this.appendPlatformDataConsumer = appendPlatformDataConsumer; - this.appendServiceDataConsumer = appendServiceDataConsumer; - this.submitTaskConsumer = submitTaskConsumer; - this.checkServiceEnabledSupplier = checkServiceEnabledSupplier; - this.errorLogger = errorLogger; - this.infoLogger = infoLogger; - this.logErrors = logErrors; - this.logSentData = logSentData; - this.logResponseStatusText = logResponseStatusText; - if (!skipRelocateCheck) { - checkRelocation(); - } - if (enabled) { - // WARNING: Removing the option to opt-out will get your plugin banned from - // bStats - startSubmitting(); - } - } + private void submitData() { + final JsonObjectBuilder baseJsonBuilder = new JsonObjectBuilder(); + appendPlatformDataConsumer.accept(baseJsonBuilder); + final JsonObjectBuilder serviceJsonBuilder = new JsonObjectBuilder(); + appendServiceDataConsumer.accept(serviceJsonBuilder); + JsonObjectBuilder.JsonObject[] chartData = + customCharts.stream() + .map(customChart -> customChart.getRequestJsonObject(errorLogger, logErrors)) + .filter(Objects::nonNull) + .toArray(JsonObjectBuilder.JsonObject[]::new); + serviceJsonBuilder.appendField("id", serviceId); + serviceJsonBuilder.appendField("customCharts", chartData); + baseJsonBuilder.appendField("service", serviceJsonBuilder.build()); + baseJsonBuilder.appendField("serverUUID", serverUuid); + baseJsonBuilder.appendField("metricsVersion", METRICS_VERSION); + JsonObjectBuilder.JsonObject data = baseJsonBuilder.build(); + scheduler.execute( + () -> { + try { + // Send the data + sendData(data); + } catch (Exception e) { + // Something went wrong! :( + if (logErrors) { + errorLogger.accept("Could not submit bStats metrics data", e); + } + } + }); + } - /** - * Gzips the given string. - * - * @param str The string to gzip. - * @return The gzipped string. - */ - private static byte[] compress(final String str) throws IOException { - if (str == null) { - return null; - } - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) { - gzip.write(str.getBytes(StandardCharsets.UTF_8)); - } - return outputStream.toByteArray(); - } + private void sendData(JsonObjectBuilder.JsonObject data) throws Exception { + if (logSentData) { + infoLogger.accept("Sent bStats metrics data: " + data.toString()); + } + String url = String.format(REPORT_URL, platform); + HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection(); + // Compress the data to save bandwidth + byte[] compressedData = compress(data.toString()); + connection.setRequestMethod("POST"); + connection.addRequestProperty("Accept", "application/json"); + connection.addRequestProperty("Connection", "close"); + connection.addRequestProperty("Content-Encoding", "gzip"); + connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length)); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setRequestProperty("User-Agent", "Metrics-Service/1"); + connection.setDoOutput(true); + try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { + outputStream.write(compressedData); + } + StringBuilder builder = new StringBuilder(); + try (BufferedReader bufferedReader = + new BufferedReader(new InputStreamReader(connection.getInputStream()))) { + String line; + while ((line = bufferedReader.readLine()) != null) { + builder.append(line); + } + } + if (logResponseStatusText) { + infoLogger.accept("Sent data to bStats and received response: " + builder); + } + } - public void addCustomChart(CustomChart chart) { - this.customCharts.add(chart); - } + /** Checks that the class was properly relocated. */ + private void checkRelocation() { + // You can use the property to disable the check in your test environment + if (System.getProperty("bstats.relocatecheck") == null + || !System.getProperty("bstats.relocatecheck").equals("false")) { + // Maven's Relocate is clever and changes strings, too. So we have to use this + // little "trick" ... :D + final String defaultPackage = + new String(new byte[] {'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'}); + final String examplePackage = + new String(new byte[] {'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); + // We want to make sure no one just copy & pastes the example and uses the wrong + // package names + if (MetricsBase.class.getPackage().getName().startsWith(defaultPackage) + || MetricsBase.class.getPackage().getName().startsWith(examplePackage)) { + throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); + } + } + } - public void shutdown() { - scheduler.shutdown(); - } + /** + * Gzips the given string. + * + * @param str The string to gzip. + * @return The gzipped string. + */ + private static byte[] compress(final String str) throws IOException { + if (str == null) { + return null; + } + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) { + gzip.write(str.getBytes(StandardCharsets.UTF_8)); + } + return outputStream.toByteArray(); + } + } - private void startSubmitting() { - final Runnable submitTask = - () -> { - if (!enabled || !checkServiceEnabledSupplier.get()) { - // Submitting data or service is disabled - scheduler.shutdown(); - return; - } - if (submitTaskConsumer != null) { - submitTaskConsumer.accept(this::submitData); - } else { - this.submitData(); - } - }; - // Many servers tend to restart at a fixed time at xx:00 which causes an uneven - // distribution of requests on the - // bStats backend. To circumvent this problem, we introduce some randomness into - // the initial and second delay. - // WARNING: You must not modify and part of this Metrics class, including the - // submit delay or frequency! - // WARNING: Modifying this code will get your plugin banned on bStats. Just - // don't do it! - long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3)); - long secondDelay = (long) (1000 * 60 * (Math.random() * 30)); - scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS); - scheduler.scheduleAtFixedRate( - submitTask, initialDelay + secondDelay, 1000 * 60 * 30, TimeUnit.MILLISECONDS); - } + public static class AdvancedBarChart extends CustomChart { - private void submitData() { - final JsonObjectBuilder baseJsonBuilder = new JsonObjectBuilder(); - appendPlatformDataConsumer.accept(baseJsonBuilder); - final JsonObjectBuilder serviceJsonBuilder = new JsonObjectBuilder(); - appendServiceDataConsumer.accept(serviceJsonBuilder); - JsonObjectBuilder.JsonObject[] chartData = - customCharts.stream() - .map(customChart -> customChart.getRequestJsonObject(errorLogger, logErrors)) - .filter(Objects::nonNull) - .toArray(JsonObjectBuilder.JsonObject[]::new); - serviceJsonBuilder.appendField("id", serviceId); - serviceJsonBuilder.appendField("customCharts", chartData); - baseJsonBuilder.appendField("service", serviceJsonBuilder.build()); - baseJsonBuilder.appendField("serverUUID", serverUuid); - baseJsonBuilder.appendField("metricsVersion", METRICS_VERSION); - JsonObjectBuilder.JsonObject data = baseJsonBuilder.build(); - scheduler.execute( - () -> { - try { - // Send the data - sendData(data); - } catch (Exception e) { - // Something went wrong! :( - if (logErrors) { - errorLogger.accept("Could not submit bStats metrics data", e); - } - } - }); - } + private final Callable> callable; - private void sendData(JsonObjectBuilder.JsonObject data) throws Exception { - if (logSentData) { - infoLogger.accept("Sent bStats metrics data: " + data.toString()); - } - String url = String.format(REPORT_URL, platform); - HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection(); - // Compress the data to save bandwidth - byte[] compressedData = compress(data.toString()); - connection.setRequestMethod("POST"); - connection.addRequestProperty("Accept", "application/json"); - connection.addRequestProperty("Connection", "close"); - connection.addRequestProperty("Content-Encoding", "gzip"); - connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length)); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestProperty("User-Agent", "Metrics-Service/1"); - connection.setDoOutput(true); - try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) { - outputStream.write(compressedData); - } - StringBuilder builder = new StringBuilder(); - try (BufferedReader bufferedReader = - new BufferedReader(new InputStreamReader(connection.getInputStream()))) { - String line; - while ((line = bufferedReader.readLine()) != null) { - builder.append(line); - } - } - if (logResponseStatusText) { - infoLogger.accept("Sent data to bStats and received response: " + builder); - } - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public AdvancedBarChart(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } - /** - * Checks that the class was properly relocated. - */ - private void checkRelocation() { - // You can use the property to disable the check in your test environment - if (System.getProperty("bstats.relocatecheck") == null - || !System.getProperty("bstats.relocatecheck").equals("false")) { - // Maven's Relocate is clever and changes strings, too. So we have to use this - // little "trick" ... :D - final String defaultPackage = - new String(new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'}); - final String examplePackage = - new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'}); - // We want to make sure no one just copy & pastes the example and uses the wrong - // package names - if (MetricsBase.class.getPackage().getName().startsWith(defaultPackage) - || MetricsBase.class.getPackage().getName().startsWith(examplePackage)) { - throw new IllegalStateException("bStats Metrics class has not been relocated correctly!"); - } - } - } + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean allSkipped = true; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue().length == 0) { + // Skip this invalid + continue; + } + allSkipped = false; + valuesBuilder.appendField(entry.getKey(), entry.getValue()); + } + if (allSkipped) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); } + } - public static class AdvancedBarChart extends CustomChart { + public static class SimplePie extends CustomChart { - private final Callable> callable; + private final Callable callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public AdvancedBarChart(String chartId, Callable> callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public SimplePie(String chartId, Callable callable) { + super(chartId); + this.callable = callable; + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - boolean allSkipped = true; - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue().length == 0) { - // Skip this invalid - continue; - } - allSkipped = false; - valuesBuilder.appendField(entry.getKey(), entry.getValue()); - } - if (allSkipped) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); - } + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + String value = callable.call(); + if (value == null || value.isEmpty()) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("value", value).build(); } + } - public static class SimplePie extends CustomChart { + public static class DrilldownPie extends CustomChart { - private final Callable callable; + private final Callable>> callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public SimplePie(String chartId, Callable callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public DrilldownPie(String chartId, Callable>> callable) { + super(chartId); + this.callable = callable; + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - String value = callable.call(); - if (value == null || value.isEmpty()) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("value", value).build(); - } + @Override + public JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map> map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean reallyAllSkipped = true; + for (Map.Entry> entryValues : map.entrySet()) { + JsonObjectBuilder valueBuilder = new JsonObjectBuilder(); + boolean allSkipped = true; + for (Map.Entry valueEntry : map.get(entryValues.getKey()).entrySet()) { + valueBuilder.appendField(valueEntry.getKey(), valueEntry.getValue()); + allSkipped = false; + } + if (!allSkipped) { + reallyAllSkipped = false; + valuesBuilder.appendField(entryValues.getKey(), valueBuilder.build()); + } + } + if (reallyAllSkipped) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); } + } - public static class DrilldownPie extends CustomChart { + public static class SingleLineChart extends CustomChart { - private final Callable>> callable; + private final Callable callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public DrilldownPie(String chartId, Callable>> callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public SingleLineChart(String chartId, Callable callable) { + super(chartId); + this.callable = callable; + } - @Override - public JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map> map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - boolean reallyAllSkipped = true; - for (Map.Entry> entryValues : map.entrySet()) { - JsonObjectBuilder valueBuilder = new JsonObjectBuilder(); - boolean allSkipped = true; - for (Map.Entry valueEntry : map.get(entryValues.getKey()).entrySet()) { - valueBuilder.appendField(valueEntry.getKey(), valueEntry.getValue()); - allSkipped = false; - } - if (!allSkipped) { - reallyAllSkipped = false; - valuesBuilder.appendField(entryValues.getKey(), valueBuilder.build()); - } - } - if (reallyAllSkipped) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); - } + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + int value = callable.call(); + if (value == 0) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("value", value).build(); } + } - public static class SingleLineChart extends CustomChart { + public static class MultiLineChart extends CustomChart { - private final Callable callable; + private final Callable> callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public SingleLineChart(String chartId, Callable callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public MultiLineChart(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - int value = callable.call(); - if (value == 0) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("value", value).build(); - } + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean allSkipped = true; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue() == 0) { + // Skip this invalid + continue; + } + allSkipped = false; + valuesBuilder.appendField(entry.getKey(), entry.getValue()); + } + if (allSkipped) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); } + } - public static class MultiLineChart extends CustomChart { + public static class AdvancedPie extends CustomChart { - private final Callable> callable; + private final Callable> callable; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public MultiLineChart(String chartId, Callable> callable) { - super(chartId); - this.callable = callable; - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public AdvancedPie(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - boolean allSkipped = true; - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() == 0) { - // Skip this invalid - continue; - } - allSkipped = false; - valuesBuilder.appendField(entry.getKey(), entry.getValue()); - } - if (allSkipped) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); - } + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + boolean allSkipped = true; + for (Map.Entry entry : map.entrySet()) { + if (entry.getValue() == 0) { + // Skip this invalid + continue; + } + allSkipped = false; + valuesBuilder.appendField(entry.getKey(), entry.getValue()); + } + if (allSkipped) { + // Null = skip the chart + return null; + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); } + } - public static class AdvancedPie extends CustomChart { + public abstract static class CustomChart { - private final Callable> callable; + private final String chartId; - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public AdvancedPie(String chartId, Callable> callable) { - super(chartId); - this.callable = callable; - } + protected CustomChart(String chartId) { + if (chartId == null) { + throw new IllegalArgumentException("chartId must not be null"); + } + this.chartId = chartId; + } - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - boolean allSkipped = true; - for (Map.Entry entry : map.entrySet()) { - if (entry.getValue() == 0) { - // Skip this invalid - continue; - } - allSkipped = false; - valuesBuilder.appendField(entry.getKey(), entry.getValue()); - } - if (allSkipped) { - // Null = skip the chart - return null; - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); - } + public JsonObjectBuilder.JsonObject getRequestJsonObject( + BiConsumer errorLogger, boolean logErrors) { + JsonObjectBuilder builder = new JsonObjectBuilder(); + builder.appendField("chartId", chartId); + try { + JsonObjectBuilder.JsonObject data = getChartData(); + if (data == null) { + // If the data is null we don't send the chart. + return null; + } + builder.appendField("data", data); + } catch (Throwable t) { + if (logErrors) { + errorLogger.accept("Failed to get data for custom chart with id " + chartId, t); + } + return null; + } + return builder.build(); } - public abstract static class CustomChart { + protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception; + } - private final String chartId; + public static class SimpleBarChart extends CustomChart { - protected CustomChart(String chartId) { - if (chartId == null) { - throw new IllegalArgumentException("chartId must not be null"); - } - this.chartId = chartId; - } + private final Callable> callable; - public JsonObjectBuilder.JsonObject getRequestJsonObject( - BiConsumer errorLogger, boolean logErrors) { - JsonObjectBuilder builder = new JsonObjectBuilder(); - builder.appendField("chartId", chartId); - try { - JsonObjectBuilder.JsonObject data = getChartData(); - if (data == null) { - // If the data is null we don't send the chart. - return null; - } - builder.appendField("data", data); - } catch (Throwable t) { - if (logErrors) { - errorLogger.accept("Failed to get data for custom chart with id " + chartId, t); - } - return null; - } - return builder.build(); - } + /** + * Class constructor. + * + * @param chartId The id of the chart. + * @param callable The callable which is used to request the chart data. + */ + public SimpleBarChart(String chartId, Callable> callable) { + super(chartId); + this.callable = callable; + } - protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception; + @Override + protected JsonObjectBuilder.JsonObject getChartData() throws Exception { + JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); + Map map = callable.call(); + if (map == null || map.isEmpty()) { + // Null = skip the chart + return null; + } + for (Map.Entry entry : map.entrySet()) { + valuesBuilder.appendField(entry.getKey(), new int[] {entry.getValue()}); + } + return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); } + } - public static class SimpleBarChart extends CustomChart { + /** + * An extremely simple JSON builder. + * + *

While this class is neither feature-rich nor the most performant one, it's sufficient enough + * for its use-case. + */ + public static class JsonObjectBuilder { - private final Callable> callable; + private StringBuilder builder = new StringBuilder(); - /** - * Class constructor. - * - * @param chartId The id of the chart. - * @param callable The callable which is used to request the chart data. - */ - public SimpleBarChart(String chartId, Callable> callable) { - super(chartId); - this.callable = callable; - } + private boolean hasAtLeastOneField = false; - @Override - protected JsonObjectBuilder.JsonObject getChartData() throws Exception { - JsonObjectBuilder valuesBuilder = new JsonObjectBuilder(); - Map map = callable.call(); - if (map == null || map.isEmpty()) { - // Null = skip the chart - return null; - } - for (Map.Entry entry : map.entrySet()) { - valuesBuilder.appendField(entry.getKey(), new int[]{entry.getValue()}); - } - return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build(); - } + public JsonObjectBuilder() { + builder.append("{"); } /** - * An extremely simple JSON builder. + * Appends a null field to the JSON. * - *

While this class is neither feature-rich nor the most performant one, it's sufficient enough - * for its use-case. + * @param key The key of the field. + * @return A reference to this object. */ - public static class JsonObjectBuilder { - - private StringBuilder builder = new StringBuilder(); - - private boolean hasAtLeastOneField = false; - - public JsonObjectBuilder() { - builder.append("{"); - } - - /** - * Escapes the given string like stated in https://www.ietf.org/rfc/rfc4627.txt. - * - *

This method escapes only the necessary characters '"', '\'. and '\u0000' - '\u001F'. - * Compact escapes are not used (e.g., '\n' is escaped as "\u000a" and not as "\n"). - * - * @param value The value to escape. - * @return The escaped value. - */ - private static String escape(String value) { - final StringBuilder builder = new StringBuilder(); - for (int i = 0; i < value.length(); i++) { - char c = value.charAt(i); - if (c == '"') { - builder.append("\\\""); - } else if (c == '\\') { - builder.append("\\\\"); - } else if (c <= '\u000F') { - builder.append("\\u000").append(Integer.toHexString(c)); - } else if (c <= '\u001F') { - builder.append("\\u00").append(Integer.toHexString(c)); - } else { - builder.append(c); - } - } - return builder.toString(); - } + public JsonObjectBuilder appendNull(String key) { + appendFieldUnescaped(key, "null"); + return this; + } - /** - * Appends a null field to the JSON. - * - * @param key The key of the field. - * @return A reference to this object. - */ - public JsonObjectBuilder appendNull(String key) { - appendFieldUnescaped(key, "null"); - return this; - } + /** + * Appends a string field to the JSON. + * + * @param key The key of the field. + * @param value The value of the field. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, String value) { + if (value == null) { + throw new IllegalArgumentException("JSON value must not be null"); + } + appendFieldUnescaped(key, "\"" + escape(value) + "\""); + return this; + } - /** - * Appends a string field to the JSON. - * - * @param key The key of the field. - * @param value The value of the field. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, String value) { - if (value == null) { - throw new IllegalArgumentException("JSON value must not be null"); - } - appendFieldUnescaped(key, "\"" + escape(value) + "\""); - return this; - } + /** + * Appends an integer field to the JSON. + * + * @param key The key of the field. + * @param value The value of the field. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, int value) { + appendFieldUnescaped(key, String.valueOf(value)); + return this; + } - /** - * Appends an integer field to the JSON. - * - * @param key The key of the field. - * @param value The value of the field. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, int value) { - appendFieldUnescaped(key, String.valueOf(value)); - return this; - } + /** + * Appends an object to the JSON. + * + * @param key The key of the field. + * @param object The object. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, JsonObject object) { + if (object == null) { + throw new IllegalArgumentException("JSON object must not be null"); + } + appendFieldUnescaped(key, object.toString()); + return this; + } - /** - * Appends an object to the JSON. - * - * @param key The key of the field. - * @param object The object. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, JsonObject object) { - if (object == null) { - throw new IllegalArgumentException("JSON object must not be null"); - } - appendFieldUnescaped(key, object.toString()); - return this; - } + /** + * Appends a string array to the JSON. + * + * @param key The key of the field. + * @param values The string array. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, String[] values) { + if (values == null) { + throw new IllegalArgumentException("JSON values must not be null"); + } + String escapedValues = + Arrays.stream(values) + .map(value -> "\"" + escape(value) + "\"") + .collect(Collectors.joining(",")); + appendFieldUnescaped(key, "[" + escapedValues + "]"); + return this; + } - /** - * Appends a string array to the JSON. - * - * @param key The key of the field. - * @param values The string array. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, String[] values) { - if (values == null) { - throw new IllegalArgumentException("JSON values must not be null"); - } - String escapedValues = - Arrays.stream(values) - .map(value -> "\"" + escape(value) + "\"") - .collect(Collectors.joining(",")); - appendFieldUnescaped(key, "[" + escapedValues + "]"); - return this; - } + /** + * Appends an integer array to the JSON. + * + * @param key The key of the field. + * @param values The integer array. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, int[] values) { + if (values == null) { + throw new IllegalArgumentException("JSON values must not be null"); + } + String escapedValues = + Arrays.stream(values).mapToObj(String::valueOf).collect(Collectors.joining(",")); + appendFieldUnescaped(key, "[" + escapedValues + "]"); + return this; + } - /** - * Appends an integer array to the JSON. - * - * @param key The key of the field. - * @param values The integer array. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, int[] values) { - if (values == null) { - throw new IllegalArgumentException("JSON values must not be null"); - } - String escapedValues = - Arrays.stream(values).mapToObj(String::valueOf).collect(Collectors.joining(",")); - appendFieldUnescaped(key, "[" + escapedValues + "]"); - return this; - } + /** + * Appends an object array to the JSON. + * + * @param key The key of the field. + * @param values The integer array. + * @return A reference to this object. + */ + public JsonObjectBuilder appendField(String key, JsonObject[] values) { + if (values == null) { + throw new IllegalArgumentException("JSON values must not be null"); + } + String escapedValues = + Arrays.stream(values).map(JsonObject::toString).collect(Collectors.joining(",")); + appendFieldUnescaped(key, "[" + escapedValues + "]"); + return this; + } - /** - * Appends an object array to the JSON. - * - * @param key The key of the field. - * @param values The integer array. - * @return A reference to this object. - */ - public JsonObjectBuilder appendField(String key, JsonObject[] values) { - if (values == null) { - throw new IllegalArgumentException("JSON values must not be null"); - } - String escapedValues = - Arrays.stream(values).map(JsonObject::toString).collect(Collectors.joining(",")); - appendFieldUnescaped(key, "[" + escapedValues + "]"); - return this; - } + /** + * Appends a field to the object. + * + * @param key The key of the field. + * @param escapedValue The escaped value of the field. + */ + private void appendFieldUnescaped(String key, String escapedValue) { + if (builder == null) { + throw new IllegalStateException("JSON has already been built"); + } + if (key == null) { + throw new IllegalArgumentException("JSON key must not be null"); + } + if (hasAtLeastOneField) { + builder.append(","); + } + builder.append("\"").append(escape(key)).append("\":").append(escapedValue); + hasAtLeastOneField = true; + } - /** - * Appends a field to the object. - * - * @param key The key of the field. - * @param escapedValue The escaped value of the field. - */ - private void appendFieldUnescaped(String key, String escapedValue) { - if (builder == null) { - throw new IllegalStateException("JSON has already been built"); - } - if (key == null) { - throw new IllegalArgumentException("JSON key must not be null"); - } - if (hasAtLeastOneField) { - builder.append(","); - } - builder.append("\"").append(escape(key)).append("\":").append(escapedValue); - hasAtLeastOneField = true; - } + /** + * Builds the JSON string and invalidates this builder. + * + * @return The built JSON string. + */ + public JsonObject build() { + if (builder == null) { + throw new IllegalStateException("JSON has already been built"); + } + JsonObject object = new JsonObject(builder.append("}").toString()); + builder = null; + return object; + } - /** - * Builds the JSON string and invalidates this builder. - * - * @return The built JSON string. - */ - public JsonObject build() { - if (builder == null) { - throw new IllegalStateException("JSON has already been built"); - } - JsonObject object = new JsonObject(builder.append("}").toString()); - builder = null; - return object; - } + /** + * Escapes the given string like stated in https://www.ietf.org/rfc/rfc4627.txt. + * + *

This method escapes only the necessary characters '"', '\'. and '\u0000' - '\u001F'. + * Compact escapes are not used (e.g., '\n' is escaped as "\u000a" and not as "\n"). + * + * @param value The value to escape. + * @return The escaped value. + */ + private static String escape(String value) { + final StringBuilder builder = new StringBuilder(); + for (int i = 0; i < value.length(); i++) { + char c = value.charAt(i); + if (c == '"') { + builder.append("\\\""); + } else if (c == '\\') { + builder.append("\\\\"); + } else if (c <= '\u000F') { + builder.append("\\u000").append(Integer.toHexString(c)); + } else if (c <= '\u001F') { + builder.append("\\u00").append(Integer.toHexString(c)); + } else { + builder.append(c); + } + } + return builder.toString(); + } - /** - * A super simple representation of a JSON object. - * - *

This class only exists to make methods of the {@link JsonObjectBuilder} type-safe and not - * allow a raw string inputs for methods like {@link JsonObjectBuilder#appendField(String, - * JsonObject)}. - */ - public static class JsonObject { + /** + * A super simple representation of a JSON object. + * + *

This class only exists to make methods of the {@link JsonObjectBuilder} type-safe and not + * allow a raw string inputs for methods like {@link JsonObjectBuilder#appendField(String, + * JsonObject)}. + */ + public static class JsonObject { - private final String value; + private final String value; - private JsonObject(String value) { - this.value = value; - } + private JsonObject(String value) { + this.value = value; + } - @Override - public String toString() { - return value; - } - } + @Override + public String toString() { + return value; + } } -} \ No newline at end of file + } +} From ef3236664e4dbb4b1ba35c85a99e01e0d300363e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:18:07 +0200 Subject: [PATCH 218/260] Update PlayerUtils.java --- .../minecraft/spigot/utils/PlayerUtils.java | 442 +++++++++--------- 1 file changed, 221 insertions(+), 221 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/PlayerUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/PlayerUtils.java index e45edfdb..ab8e7456 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/PlayerUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/PlayerUtils.java @@ -1,5 +1,16 @@ package com.falchus.lib.minecraft.spigot.utils; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import com.falchus.lib.minecraft.spigot.enums.Sound; import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; @@ -7,230 +18,219 @@ import com.google.common.io.ByteStreams; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; + import lombok.NonNull; import lombok.SneakyThrows; import lombok.experimental.UtilityClass; -import net.luckperms.api.LuckPerms; -import net.luckperms.api.LuckPermsProvider; -import net.luckperms.api.model.user.User; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.jetbrains.annotations.NotNull; - -import java.util.*; @UtilityClass public class PlayerUtils { - - public static final Set vanished = new HashSet<>(); - public static final Map skins = new HashMap<>(); - public static final Map names = new HashMap<>(); - private static final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - - /** - * Sends a raw NMS packet to a player. - */ - public static void sendPacket(@NonNull Player player, @NonNull Object packet) { - VersionProvider.get().sendPacket(player, packet); - } - - /** - * Sends a title and/or subtitle to a player. - */ - public static void sendTitle(@NonNull Player player, String title, String subtitle) { - VersionProvider.get().sendTitle(player, title, subtitle); - } - - /** - * Sends a tablist header/footer and display name to a player. - */ - public static void sendTablist(@NonNull Player player, List header, List footer, String name) { - VersionProvider.get().sendTablist(player, header, footer, name); - } - - /** - * Sends a bossbar to a player. - */ - public static void sendBossbar(@NonNull Player player, @NonNull String title, double progress) { - VersionProvider.get().sendBossbar(player, title, progress); - } - - /** - * Removes the bossbar from a player. - */ - public static void removeBossbar(@NonNull Player player) { - VersionProvider.get().removeBossbar(player); - } - - /** - * Sends an action-bar message to a player. - */ - public static void sendActionbar(@NonNull Player player, @NonNull String message) { - VersionProvider.get().sendActionbar(player, message); - } - - /** - * Sends a nametag (prefix + suffix) for a player visible to all online players. - */ - public static void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { - VersionProvider.get().sendNametag(player, prefix, suffix); - } - - /** - * Removes the nametag of a player for all online players. - */ - public static void removeNametag(@NonNull Player player) { - VersionProvider.get().removeNametag(player); - } - - /** - * Plays a sound to a player at the given location. - */ - public static void playSound(@NonNull Player player, @NonNull Location location, - @NonNull Sound sound, float volume, float pitch) { - VersionProvider.get().playSound(player, location, sound, volume, pitch); - } - - /** - * Freezes a player (prevents movement and interaction). - */ - public static void freeze(@NonNull Player player) { - plugin.getFreezeListener().players.add(player.getUniqueId()); - } - - /** - * Unfreezes a player. - */ - public static void unfreeze(@NonNull Player player) { - plugin.getFreezeListener().players.remove(player.getUniqueId()); - } - - /** - * Returns the LuckPerms rank prefix of a player, or an empty string. - */ - public static @NotNull String getLuckPermsRankPrefix(@NonNull Player player) { - if (!Bukkit.getPluginManager().isPluginEnabled("LuckPerms")) return ""; - - LuckPerms lp = LuckPermsProvider.get(); - User user = lp.getPlayerAdapter(Player.class).getUser(player); - String prefix = user.getCachedData().getMetaData().getPrefix(); - return prefix != null ? prefix : ""; - } - - /** - * Vanishes a player from all online players. - *

- * Uses {@code hidePlayer(Plugin, Player)} — the non-deprecated overload - * available since Paper 1.18 and the only one in Paper 26.x. - */ - public static void vanish(@NonNull Player player) { - if (vanished.add(player.getUniqueId())) { - for (Player online : Bukkit.getOnlinePlayers()) { - online.hidePlayer(plugin, player); - } - } - } - - /** - * Un-vanishes a player so all online players can see them again. - *

- * Uses {@code showPlayer(Plugin, Player)} — consistent with the - * {@link #vanish} counterpart. - */ - public static void unvanish(@NonNull Player player) { - if (vanished.remove(player.getUniqueId())) { - for (Player online : Bukkit.getOnlinePlayers()) { - online.showPlayer(plugin, player); - } - } - } - - /** - * @return the NMS {@code EntityPlayer} for the given Bukkit {@link Player}. - */ - public static Object getEntityPlayer(@NonNull Player player) { - return VersionProvider.get().getEntityPlayer(player); - } - - /** - * @return the {@link GameProfile} from an NMS {@code EntityPlayer}. - */ - public static GameProfile getProfile(@NonNull Object entityPlayer) { - return VersionProvider.get().getProfile(entityPlayer); - } - - /** - * @return the current ping (ms) of a player. - */ - public static int getPing(@NonNull Player player) { - return VersionProvider.get().getPing(player); - } - - /** - * Sets a custom skin on a player (by UUID of the skin owner). - */ - public static void setSkin(@NonNull Player player, @NonNull UUID uuid) { - VersionProvider.get().setSkin(player, uuid); - } - - /** - * Resets a player's skin to their original one. - */ - public static void resetSkin(@NonNull Player player) { - VersionProvider.get().resetSkin(player); - } - - /** - * Sets a custom display name on a player. - */ - public static void setName(@NonNull Player player, @NonNull String name) { - VersionProvider.get().setName(player, name); - } - - /** - * Resets a player's display name to their original username. - */ - public static void resetName(@NonNull Player player) { - VersionProvider.get().resetName(player); - } - - /** - * Forces all clients to reload the player's {@link GameProfile}. - */ - public static void refresh(@NonNull Player player) { - VersionProvider.get().refresh(player); - } - - /** - * Adds a fake {@code EntityPlayer} to a player's player-info list. - */ - public static void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - VersionProvider.get().addEntityPlayer(player, entityPlayer); - } - - /** - * Removes a fake {@code EntityPlayer} from a player's player-info list. - */ - public static void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - VersionProvider.get().removeEntityPlayer(player, entityPlayer); - } - - /** - * Spawns a fake {@code EntityPlayer} entity for a player. - */ - public static void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { - VersionProvider.get().spawnEntityPlayer(player, entityPlayer); - } - - /** - * Connects the player to a proxy server via BungeeCord plugin messaging. - */ - @SneakyThrows - public static void connectToServer(@NonNull Player player, @NonNull String server) { - ByteArrayDataOutput out = ByteStreams.newDataOutput(); - out.writeUTF("Connect"); - out.writeUTF(server); - player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); - } -} \ No newline at end of file + + private static final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + public static final Set vanished = new HashSet<>(); + public static final Map skins = new HashMap<>(); + public static final Map names = new HashMap<>(); + + /** + * Sends a raw NMS packet to a player. + */ + public static void sendPacket(@NonNull Player player, @NonNull Object packet) { + VersionProvider.get().sendPacket(player, packet); + } + + /** + * Sends a title and/or subtitle to a player. + */ + public static void sendTitle(@NonNull Player player, String title, String subtitle) { + VersionProvider.get().sendTitle(player, title, subtitle); + } + + /** + * Sends a tablist to a player. + */ + public static void sendTablist(@NonNull Player player, List header, List footer, String name) { + VersionProvider.get().sendTablist(player, header, footer, name); + } + + /** + * Sends a bossbar to a player. + */ + public static void sendBossbar(@NonNull Player player, @NonNull String title, double progress) { + VersionProvider.get().sendBossbar(player, title, progress); + } + + /** + * Removes a bossbar from a player. + */ + public static void removeBossbar(@NonNull Player player) { + VersionProvider.get().removeBossbar(player); + } + + /** + * Sends a actionbar to a player. + */ + public static void sendActionbar(@NonNull Player player, @NonNull String message) { + VersionProvider.get().sendActionbar(player, message); + } + + /** + * Sends a nametag for a player. + */ + public static void sendNametag(@NonNull Player player, @NonNull String prefix, @NonNull String suffix) { + VersionProvider.get().sendNametag(player, prefix, suffix); + } + + /** + * Removes a nametag from a player. + */ + public static void removeNametag(@NonNull Player player) { + VersionProvider.get().removeNametag(player); + } + + /** + * Plays a sound to a player. + */ + public static void playSound(@NonNull Player player, @NonNull Location location, @NonNull Sound sound, float volume, float pitch) { + VersionProvider.get().playSound(player, location, sound, volume, pitch); + } + + /** + * Freezes a player. + */ + public static void freeze(@NonNull Player player) { + plugin.getFreezeListener().players.add(player.getUniqueId()); + } + + /** + * Unfreezes a player. + */ + public static void unfreeze(@NonNull Player player) { + plugin.getFreezeListener().players.remove(player.getUniqueId()); + } + + /** + * Retrieves the LuckPerms rank prefix of a player. + */ + public static String getLuckPermsRankPrefix(@NonNull Player player) { + if (!Bukkit.getPluginManager().isPluginEnabled("LuckPerms")) return ""; + + net.luckperms.api.LuckPerms luckPerms = net.luckperms.api.LuckPermsProvider.get(); + net.luckperms.api.model.user.User user = luckPerms.getPlayerAdapter(Player.class).getUser(player); + net.luckperms.api.cacheddata.CachedMetaData metaData = user.getCachedData().getMetaData(); + String prefix = metaData.getPrefix(); + return prefix != null ? prefix : ""; + } + + /** + * Vanishes a player. + */ + public static void vanish(@NonNull Player player) { + if (vanished.add(player.getUniqueId())) { + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + onlinePlayer.hidePlayer(player); + } + } + } + + /** + * Unvanishes a player. + */ + public static void unvanish(@NonNull Player player) { + if (vanished.remove(player.getUniqueId())) { + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + onlinePlayer.showPlayer(player); + } + } + } + + /** + * @return EntityPlayer from Player + */ + public static Object getEntityPlayer(@NonNull Player player) { + return VersionProvider.get().getEntityPlayer(player); + } + + /** + * @return GameProfile from EntityPlayer + */ + public static GameProfile getProfile(@NonNull Object entityPlayer) { + return VersionProvider.get().getProfile(entityPlayer); + } + + /** + * @return ping from a player. + */ + public static int getPing(@NonNull Player player) { + return VersionProvider.get().getPing(player); + } + + /** + * Sets a custom skin. + */ + public static void setSkin(@NonNull Player player, @NonNull UUID uuid) { + VersionProvider.get().setSkin(player, uuid); + } + + /** + * Resets the skin back to the original. + */ + public static void resetSkin(@NonNull Player player) { + VersionProvider.get().resetSkin(player); + } + + /** + * Sets a custom name. + */ + public static void setName(@NonNull Player player, @NonNull String name) { + VersionProvider.get().setName(player, name); + } + + /** + * Resets the name back to the original. + */ + public static void resetName(@NonNull Player player) { + VersionProvider.get().resetName(player); + } + + /** + * Forces clients to reload the player's GameProfile. + */ + public static void refresh(@NonNull Player player) { + VersionProvider.get().refresh(player); + } + + /** + * Adds a EntityPlayer. + */ + public static void addEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + VersionProvider.get().addEntityPlayer(player, entityPlayer); + } + + /** + * Removes a EntityPlayer. + */ + public static void removeEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + VersionProvider.get().removeEntityPlayer(player, entityPlayer); + } + + /** + * Spawns a EntityPlayer. + */ + public static void spawnEntityPlayer(@NonNull Player player, @NonNull Object entityPlayer) { + VersionProvider.get().spawnEntityPlayer(player, entityPlayer); + } + + /** + * Connects the player to a proxy server. + * via BungeeCord messaging + */ + @SneakyThrows + public static void connectToServer(@NonNull Player player, @NonNull String server) { + ByteArrayDataOutput out = ByteStreams.newDataOutput(); + + out.writeUTF("Connect"); + out.writeUTF(server); + + player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray()); + } +} From 512139a074a7117b82d41124c839c8a4432ac914 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:18:34 +0200 Subject: [PATCH 219/260] Update ServerUtils.java --- .../minecraft/spigot/utils/ServerUtils.java | 156 +++++++++--------- 1 file changed, 79 insertions(+), 77 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/ServerUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/ServerUtils.java index f74af6be..bf8598fb 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/ServerUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/ServerUtils.java @@ -1,88 +1,90 @@ package com.falchus.lib.minecraft.spigot.utils; +import org.bukkit.Bukkit; +import org.bukkit.Server; + import com.falchus.lib.minecraft.spigot.enums.Version; import com.falchus.lib.minecraft.spigot.utils.version.VersionProvider; + import lombok.experimental.UtilityClass; -import org.bukkit.Bukkit; -import org.bukkit.Server; @UtilityClass public class ServerUtils { - /** - * @return MinecraftServer - */ - public static Object getMcServer() { - return VersionProvider.get().getMcServer(); - } - - /** - * @return {@link Server} - */ - public static Object getBukkitServer() { - return VersionProvider.get().getBukkitServer(); - } - - /** - * @return {@link Version} - */ - public static Version getVersion() { - int major = getMajorVersion(); - int minor = getMinorVersion(); - - Version version = null; - for (Version v : Version.values()) { - if (v.getMajor() < major || (v.getMajor() == major && v.getMinor() <= minor)) { - if (version == null || v.isAfter(version)) { - version = v; - } - } + /** + * @return MinecraftServer + */ + public static Object getMcServer() { + return VersionProvider.get().getMcServer(); + } + + /** + * @return {@link Server} + */ + public static Object getBukkitServer() { + return VersionProvider.get().getBukkitServer(); + } + + /** + * @return {@link Version} + */ + public static Version getVersion() { + int major = getMajorVersion(); + int minor = getMinorVersion(); + + Version version = null; + for (Version v : Version.values()) { + if (v.getMajor() < major || (v.getMajor() == major && v.getMinor() <= minor)) { + if (version == null || v.isAfter(version)) { + version = v; + } + } + } + if (version == null) { + throw new IllegalStateException("Unsupported server version: " + getVersionString()); + } + return version; + } + + /** + * @return e.g. "1.8.8" + */ + public static String getVersionString() { + return VersionProvider.get().getVersion(); + } + + /** + * @return e.g. 26 for 26.1 + */ + public static int getMajorVersion() { + String bukkitVersion = Bukkit.getBukkitVersion(); + String mc = bukkitVersion.split("-")[0]; + + try { + return Integer.parseInt(mc.split("\\.")[0]); + } catch (Exception e) { + throw new RuntimeException(e); } - if (version == null) { - throw new IllegalStateException("Unsupported server version: " + getVersionString()); + } + + /** + * @return e.g. 8 for 1.8.8 + */ + public static int getMinorVersion() { + String bukkitVersion = Bukkit.getBukkitVersion(); + String mc = bukkitVersion.split("-")[0]; + + try { + return Integer.parseInt(mc.split("\\.")[1]); + } catch (Exception e) { + throw new RuntimeException(e); } - return version; - } - - /** - * @return e.g. "1.8.8" - */ - public static String getVersionString() { - return VersionProvider.get().getVersion(); - } - - /** - * @return e.g. 26 for 26.1 - */ - public static int getMajorVersion() { - String bukkitVersion = Bukkit.getBukkitVersion(); - String mc = bukkitVersion.split("-")[0]; - - try { - return Integer.parseInt(mc.split("\\.")[0]); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * @return e.g. 8 for 1.8.8 - */ - public static int getMinorVersion() { - String bukkitVersion = Bukkit.getBukkitVersion(); - String mc = bukkitVersion.split("-")[0]; - - try { - return Integer.parseInt(mc.split("\\.")[1]); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - /** - * @return recent TPS - */ - public static double[] getRecentTps() { - return VersionProvider.get().getRecentTps(); - } -} \ No newline at end of file + } + + /** + * @return recent TPS + */ + public static double[] getRecentTps() { + return VersionProvider.get().getRecentTps(); + } +} From 188c378fc66cfce9f7636accc9b6765c593d239f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:19:05 +0200 Subject: [PATCH 220/260] Update FalchusLibMinecraftSpigot.java --- .../spigot/FalchusLibMinecraftSpigot.java | 75 +++++++++---------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/FalchusLibMinecraftSpigot.java b/src/com/falchus/lib/minecraft/spigot/FalchusLibMinecraftSpigot.java index 936e93b8..182f3971 100644 --- a/src/com/falchus/lib/minecraft/spigot/FalchusLibMinecraftSpigot.java +++ b/src/com/falchus/lib/minecraft/spigot/FalchusLibMinecraftSpigot.java @@ -1,52 +1,45 @@ package com.falchus.lib.minecraft.spigot; -import com.falchus.lib.minecraft.FalchusLibMinecraft; +import org.bukkit.plugin.java.JavaPlugin; + import com.falchus.lib.minecraft.spigot.listeners.*; -import com.falchus.lib.minecraft.spigot.listeners.message.LabyModMessageListener; -import com.falchus.lib.minecraft.spigot.listeners.message.LunarMessageListener; -import com.falchus.lib.minecraft.spigot.manager.ClientManager; -import com.falchus.lib.minecraft.spigot.utils.Metrics; -import com.falchus.lib.minecraft.spigot.utils.SchedulerUtils; +import com.falchus.lib.minecraft.spigot.listeners.message.*; +import com.falchus.lib.minecraft.spigot.manager.*; +import com.falchus.lib.minecraft.spigot.utils.*; + import lombok.AccessLevel; import lombok.Getter; import lombok.experimental.FieldDefaults; -import org.bukkit.plugin.java.JavaPlugin; @Getter @FieldDefaults(level = AccessLevel.PRIVATE) public class FalchusLibMinecraftSpigot extends JavaPlugin { - @Getter - static FalchusLibMinecraftSpigot instance; - - LabyModMessageListener labyModMessageListener; - LunarMessageListener lunarMessageListener; - EntityPlayerListener entityPlayerListener; - FreezeListener freezeListener; - ItemListener itemListener; - JoinQuitListener joinQuitListener; - LobbyCancelListener lobbyCancelListener; - ClientManager clientManager; - - @Override - public void onEnable() { - instance = this; - - if (FalchusLibMinecraft.isFolia()) { - getLogger().info("Folia detected — using Folia-compatible scheduler."); - } - - new Metrics(this, 28050); - - getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); - - labyModMessageListener = new LabyModMessageListener(); - lunarMessageListener = new LunarMessageListener(); - entityPlayerListener = new EntityPlayerListener(); - freezeListener = new FreezeListener(); - itemListener = new ItemListener(); - joinQuitListener = new JoinQuitListener(); - lobbyCancelListener = new LobbyCancelListener(); - clientManager = new ClientManager(); - } -} \ No newline at end of file + @Getter static FalchusLibMinecraftSpigot instance; + + LabyModMessageListener labyModMessageListener; + LunarMessageListener lunarMessageListener; + EntityPlayerListener entityPlayerListener; + FreezeListener freezeListener; + ItemListener itemListener; + JoinQuitListener joinQuitListener; + LobbyCancelListener lobbyCancelListener; + ClientManager clientManager; + + @Override + public void onEnable() { + instance = this; + new Metrics(this, 28050); + + getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); + + labyModMessageListener = new LabyModMessageListener(); + lunarMessageListener = new LunarMessageListener(); + entityPlayerListener = new EntityPlayerListener(); + freezeListener = new FreezeListener(); + itemListener = new ItemListener(); + joinQuitListener = new JoinQuitListener(); + lobbyCancelListener = new LobbyCancelListener(); + clientManager = new ClientManager(); + } +} From ea0c1eb090306a58ded54377c8ef80de58789beb Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:19:19 +0200 Subject: [PATCH 221/260] Update AdventureUtils.java --- .../lib/minecraft/utils/AdventureUtils.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/com/falchus/lib/minecraft/utils/AdventureUtils.java b/src/com/falchus/lib/minecraft/utils/AdventureUtils.java index b6cf0ff7..5938f07d 100644 --- a/src/com/falchus/lib/minecraft/utils/AdventureUtils.java +++ b/src/com/falchus/lib/minecraft/utils/AdventureUtils.java @@ -8,11 +8,11 @@ public class AdventureUtils { - public static String toJson(@NonNull Component component) { - return GsonComponentSerializer.gson().serialize(component); - } - - public static TextComponent legacy(@NonNull String input) { - return LegacyComponentSerializer.legacySection().deserialize(input); - } + public static String toJson(@NonNull Component component) { + return GsonComponentSerializer.gson().serialize(component); + } + + public static TextComponent legacy(@NonNull String input) { + return LegacyComponentSerializer.legacySection().deserialize(input); + } } From 6b464174e11cedb8a05f0882779d6ad35536404e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:19:43 +0200 Subject: [PATCH 222/260] Update APIUtils.java --- .../falchus/lib/minecraft/utils/APIUtils.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/com/falchus/lib/minecraft/utils/APIUtils.java b/src/com/falchus/lib/minecraft/utils/APIUtils.java index ace9a1d1..dd3aa8b5 100644 --- a/src/com/falchus/lib/minecraft/utils/APIUtils.java +++ b/src/com/falchus/lib/minecraft/utils/APIUtils.java @@ -1,45 +1,46 @@ package com.falchus.lib.minecraft.utils; +import java.util.UUID; + import com.falchus.lib.utils.http.HTTPRequest; import com.google.gson.JsonObject; import com.google.gson.JsonParser; + import lombok.NonNull; import lombok.experimental.UtilityClass; -import java.util.UUID; - @UtilityClass public class APIUtils { - /** - * Gets the UUID of a player. - * - * @return the player's {@link UUID} - */ + /** + * Gets the UUID of a player. + * + * @return the player's {@link UUID} + */ public static UUID getUUID(@NonNull String username) { - String body = HTTPRequest.get("https://api.mojang.com/users/profiles/minecraft/" + username); + String body = HTTPRequest.get("https://api.mojang.com/users/profiles/minecraft/" + username); if (body == null) return null; - JsonObject json = JsonParser.parseString(body).getAsJsonObject(); - String id = json.get("id").getAsString(); - + JsonObject json = JsonParser.parseString(body).getAsJsonObject(); + String id = json.get("id").getAsString(); + String uuid = id.replaceFirst( - "(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w+)", - "$1-$2-$3-$4-$5" + "(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w+)", + "$1-$2-$3-$4-$5" ); return UUID.fromString(uuid); } - + /** * Gets the name of a player by UUID. - * + * * @return the player's username {@link String} - */ + */ public static String getName(@NonNull String uuid) { String body = HTTPRequest.get("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.replace("-", "")); if (body == null) return null; - JsonObject json = JsonParser.parseString(body).getAsJsonObject(); - return json.get("name").getAsString(); + JsonObject json = JsonParser.parseString(body).getAsJsonObject(); + return json.get("name").getAsString(); } -} \ No newline at end of file +} From 9352010c39395d39b5add4dc56263c361f33ae99 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:19:55 +0200 Subject: [PATCH 223/260] Update CloudNet.java --- .../falchus/lib/minecraft/utils/CloudNet.java | 216 +++++++++--------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/src/com/falchus/lib/minecraft/utils/CloudNet.java b/src/com/falchus/lib/minecraft/utils/CloudNet.java index 1b4d8254..4f7acf01 100644 --- a/src/com/falchus/lib/minecraft/utils/CloudNet.java +++ b/src/com/falchus/lib/minecraft/utils/CloudNet.java @@ -1,5 +1,9 @@ package com.falchus.lib.minecraft.utils; +import java.util.Collection; +import java.util.List; +import java.util.UUID; + import eu.cloudnetservice.driver.document.property.DocProperty; import eu.cloudnetservice.driver.event.EventManager; import eu.cloudnetservice.driver.inject.InjectionLayer; @@ -18,154 +22,150 @@ import lombok.NonNull; import lombok.experimental.UtilityClass; -import java.util.Collection; -import java.util.List; -import java.util.UUID; - @UtilityClass public class CloudNet { - public static final BridgeServiceHelper bridgeServiceHelper = InjectionLayer.ext().instance(BridgeServiceHelper.class); - public static final PlayerManager playerManager = InjectionLayer.ext().instance(ServiceRegistry.class).defaultInstance(PlayerManager.class); - public static final CloudServiceFactory cloudServiceFactory = InjectionLayer.ext().instance(CloudServiceFactory.class); - public static final CloudServiceProvider cloudServiceProvider = InjectionLayer.ext().instance(CloudServiceProvider.class); - public static final ServiceInfoHolder serviceInfoHolder = InjectionLayer.ext().instance(ServiceInfoHolder.class); - public static final EventManager eventManager = InjectionLayer.ext().instance(EventManager.class); - - /** - * Broadcasts a message to all players globally. - */ - public static void broadcastMessage(@NonNull List messages) { - String message = String.join("\n", messages); + public static final BridgeServiceHelper bridgeServiceHelper = InjectionLayer.ext().instance(BridgeServiceHelper.class); + public static final PlayerManager playerManager = InjectionLayer.ext().instance(ServiceRegistry.class).defaultInstance(PlayerManager.class); + public static final CloudServiceFactory cloudServiceFactory = InjectionLayer.ext().instance(CloudServiceFactory.class); + public static final CloudServiceProvider cloudServiceProvider = InjectionLayer.ext().instance(CloudServiceProvider.class); + public static final ServiceInfoHolder serviceInfoHolder = InjectionLayer.ext().instance(ServiceInfoHolder.class); + public static final EventManager eventManager = InjectionLayer.ext().instance(EventManager.class); + + /** + * Broadcasts a message to all players globally. + */ + public static void broadcastMessage(@NonNull List messages) { + String message = String.join("\n", messages); playerManager.globalPlayerExecutor().sendChatMessage(AdventureUtils.legacy(message)); - } - - /** - * Publishes an update for the current service. - */ - public static void publishServiceInfoUpdate() { + } + + /** + * Publishes an update for the current service. + */ + public static void publishServiceInfoUpdate() { serviceInfoHolder.publishServiceInfoUpdate(); - } - - /** - * Creates and starts a new service. - */ - public static void createAndStartService(@NonNull ServiceConfiguration serviceConfig) { - cloudServiceFactory.createCloudServiceAsync(serviceConfig) - .thenAccept(result -> { - if (result.state() == ServiceCreateResult.State.CREATED) { - UUID uuid = result.serviceInfo().serviceId().uniqueId(); - ServiceInfoSnapshot service = cloudServiceProvider.service(uuid); - service.provider().startAsync(); - } - }); - } - - /** - * @return player count for the group - */ - public static int getPlayerCountFromGroup(@NonNull String group) { - return playerManager.groupOnlinePlayers(group).count(); - } - - /** - * @return player count for the task - */ - public static int getPlayerCountFromTask(@NonNull String task) { - return playerManager.taskOnlinePlayers(task).count(); - } - - /** - * @return player count for the service - */ - public static int getPlayerCountFromService(@NonNull String service) { - return getService(service).readProperty(BridgeDocProperties.ONLINE_COUNT); - } - - /** - * @return service by name - */ - public static ServiceInfoSnapshot getService(@NonNull String service) { - return cloudServiceProvider.serviceByName(service); - } + } + + /** + * Creates and starts a new service. + */ + public static void createAndStartService(@NonNull ServiceConfiguration serviceConfig) { + cloudServiceFactory.createCloudServiceAsync(serviceConfig) + .thenAccept(result -> { + if (result.state() == ServiceCreateResult.State.CREATED) { + UUID uuid = result.serviceInfo().serviceId().uniqueId(); + ServiceInfoSnapshot service = cloudServiceProvider.service(uuid); + service.provider().startAsync(); + } + }); + } + + /** + * @return player count for the group + */ + public static int getPlayerCountFromGroup(@NonNull String group) { + return playerManager.groupOnlinePlayers(group).count(); + } + + /** + * @return player count for the task + */ + public static int getPlayerCountFromTask(@NonNull String task) { + return playerManager.taskOnlinePlayers(task).count(); + } + + /** + * @return player count for the service + */ + public static int getPlayerCountFromService(@NonNull String service) { + return getService(service).readProperty(BridgeDocProperties.ONLINE_COUNT); + } + + /** + * @return service by name + */ + public static ServiceInfoSnapshot getService(@NonNull String service) { + return cloudServiceProvider.serviceByName(service); + } + + /** + * @return services by group + */ + public static Collection getServicesByGroup(@NonNull String group) { + return cloudServiceProvider.servicesByGroup(group); + } + + /** + * @return services by task + */ + public static Collection getServicesByTask(@NonNull String task) { + return cloudServiceProvider.servicesByTask(task); + } /** - * @return services by group + * Sets the "extra" field for the current service. */ - public static Collection getServicesByGroup(@NonNull String group) { - return cloudServiceProvider.servicesByGroup(group); + public static void setExtra(@NonNull String newExtra) { + bridgeServiceHelper.extra().set(newExtra); } /** - * @return services by task + * Sets the MOTD for the current service. */ - public static Collection getServicesByTask(@NonNull String task) { - return cloudServiceProvider.servicesByTask(task); + public static void setMotd(@NonNull String newMotd) { + bridgeServiceHelper.motd().set(newMotd); } - + /** * @return the "extra" of the current service */ public static String getExtra() { - return bridgeServiceHelper.extra().get(); + return bridgeServiceHelper.extra().get(); } - - /** - * Sets the "extra" field for the current service. - */ - public static void setExtra(@NonNull String newExtra) { - bridgeServiceHelper.extra().set(newExtra); - } - + /** * @return the "extra" of the given service */ public static String getExtra(@NonNull String service) { - return getService(service).readProperty(BridgeDocProperties.EXTRA); + return getService(service).readProperty(BridgeDocProperties.EXTRA); } - + /** * @return the MOTD of the current service */ public static String getMotd() { return bridgeServiceHelper.motd().get(); } - - /** - * Sets the MOTD for the current service. - */ - public static void setMotd(@NonNull String newMotd) { - bridgeServiceHelper.motd().set(newMotd); - } - + /** * @return the MOTD of the given service */ public static String getMotd(@NonNull String service) { - return getService(service).readProperty(BridgeDocProperties.MOTD); + return getService(service).readProperty(BridgeDocProperties.MOTD); } - + /** * @return the state of the current service */ public static String getState() { - return bridgeServiceHelper.state().get(); + return bridgeServiceHelper.state().get(); } - + /** * @return the state of the given service */ public static String getState(@NonNull String service) { - return getService(service).readProperty(BridgeDocProperties.STATE); + return getService(service).readProperty(BridgeDocProperties.STATE); } - + /** * @return the property of the given service */ public static Object getProperty(@NonNull String service, @NonNull DocProperty property) { - return getService(service).readProperty(property); + return getService(service).readProperty(property); } - + /** * Changes the service state to "ingame" and publishes the update. */ @@ -178,7 +178,7 @@ public static void changeToIngame(boolean autoStartService) { * Changes the service state to "ingame" and publishes the update. */ public static void changeToIngame() { - changeToIngame(true); + changeToIngame(true); } /** @@ -194,32 +194,32 @@ public static void connectPlayerToTask(@NonNull UUID uuid, @NonNull String task, public static void connectPlayerToService(@NonNull UUID uuid, @NonNull String service) { playerManager.playerExecutor(uuid).connect(service); } - + /** * @return {@link PlayerExecutor} by UUID */ public static PlayerExecutor getPlayerExecutor(@NonNull UUID uuid) { - return playerManager.playerExecutor(uuid); + return playerManager.playerExecutor(uuid); } - + /** * Registers a listener. */ public static void registerListener(@NonNull Class listenerClass) { - eventManager.registerListener(listenerClass); + eventManager.registerListener(listenerClass); } - + /** * Registers a listener. */ public static void registerListener(@NonNull Object listener) { - eventManager.registerListener(listener); + eventManager.registerListener(listener); } - + /** * Registers listeners. */ public static void registerListeners(@NonNull Object... listeners) { - eventManager.registerListeners(listeners); + eventManager.registerListeners(listeners); } } From 3453bc286289c6d765ba74bf8af74ca24bd7a74e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:20:10 +0200 Subject: [PATCH 224/260] Update FalchusLibMinecraftVelocity.java --- .../minecraft/velocity/FalchusLibMinecraftVelocity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/falchus/lib/minecraft/velocity/FalchusLibMinecraftVelocity.java b/src/com/falchus/lib/minecraft/velocity/FalchusLibMinecraftVelocity.java index 1fbc63eb..14cecd4c 100644 --- a/src/com/falchus/lib/minecraft/velocity/FalchusLibMinecraftVelocity.java +++ b/src/com/falchus/lib/minecraft/velocity/FalchusLibMinecraftVelocity.java @@ -33,23 +33,23 @@ public class FalchusLibMinecraftVelocity { final File dataFolder; final File file; final Metrics.Factory metricsFactory; - + @Getter static FalchusLibMinecraftVelocity instance; - + @Inject public FalchusLibMinecraftVelocity(ProxyServer server, Logger logger, @DataDirectory Path dataFolder, Metrics.Factory metricsFactory) { this.server = server; this.logger = logger; this.dataFolder = new File(dataFolder.toFile().getParentFile(), this.getClass().getAnnotation(Plugin.class).name()); this.metricsFactory = metricsFactory; - + try { file = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI()); } catch (URISyntaxException e) { throw new RuntimeException(e); } } - + @Subscribe public void onProxyInitialize(ProxyInitializeEvent event) { instance = this; From 9c6b9f23f2941d29d69d735328f9035adee6d143 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:20:35 +0200 Subject: [PATCH 225/260] Update JsonArrayStorage.java --- .../lib/storage/impl/json/JsonArrayStorage.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/storage/impl/json/JsonArrayStorage.java b/src/com/falchus/lib/storage/impl/json/JsonArrayStorage.java index 703a74ee..7e4010c5 100644 --- a/src/com/falchus/lib/storage/impl/json/JsonArrayStorage.java +++ b/src/com/falchus/lib/storage/impl/json/JsonArrayStorage.java @@ -1,13 +1,14 @@ package com.falchus.lib.storage.impl.json; -import com.falchus.lib.storage.serializer.Serializer; +import java.nio.file.Path; + import org.json.simple.JSONArray; -import java.nio.file.Path; +import com.falchus.lib.storage.serializer.Serializer; public class JsonArrayStorage extends JsonStorage { - public JsonArrayStorage(Serializer serializer, Path folder, String fileName) { - super(serializer, folder, fileName, new JSONArray().toJSONString()); - } + public JsonArrayStorage(Serializer serializer, Path folder, String fileName) { + super(serializer, folder, fileName, new JSONArray().toJSONString()); + } } From ea7534101c1130178a5b7c0846ffaf880954e10e Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:20:46 +0200 Subject: [PATCH 226/260] Update JsonObjectStorage.java --- .../lib/storage/impl/json/JsonObjectStorage.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/storage/impl/json/JsonObjectStorage.java b/src/com/falchus/lib/storage/impl/json/JsonObjectStorage.java index 7a8a8046..1a13c2df 100644 --- a/src/com/falchus/lib/storage/impl/json/JsonObjectStorage.java +++ b/src/com/falchus/lib/storage/impl/json/JsonObjectStorage.java @@ -1,13 +1,14 @@ package com.falchus.lib.storage.impl.json; -import com.falchus.lib.storage.serializer.Serializer; +import java.nio.file.Path; + import org.json.simple.JSONObject; -import java.nio.file.Path; +import com.falchus.lib.storage.serializer.Serializer; public class JsonObjectStorage extends JsonStorage { - public JsonObjectStorage(Serializer serializer, Path folder, String fileName) { - super(serializer, folder, fileName, new JSONObject().toJSONString()); - } + public JsonObjectStorage(Serializer serializer, Path folder, String fileName) { + super(serializer, folder, fileName, new JSONObject().toJSONString()); + } } From 66612596e4c9dbb9030ffafc634d589d0860da00 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:20:58 +0200 Subject: [PATCH 227/260] Update JsonStorage.java --- src/com/falchus/lib/storage/impl/json/JsonStorage.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/storage/impl/json/JsonStorage.java b/src/com/falchus/lib/storage/impl/json/JsonStorage.java index 63de4365..da88405d 100644 --- a/src/com/falchus/lib/storage/impl/json/JsonStorage.java +++ b/src/com/falchus/lib/storage/impl/json/JsonStorage.java @@ -1,13 +1,13 @@ package com.falchus.lib.storage.impl.json; +import java.nio.file.Path; + import com.falchus.lib.storage.Storage; import com.falchus.lib.storage.serializer.Serializer; -import java.nio.file.Path; - class JsonStorage extends Storage { - JsonStorage(Serializer serializer, Path folder, String fileName, String defaultContent) { - super(serializer, folder, fileName + ".json", defaultContent); - } + JsonStorage(Serializer serializer, Path folder, String fileName, String defaultContent) { + super(serializer, folder, fileName + ".json", defaultContent); + } } From ef891d68f3a4445792f360f20fe82d5315f51ad4 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:21:11 +0200 Subject: [PATCH 228/260] Update JsonArraySerializer.java --- .../serializer/json/JsonArraySerializer.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/storage/serializer/json/JsonArraySerializer.java b/src/com/falchus/lib/storage/serializer/json/JsonArraySerializer.java index 8cc41175..9b057201 100644 --- a/src/com/falchus/lib/storage/serializer/json/JsonArraySerializer.java +++ b/src/com/falchus/lib/storage/serializer/json/JsonArraySerializer.java @@ -3,26 +3,26 @@ import org.json.simple.JSONArray; public abstract class JsonArraySerializer extends JsonSerializer { - - @Override - public String serialize(T value) { - return to(value).toJSONString(); - } - - @Override - public T deserialize(String content) { - if (content == null || content.isBlank()) { - return from(new JSONArray()); - } - - try { - Object raw = parser.parse(content); - if (raw instanceof JSONArray json) { - return from(json); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - return from(new JSONArray()); - } + + @Override + public String serialize(T value) { + return to(value).toJSONString(); + } + + @Override + public T deserialize(String content) { + if (content == null || content.isBlank()) { + return from(new JSONArray()); + } + + try { + Object raw = parser.parse(content); + if (raw instanceof JSONArray json) { + return from(json); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + return from(new JSONArray()); + } } From e1e6f5f13c3c3498a772e632512df955c3a56762 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:21:22 +0200 Subject: [PATCH 229/260] Update JsonObjectSerializer.java --- .../serializer/json/JsonObjectSerializer.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/com/falchus/lib/storage/serializer/json/JsonObjectSerializer.java b/src/com/falchus/lib/storage/serializer/json/JsonObjectSerializer.java index 457d1c60..3c71fc75 100644 --- a/src/com/falchus/lib/storage/serializer/json/JsonObjectSerializer.java +++ b/src/com/falchus/lib/storage/serializer/json/JsonObjectSerializer.java @@ -3,26 +3,26 @@ import org.json.simple.JSONObject; public abstract class JsonObjectSerializer extends JsonSerializer { - - @Override - public String serialize(T value) { - return to(value).toJSONString(); - } - - @Override - public T deserialize(String content) { - if (content == null || content.isBlank()) { - return from(new JSONObject()); - } - - try { - Object raw = parser.parse(content); - if (raw instanceof JSONObject json) { - return from(json); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - return from(new JSONObject()); - } + + @Override + public String serialize(T value) { + return to(value).toJSONString(); + } + + @Override + public T deserialize(String content) { + if (content == null || content.isBlank()) { + return from(new JSONObject()); + } + + try { + Object raw = parser.parse(content); + if (raw instanceof JSONObject json) { + return from(json); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + return from(new JSONObject()); + } } From f18709d4a84eef7f4e74748448099388da403d8b Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:21:37 +0200 Subject: [PATCH 230/260] Update JsonSerializer.java --- .../lib/storage/serializer/json/JsonSerializer.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/com/falchus/lib/storage/serializer/json/JsonSerializer.java b/src/com/falchus/lib/storage/serializer/json/JsonSerializer.java index 781e1ba4..9ec88300 100644 --- a/src/com/falchus/lib/storage/serializer/json/JsonSerializer.java +++ b/src/com/falchus/lib/storage/serializer/json/JsonSerializer.java @@ -1,10 +1,11 @@ package com.falchus.lib.storage.serializer.json; +import org.json.simple.parser.JSONParser; + import com.falchus.lib.interfaces.Mapper; import com.falchus.lib.storage.serializer.Serializer; -import org.json.simple.parser.JSONParser; abstract class JsonSerializer implements Mapper, Serializer { - - final JSONParser parser = new JSONParser(); + + final JSONParser parser = new JSONParser(); } From 6d4ebac2154afb8f530be1ee8cb1f795d755c276 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:21:48 +0200 Subject: [PATCH 231/260] Update Serializer.java --- src/com/falchus/lib/storage/serializer/Serializer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/falchus/lib/storage/serializer/Serializer.java b/src/com/falchus/lib/storage/serializer/Serializer.java index 906ebc6b..4f2dc108 100644 --- a/src/com/falchus/lib/storage/serializer/Serializer.java +++ b/src/com/falchus/lib/storage/serializer/Serializer.java @@ -2,7 +2,7 @@ public interface Serializer { - String serialize(T value); - - T deserialize(String content); + String serialize(T value); + + T deserialize(String content); } From 108632f710de8165244add50cb6a5b96a4bd25d0 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:22:00 +0200 Subject: [PATCH 232/260] Update Storage.java --- src/com/falchus/lib/storage/Storage.java | 108 +++++++++++------------ 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/src/com/falchus/lib/storage/Storage.java b/src/com/falchus/lib/storage/Storage.java index a0a21bd4..137e4dc9 100644 --- a/src/com/falchus/lib/storage/Storage.java +++ b/src/com/falchus/lib/storage/Storage.java @@ -1,65 +1,65 @@ package com.falchus.lib.storage; -import com.falchus.lib.storage.serializer.Serializer; - import java.io.File; import java.nio.file.Files; import java.nio.file.Path; -public class Storage { - - private final Serializer serializer; - private final File file; - private final String defaultContent; - - public Storage(Serializer serializer, Path folder, String fileName, String defaultContent) { - this.serializer = serializer; - this.defaultContent = defaultContent; - - try { - Files.createDirectories(folder); - file = folder.resolve(fileName).toFile(); - - if (!file.exists() || file.length() == 0) { - Files.writeString(file.toPath(), defaultContent); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @SuppressWarnings("unchecked") - public void save(T value) { - try { - String content = ((Serializer) serializer).serialize(value); - Files.writeString(file.toPath(), content); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - @SuppressWarnings("unchecked") - public T load() { - try { - if (!file.exists() || file.length() == 0) { - return ((Serializer) serializer).deserialize(defaultContent); - } +import com.falchus.lib.storage.serializer.Serializer; - String content = Files.readString(file.toPath()); - if (content == null || content.isBlank()) { - return ((Serializer) serializer).deserialize(defaultContent); - } - return ((Serializer) serializer).deserialize(content); - } catch (Exception e) { - throw new RuntimeException(e); - } - } +public class Storage { - public void delete() { + private final Serializer serializer; + private final File file; + private final String defaultContent; + + public Storage(Serializer serializer, Path folder, String fileName, String defaultContent) { + this.serializer = serializer; + this.defaultContent = defaultContent; + + try { + Files.createDirectories(folder); + file = folder.resolve(fileName).toFile(); + + if (!file.exists() || file.length() == 0) { + Files.writeString(file.toPath(), defaultContent); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @SuppressWarnings("unchecked") + public void save(T value) { try { - Files.deleteIfExists(file.toPath()); + String content = ((Serializer) serializer).serialize(value); + Files.writeString(file.toPath(), content); } catch (Exception e) { - throw new RuntimeException(e); - } - } + throw new RuntimeException(e); + } + } + + @SuppressWarnings("unchecked") + public T load() { + try { + if (!file.exists() || file.length() == 0) { + return ((Serializer) serializer).deserialize(defaultContent); + } + + String content = Files.readString(file.toPath()); + if (content == null || content.isBlank()) { + return ((Serializer) serializer).deserialize(defaultContent); + } + return ((Serializer) serializer).deserialize(content); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public void delete() { + try { + Files.deleteIfExists(file.toPath()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } From c1bd00163c73646c6893f3fb1810641a3b8fa8d1 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:22:15 +0200 Subject: [PATCH 233/260] Update CountdownTask.java --- .../falchus/lib/task/impl/CountdownTask.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/com/falchus/lib/task/impl/CountdownTask.java b/src/com/falchus/lib/task/impl/CountdownTask.java index 42a1feff..544d9012 100644 --- a/src/com/falchus/lib/task/impl/CountdownTask.java +++ b/src/com/falchus/lib/task/impl/CountdownTask.java @@ -1,6 +1,7 @@ package com.falchus.lib.task.impl; import com.falchus.lib.task.Task; + import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,19 +11,18 @@ @Getter @AllArgsConstructor public abstract class CountdownTask extends Task { - - private int remaining; - - @Override - public final void onRun(int tick) { - if (remaining <= 0) { - end(); - return; - } - onCountdown(remaining); - remaining--; - } - - protected void onCountdown(int remaining) { - } + + private int remaining; + + @Override + public final void onRun(int tick) { + if (remaining <= 0) { + end(); + return; + } + onCountdown(remaining); + remaining--; + } + + protected void onCountdown(int remaining) {} } From d2a19b5b1a18661fe8407ba831c246740827d984 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:22:28 +0200 Subject: [PATCH 234/260] Update Task.java --- src/com/falchus/lib/task/Task.java | 197 ++++++++++++++--------------- 1 file changed, 98 insertions(+), 99 deletions(-) diff --git a/src/com/falchus/lib/task/Task.java b/src/com/falchus/lib/task/Task.java index a3fdb792..93f7ee06 100644 --- a/src/com/falchus/lib/task/Task.java +++ b/src/com/falchus/lib/task/Task.java @@ -1,106 +1,105 @@ package com.falchus.lib.task; -import lombok.Getter; - import java.util.Map; -import java.util.concurrent.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -public abstract class Task implements Runnable { - - private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors()); - private static final ExecutorService worker = Executors.newCachedThreadPool(); - - private static final Map tasks = new ConcurrentHashMap<>(); - private static final Map> taskFutures = new ConcurrentHashMap<>(); - private static final AtomicInteger ids = new AtomicInteger(0); - - @Getter - private final int id = ids.incrementAndGet(); - @Getter - private boolean ended; - @Getter - private int tick; - - public static final Task runTask(Runnable runnable) { - Task task; - if (runnable instanceof Task t) { - task = t; - } else { - task = new Task() { - @Override - public void onRun(int tick) { - runnable.run(); - } - }; - } - return task; - } - - public static final Task runTaskTimer(Runnable runnable, long period, TimeUnit unit) { - return runTaskTimer(runnable, 0, period, unit); - } - - public static final Task runTaskTimer(Runnable runnable, long delay, long period, TimeUnit unit) { - return runTask(runnable).runTaskTimer(delay, period, unit); - } - - public static final Task runTaskLater(Runnable runnable, long delay, TimeUnit unit) { - return runTask(runnable).runTaskLater(delay, unit); - } - - public static final void end(int id) { - Task task = tasks.remove(id); - if (task == null) return; - - ScheduledFuture future = taskFutures.remove(id); - if (future != null) { - future.cancel(false); - } - task.end(); - } - - @Override - public final void run() { - if (ended) return; - - worker.submit(() -> onRun(tick++)); - } - - public final T runTaskTimer(long period, TimeUnit unit) { - return runTaskTimer(0, period, unit); - } - - @SuppressWarnings("unchecked") - public final T runTaskTimer(long delay, long period, TimeUnit unit) { - ScheduledFuture future = scheduler.scheduleAtFixedRate(this, delay, period, unit); - tasks.put(id, this); - taskFutures.put(id, future); - return (T) this; - } - - @SuppressWarnings("unchecked") - public final T runTaskLater(long delay, TimeUnit unit) { - ScheduledFuture future = scheduler.schedule(() -> { - run(); - end(); - }, delay, unit); - tasks.put(id, this); - taskFutures.put(id, future); - return (T) this; - } - - public final void end() { - if (ended) return; - ended = true; - - end(id); - onEnd(); - } - - protected void onRun(int tick) { - } +import lombok.Getter; - protected void onEnd() { - } +public abstract class Task implements Runnable { + + private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors()); + private static final ExecutorService worker = Executors.newCachedThreadPool(); + + private static final Map tasks = new ConcurrentHashMap<>(); + private static final Map> taskFutures = new ConcurrentHashMap<>(); + private static final AtomicInteger ids = new AtomicInteger(0); + + @Getter private final int id = ids.incrementAndGet(); + @Getter private boolean ended; + @Getter private int tick; + + @Override + public final void run() { + if (ended) return; + + worker.submit(() -> onRun(tick++)); + } + + public static final Task runTask(Runnable runnable) { + Task task; + if (runnable instanceof Task t) { + task = t; + } else { + task = new Task() { + @Override + public void onRun(int tick) { + runnable.run(); + } + }; + } + return task; + } + + public static final Task runTaskTimer(Runnable runnable, long period, TimeUnit unit) { + return runTaskTimer(runnable, 0, period, unit); + } + + public final T runTaskTimer(long period, TimeUnit unit) { + return runTaskTimer(0, period, unit); + } + + public static final Task runTaskTimer(Runnable runnable, long delay, long period, TimeUnit unit) { + return runTask(runnable).runTaskTimer(delay, period, unit); + } + + @SuppressWarnings("unchecked") + public final T runTaskTimer(long delay, long period, TimeUnit unit) { + ScheduledFuture future = scheduler.scheduleAtFixedRate(this, delay, period, unit); + tasks.put(id, this); + taskFutures.put(id, future); + return (T) this; + } + + public static final Task runTaskLater(Runnable runnable, long delay, TimeUnit unit) { + return runTask(runnable).runTaskLater(delay, unit); + } + + @SuppressWarnings("unchecked") + public final T runTaskLater(long delay, TimeUnit unit) { + ScheduledFuture future = scheduler.schedule(() -> { + run(); + end(); + }, delay, unit); + tasks.put(id, this); + taskFutures.put(id, future); + return (T) this; + } + + public static final void end(int id) { + Task task = tasks.remove(id); + if (task == null) return; + + ScheduledFuture future = taskFutures.remove(id); + if (future != null) { + future.cancel(false); + } + task.end(); + } + + public final void end() { + if (ended) return; + ended = true; + + end(id); + onEnd(); + } + + protected void onRun(int tick) {} + protected void onEnd() {} } From fdd28754487bb286d8f5152733416e23ce3cd7b2 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:22:40 +0200 Subject: [PATCH 235/260] Update ClassInstanceBuilder.java --- .../utils/builder/ClassInstanceBuilder.java | 147 +++++++++--------- 1 file changed, 74 insertions(+), 73 deletions(-) diff --git a/src/com/falchus/lib/utils/builder/ClassInstanceBuilder.java b/src/com/falchus/lib/utils/builder/ClassInstanceBuilder.java index a451a51b..b3819e9c 100644 --- a/src/com/falchus/lib/utils/builder/ClassInstanceBuilder.java +++ b/src/com/falchus/lib/utils/builder/ClassInstanceBuilder.java @@ -1,86 +1,87 @@ package com.falchus.lib.utils.builder; -import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; -import com.falchus.lib.utils.reflection.ReflectionUtils; -import lombok.Getter; -import lombok.NonNull; - import java.lang.reflect.Constructor; import java.util.List; import java.util.Map; import java.util.Set; -@Getter -public class ClassInstanceBuilder { - - private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); - private Class clazz; - private Class[] parents = new Class[0]; - private Object[] children = new Object[0]; - - /** - * Creates a new {@link ClassInstanceBuilder} by class. - */ - public ClassInstanceBuilder(@NonNull Class clazz) { - this.clazz = clazz; - } - - /** - * Creates a new {@link ClassInstanceBuilder} by class name. - */ - public ClassInstanceBuilder(@NonNull String name) { - this.clazz = ReflectionUtils.getClass(name); - } - - /** - * Creates a new {@link ClassInstanceBuilder} by first class. - */ - public ClassInstanceBuilder(@NonNull String... names) { - this.clazz = ReflectionUtils.getFirstClass( - names - ); - } - - /** - * Sets constructor parameters for the class. - */ - @SafeVarargs - public final ClassInstanceBuilder withParams(@NonNull Map, Object>... params) { - parents = new Class[params.length]; - children = new Object[params.length]; - - for (int i = 0; i < params.length; i++) { - Map, Object> map = params[i]; - if (map.size() != 1) { - throw new IllegalArgumentException("Each map must contain exactly one entry: {Class -> value}"); - } +import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; +import com.falchus.lib.utils.reflection.ReflectionUtils; - Map.Entry, Object> entry = map.entrySet().iterator().next(); - parents[i] = entry.getKey(); - children[i] = entry.getValue(); - } - return this; - } +import lombok.Getter; +import lombok.NonNull; - /** - * Builds and returns the final class instance. - */ - public Object build() { - if (clazz == null) { - throw new IllegalStateException("Class must be set"); - } +@Getter +public class ClassInstanceBuilder { - try { - Constructor ctor = ReflectionUtils.getFirstConstructor(clazz, - Set.of( - List.of(parents) - ) - ); - return ctor.newInstance( - children - ); - } catch (Exception e) { + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + private Class clazz; + private Class[] parents = new Class[0]; + private Object[] children = new Object[0]; + + /** + * Creates a new {@link ClassInstanceBuilder} by class. + */ + public ClassInstanceBuilder(@NonNull Class clazz) { + this.clazz = clazz; + } + + /** + * Creates a new {@link ClassInstanceBuilder} by class name. + */ + public ClassInstanceBuilder(@NonNull String name) { + this.clazz = ReflectionUtils.getClass(name); + } + + /** + * Creates a new {@link ClassInstanceBuilder} by first class. + */ + public ClassInstanceBuilder(@NonNull String... names) { + this.clazz = ReflectionUtils.getFirstClass( + names + ); + } + + /** + * Sets constructor parameters for the class. + */ + @SafeVarargs + public final ClassInstanceBuilder withParams(@NonNull Map, Object>... params) { + parents = new Class[params.length]; + children = new Object[params.length]; + + for (int i = 0; i < params.length; i++) { + Map, Object> map = params[i]; + if (map.size() != 1) { + throw new IllegalArgumentException("Each map must contain exactly one entry: {Class -> value}"); + } + + Map.Entry, Object> entry = map.entrySet().iterator().next(); + parents[i] = entry.getKey(); + children[i] = entry.getValue(); + } + return this; + } + + /** + * Builds and returns the final class instance. + */ + public Object build() { + if (clazz == null) { + throw new IllegalStateException("Class must be set"); + } + + try { + Constructor ctor = ReflectionUtils.getFirstConstructor(clazz, + Set.of( + List.of(parents) + ) + ); + return ctor.newInstance( + children + ); + } catch (Exception e) { throw new RuntimeException("Failed to create class instance: " + clazz.getName(), e); } - } + } } From c84df3c0413d33a6c1330467a294cc3a36b96a99 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:22:50 +0200 Subject: [PATCH 236/260] Update HTTPServerBuilder.java --- .../lib/utils/builder/HTTPServerBuilder.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/com/falchus/lib/utils/builder/HTTPServerBuilder.java b/src/com/falchus/lib/utils/builder/HTTPServerBuilder.java index eaf6feb7..42c3a31f 100644 --- a/src/com/falchus/lib/utils/builder/HTTPServerBuilder.java +++ b/src/com/falchus/lib/utils/builder/HTTPServerBuilder.java @@ -1,10 +1,5 @@ package com.falchus.lib.utils.builder; -import com.falchus.lib.utils.http.HTTPServer; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpServer; -import lombok.NonNull; - import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.InetSocketAddress; @@ -13,17 +8,23 @@ import java.util.Map; import java.util.function.BiConsumer; -public class HTTPServerBuilder { +import com.falchus.lib.utils.http.HTTPServer; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpServer; +import lombok.NonNull; + +public class HTTPServerBuilder { + + private int port = 8080; private final Map<@NonNull String, @NonNull BiConsumer<@NonNull HttpExchange, @NonNull Map>> routes = new HashMap<>(); - private int port = 8080; private BiConsumer<@NonNull HttpExchange, @NonNull Map> defaultHandler; - + public HTTPServerBuilder port(int port) { - this.port = port; - return this; + this.port = port; + return this; } - + /** * Adds a route. */ @@ -31,7 +32,7 @@ public HTTPServerBuilder route(@NonNull String path, @NonNull BiConsumer parseQuery(String query) { Map map = new HashMap<>(); From eb0874bd44fe6e0118ed82e500646e195ee3ad09 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:23:03 +0200 Subject: [PATCH 237/260] Update HTTPRequest.java --- .../falchus/lib/utils/http/HTTPRequest.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/com/falchus/lib/utils/http/HTTPRequest.java b/src/com/falchus/lib/utils/http/HTTPRequest.java index 98952a3f..aa3fc407 100644 --- a/src/com/falchus/lib/utils/http/HTTPRequest.java +++ b/src/com/falchus/lib/utils/http/HTTPRequest.java @@ -1,35 +1,35 @@ package com.falchus.lib.utils.http; -import lombok.NonNull; -import lombok.experimental.UtilityClass; - import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import lombok.NonNull; +import lombok.experimental.UtilityClass; + @UtilityClass public class HTTPRequest { - private static final HttpClient client = HttpClient.newHttpClient(); - - /** - * @return the response body as a {@link String}, or {@code null} - */ - public static String get(@NonNull String url) { - try { - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(url)) - .GET() - .build(); - + private static final HttpClient client = HttpClient.newHttpClient(); + + /** + * @return the response body as a {@link String}, or {@code null} + */ + public static String get(@NonNull String url) { + try { + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create(url)) + .GET() + .build(); + HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() != 200) return null; - + return response.body(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } } From eb0bb6ebfe5d5b2c0bfcc1170e8fe4a8602a2e4f Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:23:13 +0200 Subject: [PATCH 238/260] Update HTTPServer.java --- .../falchus/lib/utils/http/HTTPServer.java | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/com/falchus/lib/utils/http/HTTPServer.java b/src/com/falchus/lib/utils/http/HTTPServer.java index 24401ba4..f97ecd79 100644 --- a/src/com/falchus/lib/utils/http/HTTPServer.java +++ b/src/com/falchus/lib/utils/http/HTTPServer.java @@ -1,37 +1,44 @@ package com.falchus.lib.utils.http; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpServer; -import lombok.AllArgsConstructor; -import lombok.NonNull; - import java.io.IOException; import java.io.OutputStream; import java.util.Map; import java.util.function.BiConsumer; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpServer; + +import lombok.AllArgsConstructor; +import lombok.NonNull; + @AllArgsConstructor public class HTTPServer { - @NonNull - private final HttpServer server; - @NonNull - private final Map>> routes; - - /** - * Sends a plain text response to the client. - */ + @NonNull private final HttpServer server; + @NonNull private final Map>> routes; + + public void start() { + server.start(); + } + + public void stop(int delay) { + server.stop(delay); + } + + /** + * Sends a plain text response to the client. + */ public static void sendText(@NonNull HttpExchange exchange, @NonNull String text, int statusCode) { sendResponse(exchange, text, statusCode, "text/plain; charset=UTF-8"); } - + /** * Sends a JSON response to the client. */ public static void sendJson(@NonNull HttpExchange exchange, @NonNull String json, int statusCode) { sendResponse(exchange, json, statusCode, "application/json; charset=UTF-8"); } - + private static void sendResponse(@NonNull HttpExchange exchange, @NonNull String content, int statusCode, @NonNull String contentType) { try { byte[] bytes = content.getBytes("UTF-8"); @@ -45,12 +52,4 @@ private static void sendResponse(@NonNull HttpExchange exchange, @NonNull String e.printStackTrace(); } } - - public void start() { - server.start(); - } - - public void stop(int delay) { - server.stop(delay); - } } From 419aaaf03be8f751673eccae56ef27603ab2a9e3 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:23:25 +0200 Subject: [PATCH 239/260] Update ClassKey.java --- .../falchus/lib/utils/reflection/keys/ClassKey.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/falchus/lib/utils/reflection/keys/ClassKey.java b/src/com/falchus/lib/utils/reflection/keys/ClassKey.java index f1fea4e1..cad73826 100644 --- a/src/com/falchus/lib/utils/reflection/keys/ClassKey.java +++ b/src/com/falchus/lib/utils/reflection/keys/ClassKey.java @@ -1,12 +1,12 @@ package com.falchus.lib.utils.reflection.keys; -import lombok.NonNull; - import java.util.Set; -public record ClassKey(@NonNull Set names) { +import lombok.NonNull; - public ClassKey(@NonNull String... names) { - this(Set.of(names)); - } +public record ClassKey(@NonNull Set names) { + + public ClassKey(@NonNull String... names) { + this(Set.of(names)); + } } From 25713ae47fb1c4ea0699fcde87ab149db183512d Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:23:35 +0200 Subject: [PATCH 240/260] Update ConstructorKey.java --- .../utils/reflection/keys/ConstructorKey.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/com/falchus/lib/utils/reflection/keys/ConstructorKey.java b/src/com/falchus/lib/utils/reflection/keys/ConstructorKey.java index 055073ae..f0229aa3 100644 --- a/src/com/falchus/lib/utils/reflection/keys/ConstructorKey.java +++ b/src/com/falchus/lib/utils/reflection/keys/ConstructorKey.java @@ -1,17 +1,17 @@ package com.falchus.lib.utils.reflection.keys; -import lombok.NonNull; - import java.util.List; import java.util.Set; -public record ConstructorKey(@NonNull Set> classes, Set>> params) { - - public ConstructorKey(@NonNull Class clazz, Class... params) { - this(Set.of(clazz), Set.of(List.of(params))); - } +import lombok.NonNull; - public ConstructorKey(@NonNull Class clazz, Set>> params) { - this(Set.of(clazz), params); - } +public record ConstructorKey(@NonNull Set> classes, Set>> params) { + + public ConstructorKey(@NonNull Class clazz, Class... params) { + this(Set.of(clazz), Set.of(List.of(params))); + } + + public ConstructorKey(@NonNull Class clazz, Set>> params) { + this(Set.of(clazz), params); + } } From 56639c2a25e2b626f64f13122540d9872a503f85 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:23:45 +0200 Subject: [PATCH 241/260] Update FieldKey.java --- .../lib/utils/reflection/keys/FieldKey.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/com/falchus/lib/utils/reflection/keys/FieldKey.java b/src/com/falchus/lib/utils/reflection/keys/FieldKey.java index f1d00235..1f28d9ab 100644 --- a/src/com/falchus/lib/utils/reflection/keys/FieldKey.java +++ b/src/com/falchus/lib/utils/reflection/keys/FieldKey.java @@ -1,20 +1,20 @@ package com.falchus.lib.utils.reflection.keys; -import lombok.NonNull; - import java.util.Set; -public record FieldKey(@NonNull Set> classes, @NonNull Set names) { - - public FieldKey(@NonNull Class clazz, @NonNull String name) { - this(Set.of(clazz), Set.of(name)); - } - - public FieldKey(@NonNull Class clazz, @NonNull String... names) { - this(Set.of(clazz), Set.of(names)); - } +import lombok.NonNull; - public FieldKey(@NonNull Set> classes, @NonNull String... names) { - this(classes, Set.of(names)); - } +public record FieldKey(@NonNull Set> classes, @NonNull Set names) { + + public FieldKey(@NonNull Class clazz, @NonNull String name) { + this(Set.of(clazz), Set.of(name)); + } + + public FieldKey(@NonNull Class clazz, @NonNull String... names) { + this(Set.of(clazz), Set.of(names)); + } + + public FieldKey(@NonNull Set> classes, @NonNull String... names) { + this(classes, Set.of(names)); + } } From 43e1bc5351a702e7b4e5821a94705ecaeea54918 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:23:57 +0200 Subject: [PATCH 242/260] Update MethodKey.java --- .../lib/utils/reflection/keys/MethodKey.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/com/falchus/lib/utils/reflection/keys/MethodKey.java b/src/com/falchus/lib/utils/reflection/keys/MethodKey.java index 61b46ab1..98de71e4 100644 --- a/src/com/falchus/lib/utils/reflection/keys/MethodKey.java +++ b/src/com/falchus/lib/utils/reflection/keys/MethodKey.java @@ -1,21 +1,21 @@ package com.falchus.lib.utils.reflection.keys; -import lombok.NonNull; - import java.util.List; import java.util.Set; -public record MethodKey(@NonNull Set> classes, List> params, @NonNull Set names) { - - public MethodKey(@NonNull Class clazz, @NonNull String name, @NonNull Class... params) { - this(Set.of(clazz), List.of(params), Set.of(name)); - } - - public MethodKey(@NonNull Class clazz, List> params, @NonNull String... names) { - this(Set.of(clazz), params, Set.of(names)); - } +import lombok.NonNull; - public MethodKey(@NonNull Set> classes, List> params, @NonNull String... names) { - this(classes, params, Set.of(names)); - } +public record MethodKey(@NonNull Set> classes, List> params, @NonNull Set names) { + + public MethodKey(@NonNull Class clazz, @NonNull String name, @NonNull Class... params) { + this(Set.of(clazz), List.of(params), Set.of(name)); + } + + public MethodKey(@NonNull Class clazz, List> params, @NonNull String... names) { + this(Set.of(clazz), params, Set.of(names)); + } + + public MethodKey(@NonNull Set> classes, List> params, @NonNull String... names) { + this(classes, params, Set.of(names)); + } } From 17ad0f4a6bb07aadf64fdf963d08a9a9a8e8abb7 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:24:12 +0200 Subject: [PATCH 243/260] Update Dummy.java --- src/com/falchus/lib/utils/reflection/Dummy.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/com/falchus/lib/utils/reflection/Dummy.java b/src/com/falchus/lib/utils/reflection/Dummy.java index 3dbbfe0c..3fd6a945 100644 --- a/src/com/falchus/lib/utils/reflection/Dummy.java +++ b/src/com/falchus/lib/utils/reflection/Dummy.java @@ -2,8 +2,7 @@ public final class Dummy { - public static final Dummy instance = new Dummy(); - - private Dummy() { - } + public static final Dummy instance = new Dummy(); + + private Dummy() {} } From 4a359b7f685580b05859e3292f25e072f6992eae Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:24:56 +0200 Subject: [PATCH 244/260] Update ReflectionUtils.java --- .../lib/utils/reflection/ReflectionUtils.java | 334 +++++++++--------- 1 file changed, 162 insertions(+), 172 deletions(-) diff --git a/src/com/falchus/lib/utils/reflection/ReflectionUtils.java b/src/com/falchus/lib/utils/reflection/ReflectionUtils.java index 3a0658ce..245d9406 100644 --- a/src/com/falchus/lib/utils/reflection/ReflectionUtils.java +++ b/src/com/falchus/lib/utils/reflection/ReflectionUtils.java @@ -1,12 +1,5 @@ package com.falchus.lib.utils.reflection; -import com.falchus.lib.utils.reflection.keys.ClassKey; -import com.falchus.lib.utils.reflection.keys.ConstructorKey; -import com.falchus.lib.utils.reflection.keys.FieldKey; -import com.falchus.lib.utils.reflection.keys.MethodKey; -import lombok.NonNull; -import lombok.experimental.UtilityClass; - import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -16,124 +9,126 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -@UtilityClass -public class ReflectionUtils { - - private final Map>> classes = new ConcurrentHashMap<>(); - private final Map>> firstClasses = new ConcurrentHashMap<>(); - - private final Map> fields = new ConcurrentHashMap<>(); - private final Map> firstFields = new ConcurrentHashMap<>(); - private final Map> firstFieldsClasses = new ConcurrentHashMap<>(); +import com.falchus.lib.utils.reflection.keys.*; - private final Map> methods = new ConcurrentHashMap<>(); - private final Map> firstMethods = new ConcurrentHashMap<>(); - private final Map> firstMethodsClasses = new ConcurrentHashMap<>(); +import lombok.NonNull; +import lombok.experimental.UtilityClass; - private final Map>> constructors = new ConcurrentHashMap<>(); - private final Map>> firstConstructors = new ConcurrentHashMap<>(); - private final Map>> firstConstructorsClasses = new ConcurrentHashMap<>(); +@UtilityClass +public class ReflectionUtils { + + private final Map>> classes = new ConcurrentHashMap<>(); + private final Map>> firstClasses = new ConcurrentHashMap<>(); + + private final Map> fields = new ConcurrentHashMap<>(); + private final Map> firstFields = new ConcurrentHashMap<>(); + private final Map> firstFieldsClasses = new ConcurrentHashMap<>(); + + private final Map> methods = new ConcurrentHashMap<>(); + private final Map> firstMethods = new ConcurrentHashMap<>(); + private final Map> firstMethodsClasses = new ConcurrentHashMap<>(); + + private final Map>> constructors = new ConcurrentHashMap<>(); + private final Map>> firstConstructors = new ConcurrentHashMap<>(); + private final Map>> firstConstructorsClasses = new ConcurrentHashMap<>(); public static Class getClass(@NonNull String name) { - return classes.computeIfAbsent(new ClassKey(name), k -> { + return classes.computeIfAbsent(new ClassKey(name), k -> { try { return Optional.of(Class.forName(name)); } catch (ClassNotFoundException e) { - return Optional.empty(); + return Optional.empty(); } - }).orElseThrow(() -> - new RuntimeException() - ); + }).orElseThrow(() -> + new RuntimeException() + ); } - + public static Class getFirstClass(@NonNull String... names) { - return firstClasses.computeIfAbsent(new ClassKey(names), k -> { + return firstClasses.computeIfAbsent(new ClassKey(names), k -> { for (String name : names) { - Class found = getClass(name); - if (found != null) { - return Optional.of(found); - } + Class found = getClass(name); + if (found != null) { + return Optional.of(found); + } } return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the classes exist: " + String.join(", ", names)) - ); + }).orElseThrow(() -> + new RuntimeException("None of the classes exist: " + String.join(", ", names)) + ); } - + public static Field getField(@NonNull Class clazz, @NonNull String name) { - return fields.computeIfAbsent(new FieldKey(clazz, name), k -> { - Class current = clazz; - - while (current != null) { - try { - Field field = current.getField(name); - field.setAccessible(true); - return Optional.of(field); - } catch (NoSuchFieldException ignored) { - } - - try { - Field field = current.getDeclaredField(name); - field.setAccessible(true); - return Optional.of(field); - } catch (NoSuchFieldException ignored) { - } - - current = current.getSuperclass(); - } - return Optional.empty(); - }).orElse(null); + return fields.computeIfAbsent(new FieldKey(clazz, name), k -> { + Class current = clazz; + + while (current != null) { + try { + Field field = current.getField(name); + field.setAccessible(true); + return Optional.of(field); + } catch (NoSuchFieldException ignored) {} + + try { + Field field = current.getDeclaredField(name); + field.setAccessible(true); + return Optional.of(field); + } catch (NoSuchFieldException ignored) {} + + current = current.getSuperclass(); + } + return Optional.empty(); + }).orElse(null); } - + public static Field getField(@NonNull Object instance, @NonNull String name) { - return getField(instance.getClass(), name); + return getField(instance.getClass(), name); } - + public static Field getFirstField(@NonNull Class clazz, @NonNull String... names) { - return firstFields.computeIfAbsent(new FieldKey(clazz, names), k -> { + return firstFields.computeIfAbsent(new FieldKey(clazz, names), k -> { for (String name : names) { Field found = getField(clazz, name); if (found != null) { - return Optional.of(found); + return Optional.of(found); } } return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the fields exist: " + String.join(", ", names)) - ); + }).orElseThrow(() -> + new RuntimeException("None of the fields exist: " + String.join(", ", names)) + ); } - + public static Field getFirstField(@NonNull Object instance, @NonNull String... names) { return getFirstField(instance.getClass(), names); } - + public static Field getFirstField(@NonNull Set> classes, @NonNull String... names) { - return firstFieldsClasses.computeIfAbsent(new FieldKey(classes, names), k -> { - for (Class clazz : classes) { - try { - return Optional.of(getFirstField(clazz, names)); - } catch (RuntimeException ignored) { - } - } - return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the fields exist in classes: " + classes + " - " + String.join(", ", names)) - ); + return firstFieldsClasses.computeIfAbsent(new FieldKey(classes, names), k -> { + for (Class clazz : classes) { + try { + return Optional.of(getFirstField(clazz, names)); + } catch (RuntimeException ignored) {} + } + return Optional.empty(); + }).orElseThrow(() -> + new RuntimeException("None of the fields exist in classes: " + classes + " - " + String.join(", ", names)) + ); } - + @SuppressWarnings("unchecked") - public static T getFieldValue(Object instance, @NonNull Field field) { - try { - return (T) field.get(instance); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static T getFieldValue(@NonNull Field field) { - return getFieldValue(null, field); + public static T getFieldValue(Object instance, @NonNull Field field) { + try { + return (T) field.get(instance); + } catch (Exception e) { + throw new RuntimeException(e); + } } - + + public static T getFieldValue(@NonNull Field field) { + return getFieldValue(null, field); + } + public static void setField(Object instance, @NonNull Field field, Object value) { try { field.set(instance, value); @@ -141,7 +136,7 @@ public static void setField(Object instance, @NonNull Field field, Object value) throw new RuntimeException(e); } } - + public static void setField(Object instance, @NonNull String name, Object value) { try { setField(instance, getField(instance.getClass(), name), value); @@ -149,11 +144,11 @@ public static void setField(Object instance, @NonNull String name, Object value) throw new RuntimeException(e); } } - + public static void setField(@NonNull Field field, Object value) { - setField(null, field, value); + setField(null, field, value); } - + public static void setField(@NonNull Class clazz, @NonNull String name, Object value) { try { setField(getField(clazz, name), value); @@ -161,57 +156,54 @@ public static void setField(@NonNull Class clazz, @NonNull String name, Objec throw new RuntimeException(e); } } - + public static void setFirstField(Object instance, Object value, @NonNull String... names) { - setField(instance, getFirstField(instance, names), value); + setField(instance, getFirstField(instance, names), value); } - + public static void setFirstField(@NonNull Class clazz, Object value, @NonNull String... names) { - setField(getFirstField(clazz, names), value); + setField(getFirstField(clazz, names), value); } - + public static void setFirstField(Object instance, @NonNull Set> classes, Object value, @NonNull String... names) { - for (Class clazz : classes) { - try { - setField(instance, getFirstField(clazz, names), value); - return; - } catch (RuntimeException ignored) { - } - } + for (Class clazz : classes) { + try { + setField(instance, getFirstField(clazz, names), value); + return; + } catch (RuntimeException ignored) {} + } throw new RuntimeException("None of the fields exist in classes: " + classes + " - " + String.join(", ", names)); } - + public static Method getMethod(@NonNull Class clazz, @NonNull String name, Class... params) { - return methods.computeIfAbsent(new MethodKey(clazz, name, params), k -> { - Class current = clazz; - - while (current != null) { + return methods.computeIfAbsent(new MethodKey(clazz, name, params), k -> { + Class current = clazz; + + while (current != null) { try { Method method = current.getMethod(name, params); method.setAccessible(true); return Optional.of(method); - } catch (NoSuchMethodException ignored) { - } - + } catch (NoSuchMethodException ignored) {} + try { Method method = current.getDeclaredMethod(name, params); method.setAccessible(true); return Optional.of(method); - } catch (NoSuchMethodException ignored) { - } - - current = current.getSuperclass(); - } - return Optional.empty(); - }).orElse(null); + } catch (NoSuchMethodException ignored) {} + + current = current.getSuperclass(); + } + return Optional.empty(); + }).orElse(null); } - + public static Method getMethod(@NonNull Object instance, @NonNull String name, Class... params) { - return getMethod(instance.getClass(), name, params); + return getMethod(instance.getClass(), name, params); } - + public static Method getFirstMethod(@NonNull Class clazz, List> params, @NonNull String... names) { - return firstMethods.computeIfAbsent(new MethodKey(clazz, params, names), k -> { + return firstMethods.computeIfAbsent(new MethodKey(clazz, params, names), k -> { for (String name : names) { Method found = getMethod(clazz, name, params.toArray(new Class[0])); if (found != null) { @@ -219,76 +211,74 @@ public static Method getFirstMethod(@NonNull Class clazz, List> para } } return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the methods exist: " + String.join(", ", names)) - ); + }).orElseThrow(() -> + new RuntimeException("None of the methods exist: " + String.join(", ", names)) + ); } - + public static Method getFirstMethod(@NonNull Object instance, List> params, @NonNull String... names) { - return getFirstMethod(instance.getClass(), params, names); + return getFirstMethod(instance.getClass(), params, names); } - + public static Method getFirstMethod(@NonNull Set> classes, List> params, @NonNull String... names) { - return firstMethodsClasses.computeIfAbsent(new MethodKey(classes, params, names), k -> { - for (Class clazz : classes) { - try { - return Optional.of(getFirstMethod(clazz, params, names)); - } catch (RuntimeException ignored) { - } - } - return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("None of the methods exist in classes: " + classes + " - " + String.join(", ", names)) - ); + return firstMethodsClasses.computeIfAbsent(new MethodKey(classes, params, names), k -> { + for (Class clazz : classes) { + try { + return Optional.of(getFirstMethod(clazz, params, names)); + } catch (RuntimeException ignored) {} + } + return Optional.empty(); + }).orElseThrow(() -> + new RuntimeException("None of the methods exist in classes: " + classes + " - " + String.join(", ", names)) + ); } - + public static Constructor getConstructor(@NonNull Class clazz, Class... params) { - return constructors.computeIfAbsent(new ConstructorKey(clazz, params), k -> { + return constructors.computeIfAbsent(new ConstructorKey(clazz, params), k -> { try { Constructor ctor = clazz.getDeclaredConstructor(params); ctor.setAccessible(true); return Optional.of(ctor); } catch (NoSuchMethodException e) { - return Optional.empty(); + return Optional.empty(); } - }).orElseThrow(() -> - new RuntimeException() - ); + }).orElseThrow(() -> + new RuntimeException() + ); } - + public static Constructor getConstructor(@NonNull Object instance, Class... params) { - return getConstructor(instance.getClass(), params); + return getConstructor(instance.getClass(), params); } - + public static Constructor getFirstConstructor(@NonNull Class clazz, Set>> params) { - return firstConstructors.computeIfAbsent(new ConstructorKey(clazz, params), k -> { + return firstConstructors.computeIfAbsent(new ConstructorKey(clazz, params), k -> { for (List> list : params) { - Constructor found = getConstructor(clazz, list.toArray(new Class[0])); + Constructor found = getConstructor(clazz, list.toArray(new Class[0])); if (found != null) { return Optional.of(found); } } return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("No matching constructor found for class: " + clazz.getName()) - ); + }).orElseThrow(() -> + new RuntimeException("No matching constructor found for class: " + clazz.getName()) + ); } - + public static Constructor getFirstConstructor(@NonNull Object instance, Set>> params) { - return getFirstConstructor(instance.getClass(), params); + return getFirstConstructor(instance.getClass(), params); } - + public static Constructor getFirstConstructor(@NonNull Set> classes, Set>> params) { - return firstConstructorsClasses.computeIfAbsent(new ConstructorKey(classes, params), k -> { - for (Class clazz : classes) { - try { - return Optional.of(getFirstConstructor(clazz, params)); - } catch (RuntimeException ignored) { - } - } - return Optional.empty(); - }).orElseThrow(() -> - new RuntimeException("No matching constructor found for classes: " + classes) - ); + return firstConstructorsClasses.computeIfAbsent(new ConstructorKey(classes, params), k -> { + for (Class clazz : classes) { + try { + return Optional.of(getFirstConstructor(clazz, params)); + } catch (RuntimeException ignored) {} + } + return Optional.empty(); + }).orElseThrow(() -> + new RuntimeException("No matching constructor found for classes: " + classes) + ); } } From 38e85bba3343ca2553b11310570ce5635ee653a8 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:25:13 +0200 Subject: [PATCH 245/260] Update ClassWrapper.java --- .../lib/utils/wrapper/impl/ClassWrapper.java | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/src/com/falchus/lib/utils/wrapper/impl/ClassWrapper.java b/src/com/falchus/lib/utils/wrapper/impl/ClassWrapper.java index ffd333d2..b1777946 100644 --- a/src/com/falchus/lib/utils/wrapper/impl/ClassWrapper.java +++ b/src/com/falchus/lib/utils/wrapper/impl/ClassWrapper.java @@ -1,49 +1,50 @@ package com.falchus.lib.utils.wrapper.impl; -import com.falchus.lib.utils.reflection.Dummy; -import com.falchus.lib.utils.reflection.ReflectionUtils; -import com.falchus.lib.utils.wrapper.Wrapper; -import lombok.Getter; -import lombok.NonNull; - import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.List; import java.util.Set; -@Getter -public class ClassWrapper extends Wrapper { - - protected final Set> classes; - - public ClassWrapper(@NonNull T handle, @NonNull Set> classes) { - super(handle); - this.classes = classes; - - if (handle instanceof Dummy) return; - if (!classes.stream().anyMatch(clazz -> clazz.isAssignableFrom(handle.getClass()))) { - throw new RuntimeException("Handle " + handle.getClass().getName() + " is not assignable to any of: " + classes.stream().map(Class::getName).toList()); - } - } - - @Override - protected Field getFirstField(@NonNull String... names) { - return ReflectionUtils.getFirstField(classes, names); - } +import com.falchus.lib.utils.reflection.Dummy; +import com.falchus.lib.utils.reflection.ReflectionUtils; +import com.falchus.lib.utils.wrapper.Wrapper; - @Override - protected void setFirstField(Object value, @NonNull String... names) { - ReflectionUtils.setFirstField(handle, classes, value, names); - } +import lombok.Getter; +import lombok.NonNull; - @Override - protected Method getFirstMethod(List> params, @NonNull String... names) { - return ReflectionUtils.getFirstMethod(classes, params, names); - } +@Getter +public class ClassWrapper extends Wrapper { - @Override - protected Constructor getFirstConstructor(Set>> params) { - return ReflectionUtils.getFirstConstructor(classes, params); - } + protected final Set> classes; + + public ClassWrapper(@NonNull T handle, @NonNull Set> classes) { + super(handle); + this.classes = classes; + + if (handle instanceof Dummy) return; + if (!classes.stream().anyMatch(clazz -> clazz.isAssignableFrom(handle.getClass()))) { + throw new RuntimeException("Handle " + handle.getClass().getName() + " is not assignable to any of: " + classes.stream().map(Class::getName).toList()); + } + } + + @Override + protected Field getFirstField(@NonNull String... names) { + return ReflectionUtils.getFirstField(classes, names); + } + + @Override + protected void setFirstField(Object value, @NonNull String... names) { + ReflectionUtils.setFirstField(handle, classes, value, names); + } + + @Override + protected Method getFirstMethod(List> params, @NonNull String... names) { + return ReflectionUtils.getFirstMethod(classes, params, names); + } + + @Override + protected Constructor getFirstConstructor(Set>> params) { + return ReflectionUtils.getFirstConstructor(classes, params); + } } From 9705699bc7161fa40d90b63fe852851d11102011 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:25:24 +0200 Subject: [PATCH 246/260] Update FirstClassWrapper.java --- .../utils/wrapper/impl/FirstClassWrapper.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/com/falchus/lib/utils/wrapper/impl/FirstClassWrapper.java b/src/com/falchus/lib/utils/wrapper/impl/FirstClassWrapper.java index 26b51c8f..1f9d0769 100644 --- a/src/com/falchus/lib/utils/wrapper/impl/FirstClassWrapper.java +++ b/src/com/falchus/lib/utils/wrapper/impl/FirstClassWrapper.java @@ -1,24 +1,25 @@ package com.falchus.lib.utils.wrapper.impl; -import com.falchus.lib.utils.reflection.ReflectionUtils; -import lombok.NonNull; - import java.util.Set; import java.util.stream.Collectors; +import com.falchus.lib.utils.reflection.ReflectionUtils; + +import lombok.NonNull; + public class FirstClassWrapper extends ClassWrapper { - public FirstClassWrapper(@NonNull T handle, @NonNull Set names) { - super(handle, names.stream() - .map(name -> { - try { - return ReflectionUtils.getFirstClass(name); - } catch (RuntimeException e) { - return null; - } - }) - .filter(c -> c != null) - .collect(Collectors.toSet()) - ); - } + public FirstClassWrapper(@NonNull T handle, @NonNull Set names) { + super(handle, names.stream() + .map(name -> { + try { + return ReflectionUtils.getFirstClass(name); + } catch (RuntimeException e) { + return null; + } + }) + .filter(c -> c != null) + .collect(Collectors.toSet()) + ); + } } From a1e4d3fc5c399e0d046050f4f0a109570768a0e4 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:25:36 +0200 Subject: [PATCH 247/260] Update Wrapper.java --- .../falchus/lib/utils/wrapper/Wrapper.java | 132 +++++++++--------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/src/com/falchus/lib/utils/wrapper/Wrapper.java b/src/com/falchus/lib/utils/wrapper/Wrapper.java index a409f8c1..84cc171a 100644 --- a/src/com/falchus/lib/utils/wrapper/Wrapper.java +++ b/src/com/falchus/lib/utils/wrapper/Wrapper.java @@ -1,12 +1,5 @@ package com.falchus.lib.utils.wrapper; -import com.falchus.lib.utils.builder.ClassInstanceBuilder; -import com.falchus.lib.utils.reflection.ReflectionUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NonNull; -import lombok.Setter; - import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -14,69 +7,76 @@ import java.util.Map; import java.util.Set; +import com.falchus.lib.utils.builder.ClassInstanceBuilder; +import com.falchus.lib.utils.reflection.ReflectionUtils; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NonNull; +import lombok.Setter; + @Getter @Setter @AllArgsConstructor public class Wrapper { - @NonNull - protected T handle; - - protected Field getField(@NonNull String name) { - return ReflectionUtils.getField(handle, name); - } - - protected Field getFirstField(@NonNull String... names) { - return ReflectionUtils.getFirstField(handle, names); - } - - protected U getFieldValue(@NonNull Field field) { - return ReflectionUtils.getFieldValue(handle, field); - } - - protected void setField(@NonNull Field field, Object value) { - ReflectionUtils.setField(handle, field, value); - } - - protected void setFirstField(Object value, @NonNull String... names) { - ReflectionUtils.setFirstField(handle, value, names); - } - - protected Method getMethod(@NonNull String name, Class... params) { - return ReflectionUtils.getMethod(handle, name, params); - } - - protected Method getFirstMethod(List> params, @NonNull String... names) { - return ReflectionUtils.getFirstMethod(handle, params, names); - } - - protected Constructor getConstructor(Class... params) { - return ReflectionUtils.getConstructor(handle, params); - } - - protected Constructor getFirstConstructor(Set>> params) { - return ReflectionUtils.getFirstConstructor(handle, params); - } - - @SuppressWarnings("unchecked") - public > U as(@NonNull Class clazz, Class... params) { - if (clazz.isInstance(this)) { - return (U) this; - } - - try { - Map, Object>[] paramMaps = new Map[params.length]; - for (int i = 0; i < params.length; i++) { - paramMaps[i] = Map.of(params[i], handle); - } - - return (U) new ClassInstanceBuilder( - clazz - ).withParams( - paramMaps - ).build(); - } catch (Exception e) { - return null; - } + @NonNull protected T handle; + + protected Field getField(@NonNull String name) { + return ReflectionUtils.getField(handle, name); + } + + protected Field getFirstField(@NonNull String... names) { + return ReflectionUtils.getFirstField(handle, names); + } + + protected U getFieldValue(@NonNull Field field) { + return ReflectionUtils.getFieldValue(handle, field); + } + + protected void setField(@NonNull Field field, Object value) { + ReflectionUtils.setField(handle, field, value); + } + + protected void setFirstField(Object value, @NonNull String... names) { + ReflectionUtils.setFirstField(handle, value, names); + } + + protected Method getMethod(@NonNull String name, Class... params) { + return ReflectionUtils.getMethod(handle, name, params); + } + + protected Method getFirstMethod(List> params, @NonNull String... names) { + return ReflectionUtils.getFirstMethod(handle, params, names); + } + + protected Constructor getConstructor(Class... params) { + return ReflectionUtils.getConstructor(handle, params); } + + protected Constructor getFirstConstructor(Set>> params) { + return ReflectionUtils.getFirstConstructor(handle, params); + } + + @SuppressWarnings("unchecked") + public > U as(@NonNull Class clazz, Class... params) { + if (clazz.isInstance(this)) { + return (U) this; + } + + try { + Map, Object>[] paramMaps = new Map[params.length]; + for (int i = 0; i < params.length; i++) { + paramMaps[i] = Map.of(params[i], handle); + } + + return (U) new ClassInstanceBuilder( + clazz + ).withParams( + paramMaps + ).build(); + } catch (Exception e) { + return null; + } + } } From db31e2881a9dc97f49482ef186ada61414fadfaa Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:25:47 +0200 Subject: [PATCH 248/260] Update DiscordWebhook.java --- src/com/falchus/lib/utils/DiscordWebhook.java | 170 +++++++++--------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/src/com/falchus/lib/utils/DiscordWebhook.java b/src/com/falchus/lib/utils/DiscordWebhook.java index e1f03435..43f8c9f2 100644 --- a/src/com/falchus/lib/utils/DiscordWebhook.java +++ b/src/com/falchus/lib/utils/DiscordWebhook.java @@ -1,14 +1,14 @@ package com.falchus.lib.utils; -import lombok.NonNull; -import lombok.experimental.UtilityClass; - import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.concurrent.CompletableFuture; +import lombok.NonNull; +import lombok.experimental.UtilityClass; + /** * @deprecated since 1.0.0, use JDA instead! */ @@ -16,92 +16,92 @@ @Deprecated(since = "1.0.0") public class DiscordWebhook { - public static void sendMessage(@NonNull String message, @NonNull String webhookUrl) { - CompletableFuture.runAsync(() -> { - try { - URL url = new URL(webhookUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestProperty("User-Agent", "Java-DiscordWebhook/1.0"); - connection.setDoOutput(true); - - String payload = "{\"content\":\"" + escapeJson(message) + "\"}"; - - try (OutputStream outputStream = connection.getOutputStream()) { - outputStream.write(payload.getBytes(StandardCharsets.UTF_8)); - outputStream.flush(); - } - - int responseCode = connection.getResponseCode(); - if (responseCode != 204) { - System.err.println(responseCode); - System.err.println(connection.getResponseMessage()); - } - } catch (Exception e) { - e.printStackTrace(); - } - }); - } + public static void sendMessage(@NonNull String message, @NonNull String webhookUrl) { + CompletableFuture.runAsync(() -> { + try { + URL url = new URL(webhookUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setRequestProperty("User-Agent", "Java-DiscordWebhook/1.0"); + connection.setDoOutput(true); + + String payload = "{\"content\":\"" + escapeJson(message) + "\"}"; + + try (OutputStream outputStream = connection.getOutputStream()) { + outputStream.write(payload.getBytes(StandardCharsets.UTF_8)); + outputStream.flush(); + } + + int responseCode = connection.getResponseCode(); + if (responseCode != 204) { + System.err.println(responseCode); + System.err.println(connection.getResponseMessage()); + } + } catch (Exception e) { + e.printStackTrace(); + } + }); + } public static void sendEmbedMessage(String title, String description, int red, int green, int blue, String footerText, String footerImageUrl, String thumbnailUrl, @NonNull String webhookUrl) { - CompletableFuture.runAsync(() -> { - try { - URL url = new URL(webhookUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); - connection.setRequestProperty("User-Agent", "Java-DiscordWebhook/1.0"); - connection.setDoOutput(true); - - int color = (red << 16) + (green << 8) + blue; - - StringBuilder payload = new StringBuilder(); - payload.append("{\"embeds\":[{"); - - if (title != null) { - payload.append("\"title\":\"").append(escapeJson(title)).append("\","); - } - if (description != null) { - payload.append("\"description\":\"").append(escapeJson(description)).append("\","); - } - payload.append("\"color\":").append(color); - - if (footerText != null) { - payload.append(",\"footer\":{\"text\":\"").append(escapeJson(footerText)).append("\""); - if (footerImageUrl != null) { - payload.append(",\"icon_url\":\"").append(footerImageUrl).append("\""); - } - payload.append("}"); - } - - if (thumbnailUrl != null) { - payload.append(",\"thumbnail\":{\"url\":\"").append(thumbnailUrl).append("\"}"); - } - - payload.append("}]}"); - - try (OutputStream outputStream = connection.getOutputStream()) { - outputStream.write(payload.toString().getBytes(StandardCharsets.UTF_8)); - outputStream.flush(); - } - - int responseCode = connection.getResponseCode(); - if (responseCode != 204) { - System.err.println(responseCode); - System.err.println(connection.getResponseMessage()); - } - } catch (Exception e) { - e.printStackTrace(); - } - }); + CompletableFuture.runAsync(() -> { + try { + URL url = new URL(webhookUrl); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8"); + connection.setRequestProperty("User-Agent", "Java-DiscordWebhook/1.0"); + connection.setDoOutput(true); + + int color = (red << 16) + (green << 8) + blue; + + StringBuilder payload = new StringBuilder(); + payload.append("{\"embeds\":[{"); + + if (title != null) { + payload.append("\"title\":\"").append(escapeJson(title)).append("\","); + } + if (description != null) { + payload.append("\"description\":\"").append(escapeJson(description)).append("\","); + } + payload.append("\"color\":").append(color); + + if (footerText != null) { + payload.append(",\"footer\":{\"text\":\"").append(escapeJson(footerText)).append("\""); + if (footerImageUrl != null) { + payload.append(",\"icon_url\":\"").append(footerImageUrl).append("\""); + } + payload.append("}"); + } + + if (thumbnailUrl != null) { + payload.append(",\"thumbnail\":{\"url\":\"").append(thumbnailUrl).append("\"}"); + } + + payload.append("}]}"); + + try (OutputStream outputStream = connection.getOutputStream()) { + outputStream.write(payload.toString().getBytes(StandardCharsets.UTF_8)); + outputStream.flush(); + } + + int responseCode = connection.getResponseCode(); + if (responseCode != 204) { + System.err.println(responseCode); + System.err.println(connection.getResponseMessage()); + } + } catch (Exception e) { + e.printStackTrace(); + } + }); } private static String escapeJson(@NonNull String text) { return text.replace("\\", "\\\\") - .replace("\"", "\\\"") - .replace("\n", "\\n"); + .replace("\"", "\\\"") + .replace("\n", "\\n"); } -} \ No newline at end of file +} From 89b29528079ea9710ad10258b04b0f0a6260aa6b Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:26:09 +0200 Subject: [PATCH 249/260] Update FastRandom.java --- src/com/falchus/lib/utils/FastRandom.java | 129 +++++++++++----------- 1 file changed, 65 insertions(+), 64 deletions(-) diff --git a/src/com/falchus/lib/utils/FastRandom.java b/src/com/falchus/lib/utils/FastRandom.java index bec3634d..94fd9fbc 100644 --- a/src/com/falchus/lib/utils/FastRandom.java +++ b/src/com/falchus/lib/utils/FastRandom.java @@ -1,84 +1,85 @@ package com.falchus.lib.utils; -import lombok.AllArgsConstructor; +import java.util.Random; import javax.annotation.concurrent.ThreadSafe; -import java.util.Random; + +import lombok.AllArgsConstructor; /** - * Implementation of George Marsaglia's elegant Xorshift random generator which is + * Implementation of George Marsaglia's elegant Xorshift random generator which is * 30% faster and better quality than the built-in java.util.random see also see * http://www.javamex.com/tutorials/random_numbers/xorshift.shtml */ @AllArgsConstructor @ThreadSafe // The fast random can be used with multiple threads public class FastRandom extends Random implements Cloneable { - + private static final long serialVersionUID = 1L; - protected long seed; - - /** - * Creates a new pseudo random number generator. The seed is initialized to the - * current time, as if by setSeed(System.currentTimeMillis());. - */ - public FastRandom() { - this(System.nanoTime()); - } + protected long seed; - /** - * Returns the current state of the seed, can be used to clone the object - * - * @returns the current seed - */ - public synchronized long getSeed() { - return seed; - } + /** + * Creates a new pseudo random number generator. The seed is initialized to the + * current time, as if by setSeed(System.currentTimeMillis());. + */ + public FastRandom() { + this(System.nanoTime()); + } - /** - * Sets the seed for this pseudo random number generator. As described above, - * two instances of the same random class, starting with the same seed, produce - * the same results, if the same methods are called. - * - * @param seed the new seed - */ - public synchronized void setSeed(long seed) { - this.seed = seed; - super.setSeed(seed); - } + /** + * Returns the current state of the seed, can be used to clone the object + * + * @returns the current seed + */ + public synchronized long getSeed() { + return seed; + } - /** - * Sets the specified seed value from the specified int[] - * - * @param array - */ - synchronized public void setSeed(int[] array) { - if (array.length == 0) - throw new IllegalArgumentException("Array length must be greater than zero"); - setSeed(array.hashCode()); - } + /** + * Sets the seed for this pseudo random number generator. As described above, + * two instances of the same random class, starting with the same seed, produce + * the same results, if the same methods are called. + * + * @param seed the new seed + */ + public synchronized void setSeed(long seed) { + this.seed = seed; + super.setSeed(seed); + } - /** - * Returns an XSRandom object with the same state as the original - */ - public FastRandom clone() { - return new FastRandom(getSeed()); - } + /** + * Returns an XSRandom object with the same state as the original + */ + public FastRandom clone() { + return new FastRandom(getSeed()); + } - /** - * Implementation of George Marsaglia's elegant Xorshift random generator 30% - * faster and better quality than the built-in java.util.random see also see - * http://www.javamex.com/tutorials/random_numbers/xorshift.shtml - */ - @Override - protected int next(int nbits) { - long x = seed; - x ^= (x << 21); - x ^= (x >>> 35); - x ^= (x << 4); - seed = x; - x &= ((1L << nbits) - 1); + /** + * Implementation of George Marsaglia's elegant Xorshift random generator 30% + * faster and better quality than the built-in java.util.random see also see + * http://www.javamex.com/tutorials/random_numbers/xorshift.shtml + */ + @Override + protected int next(int nbits) { + long x = seed; + x ^= (x << 21); + x ^= (x >>> 35); + x ^= (x << 4); + seed = x; + x &= ((1L << nbits) - 1); + + return (int) x; + } - return (int) x; - } -} \ No newline at end of file + /** + * Sets the specified seed value from the specified int[] + * + * @param array + */ + synchronized public void setSeed(int[] array) { + if (array.length == 0) + throw new IllegalArgumentException("Array length must be greater than zero"); + setSeed(array.hashCode()); + } +} From e5e90551f19cbaae698f48f5c4a4315443c46937 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:26:28 +0200 Subject: [PATCH 250/260] Update FileUtils.java --- src/com/falchus/lib/utils/FileUtils.java | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/com/falchus/lib/utils/FileUtils.java b/src/com/falchus/lib/utils/FileUtils.java index 5969100d..297e6505 100644 --- a/src/com/falchus/lib/utils/FileUtils.java +++ b/src/com/falchus/lib/utils/FileUtils.java @@ -1,23 +1,23 @@ package com.falchus.lib.utils; -import lombok.experimental.UtilityClass; - import java.io.File; +import lombok.experimental.UtilityClass; + @UtilityClass public class FileUtils { - public static void deleteFolder(File folder) { - File[] files = folder.listFiles(); - if (files != null) { - for (File file : files) { - if (file.isDirectory()) { - deleteFolder(file); - } else { - file.delete(); - } - } - } - folder.delete(); - } + public static void deleteFolder(File folder) { + File[] files = folder.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isDirectory()) { + deleteFolder(file); + } else { + file.delete(); + } + } + } + folder.delete(); + } } From 51635e5cbfbf96ca48962b01ee125af648f91bd3 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:26:39 +0200 Subject: [PATCH 251/260] Update MySQL.java --- src/com/falchus/lib/utils/MySQL.java | 120 +++++++++++++-------------- 1 file changed, 58 insertions(+), 62 deletions(-) diff --git a/src/com/falchus/lib/utils/MySQL.java b/src/com/falchus/lib/utils/MySQL.java index f6ca08ef..0b64a505 100644 --- a/src/com/falchus/lib/utils/MySQL.java +++ b/src/com/falchus/lib/utils/MySQL.java @@ -1,76 +1,72 @@ package com.falchus.lib.utils; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + @RequiredArgsConstructor public class MySQL { - @NonNull - private final String host; - private final int port; - @NonNull - private final String database; - @NonNull - private final String username; - private final String password; - + @NonNull private final String host; + private final int port; + @NonNull private final String database; + @NonNull private final String username; + private final String password; + private final ThreadLocal connection = new ThreadLocal<>(); + + /** + * Establishes a new connection if none is currently open. + * + * @throws SQLException + */ + public void connect() throws SQLException { + if (isConnected()) return; + String url = "jdbc:mysql://" + host + ":" + port + "/" + database + + "?useSSL=false&autoReconnect=true&characterEncoding=UTF-8&useUnicode=true"; - /** - * Establishes a new connection if none is currently open. - * - * @throws SQLException - */ - public void connect() throws SQLException { - if (isConnected()) return; - String url = "jdbc:mysql://" + host + ":" + port + "/" + database - + "?useSSL=false&autoReconnect=true&characterEncoding=UTF-8&useUnicode=true"; - - Connection connection = (password == null) - ? DriverManager.getConnection(url, username, "") - : DriverManager.getConnection(url, username, password); - this.connection.set(connection); - } - - /** - * Checks whether the connection is active and not closed. - * - * @return true if a valid connection is open - */ - public boolean isConnected() { - try { - Connection connection = this.connection.get(); - return connection != null && !connection.isClosed(); - } catch (SQLException e) { - return false; - } - } - - /** - * Closes the current connection if it exists. - */ - public void disconnect() { - Connection connection = this.connection.get(); - if (connection != null) { - try { - connection.close(); - } catch (SQLException ignored) { - } - this.connection.remove(); - } - } - - /** - * Returns the active connection, reconnecting if necessary. - * - * @return an open {@link Connection} instance (may be newly created) - * @throws SQLException - */ + Connection connection = (password == null) + ? DriverManager.getConnection(url, username, "") + : DriverManager.getConnection(url, username, password); + this.connection.set(connection); + } + + /** + * Checks whether the connection is active and not closed. + * + * @return true if a valid connection is open + */ + public boolean isConnected() { + try { + Connection connection = this.connection.get(); + return connection != null && !connection.isClosed(); + } catch (SQLException e) { + return false; + } + } + + /** + * Closes the current connection if it exists. + */ + public void disconnect() { + Connection connection = this.connection.get(); + if (connection != null) { + try { + connection.close(); + } catch (SQLException ignored) {} + this.connection.remove(); + } + } + + /** + * Returns the active connection, reconnecting if necessary. + * + * @return an open {@link Connection} instance (may be newly created) + * @throws SQLException + */ public Connection getConnection() throws SQLException { if (!isConnected()) { connect(); From c5e498b1ea10b02fae1dbd309603e73b6decef58 Mon Sep 17 00:00:00 2001 From: Elias Date: Fri, 10 Apr 2026 23:26:51 +0200 Subject: [PATCH 252/260] Update VPNApi.java --- src/com/falchus/lib/utils/VPNApi.java | 41 ++++++++++++++------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/com/falchus/lib/utils/VPNApi.java b/src/com/falchus/lib/utils/VPNApi.java index c43dd137..e7c1a733 100644 --- a/src/com/falchus/lib/utils/VPNApi.java +++ b/src/com/falchus/lib/utils/VPNApi.java @@ -3,30 +3,31 @@ import com.falchus.lib.utils.http.HTTPRequest; import com.google.gson.JsonObject; import com.google.gson.JsonParser; + import lombok.NonNull; import lombok.experimental.UtilityClass; @UtilityClass public class VPNApi { - /** - * Checks if the given IP is a VPN. - * via vpnapi.io - * - * @return {@code true} if it is, {@code false} otherwise. - */ - public static boolean isVPN(@NonNull String ip, String apiKey) { - String url = "https://vpnapi.io/api/" + ip; - if (apiKey != null && !apiKey.isEmpty()) { - url += "?key=" + apiKey; - } - - String body = HTTPRequest.get(url); - if (body == null) return false; - - JsonObject json = JsonParser.parseString(body).getAsJsonObject(); - return json.has("security") && - json.getAsJsonObject("security").has("vpn") && - json.getAsJsonObject("security").get("vpn").getAsBoolean(); - } + /** + * Checks if the given IP is a VPN. + * via vpnapi.io + * + * @return {@code true} if it is, {@code false} otherwise. + */ + public static boolean isVPN(@NonNull String ip, String apiKey) { + String url = "https://vpnapi.io/api/" + ip; + if (apiKey != null && !apiKey.isEmpty()) { + url += "?key=" + apiKey; + } + + String body = HTTPRequest.get(url); + if (body == null) return false; + + JsonObject json = JsonParser.parseString(body).getAsJsonObject(); + return json.has("security") && + json.getAsJsonObject("security").has("vpn") && + json.getAsJsonObject("security").get("vpn").getAsBoolean(); + } } From b02cab42b835f6cddb575fdb7d4eb4399f75bf4f Mon Sep 17 00:00:00 2001 From: Elias Date: Sat, 11 Apr 2026 01:26:48 +0200 Subject: [PATCH 253/260] store plugin instance in SchedulerUtils --- .../lib/minecraft/spigot/utils/SchedulerUtils.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java index 286126e5..2479a4cd 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java @@ -21,11 +21,12 @@ @UtilityClass public class SchedulerUtils { + private final FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); + /** * Runs a task on the main thread (Bukkit) or the global region thread (Folia). */ public static void runTask(@NonNull Runnable runnable) { - FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); if (FalchusLibMinecraft.isFolia()) { Bukkit.getGlobalRegionScheduler().run(plugin, task -> runnable.run()); } else { @@ -37,7 +38,6 @@ public static void runTask(@NonNull Runnable runnable) { * Runs a task asynchronously on both Bukkit and Folia. */ public static void runTaskAsync(@NonNull Runnable runnable) { - FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); if (FalchusLibMinecraft.isFolia()) { Bukkit.getAsyncScheduler().runNow(plugin, task -> runnable.run()); } else { @@ -57,7 +57,6 @@ public static void runTaskAsync(@NonNull Runnable runnable) { * @param runnable the task to execute */ public static void runTaskForEntity(@NonNull Entity entity, @NonNull Runnable runnable) { - FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); if (FalchusLibMinecraft.isFolia()) { // Returns null if the entity is no longer valid — safe to ignore. entity.getScheduler().run(plugin, task -> runnable.run(), null); @@ -73,11 +72,10 @@ public static void runTaskForEntity(@NonNull Entity entity, @NonNull Runnable ru * @param delayTicks delay in server ticks (1 tick ≈ 50 ms) */ public static void runTaskLater(@NonNull Runnable runnable, long delayTicks) { - FalchusLibMinecraftSpigot plugin = FalchusLibMinecraftSpigot.getInstance(); if (FalchusLibMinecraft.isFolia()) { Bukkit.getGlobalRegionScheduler().runDelayed(plugin, task -> runnable.run(), Math.max(1, delayTicks)); } else { Bukkit.getScheduler().runTaskLater(plugin, runnable, Math.max(1, delayTicks)); } } -} \ No newline at end of file +} From a208132a1dc6d2ef11f8442197b3b1660a9332d6 Mon Sep 17 00:00:00 2001 From: Elias Date: Sat, 11 Apr 2026 01:33:54 +0200 Subject: [PATCH 254/260] Update Sound.java --- src/com/falchus/lib/minecraft/spigot/enums/Sound.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/falchus/lib/minecraft/spigot/enums/Sound.java b/src/com/falchus/lib/minecraft/spigot/enums/Sound.java index 78e05c21..10b57b1c 100644 --- a/src/com/falchus/lib/minecraft/spigot/enums/Sound.java +++ b/src/com/falchus/lib/minecraft/spigot/enums/Sound.java @@ -21,5 +21,5 @@ public enum Sound { ANVIL_LAND("BLOCK_ANVIL_LAND"), BAT_TAKEOFF("ENTITY_BAT_TAKEOFF"); - public final String modernName; + private final String modernName; } From 52e94e8ae65fc85b4d6eecf138eb1e5d49f7bb4c Mon Sep 17 00:00:00 2001 From: Elias Date: Sat, 11 Apr 2026 01:37:10 +0200 Subject: [PATCH 255/260] Update FalchusLibMinecraft.java --- .../lib/minecraft/FalchusLibMinecraft.java | 52 ++++++++----------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/src/com/falchus/lib/minecraft/FalchusLibMinecraft.java b/src/com/falchus/lib/minecraft/FalchusLibMinecraft.java index 88bb0ccf..9b039ed4 100644 --- a/src/com/falchus/lib/minecraft/FalchusLibMinecraft.java +++ b/src/com/falchus/lib/minecraft/FalchusLibMinecraft.java @@ -1,50 +1,40 @@ package com.falchus.lib.minecraft; import com.falchus.lib.minecraft.enums.Software; -import org.jetbrains.annotations.Nullable; /** * Class for detecting the Minecraft server software at runtime. */ public class FalchusLibMinecraft { - private static Software cached; + private static Software software; - /** - * Detects the server software by checking for known classes. - * Result is cached after first call. - * + /** + * Detects the server software by checking for known classes. + * * @return {@link Software} or {@code null} if unknown. - */ - public static @Nullable Software getSoftware() { - if (cached != null) return cached; + */ + public static Software getSoftware() { + if (software != null) return software; - String[] classNames = { - "io.papermc.paper.threadedregions.RegionizedServer", - "org.bukkit.plugin.java.JavaPlugin", - "com.velocitypowered.api.plugin.Plugin" - }; - Software[] softwares = { - Software.FOLIA, - Software.SPIGOT, - Software.VELOCITY - }; + String[] classNames = { + "io.papermc.paper.threadedregions.RegionizedServer", + "org.bukkit.plugin.java.JavaPlugin", + "com.velocitypowered.api.plugin.Plugin" + }; + Software[] softwares = { + Software.FOLIA, + Software.SPIGOT, + Software.VELOCITY + }; for (int i = 0; i < classNames.length; i++) { try { Class.forName(classNames[i]); - cached = softwares[i]; - return cached; - } catch (ClassNotFoundException ignored) { - } + software = softwares[i]; + return software; + } catch (ClassNotFoundException ignored) {} } return null; } - - /** - * @return {@code true} if the server is running Folia. - */ - public static boolean isFolia() { - return getSoftware() == Software.FOLIA; - } -} \ No newline at end of file +} From 8d95a5ecda5784a11fa12110d05de0914cc0648c Mon Sep 17 00:00:00 2001 From: Elias Date: Sat, 11 Apr 2026 01:42:20 +0200 Subject: [PATCH 256/260] Update SchedulerUtils.java --- .../lib/minecraft/spigot/utils/SchedulerUtils.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java b/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java index 2479a4cd..f7deb7ae 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/SchedulerUtils.java @@ -1,6 +1,7 @@ package com.falchus.lib.minecraft.spigot.utils; import com.falchus.lib.minecraft.FalchusLibMinecraft; +import com.falchus.lib.minecraft.enums.Software; import com.falchus.lib.minecraft.spigot.FalchusLibMinecraftSpigot; import lombok.NonNull; import lombok.experimental.UtilityClass; @@ -27,7 +28,7 @@ public class SchedulerUtils { * Runs a task on the main thread (Bukkit) or the global region thread (Folia). */ public static void runTask(@NonNull Runnable runnable) { - if (FalchusLibMinecraft.isFolia()) { + if (FalchusLibMinecraft.getSoftware() == Software.FOLIA) { Bukkit.getGlobalRegionScheduler().run(plugin, task -> runnable.run()); } else { Bukkit.getScheduler().runTask(plugin, runnable); @@ -38,7 +39,7 @@ public static void runTask(@NonNull Runnable runnable) { * Runs a task asynchronously on both Bukkit and Folia. */ public static void runTaskAsync(@NonNull Runnable runnable) { - if (FalchusLibMinecraft.isFolia()) { + if (FalchusLibMinecraft.getSoftware() == Software.FOLIA) { Bukkit.getAsyncScheduler().runNow(plugin, task -> runnable.run()); } else { Bukkit.getScheduler().runTaskAsynchronously(plugin, runnable); @@ -57,7 +58,7 @@ public static void runTaskAsync(@NonNull Runnable runnable) { * @param runnable the task to execute */ public static void runTaskForEntity(@NonNull Entity entity, @NonNull Runnable runnable) { - if (FalchusLibMinecraft.isFolia()) { + if (FalchusLibMinecraft.getSoftware() == Software.FOLIA) { // Returns null if the entity is no longer valid — safe to ignore. entity.getScheduler().run(plugin, task -> runnable.run(), null); } else { @@ -72,7 +73,7 @@ public static void runTaskForEntity(@NonNull Entity entity, @NonNull Runnable ru * @param delayTicks delay in server ticks (1 tick ≈ 50 ms) */ public static void runTaskLater(@NonNull Runnable runnable, long delayTicks) { - if (FalchusLibMinecraft.isFolia()) { + if (FalchusLibMinecraft.getSoftware() == Software.FOLIA) { Bukkit.getGlobalRegionScheduler().runDelayed(plugin, task -> runnable.run(), Math.max(1, delayTicks)); } else { Bukkit.getScheduler().runTaskLater(plugin, runnable, Math.max(1, delayTicks)); From 983e7f145ff2e9e0249c6b7e14cb950f9baf6c00 Mon Sep 17 00:00:00 2001 From: Elias Date: Sat, 11 Apr 2026 01:42:55 +0200 Subject: [PATCH 257/260] Update VersionProvider.java --- .../lib/minecraft/spigot/utils/version/VersionProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java index 6b11c369..7837fdc5 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java @@ -1,6 +1,7 @@ package com.falchus.lib.minecraft.spigot.utils.version; import com.falchus.lib.minecraft.FalchusLibMinecraft; +import com.falchus.lib.minecraft.enums.Software; import com.falchus.lib.minecraft.spigot.enums.Version; import com.falchus.lib.minecraft.spigot.utils.ServerUtils; import com.falchus.lib.minecraft.spigot.utils.version.v1_21_R1.VersionAdapter_v1_21_R1; @@ -31,7 +32,7 @@ public class VersionProvider { private static IVersionAdapter adapter; private static IVersionAdapter load() { - if (FalchusLibMinecraft.isFolia()) { + if (FalchusLibMinecraft.getSoftware() == Software.FOLIA) { return new VersionAdapterFolia(); } @@ -90,4 +91,4 @@ public static IVersionAdapter get() { public static void reset() { adapter = null; } -} \ No newline at end of file +} From a37fc36dd7c8da95bd36681f6dd869d2008cc30b Mon Sep 17 00:00:00 2001 From: Elias Date: Sat, 11 Apr 2026 01:45:09 +0200 Subject: [PATCH 258/260] don't update yet --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index bc0da007..9ee7b912 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.falchus lib-java - 1.10.3 + 1.10.2 21 @@ -143,4 +143,4 @@ - \ No newline at end of file + From a97feb23df8c7db7a437c551b196f4d865765ff7 Mon Sep 17 00:00:00 2001 From: Elias Date: Sat, 11 Apr 2026 01:45:46 +0200 Subject: [PATCH 259/260] Update Software.java --- src/com/falchus/lib/minecraft/enums/Software.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/com/falchus/lib/minecraft/enums/Software.java b/src/com/falchus/lib/minecraft/enums/Software.java index 92655716..39b35d9b 100644 --- a/src/com/falchus/lib/minecraft/enums/Software.java +++ b/src/com/falchus/lib/minecraft/enums/Software.java @@ -1,7 +1,7 @@ package com.falchus.lib.minecraft.enums; public enum Software { + FOLIA, SPIGOT, - VELOCITY, - FOLIA -} \ No newline at end of file + VELOCITY +} From 32477451943409e9017c77a23254469caa836efb Mon Sep 17 00:00:00 2001 From: Elias Date: Sat, 11 Apr 2026 16:00:32 +0200 Subject: [PATCH 260/260] Update VersionProvider.java --- .../spigot/utils/version/VersionProvider.java | 77 +++++-------------- 1 file changed, 20 insertions(+), 57 deletions(-) diff --git a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java index 7837fdc5..5a4ba2b6 100644 --- a/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java +++ b/src/com/falchus/lib/minecraft/spigot/utils/version/VersionProvider.java @@ -1,5 +1,7 @@ package com.falchus.lib.minecraft.spigot.utils.version; +import org.bukkit.Bukkit; + import com.falchus.lib.minecraft.FalchusLibMinecraft; import com.falchus.lib.minecraft.enums.Software; import com.falchus.lib.minecraft.spigot.enums.Version; @@ -9,22 +11,12 @@ import com.falchus.lib.minecraft.spigot.utils.version.v26_1_R1.VersionAdapter_v26_1_R1; import com.falchus.lib.minecraft.spigot.utils.version.v_1_13_R1.VersionAdapter_v_1_13_R1; import com.falchus.lib.utils.builder.ClassInstanceBuilder; + import lombok.experimental.UtilityClass; -import org.bukkit.Bukkit; /** * Provides the {@link IVersionAdapter} for the current server version. - *

- * Selection order (most specific → least specific): - *

    - *
  1. Folia on any supported version → {@link VersionAdapterFolia}
  2. - *
  3. Paper 26.x.x → {@link VersionAdapter_v26_1_R1}
  4. - *
  5. 1.21.x → {@link VersionAdapter_v1_21_R1}
  6. - *
  7. 1.17–1.20 → {@link VersionAdapterModern}
  8. - *
  9. 1.13–1.16 → {@link VersionAdapter_v_1_13_R1}
  10. - *
  11. 1.9–1.12 → {@link VersionAdapter_v1_9_R1}
  12. - *
  13. 1.8 → {@link VersionAdapter}
  14. - *
+ * By default, returns {@link VersionAdapter}. */ @UtilityClass public class VersionProvider { @@ -37,44 +29,22 @@ private static IVersionAdapter load() { } Version version = ServerUtils.getVersion(); - int major = ServerUtils.getMajorVersion(); - - if (major >= 26) { - return new VersionAdapter_v26_1_R1(); - } - - if (version.isAfter(Version.v1_20)) { - return new VersionAdapter_v1_21_R1(); - } - - if (version.isAfter(Version.v1_16)) { - return new VersionAdapterModern(); - } - - if (version.isAfter(Version.v1_12)) { - return new VersionAdapter_v_1_13_R1(); - } - - if (version.isAfter(Version.v1_8)) { - return new VersionAdapter_v1_9_R1(); - } - - if (version.isBefore(Version.v1_9)) { - return new VersionAdapter(); - } - - try { - String[] parts = Bukkit.getServer().getClass().getPackageName().split("\\."); - if (parts.length >= 4) { - String ver = parts[3]; - return (IVersionAdapter) new ClassInstanceBuilder( - VersionProvider.class.getPackageName() + "." + ver - + "." + VersionAdapter.class.getSimpleName() + "_" + ver - ).build(); - } - } catch (Exception ignored) { - } - + if (version.isAfter(Version.v1_21)) return new VersionAdapter_v26_1_R1(); + if (version.isAfter(Version.v1_20)) return new VersionAdapter_v1_21_R1(); + if (version.isAfter(Version.v1_16)) return new VersionAdapterModern(); + if (version.isAfter(Version.v1_12)) return new VersionAdapter_v_1_13_R1(); + if (version.isAfter(Version.v1_8)) return new VersionAdapter_v1_9_R1(); + if (version.isBefore(Version.v1_9)) return new VersionAdapter(); + + try { + String[] parts = Bukkit.getServer().getClass().getPackageName().split("\\."); + if (parts.length >= 4) { + String ver = parts[3]; + return (IVersionAdapter) new ClassInstanceBuilder( + VersionProvider.class.getPackageName() + "." + ver + "." + VersionAdapter.class.getSimpleName() + "_" + ver + ).build(); + } + } catch (Exception ignored) {} return new VersionAdapter(); } @@ -84,11 +54,4 @@ public static IVersionAdapter get() { } return adapter; } - - /** - * Resets the cached adapter — useful in tests or hot-reload scenarios. - */ - public static void reset() { - adapter = null; - } }