Optimize MsgCommand #410
@ -1 +1 @@
|
||||
Subproject commit c4ed8948ad5bb2cb8414ee2d3408e52928237908
|
||||
Subproject commit 4e46e05a3b0c627a34631848874fc56d14ba56e4
|
@ -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()) {
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren
Wird nicht bei einem Fehler sowieso MSG_USAGE getriggert aufgrund der description? (Ansonsten wäre das ggf. ein guter Standard?)
Was bedeutet allowEAs?
allowEAs steht für:
Was default auf 'true' ist, was der default sein muss wegen backwards compatibility. Und die MSG_USAGE wird halt nicht getriggert wenn es um Strings geht. Da das ja auf alles matched, deswegen gibt es 'allowEAs' damit man eben abschalten kann das leere arrays erlaubt werden als parameter.