Compare commits
8 Commits
1.21.4-9ed
...
1.20.2-755
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65378b9e26 | ||
|
|
c252b863d5 | ||
|
|
54fd31cb6c | ||
|
|
7465ab1daf | ||
|
|
4f43e7845c | ||
|
|
5e62e78720 | ||
|
|
1d4276694e | ||
|
|
3bca6a9846 |
4
LICENSE
4
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Era4FunMC
|
||||
Copyright (c) 2024 LuminolMC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
|
||||
@@ -3,7 +3,19 @@ From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
||||
Date: Sun, 17 Dec 2023 21:01:59 +0800
|
||||
Subject: [PATCH] Leaves PCA sync protocol
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index 2c3e1b420303a3c3a9315983fbc7e47423f7d9e4..29a8331e498eba333283b41c3e6a87a7ad97747c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -45,7 +45,7 @@ import org.bukkit.scheduler.BukkitWorker;
|
||||
*/
|
||||
public class CraftScheduler implements BukkitScheduler {
|
||||
|
||||
- static Plugin MINECRAFT = new MinecraftInternalPlugin();
|
||||
+ public static Plugin MINECRAFT = new MinecraftInternalPlugin();
|
||||
/**
|
||||
* The start ID for the counter.
|
||||
*/
|
||||
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
index a62680768068b611fe723fedeb617d42c643e59e..cfe9a8eb705039ee7e2dc9262e1355c4b0f664bb 100644
|
||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||
@@ -306,10 +318,10 @@ index 1fa22445a4ecc8c08dbcf0cc6bd39dc5003604c4..c1492fce06cdc00a8e82977f0c474a54
|
||||
return ShulkerBoxBlockEntity.SLOTS;
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..946b4183c7ae438bff5938115961057759c77dac
|
||||
index 0000000000000000000000000000000000000000..ebd28033ddf0fe6a354585dc2818a9b481d90ed4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
@@ -0,0 +1,382 @@
|
||||
@@ -0,0 +1,384 @@
|
||||
+package top.leavesmc.leaves.protocol;
|
||||
+
|
||||
+import net.minecraft.core.BlockPos;
|
||||
@@ -331,6 +343,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
||||
+import org.apache.commons.lang3.tuple.MutablePair;
|
||||
+import org.apache.commons.lang3.tuple.Pair;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
@@ -344,6 +357,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
||||
+import java.util.Set;
|
||||
+import java.util.concurrent.locks.ReentrantLock;
|
||||
+
|
||||
+import static org.bukkit.craftbukkit.scheduler.CraftScheduler.MINECRAFT;
|
||||
+import static top.leavesmc.leaves.protocol.core.LeavesProtocolManager.EmptyPayload;
|
||||
+
|
||||
+@LeavesProtocol(namespace = "pca")
|
||||
@@ -413,7 +427,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
||||
+ BlockPos pos = payload.pos;
|
||||
+ ServerLevel world = player.serverLevel();
|
||||
+
|
||||
+ server.execute(() -> {
|
||||
+ player.getBukkitEntity().getScheduler().execute(MINECRAFT,() -> {
|
||||
+ BlockState blockState = world.getBlockState(pos);
|
||||
+ clearPlayerWatchData(player);
|
||||
+
|
||||
@@ -444,7 +458,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
||||
+ }
|
||||
+ blockPosWatchPlayerSet.get(pair).add(player);
|
||||
+ lock.unlock();
|
||||
+ });
|
||||
+ },null,1);
|
||||
+ }
|
||||
+
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = SyncEntityPayload.class, payloadId = "sync_entity")
|
||||
@@ -455,7 +469,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
||||
+ MinecraftServer server = MinecraftServer.getServer();
|
||||
+ int entityId = payload.entityId;
|
||||
+ ServerLevel world = player.serverLevel();
|
||||
+ server.execute(() -> {
|
||||
+ player.getBukkitEntity().getScheduler().execute(MINECRAFT,() -> {
|
||||
+ Entity entity = world.getEntity(entityId);
|
||||
+ if (entity != null) {
|
||||
+ clearPlayerWatchData(player);
|
||||
@@ -488,7 +502,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
||||
+ entityWatchPlayerSet.get(pair).add(player);
|
||||
+ lock.unlock();
|
||||
+ }
|
||||
+ });
|
||||
+ },null,1);
|
||||
+ }
|
||||
+
|
||||
+ public static void enablePcaSyncProtocol(@NotNull ServerPlayer player) {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Mon, 8 Jan 2024 12:19:29 +0000
|
||||
Subject: [PATCH] Do not process any packet if the leaves protocol supports are
|
||||
disabled
|
||||
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
index ebd28033ddf0fe6a354585dc2818a9b481d90ed4..33c7221a1f33cdb81dfac92fc3332f92cf3cd2d9 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package top.leavesmc.leaves.protocol;
|
||||
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
index de92ebdf9d51a4f9a58a7650b09f070e51710ef0..b309963dcf41f16a7b53e4cc2816975523ccba55 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java
|
||||
@@ -35,6 +35,9 @@ public class MsptSyncProtocol {
|
||||
|
||||
@ProtocolHandler.Init
|
||||
public static void init() {
|
||||
+ if (!LuminolConfig.msptSyncProtocol){
|
||||
+ return;
|
||||
+ }
|
||||
BladerenProtocol.registerFeature("mspt_sync", (player, compoundTag) -> {
|
||||
if (compoundTag.getString("Value").equals("true")) {
|
||||
onPlayerSubmit(player);
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
index fc229f23076147304754a267bcc345cc836b648b..6325f6441e28d915514e6b0ee9b450610e99b2c2 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
@@ -2,6 +2,7 @@ package top.leavesmc.leaves.protocol.syncmatica;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.netty.buffer.Unpooled;
|
||||
+import me.earthme.luminol.LuminolConfig;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -68,6 +69,9 @@ public class CommunicationManager {
|
||||
|
||||
@ProtocolHandler.PlayerJoin
|
||||
public static void onPlayerJoin(ServerPlayer player) {
|
||||
+ if (!LuminolConfig.syncmaticaProtocol){
|
||||
+ return;
|
||||
+ }
|
||||
final ExchangeTarget newPlayer = player.connection.exchangeTarget;
|
||||
final VersionHandshakeServer hi = new VersionHandshakeServer(newPlayer);
|
||||
playerMap.put(newPlayer, player);
|
||||
@@ -78,6 +82,9 @@ public class CommunicationManager {
|
||||
|
||||
@ProtocolHandler.PlayerLeave
|
||||
public static void onPlayerLeave(ServerPlayer player) {
|
||||
+ if (!LuminolConfig.syncmaticaProtocol){
|
||||
+ return;
|
||||
+ }
|
||||
final ExchangeTarget oldPlayer = player.connection.exchangeTarget;
|
||||
final Collection<Exchange> potentialMessageTarget = oldPlayer.getExchanges();
|
||||
if (potentialMessageTarget != null) {
|
||||
@@ -92,6 +99,9 @@ public class CommunicationManager {
|
||||
|
||||
@ProtocolHandler.PayloadReceiver(payload = LeavesProtocolManager.LeavesPayload.class, ignoreId = true)
|
||||
public static void onPacketGet(ServerPlayer player, LeavesProtocolManager.LeavesPayload payload) {
|
||||
+ if (!LuminolConfig.syncmaticaProtocol){
|
||||
+ return;
|
||||
+ }
|
||||
onPacket(player.connection.exchangeTarget, payload.id(), payload.data());
|
||||
}
|
||||
|
||||
106
patches/server/0050-Leaves-Fix-Bladeren-Protocol.patch
Normal file
106
patches/server/0050-Leaves-Fix-Bladeren-Protocol.patch
Normal file
@@ -0,0 +1,106 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrHua269 <novau233@163.com>
|
||||
Date: Wed, 17 Jan 2024 14:10:33 +0000
|
||||
Subject: [PATCH] Leaves Fix Bladeren Protocol
|
||||
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
index 64a1d25973b032e8cab64bbffa6824a131676773..57a563b3f2d01719d490578907411d25ea07a658 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocol.java
|
||||
@@ -8,9 +8,7 @@ import java.lang.annotation.Target;
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface LeavesProtocol {
|
||||
-
|
||||
- String namespace() default "minecraft";
|
||||
-
|
||||
- String[] namespaces() default {};
|
||||
+
|
||||
+ String[] namespace();
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
index 055f044ce6cef4377f6f577efdbfad0ec9a2d57b..18fc0e2c890020bf587f5b1d2e097126d3e19999 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
|
||||
@@ -56,7 +56,7 @@ public class LeavesProtocolManager {
|
||||
return;
|
||||
}
|
||||
|
||||
- Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = new HashMap<>();
|
||||
+ Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = KNOWN_TYPES.getOrDefault(protocol, new HashMap<>());
|
||||
for (final Method method : methods) {
|
||||
if (method.isBridge() || method.isSynthetic() || !Modifier.isStatic(method.getModifiers())) {
|
||||
continue;
|
||||
@@ -131,13 +131,13 @@ public class LeavesProtocolManager {
|
||||
|
||||
public static CustomPacketPayload getPayload(ResourceLocation id, FriendlyByteBuf buf) {
|
||||
for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) {
|
||||
- if (!protocol.namespace().equals(id.getNamespace()) && !ArrayUtils.contains(protocol.namespaces(), id.getNamespace())) {
|
||||
+ if (!ArrayUtils.contains(protocol.namespace(), id.getNamespace())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<ProtocolHandler.PayloadReceiver, Constructor<? extends CustomPacketPayload>> map = KNOWN_TYPES.get(protocol);
|
||||
for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) {
|
||||
- if (receiver.ignoreId() || receiver.payloadId().equals(id.getPath()) || ArrayUtils.contains(receiver.payloadIds(), id.getPath())) {
|
||||
+ if (receiver.ignoreId() || ArrayUtils.contains(receiver.payloadId(), id.getPath())) {
|
||||
try {
|
||||
return map.get(receiver).newInstance(id, buf);
|
||||
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
|
||||
@@ -151,15 +151,14 @@ public class LeavesProtocolManager {
|
||||
|
||||
public static void handlePayload(ServerPlayer player, CustomPacketPayload payload) {
|
||||
for (LeavesProtocol protocol : KNOW_RECEIVERS.keySet()) {
|
||||
- if (!protocol.namespace().equals(payload.id().getNamespace()) && !ArrayUtils.contains(protocol.namespaces(), payload.id().getNamespace())) {
|
||||
+ if (!ArrayUtils.contains(protocol.namespace(), payload.id().getNamespace())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<ProtocolHandler.PayloadReceiver, Method> map = KNOW_RECEIVERS.get(protocol);
|
||||
for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) {
|
||||
if (payload.getClass() == receiver.payload()) {
|
||||
- if (receiver.ignoreId() || receiver.payloadId().equals(payload.id().getPath()) ||
|
||||
- ArrayUtils.contains(receiver.payloadIds(), payload.id().getPath())) {
|
||||
+ if (receiver.ignoreId() || ArrayUtils.contains(receiver.payloadId(), payload.id().getPath())) {
|
||||
try {
|
||||
map.get(receiver).invoke(null, player, payload);
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
@@ -222,7 +221,7 @@ public class LeavesProtocolManager {
|
||||
public static void handleMinecraftRegister(String channelId, ServerPlayer player) {
|
||||
for (LeavesProtocol protocol : MINECRAFT_REGISTER.keySet()) {
|
||||
String[] channel = channelId.split(":");
|
||||
- if (!protocol.namespace().equals(channel[0]) && !ArrayUtils.contains(protocol.namespaces(), channel[0])) {
|
||||
+ if (!ArrayUtils.contains(protocol.namespace(), channel[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
index d696f001d2576d1b61cc732c81f22eb52205072b..92ad6e9b1c0d9640b80c1ebe739c613d989eec21 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/ProtocolHandler.java
|
||||
@@ -21,9 +21,7 @@ public class ProtocolHandler {
|
||||
|
||||
Class<? extends CustomPacketPayload> payload();
|
||||
|
||||
- String[] payloadIds() default {};
|
||||
-
|
||||
- String payloadId() default "";
|
||||
+ String[] payloadId();
|
||||
|
||||
boolean ignoreId() default false;
|
||||
}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
index 6325f6441e28d915514e6b0ee9b450610e99b2c2..19277aa7b9bd16b3e70d581d38a4c28e60165f65 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java
|
||||
@@ -97,7 +97,7 @@ public class CommunicationManager {
|
||||
playerMap.remove(oldPlayer);
|
||||
}
|
||||
|
||||
- @ProtocolHandler.PayloadReceiver(payload = LeavesProtocolManager.LeavesPayload.class, ignoreId = true)
|
||||
+ @ProtocolHandler.PayloadReceiver(payload = LeavesProtocolManager.LeavesPayload.class, ignoreId = true, payloadId = "")
|
||||
public static void onPacketGet(ServerPlayer player, LeavesProtocolManager.LeavesPayload payload) {
|
||||
if (!LuminolConfig.syncmaticaProtocol){
|
||||
return;
|
||||
Reference in New Issue
Block a user