mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-29 05:55:48 +01:00
Fix license, Update CH, Fix mvdelete
This commit is contained in:
parent
34a0ab2e67
commit
9d2cc9a839
@ -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:
|
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.
|
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.
|
@ -1 +1 @@
|
|||||||
Subproject commit 882ba77aa122413ebaeb70df96afe10e2845f76f
|
Subproject commit 647f75ccbb8a754af8bfae4c7f1fac0c9e98f68e
|
@ -424,6 +424,11 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
|||||||
this.log(Level.INFO, "World " + name + " was unloaded from memory.");
|
this.log(Level.INFO, "World " + name + " was unloaded from memory.");
|
||||||
this.unloadWorld(name, true);
|
this.unloadWorld(name, true);
|
||||||
return 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;
|
return false;
|
||||||
}
|
}
|
||||||
@ -441,6 +446,8 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
|||||||
this.configWorlds.removeProperty("worlds." + name);
|
this.configWorlds.removeProperty("worlds." + name);
|
||||||
this.configWorlds.save();
|
this.configWorlds.save();
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
this.log(Level.INFO, "World " + name + " was already removed from config.yml");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -453,16 +460,50 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
|||||||
*/
|
*/
|
||||||
public boolean deleteWorld(String name) {
|
public boolean deleteWorld(String name) {
|
||||||
removeWorldFromConfig(name);
|
removeWorldFromConfig(name);
|
||||||
if (unloadWorld(name, false)) {
|
unloadWorld(name, false);
|
||||||
boolean deletedWorld = deleteFolder(new File(name));
|
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)
|
if (deletedWorld)
|
||||||
{
|
{
|
||||||
this.log(Level.INFO, "World " + name + " was DELETED.");
|
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;
|
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) {
|
private boolean unloadWorld(String name, boolean safely) {
|
||||||
this.removePlayersFromWorld(name);
|
this.removePlayersFromWorld(name);
|
||||||
@ -471,12 +512,14 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
|||||||
|
|
||||||
private void removePlayersFromWorld(String name) {
|
private void removePlayersFromWorld(String name) {
|
||||||
World w = this.getServer().getWorld(name);
|
World w = this.getServer().getWorld(name);
|
||||||
|
if (w != null) {
|
||||||
World safeWorld = this.getServer().getWorlds().get(0);
|
World safeWorld = this.getServer().getWorlds().get(0);
|
||||||
List<Player> ps = w.getPlayers();
|
List<Player> ps = w.getPlayers();
|
||||||
for (Player p : ps) {
|
for (Player p : ps) {
|
||||||
p.teleport(safeWorld.getSpawnLocation());
|
p.teleport(safeWorld.getSpawnLocation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a folder Courtesy of: lithium3141
|
* Delete a folder Courtesy of: lithium3141
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.onarandombox.MultiverseCore.commands;
|
package com.onarandombox.MultiverseCore.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -23,6 +24,8 @@ public class DeleteCommand extends MultiverseCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void runCommand(CommandSender sender, List<String> args) {
|
public void runCommand(CommandSender sender, List<String> args) {
|
||||||
Class<?> paramTypes[] = { String.class };
|
Class<?> paramTypes[] = { String.class };
|
||||||
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", args, paramTypes, "World Deleted!", "World was not deleted!");
|
List<Object> objectArgs = new ArrayList<Object>(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user