mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-29 13:45:13 +01:00
Cleaned up commands.
This commit is contained in:
parent
1d3e699555
commit
49b30f5f50
@ -140,17 +140,17 @@ public class UltimateKits extends SongodaPlugin {
|
|||||||
|
|
||||||
// setup commands
|
// setup commands
|
||||||
this.commandManager = new CommandManager(this);
|
this.commandManager = new CommandManager(this);
|
||||||
this.commandManager.addCommand(new CommandKit(guiManager));
|
this.commandManager.addCommand(new CommandKit(this, guiManager));
|
||||||
this.commandManager.addCommand(new CommandPreviewKit(guiManager));
|
this.commandManager.addCommand(new CommandPreviewKit(this, guiManager));
|
||||||
this.commandManager.addMainCommand("KitAdmin")
|
this.commandManager.addMainCommand("KitAdmin")
|
||||||
.addSubCommand(new CommandReload())
|
.addSubCommand(new CommandReload(this))
|
||||||
.addSubCommand(new CommandSettings(guiManager))
|
.addSubCommand(new CommandSettings(this, guiManager))
|
||||||
.addSubCommand(new CommandCreatekit(guiManager))
|
.addSubCommand(new CommandCreatekit(this, guiManager))
|
||||||
.addSubCommand(new CommandCategories(guiManager))
|
.addSubCommand(new CommandCategories(this, guiManager))
|
||||||
.addSubCommand(new CommandEdit(guiManager))
|
.addSubCommand(new CommandEdit(this, guiManager))
|
||||||
.addSubCommand(new CommandKey())
|
.addSubCommand(new CommandKey(this))
|
||||||
.addSubCommand(new CommandSet())
|
.addSubCommand(new CommandSet(this))
|
||||||
.addSubCommand(new CommandRemove())
|
.addSubCommand(new CommandRemove(this))
|
||||||
|
|
||||||
.addSubCommand(new CommandCrate());
|
.addSubCommand(new CommandCrate());
|
||||||
|
|
||||||
|
@ -11,11 +11,12 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandCategories extends AbstractCommand {
|
public class CommandCategories extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits plugin = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
final GuiManager guiManager;
|
private final GuiManager guiManager;
|
||||||
|
|
||||||
public CommandCategories(GuiManager guiManager) {
|
public CommandCategories(UltimateKits plugin, GuiManager guiManager) {
|
||||||
super(CommandType.PLAYER_ONLY, "categories");
|
super(CommandType.PLAYER_ONLY, "categories");
|
||||||
|
this.plugin = plugin;
|
||||||
this.guiManager = guiManager;
|
this.guiManager = guiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ public class CommandCrate extends AbstractCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||||
|
|
||||||
if (args.length < 3 || args.length > 4) return ReturnType.SYNTAX_ERROR;
|
if (args.length < 3 || args.length > 4) return ReturnType.SYNTAX_ERROR;
|
||||||
|
|
||||||
OfflinePlayer target = Bukkit.getPlayer(args[0]);
|
OfflinePlayer target = Bukkit.getPlayer(args[0]);
|
||||||
|
@ -13,11 +13,12 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandCreatekit extends AbstractCommand {
|
public class CommandCreatekit extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits instance = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
final GuiManager guiManager;
|
private final GuiManager guiManager;
|
||||||
|
|
||||||
public CommandCreatekit(GuiManager guiManager) {
|
public CommandCreatekit(UltimateKits plugin, GuiManager guiManager) {
|
||||||
super(true, "createkit");
|
super(CommandType.PLAYER_ONLY, "createkit");
|
||||||
|
this.plugin = plugin;
|
||||||
this.guiManager = guiManager;
|
this.guiManager = guiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,15 +29,15 @@ public class CommandCreatekit extends AbstractCommand {
|
|||||||
return ReturnType.SYNTAX_ERROR;
|
return ReturnType.SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
String kitStr = args[0].toLowerCase();
|
String kitStr = args[0].toLowerCase();
|
||||||
if (instance.getKitManager().getKit(kitStr) != null) {
|
if (plugin.getKitManager().getKit(kitStr) != null) {
|
||||||
instance.getLocale().getMessage("command.kit.kitalreadyexists").sendPrefixedMessage(player);
|
plugin.getLocale().getMessage("command.kit.kitalreadyexists").sendPrefixedMessage(player);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.getLocale().newMessage("&aThat kit doesn't exist. Creating it now.").sendPrefixedMessage(player);
|
plugin.getLocale().newMessage("&aThat kit doesn't exist. Creating it now.").sendPrefixedMessage(player);
|
||||||
Kit kit = new Kit(kitStr.trim());
|
Kit kit = new Kit(kitStr.trim());
|
||||||
UltimateKits.getInstance().getKitManager().addKit(kit);
|
plugin.getKitManager().addKit(kit);
|
||||||
guiManager.showGUI(player, new KitEditorGui(instance, player, kit, null));
|
guiManager.showGUI(player, new KitEditorGui(plugin, player, kit, null));
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,11 +16,12 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandEdit extends AbstractCommand {
|
public class CommandEdit extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits instance = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
final GuiManager guiManager;
|
private final GuiManager guiManager;
|
||||||
|
|
||||||
public CommandEdit(GuiManager guiManager) {
|
public CommandEdit(UltimateKits plugin, GuiManager guiManager) {
|
||||||
super(true, "edit");
|
super(CommandType.PLAYER_ONLY, "edit");
|
||||||
|
this.plugin = plugin;
|
||||||
this.guiManager = guiManager;
|
this.guiManager = guiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,20 +32,20 @@ public class CommandEdit extends AbstractCommand {
|
|||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
Block block = player.getTargetBlock(null, 200);
|
Block block = player.getTargetBlock(null, 200);
|
||||||
KitBlockData kitBlockData = instance.getKitManager().getKit(block.getLocation());
|
KitBlockData kitBlockData = plugin.getKitManager().getKit(block.getLocation());
|
||||||
if (kitBlockData == null) {
|
if (kitBlockData == null) {
|
||||||
instance.getLocale().newMessage("command.kit.nokitatblock").sendPrefixedMessage(player);
|
plugin.getLocale().newMessage("command.kit.nokitatblock").sendPrefixedMessage(player);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
guiManager.showGUI(player, new BlockEditorGui(instance, kitBlockData));
|
guiManager.showGUI(player, new BlockEditorGui(plugin, kitBlockData));
|
||||||
} else {
|
} else {
|
||||||
String kitStr = args[0].toLowerCase().trim();
|
String kitStr = args[0].toLowerCase().trim();
|
||||||
if (instance.getKitManager().getKit(kitStr) == null) {
|
if (plugin.getKitManager().getKit(kitStr) == null) {
|
||||||
instance.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(player);
|
plugin.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(player);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
guiManager.showGUI(player, new KitEditorGui(instance, player, instance.getKitManager().getKit(kitStr), null));
|
guiManager.showGUI(player, new KitEditorGui(plugin, player, plugin.getKitManager().getKit(kitStr), null));
|
||||||
}
|
}
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
@ -53,7 +54,7 @@ public class CommandEdit extends AbstractCommand {
|
|||||||
protected List<String> onTab(CommandSender sender, String... args) {
|
protected List<String> onTab(CommandSender sender, String... args) {
|
||||||
List<String> tab = new ArrayList<>();
|
List<String> tab = new ArrayList<>();
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
for (Kit kit : UltimateKits.getInstance().getKitManager().getKits())
|
for (Kit kit : plugin.getKitManager().getKits())
|
||||||
tab.add(kit.getKey());
|
tab.add(kit.getKey());
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandKey extends AbstractCommand {
|
public class CommandKey extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits instance = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
|
|
||||||
public CommandKey() {
|
public CommandKey(UltimateKits plugin) {
|
||||||
super(false, "key");
|
super(CommandType.PLAYER_ONLY, "key");
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -27,14 +28,14 @@ public class CommandKey extends AbstractCommand {
|
|||||||
if (args.length != 3 && args.length != 4) {
|
if (args.length != 3 && args.length != 4) {
|
||||||
return ReturnType.SYNTAX_ERROR;
|
return ReturnType.SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
Kit kit = instance.getKitManager().getKit(args[0]);
|
Kit kit = plugin.getKitManager().getKit(args[0]);
|
||||||
if (kit == null && !args[0].toLowerCase().equals("all")) {
|
if (kit == null && !args[0].toLowerCase().equals("all")) {
|
||||||
instance.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(sender);
|
plugin.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
Player playerTo = null;
|
Player playerTo = null;
|
||||||
if (!args[2].trim().equalsIgnoreCase("all") && (playerTo = Bukkit.getPlayer(args[2])) == null) {
|
if (!args[2].trim().equalsIgnoreCase("all") && (playerTo = Bukkit.getPlayer(args[2])) == null) {
|
||||||
instance.getLocale().newMessage("&cThat username does not exist, or the user is offline!").sendPrefixedMessage(sender);
|
plugin.getLocale().newMessage("&cThat username does not exist, or the user is offline!").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
int amt = 1;
|
int amt = 1;
|
||||||
@ -46,27 +47,27 @@ public class CommandKey extends AbstractCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (amt == 0) {
|
if (amt == 0) {
|
||||||
instance.getLocale().newMessage("&a" + args[3] + " &cis not a number.").sendPrefixedMessage(sender);
|
plugin.getLocale().newMessage("&a" + args[3] + " &cis not a number.").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Key key = instance.getKeyManager().getKey(args[1]);
|
Key key = plugin.getKeyManager().getKey(args[1]);
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
instance.getLocale().newMessage("&a" + args[1] + " &cis not a key.").sendPrefixedMessage(sender);
|
plugin.getLocale().newMessage("&a" + args[1] + " &cis not a key.").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (playerTo != null) {
|
if (playerTo != null) {
|
||||||
PlayerUtils.giveItem(playerTo, key.getKeyItem(kit, amt));
|
PlayerUtils.giveItem(playerTo, key.getKeyItem(kit, amt));
|
||||||
instance.getLocale().getMessage("event.key.given")
|
plugin.getLocale().getMessage("event.key.given")
|
||||||
.processPlaceholder("kit", kit == null ? "Any" : kit.getName())
|
.processPlaceholder("kit", kit == null ? "Any" : kit.getName())
|
||||||
.sendPrefixedMessage(playerTo);
|
.sendPrefixedMessage(playerTo);
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
for (Player pl : instance.getServer().getOnlinePlayers()) {
|
for (Player pl : plugin.getServer().getOnlinePlayers()) {
|
||||||
PlayerUtils.giveItem(pl, key.getKeyItem(kit, amt));
|
PlayerUtils.giveItem(pl, key.getKeyItem(kit, amt));
|
||||||
instance.getLocale().getMessage("event.key.given")
|
plugin.getLocale().getMessage("event.key.given")
|
||||||
.processPlaceholder("kit", kit == null ? "Any" : kit.getName())
|
.processPlaceholder("kit", kit == null ? "Any" : kit.getName())
|
||||||
.sendPrefixedMessage(pl);
|
.sendPrefixedMessage(pl);
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,12 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandKit extends AbstractCommand {
|
public class CommandKit extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits instance = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
final GuiManager guiManager;
|
private final GuiManager guiManager;
|
||||||
|
|
||||||
public CommandKit(GuiManager guiManager) {
|
public CommandKit(UltimateKits plugin, GuiManager guiManager) {
|
||||||
super(false, "kit");
|
super(CommandType.PLAYER_ONLY, "kit");
|
||||||
|
this.plugin = plugin;
|
||||||
this.guiManager = guiManager;
|
this.guiManager = guiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,19 +30,19 @@ public class CommandKit extends AbstractCommand {
|
|||||||
|
|
||||||
if (args.length == 0 && sender instanceof Player) {
|
if (args.length == 0 && sender instanceof Player) {
|
||||||
// /kit - Opens GUI.
|
// /kit - Opens GUI.
|
||||||
if (instance.getKitManager().getKits().stream().anyMatch(kit -> kit.getCategory() != null))
|
if (plugin.getKitManager().getKits().stream().anyMatch(kit -> kit.getCategory() != null))
|
||||||
guiManager.showGUI((Player) sender, new CategorySelectorGui(instance, (Player) sender));
|
guiManager.showGUI((Player) sender, new CategorySelectorGui(plugin, (Player) sender));
|
||||||
else
|
else
|
||||||
guiManager.showGUI((Player) sender, new KitSelectorGui(instance, (Player) sender, null));
|
guiManager.showGUI((Player) sender, new KitSelectorGui(plugin, (Player) sender, null));
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance.getKitManager().getKit(args[0]) == null) {
|
if (plugin.getKitManager().getKit(args[0]) == null) {
|
||||||
instance.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(sender);
|
plugin.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Kit kit = instance.getKitManager().getKit(args[0]);
|
Kit kit = plugin.getKitManager().getKit(args[0]);
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
// /kit <kit> - Gives kit to self.
|
// /kit <kit> - Gives kit to self.
|
||||||
@ -49,7 +50,7 @@ public class CommandKit extends AbstractCommand {
|
|||||||
return ReturnType.NEEDS_PLAYER;
|
return ReturnType.NEEDS_PLAYER;
|
||||||
|
|
||||||
if (!kit.hasPermissionToClaim((Player) sender)) {
|
if (!kit.hasPermissionToClaim((Player) sender)) {
|
||||||
instance.getLocale().getMessage("command.general.noperms").sendPrefixedMessage(sender);
|
plugin.getLocale().getMessage("command.general.noperms").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,12 +60,12 @@ public class CommandKit extends AbstractCommand {
|
|||||||
// /kit <kit> <player> - Gives kit to another player.
|
// /kit <kit> <player> - Gives kit to another player.
|
||||||
|
|
||||||
if (!sender.hasPermission("ultimatekits.admin")) {
|
if (!sender.hasPermission("ultimatekits.admin")) {
|
||||||
instance.getLocale().getMessage("command.general.noperms").sendPrefixedMessage(sender);
|
plugin.getLocale().getMessage("command.general.noperms").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args[1].equalsIgnoreCase("all") && Bukkit.getPlayer(args[1]) == null) {
|
if (!args[1].equalsIgnoreCase("all") && Bukkit.getPlayer(args[1]) == null) {
|
||||||
instance.getLocale().newMessage("&cThat username does not exist, or the user is offline!").sendPrefixedMessage(sender);
|
plugin.getLocale().newMessage("&cThat username does not exist, or the user is offline!").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,19 +74,19 @@ public class CommandKit extends AbstractCommand {
|
|||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
kit.processGenericUse(player, true);
|
kit.processGenericUse(player, true);
|
||||||
instance.getLocale().getMessage("event.claim.givesuccess")
|
plugin.getLocale().getMessage("event.claim.givesuccess")
|
||||||
.processPlaceholder("kit", kit.getName())
|
.processPlaceholder("kit", kit.getName())
|
||||||
.sendPrefixedMessage(sender);
|
.sendPrefixedMessage(sender);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getOnlinePlayers().forEach(onlinePlayer -> {
|
Bukkit.getOnlinePlayers().forEach(onlinePlayer -> {
|
||||||
kit.processGenericUse(onlinePlayer, true);
|
kit.processGenericUse(onlinePlayer, true);
|
||||||
instance.getLocale().getMessage("event.claim.givesuccess")
|
plugin.getLocale().getMessage("event.claim.givesuccess")
|
||||||
.processPlaceholder("kit", kit.getName())
|
.processPlaceholder("kit", kit.getName())
|
||||||
.sendPrefixedMessage(sender);
|
.sendPrefixedMessage(sender);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.getLocale().newMessage("&7You gave &9" + who + "&7 kit &9" + kit.getName() + "&7.")
|
plugin.getLocale().newMessage("&7You gave &9" + who + "&7 kit &9" + kit.getName() + "&7.")
|
||||||
.sendPrefixedMessage(sender);
|
.sendPrefixedMessage(sender);
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
@ -100,7 +101,7 @@ public class CommandKit extends AbstractCommand {
|
|||||||
if (!(sender instanceof Player)) return tab;
|
if (!(sender instanceof Player)) return tab;
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
for (Kit kit : instance.getKitManager().getKits()) tab.add(kit.getKey());
|
for (Kit kit : plugin.getKitManager().getKits()) tab.add(kit.getKey());
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
tab.add("all");
|
tab.add("all");
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> tab.add(player.getName()));
|
Bukkit.getOnlinePlayers().forEach(player -> tab.add(player.getName()));
|
||||||
|
@ -12,11 +12,12 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandPreviewKit extends AbstractCommand {
|
public class CommandPreviewKit extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits instance = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
final GuiManager guiManager;
|
private final GuiManager guiManager;
|
||||||
|
|
||||||
public CommandPreviewKit(GuiManager guiManager) {
|
public CommandPreviewKit(UltimateKits plugin, GuiManager guiManager) {
|
||||||
super(true, "PreviewKit");
|
super(CommandType.PLAYER_ONLY, "PreviewKit");
|
||||||
|
this.plugin = plugin;
|
||||||
this.guiManager = guiManager;
|
this.guiManager = guiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,12 +25,12 @@ public class CommandPreviewKit extends AbstractCommand {
|
|||||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
instance.getLocale().getMessage("command.kit.nokitsupplied").sendPrefixedMessage(player);
|
plugin.getLocale().getMessage("command.kit.nokitsupplied").sendPrefixedMessage(player);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
Kit kit = instance.getKitManager().getKit(args[0].toLowerCase().trim());
|
Kit kit = plugin.getKitManager().getKit(args[0].toLowerCase().trim());
|
||||||
if (kit == null) {
|
if (kit == null) {
|
||||||
instance.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(player);
|
plugin.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(player);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
kit.display(player, guiManager, null);
|
kit.display(player, guiManager, null);
|
||||||
|
@ -9,16 +9,17 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandReload extends AbstractCommand {
|
public class CommandReload extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits instance = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
|
|
||||||
public CommandReload() {
|
public CommandReload(UltimateKits plugin) {
|
||||||
super(false, "reload");
|
super(CommandType.CONSOLE_OK, "reload");
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||||
instance.reloadConfig();
|
plugin.reloadConfig();
|
||||||
instance.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
plugin.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,26 +13,27 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandRemove extends AbstractCommand {
|
public class CommandRemove extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits instance = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
|
|
||||||
public CommandRemove() {
|
public CommandRemove(UltimateKits plugin) {
|
||||||
super(true, "remove");
|
super(CommandType.PLAYER_ONLY, "remove");
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Block block = player.getTargetBlock(null, 200);
|
Block block = player.getTargetBlock(null, 200);
|
||||||
Kit kit = instance.getKitManager().removeKitFromLocation(block.getLocation());
|
Kit kit = plugin.getKitManager().removeKitFromLocation(block.getLocation());
|
||||||
if (kit == null) return ReturnType.FAILURE;
|
if (kit == null) return ReturnType.FAILURE;
|
||||||
|
|
||||||
if (HologramManager.isEnabled()) {
|
if (HologramManager.isEnabled()) {
|
||||||
instance.getKitManager().getKitLocations().values().stream()
|
plugin.getKitManager().getKitLocations().values().stream()
|
||||||
.filter(data -> data.getKit() == kit)
|
.filter(data -> data.getKit() == kit)
|
||||||
.forEach(data -> instance.removeHologram(data));
|
.forEach(data -> plugin.removeHologram(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.getLocale().newMessage("&8Kit &9" + kit.getKey() + " &8unassigned from: &a" + block.getType().toString() + "&8.").sendPrefixedMessage(player);
|
plugin.getLocale().newMessage("&8Kit &9" + kit.getKey() + " &8unassigned from: &a" + block.getType().toString() + "&8.").sendPrefixedMessage(player);
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,28 +13,29 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandSet extends AbstractCommand {
|
public class CommandSet extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits instance = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
|
|
||||||
public CommandSet() {
|
public CommandSet(UltimateKits plugin) {
|
||||||
super(true, "set");
|
super(CommandType.PLAYER_ONLY, "set");
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
instance.getLocale().getMessage("command.kit.nokitsupplied").sendPrefixedMessage(sender);
|
plugin.getLocale().getMessage("command.kit.nokitsupplied").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Kit kit = instance.getKitManager().getKit(args[0].toLowerCase());
|
Kit kit = plugin.getKitManager().getKit(args[0].toLowerCase());
|
||||||
if (kit == null) {
|
if (kit == null) {
|
||||||
instance.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(sender);
|
plugin.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
Block b = player.getTargetBlock(null, 200);
|
Block b = player.getTargetBlock(null, 200);
|
||||||
KitBlockData data = instance.getKitManager().addKitToLocation(kit, b.getLocation());
|
KitBlockData data = plugin.getKitManager().addKitToLocation(kit, b.getLocation());
|
||||||
UltimateKits.getInstance().getDataManager().createBlockData(data);
|
UltimateKits.getInstance().getDataManager().createBlockData(data);
|
||||||
instance.getLocale().newMessage("&8Kit &a" + kit.getKey() + " &8set to: &a" + b.getType().toString() + "&8.")
|
plugin.getLocale().newMessage("&8Kit &a" + kit.getKey() + " &8set to: &a" + b.getType().toString() + "&8.")
|
||||||
.sendPrefixedMessage(sender);
|
.sendPrefixedMessage(sender);
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
|
|
||||||
|
@ -12,17 +12,18 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandSettings extends AbstractCommand {
|
public class CommandSettings extends AbstractCommand {
|
||||||
|
|
||||||
final UltimateKits instance = UltimateKits.getInstance();
|
private final UltimateKits plugin;
|
||||||
final GuiManager guiManager;
|
private final GuiManager guiManager;
|
||||||
|
|
||||||
public CommandSettings(GuiManager guiManager) {
|
public CommandSettings(UltimateKits plugin, GuiManager guiManager) {
|
||||||
super(true, "settings");
|
super(CommandType.PLAYER_ONLY, "settings");
|
||||||
|
this.plugin = plugin;
|
||||||
this.guiManager = guiManager;
|
this.guiManager = guiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||||
guiManager.showGUI((Player) sender, new PluginConfigGui(instance));
|
guiManager.showGUI((Player) sender, new PluginConfigGui(plugin));
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user