Some more basics etc...

This commit is contained in:
Simon Rigby 2011-02-26 05:21:56 +00:00
parent 4fd9821c79
commit 3f678fcd36
7 changed files with 137 additions and 25 deletions

View File

@ -0,0 +1,5 @@
package com.onarandombox.MultiVerseCore;
public class MVBlockListener {
}

View File

@ -0,0 +1,5 @@
package com.onarandombox.MultiVerseCore;
public class MVEntityListener {
}

View File

@ -0,0 +1,5 @@
package com.onarandombox.MultiVerseCore;
public class MVPlayerListener {
}

View File

@ -0,0 +1,5 @@
package com.onarandombox.MultiVerseCore;
public class MVPluginListener {
}

View File

@ -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<String> 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 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]);
}
}
}

View File

@ -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<String,MVWorld> mvWorlds = new HashMap<String,MVWorld>();
/**
* 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.

View File

@ -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();
}
}