Implement /delkit command

Closes #2709, closes #2719.
This commit is contained in:
md678685 2019-08-05 14:06:37 +01:00
parent d2724d77df
commit b97eb12dfc
4 changed files with 52 additions and 0 deletions

View File

@ -79,6 +79,12 @@ public class Kits implements IConf {
config.save(); config.save();
} }
public void removeKit(String name) {
config.set("kits." + name, null);
kits = _getKits();
config.save();
}
public String listKits(final net.ess3.api.IEssentials ess, final User user) throws Exception { public String listKits(final net.ess3.api.IEssentials ess, final User user) throws Exception {
try { try {
final ConfigurationSection kits = config.getConfigurationSection("kits"); final ConfigurationSection kits = config.getConfigurationSection("kits");

View File

@ -0,0 +1,41 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.Kit;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.StringUtil;
import org.bukkit.Server;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import static com.earth2me.essentials.I18n.tl;
public class Commanddelkit extends EssentialsCommand {
public Commanddelkit() {
super("delkit");
}
@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length < 1) {
final String kitList = ess.getKits().listKits(ess, null);
sender.sendMessage(kitList.length() > 0 ? tl("kits", kitList) : tl("noKits"));
throw new NoChargeException();
} else {
final String kitName = args[0];
final Kit kit = new Kit(kitName, ess);
if (sender.getPlayer() != null) {
kit.checkPerms(ess.getUser(sender.getPlayer()));
}
ess.getKits().removeKit(kitName);
sender.sendMessage(tl("deleteKit", kit));
}
}
}

View File

@ -89,6 +89,7 @@ defaultBanReason=The Ban Hammer has spoken\!
deleteFileError=Could not delete file\: {0} deleteFileError=Could not delete file\: {0}
deleteHome=\u00a76Home\u00a7c {0} \u00a76has been removed. deleteHome=\u00a76Home\u00a7c {0} \u00a76has been removed.
deleteJail=\u00a76Jail\u00a7c {0} \u00a76has been removed. deleteJail=\u00a76Jail\u00a7c {0} \u00a76has been removed.
deleteKit=\u00a76Kit\u00a7c {0} \u00a76has been removed.
deleteWarp=\u00a76Warp\u00a7c {0} \u00a76has been removed. deleteWarp=\u00a76Warp\u00a7c {0} \u00a76has been removed.
deniedAccessCommand=\u00a7c{0} \u00a74was denied access to command. deniedAccessCommand=\u00a7c{0} \u00a74was denied access to command.
denyBookEdit=\u00a74You cannot unlock this book. denyBookEdit=\u00a74You cannot unlock this book.

View File

@ -96,6 +96,10 @@ commands:
description: Removes a jail. description: Removes a jail.
usage: /<command> <jailname> usage: /<command> <jailname>
aliases: [edeljail,remjail,eremjail,rmjail,ermjail] aliases: [edeljail,remjail,eremjail,rmjail,ermjail]
delkit:
description: Deletes the specified kit.
usage: /<command> <kit>
aliases: [edelkit,remkit,eremkit,rmkit,ermkit]
delwarp: delwarp:
description: Deletes the specified warp. description: Deletes the specified warp.
usage: /<command> <warp> usage: /<command> <warp>