Make messages yellow if the command executor is using CommandSpy (#6)

This commit is contained in:
business-goose 2022-02-27 10:35:20 +00:00 committed by GitHub
parent b4ce0443a4
commit 1cd9ff47ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 7 deletions

View File

@ -1,5 +1,6 @@
package pw.kaboom.commandspy;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
@ -70,14 +71,17 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener
return;
}
for (String uuidString : config.getKeys(false)) {
Set<String> uuids = config.getKeys(false);
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
for (String uuidString : uuids) {
UUID uuid = UUID.fromString(uuidString);
if (Bukkit.getPlayer(uuid) != null) {
Bukkit.getPlayer(uuid).sendMessage(
ChatColor.AQUA + ""
color + ""
+ event.getPlayer().getName() + ""
+ ChatColor.AQUA + ": "
+ color + ": "
+ event.getMessage()
);
}
@ -86,18 +90,21 @@ public final class Main extends JavaPlugin implements CommandExecutor, Listener
@EventHandler
void onSignChange(final SignChangeEvent event) {
for (String uuidString : config.getKeys(false)) {
Set<String> uuids = config.getKeys(false);
ChatColor color = (uuids.contains(event.getPlayer().getUniqueId().toString())) ? ChatColor.YELLOW : ChatColor.AQUA;
for (String uuidString : uuids) {
UUID uuid = UUID.fromString(uuidString);
if (Bukkit.getPlayer(uuid) != null) {
Bukkit.getPlayer(uuid).sendMessage(
ChatColor.AQUA + ""
color + ""
+ event.getPlayer().getName() + ""
+ ChatColor.AQUA
+ color
+ " created a sign with contents:"
);
for (String line: event.getLines()) {
Bukkit.getPlayer(uuid).sendMessage(ChatColor.AQUA + " " + line);
Bukkit.getPlayer(uuid).sendMessage(color + " " + line);
}
}
}