mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 01:47:42 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: d6eda567 Provide a useful PluginClassLoader#toString a3fdafbd Restore Serialization Improvements again, wasn't an issue. 0e441c79 Revert "Improve Chat Component Legacy Serialization more" 53ef67b8 Improve Chat Component Legacy Serialization more afc1fcfc Fix serialization of colors from components eaa76a31 Add Villager Tasks to EAR inactive tick to keep behavior 357b52fd Improve Chunk Prioritization / Load Order a76bc402 Improve Chunk Status Transition Speed 7a2b345b Synchronize DataPaletteBlock instead of ReentrantLock
136 lines
5.9 KiB
Diff
136 lines
5.9 KiB
Diff
From 16fd129dea27af5866c4ff2281febb202873f9ac 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 c88177b776..8c60e565ec 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -1570,6 +1570,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 6012739331..75707adcd7 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 7d983d9a54..36260e0ec8 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 0000000000..0967ef424b
|
|
--- /dev/null
|
|
+++ b/src/main/resources/purpur.lang
|
|
@@ -0,0 +1 @@
|
|
+{}
|
|
--
|
|
2.24.0
|
|
|