mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-27 04:25:12 +01:00
Merge pull request #311 from Matsv/dev
Make command sender messages cleaner
This commit is contained in:
commit
8adbf36a3a
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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(args == null ? message : String.format(message, args)));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user