diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java index 3cbecb2..02efc3f 100644 --- a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/ChestsPlusPlus.java @@ -3,6 +3,7 @@ package com.jamesdpeters.minecraft.chests; import com.jamesdpeters.minecraft.chests.api_interfaces.ApiSpecific; import com.jamesdpeters.minecraft.chests.commands.AutoCraftCommand; import com.jamesdpeters.minecraft.chests.commands.ChestLinkCommand; +import com.jamesdpeters.minecraft.chests.commands.ChestsPlusPlusCommand; import com.jamesdpeters.minecraft.chests.crafting.Crafting; import com.jamesdpeters.minecraft.chests.listeners.StorageListener; import com.jamesdpeters.minecraft.chests.listeners.HopperListener; @@ -43,7 +44,8 @@ import org.bukkit.plugin.java.annotation.plugin.author.Author; @Author(value = "jameslfc19") @Commands({ @Command(name = "chestlink", desc = "Chests++ ChestLink Commands.", aliases = {"cl"}, usage = "Use /chestlink help for more info."), - @Command(name = "autocraft", desc = "Chests++ AutoCraft Commands.", aliases = {"ac"}, usage = "Use /autocraft help for more info.")}) + @Command(name = "autocraft", desc = "Chests++ AutoCraft Commands.", aliases = {"ac"}, usage = "Use /autocraft help for more info."), + @Command(name = "chests++", desc = "Chests++ Commands.", aliases = {"c++"}, usage = "/chests++ version")}) @Permission(name = Permissions.ADD, desc = "Gives permission to add ChestLinks!", defaultValue = PermissionDefault.TRUE) @Permission(name = Permissions.OPEN, desc = "Gives permission to open ChestLinks!", defaultValue = PermissionDefault.TRUE) @Permission(name = Permissions.MENU, desc = "Gives permission to open the ChestLink menu!", defaultValue = PermissionDefault.TRUE) @@ -88,13 +90,18 @@ public class ChestsPlusPlus extends JavaPlugin { //Remove entities that could have been left behind from bad save files/crashes etc. Utils.removeEntities(); + //Register commands new ChestLinkCommand().register(this); new AutoCraftCommand().register(this); + new ChestsPlusPlusCommand().register(this); + + //Register event listeners getServer().getPluginManager().registerEvents(new StorageListener(),this); getServer().getPluginManager().registerEvents(new InventoryListener(),this); getServer().getPluginManager().registerEvents(new HopperListener(),this); getServer().getPluginManager().registerEvents(new WorldListener(),this); + //Load storage SpigotConfig.load(this); new Config(); diff --git a/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/commands/ChestsPlusPlusCommand.java b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/commands/ChestsPlusPlusCommand.java new file mode 100644 index 0000000..7aa7a66 --- /dev/null +++ b/ChestsPlusPlus_Main/src/main/java/com/jamesdpeters/minecraft/chests/commands/ChestsPlusPlusCommand.java @@ -0,0 +1,102 @@ +package com.jamesdpeters.minecraft.chests.commands; + +import com.jamesdpeters.minecraft.chests.ChestsPlusPlus; +import com.jamesdpeters.minecraft.chests.api_interfaces.ApiSpecific; +import com.jamesdpeters.minecraft.chests.inventories.ChestLinkMenu; +import com.jamesdpeters.minecraft.chests.maventemplates.BuildConstants; +import com.jamesdpeters.minecraft.chests.misc.Messages; +import com.jamesdpeters.minecraft.chests.misc.Permissions; +import com.jamesdpeters.minecraft.chests.misc.Utils; +import com.jamesdpeters.minecraft.chests.serialize.Config; +import com.jamesdpeters.minecraft.chests.sort.SortMethod; +import com.jamesdpeters.minecraft.chests.storage.chestlink.ChestLinkStorage; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.block.Block; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class ChestsPlusPlusCommand extends ServerCommand { + + private enum OPTIONS { + VERSION("/chestsplusplus version", "Display the current version of the plugin."); + + String description, commandHelp; + static List valuesList; + + static { + valuesList = Stream.of(OPTIONS.values()).map(OPTIONS::toString).collect(Collectors.toList()); + } + + OPTIONS( String commandHelp, String description){ + this.commandHelp = commandHelp; + this.description = description; + } + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + + } + + @Override + public String getCommandName() { + return "chests++"; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if(args != null && args.length > 0) { + switch (OPTIONS.valueOf(args[0].toUpperCase())){ + case VERSION: + sender.sendMessage("ChestsPlusPlus Version: "+ BuildConstants.VERSION); + sender.sendMessage("Server Version: "+ Bukkit.getVersion()); + sender.sendMessage("CraftBukkit Version: "+ Bukkit.getBukkitVersion()); + sender.sendMessage("Detected API Version: "+ ApiSpecific.getApiVersion()); + return true; + + default: + for(ChestsPlusPlusCommand.OPTIONS option : ChestsPlusPlusCommand.OPTIONS.values()){ + sender.sendMessage(ChatColor.RED + option.commandHelp); + sender.sendMessage(ChatColor.WHITE + option.description); + } + } + } + + return false; + } + + @Override + public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { + if((sender instanceof Player)) { + if (args.length == 1) { + return OPTIONS.valuesList; + } + if(args.length == 2) { + try { + switch (OPTIONS.valueOf(args[0].toUpperCase())) { + + } + } catch (IllegalArgumentException ignored) { } + } + if(args.length == 3) { + try { + + } catch (IllegalArgumentException ignored) { } + } + if(args.length == 4) { + try { + + } catch (IllegalArgumentException ignored) { } + } + } + return null; + } +}