From 303cd6b63af8c9273f304619e4d2911d228f59fa Mon Sep 17 00:00:00 2001 From: Steffion Date: Tue, 30 Jul 2013 14:30:37 +0200 Subject: [PATCH] Redoing stuff. --- src/nl/Steffion/BlockHunt/BlockHunt.java | 6 +- .../Steffion/BlockHunt/Commands/CMDlist.java | 65 --------- .../BlockHunt/Commands/CMDpreview.java | 73 ---------- .../BlockHunt/Listeners/PlayerListener.java | 128 ++++-------------- .../Steffion/BlockHunt/Managers/CommandC.java | 16 --- .../Steffion/BlockHunt/Managers/ConfigC.java | 12 -- src/nl/Steffion/BlockHunt/W.java | 3 - src/plugin.yml | 1 + 8 files changed, 34 insertions(+), 270 deletions(-) delete mode 100644 src/nl/Steffion/BlockHunt/Commands/CMDlist.java delete mode 100644 src/nl/Steffion/BlockHunt/Commands/CMDpreview.java diff --git a/src/nl/Steffion/BlockHunt/BlockHunt.java b/src/nl/Steffion/BlockHunt/BlockHunt.java index f969840..ea4b1da 100644 --- a/src/nl/Steffion/BlockHunt/BlockHunt.java +++ b/src/nl/Steffion/BlockHunt/BlockHunt.java @@ -1,6 +1,5 @@ package nl.Steffion.BlockHunt; -import nl.Steffion.BlockHunt.Listeners.PlayerListener; import nl.Steffion.BlockHunt.Managers.CommandC; import nl.Steffion.BlockHunt.Managers.ConfigC; import nl.Steffion.BlockHunt.Managers.MessageM; @@ -19,8 +18,9 @@ public class BlockHunt extends JavaPlugin implements Listener { public void onEnable() { W.newFiles(); getServer().getPluginManager().registerEvents(this, this); - getServer().getPluginManager().registerEvents(new PlayerListener(this), - this); + // getServer().getPluginManager().registerEvents(new + // PlayerListener(this), + // this); MessageM.sendFMessage(null, ConfigC.log_Enabled, true, "name-" + W.pluginName, "version-" + W.pluginVersion, "autors-" + W.pluginAutors); diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDlist.java b/src/nl/Steffion/BlockHunt/Commands/CMDlist.java deleted file mode 100644 index 7e13380..0000000 --- a/src/nl/Steffion/BlockHunt/Commands/CMDlist.java +++ /dev/null @@ -1,65 +0,0 @@ -package nl.Steffion.BlockHunt.Commands; - -import java.io.File; -import java.util.ArrayList; - -import nl.Steffion.BlockHunt.W; -import nl.Steffion.BlockHunt.Managers.ConfigC; -import nl.Steffion.BlockHunt.Managers.MessageM; -import nl.Steffion.BlockHunt.Managers.PlayerM; -import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC; - -import org.bukkit.command.Command; -import org.bukkit.entity.Player; - -public class CMDlist extends DefaultCMD { - - @Override - public boolean exectue(Player player, Command cmd, String label, - String[] args) { - if (PlayerM.hasPerm(player, PermsC.list, true)) { - MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false, - "header-" + W.pluginName); - File arenaworldFolder = new File("plugins/" + W.pluginName - + "/defaultArenas/"); - ArrayList arenas = new ArrayList(); - for (String file : arenaworldFolder.list()) { - File arenaCheck = new File(arenaworldFolder, file); - if (arenaCheck.isDirectory()) { - arenas.add(arenaCheck.getName()); - } - } - if (arenas.size() >= 1) { - for (String arena : arenas) { - MessageM.sendMessage(player, "%A" + arena, false); - } - } else { - MessageM.sendMessage(player, "&7&oNo arenas available...", - false); - MessageM.sendMessage(player, "&7&oAdd arenas in the '" - + W.pluginName + "/defaultArenas/' folder.", false); - } - MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false, - "header-&oArenas list"); - } - return true; - } - - public static boolean isAnArena(String worldname) { - File arenaworldFolder = new File("plugins/" + W.pluginName - + "/defaultArenas/"); - - ArrayList arenas = new ArrayList(); - for (String file : arenaworldFolder.list()) { - File arenaCheck = new File(arenaworldFolder, file); - if (arenaCheck.isDirectory()) { - arenas.add(arenaCheck.getName()); - } - } - - if (arenas.contains(worldname)) { - return true; - } - return false; - } -} diff --git a/src/nl/Steffion/BlockHunt/Commands/CMDpreview.java b/src/nl/Steffion/BlockHunt/Commands/CMDpreview.java deleted file mode 100644 index 34d4193..0000000 --- a/src/nl/Steffion/BlockHunt/Commands/CMDpreview.java +++ /dev/null @@ -1,73 +0,0 @@ -package nl.Steffion.BlockHunt.Commands; - -import java.io.File; -import java.io.IOException; - -import nl.Steffion.BlockHunt.W; -import nl.Steffion.BlockHunt.Managers.CommandC; -import nl.Steffion.BlockHunt.Managers.ConfigC; -import nl.Steffion.BlockHunt.Managers.FileM; -import nl.Steffion.BlockHunt.Managers.MessageM; -import nl.Steffion.BlockHunt.Managers.PlayerM; -import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC; - -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.WorldCreator; -import org.bukkit.command.Command; -import org.bukkit.entity.Player; - -public class CMDpreview extends DefaultCMD { - - @Override - public boolean exectue(Player player, Command cmd, String label, - String[] args) { - if (PlayerM.hasPerm(player, PermsC.preview, true)) { - if (args.length == 1) { - MessageM.sendFMessage(player, ConfigC.error_notEnoughArguments, - true, "syntax-" + CommandC.PREVIEW.usage); - } else { - File arenaworldFolder = new File("plugins/" + W.pluginName - + "/defaultArenas/" + args[1]); - if (!arenaworldFolder.exists()) { - MessageM.sendFMessage(player, ConfigC.error_noArena, true, - "name-" + args[1]); - return true; - } - - boolean notFound = true; - int subID = 1; - while (notFound) { - File destFolder = new File("plugins/" + W.pluginName - + "/loadedArenas/" + args[1] + "_" + subID); - if (!destFolder.exists()) { - MessageM.sendFMessage(player, - ConfigC.normal_previewWorld, true); - try { - FileM.copyFolder(arenaworldFolder, destFolder); - W.previewWorlds.add(destFolder.getPath()); - MessageM.broadcastMessage(destFolder.getPath(), - false); - } catch (IOException e) { - e.printStackTrace(); - } - - WorldCreator wc = new WorldCreator(destFolder.getPath()); - Bukkit.getServer().createWorld(wc); - - World world = Bukkit.getWorld(destFolder.getPath()); - player.teleport(world.getSpawnLocation()); - - notFound = false; - - MessageM.sendFMessage(player, - ConfigC.normal_previewWorldDone, true); - } else { - subID = subID + 1; - } - } - } - } - return true; - } -} diff --git a/src/nl/Steffion/BlockHunt/Listeners/PlayerListener.java b/src/nl/Steffion/BlockHunt/Listeners/PlayerListener.java index 434af1d..581a4fa 100644 --- a/src/nl/Steffion/BlockHunt/Listeners/PlayerListener.java +++ b/src/nl/Steffion/BlockHunt/Listeners/PlayerListener.java @@ -1,106 +1,38 @@ package nl.Steffion.BlockHunt.Listeners; -import java.io.File; -import java.io.IOException; - -import nl.Steffion.BlockHunt.BlockHunt; -import nl.Steffion.BlockHunt.W; -import nl.Steffion.BlockHunt.Managers.ConfigC; -import nl.Steffion.BlockHunt.Managers.FileM; -import nl.Steffion.BlockHunt.Managers.MessageM; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerTeleportEvent; public class PlayerListener implements Listener { - private BlockHunt plugin; + // private BlockHunt plugin; + // + // public PlayerListener (BlockHunt plugin) { + // this.plugin = plugin; + // } - public PlayerListener (BlockHunt plugin) { - this.plugin = plugin; - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void onPlayerTeleportEvent(final PlayerTeleportEvent event) { - final Player player = event.getPlayer(); - if (W.previewWorlds.contains(event.getFrom().getWorld().getName())) { - if (!event.getFrom().getWorld().getName() - .equals(event.getTo().getWorld().getName())) { - final String worldLoc = event.getFrom().getWorld().getName(); - boolean unload = true; - - for (Player pl : Bukkit.getOnlinePlayers()) { - if (pl.getLocation().getWorld().getName().equals(worldLoc)) { - if (!pl.equals(player)) { - unload = false; - } - } - } - - if (unload) { - Bukkit.getScheduler().runTaskLaterAsynchronously( - this.plugin, new Runnable() { - @Override - public void run() { - Bukkit.unloadWorld( - Bukkit.getWorld(worldLoc), true); - MessageM.sendFMessage( - player, - ConfigC.normal_previewWorldUnloaded, - true); - } - }, 20); - - Bukkit.getScheduler().runTaskLaterAsynchronously( - this.plugin, new Runnable() { - @Override - public void run() { - try { - String[] worldPlace = event.getFrom() - .getWorld().getName() - .split("/"); - String[] worldName = worldPlace[worldPlace.length - 1] - .split("_"); - File destFolder = new File("plugins/" - + W.pluginName - + "/defaultArenas/" - + worldName[0]); - if (destFolder.exists()) { - FileM.delete(destFolder); - } - - FileM.copyFolder(new File(worldLoc), - destFolder); - } catch (IOException e) { - e.printStackTrace(); - } - } - }, 40); - - Bukkit.getScheduler().runTaskLaterAsynchronously( - this.plugin, new Runnable() { - @Override - public void run() { - try { - FileM.delete(new File(worldLoc)); - } catch (IOException e) { - e.printStackTrace(); - } - - MessageM.sendFMessage(player, - ConfigC.normal_previewWorldDeleted, - true); - } - - }, 60); - W.previewWorlds - .remove(event.getFrom().getWorld().getName()); - } - } - } - } + // @EventHandler(priority = EventPriority.MONITOR) + // public void onPlayerTeleportEvent(final PlayerTeleportEvent event) { + // final Player player = event.getPlayer(); + // if (W.previewWorlds.contains(event.getFrom().getWorld().getName())) { + // if (!event.getFrom().getWorld().getName() + // .equals(event.getTo().getWorld().getName())) { + // final String worldLoc = event.getFrom().getWorld().getName(); + // boolean unload = true; + // + // for (Player pl : Bukkit.getOnlinePlayers()) { + // if (pl.getLocation().getWorld().getName().equals(worldLoc)) { + // if (!pl.equals(player)) { + // unload = false; + // } + // } + // } + // + // if (unload) { + // ArenaHandler ah = new ArenaHandler(this.plugin); + // ah.unLoadArena(worldLoc, player); + // W.previewWorlds.remove(worldLoc); + // } + // } + // } + // } } diff --git a/src/nl/Steffion/BlockHunt/Managers/CommandC.java b/src/nl/Steffion/BlockHunt/Managers/CommandC.java index aadea83..7d44a5b 100644 --- a/src/nl/Steffion/BlockHunt/Managers/CommandC.java +++ b/src/nl/Steffion/BlockHunt/Managers/CommandC.java @@ -42,22 +42,6 @@ public enum CommandC { ConfigC.help_reload, 1, W.pluginName + " "), - LIST ("BlockHunt%list_", - "BlockHunt%l_", - new CMDlist(), - ConfigC.commandEnabled_list, - PermsC.list, - ConfigC.help_list, - 1, - W.pluginName + " "), - PREVIEW ("BlockHunt%preview_", - "BlockHunt%p_", - new CMDpreview(), - ConfigC.commandEnabled_preview, - PermsC.preview, - ConfigC.help_preview, - 1, - W.pluginName + " "), NOT_FOUND ("%_", "%_", new CMDnotfound(), diff --git a/src/nl/Steffion/BlockHunt/Managers/ConfigC.java b/src/nl/Steffion/BlockHunt/Managers/ConfigC.java index 9a291f1..6858e31 100644 --- a/src/nl/Steffion/BlockHunt/Managers/ConfigC.java +++ b/src/nl/Steffion/BlockHunt/Managers/ConfigC.java @@ -18,8 +18,6 @@ public enum ConfigC { commandEnabled_info (true, W.config), commandEnabled_help (true, W.config), commandEnabled_reload (true, W.config), - commandEnabled_list (true, W.config), - commandEnabled_preview (true, W.config), log_Enabled ("%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.", W.messages), @@ -29,18 +27,8 @@ public enum ConfigC { help_info ("%NDisplays the plugin's info.", W.messages), help_help ("%NShows a list of commands.", W.messages), help_reload ("%NReloads all configs.", W.messages), - help_list ("%NDisplays a list of available arenas.", W.messages), - help_preview ("%NMakes a copy of an arena to make changes in your arena.", - W.messages), normal_reloadedConfigs ("&aReloaded all configs!", W.messages), - normal_previewWorld ("%NMaking a preview world for you...", W.messages), - normal_previewWorldDone ("%NYour preview world has been created! Sending you...", - W.messages), - normal_previewWorldUnloaded ("%NYour preview world has been %Eunloaded%N!", - W.messages), - normal_previewWorldDeleted ("%NYour preview world has been %Edeleted%N!", - W.messages), error_noPermission ("%EYou don't have the permissions to do that!", W.messages), diff --git a/src/nl/Steffion/BlockHunt/W.java b/src/nl/Steffion/BlockHunt/W.java index a5f18ed..fac9d2b 100644 --- a/src/nl/Steffion/BlockHunt/W.java +++ b/src/nl/Steffion/BlockHunt/W.java @@ -17,11 +17,8 @@ public class W { public static String pluginMainPermission = pluginName + "."; public static ArrayList newFiles = new ArrayList(); - public static ArrayList previewWorlds = new ArrayList(); public static ConfigM config = new ConfigM("config", ""); public static ConfigM messages = new ConfigM("messages", ""); - public static ConfigM note1 = new ConfigM("PLACE WORLD FOLDERS HERE!", - "defaultArenas/"); public static void newFiles() { ConfigM.setDefaults(); diff --git a/src/plugin.yml b/src/plugin.yml index 703b640..d3ccedc 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -4,6 +4,7 @@ version: 1.0.0 authors: - Steffion description: Description here. +softdepend: [DisguiseCraft, Multiverse-Core] commands: BlockHunt: usage: /