mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-16 12:31:59 +01:00
C'mon, avoiding bad style can't be that hard!
This commit is contained in:
parent
5435fca6b3
commit
6861021c7a
@ -123,20 +123,24 @@ public class MVWorld implements MultiverseWorld {
|
||||
this.propertyList.put("color", fac.getNewProperty("color", EnglishChatColor.WHITE, "alias.color",
|
||||
"Sorry, 'color' must either one of: " + EnglishChatColor.getAllColors()));
|
||||
this.propertyList.put("pvp", fac.getNewProperty("pvp", true, "pvp",
|
||||
"Sorry, 'pvp' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "setActualPVP"));
|
||||
"Sorry, 'pvp' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
|
||||
+ "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "setActualPVP"));
|
||||
this.propertyList.put("scale", fac.getNewProperty("scale", this.getDefaultScale(this.environment), "scale",
|
||||
"Scale must be a positive double value. ex: " + ChatColor.GOLD + "2.3", "verifyScaleSetProperly"));
|
||||
this.propertyList.put("respawn", fac.getNewProperty("respawn", "", "respawnworld",
|
||||
"You must set this to the " + ChatColor.GOLD + " NAME" + ChatColor.RED + " not alias of a world."));
|
||||
this.propertyList.put("weather", fac.getNewProperty("weather", true, "allowweather",
|
||||
"Sorry, 'weather' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "setActualWeather"));
|
||||
"Sorry, 'weather' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
|
||||
+ "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "setActualWeather"));
|
||||
this.propertyList.put("difficulty", fac.getNewProperty("difficulty", Difficulty.EASY,
|
||||
"Difficulty must be set as one of the following: " + ChatColor.GREEN + "peaceful "
|
||||
+ ChatColor.AQUA + "easy " + ChatColor.GOLD + "normal " + ChatColor.RED + "hard"));
|
||||
this.propertyList.put("animals", fac.getNewProperty("animals", true, "animals.spawn",
|
||||
"Sorry, 'animals' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "syncMobs"));
|
||||
"Sorry, 'animals' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
|
||||
+ "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "syncMobs"));
|
||||
this.propertyList.put("monsters", fac.getNewProperty("monsters", true, "monsters.spawn",
|
||||
"Sorry, 'monsters' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "syncMobs"));
|
||||
"Sorry, 'monsters' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
|
||||
+ "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "syncMobs"));
|
||||
this.propertyList.put("currency", fac.getNewProperty("currency", -1, "entryfee.currency",
|
||||
"Currency must be an integer between -1 and the highest Minecraft item ID."));
|
||||
this.propertyList.put("price", fac.getNewProperty("price", 0.0, "entryfee.price",
|
||||
@ -155,7 +159,8 @@ 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 + ".", "setActualKeepSpawnInMemory"));
|
||||
"Sorry, 'memory' must either be:" + ChatColor.GREEN + " true "
|
||||
+ ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + ".", "setActualKeepSpawnInMemory"));
|
||||
this.propertyList.put("spawn", fac.getNewProperty("spawn", this.world.getSpawnLocation(), "spawn",
|
||||
"There is no help available for this variable. Go bug Rigby90 about it.", "setActualKeepSpawnInMemory"));
|
||||
this.propertyList.put("autoload", fac.getNewProperty("autoload", true,
|
||||
@ -201,12 +206,20 @@ public class MVWorld implements MultiverseWorld {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the active PVP-property to set the "actual" PVP-property.
|
||||
* @return True if the property was successfully set.
|
||||
*/
|
||||
public boolean setActualPVP() {
|
||||
// Set the PVP mode
|
||||
this.world.setPVP(this.getKnownProperty("pvp", Boolean.class).getValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the active scale-property to set the "actual" scale-property.
|
||||
* @return True if the property was successfully set.
|
||||
*/
|
||||
public boolean verifyScaleSetProperly() {
|
||||
// Ensure the scale is above 0
|
||||
if (this.getKnownProperty("scale", Double.class).getValue() <= 0) {
|
||||
@ -217,12 +230,20 @@ public class MVWorld implements MultiverseWorld {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the active keepSpawnInMemory-property to set the "actual" property.
|
||||
* @return True if the property was successfully set.
|
||||
*/
|
||||
public boolean setActualKeepSpawnInMemory() {
|
||||
// Ensure the memory setting is correct
|
||||
this.world.setKeepSpawnInMemory(this.getKnownProperty("memory", Boolean.class).getValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the active spawn-property to set the "actual" property.
|
||||
* @return True if the property was successfully set.
|
||||
*/
|
||||
public boolean setActualSpawn() {
|
||||
// Set the spawn location
|
||||
Location spawnLocation = this.getKnownProperty("spawn", Location.class).getValue();
|
||||
@ -497,7 +518,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
}
|
||||
if (property.parseValue(value)) {
|
||||
if (property instanceof MVActiveConfigProperty) {
|
||||
return this.setActiveProperty((MVActiveConfigProperty) property);
|
||||
return this.setActiveProperty((MVActiveConfigProperty<?>) property);
|
||||
}
|
||||
this.saveConfig();
|
||||
return true;
|
||||
@ -505,9 +526,9 @@ public class MVWorld implements MultiverseWorld {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean setActiveProperty(MVActiveConfigProperty property) {
|
||||
private boolean setActiveProperty(MVActiveConfigProperty<?> property) {
|
||||
try {
|
||||
if(property.getMethod() == null) {
|
||||
if (property.getMethod() == null) {
|
||||
// This property did not have a method.
|
||||
return true;
|
||||
}
|
||||
@ -867,6 +888,10 @@ public class MVWorld implements MultiverseWorld {
|
||||
this.setKnownProperty("weather", weather + "", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the active weather-property to set the "actual" property.
|
||||
* @return True if the property was successfully set.
|
||||
*/
|
||||
public boolean setActualWeather() {
|
||||
// Disable any current weather
|
||||
if (!this.getKnownProperty("weather", Boolean.class).getValue()) {
|
||||
@ -1093,6 +1118,10 @@ public class MVWorld implements MultiverseWorld {
|
||||
return String.format("%d:%02d", hours, minutes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the active time-property to set the "actual" property.
|
||||
* @return True if the property was successfully set.
|
||||
*/
|
||||
public boolean setActualTime() {
|
||||
return this.setTime(this.getKnownProperty("time", String.class).toString());
|
||||
}
|
||||
|
@ -326,7 +326,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Priority.Low, this); // Let plugins which specialize in (re)spawning carry more weight.
|
||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, this.playerListener, Priority.Low, this); // Let plugins which specialize in (re)spawning carry more weight.
|
||||
pm.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Priority.Normal, this); // To prepend the world name
|
||||
pm.registerEvent(Event.Type.PLAYER_PORTAL, this.playerListener, Priority.High, this); // We want this high to have it go last, so it can cancel if needbe.
|
||||
pm.registerEvent(Event.Type.PLAYER_PORTAL, this.playerListener, Priority.High, this);
|
||||
// We want this high to have it go last, so it can cancel if needbe.
|
||||
|
||||
pm.registerEvent(Event.Type.PLAYER_PORTAL, this.portalAdjustListener, Priority.Lowest, this); // To handle portal correction
|
||||
pm.registerEvent(Event.Type.PLAYER_CHANGED_WORLD, this.playerListener, Priority.Monitor, this); // To switch gamemode
|
||||
|
||||
|
@ -47,6 +47,7 @@ public class ActiveStringConfigProperty implements MVActiveConfigProperty<String
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
@ -55,13 +55,13 @@ public class ConfigPropertyFactory {
|
||||
* @param name The name of this ConifgProperty
|
||||
* @param defaultValue The default value.
|
||||
* @param help What string is shown for help.
|
||||
* @param node
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param method The method that should be executed.
|
||||
* @return The ActiveStringConfigProperty
|
||||
*/
|
||||
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String help, String node, String method) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, help, node, method);
|
||||
}
|
||||
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String help, String node, String method) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, help, node, method);
|
||||
}
|
||||
|
||||
// Integers
|
||||
/**
|
||||
@ -116,17 +116,18 @@ public class ConfigPropertyFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String node, String help, String method) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, node, help, method);
|
||||
}
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @param method The name of the method that's used to set this property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String node, String help, String method) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, node, help, method);
|
||||
}
|
||||
|
||||
// Strings
|
||||
/**
|
||||
@ -265,6 +266,7 @@ public class ConfigPropertyFactory {
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @param method The name of the method that's used to set this property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String node, String help, String method) {
|
||||
|
@ -7,6 +7,11 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
/**
|
||||
* An "active" {@link MVConfigProperty} that uses the specified method to be "actually" set.
|
||||
* @param <T> The type of the config-property.
|
||||
* @see MVConfigProperty
|
||||
*/
|
||||
public interface MVActiveConfigProperty<T> extends MVConfigProperty<T> {
|
||||
/**
|
||||
* Gets the method that will be executed.
|
||||
|
@ -152,6 +152,7 @@ public class WorldManager implements MVWorldManager {
|
||||
* @param generator The name of the generator plugin. This should be something like CleanRoomGenerator.
|
||||
* @return True if the plugin exists and is enabled, false if not.
|
||||
*/
|
||||
// TODO maybe remove this since it's unused?
|
||||
private boolean pluginExists(String generator) {
|
||||
Plugin myPlugin = this.plugin.getServer().getPluginManager().getPlugin(generator);
|
||||
return myPlugin != null && myPlugin.isEnabled();
|
||||
|
Loading…
Reference in New Issue
Block a user