From c883d1c1cc9ad8bb9ae8e49ee935e256e7fc11b9 Mon Sep 17 00:00:00 2001 From: yueyinqiu Date: Tue, 7 Jul 2020 18:02:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96worlds=20remove?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/worlds/RemoveExecutor.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/NWorldPermissions/src/top/nololiyt/worldpermissions/commands/worlds/RemoveExecutor.java b/NWorldPermissions/src/top/nololiyt/worldpermissions/commands/worlds/RemoveExecutor.java index b9cf362..82bd0e1 100644 --- a/NWorldPermissions/src/top/nololiyt/worldpermissions/commands/worlds/RemoveExecutor.java +++ b/NWorldPermissions/src/top/nololiyt/worldpermissions/commands/worlds/RemoveExecutor.java @@ -4,6 +4,7 @@ import org.bukkit.configuration.Configuration; import top.nololiyt.worldpermissions.RootPlugin; import top.nololiyt.worldpermissions.entitiesandtools.DotDividedStringBuilder; +import top.nololiyt.worldpermissions.entitiesandtools.MessagesSender; import top.nololiyt.worldpermissions.entitiesandtools.StringPair; import top.nololiyt.worldpermissions.commands.Executor; @@ -33,26 +34,28 @@ protected boolean run(int layer, RootPlugin rootPlugin, DotDividedStringBuilder if (args.length - 1 != layer) return false; - StringPair[] cPairs = new StringPair[]{ - StringPair.worldName(args[layer]), + String worldName = args[layer]; + + MessagesSender messagesSender = new MessagesSender(rootPlugin.getMessagesManager(), + commandSender, new StringPair[]{ + StringPair.worldName(worldName), StringPair.senderName(commandSender.getName()) - }; + }); Configuration config = rootPlugin.getConfig(); List worlds = config.getStringList("controlled-worlds"); - if(!worlds.remove(args[layer])) + if (!worlds.remove(worldName)) { - rootPlugin.getMessagesManager().sendMessage( - commandSender, messageKey.append("no-such-controlled-world"), cPairs); + messagesSender.send(messageKey.append("no-such-controlled-world")); + return true; } config.set("controlled-worlds", worlds); rootPlugin.saveConfig(); - rootPlugin.getMessagesManager().sendMessage( - commandSender, messageKey.append("completed"), cPairs); + messagesSender.send(messageKey.append("completed")); return true; } } \ No newline at end of file