mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 00:49:31 +00:00
92 lines
4.5 KiB
Diff
92 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Fri, 27 Jan 2023 09:42:57 +0800
|
|
Subject: [PATCH] Leaves: Xaero Map Protocol
|
|
|
|
Original license: GPLv3
|
|
Original project: https://github.com/LeavesMC/Leaves
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index 065b81ff738aa865a73bf5d1a1f189f6899b80c5..07dca7ece2d64fd3a56ee9de79443c4bd88f43ef 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -1369,6 +1369,7 @@ public abstract class PlayerList {
|
|
player.connection.send(new ClientboundInitializeBorderPacket(worldborder));
|
|
player.connection.send(new ClientboundSetTimePacket(world.getGameTime(), world.getDayTime(), world.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
|
|
player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(world.getSharedSpawnPos(), world.getSharedSpawnAngle()));
|
|
+ top.leavesmc.leaves.protocol.XaeroMapProtocol.onSendWorldInfo(player); // Leaves - xaero map protocol
|
|
if (world.isRaining()) {
|
|
// CraftBukkit start - handle player weather
|
|
// entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.START_RAINING, 0.0F));
|
|
diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java
|
|
index 9300969d867d523031acbd529690c97b2f9743f4..4e70a680ee7ff9966205b5a281fdb0da31b72774 100644
|
|
--- a/src/main/java/org/dreeam/leaf/LeafConfig.java
|
|
+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java
|
|
@@ -17,6 +17,7 @@ import java.lang.reflect.Method;
|
|
import java.lang.reflect.Modifier;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
+import java.util.Random;
|
|
|
|
public class LeafConfig {
|
|
|
|
@@ -297,9 +298,13 @@ public class LeafConfig {
|
|
public static boolean kickForOutOfOrderChat = true;
|
|
public static boolean jadeProtocol = false;
|
|
public static boolean appleskinProtocol = false;
|
|
+ public static boolean xaeroMapProtocol = false;
|
|
+ public static int xaeroMapServerID = new Random().nextInt();
|
|
private static void networkSettings() {
|
|
kickForOutOfOrderChat = getBoolean("network.kick-for-out-of-order-chat", kickForOutOfOrderChat);
|
|
jadeProtocol = getBoolean("network.protocol.jade-protocol", jadeProtocol);
|
|
appleskinProtocol = getBoolean("network.protocol.appleskin-protocol", appleskinProtocol);
|
|
+ xaeroMapProtocol = getBoolean("network.protocol.xaero-map-protocol", xaeroMapProtocol);
|
|
+ xaeroMapServerID = getInt("network.protocol.xaero-map-server-id", xaeroMapServerID);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/top/leavesmc/leaves/protocol/XaeroMapProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/XaeroMapProtocol.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..afedb39a2b586eb2ac786391bbf0814bef2e2ad5
|
|
--- /dev/null
|
|
+++ b/src/main/java/top/leavesmc/leaves/protocol/XaeroMapProtocol.java
|
|
@@ -0,0 +1,39 @@
|
|
+package top.leavesmc.leaves.protocol;
|
|
+
|
|
+import io.netty.buffer.Unpooled;
|
|
+import net.minecraft.network.FriendlyByteBuf;
|
|
+import net.minecraft.resources.ResourceLocation;
|
|
+import net.minecraft.server.level.ServerPlayer;
|
|
+import org.dreeam.leaf.LeafConfig;
|
|
+import org.jetbrains.annotations.Contract;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+import top.leavesmc.leaves.util.ProtocolUtils;
|
|
+
|
|
+public class XaeroMapProtocol {
|
|
+
|
|
+ public static final String PROTOCOL_ID_MINI = "xaerominimap";
|
|
+ public static final String PROTOCOL_ID_WORLD = "xaeroworldmap";
|
|
+
|
|
+ private static final ResourceLocation MINIMAP_KEY = idMini("main");
|
|
+ private static final ResourceLocation WORLDMAP_KEY = idWorld("main");
|
|
+
|
|
+ @Contract("_ -> new")
|
|
+ public static @NotNull ResourceLocation idMini(String path) {
|
|
+ return new ResourceLocation(PROTOCOL_ID_MINI, path);
|
|
+ }
|
|
+
|
|
+ @Contract("_ -> new")
|
|
+ public static @NotNull ResourceLocation idWorld(String path) {
|
|
+ return new ResourceLocation(PROTOCOL_ID_WORLD, path);
|
|
+ }
|
|
+
|
|
+ public static void onSendWorldInfo(@NotNull ServerPlayer player) {
|
|
+ if (LeafConfig.xaeroMapProtocol) {
|
|
+ FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
|
|
+ buf.writeByte(0);
|
|
+ buf.writeInt(LeafConfig.xaeroMapServerID);
|
|
+ ProtocolUtils.sendPayloadPacket(player, MINIMAP_KEY, buf);
|
|
+ ProtocolUtils.sendPayloadPacket(player, WORLDMAP_KEY, buf);
|
|
+ }
|
|
+ }
|
|
+}
|