Archiviert
1
0

Merge pull request 'Optimize MsgCommand' (#410) from OptimizeMSGAndRCommand into master

Reviewed-on: SteamWar/BungeeCore#410
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2022-06-20 13:08:51 +02:00
Commit d507ca5df2
3 geänderte Dateien mit 3 neuen und 27 gelöschten Zeilen

@ -1 +1 @@
Subproject commit c4ed8948ad5bb2cb8414ee2d3408e52928237908
Subproject commit 4e46e05a3b0c627a34631848874fc56d14ba56e4

Datei anzeigen

@ -22,7 +22,6 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.listeners.ChatListener;
import de.steamwar.bungeecore.sql.IgnoreSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -37,21 +36,10 @@ public class MsgCommand extends SWCommand {
}
@Register(description = "MSG_USAGE")
public void genericCommand(ProxiedPlayer sender, ProxiedPlayer target, @Validator String... message) {
public void genericCommand(ProxiedPlayer sender, ProxiedPlayer target, @ErrorMessage(value = "MSG_USAGE", allowEAs = false) String... message) {
msg(sender, target, message);
}
@ClassValidator(value = String[].class, local = true)
public TypeValidator<String[]> getValidator() {
return (sender, value, messageSender) -> {
if (value.length == 0) {
messageSender.send("MSG_USAGE");
return false;
}
return true;
};
}
public static void msg(ProxiedPlayer player, ProxiedPlayer target, String[] args) {
ChatSender sender = ChatSender.of(player);
if(target == null || !target.isConnected()) {

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import static de.steamwar.bungeecore.Storage.lastChats;
@ -32,18 +31,7 @@ public class RCommand extends SWCommand {
}
@Register(description = "R_USAGE")
public void genericCommand(ProxiedPlayer player, @Validator String... message) {
public void genericCommand(ProxiedPlayer player, @ErrorMessage(value = "MSG_USAGE", allowEAs = false) String... message) {
MsgCommand.msg(player, lastChats.get(player), message);
}
@ClassValidator(value = String[].class, local = true)
public TypeValidator<String[]> getValidator() {
return (sender, value, messageSender) -> {
if (value.length == 0) {
messageSender.send("R_USAGE");
return false;
}
return true;
};
}
}