Skip to content

Instantly share code, notes, and snippets.

@pog5
Created March 29, 2024 20:29
Show Gist options
  • Save pog5/271a1f3e0076a83ad65d749f796d02f1 to your computer and use it in GitHub Desktop.
Save pog5/271a1f3e0076a83ad65d749f796d02f1 to your computer and use it in GitHub Desktop.
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: pog5 <pixelnightly@proton.me>
Date: Fri, 15 Mar 2024 10:34:14 +0200
Subject: [PATCH] who needs these anyways
diff --git a/src/main/java/net/minecraft/server/Eula.java b/src/main/java/net/minecraft/server/Eula.java
index b9403a3eafc1b30b33ac654f253d0849cacadd03..42e89dea5f53d5e5d3f333644f5ad0b26b859b5a 100644
--- a/src/main/java/net/minecraft/server/Eula.java
+++ b/src/main/java/net/minecraft/server/Eula.java
@@ -10,64 +10,13 @@ import net.minecraft.SharedConstants;
import org.slf4j.Logger;
public class Eula {
- private static final Logger LOGGER = LogUtils.getLogger();
- private final Path file;
private final boolean agreed;
public Eula(Path eulaFile) {
- this.file = eulaFile;
- this.agreed = SharedConstants.IS_RUNNING_IN_IDE || this.readGlobalFile() || this.readFile(); // Gale - YAPFA - global EULA file
- }
-
- private boolean readFile() {
- // Gale start - YAPFA - global EULA file
- return readFile(this.file);
- }
-
- private boolean readGlobalFile() {
- try {
- Path globalFile = Path.of(System.getProperty("user.home"), "eula.txt");
- if (globalFile.toFile().exists()) {
- return readFile(globalFile);
- }
- } catch (Throwable ignored) {}
- return false;
- }
-
- private boolean readFile(Path file) {
- // Gale end - YAPFA - global EULA file
- try {
- boolean var3;
- try (InputStream inputStream = Files.newInputStream(file)) { // Gale - YAPFA - global EULA file
- Properties properties = new Properties();
- properties.load(inputStream);
- var3 = Boolean.parseBoolean(properties.getProperty("eula", "false"));
- }
-
- return var3;
- } catch (Exception var6) {
- if (file == this.file) { // Gale - YAPFA - global EULA file
- LOGGER.warn("Failed to load {}", (Object)this.file);
- this.saveDefaults();
- } // Gale - YAPFA - global EULA file
- return false;
- }
+ this.agreed = true;
}
public boolean hasAgreedToEULA() {
return this.agreed;
}
-
- private void saveDefaults() {
- if (!SharedConstants.IS_RUNNING_IN_IDE) {
- try (OutputStream outputStream = Files.newOutputStream(this.file)) {
- Properties properties = new Properties();
- properties.setProperty("eula", "false");
- properties.store(outputStream, "By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).");
- } catch (Exception var6) {
- LOGGER.warn("Failed to save {}", this.file, var6);
- }
-
- }
- }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 06f4c5ac93e8856648337b71f224d8ef95081909..6849e824be583c87299cf4cc4e0c4b152af07cf7 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1664,6 +1664,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Paper start - Perf: Optimize time updates
for (final ServerLevel level : this.getAllLevels()) {
final boolean doDaylight = level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT);
+ if (!doDaylight) break;
final long dayTime = level.getDayTime();
long worldTime = level.getGameTime();
final ClientboundSetTimePacket worldPacket = new ClientboundSetTimePacket(worldTime, dayTime, doDaylight);
@@ -1721,7 +1722,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
GameTestTicker.SINGLETON.tick();
}
- top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleTick(); // Leaves - protocol
+ //top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleTick(); // Leaves - protocol
for (int i = 0; i < this.tickables.size(); ++i) {
((Runnable) this.tickables.get(i)).run();
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
index b7c6717efcefe4efae3fd69ebaa3697bfd3dc9c8..23411e8cb86765e5d45db9be46f09fcc56ae83eb 100644
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
@@ -75,6 +75,7 @@ public class PlayerAdvancements {
this.codec = DataFixTypes.ADVANCEMENTS.wrapCodec(PlayerAdvancements.Data.CODEC, dataFixer, 1343);
this.load(advancementLoader);
+ stopListening();
}
public void setPlayer(ServerPlayer owner) {
@@ -105,6 +106,7 @@ public class PlayerAdvancements {
}
private void registerListeners(ServerAdvancementManager advancementLoader) {
+ /*
Iterator iterator = advancementLoader.getAllAdvancements().iterator();
while (iterator.hasNext()) {
@@ -113,9 +115,12 @@ public class PlayerAdvancements {
this.registerListeners(advancementholder);
}
+ */
+
}
private void checkForAutomaticTriggers(ServerAdvancementManager advancementLoader) {
+ /*
Iterator iterator = advancementLoader.getAllAdvancements().iterator();
while (iterator.hasNext()) {
@@ -128,9 +133,12 @@ public class PlayerAdvancements {
}
}
+ */
+
}
private void load(ServerAdvancementManager advancementLoader) {
+ /*
if (Files.isRegularFile(this.playerSavePath, new LinkOption[0])) {
try {
JsonReader jsonreader = new JsonReader(Files.newBufferedReader(this.playerSavePath, StandardCharsets.UTF_8));
@@ -159,11 +167,14 @@ public class PlayerAdvancements {
}
}
- this.checkForAutomaticTriggers(advancementLoader);
- this.registerListeners(advancementLoader);
+ */
+
+ //this.checkForAutomaticTriggers(advancementLoader);
+ //this.registerListeners(advancementLoader);
}
public void save() {
+ /*
if (org.spigotmc.SpigotConfig.disableAdvancementSaving) return; // Spigot
JsonElement jsonelement = (JsonElement) Util.getOrThrow(this.codec.encodeStart(JsonOps.INSTANCE, this.asData()), IllegalStateException::new);
@@ -192,6 +203,8 @@ public class PlayerAdvancements {
PlayerAdvancements.LOGGER.error("Couldn't save player advancements to {}", this.playerSavePath, ioexception);
}
+ */
+
}
private void applyFrom(ServerAdvancementManager loader, PlayerAdvancements.Data progressMap) {
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index 4a6bb425902b780ddfcc505e71d4ff70ff0babb9..89707d5517e1afa338caa66da97511ba8e5800c2 100644
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -136,7 +136,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@Override
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
- top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePayload(player, packet.payload()); // Leaves - protocol
+ //top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePayload(player, packet.payload()); // Leaves - protocol
// Paper start - Brand support
if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) {
this.player.clientBrandName = brandPayload.brand();
@@ -148,7 +148,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
ResourceLocation identifier = packet.payload().id();
ByteBuf payload = ((ServerboundCustomPayloadPacket.UnknownPayload)packet.payload()).data();
-
+ /*
if (identifier.equals(ServerCommonPacketListenerImpl.CUSTOM_REGISTER)) {
try {
String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
@@ -167,7 +167,9 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
} catch (Exception ignore) {
}
// Purpur end
- } else if (identifier.equals(ServerCommonPacketListenerImpl.CUSTOM_UNREGISTER)) {
+
+ */
+ if (identifier.equals(ServerCommonPacketListenerImpl.CUSTOM_UNREGISTER)) {
try {
String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
for (String channel : channels.split("\0")) {
@@ -238,33 +240,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
long elapsedTime = currentTime - this.keepAliveTime;
// Gale start - Purpur - send multiple keep-alive packets
- if (GaleGlobalConfiguration.get().misc.keepalive.sendMultiple) {
- if (elapsedTime >= 1000L) { // 1 second
- if (!this.processedDisconnect && this.keepAlives.size() >= KEEPALIVE_LIMIT_IN_SECONDS) {
- LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // Leaf - Fix keepalive kicked name
- disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT);
- } else {
- this.keepAliveTime = currentTime; // hijack this field for 1 second intervals
- this.keepAlives.add(currentTime); // currentTime is ID
- send(new ClientboundKeepAlivePacket(currentTime));
- }
- }
- } else {
- // Gale end - Purpur - send multiple keep-alive packets
- if (this.keepAlivePending) {
- if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected
- ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info
- this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause
- }
- } else {
- if (elapsedTime >= 15000L) { // 15 seconds
- this.keepAlivePending = true;
- this.keepAliveTime = currentTime;
- this.keepAliveChallenge = currentTime;
- this.send(new ClientboundKeepAlivePacket(this.keepAliveChallenge));
+ if (elapsedTime >= 1000L) { // 1 second
+ if (!this.processedDisconnect && this.keepAlives.size() >= KEEPALIVE_LIMIT_IN_SECONDS) {
+ LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // Leaf - Fix keepalive kicked name
+ disconnect(Component.translatable("disconnect.timeout"), PlayerKickEvent.Cause.TIMEOUT);
+ } else {
+ this.keepAliveTime = currentTime; // hijack this field for 1 second intervals
+ this.keepAlives.add(currentTime); // currentTime is ID
+ send(new ClientboundKeepAlivePacket(currentTime));
}
}
- } // Gale - Purpur - send multiple keep-alive packets
// Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings
}
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 25c7f47382f8a9949e2785c36f67dcf455d33f5a..602c2d748c18cd0ef4bfd83bd9d6a8413ffe32cc 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -30,6 +30,7 @@ import javax.annotation.Nullable;
import me.titaniumtown.ArrayConstants;
import net.minecraft.ChatFormatting;
import net.minecraft.FileUtil;
+import net.minecraft.advancements.AdvancementTree;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.BlockPos;
import net.minecraft.core.LayeredRegistryAccess;
@@ -362,7 +363,7 @@ public abstract class PlayerList {
}
player.didPlayerJoinEvent = true; // Gale - EMC - do not process chat/commands before player has joined
- top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol
+ //top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
@@ -607,13 +608,15 @@ public abstract class PlayerList {
if (serverstatisticmanager != null) {
serverstatisticmanager.save();
}
-
+ /*
PlayerAdvancements advancementdataplayer = (PlayerAdvancements) player.getAdvancements(); // CraftBukkit
if (advancementdataplayer != null) {
advancementdataplayer.save();
}
+ */
+
}
public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // CraftBukkit - return string // Paper - return Component
@@ -739,7 +742,7 @@ public abstract class PlayerList {
while (iterator.hasNext()) {
entityplayer = (ServerPlayer) iterator.next();
- this.save(entityplayer); // CraftBukkit - Force the player's inventory to be saved
+ //this.save(entityplayer); // CraftBukkit - Force the player's inventory to be saved
entityplayer.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"), org.bukkit.event.player.PlayerKickEvent.Cause.DUPLICATE_LOGIN); // Paper - kick event cause
}
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 740039a14fe915e7edd30273de628efd92512e4a..f8c279663f1ce6f7b108e59cbb05be2c162b4506 100644
--- a/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
+++ b/src/main/java/top/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
@@ -45,6 +45,7 @@ public class LeavesProtocolManager {
private static final Map<LeavesProtocol, Map<ProtocolHandler.MinecraftRegister, Method>> MINECRAFT_REGISTER = new HashMap<>();
public static void init() {
+ /*
for (Class<?> clazz : getClasses("top.leavesmc.leaves.protocol")) {
final LeavesProtocol protocol = clazz.getAnnotation(LeavesProtocol.class);
if (protocol != null) {
@@ -131,9 +132,12 @@ public class LeavesProtocolManager {
KNOWN_TYPES.put(protocol, map);
}
}
+
+ */
}
public static CustomPacketPayload getPayload(ResourceLocation id, FriendlyByteBuf buf) {
+ /*
for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) {
if (!ArrayUtils.contains(protocol.namespace(), id.getNamespace())) {
continue;
@@ -152,6 +156,8 @@ public class LeavesProtocolManager {
}
}
}
+
+ */
return null;
}
@@ -186,6 +192,7 @@ public class LeavesProtocolManager {
}
public static void handleTick() {
+ /*
if (!TICKERS.isEmpty()) {
try {
for (Method method : TICKERS) {
@@ -195,9 +202,12 @@ public class LeavesProtocolManager {
e.printStackTrace();
}
}
+
+ */
}
public static void handlePlayerJoin(ServerPlayer player) {
+ /*
if (!PLAYER_JOIN.isEmpty()) {
try {
for (Method method : PLAYER_JOIN) {
@@ -207,9 +217,12 @@ public class LeavesProtocolManager {
e.printStackTrace();
}
}
+
+ */
}
public static void handlePlayerLeave(ServerPlayer player) {
+ /*
if (!PLAYER_LEAVE.isEmpty()) {
try {
for (Method method : PLAYER_LEAVE) {
@@ -219,9 +232,12 @@ public class LeavesProtocolManager {
e.printStackTrace();
}
}
+
+ */
}
public static void handleServerReload() {
+ /*
if (!RELOAD_SERVER.isEmpty()) {
try {
for (Method method : RELOAD_SERVER) {
@@ -231,6 +247,8 @@ public class LeavesProtocolManager {
e.printStackTrace();
}
}
+
+ */
}
public static void handleMinecraftRegister(String channelId, ServerPlayer player) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment