mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 09:27:43 +01:00
Allow anvil colors
This commit is contained in:
52
patches/server/0122-Allow-anvil-colors.patch
Normal file
52
patches/server/0122-Allow-anvil-colors.patch
Normal file
@@ -0,0 +1,52 @@
|
||||
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 4aa6b035a6..5e4e59e5c8 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 278b100de9..711858a716 100644
|
||||
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
||||
@@ -206,6 +206,11 @@ public class PurpurWorldConfig {
|
||||
});
|
||||
}
|
||||
|
||||
+ public boolean anvilAllowColors = false;
|
||||
+ private void anvilSettings() {
|
||||
+ anvilAllowColors = getBoolean("blocks.anvil.allow-colors", anvilAllowColors);
|
||||
+ }
|
||||
+
|
||||
public int bambooMaxHeight = 16;
|
||||
public int bambooSmallHeight = 10;
|
||||
private void bambooSettings() {
|
||||
Reference in New Issue
Block a user