Pārlūkot izejas kodu

reorganized commands, add new inspect command

Added a help page that explains every command.

Added a new command /customoregen inspect <player> that allows server
owners to show information about current generator specs of a player
MasterCake 4 gadi atpakaļ
vecāks
revīzija
941e09901f

+ 47 - 8
src/xyz/spaceio/customoregen/Cmd.java

@@ -2,9 +2,11 @@ package xyz.spaceio.customoregen;
 
 import java.io.IOException;
 
+import org.bukkit.Bukkit;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandExecutor;
 import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
 
 public class Cmd implements CommandExecutor {
 	CustomOreGen plugin;
@@ -13,19 +15,56 @@ public class Cmd implements CommandExecutor {
 		this.plugin = main;
 	}
 
-	public boolean onCommand(CommandSender cs, Command arg1, String arg2, String[] arg3) {
+	public boolean onCommand(CommandSender cs, Command arg1, String arg2, String[] args) {
 		if (!cs.hasPermission("customoregen.admin")) {
 			cs.sendMessage("You dont have permissions.");
+			return true;
 		} else {
-			try {
-				this.plugin.reload();
-			} catch (IOException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+			if(args.length > 0) {
+				switch(args[0].toLowerCase()) {
+					case "reload":
+						try {
+							this.plugin.reload();
+							cs.sendMessage("§aConfig reloaded!");
+						} catch (IOException e) {
+							// TODO Auto-generated catch block
+							e.printStackTrace();
+						}
+						return true;
+					case "inspect":
+						String playerName = args.length > 1 ? args[1] : cs.getName();
+						
+						Player player = Bukkit.getPlayer(playerName);
+						if (player == null) {
+							cs.sendMessage("§cInvalid player");
+							return true;
+						}
+						
+						cs.sendMessage(String.format("§c====== INFO %s =======", player.getName()));
+						cs.sendMessage("§2Skyblock Plugin: §a" + plugin.getHookName());
+						cs.sendMessage("§2Island level: §a" + plugin.getLevel(player.getUniqueId(), player.getWorld().getName()));
+						cs.sendMessage("§2Island owner: §a" + plugin.getOwner(player.getLocation()).getName());
+						
+						GeneratorConfig gc = plugin.getGeneratorConfigForPlayer(player, player.getWorld().getName());
+						cs.sendMessage("§3Applied Generator name: §a" + gc.label);
+						cs.sendMessage("§3Generator permission: §a" + gc.permission);
+						cs.sendMessage("§3Generator unlock level: §a" + gc.unlock_islandLevel);
+						
+						return true;
+						
+					default:
+						showHelp(cs);
+						return true;
+				}
+			}else {
+				showHelp(cs);
+				return true;
 			}
-			cs.sendMessage("§aConfig reloaded!");
 		}
 		
-		return true;
+	}
+	private void showHelp(CommandSender cs) {
+		cs.sendMessage("§a/customoregen reload §2-Reloads the config.yml");
+		cs.sendMessage("§a/customoregen inspect <player> §2-Returns information about the applied generator");
 	}
 }

+ 20 - 2
src/xyz/spaceio/customoregen/CustomOreGen.java

@@ -72,6 +72,11 @@ public class CustomOreGen extends JavaPlugin {
 	 * Prefix for the clogger
 	 */
 	private final String PREFIX = "§6[CustomOreGen] ";
+	
+	/*
+	 * Main event class
+	 */
+	private Events events;
 
 
 	@Override
@@ -79,8 +84,6 @@ public class CustomOreGen extends JavaPlugin {
 		clogger = getServer().getConsoleSender();
 		
 		PluginManager pm = Bukkit.getPluginManager();
-		
-		pm.registerEvents(new Events(this), this);
 
 		this.loadHook();
 
@@ -93,6 +96,10 @@ public class CustomOreGen extends JavaPlugin {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
+		
+		events = new Events(this);
+		
+		pm.registerEvents(events, this);
 
 		// some persisting saving stuff
 		
@@ -197,10 +204,21 @@ public class CustomOreGen extends JavaPlugin {
 
 		return p;
 	}
+	
+	/**
+	 * Gets the skyblock hook name in use
+	 * 
+	 * @return The name of the hook class
+	 */
+	public String getHookName() {
+		return this.skyblockAPI.getClass().getName();
+	}
 
 	public void reload() throws IOException {
 		reloadConfig();
 		configHandler.loadConfig();
+		
+		events.load();
 	}
 
 	/**