From 3f678fcd362d35ee7e1beb293cd3130cca30fcc7 Mon Sep 17 00:00:00 2001 From: Simon Rigby Date: Sat, 26 Feb 2011 05:21:56 +0000 Subject: [PATCH] Some more basics etc... --- .../MultiVerseCore/MVBlockListener.java | 5 ++ .../MultiVerseCore/MVEntityListener.java | 5 ++ .../MultiVerseCore/MVPlayerListener.java | 5 ++ .../MultiVerseCore/MVPluginListener.java | 5 ++ .../onarandombox/MultiVerseCore/MVWorld.java | 65 +++++++++++++++++++ .../MultiVerseCore/MultiVerseCore.java | 49 +++++++------- .../onarandombox/utils/stringLocation.java | 28 ++++++++ 7 files changed, 137 insertions(+), 25 deletions(-) create mode 100644 src/com/onarandombox/MultiVerseCore/MVBlockListener.java create mode 100644 src/com/onarandombox/MultiVerseCore/MVEntityListener.java create mode 100644 src/com/onarandombox/MultiVerseCore/MVPlayerListener.java create mode 100644 src/com/onarandombox/MultiVerseCore/MVPluginListener.java create mode 100644 src/com/onarandombox/MultiVerseCore/MVWorld.java create mode 100644 src/com/onarandombox/utils/stringLocation.java diff --git a/src/com/onarandombox/MultiVerseCore/MVBlockListener.java b/src/com/onarandombox/MultiVerseCore/MVBlockListener.java new file mode 100644 index 00000000..f2e16c48 --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/MVBlockListener.java @@ -0,0 +1,5 @@ +package com.onarandombox.MultiVerseCore; + +public class MVBlockListener { + +} diff --git a/src/com/onarandombox/MultiVerseCore/MVEntityListener.java b/src/com/onarandombox/MultiVerseCore/MVEntityListener.java new file mode 100644 index 00000000..2ae51981 --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/MVEntityListener.java @@ -0,0 +1,5 @@ +package com.onarandombox.MultiVerseCore; + +public class MVEntityListener { + +} diff --git a/src/com/onarandombox/MultiVerseCore/MVPlayerListener.java b/src/com/onarandombox/MultiVerseCore/MVPlayerListener.java new file mode 100644 index 00000000..80aa543e --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/MVPlayerListener.java @@ -0,0 +1,5 @@ +package com.onarandombox.MultiVerseCore; + +public class MVPlayerListener { + +} diff --git a/src/com/onarandombox/MultiVerseCore/MVPluginListener.java b/src/com/onarandombox/MultiVerseCore/MVPluginListener.java new file mode 100644 index 00000000..c25f33a7 --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/MVPluginListener.java @@ -0,0 +1,5 @@ +package com.onarandombox.MultiVerseCore; + +public class MVPluginListener { + +} diff --git a/src/com/onarandombox/MultiVerseCore/MVWorld.java b/src/com/onarandombox/MultiVerseCore/MVWorld.java new file mode 100644 index 00000000..e13090cf --- /dev/null +++ b/src/com/onarandombox/MultiVerseCore/MVWorld.java @@ -0,0 +1,65 @@ +package com.onarandombox.MultiVerseCore; + +import java.util.List; +import java.util.logging.Logger; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.util.config.Configuration; + +import com.onarandombox.utils.stringLocation; + +@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 Location spawn; // Location of the Spawn Point. + + 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 Boolean monsters; // Does this World allow Monsters to Spawn? + 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 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 MVWorld(World world, Configuration config, MultiVerseCore instance){ + this.config = config; + this.plugin = instance; + + this.world = world; + this.name = world.getName(); + + this.alias = config.getString("worlds." + this.name + ".alias",""); + + this.environment = world.getEnvironment(); + + this.spawn = getSpawn(this.config.getString("worlds." + name + ".spawn", "").split(":")); + + this.monsters = config.getBoolean("worlds." + this.name + ".monsters", true); + this.animals = config.getBoolean("worlds." + this.name + ".animals", true); + this.pvp = config.getBoolean("worlds." + this.name + ".pvp", true); + } + + private Location getSpawn(String[] spawn){ + Location l = null; + + if(spawn.length!=5){ + return this.world.getSpawnLocation(); + } else { + return new stringLocation().stringToLocation(world, spawn[0], spawn[1], spawn[2], spawn[3], spawn[4]); + } + } + +} \ No newline at end of file diff --git a/src/com/onarandombox/MultiVerseCore/MultiVerseCore.java b/src/com/onarandombox/MultiVerseCore/MultiVerseCore.java index d33febf8..73b11729 100644 --- a/src/com/onarandombox/MultiVerseCore/MultiVerseCore.java +++ b/src/com/onarandombox/MultiVerseCore/MultiVerseCore.java @@ -1,6 +1,7 @@ package com.onarandombox.MultiVerseCore; import java.io.File; +import java.util.HashMap; import java.util.logging.Logger; import org.bukkit.Server; @@ -19,36 +20,35 @@ import com.nijikokun.bukkit.iConomy.iConomy; @SuppressWarnings("unused") public class MultiVerseCore extends JavaPlugin { - /** - * Variable for whether we are going to allow Debug Messages or not. - */ + // Variable to state whether we are displaying Debug Messages or not. public boolean debug = false; - /** - * Variable to hold the Server Instance. - */ - public static Server server; - /** - * Permissions Plugin - */ - public static PermissionHandler Permissions = null; - /** - * Setup the Logger, also set a public variable which contains the prefix - * for all log messages, this allows for easy change. - */ + + // Useless stuff to keep us going. private final Logger log = Logger.getLogger("Minecraft"); public final String logPrefix = "[MultiVerse-Core] "; - /** - * Variable to hold the Plugin instance. - */ public static Plugin instance; - /** - * Variable to hold the Plugins Description - */ + public static Server server; public static PluginDescriptionFile description; + + // Permissions Handler + public static PermissionHandler Permissions = null; + + // Configurations + public static Configuration configMV; + public static Configuration configWorlds; + + // Setup the block/player/entity listener. + private MVPlayerListener playerListener; + private MVBlockListener blockListener; + private MVEntityListener entityListener; + private MVPluginListener pluginListener; + + // HashMap to contain all the Worlds which this Plugin will manage. + public HashMap mvWorlds = new HashMap(); + /** * What happens when the plugin gets around to be enabled... */ - @Override public void onEnable() { this.getDataFolder().mkdir(); /** @@ -59,15 +59,14 @@ public class MultiVerseCore extends JavaPlugin { /** * What happens when the plugin gets disabled... */ - @Override public void onDisable() { log.info(logPrefix + "- Disabled"); } /** * onCommand */ - public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { - return debug; + public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { + return false; } /** * Basic Debug Output function, if we've enabled debugging we'll output more information. diff --git a/src/com/onarandombox/utils/stringLocation.java b/src/com/onarandombox/utils/stringLocation.java new file mode 100644 index 00000000..8e7062f1 --- /dev/null +++ b/src/com/onarandombox/utils/stringLocation.java @@ -0,0 +1,28 @@ +package com.onarandombox.utils; + +import org.bukkit.Location; +import org.bukkit.World; + +public class stringLocation { + + public Location stringToLocation(World world, String xStr, String yStr, String zStr, String yawStr, String pitchStr){ + double x = Double.parseDouble(xStr); + double y = Double.parseDouble(yStr); + double z = Double.parseDouble(zStr); + float yaw = Float.valueOf(yawStr).floatValue(); + float pitch = Float.valueOf(pitchStr).floatValue(); + + return new Location(world, x, y, z, yaw, pitch); + } + + public String locationToString(Location location) { + StringBuilder l = new StringBuilder(); + l.append(location.getBlockX() + ":"); + l.append(location.getBlockY() + ":"); + l.append(location.getBlockZ() + ":"); + l.append(location.getYaw() + ":"); + l.append(location.getPitch()); + return l.toString(); + } + +}