mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 1c8b6065e Skip distance map update when spawning is disabled 091e6700f Added PlayerStonecutterRecipeSelectEvent fc885f966 Add toggle for always placing the dragon egg b3a6da3a7 Updated Upstream (Bukkit/CraftBukkit) 18ccc062d [Auto] Updated Upstream (Spigot) e9a87b72b fix BaseTag constructor (#5095)
53 lines
3.0 KiB
Diff
53 lines
3.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Tue, 4 Aug 2020 22:08:23 -0500
|
|
Subject: [PATCH] Allow anvil colors
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ContainerAnvil.java b/src/main/java/net/minecraft/server/ContainerAnvil.java
|
|
index 4aa6b035a6a8ea39401c6566cd286de39f60e942..5e4e59e5c8478b76078fdda14e5ced76304d489c 100644
|
|
--- a/src/main/java/net/minecraft/server/ContainerAnvil.java
|
|
+++ b/src/main/java/net/minecraft/server/ContainerAnvil.java
|
|
@@ -251,6 +251,25 @@ public class ContainerAnvil extends ContainerAnvilAbstract {
|
|
} else if (!this.renameText.equals(itemstack.getName().getString())) {
|
|
b1 = 1;
|
|
i += b1;
|
|
+ // Purpur start
|
|
+ if (player != null && player.world.purpurConfig.anvilAllowColors && player.getBukkitEntity().hasPermission("purpur.anvil.color")) {
|
|
+ String json = "";
|
|
+ try {
|
|
+ String coloredText = net.md_5.bungee.api.ChatColor.translateAlternateColorCodes('&', this.renameText);
|
|
+ net.md_5.bungee.api.chat.BaseComponent[] bungeeComp = net.md_5.bungee.api.chat.TextComponent.fromLegacyText(coloredText);
|
|
+ json = net.md_5.bungee.chat.ComponentSerializer.toString(bungeeComp);
|
|
+ IChatBaseComponent nmsComp = IChatBaseComponent.ChatSerializer.jsonToComponent(json);
|
|
+ itemstack1.a(nmsComp);
|
|
+ } catch (Exception e) {
|
|
+ MinecraftServer.LOGGER.warn("There was a problem processing item name json component on anvil!");
|
|
+ MinecraftServer.LOGGER.warn("We have fallen back to legacy colorless item name to prevent real errors");
|
|
+ MinecraftServer.LOGGER.warn("Please report this to Purpur!");
|
|
+ MinecraftServer.LOGGER.warn("JSON: " + json);
|
|
+ MinecraftServer.LOGGER.warn("The following error describes what went wrong:");
|
|
+ e.printStackTrace();
|
|
+ }
|
|
+ } else
|
|
+ // Purpur end
|
|
itemstack1.a((IChatBaseComponent) (new ChatComponentText(this.renameText)));
|
|
}
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index be101114003d06b445040b98b8b80e78a0b44bed..02fdf6d801f6583ac9991fc08d9811432fb9602b 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -222,6 +222,11 @@ public class PurpurWorldConfig {
|
|
});
|
|
}
|
|
|
|
+ public boolean anvilAllowColors = false;
|
|
+ private void anvilSettings() {
|
|
+ anvilAllowColors = getBoolean("blocks.anvil.allow-colors", anvilAllowColors);
|
|
+ }
|
|
+
|
|
public boolean bedExplode = true;
|
|
public double bedExplosionPower = 5.0D;
|
|
public boolean bedExplosionFire = true;
|