mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: 8ce3dd5f [CI-SKIP] Fix Mojang API Brigadier dep - THIS IS NOT A NEW BUILD 00d760a5 Fix build due to spigot changing the build timestamp process 842e040c Updated Upstream (Bukkit/CraftBukkit/Spigot) c03260a2 Add getter and setter for villager's numberOfRestocksToday (#3231) fe366fbe null check tracker for entity metadata update - Fixes #3070 fdf41b74 Implement Brigadier Mojang API e0ea2e0e Entity Activation Range 2.0! Major improvements to restoring behavior 10396d28 Fix Tracking Range mismatch on Vehicle/Passenger checks
136 lines
5.9 KiB
Diff
136 lines
5.9 KiB
Diff
From 219ff737bfd7175c99cc7ab05733cd32ebee471d 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 0f9bca8b8..90c5dc1d6 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -1560,6 +1560,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
|
|
|