mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 01:17:42 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: cb15cfa4 Improve Async Login so pending connections dont get exposed f275e9cb Optimize Hoppers - Major Boost - Got2GoFast! 0106485c Improvements to watchdog changes 65934b1f Fix build for last commit. 5am commits are great 3f436029 Don't process watchdog until server has fully started and ticked. 938bd972 Don't fire BlockFade on worldgen threads - Fixes #3208 509a828e Fix loading spawn chunks when async chunks is off 8a91bfd2 Improvements to async login bf698865 Revert "Re-track players that dismount from other players" 82b98418 Fix some issues with async login as well another source of sync loads aa241d2b Allow multiple callbacks to schedule for Callback Executor a2064a41 Add PlayerAttackEntityCooldownResetEvent This event is called when processing a player's attack on an entity right before their attack strength cd is reset, there are no existing events that fire within this period of time so it was impossible to capture the players attack strength via API prior to this commit. f48d4299 Allow sleeping players to float eeb2f67d Fix Bed respawn deviating too far from vanilla (#3195) 68a7b9fe Move player to spawn point if spawn in unloaded world
136 lines
5.9 KiB
Diff
136 lines
5.9 KiB
Diff
From 70383ed7cde19a9d417b1c1f0defb4784ab5ef7f 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 079ddc71..1d921212 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -1558,6 +1558,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 60127393..75707adc 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 7d983d9a..36260e0e 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 00000000..0967ef42
|
|
--- /dev/null
|
|
+++ b/src/main/resources/purpur.lang
|
|
@@ -0,0 +1 @@
|
|
+{}
|
|
--
|
|
2.24.0
|
|
|