Compare commits

...

5 Commits

Author SHA1 Message Date
M2ke4U
7465ab1daf I am a idiot 2024-01-02 23:10:41 +08:00
M2ke4U
4f43e7845c [ci skip]Updated LICENSE and migrated license to luminolmc 2024-01-02 23:10:09 +08:00
M2ke4U
5e62e78720 [ci skip]Rename build.yml to build_1_20_2.yml 2023-12-24 21:28:43 +08:00
M2ke4U
1d4276694e Update 0045-Leaves-PCA-sync-protocol.patch 2023-12-24 16:33:23 +08:00
M2ke4U
3bca6a9846 Fix threading issue in PCA sync protocol 2023-12-24 14:51:16 +08:00
3 changed files with 22 additions and 8 deletions

View File

@@ -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.

View File

@@ -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) {