From 9d2cc9a8394790fd2b5156f54dd14c56db22c8ec Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Wed, 3 Aug 2011 18:15:21 -0600 Subject: [PATCH] Fix license, Update CH, Fix mvdelete --- README.md | 2 +- lib/commandhandler | 2 +- .../MultiverseCore/MultiverseCore.java | 63 ++++++++++++++++--- .../commands/DeleteCommand.java | 5 +- 4 files changed, 59 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 74f37f16..6b7ee345 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Copyright (c) 2011, The Multiverse Team All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the FernFerret Studios nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/lib/commandhandler b/lib/commandhandler index 882ba77a..647f75cc 160000 --- a/lib/commandhandler +++ b/lib/commandhandler @@ -1 +1 @@ -Subproject commit 882ba77aa122413ebaeb70df96afe10e2845f76f +Subproject commit 647f75ccbb8a754af8bfae4c7f1fac0c9e98f68e diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index d8565e33..c330c06e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -254,11 +254,11 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { this.commandHandler.registerCommand(new ModifySetCommand(this)); this.commandHandler.registerCommand(new ModifyRemoveCommand(this)); this.commandHandler.registerCommand(new ModifyClearCommand(this)); - + // Misc Commands this.commandHandler.registerCommand(new EnvironmentCommand(this)); this.commandHandler.registerCommand(new SleepCommand(this)); - + } /** @@ -424,6 +424,11 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { this.log(Level.INFO, "World " + name + " was unloaded from memory."); this.unloadWorld(name, true); return true; + } else if(this.getServer().getWorld(name) != null) { + this.log(Level.WARNING, "Hmm Multiverse does not know about this world but it's still loaded in memory."); + this.log(Level.WARNING, "To be on the safe side, you should import it then try unloading again..."); + } else { + this.log(Level.INFO, "The world " + name + " was already unloaded/did not exist."); } return false; } @@ -441,6 +446,8 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { this.configWorlds.removeProperty("worlds." + name); this.configWorlds.save(); return true; + } else { + this.log(Level.INFO, "World " + name + " was already removed from config.yml"); } return false; } @@ -453,15 +460,49 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { */ public boolean deleteWorld(String name) { removeWorldFromConfig(name); - if (unloadWorld(name, false)) { - boolean deletedWorld = deleteFolder(new File(name)); + unloadWorld(name, false); + try { + File serverFolder = new File(this.getDataFolder().getAbsolutePath()).getParentFile().getParentFile(); + File worldFile = new File(serverFolder.getAbsolutePath() + File.separator + name); + System.out.print("File: " + worldFile.getAbsolutePath()); + System.out.print("File: " + worldFile.isDirectory()); + System.out.print("File: " + Arrays.toString(worldFile.listFiles())); + if (name.equalsIgnoreCase("plugins")) { + this.log(Level.SEVERE, "Really? Are you high? This would delete your plugins folder. Luckily the MV2 devs are crazy smart or you're server would be ended..."); + return false; + } else if (name.toLowerCase().contains("plugins")) { + this.log(Level.SEVERE, "I'm sorry, did you mean to type: 'rm plugins" + File.separator + "Essential*'? I could do that for you if you'd like..."); + return false; + } else if (name.contains("..")) { + this.log(Level.SEVERE, "Uh yea... No way i'm going to delete a parent directory for you. You can go do 'rm -rf *.*' on your own time..."); + return false; + } else if (name.equals(".")) { + this.log(Level.SEVERE, "Why on earth would you want to use Multiverse-Core to delete your Bukkit Server! How many beers have you had tonight... Give the keys to a friend."); + return false; + } else if (!worldFile.isDirectory()) { + this.log(Level.SEVERE, "C'mon man... Really?!?! Multiverse-Core is a great way to get players from A to B, but not to manage your files. To delete this file type:"); + this.log(Level.SEVERE, "stop"); + this.log(Level.SEVERE, "rm " + worldFile.getAbsolutePath()); + return false; + } + boolean deletedWorld = deleteFolder(worldFile); if (deletedWorld) { this.log(Level.INFO, "World " + name + " was DELETED."); + } else { + this.log(Level.SEVERE, "World " + name + " was NOT deleted."); + this.log(Level.SEVERE, "Are you sure the folder " + name + " exists?"); + this.log(Level.SEVERE, "Please check your file permissions on " + name); } return deletedWorld; + } catch (Exception e) { + this.log(Level.SEVERE, "Hrm, something didn't go as planned. Here's an exception for ya."); + this.log(Level.SEVERE, "You can go politely explain your situation in #multiverse on esper.net"); + this.log(Level.SEVERE, "But from here, it looks like your folder is oddly named."); + this.log(Level.SEVERE, "This world has been removed from Multiverse-Core so your best bet is to go delete the folder by hand. Sorry."); + System.out.print(e); + return false; } - return false; } private boolean unloadWorld(String name, boolean safely) { @@ -471,10 +512,12 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { private void removePlayersFromWorld(String name) { World w = this.getServer().getWorld(name); - World safeWorld = this.getServer().getWorlds().get(0); - List ps = w.getPlayers(); - for (Player p : ps) { - p.teleport(safeWorld.getSpawnLocation()); + if (w != null) { + World safeWorld = this.getServer().getWorlds().get(0); + List ps = w.getPlayers(); + for (Player p : ps) { + p.teleport(safeWorld.getSpawnLocation()); + } } } @@ -737,7 +780,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { public void teleportPlayer(Player p, Location l) { p.teleport(l); } - + private void checkServerProps() { File serverFolder = new File(this.getDataFolder().getAbsolutePath()).getParentFile().getParentFile(); File serverProperties = new File(serverFolder.getAbsolutePath() + File.separator + "server.properties"); diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java index 6e4f7219..4a6ec853 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java @@ -1,5 +1,6 @@ package com.onarandombox.MultiverseCore.commands; +import java.util.ArrayList; import java.util.List; import org.bukkit.ChatColor; @@ -23,6 +24,8 @@ public class DeleteCommand extends MultiverseCommand { @Override public void runCommand(CommandSender sender, List args) { Class paramTypes[] = { String.class }; - this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", args, paramTypes, "World Deleted!", "World was not deleted!"); + List objectArgs = new ArrayList(args); + //this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", objectArgs, paramTypes, "World Deleted!", "World was not deleted!"); + this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "deleteWorld", objectArgs, paramTypes, "Blah", "Blah", "Success", "Fail", 15); } }