Compare commits
7 Commits
dev/1.21.4
...
1.20.2-744
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c252b863d5 | ||
|
|
54fd31cb6c | ||
|
|
7465ab1daf | ||
|
|
4f43e7845c | ||
|
|
5e62e78720 | ||
|
|
1d4276694e | ||
|
|
3bca6a9846 |
4
LICENSE
4
LICENSE
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023 Era4FunMC
|
Copyright (c) 2024 LuminolMC
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
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
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
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
|
Date: Sun, 17 Dec 2023 21:01:59 +0800
|
||||||
Subject: [PATCH] Leaves PCA sync protocol
|
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
|
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||||
index a62680768068b611fe723fedeb617d42c643e59e..cfe9a8eb705039ee7e2dc9262e1355c4b0f664bb 100644
|
index a62680768068b611fe723fedeb617d42c643e59e..cfe9a8eb705039ee7e2dc9262e1355c4b0f664bb 100644
|
||||||
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
||||||
@@ -306,10 +318,10 @@ index 1fa22445a4ecc8c08dbcf0cc6bd39dc5003604c4..c1492fce06cdc00a8e82977f0c474a54
|
|||||||
return ShulkerBoxBlockEntity.SLOTS;
|
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
|
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
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..946b4183c7ae438bff5938115961057759c77dac
|
index 0000000000000000000000000000000000000000..ebd28033ddf0fe6a354585dc2818a9b481d90ed4
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
+++ b/src/main/java/top/leavesmc/leaves/protocol/PcaSyncProtocol.java
|
||||||
@@ -0,0 +1,382 @@
|
@@ -0,0 +1,384 @@
|
||||||
+package top.leavesmc.leaves.protocol;
|
+package top.leavesmc.leaves.protocol;
|
||||||
+
|
+
|
||||||
+import net.minecraft.core.BlockPos;
|
+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.MutablePair;
|
||||||
+import org.apache.commons.lang3.tuple.Pair;
|
+import org.apache.commons.lang3.tuple.Pair;
|
||||||
+import org.apache.logging.log4j.LogManager;
|
+import org.apache.logging.log4j.LogManager;
|
||||||
|
+import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||||
+import org.jetbrains.annotations.Contract;
|
+import org.jetbrains.annotations.Contract;
|
||||||
+import org.jetbrains.annotations.NotNull;
|
+import org.jetbrains.annotations.NotNull;
|
||||||
+import org.jetbrains.annotations.Nullable;
|
+import org.jetbrains.annotations.Nullable;
|
||||||
@@ -344,6 +357,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
|||||||
+import java.util.Set;
|
+import java.util.Set;
|
||||||
+import java.util.concurrent.locks.ReentrantLock;
|
+import java.util.concurrent.locks.ReentrantLock;
|
||||||
+
|
+
|
||||||
|
+import static org.bukkit.craftbukkit.scheduler.CraftScheduler.MINECRAFT;
|
||||||
+import static top.leavesmc.leaves.protocol.core.LeavesProtocolManager.EmptyPayload;
|
+import static top.leavesmc.leaves.protocol.core.LeavesProtocolManager.EmptyPayload;
|
||||||
+
|
+
|
||||||
+@LeavesProtocol(namespace = "pca")
|
+@LeavesProtocol(namespace = "pca")
|
||||||
@@ -413,7 +427,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
|||||||
+ BlockPos pos = payload.pos;
|
+ BlockPos pos = payload.pos;
|
||||||
+ ServerLevel world = player.serverLevel();
|
+ ServerLevel world = player.serverLevel();
|
||||||
+
|
+
|
||||||
+ server.execute(() -> {
|
+ player.getBukkitEntity().getScheduler().execute(MINECRAFT,() -> {
|
||||||
+ BlockState blockState = world.getBlockState(pos);
|
+ BlockState blockState = world.getBlockState(pos);
|
||||||
+ clearPlayerWatchData(player);
|
+ clearPlayerWatchData(player);
|
||||||
+
|
+
|
||||||
@@ -444,7 +458,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
|||||||
+ }
|
+ }
|
||||||
+ blockPosWatchPlayerSet.get(pair).add(player);
|
+ blockPosWatchPlayerSet.get(pair).add(player);
|
||||||
+ lock.unlock();
|
+ lock.unlock();
|
||||||
+ });
|
+ },null,1);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @ProtocolHandler.PayloadReceiver(payload = SyncEntityPayload.class, payloadId = "sync_entity")
|
+ @ProtocolHandler.PayloadReceiver(payload = SyncEntityPayload.class, payloadId = "sync_entity")
|
||||||
@@ -455,7 +469,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
|||||||
+ MinecraftServer server = MinecraftServer.getServer();
|
+ MinecraftServer server = MinecraftServer.getServer();
|
||||||
+ int entityId = payload.entityId;
|
+ int entityId = payload.entityId;
|
||||||
+ ServerLevel world = player.serverLevel();
|
+ ServerLevel world = player.serverLevel();
|
||||||
+ server.execute(() -> {
|
+ player.getBukkitEntity().getScheduler().execute(MINECRAFT,() -> {
|
||||||
+ Entity entity = world.getEntity(entityId);
|
+ Entity entity = world.getEntity(entityId);
|
||||||
+ if (entity != null) {
|
+ if (entity != null) {
|
||||||
+ clearPlayerWatchData(player);
|
+ clearPlayerWatchData(player);
|
||||||
@@ -488,7 +502,7 @@ index 0000000000000000000000000000000000000000..946b4183c7ae438bff59381159610577
|
|||||||
+ entityWatchPlayerSet.get(pair).add(player);
|
+ entityWatchPlayerSet.get(pair).add(player);
|
||||||
+ lock.unlock();
|
+ lock.unlock();
|
||||||
+ }
|
+ }
|
||||||
+ });
|
+ },null,1);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static void enablePcaSyncProtocol(@NotNull ServerPlayer player) {
|
+ 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());
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user