mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 20:16:06 +01:00
Made 'worlds' private and added accessor methods.
This commit is contained in:
parent
53345c2f42
commit
b2bcb941c3
@ -47,14 +47,14 @@ public class MVEntityListener extends EntityListener {
|
|||||||
World world = event.getEntity().getWorld();
|
World world = event.getEntity().getWorld();
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
if (!(plugin.worlds.containsKey(world.getName())))
|
if (!(this.plugin.isMVWorld(world.getName())))
|
||||||
return; // Check if it's a world which we are meant to be managing.
|
return; // Check if it's a world which we are meant to be managing.
|
||||||
|
|
||||||
CreatureType creature = event.getCreatureType();
|
CreatureType creature = event.getCreatureType();
|
||||||
|
|
||||||
// event.getEntity().getWorld().spawnCreature(arg0, arg1);
|
// event.getEntity().getWorld().spawnCreature(arg0, arg1);
|
||||||
|
|
||||||
MVWorld mvworld = plugin.worlds.get(world.getName());
|
MVWorld mvworld = this.plugin.getMVWorld(world.getName());
|
||||||
|
|
||||||
// TODO: Look of this and see if there's a cleaner/better method of doing so...
|
// TODO: Look of this and see if there's a cleaner/better method of doing so...
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class MVPermissions {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Boolean canTravelFromWorld(Player p, World w) {
|
public Boolean canTravelFromWorld(Player p, World w) {
|
||||||
List<String> blackList = this.plugin.worlds.get(w.getName()).worldBlacklist;
|
List<String> blackList = this.plugin.getMVWorld(w.getName()).worldBlacklist;
|
||||||
|
|
||||||
boolean returnValue = true;
|
boolean returnValue = true;
|
||||||
|
|
||||||
@ -74,8 +74,8 @@ public class MVPermissions {
|
|||||||
*/
|
*/
|
||||||
public Boolean canEnterWorld(Player p, World w) {
|
public Boolean canEnterWorld(Player p, World w) {
|
||||||
|
|
||||||
List<String> whiteList = this.plugin.worlds.get(w.getName()).playerWhitelist;
|
List<String> whiteList = this.plugin.getMVWorld(w.getName()).playerWhitelist;
|
||||||
List<String> blackList = this.plugin.worlds.get(w.getName()).playerBlacklist;
|
List<String> blackList = this.plugin.getMVWorld(w.getName()).playerBlacklist;
|
||||||
|
|
||||||
boolean returnValue = true;
|
boolean returnValue = true;
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ public class MVTeleport {
|
|||||||
|
|
||||||
double x, y, z;
|
double x, y, z;
|
||||||
|
|
||||||
// Grab the Compression value for each world.
|
// Grab the Scaling value for each world.
|
||||||
double srcComp = plugin.worlds.get(l.getWorld().getName()).scaling;
|
double srcComp = this.plugin.getMVWorld(l.getWorld().getName()).scaling;
|
||||||
double trgComp = plugin.worlds.get(w.getName()).scaling;
|
double trgComp = this.plugin.getMVWorld(w.getName()).scaling;
|
||||||
|
|
||||||
// MultiverseCore.debugMsg(p.getName() + " -> " + p.getWorld().getName() + "(" + srcComp + ") -> " + w.getName() + "(" + trgComp + ")");
|
// MultiverseCore.debugMsg(p.getName() + " -> " + p.getWorld().getName() + "(" + srcComp + ") -> " + w.getName() + "(" + trgComp + ")");
|
||||||
|
|
||||||
@ -128,10 +128,10 @@ public class MVTeleport {
|
|||||||
*/
|
*/
|
||||||
private double safeColumn(World world, double x, double y, double z) {
|
private double safeColumn(World world, double x, double y, double z) {
|
||||||
for (double ny = 0; ny < 48; ny++) {
|
for (double ny = 0; ny < 48; ny++) {
|
||||||
if ((y + ny < 120) && !bs.blockIsNotSafe(world, x, y + ny, z)) {
|
if ((y + ny < 120) && !this.bs.blockIsNotSafe(world, x, y + ny, z)) {
|
||||||
return y + ny;
|
return y + ny;
|
||||||
}
|
}
|
||||||
if ((y - ny > 4) && !bs.blockIsNotSafe(world, x, y - ny, z)) {
|
if ((y - ny > 4) && !this.bs.blockIsNotSafe(world, x, y - ny, z)) {
|
||||||
return y - ny;
|
return y - ny;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
public UpdateChecker updateCheck;
|
public UpdateChecker updateCheck;
|
||||||
|
|
||||||
// HashMap to contain all the Worlds which this Plugin will manage.
|
// HashMap to contain all the Worlds which this Plugin will manage.
|
||||||
public HashMap<String, MVWorld> worlds = new HashMap<String, MVWorld>();
|
private HashMap<String, MVWorld> worlds = new HashMap<String, MVWorld>();
|
||||||
|
|
||||||
// HashMap to contain all custom generators. Plugins will have to register!
|
// HashMap to contain all custom generators. Plugins will have to register!
|
||||||
private HashMap<String, ChunkGenerator> worldGenerators = new HashMap<String, ChunkGenerator>();
|
private HashMap<String, ChunkGenerator> worldGenerators = new HashMap<String, ChunkGenerator>();
|
||||||
@ -149,17 +149,17 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
// pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Highest, this); // Low so it acts above any other.
|
// pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Highest, this); // Low so it acts above any other.
|
||||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, playerListener, Priority.Highest, this); // Cancel Teleports if needed.
|
pm.registerEvent(Event.Type.PLAYER_TELEPORT, this.playerListener, Priority.Highest, this); // Cancel Teleports if needed.
|
||||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this); // To create the Player Session
|
pm.registerEvent(Event.Type.PLAYER_LOGIN, this.playerListener, Priority.Normal, this); // To create the Player Session
|
||||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this); // To remove Player Sessions
|
pm.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Priority.Normal, this); // To remove Player Sessions
|
||||||
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Priority.Highest, this);
|
pm.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Normal, this); // To Allow/Disallow PVP as well as EnableHealth.
|
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Priority.Normal, this); // To Allow/Disallow PVP as well as EnableHealth.
|
||||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning.
|
pm.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Priority.Normal, this); // To prevent all or certain animals/monsters from spawning.
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLUGIN_ENABLE, pluginListener, Priority.Monitor, this);
|
pm.registerEvent(Event.Type.PLUGIN_ENABLE, this.pluginListener, Priority.Monitor, this);
|
||||||
pm.registerEvent(Event.Type.PLUGIN_DISABLE, pluginListener, Priority.Monitor, this);
|
pm.registerEvent(Event.Type.PLUGIN_DISABLE, this.pluginListener, Priority.Monitor, this);
|
||||||
|
|
||||||
// pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this); // To prevent Blocks being destroyed.
|
// pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this); // To prevent Blocks being destroyed.
|
||||||
// pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this); // To prevent Blocks being placed.
|
// pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this); // To prevent Blocks being placed.
|
||||||
@ -203,43 +203,43 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
new DefaultConfiguration(getDataFolder(), "worlds.yml");
|
new DefaultConfiguration(getDataFolder(), "worlds.yml");
|
||||||
|
|
||||||
// Now grab the Configuration Files.
|
// Now grab the Configuration Files.
|
||||||
configMV = new Configuration(new File(getDataFolder(), "config.yml"));
|
this.configMV = new Configuration(new File(getDataFolder(), "config.yml"));
|
||||||
configWorlds = new Configuration(new File(getDataFolder(), "worlds.yml"));
|
this.configWorlds = new Configuration(new File(getDataFolder(), "worlds.yml"));
|
||||||
|
|
||||||
// Now attempt to Load the configurations.
|
// Now attempt to Load the configurations.
|
||||||
try {
|
try {
|
||||||
configMV.load();
|
this.configMV.load();
|
||||||
log(Level.INFO, "- Multiverse Config -- Loaded");
|
log(Level.INFO, "- Multiverse Config -- Loaded");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log(Level.INFO, "- Failed to load config.yml");
|
log(Level.INFO, "- Failed to load config.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
configWorlds.load();
|
this.configWorlds.load();
|
||||||
log(Level.INFO, "- World Config -- Loaded");
|
log(Level.INFO, "- World Config -- Loaded");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log(Level.INFO, "- Failed to load worlds.yml");
|
log(Level.INFO, "- Failed to load worlds.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup the Debug option, we'll default to false because this option will not be in the default config.
|
// Setup the Debug option, we'll default to false because this option will not be in the default config.
|
||||||
this.debug = configMV.getBoolean("debug", false);
|
this.debug = this.configMV.getBoolean("debug", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Purge the Worlds of Entities that are disallowed.
|
* Purge the Worlds of Entities that are disallowed.
|
||||||
*/
|
*/
|
||||||
private void purgeWorlds() {
|
private void purgeWorlds() {
|
||||||
if (worlds.size() <= 0)
|
if (this.worlds.size() <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: Need a better method than this... too messy and atm it's not complete.
|
// TODO: Need a better method than this... too messy and atm it's not complete.
|
||||||
|
|
||||||
Set<String> worldKeys = worlds.keySet();
|
Set<String> worldKeys = this.worlds.keySet();
|
||||||
for (String key : worldKeys) {
|
for (String key : worldKeys) {
|
||||||
World world = getServer().getWorld(key);
|
World world = getServer().getWorld(key);
|
||||||
if (world == null)
|
if (world == null)
|
||||||
continue;
|
continue;
|
||||||
MVWorld mvworld = worlds.get(key);
|
MVWorld mvworld = this.worlds.get(key);
|
||||||
List<String> monsters = mvworld.monsterList;
|
List<String> monsters = mvworld.monsterList;
|
||||||
List<String> animals = mvworld.animalList;
|
List<String> animals = mvworld.animalList;
|
||||||
System.out.print("Monster Size:" + monsters.size() + " - " + "Animal Size: " + animals.size());
|
System.out.print("Monster Size:" + monsters.size() + " - " + "Animal Size: " + animals.size());
|
||||||
@ -292,23 +292,23 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
private void registerCommands() {
|
private void registerCommands() {
|
||||||
// Page 1
|
// Page 1
|
||||||
commandManager.addCommand(new HelpCommand(this));
|
this.commandManager.addCommand(new HelpCommand(this));
|
||||||
commandManager.addCommand(new CoordCommand(this));
|
this.commandManager.addCommand(new CoordCommand(this));
|
||||||
commandManager.addCommand(new TeleportCommand(this));
|
this.commandManager.addCommand(new TeleportCommand(this));
|
||||||
commandManager.addCommand(new ListCommand(this));
|
this.commandManager.addCommand(new ListCommand(this));
|
||||||
commandManager.addCommand(new WhoCommand(this));
|
this.commandManager.addCommand(new WhoCommand(this));
|
||||||
commandManager.addCommand(new SetSpawnCommand(this));
|
this.commandManager.addCommand(new SetSpawnCommand(this));
|
||||||
commandManager.addCommand(new CreateCommand(this));
|
this.commandManager.addCommand(new CreateCommand(this));
|
||||||
commandManager.addCommand(new ImportCommand(this));
|
this.commandManager.addCommand(new ImportCommand(this));
|
||||||
commandManager.addCommand(new SpawnCommand(this));
|
this.commandManager.addCommand(new SpawnCommand(this));
|
||||||
commandManager.addCommand(new RemoveCommand(this));
|
this.commandManager.addCommand(new RemoveCommand(this));
|
||||||
commandManager.addCommand(new DeleteCommand(this));
|
this.commandManager.addCommand(new DeleteCommand(this));
|
||||||
commandManager.addCommand(new UnloadCommand(this));
|
this.commandManager.addCommand(new UnloadCommand(this));
|
||||||
commandManager.addCommand(new ConfirmCommand(this));
|
this.commandManager.addCommand(new ConfirmCommand(this));
|
||||||
commandManager.addCommand(new InfoCommand(this));
|
this.commandManager.addCommand(new InfoCommand(this));
|
||||||
commandManager.addCommand(new ReloadCommand(this));
|
this.commandManager.addCommand(new ReloadCommand(this));
|
||||||
commandManager.addCommand(new ModifyCommand(this));
|
this.commandManager.addCommand(new ModifyCommand(this));
|
||||||
commandManager.addCommand(new EnvironmentCommand(this));
|
this.commandManager.addCommand(new EnvironmentCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,18 +318,18 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
// Basic Counter to count how many Worlds we are loading.
|
// Basic Counter to count how many Worlds we are loading.
|
||||||
int count = 0;
|
int count = 0;
|
||||||
// Grab all the Worlds from the Config.
|
// Grab all the Worlds from the Config.
|
||||||
List<String> worldKeys = configWorlds.getKeys("worlds");
|
List<String> worldKeys = this.configWorlds.getKeys("worlds");
|
||||||
|
|
||||||
// Check that the list is not null.
|
// Check that the list is not null.
|
||||||
if (worldKeys != null) {
|
if (worldKeys != null) {
|
||||||
for (String worldKey : worldKeys) {
|
for (String worldKey : worldKeys) {
|
||||||
// Check if the World is already loaded within the Plugin.
|
// Check if the World is already loaded within the Plugin.
|
||||||
if (worlds.containsKey(worldKey)) {
|
if (this.worlds.containsKey(worldKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Grab the initial values from the config file.
|
// Grab the initial values from the config file.
|
||||||
String environment = configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
|
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||||
String seedString = configWorlds.getString("worlds." + worldKey + ".seed", "");
|
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", "");
|
||||||
|
|
||||||
log(Level.INFO, "Loading World & Settings - '" + worldKey + "' - " + environment);
|
log(Level.INFO, "Loading World & Settings - '" + worldKey + "' - " + environment);
|
||||||
|
|
||||||
@ -426,21 +426,21 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
if (seed != null) {
|
if (seed != null) {
|
||||||
if (customGenerator != null) {
|
if (customGenerator != null) {
|
||||||
World world = getServer().createWorld(name, env, seed, customGenerator);
|
World world = getServer().createWorld(name, env, seed, customGenerator);
|
||||||
worlds.put(name, new MVWorld(world, configWorlds, this, seed, envString)); // Place the World into the HashMap.
|
this.worlds.put(name, new MVWorld(world, this.configWorlds, this, seed, envString)); // Place the World into the HashMap.
|
||||||
log(Level.INFO, "Loading World & Settings - '" + name + "' - " + envString + " with seed: " + seed);
|
log(Level.INFO, "Loading World & Settings - '" + name + "' - " + envString + " with seed: " + seed);
|
||||||
} else {
|
} else {
|
||||||
World world = getServer().createWorld(name, env, seed);
|
World world = getServer().createWorld(name, env, seed);
|
||||||
worlds.put(name, new MVWorld(world, configWorlds, this, seed, envString)); // Place the World into the HashMap.
|
this.worlds.put(name, new MVWorld(world, this.configWorlds, this, seed, envString)); // Place the World into the HashMap.
|
||||||
log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " with seed: " + seed);
|
log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env + " with seed: " + seed);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (customGenerator != null) {
|
if (customGenerator != null) {
|
||||||
World world = getServer().createWorld(name, env, customGenerator);
|
World world = getServer().createWorld(name, env, customGenerator);
|
||||||
worlds.put(name, new MVWorld(world, configWorlds, this, null, envString)); // Place the World into the HashMap.
|
this.worlds.put(name, new MVWorld(world, this.configWorlds, this, null, envString)); // Place the World into the HashMap.
|
||||||
log(Level.INFO, "Loading World & Settings - '" + name + "' - " + envString);
|
log(Level.INFO, "Loading World & Settings - '" + name + "' - " + envString);
|
||||||
} else {
|
} else {
|
||||||
World world = getServer().createWorld(name, env);
|
World world = getServer().createWorld(name, env);
|
||||||
worlds.put(name, new MVWorld(world, configWorlds, this, null, envString)); // Place the World into the HashMap.
|
this.worlds.put(name, new MVWorld(world, this.configWorlds, this, null, envString)); // Place the World into the HashMap.
|
||||||
log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env);
|
log(Level.INFO, "Loading World & Settings - '" + name + "' - " + env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -455,8 +455,8 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
* @return True if success, false if failure.
|
* @return True if success, false if failure.
|
||||||
*/
|
*/
|
||||||
public boolean unloadWorld(String name) {
|
public boolean unloadWorld(String name) {
|
||||||
if (worlds.containsKey(name)) {
|
if (this.worlds.containsKey(name)) {
|
||||||
worlds.remove(name);
|
this.worlds.remove(name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -470,8 +470,8 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
public boolean removeWorld(String name) {
|
public boolean removeWorld(String name) {
|
||||||
unloadWorld(name);
|
unloadWorld(name);
|
||||||
configWorlds.removeProperty("worlds." + name);
|
this.configWorlds.removeProperty("worlds." + name);
|
||||||
configWorlds.save();
|
this.configWorlds.save();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,11 +530,11 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public MVPlayerSession getPlayerSession(Player player) {
|
public MVPlayerSession getPlayerSession(Player player) {
|
||||||
if (playerSessions.containsKey(player.getName())) {
|
if (this.playerSessions.containsKey(player.getName())) {
|
||||||
return playerSessions.get(player.getName());
|
return this.playerSessions.get(player.getName());
|
||||||
} else {
|
} else {
|
||||||
playerSessions.put(player.getName(), new MVPlayerSession(player, configMV, this));
|
this.playerSessions.put(player.getName(), new MVPlayerSession(player, this.configMV, this));
|
||||||
return playerSessions.get(player.getName());
|
return this.playerSessions.get(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,7 +572,7 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
sender.sendMessage("This plugin is Disabled!");
|
sender.sendMessage("This plugin is Disabled!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return commandManager.dispatch(sender, command, commandLabel, args);
|
return this.commandManager.dispatch(sender, command, commandLabel, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -600,7 +600,7 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Messaging getMessaging() {
|
public Messaging getMessaging() {
|
||||||
return messaging;
|
return this.messaging;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -627,11 +627,11 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CommandManager getCommandManager() {
|
public CommandManager getCommandManager() {
|
||||||
return commandManager;
|
return this.commandManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTag() {
|
public String getTag() {
|
||||||
return tag;
|
return this.tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -659,8 +659,8 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ChunkGenerator getChunkGenFromEnv(String env) {
|
private ChunkGenerator getChunkGenFromEnv(String env) {
|
||||||
if (worldGenerators.containsKey(env)) {
|
if (this.worldGenerators.containsKey(env)) {
|
||||||
return worldGenerators.get(env);
|
return this.worldGenerators.get(env);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -686,7 +686,7 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
public void queueCommand(CommandSender sender, String commandName, String methodName, String[] args, Class<?>[] paramTypes, String success, String fail) {
|
public void queueCommand(CommandSender sender, String commandName, String methodName, String[] args, Class<?>[] paramTypes, String success, String fail) {
|
||||||
cancelQueuedCommand(sender);
|
cancelQueuedCommand(sender);
|
||||||
queuedCommands.add(new QueuedCommand(methodName, args, paramTypes, sender, Calendar.getInstance(), this, success, fail));
|
this.queuedCommands.add(new QueuedCommand(methodName, args, paramTypes, sender, Calendar.getInstance(), this, success, fail));
|
||||||
sender.sendMessage("The command " + ChatColor.RED + commandName + ChatColor.WHITE + " has been halted due to the fact that it could break something!");
|
sender.sendMessage("The command " + ChatColor.RED + commandName + ChatColor.WHITE + " has been halted due to the fact that it could break something!");
|
||||||
sender.sendMessage("If you still wish to execute " + ChatColor.RED + commandName + ChatColor.WHITE + ", please type: " + ChatColor.GREEN + "/mvconfirm " + ChatColor.GOLD + "YES");
|
sender.sendMessage("If you still wish to execute " + ChatColor.RED + commandName + ChatColor.WHITE + ", please type: " + ChatColor.GREEN + "/mvconfirm " + ChatColor.GOLD + "YES");
|
||||||
sender.sendMessage(ChatColor.GREEN + "/mvconfirm" + ChatColor.WHITE + " will only be available for 10 seconds.");
|
sender.sendMessage(ChatColor.GREEN + "/mvconfirm" + ChatColor.WHITE + " will only be available for 10 seconds.");
|
||||||
@ -699,7 +699,7 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean confirmQueuedCommand(CommandSender sender) {
|
public boolean confirmQueuedCommand(CommandSender sender) {
|
||||||
for (QueuedCommand com : queuedCommands) {
|
for (QueuedCommand com : this.queuedCommands) {
|
||||||
if (com.getSender().equals(sender)) {
|
if (com.getSender().equals(sender)) {
|
||||||
if (com.execute()) {
|
if (com.execute()) {
|
||||||
sender.sendMessage(com.getSuccess());
|
sender.sendMessage(com.getSuccess());
|
||||||
@ -720,14 +720,14 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
public void cancelQueuedCommand(CommandSender sender) {
|
public void cancelQueuedCommand(CommandSender sender) {
|
||||||
QueuedCommand c = null;
|
QueuedCommand c = null;
|
||||||
for (QueuedCommand com : queuedCommands) {
|
for (QueuedCommand com : this.queuedCommands) {
|
||||||
if (com.getSender().equals(sender)) {
|
if (com.getSender().equals(sender)) {
|
||||||
c = com;
|
c = com;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
// Each person is allowed at most one queued command.
|
// Each person is allowed at most one queued command.
|
||||||
queuedCommands.remove(c);
|
this.queuedCommands.remove(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,7 +735,18 @@ public class MultiverseCore extends JavaPlugin {
|
|||||||
return this.worldGenerators.keySet();
|
return this.worldGenerators.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<MVWorld> getWorlds() {
|
public Collection<MVWorld> getMVWorlds() {
|
||||||
return this.worlds.values();
|
return this.worlds.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MVWorld getMVWorld(String name) {
|
||||||
|
if(this.worlds.containsKey(name)) {
|
||||||
|
return this.worlds.get(name);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMVWorld(String name) {
|
||||||
|
return this.worlds.containsKey(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class CoordCommand extends BaseCommand {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
p.sendMessage(ChatColor.RED + "World: " + ChatColor.WHITE + p.getWorld().getName());
|
p.sendMessage(ChatColor.RED + "World: " + ChatColor.WHITE + p.getWorld().getName());
|
||||||
p.sendMessage(ChatColor.RED + "World Scale: " + ChatColor.WHITE + this.plugin.worlds.get(p.getWorld().getName()).scaling);
|
p.sendMessage(ChatColor.RED + "World Scale: " + ChatColor.WHITE + this.plugin.getMVWorld(p.getWorld().getName()).scaling);
|
||||||
p.sendMessage(ChatColor.RED + "Coordinates: " + ChatColor.WHITE + this.locMan.strCoords(p.getLocation()));
|
p.sendMessage(ChatColor.RED + "Coordinates: " + ChatColor.WHITE + this.locMan.strCoords(p.getLocation()));
|
||||||
p.sendMessage(ChatColor.RED + "Direction: " + ChatColor.WHITE + this.locMan.getDirection(p.getLocation()));
|
p.sendMessage(ChatColor.RED + "Direction: " + ChatColor.WHITE + this.locMan.getDirection(p.getLocation()));
|
||||||
p.sendMessage(ChatColor.RED + "Block: " + ChatColor.WHITE + Material.getMaterial(p.getWorld().getBlockTypeIdAt(p.getLocation())));
|
p.sendMessage(ChatColor.RED + "Block: " + ChatColor.WHITE + Material.getMaterial(p.getWorld().getBlockTypeIdAt(p.getLocation())));
|
||||||
|
@ -37,7 +37,7 @@ public class CreateCommand extends BaseCommand {
|
|||||||
seed = args[2];
|
seed = args[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new File(worldName).exists() || this.plugin.worlds.containsKey(worldName)) {
|
if (new File(worldName).exists() || this.plugin.isMVWorld(worldName)) {
|
||||||
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
|
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
|
||||||
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
|
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
|
||||||
return;
|
return;
|
||||||
|
@ -25,7 +25,7 @@ public class ImportCommand extends BaseCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
String worldName = args[0];
|
String worldName = args[0];
|
||||||
if (this.plugin.worlds.containsKey(worldName) && new File(worldName).exists()) {
|
if (this.plugin.isMVWorld(worldName) && new File(worldName).exists()) {
|
||||||
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
|
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ public class InfoCommand extends BaseCommand {
|
|||||||
} else {
|
} else {
|
||||||
worldName = args[0];
|
worldName = args[0];
|
||||||
}
|
}
|
||||||
if (this.plugin.worlds.containsKey(worldName)) {
|
if (this.plugin.isMVWorld(worldName)) {
|
||||||
for (String s : buildEntireCommand(this.plugin.worlds.get(worldName))) {
|
for (String s : buildEntireCommand(this.plugin.getMVWorld(worldName))) {
|
||||||
sender.sendMessage(s);
|
sender.sendMessage(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class ListCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String output = ChatColor.LIGHT_PURPLE + "Worlds which you can view:\n";
|
String output = ChatColor.LIGHT_PURPLE + "Worlds which you can view:\n";
|
||||||
for (MVWorld world : this.plugin.worlds.values()) {
|
for (MVWorld world : this.plugin.getMVWorlds()) {
|
||||||
|
|
||||||
if (p != null && (!this.plugin.ph.canEnterWorld(p, world.getCBWorld()))) {
|
if (p != null && (!this.plugin.ph.canEnterWorld(p, world.getCBWorld()))) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -2,28 +2,62 @@ package com.onarandombox.MultiverseCore.command.commands;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.MVWorld;
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
import com.onarandombox.MultiverseCore.command.BaseCommand;
|
||||||
|
|
||||||
|
enum Action{Set, Add, Remove}
|
||||||
public class ModifyCommand extends BaseCommand {
|
public class ModifyCommand extends BaseCommand {
|
||||||
|
|
||||||
public ModifyCommand(MultiverseCore plugin) {
|
public ModifyCommand(MultiverseCore plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.name = "Modify a World";
|
this.name = "Modify a World";
|
||||||
this.description = "Modify various aspects of worlds";
|
this.description = "Modify various aspects of worlds. See the help wiki for how to use this command properly. If you do not include a world, the current world will be used";
|
||||||
this.usage = "/mvmodify" + ChatColor.GREEN + " {WORLD} {TYPE}" + ChatColor.GOLD + " [SEED]";
|
this.usage = "/mvmodify" + ChatColor.GOLD + " [WORLD] " + ChatColor.GREEN + "{SET|ADD|REMOVE} {VALUE} {PROPERTY}";
|
||||||
this.minArgs = 2;
|
this.minArgs = 3;
|
||||||
this.maxArgs = 3;
|
this.maxArgs = 4;
|
||||||
this.identifiers.add("mvcreate");
|
this.identifiers.add("mvmodify");
|
||||||
this.permission = "multiverse.world.create";
|
this.permission = "multiverse.world.modify";
|
||||||
this.requiresOp = true;
|
this.requiresOp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
// TODO Currently only NON-List items will be supported
|
// We NEED a world from the command line
|
||||||
|
if(args.length == 3 && !(sender instanceof Player)){
|
||||||
|
sender.sendMessage("From the command line, WORLD is required.");
|
||||||
|
sender.sendMessage("Nothing changed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MVWorld world;
|
||||||
|
Action action;
|
||||||
|
String value;
|
||||||
|
String property;
|
||||||
|
Player p;
|
||||||
|
if(args.length == 3) {
|
||||||
|
p = (Player) sender;
|
||||||
|
world = plugin.getMVWorld(p.getWorld().getName());
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Action getActionEnum(String action) {
|
||||||
|
if(action.equalsIgnoreCase("set")) {
|
||||||
|
return Action.Set;
|
||||||
|
}
|
||||||
|
if(action.equalsIgnoreCase("add") || action.equalsIgnoreCase("+")) {
|
||||||
|
return Action.Add;
|
||||||
|
}
|
||||||
|
if(action.equalsIgnoreCase("remove") || action.equalsIgnoreCase("-")) {
|
||||||
|
return Action.Remove;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,18 +38,18 @@ public class WhoCommand extends BaseCommand {
|
|||||||
List<MVWorld> worlds = new ArrayList<MVWorld>();
|
List<MVWorld> worlds = new ArrayList<MVWorld>();
|
||||||
|
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (this.plugin.worlds.containsKey(args[0])) {
|
if (this.plugin.isMVWorld(args[0])) {
|
||||||
worlds.add(this.plugin.worlds.get(args[0]));
|
worlds.add(this.plugin.getMVWorld(args[0]));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + "World does not exist");
|
sender.sendMessage(ChatColor.RED + "World does not exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
worlds = new ArrayList<MVWorld>(this.plugin.getWorlds());
|
worlds = new ArrayList<MVWorld>(this.plugin.getMVWorlds());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MVWorld world : worlds) {
|
for (MVWorld world : worlds) {
|
||||||
if (!(this.plugin.worlds.containsKey(world.name))) {
|
if (!(this.plugin.isMVWorld(world.name))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ public class Destination {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we only found one param, assume world, but still check for validity
|
// If we only found one param, assume world, but still check for validity
|
||||||
if (items.length == 1 && plugin.worlds.containsKey(items[0])) {
|
if (items.length == 1 && plugin.isMVWorld(items[0])) {
|
||||||
return new Destination(items[0], DestinationType.World);
|
return new Destination(items[0], DestinationType.World);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items[0].equalsIgnoreCase("w") && plugin.worlds.containsKey(items[0])) {
|
if (items[0].equalsIgnoreCase("w") && plugin.isMVWorld(items[0])) {
|
||||||
return new Destination(items[1], DestinationType.World);
|
return new Destination(items[1], DestinationType.World);
|
||||||
} else if (items[0].equalsIgnoreCase("p")) {
|
} else if (items[0].equalsIgnoreCase("p")) {
|
||||||
// TODO: Check for a valid portal, we can't right now, as portals aren't really in yet.
|
// TODO: Check for a valid portal, we can't right now, as portals aren't really in yet.
|
||||||
|
Loading…
Reference in New Issue
Block a user