Update MsgCommand and RCommand to new Validator API
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Dieser Commit ist enthalten in:
Ursprung
5eaa87885d
Commit
81913953d8
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -37,14 +37,21 @@ public class MsgCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "MSG_USAGE")
|
@Register(description = "MSG_USAGE")
|
||||||
public void genericCommand(ProxiedPlayer sender, ProxiedPlayer target, String... message) {
|
public void genericCommand(ProxiedPlayer sender, ProxiedPlayer target, @Validator String... message) {
|
||||||
if (message.length == 0) {
|
|
||||||
Message.send("MSG_USAGE", sender);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
msg(sender, target, 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) {
|
public static void msg(ProxiedPlayer player, ProxiedPlayer target, String[] args) {
|
||||||
ChatSender sender = ChatSender.of(player);
|
ChatSender sender = ChatSender.of(player);
|
||||||
if(target == null || !target.isConnected()) {
|
if(target == null || !target.isConnected()) {
|
||||||
|
@ -36,11 +36,11 @@ public class RCommand extends SWCommand {
|
|||||||
MsgCommand.msg(player, lastChats.get(player), message);
|
MsgCommand.msg(player, lastChats.get(player), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(String[].class)
|
@ClassValidator(value = String[].class, local = true)
|
||||||
public TypeValidator<String[]> getValidator() {
|
public TypeValidator<String[]> getValidator() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
if (value.length == 0) {
|
if (value.length == 0) {
|
||||||
messageSender.accept("R_USAGE", new Object[0]);
|
messageSender.send("R_USAGE");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren