mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-23 16:51:28 +01:00
Added item specific help to config properties.
This commit is contained in:
parent
b19799f764
commit
65b375edeb
@ -79,24 +79,31 @@ public class MVWorld implements MultiverseWorld {
|
||||
// Start NEW config awesomeness.
|
||||
ConfigPropertyFactory fac = new ConfigPropertyFactory(this.worldSection);
|
||||
this.propertyList = new HashMap<String, MVConfigProperty>();
|
||||
this.propertyList.put("hidden", fac.getNewProperty("hidden", false));
|
||||
// The format of these are either:
|
||||
// getNewProperty(name, defaultValue, helpText)
|
||||
// or
|
||||
// getNewProperty(name, defaultValue, yamlConfigNode, helpText)
|
||||
//
|
||||
// If the first type is used, name is used as the yamlConfigNode
|
||||
this.propertyList.put("hidden", fac.getNewProperty("hidden", false, "Sorry, 'hidden' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
this.propertyList.put("alias", fac.getNewProperty("alias", "", "alias.name"));
|
||||
this.propertyList.put("color", fac.getNewProperty("color", EnglishChatColor.WHITE, "alias.color"));
|
||||
this.propertyList.put("pvp", fac.getNewProperty("pvp", true));
|
||||
this.propertyList.put("scale", fac.getNewProperty("scale", this.getDefaultScale(this.environment)));
|
||||
this.propertyList.put("respawn", fac.getNewProperty("respawn", "", "respawnworld"));
|
||||
this.propertyList.put("weather", fac.getNewProperty("weather", true, "allowweather"));
|
||||
this.propertyList.put("difficulty", fac.getNewProperty("difficulty", Difficulty.EASY));
|
||||
this.propertyList.put("animals", fac.getNewProperty("animals", true, "animals.spawn"));
|
||||
this.propertyList.put("monsters", fac.getNewProperty("monsters", true, "monsters.spawn"));
|
||||
this.propertyList.put("currency", fac.getNewProperty("currency", -1, "entryfee.currency"));
|
||||
this.propertyList.put("price", fac.getNewProperty("price", 0.0, "entryfee.price"));
|
||||
this.propertyList.put("hunger", fac.getNewProperty("hunger", true));
|
||||
this.propertyList.put("autoheal", fac.getNewProperty("autoheal", true));
|
||||
this.propertyList.put("adjustspawn", fac.getNewProperty("adjustspawn", true));
|
||||
this.propertyList.put("gamemode", fac.getNewProperty("gamemode", GameMode.SURVIVAL));
|
||||
this.propertyList.put("memory", fac.getNewProperty("keepspawninmemory", true, "keepspawninmemory"));
|
||||
this.propertyList.put("spawn", fac.getNewProperty("spawn", this.readSpawnFromConfig(this.getCBWorld())));
|
||||
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, "Sorry, 'hidden' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
this.propertyList.put("scale", fac.getNewProperty("scale", this.getDefaultScale(this.environment), "There is no help available for this variable. Go bug Rigby90 about it."));
|
||||
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, 'hidden' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
this.propertyList.put("difficulty", fac.getNewProperty("difficulty", Difficulty.EASY, "Difficulty must be set as one of the following: " + ChatColor.GOLD));
|
||||
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 + ". (see "));
|
||||
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 + "."));
|
||||
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", "Price must be a double formatted number like: 1.3"));
|
||||
this.propertyList.put("hunger", fac.getNewProperty("hunger", true, "Sorry, 'hidden' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
this.propertyList.put("autoheal", fac.getNewProperty("autoheal", true, "Sorry, 'hidden' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
this.propertyList.put("adjustspawn", fac.getNewProperty("adjustspawn", true, "Sorry, 'hidden' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE + "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||
this.propertyList.put("gamemode", fac.getNewProperty("gamemode", GameMode.SURVIVAL, "There is no help available for this variable. Go bug Rigby90 about it."));
|
||||
this.propertyList.put("memory", fac.getNewProperty("keepspawninmemory", true, "keepspawninmemory", "Sorry, 'hidden' 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."));
|
||||
((LocationConfigProperty) this.propertyList.get("spawn")).setValue(this.readSpawnFromConfig(this.getCBWorld()));
|
||||
|
||||
// Set aliases
|
||||
this.propertyList.put("curr", this.propertyList.get("currency"));
|
||||
@ -202,7 +209,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
|
||||
public String getColoredWorldString() {
|
||||
EnglishChatColor worldColor = ((ColorConfigProperty) this.propertyList.get("color")).getValue();
|
||||
String alias = ((StringConfigProperty) this.propertyList.get("string")).getValue();
|
||||
String alias = ((StringConfigProperty) this.propertyList.get("alias")).getValue();
|
||||
if (worldColor.getColor() == null) {
|
||||
return alias + ChatColor.WHITE;
|
||||
}
|
||||
@ -307,7 +314,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
|
||||
// TODO: Provide better feedback
|
||||
@Override
|
||||
public boolean setVariable(String name, String value) throws PropertyDoesNotExistException {
|
||||
public boolean setProperty(String name, String value) throws PropertyDoesNotExistException {
|
||||
if (this.propertyList.containsKey(name)) {
|
||||
if (this.propertyList.get(name).parseValue(value)) {
|
||||
this.saveConfig();
|
||||
@ -318,13 +325,22 @@ public class MVWorld implements MultiverseWorld {
|
||||
throw new PropertyDoesNotExistException(name);
|
||||
}
|
||||
|
||||
public String getVariable(String name) throws PropertyDoesNotExistException {
|
||||
@Override
|
||||
public String getPropertyValue(String name) throws PropertyDoesNotExistException {
|
||||
if (this.propertyList.containsKey(name)) {
|
||||
return this.propertyList.get(name).toString();
|
||||
}
|
||||
throw new PropertyDoesNotExistException(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MVConfigProperty getProperty(String name) throws PropertyDoesNotExistException {
|
||||
if (this.propertyList.containsKey(name)) {
|
||||
return this.propertyList.get(name);
|
||||
}
|
||||
throw new PropertyDoesNotExistException(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Environment getEnvironment() {
|
||||
// This variable is not settable in-game, therefore does not get a property.
|
||||
@ -613,7 +629,7 @@ public class MVWorld implements MultiverseWorld {
|
||||
|
||||
@Override
|
||||
public Location getSpawnLocation() {
|
||||
return ((LocationConfigProperty)this.propertyList.get("spawn")).getValue();
|
||||
return ((LocationConfigProperty) this.propertyList.get("spawn")).getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@ -28,14 +29,41 @@ public interface MultiverseWorld {
|
||||
public World getCBWorld();
|
||||
|
||||
/**
|
||||
* Adds the property to the given value. The property must be a {@link com.onarandombox.MultiverseCore.enums.SetProperties}.
|
||||
* Adds the property to the given value.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.SetProperties} to set.
|
||||
* @param property The name of a world property to set.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
*
|
||||
* @return True if the value was set, false if not.
|
||||
*
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
public boolean setVariable(String property, String value) throws PropertyDoesNotExistException;
|
||||
public boolean setProperty(String property, String value) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Gets the actual MVConfigProperty from this world.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
*
|
||||
* @return A valid MVWorldProperty.
|
||||
*
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
public MVConfigProperty getProperty(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Gets the string representation of a property.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
*
|
||||
* @return A valid MVWorldProperty.
|
||||
*
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
public String getPropertyValue(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
|
@ -138,7 +138,6 @@ public class InfoCommand extends MultiverseCommand {
|
||||
message.add(new FancyHeader("PVP Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.isPVPEnabled() + "", colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getPVP() + "", colors));
|
||||
message.add(new FancyMessage("Fake PVP Enabled: ", world.getFakePVP() + "", colors));
|
||||
worldInfo.add(message);
|
||||
// Page 3
|
||||
message = new ArrayList<FancyText>();
|
||||
|
@ -9,7 +9,6 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.enums.Action;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
@ -56,6 +55,10 @@ public class ModifySetCommand extends MultiverseCommand {
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// Special case for spawn:
|
||||
if (args.size() == 1) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("You must be a player to set the" + ChatColor.GREEN + " spawn");
|
||||
return;
|
||||
}
|
||||
if (args.get(0).equalsIgnoreCase("spawn")) {
|
||||
SetSpawnCommand c = new SetSpawnCommand(this.plugin);
|
||||
c.setWorldSpawn(sender);
|
||||
@ -101,10 +104,10 @@ public class ModifySetCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (world.setVariable(property, value)) {
|
||||
if (world.setProperty(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property + ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "There was an error setting " + ChatColor.GRAY + property);
|
||||
sender.sendMessage(world.getProperty(property).getHelp());
|
||||
}
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + property + ChatColor.RED + "'");
|
||||
|
@ -14,18 +14,21 @@ public class BooleanConfigProperty implements MVConfigProperty<Boolean> {
|
||||
private Boolean value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue) {
|
||||
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String help) {
|
||||
this.name = name;
|
||||
this.configNode = name;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.setValue(this.section.getBoolean(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String configNode) {
|
||||
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.setValue(this.section.getBoolean(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
@ -70,4 +73,9 @@ public class BooleanConfigProperty implements MVConfigProperty<Boolean> {
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -15,18 +15,21 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
|
||||
private EnglishChatColor value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue) {
|
||||
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String help) {
|
||||
this.name = name;
|
||||
this.configNode = name;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String configNode) {
|
||||
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
@ -69,4 +72,9 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -22,74 +22,74 @@ public class ConfigPropertyFactory {
|
||||
}
|
||||
|
||||
// Booleans
|
||||
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue);
|
||||
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String help) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String node) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, node);
|
||||
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String node, String help) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
}
|
||||
|
||||
// Integers
|
||||
public IntegerConfigProperty getNewProperty(String name, int defaultValue) {
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue);
|
||||
public IntegerConfigProperty getNewProperty(String name, int defaultValue, String help) {
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue, help) ;
|
||||
}
|
||||
|
||||
public IntegerConfigProperty getNewProperty(String name, int defaultValue, String node) {
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue, node);
|
||||
public IntegerConfigProperty getNewProperty(String name, int defaultValue, String node, String help) {
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
}
|
||||
|
||||
// Doubles
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue);
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String help) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, help) ;
|
||||
}
|
||||
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String node) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, node);
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String node, String help) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
}
|
||||
|
||||
// Strings
|
||||
public StringConfigProperty getNewProperty(String name, String defaultValue) {
|
||||
return new StringConfigProperty(this.section, name, defaultValue);
|
||||
public StringConfigProperty getNewProperty(String name, String defaultValue, String help) {
|
||||
return new StringConfigProperty(this.section, name, defaultValue, help) ;
|
||||
}
|
||||
|
||||
public StringConfigProperty getNewProperty(String name, String defaultValue, String node) {
|
||||
return new StringConfigProperty(this.section, name, defaultValue, node);
|
||||
public StringConfigProperty getNewProperty(String name, String defaultValue, String node, String help) {
|
||||
return new StringConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
}
|
||||
|
||||
// Colors
|
||||
public ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue) {
|
||||
return new ColorConfigProperty(this.section, name, defaultValue);
|
||||
public ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue, String help) {
|
||||
return new ColorConfigProperty(this.section, name, defaultValue, help) ;
|
||||
}
|
||||
|
||||
public ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue, String node) {
|
||||
return new ColorConfigProperty(this.section, name, defaultValue, node);
|
||||
public ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue, String node, String help) {
|
||||
return new ColorConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
}
|
||||
|
||||
// Difficulty
|
||||
public DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue) {
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue);
|
||||
public DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue, String help) {
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue, help) ;
|
||||
}
|
||||
|
||||
public DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue, String node) {
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue, node);
|
||||
public DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue, String node, String help) {
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
}
|
||||
|
||||
// GameMode
|
||||
public GameModeConfigProperty getNewProperty(String name, GameMode defaultValue) {
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue);
|
||||
public GameModeConfigProperty getNewProperty(String name, GameMode defaultValue, String help) {
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue, help) ;
|
||||
}
|
||||
|
||||
public GameModeConfigProperty getNewProperty(String name, GameMode defaultValue, String node) {
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue, node);
|
||||
public GameModeConfigProperty getNewProperty(String name, GameMode defaultValue, String node, String help) {
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
}
|
||||
|
||||
// GameMode
|
||||
public LocationConfigProperty getNewProperty(String name, Location defaultValue) {
|
||||
return new LocationConfigProperty(this.section, name, defaultValue);
|
||||
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String help) {
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, help) ;
|
||||
}
|
||||
|
||||
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String node) {
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, node);
|
||||
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String node, String help) {
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, node, help) ;
|
||||
}
|
||||
}
|
||||
|
@ -16,18 +16,21 @@ public class DifficultyConfigProperty implements MVConfigProperty<Difficulty> {
|
||||
private Difficulty value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue) {
|
||||
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String help) {
|
||||
this.name = name;
|
||||
this.configNode = name;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String configNode) {
|
||||
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
@ -73,4 +76,9 @@ public class DifficultyConfigProperty implements MVConfigProperty<Difficulty> {
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -14,18 +14,21 @@ public class DoubleConfigProperty implements MVConfigProperty<Double> {
|
||||
private Double value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue) {
|
||||
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String help) {
|
||||
this.name = name;
|
||||
this.configNode = name;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.setValue(this.section.getDouble(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String configNode) {
|
||||
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.setValue(this.section.getDouble(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
@ -68,4 +71,9 @@ public class DoubleConfigProperty implements MVConfigProperty<Double> {
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -16,18 +16,21 @@ public class GameModeConfigProperty implements MVConfigProperty<GameMode> {
|
||||
private GameMode value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue) {
|
||||
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String help) {
|
||||
this.name = name;
|
||||
this.configNode = name;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String configNode) {
|
||||
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
@ -73,4 +76,9 @@ public class GameModeConfigProperty implements MVConfigProperty<GameMode> {
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -14,18 +14,21 @@ public class IntegerConfigProperty implements MVConfigProperty<Integer> {
|
||||
private Integer value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue) {
|
||||
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String help) {
|
||||
this.name = name;
|
||||
this.configNode = name;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.setValue(this.section.getInt(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String configNode) {
|
||||
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.setValue(this.section.getInt(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
@ -68,4 +71,9 @@ public class IntegerConfigProperty implements MVConfigProperty<Integer> {
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
}
|
||||
|
@ -16,18 +16,21 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
|
||||
private Location value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue) {
|
||||
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String help) {
|
||||
this.name = name;
|
||||
this.configNode = name;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.setValue(this.getLocationFromConfig(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String configNode) {
|
||||
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.setValue(this.getLocationFromConfig(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
@ -57,6 +60,11 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
|
||||
return LocationManipulation.strCoordsRaw(this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setValue(Location value) {
|
||||
if (value == null) {
|
||||
|
@ -29,6 +29,13 @@ public interface MVConfigProperty<T> {
|
||||
*/
|
||||
public String toString();
|
||||
|
||||
/**
|
||||
* Gets the help string for this
|
||||
*
|
||||
* @return The value of this property as a string.
|
||||
*/
|
||||
public String getHelp();
|
||||
|
||||
/**
|
||||
* Sets the value of this property
|
||||
*
|
||||
|
@ -14,18 +14,21 @@ public class StringConfigProperty implements MVConfigProperty<String> {
|
||||
private String value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue) {
|
||||
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String help) {
|
||||
this.name = name;
|
||||
this.configNode = name;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String configNode) {
|
||||
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
@ -58,6 +61,16 @@ public class StringConfigProperty implements MVConfigProperty<String> {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help string for this
|
||||
*
|
||||
* @return The value of this property as a string.
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setValue(String value) {
|
||||
if (value == null) {
|
||||
|
@ -49,47 +49,6 @@ public class MVEntityListener extends EntityListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event - When a Entity is Damaged, we first sort out whether it is of importance to us, such as EntityVSEntity or
|
||||
* EntityVSProjectile. Then we grab the attacked and defender and check if its a player. Then deal with the PVP
|
||||
* Aspect.
|
||||
*/
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
Entity attacker;
|
||||
Entity defender;
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
|
||||
attacker = sub.getDamager();
|
||||
defender = sub.getEntity();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (attacker == null || defender == null) {
|
||||
return;
|
||||
}
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
World w = player.getWorld();
|
||||
|
||||
if (!this.worldManager.isMVWorld(w.getName())) {
|
||||
// if the world is not handled, we don't care
|
||||
return;
|
||||
}
|
||||
MultiverseWorld world = this.worldManager.getMVWorld(w.getName());
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
if (!world.isPVPEnabled() && world.getFakePVP()) {
|
||||
((Player) attacker).sendMessage(ChatColor.RED + "PVP is disabled in this World.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
|
@ -27,24 +27,11 @@ public class MVPluginListener extends ServerListener {
|
||||
/** Keep an eye out for Plugins which we can utilize. */
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if (event.getPlugin() instanceof com.onarandombox.MultiverseCore.MVPlugin) {
|
||||
this.plugin.log(Level.SEVERE, "Your version of '" + event.getPlugin() + "' is OUT OF DATE.");
|
||||
this.plugin.log(Level.SEVERE, "Please grab the latest version from:");
|
||||
this.plugin.log(Level.SEVERE, "http://bukkit.onarandombox.com/?dir=" + event.getPlugin().getDescription().getName().toLowerCase());
|
||||
this.plugin.log(Level.SEVERE, "I'm going to disable " + event.getPlugin().getDescription().getName() + " now.");
|
||||
this.plugin.log(Level.SEVERE, "IF YOU DO NOT UPDATE, YOUR SERVER WILL **NOT** FUNCTION PROPERLY!!!");
|
||||
this.plugin.getServer().getPluginManager().disablePlugin(event.getPlugin());
|
||||
}
|
||||
// Let AllPay handle all econ plugin loadings, only go for econ plugins we support
|
||||
if (Arrays.asList(AllPay.validEconPlugins).contains(event.getPlugin().getDescription().getName())) {
|
||||
this.plugin.setBank(this.plugin.getBanker().loadEconPlugin());
|
||||
}
|
||||
if (event.getPlugin().getDescription().getName().equals("MultiVerse")) {
|
||||
if (event.getPlugin().isEnabled()) {
|
||||
this.plugin.getServer().getPluginManager().disablePlugin(event.getPlugin());
|
||||
this.plugin.log(Level.WARNING, "I just disabled the old version of Multiverse for you. You should remove the JAR now, your configs have been migrated.");
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getPlugin().getDescription().getName().equals("Spout")) {
|
||||
this.plugin.setSpout();
|
||||
this.plugin.log(Level.INFO, "Spout integration enabled.");
|
||||
|
Loading…
Reference in New Issue
Block a user