From 81913953d8773f784940546e7f7217c97bd4c174 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 16 Jun 2022 23:10:27 +0200 Subject: [PATCH] Update MsgCommand and RCommand to new Validator API --- .../bungeecore/commands/MsgCommand.java | 19 +++++++++++++------ .../bungeecore/commands/RCommand.java | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/MsgCommand.java b/src/de/steamwar/bungeecore/commands/MsgCommand.java index 0eb5751..dcbc792 100644 --- a/src/de/steamwar/bungeecore/commands/MsgCommand.java +++ b/src/de/steamwar/bungeecore/commands/MsgCommand.java @@ -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 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()) { diff --git a/src/de/steamwar/bungeecore/commands/RCommand.java b/src/de/steamwar/bungeecore/commands/RCommand.java index fa69199..13914d8 100644 --- a/src/de/steamwar/bungeecore/commands/RCommand.java +++ b/src/de/steamwar/bungeecore/commands/RCommand.java @@ -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 getValidator() { return (sender, value, messageSender) -> { if (value.length == 0) { - messageSender.accept("R_USAGE", new Object[0]); + messageSender.send("R_USAGE"); return false; } return true;