Skip to content

Commit 4c221a0

Browse files
committed
Updated Upstream (Leaves)
Upstream has released updates that appear to apply and compile correctly Leaves Changes: LeavesMC/Leaves@e3b0cf4a Fix tripwire with end platform (#542) LeavesMC/Leaves@8615b2f4 Recheck for null before handling player join (#550) LeavesMC/Leaves@093b9290 Fix protocol bugs (#537) LeavesMC/Leaves@852184c1 Vanilla Fluid Pushing (#547) (#551) LeavesMC/Leaves@911ec9b9 Fix Carpet protocol (#552) LeavesMC/Leaves@2654bf53 Fully rewrite I18n support (#545) LeavesMC/Leaves@f33f5fea Refactor command system, fix bugs (#573) LeavesMC/Leaves@6c07912d Remove Force peaceful mode switch (#265) (#579) LeavesMC/Leaves@2dcf9f85 Fix spawnInvulnerableTime (#583) LeavesMC/Leaves@6d76c1f1 Fix unexpected IOE (#582) LeavesMC/Leaves@3187d77f Fix IAE update suppression crash (#581)
1 parent ebce26c commit 4c221a0

File tree

6 files changed

+165
-14
lines changed

6 files changed

+165
-14
lines changed

leaf-server/minecraft-patches/features/0112-Leaves-Protocol-Core.patch

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ From: violetc <58360096+s-yh-china@users.noreply.github.com>
33
Date: Tue, 26 Sep 2023 19:00:41 +0800
44
Subject: [PATCH] Leaves: Protocol Core
55

6-
TODO: Check whether Leaves's Return-nether-portal-fix.patch improves performance
7-
and change store way to sql maybe?
8-
96
Original license: GPLv3
107
Original project: https://github.com/LeavesMC/Leaves
118

12-
Commit: 9d32c5bd3df7c76055aff886ed9efda02e45a45a
9+
Commit: 3187d77f57058a81bc04ce7eaac1224f58b03c25
1310

1411
diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
1512
index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..56fd1ed7ccaf96e7eedea60fbdbf7f934939d563 100644
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
package org.leavesmc.leaves.plugin;
2+
3+
import org.bukkit.Server;
4+
import org.bukkit.command.Command;
5+
import org.bukkit.command.CommandSender;
6+
import org.bukkit.configuration.file.FileConfiguration;
7+
import org.bukkit.generator.BiomeProvider;
8+
import org.bukkit.generator.ChunkGenerator;
9+
import org.bukkit.plugin.PluginBase;
10+
import org.bukkit.plugin.PluginDescriptionFile;
11+
import org.bukkit.plugin.PluginLoader;
12+
import org.bukkit.plugin.PluginLogger;
13+
import org.jetbrains.annotations.NotNull;
14+
import org.jetbrains.annotations.Nullable;
15+
16+
import java.io.File;
17+
import java.io.InputStream;
18+
import java.util.List;
19+
20+
public class MinecraftInternalPlugin extends PluginBase {
21+
22+
public static final MinecraftInternalPlugin INSTANCE = new MinecraftInternalPlugin();
23+
24+
private boolean enabled = true;
25+
26+
private final PluginDescriptionFile pdf;
27+
28+
public MinecraftInternalPlugin() {
29+
String pluginName = "Minecraft";
30+
pdf = new PluginDescriptionFile(pluginName, "1.0", "nms");
31+
}
32+
33+
public void setEnabled(boolean enabled) {
34+
this.enabled = enabled;
35+
}
36+
37+
@Override
38+
public File getDataFolder() {
39+
throw new UnsupportedOperationException("Not supported.");
40+
}
41+
42+
@Override
43+
public PluginDescriptionFile getDescription() {
44+
return pdf;
45+
}
46+
47+
@Override
48+
public io.papermc.paper.plugin.configuration.PluginMeta getPluginMeta() {
49+
return pdf;
50+
}
51+
52+
@Override
53+
public FileConfiguration getConfig() {
54+
throw new UnsupportedOperationException("Not supported.");
55+
}
56+
57+
@Override
58+
public InputStream getResource(String filename) {
59+
throw new UnsupportedOperationException("Not supported.");
60+
}
61+
62+
@Override
63+
public void saveConfig() {
64+
throw new UnsupportedOperationException("Not supported.");
65+
}
66+
67+
@Override
68+
public void saveDefaultConfig() {
69+
throw new UnsupportedOperationException("Not supported.");
70+
}
71+
72+
@Override
73+
public void saveResource(String resourcePath, boolean replace) {
74+
throw new UnsupportedOperationException("Not supported.");
75+
}
76+
77+
@Override
78+
public void reloadConfig() {
79+
throw new UnsupportedOperationException("Not supported.");
80+
}
81+
82+
@Override
83+
public PluginLogger getLogger() {
84+
throw new UnsupportedOperationException("Not supported.");
85+
}
86+
87+
@Override
88+
public PluginLoader getPluginLoader() {
89+
throw new UnsupportedOperationException("Not supported.");
90+
}
91+
92+
@Override
93+
public Server getServer() {
94+
throw new UnsupportedOperationException("Not supported.");
95+
}
96+
97+
@Override
98+
public boolean isEnabled() {
99+
return enabled;
100+
}
101+
102+
@Override
103+
public void onDisable() {
104+
throw new UnsupportedOperationException("Not supported.");
105+
}
106+
107+
@Override
108+
public void onLoad() {
109+
throw new UnsupportedOperationException("Not supported.");
110+
}
111+
112+
@Override
113+
public void onEnable() {
114+
throw new UnsupportedOperationException("Not supported.");
115+
}
116+
117+
@Override
118+
public boolean isNaggable() {
119+
throw new UnsupportedOperationException("Not supported.");
120+
}
121+
122+
@Override
123+
public void setNaggable(boolean canNag) {
124+
throw new UnsupportedOperationException("Not supported.");
125+
}
126+
127+
@Override
128+
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
129+
throw new UnsupportedOperationException("Not supported.");
130+
}
131+
132+
@Override
133+
public @Nullable BiomeProvider getDefaultBiomeProvider(@NotNull String worldName, @Nullable String id) {
134+
throw new UnsupportedOperationException("Not supported.");
135+
}
136+
137+
@Override
138+
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
139+
throw new UnsupportedOperationException("Not supported.");
140+
}
141+
142+
@Override
143+
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
144+
throw new UnsupportedOperationException("Not supported.");
145+
}
146+
147+
@Override
148+
public @NotNull io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager<org.bukkit.plugin.Plugin> getLifecycleManager() {
149+
throw new UnsupportedOperationException("Not supported.");
150+
}
151+
}

leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.Enumeration;
2929
import java.util.HashMap;
3030
import java.util.HashSet;
31-
import java.util.Iterator;
3231
import java.util.LinkedHashSet;
3332
import java.util.List;
3433
import java.util.Map;
@@ -322,9 +321,8 @@ private static void sendKnownId(ServerPlayer player) {
322321
if (set.isEmpty()) return;
323322
// Leaf end - optimize leaves protocol manager
324323
ProtocolUtils.sendBytebufPacket(player, ResourceLocation.fromNamespaceAndPath("minecraft", "register"), buf -> {
325-
ResourceLocation channel;
326-
for (Iterator<String> var3 = set.iterator(); var3.hasNext(); buf.writeBytes(channel.toString().getBytes(StandardCharsets.US_ASCII))) {
327-
channel = ResourceLocation.parse(var3.next());
324+
for (String channel : set) {
325+
buf.writeBytes(channel.getBytes(StandardCharsets.US_ASCII));
328326
buf.writeByte(0);
329327
}
330328
buf.writerIndex(Math.max(buf.writerIndex() - 1, 0));

leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@
3636
import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
3737
import net.minecraft.world.level.block.entity.LecternBlockEntity;
3838
import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity;
39+
import org.bukkit.Bukkit;
3940
import org.dreeam.leaf.config.modules.network.ProtocolSupport;
4041
import org.jetbrains.annotations.Contract;
4142
import org.jetbrains.annotations.NotNull;
4243
import org.leavesmc.leaves.LeavesLogger;
44+
import org.leavesmc.leaves.plugin.MinecraftInternalPlugin;
4345
import org.leavesmc.leaves.protocol.core.LeavesProtocol;
4446
import org.leavesmc.leaves.protocol.core.ProtocolHandler;
4547
import org.leavesmc.leaves.protocol.core.ProtocolUtils;
@@ -181,7 +183,7 @@ public static void onPlayerLeave(ServerPlayer player) {
181183

182184
@ProtocolHandler.PayloadReceiver(payload = RequestEntityPayload.class)
183185
public static void requestEntityData(ServerPlayer player, RequestEntityPayload payload) {
184-
MinecraftServer.getServer().execute(() -> {
186+
Bukkit.getGlobalRegionScheduler().run(MinecraftInternalPlugin.INSTANCE, (task) -> {
185187
EntityAccessor accessor = payload.data().unpack(player);
186188
if (accessor == null) {
187189
return;
@@ -217,8 +219,7 @@ public static void requestEntityData(ServerPlayer player, RequestEntityPayload p
217219

218220
@ProtocolHandler.PayloadReceiver(payload = RequestBlockPayload.class)
219221
public static void requestBlockData(ServerPlayer player, RequestBlockPayload payload) {
220-
MinecraftServer server = MinecraftServer.getServer();
221-
server.execute(() -> {
222+
Bukkit.getGlobalRegionScheduler().run(MinecraftInternalPlugin.INSTANCE, (task) -> {
222223
BlockAccessor accessor = payload.data().unpack(player);
223224
if (accessor == null) {
224225
return;

leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class SyncmaticaProtocol {
2323
private static final FeatureSet featureSet = new FeatureSet(Arrays.asList(Feature.values()));
2424
private static final SyncmaticManager syncmaticManager = new SyncmaticManager();
2525
private static final FileStorage fileStorage = new FileStorage();
26-
private static final int[] ILLEGAL_CHARS = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47};
26+
private static final int[] ILLEGAL_CHARS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47, 34, 60, 62, 124};
2727
private static final String ILLEGAL_PATTERNS = "(^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\\..*)?$)|(^\\.\\.*$)";
2828
private static boolean loaded = false;
2929

@@ -51,11 +51,14 @@ public static FileStorage getFileStorage() {
5151
return fileStorage;
5252
}
5353

54-
public static void init() {
55-
if (!loaded) {
54+
public static void init(boolean status) {
55+
if (status && !loaded) {
5656
litematicFolder.mkdirs();
5757
syncmaticManager.startup();
5858
loaded = true;
59+
} else if (!status && loaded) {
60+
syncmaticManager.updateServerPlacement();
61+
loaded = false;
5962
}
6063
}
6164

leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void handle(final @NotNull ResourceLocation id, final @NotNull FriendlyBy
5959
MessageType.ERROR,
6060
"syncmatica.error.cancelled_transmit_exceed_quota"
6161
);
62+
return;
6263
}
6364
try {
6465
packetBuf.readBytes(outputStream, size);

0 commit comments

Comments
 (0)