mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@29b17a8 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9088) PaperMC/Paper@b5ce6e3 Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9104) PaperMC/Paper@9cda284 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@f8c0112 {ci skip} add missing labels to project status map (#9106) PaperMC/Paper@6a7fef0 Allow entity effect changes off the main thread for worldgen (#8942) PaperMC/Paper@f8d2f82 Resolve Plugin Dependency Issues, Improve PluginLoading Compat, Small Loading Issues (#9068) PaperMC/Paper@b626528 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@058d7c1 Updated Upstream (Bukkit/CraftBukkit/Spigot) PaperMC/Paper@ab72b12 Update Adventure to 4.13.1 (#9113) PaperMC/Paper@8be7a60 Fix getBrightness and getRawBrightness throwing exception in BlockStateListPopulator (#9111) PaperMC/Paper@e811927 Revert "Resolve Plugin Dependency Issues, Improve PluginLoading Compat, Small Loading Issues (#9068)" Pufferfish Changes: pufferfish-gg/Pufferfish@da9fd85 Updated Upstream (Paper) pufferfish-gg/Pufferfish@751dfb0 Updated Upstream (Paper) pufferfish-gg/Pufferfish@c09a154 Updated Upstream (Paper) pufferfish-gg/Pufferfish@b778163 Updated Upstream (Paper)
78 lines
4.6 KiB
Diff
78 lines
4.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Tue, 3 Nov 2020 01:25:06 -0600
|
|
Subject: [PATCH] Allow color codes in books
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 112d830b024bd67297d24c030e7f02450be5eecf..9ec106d3e550eba93ca154094a3b51aa42732d88 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1341,13 +1341,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
itemstack1.setTag(nbttagcompound.copy());
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ boolean hasPerm = getCraftPlayer().hasPermission("purpur.book.color.edit") || getCraftPlayer().hasPermission("purpur.book.color.sign");
|
|
itemstack1.addTagElement("author", StringTag.valueOf(this.player.getName().getString()));
|
|
if (this.player.isTextFilteringEnabled()) {
|
|
- itemstack1.addTagElement("title", StringTag.valueOf(title.filteredOrEmpty()));
|
|
+ itemstack1.addTagElement("title", StringTag.valueOf(color(title.filteredOrEmpty(), hasPerm)));
|
|
} else {
|
|
- itemstack1.addTagElement("filtered_title", StringTag.valueOf(title.filteredOrEmpty()));
|
|
- itemstack1.addTagElement("title", StringTag.valueOf(title.raw()));
|
|
+ itemstack1.addTagElement("filtered_title", StringTag.valueOf(color(title.filteredOrEmpty(), hasPerm)));
|
|
+ itemstack1.addTagElement("title", StringTag.valueOf(color(title.raw(), hasPerm)));
|
|
}
|
|
+ // Purpur end
|
|
|
|
this.updateBookPages(pages, (s) -> {
|
|
return Component.Serializer.toJson(Component.literal(s));
|
|
@@ -1359,10 +1362,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
private void updateBookPages(List<FilteredText> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack handItem) { // CraftBukkit
|
|
ListTag nbttaglist = new ListTag();
|
|
|
|
+ // Purpur start
|
|
+ boolean hasPerm = getCraftPlayer().hasPermission("purpur.book.color.edit");
|
|
if (this.player.isTextFilteringEnabled()) {
|
|
- Stream<StringTag> stream = list.stream().map((filteredtext) -> { // CraftBukkit - decompile error
|
|
- return StringTag.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty()));
|
|
+ Stream<StringTag> stream = list.stream().map(s -> color(s.filteredOrEmpty(), hasPerm, false)).map((s) -> { // CraftBukkit - decompile error
|
|
+ return StringTag.valueOf((String) unaryoperator.apply(s));
|
|
});
|
|
+ // Purpur end
|
|
|
|
Objects.requireNonNull(nbttaglist);
|
|
stream.forEach(nbttaglist::add);
|
|
@@ -1372,11 +1378,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
|
|
for (int j = list.size(); i < j; ++i) {
|
|
FilteredText filteredtext = (FilteredText) list.get(i);
|
|
- String s = filteredtext.raw();
|
|
+ String s = color(filteredtext.raw(), hasPerm, false); // Purpur
|
|
|
|
nbttaglist.add(StringTag.valueOf((String) unaryoperator.apply(s)));
|
|
if (filteredtext.isFiltered()) {
|
|
- nbttagcompound.putString(String.valueOf(i), (String) unaryoperator.apply(filteredtext.filteredOrEmpty()));
|
|
+ nbttagcompound.putString(String.valueOf(i), (String) unaryoperator.apply((String) color(filteredtext.filteredOrEmpty(), hasPerm, false))); // Purpur
|
|
}
|
|
}
|
|
|
|
@@ -1389,6 +1395,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
this.player.getInventory().setItem(slot, CraftEventFactory.handleEditBookEvent(player, slot, handItem, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent)
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ private String color(String str, boolean hasPerm) {
|
|
+ return color(str, hasPerm, true);
|
|
+ }
|
|
+
|
|
+ private String color(String str, boolean hasPerm, boolean parseHex) {
|
|
+ return hasPerm ? org.bukkit.ChatColor.color(str, parseHex) : str;
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
public void handleEntityTagQuery(ServerboundEntityTagQuery packet) {
|
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|