mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-18 17:07:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: cf82dad3 Fix Non Full Status Chunk NBT Memory Leak 5a12515a Update Log4J Configuration file to stop truncating stack traces 7c001d64 More Improvements to Chunks e1c45196 Fix high memory use of non ticking chunks ee9f0d51 Fix another case of breaking blocks causing sync chunk loads 6009ba8f Drop AABB limit patch until it can be tested more 0e9c24e5 Fix log spam about Hanging entities bounding boxes 83fadad7 Fix conversion for deserializing raw nbt itemstacks - Fixes #3424 4d38ee11 Many fixes and improvements to chunk prioritization 281181c7 Use saner Entity bounding box limits edd6b6a2 Protect the visible chunk map from plugins touching it, trim Timing Errors 18c68657 Optimize performance of object pool 7e1525ea Many improvements to chunk prioritization and bug fixes c82b292a Fix pooled buffer leak resulting in dynmap black spots - Fixes #3386 63274472 Fix ./paper edit continue for Windows eb5a3058 Fix path in CONTRIBUTING.md (#3406) f6ed326d Fix a small error in CONTRIBUTING.md (#3403) 614a664b Implement Chunk Priority / Urgency System for Chunks
136 lines
5.9 KiB
Diff
136 lines
5.9 KiB
Diff
From 2eebb2917735c5dbb2fee924861f3da007d84acf Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Thu, 26 Mar 2020 13:17:09 -0500
|
|
Subject: [PATCH] Add language asset purpur.lang
|
|
|
|
---
|
|
.../net/minecraft/server/EntityPlayer.java | 1 +
|
|
.../net/minecraft/server/LocaleLanguage.java | 48 +++++++++++++++++--
|
|
.../pl3x/purpur/command/PurpurCommand.java | 3 ++
|
|
src/main/resources/purpur.lang | 1 +
|
|
4 files changed, 49 insertions(+), 4 deletions(-)
|
|
create mode 100644 src/main/resources/purpur.lang
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
index d60f659b3..4b88a74ff 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -1561,6 +1561,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|
}
|
|
|
|
public void a(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype) {
|
|
+ if (ichatbasecomponent == null) return; // Purpur
|
|
this.playerConnection.a((Packet) (new PacketPlayOutChat(ichatbasecomponent, chatmessagetype)), (future) -> {
|
|
if (!future.isSuccess() && (chatmessagetype == ChatMessageType.GAME_INFO || chatmessagetype == ChatMessageType.SYSTEM)) {
|
|
boolean flag = true;
|
|
diff --git a/src/main/java/net/minecraft/server/LocaleLanguage.java b/src/main/java/net/minecraft/server/LocaleLanguage.java
|
|
index 601273933..75707adcd 100644
|
|
--- a/src/main/java/net/minecraft/server/LocaleLanguage.java
|
|
+++ b/src/main/java/net/minecraft/server/LocaleLanguage.java
|
|
@@ -15,18 +15,41 @@ import java.util.Map.Entry;
|
|
import java.util.regex.Pattern;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
+import org.bukkit.ChatColor;
|
|
|
|
public class LocaleLanguage {
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
private static final Pattern b = Pattern.compile("%(\\d+\\$)?[\\d\\.]*[df]");
|
|
private static final LocaleLanguage c = new LocaleLanguage();
|
|
- private final Map<String, String> d = Maps.newHashMap();
|
|
- private long e;
|
|
+ private final Map<String, String> d = Maps.newHashMap(); public Map<String, String> getStorage() { return this.d; } // Purpur - OBFHELPER
|
|
+ private long e; public long getLastUpdateTime() { return this.e; } public void setLastUpdateTime(int time) { this.e = time; } // Purpur - OBFHELPER
|
|
|
|
public LocaleLanguage() {
|
|
+ // Purpur start
|
|
+ reload(this);
|
|
+ }
|
|
+
|
|
+ private void loadFromFile(String resource) {
|
|
try {
|
|
- InputStream inputstream = LocaleLanguage.class.getResourceAsStream("/assets/minecraft/lang/en_us.json");
|
|
+ java.io.File file = new java.io.File(resource);
|
|
+ if (!file.exists()) {
|
|
+ java.nio.file.Files.copy(getClass().getResourceAsStream("/" + resource), file.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
|
+ }
|
|
+ loadFromJar("/" + resource);
|
|
+ loadFromStream(resource, new java.io.FileInputStream(file));
|
|
+ } catch (IOException e) {
|
|
+ LOGGER.error("Couldn't read string from " + resource, e);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ private void loadFromJar(String resource) {
|
|
+ loadFromStream(resource, getClass().getResourceAsStream(resource));
|
|
+ }
|
|
+
|
|
+ private void loadFromStream(String resource, InputStream inputstream) {
|
|
+ try {
|
|
+ // Purpur end
|
|
Throwable throwable = null;
|
|
|
|
try {
|
|
@@ -60,7 +83,7 @@ public class LocaleLanguage {
|
|
|
|
}
|
|
} catch (JsonParseException | IOException ioexception) {
|
|
- LocaleLanguage.LOGGER.error("Couldn't read strings from /assets/minecraft/lang/en_us.json", ioexception);
|
|
+ LocaleLanguage.LOGGER.error("Couldn't read strings from " + resource, ioexception); // Purpur
|
|
}
|
|
|
|
}
|
|
@@ -88,4 +111,21 @@ public class LocaleLanguage {
|
|
public long b() {
|
|
return this.e;
|
|
}
|
|
+
|
|
+ // Purpur start
|
|
+ public static void reload(LocaleLanguage instance) {
|
|
+ instance.setLastUpdateTime(0);
|
|
+ instance.getStorage().clear();
|
|
+ instance.loadFromJar("/assets/minecraft/lang/en_us.json");
|
|
+ instance.loadFromFile("purpur.lang");
|
|
+ }
|
|
+
|
|
+ public static ChatMessage translate(String key, Object... args) {
|
|
+ String str = getInstance().translateKey(key);
|
|
+ if (str == null) return null;
|
|
+ str = ChatColor.translateAlternateColorCodes('&', str);
|
|
+ if (str.isEmpty()) return null;
|
|
+ return new ChatMessage(str, args);
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
diff --git a/src/main/java/net/pl3x/purpur/command/PurpurCommand.java b/src/main/java/net/pl3x/purpur/command/PurpurCommand.java
|
|
index 7d983d9a5..36260e0ec 100644
|
|
--- a/src/main/java/net/pl3x/purpur/command/PurpurCommand.java
|
|
+++ b/src/main/java/net/pl3x/purpur/command/PurpurCommand.java
|
|
@@ -1,5 +1,6 @@
|
|
package net.pl3x.purpur.command;
|
|
|
|
+import net.minecraft.server.LocaleLanguage;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.WorldServer;
|
|
import net.pl3x.purpur.PurpurConfig;
|
|
@@ -45,6 +46,8 @@ public class PurpurCommand extends Command {
|
|
Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
|
|
Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
|
|
|
+ LocaleLanguage.reload(LocaleLanguage.getInstance());
|
|
+
|
|
MinecraftServer console = MinecraftServer.getServer();
|
|
PurpurConfig.init((File) console.options.valueOf("purpur-settings"));
|
|
for (WorldServer world : console.getWorlds()) {
|
|
diff --git a/src/main/resources/purpur.lang b/src/main/resources/purpur.lang
|
|
new file mode 100644
|
|
index 000000000..0967ef424
|
|
--- /dev/null
|
|
+++ b/src/main/resources/purpur.lang
|
|
@@ -0,0 +1 @@
|
|
+{}
|
|
--
|
|
2.24.0
|
|
|