Removed deprecated items, Add autoload (Fixes #241)

This commit is contained in:
Eric Stokes 2011-11-22 21:01:00 -07:00
parent 8803374126
commit 5d932060ee
10 changed files with 72 additions and 66 deletions

View File

@ -1,17 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore;
/**
* Dummy class to make old MV Plugins not explode.
* If this loads, the user WILL get a severe telling them to update said plugin!
* WILL BE DELETED ON 11/1/11
*/
@Deprecated
public interface LoggablePlugin extends com.onarandombox.MultiverseCore.api.LoggablePlugin {
}

View File

@ -1,20 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore;
/**
* Dummy class to make old MV Plugins not explode.
* If this loads, the user WILL get a severe telling them to update said plugin!
* WILL BE DELETED ON 11/1/11
*/
@Deprecated
public class MVPermissions extends com.onarandombox.MultiverseCore.utils.MVPermissions {
public MVPermissions(MultiverseCore plugin) {
super(plugin);
}
}

View File

@ -1,17 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore;
/**
* Dummy class to make old MV Plugins not explode.
* If this loads, the user WILL get a severe telling them to update said plugin!
* WILL BE DELETED ON 11/1/11
*/
@Deprecated
public interface MVPlugin extends com.onarandombox.MultiverseCore.api.MVPlugin {
}

View File

@ -104,6 +104,7 @@ public class MVWorld implements MultiverseWorld {
this.propertyList.put("gamemode", fac.getNewProperty("gamemode", GameMode.SURVIVAL, "GameMode must be set as one of the following: " + ChatColor.RED + "survival " + ChatColor.GREEN + "creative "));
this.propertyList.put("memory", fac.getNewProperty("keepspawninmemory", true, "keepspawninmemory", "Sorry, 'memory' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
this.propertyList.put("spawn", fac.getNewProperty("spawn", this.world.getSpawnLocation(), "There is no help available for this variable. Go bug Rigby90 about it."));
this.propertyList.put("autoload", fac.getNewProperty("autoload", true, "Set this to false ONLY if you don't want this world to load itself on server restart."));
((LocationConfigProperty) this.getKnownProperty("spawn")).setValue(this.readSpawnFromConfig(this.getCBWorld()));
// Set aliases
@ -692,4 +693,15 @@ public class MVWorld implements MultiverseWorld {
public boolean getAdjustSpawn() {
return ((BooleanConfigProperty) this.getKnownProperty("adjustspawn")).getValue();
}
@Override
public void setAutoLoad(boolean adjust) {
((BooleanConfigProperty) this.getKnownProperty("autoload")).setValue(adjust);
saveConfig();
}
@Override
public boolean getAutoLoad() {
return ((BooleanConfigProperty) this.getKnownProperty("autoload")).getValue();
}
}

View File

@ -260,7 +260,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
/** Function to Register all the Events needed. */
private void registerEvents() {
System.out.print(getServer().getName());
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_TELEPORT, this.playerListener, Priority.Highest, this); // Cancel Teleports if needed.

View File

@ -13,6 +13,7 @@ import org.bukkit.World.Environment;
import org.bukkit.generator.ChunkGenerator;
import java.util.Collection;
import java.util.List;
/**
* Multiverse 2 World Manager API
@ -149,4 +150,6 @@ public interface MVWorldManager {
* @return A Multiverse world that players will spawn in or null if no MV world has been set.
*/
public MultiverseWorld getSpawnWorld();
public List<String> getUnloadedWorlds();
}

View File

@ -482,4 +482,22 @@ public interface MultiverseWorld {
* @return True if Multiverse should adjust the spawn, false if not.
*/
public boolean getAdjustSpawn();
/**
* Sets whether or not Multiverse should auto-load this world.
*
* True is default.
*
* @param autoLoad True if multiverse should autoload this world the spawn, false if not.
*/
public void setAutoLoad(boolean autoLoad);
/**
* Gets whether or not Multiverse should auto-load this world.
*
* @return True if Multiverse should auto-load this world.
*/
public boolean getAutoLoad();
}

View File

@ -65,6 +65,11 @@ public class ListCommand extends MultiverseCommand {
output += outputCache;
}
}
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
output += ChatColor.GRAY + name + " - UNLOADED\n";
}
}
String[] response = output.split("\n");
for (String msg : response) {
sender.sendMessage(msg);

View File

@ -49,7 +49,6 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
return false;
}
this.value = value;
System.out.println(this.value.getText());
this.section.set(configNode, this.value.getText());
return true;
}

View File

@ -23,10 +23,7 @@ import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.logging.Level;
/**
@ -37,15 +34,18 @@ import java.util.logging.Level;
public class WorldManager implements MVWorldManager {
private MultiverseCore plugin;
private PurgeWorlds worldPurger;
private HashMap<String, MultiverseWorld> worlds;
private Map<String, MultiverseWorld> worlds;
private List<String> unloadedWorlds;
private FileConfiguration configWorlds = null;
public WorldManager(MultiverseCore core) {
this.plugin = core;
this.worlds = new HashMap<String, MultiverseWorld>();
this.unloadedWorlds = new ArrayList<String>();
this.worldPurger = new PurgeWorlds(this.plugin);
}
/** {@inheritDoc} */
public boolean addWorld(String name, Environment env, String seedString, String generator) {
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
@ -96,6 +96,9 @@ public class WorldManager implements MVWorldManager {
MultiverseWorld mvworld = new MVWorld(world, this.configWorlds, this.plugin, seed, generator);
this.worldPurger.purgeWorld(null, mvworld);
this.worlds.put(name, mvworld);
if (this.unloadedWorlds.contains(name)) {
this.unloadedWorlds.remove(name);
}
return true;
}
@ -154,12 +157,14 @@ public class WorldManager implements MVWorldManager {
this.worlds.remove(name);
this.plugin.log(Level.INFO, "World '" + name + "' was unloaded from memory.");
this.unloadWorldFromBukkit(name, true);
this.unloadedWorlds.add(name);
return true;
} else if (this.plugin.getServer().getWorld(name) != null) {
this.plugin.log(Level.WARNING, "Hmm Multiverse does not know about this world but it's still loaded in memory.");
this.plugin.log(Level.WARNING, "To be on the safe side, you should import it then try unloading again...");
this.plugin.log(Level.WARNING, "Hmm Multiverse does not know about this world but it's loaded in memory.");
this.plugin.log(Level.WARNING, "To unload it using multiverse, use:");
this.plugin.log(Level.WARNING, "/mv import " + name + " " + this.plugin.getServer().getWorld(name).getEnvironment().toString());
} else {
this.plugin.log(Level.INFO, "The world " + name + " was already unloaded/did not exist.");
this.plugin.log(Level.INFO, "Multiverse does not know about " + name + ".");
}
return false;
}
@ -168,6 +173,10 @@ public class WorldManager implements MVWorldManager {
public boolean loadWorld(String name) {
// Check if the World is already loaded
if (this.worlds.containsKey(name)) {
// Ensure it's not unloaded, since it IS loaded.
if (this.unloadedWorlds.contains(name)) {
this.unloadedWorlds.remove(name);
}
return true;
}
@ -182,7 +191,9 @@ public class WorldManager implements MVWorldManager {
String generatorString = this.configWorlds.getString("worlds." + name + ".generator");
addWorld(name, this.plugin.getEnvFromString(environment), seedString, generatorString);
if (this.unloadedWorlds.contains(name)) {
this.unloadedWorlds.remove(name);
}
return true;
} else {
return false;
@ -228,7 +239,7 @@ public class WorldManager implements MVWorldManager {
this.plugin.log(Level.SEVERE, "Please check your file permissions on " + name);
}
return deletedWorld;
} catch (Exception e) {
} catch (Throwable e) {
this.plugin.log(Level.SEVERE, "Hrm, something didn't go as planned. Here's an exception for ya.");
this.plugin.log(Level.SEVERE, "You can go politely explain your situation in #multiverse on esper.net");
this.plugin.log(Level.SEVERE, "But from here, it looks like your folder is oddly named.");
@ -377,6 +388,14 @@ public class WorldManager implements MVWorldManager {
if (this.worlds.containsKey(worldKey)) {
continue;
}
// If autoload was set to false, don't load this one.
if (!this.configWorlds.getBoolean("worlds." + worldKey + ".autoload", true)) {
if (!this.unloadedWorlds.contains(worldKey)) {
this.unloadedWorlds.add(worldKey);
}
continue;
}
// Grab the initial values from the config file.
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL"); // Grab the Environment as a String.
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", "");
@ -427,4 +446,9 @@ public class WorldManager implements MVWorldManager {
public MultiverseWorld getSpawnWorld() {
return this.getMVWorld(this.plugin.getServer().getWorlds().get(0));
}
@Override
public List<String> getUnloadedWorlds() {
return this.unloadedWorlds;
}
}