diff --git a/lib/Essentials.jar b/lib/Essentials.jar new file mode 100644 index 00000000..5983ee95 Binary files /dev/null and b/lib/Essentials.jar differ diff --git a/lib/Permissions.jar b/lib/Permissions.jar new file mode 100644 index 00000000..5d1ec9ef Binary files /dev/null and b/lib/Permissions.jar differ diff --git a/lib/craftbukkit-0.0.1-SNAPSHOT.jar b/lib/craftbukkit-0.0.1-SNAPSHOT.jar new file mode 100644 index 00000000..ec27f656 Binary files /dev/null and b/lib/craftbukkit-0.0.1-SNAPSHOT.jar differ diff --git a/lib/iConomy.jar b/lib/iConomy.jar new file mode 100644 index 00000000..0826420b Binary files /dev/null and b/lib/iConomy.jar differ diff --git a/lib/update.sh b/lib/update.sh new file mode 100755 index 00000000..693fa383 --- /dev/null +++ b/lib/update.sh @@ -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 \ No newline at end of file diff --git a/src/com/onarandombox/MultiverseCore/MVEntityListener.java b/src/com/onarandombox/MultiverseCore/MVEntityListener.java index 7bad3455..778cd79c 100644 --- a/src/com/onarandombox/MultiverseCore/MVEntityListener.java +++ b/src/com/onarandombox/MultiverseCore/MVEntityListener.java @@ -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. diff --git a/src/com/onarandombox/MultiverseCore/MVPlayerListener.java b/src/com/onarandombox/MultiverseCore/MVPlayerListener.java index b9ea535a..bd5800c2 100644 --- a/src/com/onarandombox/MultiverseCore/MVPlayerListener.java +++ b/src/com/onarandombox/MultiverseCore/MVPlayerListener.java @@ -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) { diff --git a/src/com/onarandombox/MultiverseCore/MVWorld.java b/src/com/onarandombox/MultiverseCore/MVWorld.java index 32998a27..0fb836a5 100644 --- a/src/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/com/onarandombox/MultiverseCore/MVWorld.java @@ -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 animalList = new ArrayList(); // 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 monsterList = new ArrayList(); // Contain a list of Monsters which we want to ignore the Spawn Setting. - + public Boolean pvp; // Does this World allow PVP? - - public List blockBlacklist; // Contain a list of Blocks which we won't allow on this World. + + public List blockBlacklist; // Contain a list of Blocks which we won't allow on this World. public List joinWhitelist; // Contain a list of Players/Groups which can join this World. public List joinBlacklist; // Contain a list of Players/Groups which cannot join this World. public List editWhitelist; // Contain a list of Players/Groups which can edit this World. (Place/Destroy Blocks) public List editBlacklist; // Contain a list of Players/Groups which cannot edit this World. (Place/Destroy Blocks) public List 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 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()).size() == 0) { + addSampleData(); + } } - + private void initLists() { - blockBlacklist = new ArrayList(); + blockBlacklist = new ArrayList(); joinWhitelist = new ArrayList(); joinBlacklist = new ArrayList(); editWhitelist = new ArrayList(); @@ -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"); diff --git a/src/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/com/onarandombox/MultiverseCore/MultiverseCore.java index 3c68448b..13498763 100644 --- a/src/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -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... */ diff --git a/src/com/onarandombox/MultiverseCore/command/commands/DeleteCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/DeleteCommand.java new file mode 100644 index 00000000..f989f00c --- /dev/null +++ b/src/com/onarandombox/MultiverseCore/command/commands/DeleteCommand.java @@ -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!"); + } + } + +} diff --git a/src/com/onarandombox/MultiverseCore/command/commands/RemoveCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/RemoveCommand.java new file mode 100644 index 00000000..10296a5f --- /dev/null +++ b/src/com/onarandombox/MultiverseCore/command/commands/RemoveCommand.java @@ -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!"); + } + } + +} diff --git a/src/com/onarandombox/MultiverseCore/command/commands/UnloadCommand.java b/src/com/onarandombox/MultiverseCore/command/commands/UnloadCommand.java new file mode 100644 index 00000000..61b34141 --- /dev/null +++ b/src/com/onarandombox/MultiverseCore/command/commands/UnloadCommand.java @@ -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!"); + } + } + +} diff --git a/src/com/onarandombox/MultiverseCore/commands/MVRemove.java b/src/com/onarandombox/MultiverseCore/commands/MVRemove.java deleted file mode 100644 index 2d3d3b31..00000000 --- a/src/com/onarandombox/MultiverseCore/commands/MVRemove.java +++ /dev/null @@ -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; - } - -} diff --git a/src/plugin.yml b/src/plugin.yml index 14e99bd0..277e3138 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -19,11 +19,17 @@ commands: / creative normal -- Imports an existing world called 'creative' with a NORMAL environment. / hellworld nether -- Imports an existing world called 'hellworld' with a NETHER environment. mvremove: + description: World remove command + usage: | + / + mvdelete: description: World delete command usage: | / - / creative -- Removes the world 'creative' from the MultiVerse setup. - / hellworld -- Removes the world 'hellworld' from the MultiVerse setup. + mvunload: + description: World unload command + usage: | + / mvmodify: description: Modify the settings of an existing world usage: |