mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
1.21.4 (#413)
* init 1.21.4, and boom! * build change, but weight not work * just work * Build changes, and delete timings * Fix API patches (#406) * Fix API patches * merge --------- Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> * 0006/0129 * 0009/0129 * 0011/0129 * 0018/0129 * 0030/0129 * 0035/0129 * 0043/0129 * 0048/0129 * 0049/0129 * 0057/0129 * 0065/0129 * 0086/0129 (#408) * 0072/0129 * 0080/0129 * Readd patch infos * 0086/0129 * Delete applied patches * 0087/0129 * 0091/0129 * 0097/0129 * 0101/0129 * 102/129 * 0107/0129 * 0112/0129 * 0118/0129 * 0129/0129, 100% patched * fix some * server work * Protocol... (#409) * Jade v7 * Fix changed part for Jade * Formatting imports, add Lms Paster protocol * REI payloads 5/8 * Add REI support, remove unnecessary content in Jade * Rename * Make jade better * Make action work * fix action jar * Fix some protocol * Fix bot action, and entity tickCount * Fix Warden GameEventListener register on load * Fix extra Raider drop * Fix grindstone overstacking * Update Paper, and some doc * Merge * [ci skip] Update Action --------- Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
This commit is contained in:
412
leaves-api/paper-patches/features/0007-Bytebuf-API.patch
Normal file
412
leaves-api/paper-patches/features/0007-Bytebuf-API.patch
Normal file
@@ -0,0 +1,412 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
|
||||
Date: Wed, 22 May 2024 10:12:04 +0800
|
||||
Subject: [PATCH] Bytebuf API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 9564d2e3f3126104f73a1942ea5c45a69ebb158a..63c90d151f4a50e2da63f640587d7041dcc1a8b6 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -2996,6 +2996,12 @@ public final class Bukkit {
|
||||
}
|
||||
// Leaves end - Photographer API
|
||||
|
||||
+ // Leaves start - Bytebuf API
|
||||
+ public static org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager() {
|
||||
+ return server.getBytebufManager();
|
||||
+ }
|
||||
+ // Leaves end - Bytebuf API
|
||||
+
|
||||
@NotNull
|
||||
public static Server.Spigot spigot() {
|
||||
return server.spigot();
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 991ec55218da08377bb71272fd6bca9f3bed0582..2590bc0813672ca566dfae734812de6a53519a1a 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2672,4 +2672,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
// Leaves start - Photographer API
|
||||
@NotNull PhotographerManager getPhotographerManager();
|
||||
// Leaves end - Photographer API
|
||||
+
|
||||
+ // Leaves start - Bytebuf API
|
||||
+ org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager();
|
||||
+ // Leaves end - Bytebuf API
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 0081dd53b6a81ce7892e58d61f9f8a6718e30775..c706a782a1739b54af85d4b6a996bf1d5d571ba1 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3853,6 +3853,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
boolean isChunkSent(long chunkKey);
|
||||
// Paper end
|
||||
|
||||
+ // Leaves start - Bytebuf API
|
||||
+ void sendPacket(org.leavesmc.leaves.bytebuf.packet.Packet packet);
|
||||
+
|
||||
+ void sendPacket(org.leavesmc.leaves.bytebuf.Bytebuf buf, org.leavesmc.leaves.bytebuf.packet.PacketType type);
|
||||
+ // Leaves end - Bytebuf API
|
||||
+
|
||||
@Override
|
||||
Spigot spigot();
|
||||
// Spigot end
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java b/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7038b2a5090154fe8d75ba9c9413952d834bb609
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java
|
||||
@@ -0,0 +1,107 @@
|
||||
+package org.leavesmc.leaves.bytebuf;
|
||||
+
|
||||
+import com.google.gson.JsonElement;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+
|
||||
+import java.util.UUID;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public interface Bytebuf {
|
||||
+
|
||||
+ static Bytebuf buf(int size) {
|
||||
+ return Bukkit.getBytebufManager().newBytebuf(size);
|
||||
+ }
|
||||
+
|
||||
+ static Bytebuf buf() {
|
||||
+ return buf(128);
|
||||
+ }
|
||||
+
|
||||
+ static Bytebuf of(byte[] bytes) {
|
||||
+ return Bukkit.getBytebufManager().toBytebuf(bytes);
|
||||
+ }
|
||||
+
|
||||
+ byte[] toArray();
|
||||
+
|
||||
+ Bytebuf skipBytes(int i);
|
||||
+
|
||||
+ int readerIndex();
|
||||
+
|
||||
+ Bytebuf readerIndex(int i);
|
||||
+
|
||||
+ int writerIndex();
|
||||
+
|
||||
+ Bytebuf writerIndex(int i);
|
||||
+
|
||||
+ Bytebuf resetReaderIndex();
|
||||
+
|
||||
+ Bytebuf resetWriterIndex();
|
||||
+
|
||||
+ Bytebuf writeByte(int i);
|
||||
+
|
||||
+ byte readByte();
|
||||
+
|
||||
+ Bytebuf writeBoolean(boolean b);
|
||||
+
|
||||
+ boolean readBoolean();
|
||||
+
|
||||
+ Bytebuf writeFloat(float f);
|
||||
+
|
||||
+ float readFloat();
|
||||
+
|
||||
+ Bytebuf writeDouble(double d);
|
||||
+
|
||||
+ double readDouble();
|
||||
+
|
||||
+ Bytebuf writeShort(int i);
|
||||
+
|
||||
+ short readShort();
|
||||
+
|
||||
+ Bytebuf writeInt(int i);
|
||||
+
|
||||
+ int readInt();
|
||||
+
|
||||
+ Bytebuf writeLong(long i);
|
||||
+
|
||||
+ long readLong();
|
||||
+
|
||||
+ Bytebuf writeVarInt(int i);
|
||||
+
|
||||
+ int readVarInt();
|
||||
+
|
||||
+ Bytebuf writeVarLong(long i);
|
||||
+
|
||||
+ long readVarLong();
|
||||
+
|
||||
+ Bytebuf writeUUID(UUID uuid);
|
||||
+
|
||||
+ UUID readUUID();
|
||||
+
|
||||
+ Bytebuf writeEnum(Enum<?> instance);
|
||||
+
|
||||
+ <T extends Enum<T>> T readEnum(Class<T> enumClass);
|
||||
+
|
||||
+ Bytebuf writeUTFString(String utf);
|
||||
+
|
||||
+ String readUTFString();
|
||||
+
|
||||
+ Bytebuf writeComponentPlain(String str);
|
||||
+
|
||||
+ String readComponentPlain();
|
||||
+
|
||||
+ Bytebuf writeComponentJson(JsonElement json);
|
||||
+
|
||||
+ JsonElement readComponentJson();
|
||||
+
|
||||
+ Bytebuf writeItemStack(ItemStack itemStack);
|
||||
+
|
||||
+ ItemStack readItemStack();
|
||||
+
|
||||
+ Bytebuf writeItemStackList(List<ItemStack> itemStacks);
|
||||
+
|
||||
+ List<ItemStack> readItemStackList();
|
||||
+
|
||||
+ Bytebuf copy();
|
||||
+
|
||||
+ boolean release();
|
||||
+}
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/BytebufManager.java b/src/main/java/org/leavesmc/leaves/bytebuf/BytebufManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8668e47dee7a23d7843efc4a9752919f7a1dce88
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/BytebufManager.java
|
||||
@@ -0,0 +1,15 @@
|
||||
+package org.leavesmc.leaves.bytebuf;
|
||||
+
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+import org.leavesmc.leaves.bytebuf.packet.PacketListener;
|
||||
+
|
||||
+public interface BytebufManager {
|
||||
+
|
||||
+ void registerListener(Plugin plugin, PacketListener listener);
|
||||
+
|
||||
+ void unregisterListener(Plugin plugin, PacketListener listener);
|
||||
+
|
||||
+ Bytebuf newBytebuf(int size);
|
||||
+
|
||||
+ Bytebuf toBytebuf(byte[] bytes);
|
||||
+}
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/packet/Packet.java b/src/main/java/org/leavesmc/leaves/bytebuf/packet/Packet.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8bb00c16fe3e6089397cc0fcaaec4715960dd724
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/packet/Packet.java
|
||||
@@ -0,0 +1,6 @@
|
||||
+package org.leavesmc.leaves.bytebuf.packet;
|
||||
+
|
||||
+import org.leavesmc.leaves.bytebuf.Bytebuf;
|
||||
+
|
||||
+public record Packet(PacketType type, Bytebuf bytebuf) {
|
||||
+}
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketListener.java b/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketListener.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e246c0a8725fa3b2be065433652a19a565c7205c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketListener.java
|
||||
@@ -0,0 +1,10 @@
|
||||
+package org.leavesmc.leaves.bytebuf.packet;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+
|
||||
+public interface PacketListener {
|
||||
+
|
||||
+ Packet onPacketIn(Player player, Packet packet);
|
||||
+
|
||||
+ Packet onPacketOut(Player player, Packet packet);
|
||||
+}
|
||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketType.java b/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketType.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ceebd752f4c3e50943b22902e01eaf9648941785
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketType.java
|
||||
@@ -0,0 +1,191 @@
|
||||
+package org.leavesmc.leaves.bytebuf.packet;
|
||||
+
|
||||
+public enum PacketType {
|
||||
+ // ClientboundBundle,
|
||||
+ // ClientboundBundleDelimiter,
|
||||
+ ClientboundAddEntity,
|
||||
+ ClientboundAddExperienceOrb,
|
||||
+ ClientboundAnimate,
|
||||
+ ClientboundAwardStats,
|
||||
+ ClientboundBlockChangedAck,
|
||||
+ ClientboundBlockDestruction,
|
||||
+ ClientboundBlockEntityData,
|
||||
+ ClientboundBlockEvent,
|
||||
+ ClientboundBlockUpdate,
|
||||
+ ClientboundBossEvent,
|
||||
+ ClientboundChangeDifficulty,
|
||||
+ ClientboundChunkBatchFinished,
|
||||
+ ClientboundChunkBatchStart,
|
||||
+ ClientboundChunksBiomes,
|
||||
+ ClientboundClearTitles,
|
||||
+ ClientboundCommandSuggestions,
|
||||
+ ClientboundCommands,
|
||||
+ ClientboundContainerClose,
|
||||
+ ClientboundContainerSetContent,
|
||||
+ ClientboundContainerSetData,
|
||||
+ ClientboundContainerSetSlot,
|
||||
+ ClientboundCooldown,
|
||||
+ ClientboundCustomChatCompletions,
|
||||
+ ClientboundDamageEvent,
|
||||
+ ClientboundDebugSample,
|
||||
+ ClientboundDeleteChat,
|
||||
+ ClientboundDisguisedChat,
|
||||
+ ClientboundEntityEvent,
|
||||
+ ClientboundExplode,
|
||||
+ ClientboundForgetLevelChunk,
|
||||
+ ClientboundGameEvent,
|
||||
+ ClientboundHorseScreenOpen,
|
||||
+ ClientboundHurtAnimation,
|
||||
+ ClientboundInitializeBorder,
|
||||
+ ClientboundLevelChunkWithLight,
|
||||
+ ClientboundLevelEvent,
|
||||
+ ClientboundLevelParticles,
|
||||
+ ClientboundLightUpdate,
|
||||
+ ClientboundLogin,
|
||||
+ ClientboundMapItemData,
|
||||
+ ClientboundMerchantOffers,
|
||||
+ ClientboundMoveEntityPos,
|
||||
+ ClientboundMoveEntityPosRot,
|
||||
+ ClientboundMoveEntityRot,
|
||||
+ ClientboundMoveVehicle,
|
||||
+ ClientboundOpenBook,
|
||||
+ ClientboundOpenScreen,
|
||||
+ ClientboundOpenSignEditor,
|
||||
+ ClientboundPlaceGhostRecipe,
|
||||
+ ClientboundPlayerAbilities,
|
||||
+ ClientboundPlayerChat,
|
||||
+ ClientboundPlayerCombatEnd,
|
||||
+ ClientboundPlayerCombatEnter,
|
||||
+ ClientboundPlayerCombatKill,
|
||||
+ ClientboundPlayerInfoRemove,
|
||||
+ ClientboundPlayerInfoUpdate,
|
||||
+ ClientboundPlayerLookAt,
|
||||
+ ClientboundPlayerPosition,
|
||||
+ ClientboundRecipe,
|
||||
+ ClientboundRemoveEntities,
|
||||
+ ClientboundRemoveMobEffect,
|
||||
+ ClientboundRespawn,
|
||||
+ ClientboundRotateHead,
|
||||
+ ClientboundSectionBlocksUpdate,
|
||||
+ ClientboundSelectAdvancementsTab,
|
||||
+ ClientboundServerData,
|
||||
+ ClientboundSetActionBarText,
|
||||
+ ClientboundSetBorderCenter,
|
||||
+ ClientboundSetBorderLerpSize,
|
||||
+ ClientboundSetBorderSize,
|
||||
+ ClientboundSetBorderWarningDelay,
|
||||
+ ClientboundSetBorderWarningDistance,
|
||||
+ ClientboundSetCamera,
|
||||
+ ClientboundSetCarriedItem,
|
||||
+ ClientboundSetChunkCacheCenter,
|
||||
+ ClientboundSetChunkCacheRadius,
|
||||
+ ClientboundSetDefaultSpawnPosition,
|
||||
+ ClientboundSetDisplayObjective,
|
||||
+ ClientboundSetEntityData,
|
||||
+ ClientboundSetEntityLink,
|
||||
+ ClientboundSetEntityMotion,
|
||||
+ ClientboundSetEquipment,
|
||||
+ ClientboundSetExperience,
|
||||
+ ClientboundSetHealth,
|
||||
+ ClientboundSetObjective,
|
||||
+ ClientboundSetPassengers,
|
||||
+ ClientboundSetPlayerTeam,
|
||||
+ ClientboundSetScore,
|
||||
+ ClientboundSetSimulationDistance,
|
||||
+ ClientboundSetSubtitleText,
|
||||
+ ClientboundSetTime,
|
||||
+ ClientboundSetTitleText,
|
||||
+ ClientboundSetTitlesAnimation,
|
||||
+ ClientboundSoundEntity,
|
||||
+ ClientboundSound,
|
||||
+ ClientboundStartConfiguration,
|
||||
+ ClientboundStopSound,
|
||||
+ ClientboundSystemChat,
|
||||
+ ClientboundTabList,
|
||||
+ ClientboundTagQuery,
|
||||
+ ClientboundTakeItemEntity,
|
||||
+ ClientboundTeleportEntity,
|
||||
+ ClientboundUpdateAdvancements,
|
||||
+ ClientboundUpdateAttributes,
|
||||
+ ClientboundUpdateMobEffect,
|
||||
+ ClientboundUpdateRecipes,
|
||||
+ ClientboundProjectilePower,
|
||||
+ ServerboundAcceptTeleportation,
|
||||
+ ServerboundBlockEntityTagQuery,
|
||||
+ ServerboundChangeDifficulty,
|
||||
+ ServerboundChatAck,
|
||||
+ ServerboundChatCommand,
|
||||
+ ServerboundChatCommandSigned,
|
||||
+ ServerboundChat,
|
||||
+ ServerboundChatSessionUpdate,
|
||||
+ ServerboundChunkBatchReceived,
|
||||
+ ServerboundClientCommand,
|
||||
+ ServerboundCommandSuggestion,
|
||||
+ ServerboundConfigurationAcknowledged,
|
||||
+ ServerboundContainerButtonClick,
|
||||
+ ServerboundContainerClick,
|
||||
+ ServerboundContainerClose,
|
||||
+ ServerboundContainerSlotStateChanged,
|
||||
+ ServerboundDebugSampleSubscription,
|
||||
+ ServerboundEditBook,
|
||||
+ ServerboundEntityTagQuery,
|
||||
+ ServerboundInteract,
|
||||
+ ServerboundJigsawGenerate,
|
||||
+ ServerboundLockDifficulty,
|
||||
+ ServerboundMovePlayerPos,
|
||||
+ ServerboundMovePlayerPosRot,
|
||||
+ ServerboundMovePlayerRot,
|
||||
+ ServerboundMovePlayerStatusOnly,
|
||||
+ ServerboundMoveVehicle,
|
||||
+ ServerboundPaddleBoat,
|
||||
+ ServerboundPickItem,
|
||||
+ ServerboundPlaceRecipe,
|
||||
+ ServerboundPlayerAbilities,
|
||||
+ ServerboundPlayerAction,
|
||||
+ ServerboundPlayerCommand,
|
||||
+ ServerboundPlayerInput,
|
||||
+ ServerboundRecipeBookChangeSettings,
|
||||
+ ServerboundRecipeBookSeenRecipe,
|
||||
+ ServerboundRenameItem,
|
||||
+ ServerboundSeenAdvancements,
|
||||
+ ServerboundSelectTrade,
|
||||
+ ServerboundSetBeacon,
|
||||
+ ServerboundSetCarriedItem,
|
||||
+ ServerboundSetCommandBlock,
|
||||
+ ServerboundSetCommandMinecart,
|
||||
+ ServerboundSetCreativeModeSlot,
|
||||
+ ServerboundSetJigsawBlock,
|
||||
+ ServerboundSetStructureBlock,
|
||||
+ ServerboundSignUpdate,
|
||||
+ ServerboundSwing,
|
||||
+ ServerboundTeleportToEntity,
|
||||
+ ServerboundUseItemOn,
|
||||
+ ServerboundUseItem,
|
||||
+ ClientboundResetScore,
|
||||
+ ClientboundTickingState,
|
||||
+ ClientboundTickingStep,
|
||||
+ ClientboundCustomPayload,
|
||||
+ ClientboundCustomDetails,
|
||||
+ ClientboundRecipeBookAdd,
|
||||
+ ServerboundClientTickEnd,
|
||||
+ ClientboundSetHeldSlot,
|
||||
+ ServerboundSelectBundleItem,
|
||||
+ ClientboundSetPlayerInventory,
|
||||
+ ClientboundSetCursorItem,
|
||||
+ ClientboundDisconnect,
|
||||
+ ClientboundKeepAlive,
|
||||
+ ClientboundPing,
|
||||
+ ClientboundResourcePackPop,
|
||||
+ ClientboundResourcePackPush,
|
||||
+ ClientboundServerLinks,
|
||||
+ ClientboundStoreCookie,
|
||||
+ ClientboundTransfer,
|
||||
+ ClientboundUpdateTags,
|
||||
+ ServerboundClientInformation,
|
||||
+ ServerboundCustomPayload,
|
||||
+ ServerboundKeepAlive,
|
||||
+ ServerboundPong,
|
||||
+ ServerboundResourcePack,
|
||||
+ ServerboundPingRequest,
|
||||
+ ClientboundPongResponse
|
||||
+}
|
||||
Reference in New Issue
Block a user