Skip to content

Commit a3ad720

Browse files
Remove ChatColor usages (#7543)
1 parent 2033dba commit a3ad720

File tree

908 files changed

+904
-794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

908 files changed

+904
-794
lines changed

patches/api/0005-Adventure.patch

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ index ab6b0ec328e94bf65a0dafd0403e5ee3b870296c..c8d37184d8e882a4084a1bfef85faa33
12841284

12851285
/**
12861286
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
1287-
index 4bfc214685164a38ba4261b2bae7faa8a3bd297e..8edd78adb042013bf702027f59455045d3b3e14f 100644
1287+
index 4bfc214685164a38ba4261b2bae7faa8a3bd297e..11af71edd7eaefb3cce3c2b59d390ff92e95ec64 100644
12881288
--- a/src/main/java/org/bukkit/command/Command.java
12891289
+++ b/src/main/java/org/bukkit/command/Command.java
12901290
@@ -32,8 +32,7 @@ public abstract class Command {
@@ -1340,7 +1340,7 @@ index 4bfc214685164a38ba4261b2bae7faa8a3bd297e..8edd78adb042013bf702027f59455045
13401340
return this;
13411341
}
13421342

1343-
@@ -399,6 +402,25 @@ public abstract class Command {
1343+
@@ -399,13 +402,47 @@ public abstract class Command {
13441344
this.usageMessage = (usage == null) ? "" : usage;
13451345
return this;
13461346
}
@@ -1366,6 +1366,43 @@ index 4bfc214685164a38ba4261b2bae7faa8a3bd297e..8edd78adb042013bf702027f59455045
13661366

13671367
public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull String message) {
13681368
broadcastCommandMessage(source, message, true);
1369+
}
1370+
1371+
public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull String message, boolean sendToSource) {
1372+
- String result = source.getName() + ": " + message;
1373+
+ // Paper start
1374+
+ broadcastCommandMessage(source, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message), sendToSource);
1375+
+ }
1376+
+
1377+
+ public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull net.kyori.adventure.text.Component message) {
1378+
+ broadcastCommandMessage(source, message, true);
1379+
+ }
1380+
+
1381+
+ public static void broadcastCommandMessage(@NotNull CommandSender source, @NotNull net.kyori.adventure.text.Component message, boolean sendToSource) {
1382+
+ net.kyori.adventure.text.TextComponent.Builder result = net.kyori.adventure.text.Component.text()
1383+
+ .color(net.kyori.adventure.text.format.NamedTextColor.WHITE)
1384+
+ .decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, false)
1385+
+ .append(source.name())
1386+
+ .append(net.kyori.adventure.text.Component.text(": "))
1387+
+ .append(message);
1388+
+ // Paper end
1389+
1390+
if (source instanceof BlockCommandSender) {
1391+
BlockCommandSender blockCommandSender = (BlockCommandSender) source;
1392+
@@ -424,7 +461,12 @@ public abstract class Command {
1393+
}
1394+
1395+
Set<Permissible> users = Bukkit.getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
1396+
- String colored = ChatColor.GRAY + "" + ChatColor.ITALIC + "[" + result + ChatColor.GRAY + ChatColor.ITALIC + "]";
1397+
+ // Paper start
1398+
+ net.kyori.adventure.text.TextComponent.Builder colored = net.kyori.adventure.text.Component.text()
1399+
+ .color(net.kyori.adventure.text.format.NamedTextColor.GRAY)
1400+
+ .decorate(net.kyori.adventure.text.format.TextDecoration.ITALIC)
1401+
+ .append(net.kyori.adventure.text.Component.text("["), result, net.kyori.adventure.text.Component.text("]"));
1402+
+ // Paper end
1403+
1404+
if (sendToSource && !(source instanceof ConsoleCommandSender)) {
1405+
source.sendMessage(message);
13691406
diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java
13701407
index 284be63a125624a8ae43d2c164aede810ce6bfe5..22b654efdcc49d6dc6d52c9d6afa1c9dc7978e35 100644
13711408
--- a/src/main/java/org/bukkit/command/CommandSender.java
@@ -3639,7 +3676,7 @@ index 94852d50e88d0594b84b581cd627174043629995..36bcbb3f3acedf7ebecbf6f6b358cf64
36393676
throw new UnsupportedOperationException("Not supported yet.");
36403677
}
36413678
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
3642-
index 91eee1470f0969e9eef0753c0c700ae5354f1acc..69f68ca2d62c2cfe07a193776054c14c352a5942 100644
3679+
index 2fbb0b7640dd9b9b0e70d4bc60fbb0310d5ec250..a19635c38705e6221ae25d58e976e483e7ed17e4 100644
36433680
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
36443681
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
36453682
@@ -31,6 +31,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste

patches/api/0007-Timings-v2.patch

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,10 +1559,10 @@ index 0000000000000000000000000000000000000000..da76e1aaee1dee794e38ddd4e0a28e00
15591559
+}
15601560
diff --git a/src/main/java/co/aikar/timings/TimingsCommand.java b/src/main/java/co/aikar/timings/TimingsCommand.java
15611561
new file mode 100644
1562-
index 0000000000000000000000000000000000000000..f7c2245a310a084367ff25db539b3c967d5cb141
1562+
index 0000000000000000000000000000000000000000..c01606bddbcf123ca322d14cbccfc3095777dd4c
15631563
--- /dev/null
15641564
+++ b/src/main/java/co/aikar/timings/TimingsCommand.java
1565-
@@ -0,0 +1,119 @@
1565+
@@ -0,0 +1,120 @@
15661566
+/*
15671567
+ * This file is licensed under the MIT License (MIT).
15681568
+ *
@@ -1589,16 +1589,17 @@ index 0000000000000000000000000000000000000000..f7c2245a310a084367ff25db539b3c96
15891589
+package co.aikar.timings;
15901590
+
15911591
+import com.google.common.collect.ImmutableList;
1592+
+import net.kyori.adventure.text.format.NamedTextColor;
15921593
+import org.apache.commons.lang.Validate;
1593-
+import org.bukkit.ChatColor;
15941594
+import org.bukkit.command.CommandSender;
15951595
+import org.bukkit.command.defaults.BukkitCommand;
15961596
+import org.bukkit.util.StringUtil;
15971597
+
15981598
+import java.util.ArrayList;
15991599
+import java.util.List;
16001600
+import org.jetbrains.annotations.NotNull;
1601-
+import org.jetbrains.annotations.Nullable;
1601+
+
1602+
+import static net.kyori.adventure.text.Component.text;
16021603
+
16031604
+
16041605
+public class TimingsCommand extends BukkitCommand {
@@ -1618,41 +1619,41 @@ index 0000000000000000000000000000000000000000..f7c2245a310a084367ff25db539b3c96
16181619
+ return true;
16191620
+ }
16201621
+ if (args.length < 1) {
1621-
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
1622+
+ sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED));
16221623
+ return true;
16231624
+ }
16241625
+ final String arg = args[0];
16251626
+ if ("on".equalsIgnoreCase(arg)) {
16261627
+ Timings.setTimingsEnabled(true);
1627-
+ sender.sendMessage("Enabled Timings & Reset");
1628+
+ sender.sendMessage(text("Enabled Timings & Reset"));
16281629
+ return true;
16291630
+ } else if ("off".equalsIgnoreCase(arg)) {
16301631
+ Timings.setTimingsEnabled(false);
1631-
+ sender.sendMessage("Disabled Timings");
1632+
+ sender.sendMessage(text("Disabled Timings"));
16321633
+ return true;
16331634
+ }
16341635
+
16351636
+ if (!Timings.isTimingsEnabled()) {
1636-
+ sender.sendMessage("Please enable timings by typing /timings on");
1637+
+ sender.sendMessage(text("Please enable timings by typing /timings on"));
16371638
+ return true;
16381639
+ }
16391640
+
16401641
+ long now = System.currentTimeMillis();
16411642
+ if ("verbon".equalsIgnoreCase(arg)) {
16421643
+ Timings.setVerboseTimingsEnabled(true);
1643-
+ sender.sendMessage("Enabled Verbose Timings");
1644+
+ sender.sendMessage(text("Enabled Verbose Timings"));
16441645
+ return true;
16451646
+ } else if ("verboff".equalsIgnoreCase(arg)) {
16461647
+ Timings.setVerboseTimingsEnabled(false);
1647-
+ sender.sendMessage("Disabled Verbose Timings");
1648+
+ sender.sendMessage(text("Disabled Verbose Timings"));
16481649
+ return true;
16491650
+ } else if ("reset".equalsIgnoreCase(arg)) {
16501651
+ if (now - lastResetAttempt < 30000) {
16511652
+ TimingsManager.reset();
1652-
+ sender.sendMessage(ChatColor.RED + "Timings reset. Please wait 5-10 minutes before using /timings report.");
1653+
+ sender.sendMessage(text("Timings reset. Please wait 5-10 minutes before using /timings report.", NamedTextColor.RED));
16531654
+ } else {
16541655
+ lastResetAttempt = now;
1655-
+ sender.sendMessage(ChatColor.RED + "WARNING: Timings v2 should not be reset. If you are encountering lag, please wait 3 minutes and then issue a report. The best timings will include 10+ minutes, with data before and after your lag period. If you really want to reset, run this command again within 30 seconds.");
1656+
+ sender.sendMessage(text("WARNING: Timings v2 should not be reset. If you are experiencing lag, please wait 3 minutes and then issue a report. The best timings will include 10+ minutes, with data before and after your lag period. If you really want to reset, run this command again within 30 seconds.", NamedTextColor.RED));
16561657
+ }
16571658
+ } else if (
16581659
+ "paste".equalsIgnoreCase(arg) ||
@@ -1663,7 +1664,7 @@ index 0000000000000000000000000000000000000000..f7c2245a310a084367ff25db539b3c96
16631664
+ ) {
16641665
+ Timings.generateReport(sender);
16651666
+ } else {
1666-
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
1667+
+ sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED));
16671668
+ }
16681669
+ return true;
16691670
+ }
@@ -2887,7 +2888,7 @@ index 0000000000000000000000000000000000000000..f9a00aecca5ec41b460bf41dfe1c6969
28872888
+ }
28882889
+}
28892890
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
2890-
index 8edd78adb042013bf702027f59455045d3b3e14f..53f9262f7c61985eeef1f418098bd764522d3c9a 100644
2891+
index 11af71edd7eaefb3cce3c2b59d390ff92e95ec64..8d7a61b711cec7eff0e71b9ae942f3050196d955 100644
28912892
--- a/src/main/java/org/bukkit/command/Command.java
28922893
+++ b/src/main/java/org/bukkit/command/Command.java
28932894
@@ -33,6 +33,8 @@ public abstract class Command {

patches/api/0029-Add-command-to-reload-permissions.yml-and-require-co.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ index 75bc4937f7a895c1bbf0a0800035ad8f7e0c5f46..be5f25a51a12082cb6732445c221d612
3535
+ void reloadPermissions(); // Paper
3636
}
3737
diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
38-
index 50cc311be7904cc8fc6070a21c8e4de3a489fd20..c62da4131b17e66892678e8b618fb9ba3de93b56 100644
38+
index 50cc311be7904cc8fc6070a21c8e4de3a489fd20..5fa9d648bc780e874f658597f1a24715bccac5cb 100644
3939
--- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
4040
+++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
4141
@@ -13,15 +13,35 @@ public class ReloadCommand extends BukkitCommand {
@@ -58,17 +58,17 @@ index 50cc311be7904cc8fc6070a21c8e4de3a489fd20..c62da4131b17e66892678e8b618fb9ba
5858
+ if (args.length == 1) {
5959
+ if (args[0].equalsIgnoreCase("permissions")) {
6060
+ Bukkit.getServer().reloadPermissions();
61-
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Permissions successfully reloaded.");
61+
+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Permissions successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
6262
+ return true;
6363
+ } else if ("confirm".equalsIgnoreCase(args[0])) {
6464
+ confirmed = true;
6565
+ } else {
66-
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Usage: " + usageMessage);
66+
+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Usage: " + usageMessage, net.kyori.adventure.text.format.NamedTextColor.RED));
6767
+ return true;
6868
+ }
6969
+ }
7070
+ if (!confirmed) {
71-
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Are you sure you wish to reload your server? Doing so may cause bugs and memory leaks. It is recommended to restart instead of using /reload. To confirm, please type " + ChatColor.YELLOW + "/reload confirm");
71+
+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Are you sure you wish to reload your server? Doing so may cause bugs and memory leaks. It is recommended to restart instead of using /reload. To confirm, please type ", net.kyori.adventure.text.format.NamedTextColor.RED).append(net.kyori.adventure.text.Component.text("/reload confirm", net.kyori.adventure.text.format.NamedTextColor.YELLOW)));
7272
+ return true;
7373
+ }
7474
+ // Paper end

patches/api/0042-Allow-Reloading-of-Command-Aliases.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ index adfc7aae2c0f49bbcdd358e83b04a0cf078a7d52..460fda05a62b12db2edcfb7ea8b2a5dd
7272
+ // Paper end
7373
}
7474
diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
75-
index c62da4131b17e66892678e8b618fb9ba3de93b56..0c7ba0718de2b93d013968ca0fec34ffd423990f 100644
75+
index 5fa9d648bc780e874f658597f1a24715bccac5cb..3ec32b46264cfff857b50129b5e0fa5584943ec6 100644
7676
--- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
7777
+++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java
7878
@@ -13,7 +13,7 @@ public class ReloadCommand extends BukkitCommand {
@@ -86,13 +86,13 @@ index c62da4131b17e66892678e8b618fb9ba3de93b56..0c7ba0718de2b93d013968ca0fec34ff
8686
}
8787
@@ -29,6 +29,13 @@ public class ReloadCommand extends BukkitCommand {
8888
Bukkit.getServer().reloadPermissions();
89-
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Permissions successfully reloaded.");
89+
Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Permissions successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
9090
return true;
9191
+ } else if ("commands".equalsIgnoreCase(args[0])) {
9292
+ if (Bukkit.getServer().reloadCommandAliases()) {
93-
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Command aliases successfully reloaded.");
93+
+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("Command aliases successfully reloaded.", net.kyori.adventure.text.format.NamedTextColor.GREEN));
9494
+ } else {
95-
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "An error occurred while trying to reload command aliases.");
95+
+ Command.broadcastCommandMessage(sender, net.kyori.adventure.text.Component.text("An error occurred while trying to reload command aliases.", net.kyori.adventure.text.format.NamedTextColor.RED));
9696
+ }
9797
+ return true;
9898
} else if ("confirm".equalsIgnoreCase(args[0])) {

0 commit comments

Comments
 (0)