3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-09-08 22:02:50 +02:00

Make command sender messages cleaner

Dieser Commit ist enthalten in:
Matsv 2016-04-02 11:51:17 +02:00
Ursprung 3602c5087b
Commit 2e3677a592
8 geänderte Dateien mit 25 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -63,4 +63,15 @@ public abstract class ViaSubCommand {
public String color(String s) {
return ViaCommandHandler.color(s);
}
/**
* Send message formatted / colored
*
* @param sender command sender
* @param message string message
* @param args optional objects
*/
public void sendMessage(CommandSender sender, String message, Object... args){
ViaCommandHandler.sendMessage(sender, message, args);
}
}

Datei anzeigen

@ -145,4 +145,8 @@ public class ViaCommandHandler implements ViaVersionCommand, CommandExecutor, Ta
}
return string;
}
public static void sendMessage(@NonNull CommandSender sender, String message, Object... args) {
sender.sendMessage(color(String.format(message, args)));
}
}

Datei anzeigen

@ -23,8 +23,8 @@ public class AutoTeamSubCmd extends ViaSubCommand {
boolean newValue = !plugin.isAutoTeam();
plugin.getConfig().set("auto-team", newValue);
plugin.saveConfig();
sender.sendMessage(color("&6We will " + (newValue ? "&aautomatically team players" : "&cno longer auto team players")));
sender.sendMessage(color("&6All players will need to re-login for the change to take place."));
sendMessage(sender, "&6We will %s", (newValue ? "&aautomatically team players" : "&cno longer auto team players"));
sendMessage(sender, "&6All players will need to re-login for the change to take place.");
return true;
}

Datei anzeigen

@ -21,7 +21,7 @@ public class DebugSubCmd extends ViaSubCommand {
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
plugin.setDebug(!plugin.isDebug());
sender.sendMessage(color("&6Debug mode is now " + (plugin.isDebug() ? "&aenabled" : "&cdisabled")));
sendMessage(sender, "&6Debug mode is now %s" , (plugin.isDebug() ? "&aenabled" : "&cdisabled"));
return true;
}
}

Datei anzeigen

@ -17,12 +17,12 @@ public class DisplayLeaksSubCmd extends ViaSubCommand {
@Override
public boolean execute(CommandSender sender, String[] args) {
if (ResourceLeakDetector.getLevel() != ResourceLeakDetector.Level.ADVANCED) {
if (ResourceLeakDetector.getLevel() != ResourceLeakDetector.Level.ADVANCED)
ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
} else {
else
ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);
}
sender.sendMessage(color("&6Leak detector is now " + (ResourceLeakDetector.getLevel() == ResourceLeakDetector.Level.ADVANCED ? "&aenabled" : "&cdisabled")));
sendMessage(sender, "&6Leak detector is now %s", (ResourceLeakDetector.getLevel() == ResourceLeakDetector.Level.ADVANCED ? "&aenabled" : "&cdisabled"));
return true;
}
}

Datei anzeigen

@ -23,7 +23,7 @@ public class DontBugMeSubCmd extends ViaSubCommand {
boolean newValue = !plugin.isCheckForUpdates();
plugin.getConfig().set("checkforupdates", newValue);
plugin.saveConfig();
sender.sendMessage(color("&6We will " + (newValue ? "&anotify you about updates." : "&cnot tell you about updates.")));
sendMessage(sender, "&6We will %snotify you about updates.", (newValue ? "&a" : "&cnot "));
return true;
}

Datei anzeigen

@ -39,7 +39,7 @@ public class ListSubCmd extends ViaSubCommand {
Map<Integer, Set<String>> sorted = new TreeMap<>(playerVersions);
for (Map.Entry<Integer, Set<String>> entry : sorted.entrySet())
sender.sendMessage(String.format(color("&8[&6%s&8]: &b%s"), ProtocolVersion.getProtocol(entry.getKey()).getName(), entry.getValue()));
sendMessage(sender, "&8[&6%s&8]: &b%s", ProtocolVersion.getProtocol(entry.getKey()).getName(), entry.getValue());
sorted.clear();
return true;

Datei anzeigen

@ -21,7 +21,7 @@ public class ReloadSubCmd extends ViaSubCommand {
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
plugin.generateConfig();
sender.sendMessage(color("&6Configuration successfully reloaded! Some features may need a restart."));
sendMessage(sender, "&6Configuration successfully reloaded! Some features may need a restart.");
return true;
}
}