mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 12:05:14 +01:00
Add mvdelete, mvremove and mvunload
This commit is contained in:
parent
8e41d2ea4b
commit
6afd8dfdfb
BIN
lib/Essentials.jar
Normal file
BIN
lib/Essentials.jar
Normal file
Binary file not shown.
BIN
lib/Permissions.jar
Normal file
BIN
lib/Permissions.jar
Normal file
Binary file not shown.
BIN
lib/craftbukkit-0.0.1-SNAPSHOT.jar
Normal file
BIN
lib/craftbukkit-0.0.1-SNAPSHOT.jar
Normal file
Binary file not shown.
BIN
lib/iConomy.jar
Normal file
BIN
lib/iConomy.jar
Normal file
Binary file not shown.
4
lib/update.sh
Executable file
4
lib/update.sh
Executable file
@ -0,0 +1,4 @@
|
||||
wget -N http://ci.bukkit.org/job/dev-CraftBukkit/lastSuccessfulBuild/artifact/target/craftbukkit-0.0.1-SNAPSHOT.jar
|
||||
wget -N http://www.theyeticave.net/downloads/permissions/3.1.5/Permissions.jar
|
||||
wget -N http://earth2me.net:8001/artifactory/essentials-2.2/Essentials.jar
|
||||
wget -N http://mirror.nexua.org/iConomy/JARS/5.0/1/iConomy.jar
|
@ -6,8 +6,10 @@ import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
@ -27,6 +29,15 @@ public class MVEntityListener extends EntityListener {
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
if(event.getEntity() instanceof Player) {
|
||||
Player p = (Player)event.getEntity();
|
||||
p.sendMessage("You died!");
|
||||
}
|
||||
super.onEntityDeath(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit.
|
||||
|
@ -30,11 +30,15 @@ public class MVPlayerListener extends PlayerListener {
|
||||
// MultiVerseCore.log.info("2 - " + event.getPlayer().getLocation().toString());
|
||||
MVPlayerSession ps = this.plugin.getPlayerSession(event.getPlayer());
|
||||
ps.setRespawnWorld(event.getTo().getWorld());
|
||||
|
||||
log.warning("To: " + event.getTo().getWorld().getName());
|
||||
log.warning("From: " + event.getFrom().getWorld().getName());
|
||||
}
|
||||
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
|
@ -9,60 +9,60 @@ import org.bukkit.util.config.Configuration;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class MVWorld {
|
||||
|
||||
|
||||
private MultiverseCore plugin; // Hold the Plugin Instance.
|
||||
private Configuration config; // Hold the Configuration File.
|
||||
|
||||
|
||||
public World world; // The World Instance.
|
||||
public Environment environment; // Hold the Environment type EG Environment.NETHER / Environment.NORMAL
|
||||
public Long seed;
|
||||
|
||||
|
||||
public String name; // The Worlds Name, EG its folder name.
|
||||
public String alias = ""; // Short Alias for the World, this will be used in Chat Prefixes.
|
||||
|
||||
|
||||
public Boolean animals; // Does this World allow Animals to Spawn?
|
||||
public List<String> animalList = new ArrayList<String>(); // Contain a list of Animals which we want to ignore the Spawn Setting.
|
||||
|
||||
|
||||
public Boolean monsters; // Does this World allow Monsters to Spawn?
|
||||
public List<String> monsterList = new ArrayList<String>(); // Contain a list of Monsters which we want to ignore the Spawn Setting.
|
||||
|
||||
|
||||
public Boolean pvp; // Does this World allow PVP?
|
||||
|
||||
public List<String> blockBlacklist; // Contain a list of Blocks which we won't allow on this World.
|
||||
|
||||
public List<Integer> blockBlacklist; // Contain a list of Blocks which we won't allow on this World.
|
||||
public List<String> joinWhitelist; // Contain a list of Players/Groups which can join this World.
|
||||
public List<String> joinBlacklist; // Contain a list of Players/Groups which cannot join this World.
|
||||
public List<String> editWhitelist; // Contain a list of Players/Groups which can edit this World. (Place/Destroy Blocks)
|
||||
public List<String> editBlacklist; // Contain a list of Players/Groups which cannot edit this World. (Place/Destroy Blocks)
|
||||
public List<String> worldBlacklist; // Contain a list of Worlds which Players cannot use to Portal to this World.
|
||||
|
||||
|
||||
public Double compression; // How stretched/compressed distances are
|
||||
|
||||
|
||||
public MVWorld(World world, Configuration config, MultiverseCore instance, Long seed) {
|
||||
this.config = config;
|
||||
this.plugin = instance;
|
||||
|
||||
|
||||
this.world = world;
|
||||
this.name = world.getName();
|
||||
this.environment = world.getEnvironment();
|
||||
this.seed = seed;
|
||||
|
||||
initLists();
|
||||
|
||||
|
||||
this.alias = config.getString("worlds." + this.name + ".alias", "");
|
||||
this.pvp = config.getBoolean("worlds." + this.name + ".pvp", true);
|
||||
|
||||
|
||||
this.compression = config.getDouble("worlds." + this.name + ".compression", 1.0);
|
||||
|
||||
|
||||
this.joinWhitelist = config.getStringList("worlds." + name + ".playerWhitelist", joinWhitelist);
|
||||
this.joinBlacklist = config.getStringList("worlds." + name + ".playerBlacklist", joinBlacklist);
|
||||
this.worldBlacklist = config.getStringList("worlds." + name + ".worldBlacklist", worldBlacklist);
|
||||
this.blockBlacklist = config.getStringList("worlds." + name + ".blockBlacklist", blockBlacklist);
|
||||
this.blockBlacklist = config.getIntList("worlds." + name + ".blockBlacklist", blockBlacklist);
|
||||
this.editWhitelist = config.getStringList("worlds." + name + ".editWhitelist", editWhitelist);
|
||||
this.editBlacklist = config.getStringList("worlds." + name + ".editBlacklist", editBlacklist);
|
||||
|
||||
|
||||
this.animals = config.getBoolean("worlds." + name + ".animals.spawn", true);
|
||||
this.monsters = config.getBoolean("worlds." + name + ".monsters.spawn", true);
|
||||
|
||||
|
||||
List<String> temp;
|
||||
temp = config.getStringList("worlds." + name + ".animals.exceptions", animalList);
|
||||
this.animalList.clear();
|
||||
@ -77,11 +77,13 @@ public class MVWorld {
|
||||
}
|
||||
|
||||
config.save();
|
||||
addSampleData();
|
||||
if (config.getIntList("worlds." + name + ".blockBlacklist", new ArrayList<Integer>()).size() == 0) {
|
||||
addSampleData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initLists() {
|
||||
blockBlacklist = new ArrayList<String>();
|
||||
blockBlacklist = new ArrayList<Integer>();
|
||||
joinWhitelist = new ArrayList<String>();
|
||||
joinBlacklist = new ArrayList<String>();
|
||||
editWhitelist = new ArrayList<String>();
|
||||
@ -94,7 +96,7 @@ public class MVWorld {
|
||||
|
||||
this.animalList.add("pig");
|
||||
|
||||
this.blockBlacklist.add("49");
|
||||
this.blockBlacklist.add(49);
|
||||
|
||||
this.joinWhitelist.add("fernferret");
|
||||
this.joinWhitelist.add("g:Admins");
|
||||
|
@ -44,17 +44,19 @@ import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.onarandombox.MultiverseCore.command.CommandManager;
|
||||
import com.onarandombox.MultiverseCore.command.commands.CoordCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.ListCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.CreateCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.DeleteCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.ImportCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.SpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.ListCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.RemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.SetSpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.WhoCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.SpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.UnloadCommand;
|
||||
import com.onarandombox.MultiverseCore.command.commands.WhoCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.MVModify;
|
||||
import com.onarandombox.MultiverseCore.commands.MVReload;
|
||||
import com.onarandombox.MultiverseCore.commands.MVRemove;
|
||||
import com.onarandombox.MultiverseCore.configuration.DefaultConfiguration;
|
||||
import com.onarandombox.utils.DebugLog;
|
||||
import com.onarandombox.utils.Messaging;
|
||||
@ -300,6 +302,9 @@ public class MultiverseCore extends JavaPlugin {
|
||||
commandManager.addCommand(new CreateCommand(this));
|
||||
commandManager.addCommand(new ImportCommand(this));
|
||||
commandManager.addCommand(new SpawnCommand(this));
|
||||
commandManager.addCommand(new RemoveCommand(this));
|
||||
commandManager.addCommand(new DeleteCommand(this));
|
||||
commandManager.addCommand(new UnloadCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,12 +313,12 @@ public class MultiverseCore extends JavaPlugin {
|
||||
private void setupCommands() {
|
||||
// commands.put("mvcreate", new CreateCommand(this));
|
||||
// commands.put("mvimport", new ImportCommand(this));
|
||||
commands.put("mvremove", new MVRemove(this));
|
||||
// commands.put("mvremove", new RemoveCommand(this));
|
||||
commands.put("mvmodify", new MVModify(this));
|
||||
// commands.put("mvtp", new TeleportCommand(this));
|
||||
// commands.put("mvlist", new ListCommand(this));
|
||||
// commands.put("mvsetspawn", new SetSpawnCommand(this));
|
||||
//commands.put("mvspawn", new SpawnCommand(this));
|
||||
// commands.put("mvspawn", new SpawnCommand(this));
|
||||
// commands.put("mvcoord", new MVCoord(this));
|
||||
// commands.put("mvwho", new WhoCommand(this));
|
||||
commands.put("mvreload", new MVReload(this));
|
||||
@ -341,7 +346,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
Long seed = null;
|
||||
// Work out the Environment
|
||||
Environment env = getEnvFromString(environment, null);
|
||||
if(env == null) {
|
||||
if (env == null) {
|
||||
env = Environment.NORMAL;
|
||||
}
|
||||
// If a seed was given we need to parse it to a Long Format.
|
||||
@ -383,7 +388,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
int additonalWorldsLoaded = 0;
|
||||
// Load the default world:
|
||||
World world = this.getServer().getWorlds().get(0);
|
||||
if(!this.worlds.containsKey(world.getName())) {
|
||||
if (!this.worlds.containsKey(world.getName())) {
|
||||
log.info("Loading World & Settings - '" + world.getName() + "' - " + world.getEnvironment());
|
||||
addWorld(world.getName(), Environment.NORMAL, null);
|
||||
additonalWorldsLoaded++;
|
||||
@ -391,7 +396,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
|
||||
// This next one could be null if they have it disabled in server.props
|
||||
World world_nether = this.getServer().getWorld(world.getName() + "_nether");
|
||||
if(world_nether != null && !this.worlds.containsKey(world_nether.getName())) {
|
||||
if (world_nether != null && !this.worlds.containsKey(world_nether.getName())) {
|
||||
log.info("Loading World & Settings - '" + world.getName() + "' - " + world_nether.getEnvironment());
|
||||
addWorld(world_nether.getName(), Environment.NETHER, null);
|
||||
additonalWorldsLoaded++;
|
||||
@ -399,7 +404,7 @@ public class MultiverseCore extends JavaPlugin {
|
||||
|
||||
return additonalWorldsLoaded;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the worlds Seed.
|
||||
*
|
||||
@ -420,14 +425,14 @@ public class MultiverseCore extends JavaPlugin {
|
||||
if (seed != null) {
|
||||
World world = getServer().createWorld(name, environment, seed);
|
||||
worlds.put(name, new MVWorld(world, configWorlds, this, seed)); // Place the World into the HashMap.
|
||||
// configWorlds.setProperty("worlds." + world.getName() + ".environment", environment.toString());
|
||||
// configWorlds.save();
|
||||
// configWorlds.setProperty("worlds." + world.getName() + ".environment", environment.toString());
|
||||
// configWorlds.save();
|
||||
System.out.print("Seed - " + getSeed(world));
|
||||
} else {
|
||||
World world = getServer().createWorld(name, environment);
|
||||
worlds.put(name, new MVWorld(world, configWorlds, this, null)); // Place the World into the HashMap.
|
||||
// configWorlds.setProperty("worlds." + world.getName() + ".environment", environment.toString());
|
||||
// configWorlds.save();
|
||||
// configWorlds.setProperty("worlds." + world.getName() + ".environment", environment.toString());
|
||||
// configWorlds.save();
|
||||
System.out.print("Seed - " + getSeed(world));
|
||||
}
|
||||
|
||||
@ -437,14 +442,70 @@ public class MultiverseCore extends JavaPlugin {
|
||||
addWorld(name, environment, null);
|
||||
}
|
||||
|
||||
public boolean removeWorld(String name) {
|
||||
if(worlds.containsKey(name)) {
|
||||
/**
|
||||
* Remove the world from the Multiverse list
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public boolean unloadWorld(String name) {
|
||||
if (worlds.containsKey(name)) {
|
||||
worlds.remove(name);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list and from the config
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public boolean removeWorld(String name) {
|
||||
unloadWorld(name);
|
||||
configWorlds.removeProperty("worlds." + name);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the config and deletes the folder
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public boolean deleteWorld(String name) {
|
||||
unloadWorld(name);
|
||||
removeWorld(name);
|
||||
if (getServer().unloadWorld(name, false)) {
|
||||
return deleteFolder(new File(name));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a folder Courtesy of: lithium3141
|
||||
*
|
||||
* @param file The folder to delete
|
||||
* @return true if success
|
||||
*/
|
||||
private boolean deleteFolder(File file) {
|
||||
if (file.exists()) {
|
||||
// If the file exists, and it has more than one file in it.
|
||||
if (file.isDirectory()) {
|
||||
for (File f : file.listFiles()) {
|
||||
if (!this.deleteFolder(f)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
return !file.exists();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* What happens when the plugin gets disabled...
|
||||
*/
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
|
||||
public class DeleteCommand extends BaseCommand {
|
||||
|
||||
public DeleteCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
name = "Delete World";
|
||||
description = "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.";
|
||||
usage = "/mvdelete" + ChatColor.GREEN + " {WORLD} ";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("mvdelete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (plugin.deleteWorld(args[0])) {
|
||||
sender.sendMessage("World Deleted!");
|
||||
} else {
|
||||
sender.sendMessage("Error trying to delete World!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
|
||||
public class RemoveCommand extends BaseCommand {
|
||||
|
||||
public RemoveCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
name = "Remove World";
|
||||
description = "Unloads a world from Multiverse and removes it from worlds.yml, this does NOT remove the world folder.";
|
||||
usage = "/mvremove" + ChatColor.GREEN + " {WORLD} ";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("mvremove");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (plugin.removeWorld(args[0])) {
|
||||
sender.sendMessage("World removed from config!");
|
||||
} else {
|
||||
sender.sendMessage("Error trying to remove world from config!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.onarandombox.MultiverseCore.command.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||
|
||||
public class UnloadCommand extends BaseCommand {
|
||||
|
||||
public UnloadCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
name = "Unload World";
|
||||
description = "Unloads a world from Multiverse. This does NOT remove the world folder. This does NOT remove it from the config file.";
|
||||
usage = "/mvunload" + ChatColor.GREEN + " {WORLD} ";
|
||||
minArgs = 1;
|
||||
maxArgs = 1;
|
||||
identifiers.add("mvunload");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (plugin.unloadWorld(args[0])) {
|
||||
sender.sendMessage("World Unloaded!");
|
||||
} else {
|
||||
sender.sendMessage("Error trying to unload world!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVCommandHandler;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class MVRemove extends MVCommandHandler {
|
||||
|
||||
public MVRemove(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean perform(CommandSender sender, String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -19,11 +19,17 @@ commands:
|
||||
/<command> creative normal -- Imports an existing world called 'creative' with a NORMAL environment.
|
||||
/<command> hellworld nether -- Imports an existing world called 'hellworld' with a NETHER environment.
|
||||
mvremove:
|
||||
description: World remove command
|
||||
usage: |
|
||||
/<command> <world>
|
||||
mvdelete:
|
||||
description: World delete command
|
||||
usage: |
|
||||
/<command> <world>
|
||||
/<command> creative -- Removes the world 'creative' from the MultiVerse setup.
|
||||
/<command> hellworld -- Removes the world 'hellworld' from the MultiVerse setup.
|
||||
mvunload:
|
||||
description: World unload command
|
||||
usage: |
|
||||
/<command> <world>
|
||||
mvmodify:
|
||||
description: Modify the settings of an existing world
|
||||
usage: |
|
||||
|
Loading…
Reference in New Issue
Block a user