geforkt von SteamWar/BungeeCore
Update MsgCommand and RCommand to new Validator API
Dieser Commit ist enthalten in:
Ursprung
5eaa87885d
Commit
81913953d8
@ -19,10 +19,10 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.Message;
|
||||
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,14 +37,21 @@ public class MsgCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register(description = "MSG_USAGE")
|
||||
public void genericCommand(ProxiedPlayer sender, ProxiedPlayer target, String... message) {
|
||||
if (message.length == 0) {
|
||||
Message.send("MSG_USAGE", sender);
|
||||
return;
|
||||
}
|
||||
public void genericCommand(ProxiedPlayer sender, ProxiedPlayer target, @Validator 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()) {
|
||||
|
@ -36,11 +36,11 @@ public class RCommand extends SWCommand {
|
||||
MsgCommand.msg(player, lastChats.get(player), message);
|
||||
}
|
||||
|
||||
@ClassValidator(String[].class)
|
||||
@ClassValidator(value = String[].class, local = true)
|
||||
public TypeValidator<String[]> getValidator() {
|
||||
return (sender, value, messageSender) -> {
|
||||
if (value.length == 0) {
|
||||
messageSender.accept("R_USAGE", new Object[0]);
|
||||
messageSender.send("R_USAGE");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren