Files
Purpur/patches/server/0095-Allow-anvil-colors.patch
William Blake Galbreath 655af9a48c Component related conveniences
2021-06-29 21:43:43 -05:00

55 lines
2.8 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/world/inventory/AnvilMenu.java b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
index c81af461fa01dac0b7b26becc1a5e7ae31bb5f95..2dbc71a3d76cc87e2683b8f351bd8db04481855e 100644
--- a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
@@ -2,6 +2,9 @@ package net.minecraft.world.inventory;
import java.util.Iterator;
import java.util.Map;
+
+import io.papermc.paper.adventure.PaperAdventure;
+import net.kyori.adventure.text.format.TextDecoration;
import net.minecraft.nbt.IntTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
@@ -278,6 +281,17 @@ public class AnvilMenu extends ItemCombinerMenu {
} else if (!this.itemName.equals(itemstack.getHoverName().getString())) {
b1 = 1;
i += b1;
+ // Purpur start
+ if (player != null && player.level.purpurConfig.anvilAllowColors && player.getBukkitEntity().hasPermission("purpur.anvil.color")) {
+ final net.kyori.adventure.text.Component renameTextComponent;
+ if (itemName.startsWith("&r") && player.getBukkitEntity().hasPermission("purpur.anvil.remove_italics")) {
+ renameTextComponent = PaperAdventure.LEGACY_AMPERSAND.deserialize(itemName.substring(2)).decoration(TextDecoration.ITALIC, false);
+ } else {
+ renameTextComponent = PaperAdventure.LEGACY_AMPERSAND.deserialize(itemName);
+ }
+ itemstack1.setHoverName(PaperAdventure.asVanilla(renameTextComponent));
+ } else
+ // Purpur end
itemstack1.setHoverName((Component) (new TextComponent(this.itemName)));
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 97b8b8f6c6c9761d06344fa065a573a7bea37ef6..c0dd404357dade5ef61f6c20b143ec46543cfb51 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -274,6 +274,11 @@ public class PurpurWorldConfig {
voidDamageDealt = getDouble("gameplay-mechanics.void-damage-dealt", voidDamageDealt);
}
+ 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;