Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Make command sender messages cleaner
Dieser Commit ist enthalten in:
Ursprung
3602c5087b
Commit
2e3677a592
@ -63,4 +63,15 @@ public abstract class ViaSubCommand {
|
|||||||
public String color(String s) {
|
public String color(String s) {
|
||||||
return ViaCommandHandler.color(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,4 +145,8 @@ public class ViaCommandHandler implements ViaVersionCommand, CommandExecutor, Ta
|
|||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendMessage(@NonNull CommandSender sender, String message, Object... args) {
|
||||||
|
sender.sendMessage(color(String.format(message, args)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ public class AutoTeamSubCmd extends ViaSubCommand {
|
|||||||
boolean newValue = !plugin.isAutoTeam();
|
boolean newValue = !plugin.isAutoTeam();
|
||||||
plugin.getConfig().set("auto-team", newValue);
|
plugin.getConfig().set("auto-team", newValue);
|
||||||
plugin.saveConfig();
|
plugin.saveConfig();
|
||||||
sender.sendMessage(color("&6We will " + (newValue ? "&aautomatically team players" : "&cno longer auto team players")));
|
sendMessage(sender, "&6We will %s", (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, "&6All players will need to re-login for the change to take place.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class DebugSubCmd extends ViaSubCommand {
|
|||||||
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||||
|
|
||||||
plugin.setDebug(!plugin.isDebug());
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@ public class DisplayLeaksSubCmd extends ViaSubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, String[] args) {
|
public boolean execute(CommandSender sender, String[] args) {
|
||||||
if (ResourceLeakDetector.getLevel() != ResourceLeakDetector.Level.ADVANCED) {
|
if (ResourceLeakDetector.getLevel() != ResourceLeakDetector.Level.ADVANCED)
|
||||||
ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
|
ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
|
||||||
} else {
|
else
|
||||||
ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class DontBugMeSubCmd extends ViaSubCommand {
|
|||||||
boolean newValue = !plugin.isCheckForUpdates();
|
boolean newValue = !plugin.isCheckForUpdates();
|
||||||
plugin.getConfig().set("checkforupdates", newValue);
|
plugin.getConfig().set("checkforupdates", newValue);
|
||||||
plugin.saveConfig();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class ListSubCmd extends ViaSubCommand {
|
|||||||
Map<Integer, Set<String>> sorted = new TreeMap<>(playerVersions);
|
Map<Integer, Set<String>> sorted = new TreeMap<>(playerVersions);
|
||||||
|
|
||||||
for (Map.Entry<Integer, Set<String>> entry : sorted.entrySet())
|
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();
|
sorted.clear();
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,7 +21,7 @@ public class ReloadSubCmd extends ViaSubCommand {
|
|||||||
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||||
|
|
||||||
plugin.generateConfig();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren