mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-12-05 00:43:25 +01:00
Pull changes from master.
This commit is contained in:
parent
22a7c5ae94
commit
abb58b0563
50
pom.xml
50
pom.xml
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>OnARandomBox</id>
|
<id>pneumaticsystem</id>
|
||||||
<url>http://repo.onarandombox.com/artifactory/repo</url>
|
<url>http://pneumaticsystem.com:25578/nexus/content/groups/public</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
@ -31,9 +31,25 @@
|
|||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>jenkins</system>
|
<system>jenkins</system>
|
||||||
<url>http://ci.onarandombox.com</url>
|
<url>http://pneumaticsystem.com:25579</url>
|
||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
|
<!-- Profiles are used to detect whether this is a local or Jenkins build
|
||||||
|
and adjust the build number accordingly -->
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>jenkins</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env.BUILD_NUMBER</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<properties>
|
||||||
|
<project.build.number>${env.BUILD_NUMBER}</project.build.number>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -109,6 +125,26 @@
|
|||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>2.1.2</version>
|
<version>2.1.2</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.11</version>
|
||||||
|
<configuration>
|
||||||
|
<parallel>methods</parallel>
|
||||||
|
<threadCount>10</threadCount>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/TestCommandSender.java</exclude>
|
||||||
|
<exclude>**/TestInstanceCreator.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.surefire</groupId>
|
||||||
|
<artifactId>surefire-junit47</artifactId>
|
||||||
|
<version>2.11</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@ -187,10 +223,9 @@
|
|||||||
<!-- End of Economy Dependencies -->
|
<!-- End of Economy Dependencies -->
|
||||||
<!-- Start of Test Dependencies -->
|
<!-- Start of Test Dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.8.2</version>
|
<version>4.8.2</version>
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.powermock</groupId>
|
<groupId>org.powermock</groupId>
|
||||||
@ -219,11 +254,6 @@
|
|||||||
<version>3.0</version>
|
<version>3.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>4.8.1</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- End of Test Dependencies -->
|
<!-- End of Test Dependencies -->
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -45,7 +45,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
private String name; // The Worlds Name, EG its folder name.
|
private String name; // The Worlds Name, EG its folder name.
|
||||||
|
|
||||||
private Map<String, List<String>> masterList;
|
private Map<String, List<String>> masterList;
|
||||||
private Map<String, MVConfigProperty> propertyList;
|
private Map<String, MVConfigProperty<?>> propertyList;
|
||||||
private String generator;
|
private String generator;
|
||||||
|
|
||||||
private Permission permission;
|
private Permission permission;
|
||||||
@ -82,7 +82,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
// Start NEW config awesomeness.
|
// Start NEW config awesomeness.
|
||||||
ConfigPropertyFactory fac = new ConfigPropertyFactory(this.worldSection);
|
ConfigPropertyFactory fac = new ConfigPropertyFactory(this.worldSection);
|
||||||
this.propertyList = new HashMap<String, MVConfigProperty>();
|
this.propertyList = new HashMap<String, MVConfigProperty<?>>();
|
||||||
// The format of these are either:
|
// The format of these are either:
|
||||||
// getNewProperty(name, defaultValue, helpText)
|
// getNewProperty(name, defaultValue, helpText)
|
||||||
// or
|
// or
|
||||||
@ -109,7 +109,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
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("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."));
|
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."));
|
||||||
this.propertyList.put("bedrespawn", fac.getNewProperty("bedrespawn", true, "If a player dies in this world, shoudld they go to their bed?"));
|
this.propertyList.put("bedrespawn", fac.getNewProperty("bedrespawn", true, "If a player dies in this world, shoudld they go to their bed?"));
|
||||||
((LocationConfigProperty) this.getKnownProperty("spawn")).setValue(this.readSpawnFromConfig(this.getCBWorld()));
|
this.getKnownProperty("spawn", Location.class).setValue(this.readSpawnFromConfig(this.getCBWorld()));
|
||||||
|
|
||||||
|
|
||||||
// Set aliases
|
// Set aliases
|
||||||
@ -144,28 +144,28 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
public void changeActiveEffects() {
|
public void changeActiveEffects() {
|
||||||
// Disable any current weather
|
// Disable any current weather
|
||||||
if (!(Boolean) this.getKnownProperty("weather").getValue()) {
|
if (!this.getKnownProperty("weather", Boolean.class).getValue()) {
|
||||||
this.getCBWorld().setStorm(false);
|
this.getCBWorld().setStorm(false);
|
||||||
this.getCBWorld().setThundering(false);
|
this.getCBWorld().setThundering(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the spawn location
|
// Set the spawn location
|
||||||
Location spawnLocation = ((LocationConfigProperty) this.getKnownProperty("spawn")).getValue();
|
Location spawnLocation = this.getKnownProperty("spawn", Location.class).getValue();
|
||||||
this.getCBWorld().setSpawnLocation(spawnLocation.getBlockX(), spawnLocation.getBlockY(), spawnLocation.getBlockZ());
|
this.getCBWorld().setSpawnLocation(spawnLocation.getBlockX(), spawnLocation.getBlockY(), spawnLocation.getBlockZ());
|
||||||
|
|
||||||
// Syncronize all Mob settings
|
// Syncronize all Mob settings
|
||||||
this.syncMobs();
|
this.syncMobs();
|
||||||
|
|
||||||
// Ensure the memory setting is correct
|
// Ensure the memory setting is correct
|
||||||
this.world.setKeepSpawnInMemory(((BooleanConfigProperty) this.getKnownProperty("memory")).getValue());
|
this.world.setKeepSpawnInMemory(this.getKnownProperty("memory", Boolean.class).getValue());
|
||||||
|
|
||||||
// Set the PVP mode
|
// Set the PVP mode
|
||||||
this.world.setPVP(((BooleanConfigProperty) this.getKnownProperty("pvp")).getValue());
|
this.world.setPVP(this.getKnownProperty("pvp", Boolean.class).getValue());
|
||||||
|
|
||||||
// Ensure the scale is above 0
|
// Ensure the scale is above 0
|
||||||
if (((DoubleConfigProperty) this.getKnownProperty("scale")).getValue() <= 0) {
|
if (this.getKnownProperty("scale", Double.class).getValue() <= 0) {
|
||||||
// Disallow negative or 0 scalings.
|
// Disallow negative or 0 scalings.
|
||||||
((DoubleConfigProperty) this.getKnownProperty("scale")).setValue(1.0);
|
this.getKnownProperty("scale", Double.class).setValue(1.0);
|
||||||
this.plugin.log(Level.WARNING, "Someone tried to set a scale <= 0, defaulting to 1.");
|
this.plugin.log(Level.WARNING, "Someone tried to set a scale <= 0, defaulting to 1.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,13 +173,13 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
// TODO: Move this to a per world gamemode
|
// TODO: Move this to a per world gamemode
|
||||||
if (MultiverseCore.EnforceGameModes) {
|
if (MultiverseCore.EnforceGameModes) {
|
||||||
for (Player p : this.plugin.getServer().getWorld(this.getName()).getPlayers()) {
|
for (Player p : this.plugin.getServer().getWorld(this.getName()).getPlayers()) {
|
||||||
this.plugin.log(Level.FINER, "Setting " + p.getName() + "'s GameMode to " + this.getKnownProperty("mode").getValue().toString());
|
this.plugin.log(Level.FINER, "Setting " + p.getName() + "'s GameMode to " + this.getKnownProperty("mode", GameMode.class).getValue().toString());
|
||||||
this.plugin.getPlayerListener().handleGameMode(p, this);
|
this.plugin.getPlayerListener().handleGameMode(p, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the difficulty
|
// Set the difficulty
|
||||||
this.getCBWorld().setDifficulty(((DifficultyConfigProperty) this.getKnownProperty("diff")).getValue());
|
this.getCBWorld().setDifficulty(this.getKnownProperty("diff", Difficulty.class).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getDefaultScale(Environment environment) {
|
private double getDefaultScale(Environment environment) {
|
||||||
@ -216,8 +216,8 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getColoredWorldString() {
|
public String getColoredWorldString() {
|
||||||
EnglishChatColor worldColor = ((ColorConfigProperty) this.getKnownProperty("color")).getValue();
|
EnglishChatColor worldColor = this.getKnownProperty("color", EnglishChatColor.class).getValue();
|
||||||
String alias = ((StringConfigProperty) this.getKnownProperty("alias")).getValue();
|
String alias = this.getKnownProperty("alias", String.class).getValue();
|
||||||
if (worldColor == null) {
|
if (worldColor == null) {
|
||||||
this.setKnownProperty("color", "WHITE", null);
|
this.setKnownProperty("color", "WHITE", null);
|
||||||
return alias + ChatColor.WHITE;
|
return alias + ChatColor.WHITE;
|
||||||
@ -271,9 +271,10 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addToVariable(String property, String value) {
|
public boolean addToVariable(String property, String value) {
|
||||||
|
property = property.toLowerCase();
|
||||||
if (this.masterList.keySet().contains(property)) {
|
if (this.masterList.keySet().contains(property)) {
|
||||||
|
|
||||||
if (property.equalsIgnoreCase("animals") || property.equalsIgnoreCase("monsters")) {
|
if (property.equals("animals") || property.equals("monsters")) {
|
||||||
this.masterList.get(property).add(value.toUpperCase());
|
this.masterList.get(property).add(value.toUpperCase());
|
||||||
this.worldSection.set(property.toLowerCase() + ".exceptions", this.masterList.get(property));
|
this.worldSection.set(property.toLowerCase() + ".exceptions", this.masterList.get(property));
|
||||||
this.syncMobs();
|
this.syncMobs();
|
||||||
@ -289,15 +290,16 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFromVariable(String property, String value) {
|
public boolean removeFromVariable(String property, String value) {
|
||||||
|
property = property.toLowerCase();
|
||||||
if (this.masterList.keySet().contains(property)) {
|
if (this.masterList.keySet().contains(property)) {
|
||||||
|
|
||||||
if (property.equalsIgnoreCase("animals") || property.equalsIgnoreCase("monsters")) {
|
if (property.equals("animals") || property.equals("monsters")) {
|
||||||
this.masterList.get(property).remove(value.toUpperCase());
|
this.masterList.get(property).remove(value.toUpperCase());
|
||||||
this.worldSection.set("" + property.toLowerCase() + ".exceptions", this.masterList.get(property));
|
this.worldSection.set(property + ".exceptions", this.masterList.get(property));
|
||||||
this.syncMobs();
|
this.syncMobs();
|
||||||
} else {
|
} else {
|
||||||
this.masterList.get(property).remove(value);
|
this.masterList.get(property).remove(value);
|
||||||
this.worldSection.set("" + property.toLowerCase(), this.masterList.get(property));
|
this.worldSection.set(property, this.masterList.get(property));
|
||||||
}
|
}
|
||||||
saveConfig();
|
saveConfig();
|
||||||
return true;
|
return true;
|
||||||
@ -308,12 +310,12 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
private void syncMobs() {
|
private void syncMobs() {
|
||||||
|
|
||||||
if (this.getAnimalList().isEmpty()) {
|
if (this.getAnimalList().isEmpty()) {
|
||||||
this.world.setSpawnFlags(this.world.getAllowMonsters(), ((BooleanConfigProperty) this.getKnownProperty("animals")).getValue());
|
this.world.setSpawnFlags(this.world.getAllowMonsters(), this.getKnownProperty("animals", Boolean.class).getValue());
|
||||||
} else {
|
} else {
|
||||||
this.world.setSpawnFlags(this.world.getAllowMonsters(), true);
|
this.world.setSpawnFlags(this.world.getAllowMonsters(), true);
|
||||||
}
|
}
|
||||||
if (this.getMonsterList().isEmpty()) {
|
if (this.getMonsterList().isEmpty()) {
|
||||||
this.world.setSpawnFlags(((BooleanConfigProperty) this.getKnownProperty("monsters")).getValue(), this.world.getAllowAnimals());
|
this.world.setSpawnFlags(this.getKnownProperty("monsters", Boolean.class).getValue(), this.world.getAllowAnimals());
|
||||||
} else {
|
} else {
|
||||||
this.world.setSpawnFlags(true, this.world.getAllowAnimals());
|
this.world.setSpawnFlags(true, this.world.getAllowAnimals());
|
||||||
}
|
}
|
||||||
@ -322,30 +324,41 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setKeepSpawnInMemory(boolean value) {
|
public void setKeepSpawnInMemory(boolean value) {
|
||||||
((BooleanConfigProperty) this.getKnownProperty("memory")).setValue(value);
|
this.getKnownProperty("memory", Boolean.class).setValue(value);
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Provide better feedback
|
// TODO: Provide better feedback
|
||||||
@Override
|
@Override
|
||||||
public boolean setProperty(String name, String value, CommandSender sender) throws PropertyDoesNotExistException {
|
public boolean setProperty(String name, String value, CommandSender sender) throws PropertyDoesNotExistException {
|
||||||
if (this.setKnownProperty(name, value, sender) || this.setKnownProperty(this.propertyAliases.get(name), value, sender)) {
|
if (!this.isValidPropertyName(name)) {
|
||||||
return true;
|
throw new PropertyDoesNotExistException(name);
|
||||||
}
|
}
|
||||||
throw new PropertyDoesNotExistException(name);
|
return this.setKnownProperty(name, value, sender) || this.setKnownProperty(this.propertyAliases.get(name), value, sender);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidPropertyName(String name) {
|
||||||
|
return this.propertyList.containsKey(name) || this.propertyAliases.containsKey(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPropertyValue(String name) throws PropertyDoesNotExistException {
|
public String getPropertyValue(String name) throws PropertyDoesNotExistException {
|
||||||
if (this.propertyList.containsKey(name)) {
|
if (this.propertyList.containsKey(name)) {
|
||||||
return this.getKnownProperty(name).toString();
|
return this.getKnownProperty(name, Object.class).toString();
|
||||||
}
|
}
|
||||||
throw new PropertyDoesNotExistException(name);
|
throw new PropertyDoesNotExistException(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MVConfigProperty getProperty(String name) throws PropertyDoesNotExistException {
|
@Deprecated
|
||||||
MVConfigProperty p = this.getKnownProperty(name);
|
public MVConfigProperty<?> getProperty(String property) throws PropertyDoesNotExistException {
|
||||||
|
return getProperty(property, Object.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> MVConfigProperty<T> getProperty(String name, Class<T> expected) throws PropertyDoesNotExistException {
|
||||||
|
MVConfigProperty<T> p = this.getKnownProperty(name, expected);
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
throw new PropertyDoesNotExistException(name);
|
throw new PropertyDoesNotExistException(name);
|
||||||
}
|
}
|
||||||
@ -356,14 +369,19 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
* This method should only be used from inside this class when it is KNOWN that the property exists.
|
* This method should only be used from inside this class when it is KNOWN that the property exists.
|
||||||
*
|
*
|
||||||
* @param name The known name of a property
|
* @param name The known name of a property
|
||||||
|
* @param expected The Type of the expected value
|
||||||
* @return The property object.
|
* @return The property object.
|
||||||
*/
|
*/
|
||||||
private MVConfigProperty getKnownProperty(String name) {
|
@SuppressWarnings("unchecked")
|
||||||
if (this.propertyList.containsKey(name)) {
|
private <T> MVConfigProperty<T> getKnownProperty(String name, Class<T> expected) {
|
||||||
return this.propertyList.get(name);
|
try {
|
||||||
} else if (this.propertyAliases.containsKey(name)) {
|
if (this.propertyList.containsKey(name)) {
|
||||||
// If the property was defined in the alias table, make sure to grab the actual name
|
return (MVConfigProperty<T>) this.propertyList.get(name);
|
||||||
return this.propertyList.get(this.propertyAliases.get(name));
|
} else if (this.propertyAliases.containsKey(name)) {
|
||||||
|
// If the property was defined in the alias table, make sure to grab the actual name
|
||||||
|
return (MVConfigProperty<T>) this.propertyList.get(this.propertyAliases.get(name));
|
||||||
|
}
|
||||||
|
} catch (ClassCastException e) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -377,9 +395,9 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
* @return True if the property was saved, false if not.
|
* @return True if the property was saved, false if not.
|
||||||
*/
|
*/
|
||||||
private boolean setKnownProperty(String name, String value, CommandSender sender) {
|
private boolean setKnownProperty(String name, String value, CommandSender sender) {
|
||||||
MVConfigProperty property;
|
MVConfigProperty<?> property;
|
||||||
if (this.propertyList.containsKey(name)) {
|
if (this.propertyList.containsKey(name)) {
|
||||||
property = this.getKnownProperty(name);
|
property = this.getKnownProperty(name, Object.class);
|
||||||
} else if (this.propertyAliases.containsKey(name)) {
|
} else if (this.propertyAliases.containsKey(name)) {
|
||||||
return this.setKnownProperty(this.propertyAliases.get(name), value, sender);
|
return this.setKnownProperty(this.propertyAliases.get(name), value, sender);
|
||||||
} else {
|
} else {
|
||||||
@ -434,7 +452,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAlias() {
|
public String getAlias() {
|
||||||
String alias = ((StringConfigProperty) this.getKnownProperty("alias")).getValue();
|
String alias = this.getKnownProperty("alias", String.class).getValue();
|
||||||
if (alias == null || alias.length() == 0) {
|
if (alias == null || alias.length() == 0) {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
@ -449,7 +467,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canAnimalsSpawn() {
|
public boolean canAnimalsSpawn() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("animals")).getValue();
|
return this.getKnownProperty("animals", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -464,7 +482,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canMonstersSpawn() {
|
public boolean canMonstersSpawn() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("monsters")).getValue();
|
return this.getKnownProperty("monsters", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -479,7 +497,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPVPEnabled() {
|
public boolean isPVPEnabled() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("pvp")).getValue();
|
return this.getKnownProperty("pvp", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -489,7 +507,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isHidden() {
|
public boolean isHidden() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("hidden")).getValue();
|
return this.getKnownProperty("hidden", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -503,7 +521,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getScaling() {
|
public double getScaling() {
|
||||||
return ((DoubleConfigProperty) this.getKnownProperty("scale")).getValue();
|
return this.getKnownProperty("scale", Double.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -522,7 +540,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChatColor getColor() {
|
public ChatColor getColor() {
|
||||||
return ((ColorConfigProperty) this.getKnownProperty("color")).getValue().getColor();
|
return this.getKnownProperty("color", EnglishChatColor.class).getValue().getColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean clearList(String property) {
|
public boolean clearList(String property) {
|
||||||
@ -543,7 +561,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getRespawnToWorld() {
|
public World getRespawnToWorld() {
|
||||||
return (this.plugin.getServer().getWorld(((StringConfigProperty) this.getKnownProperty("respawn")).getValue()));
|
return (this.plugin.getServer().getWorld(this.getKnownProperty("respawn", String.class).getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -558,7 +576,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCurrency() {
|
public int getCurrency() {
|
||||||
return ((IntegerConfigProperty) this.getKnownProperty("curr")).getValue();
|
return this.getKnownProperty("curr", Integer.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -568,7 +586,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPrice() {
|
public double getPrice() {
|
||||||
return ((DoubleConfigProperty) this.getKnownProperty("price")).getValue();
|
return this.getKnownProperty("price", Double.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -599,7 +617,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameMode getGameMode() {
|
public GameMode getGameMode() {
|
||||||
return ((GameModeConfigProperty) this.getKnownProperty("mode")).getValue();
|
return this.getKnownProperty("mode", GameMode.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -609,12 +627,12 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWeatherEnabled() {
|
public boolean isWeatherEnabled() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("weather")).getValue();
|
return this.getKnownProperty("weather", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isKeepingSpawnInMemory() {
|
public boolean isKeepingSpawnInMemory() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("memory")).getValue();
|
return this.getKnownProperty("memory", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -624,13 +642,13 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getHunger() {
|
public boolean getHunger() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("hunger")).getValue();
|
return this.getKnownProperty("hunger", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSpawnLocation(Location l) {
|
public void setSpawnLocation(Location l) {
|
||||||
this.getCBWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
this.getCBWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||||
((LocationConfigProperty) this.getKnownProperty("spawn")).setValue(l);
|
this.getKnownProperty("spawn", Location.class).setValue(l);
|
||||||
this.saveConfig();
|
this.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,6 +672,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
}
|
}
|
||||||
// If it's not, find a better one.
|
// If it's not, find a better one.
|
||||||
this.plugin.log(Level.WARNING, "Spawn location from world.dat file was unsafe. Adjusting...");
|
this.plugin.log(Level.WARNING, "Spawn location from world.dat file was unsafe. Adjusting...");
|
||||||
|
this.plugin.log(Level.WARNING, "Original Location: " + LocationManipulation.strCoordsRaw(spawnLocation));
|
||||||
Location newSpawn = teleporter.getSafeLocation(spawnLocation, 16, 16);
|
Location newSpawn = teleporter.getSafeLocation(spawnLocation, 16, 16);
|
||||||
// I think we could also do this, as I think this is what Notch does.
|
// I think we could also do this, as I think this is what Notch does.
|
||||||
// Not sure how it will work in the nether...
|
// Not sure how it will work in the nether...
|
||||||
@ -682,7 +701,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getSpawnLocation() {
|
public Location getSpawnLocation() {
|
||||||
return ((LocationConfigProperty) this.getKnownProperty("spawn")).getValue();
|
return this.getKnownProperty("spawn", Location.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -697,7 +716,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAutoHeal() {
|
public boolean getAutoHeal() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("autoheal")).getValue();
|
return this.getKnownProperty("autoheal", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -712,7 +731,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAdjustSpawn() {
|
public boolean getAdjustSpawn() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("adjustspawn")).getValue();
|
return this.getKnownProperty("adjustspawn", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -722,7 +741,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getAutoLoad() {
|
public boolean getAutoLoad() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("autoload")).getValue();
|
return this.getKnownProperty("autoload", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -732,7 +751,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getBedRespawn() {
|
public boolean getBedRespawn() {
|
||||||
return ((BooleanConfigProperty) this.getKnownProperty("bedrespawn")).getValue();
|
return this.getKnownProperty("bedrespawn", Boolean.class).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,9 @@ import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
|||||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||||
import com.onarandombox.MultiverseCore.localization.*;
|
import com.onarandombox.MultiverseCore.localization.MessageProvider;
|
||||||
|
import com.onarandombox.MultiverseCore.localization.MessageProviding;
|
||||||
|
import com.onarandombox.MultiverseCore.localization.SimpleMessageProvider;
|
||||||
import com.onarandombox.MultiverseCore.utils.*;
|
import com.onarandombox.MultiverseCore.utils.*;
|
||||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -36,7 +38,8 @@ import org.bukkit.event.Event.Priority;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -55,11 +58,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to find out who is teleporting a player.
|
* This method is used to find out who is teleporting a player.
|
||||||
* @param playerName
|
*
|
||||||
* @return
|
* @param playerName The teleported player.
|
||||||
|
* @return The player that teleported the other one.
|
||||||
*/
|
*/
|
||||||
public static String getPlayerTeleporter(String playerName) {
|
public static String getPlayerTeleporter(String playerName) {
|
||||||
if(teleportQueue.containsKey(playerName)) {
|
if (teleportQueue.containsKey(playerName)) {
|
||||||
String teleportee = teleportQueue.get(playerName);
|
String teleportee = teleportQueue.get(playerName);
|
||||||
teleportQueue.remove(playerName);
|
teleportQueue.remove(playerName);
|
||||||
return teleportee;
|
return teleportee;
|
||||||
@ -201,7 +205,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
this.log(Level.SEVERE, "Your configs were not loaded. Very little will function in Multiverse.");
|
this.log(Level.SEVERE, "Your configs were not loaded. Very little will function in Multiverse.");
|
||||||
}
|
}
|
||||||
this.anchorManager.loadAnchors();
|
this.anchorManager.loadAnchors();
|
||||||
this.messageProvider.setLocale(new Locale(multiverseConfig.getString("locale", "en")));
|
try {
|
||||||
|
this.messageProvider.setLocale(new Locale(multiverseConfig.getString("locale", "en")));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
this.log(Level.SEVERE, e.getMessage());
|
||||||
|
this.getServer().getPluginManager().disablePlugin(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateAllpay() {
|
private boolean validateAllpay() {
|
||||||
@ -218,6 +227,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
//TODO: Deal with this. It's bad.
|
||||||
}
|
}
|
||||||
log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
|
log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
|
||||||
log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of AllPay!");
|
log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of AllPay!");
|
||||||
@ -240,6 +250,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
//TODO: Deal with this. It's bad.
|
||||||
}
|
}
|
||||||
log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
|
log.info(tag + " - Version " + this.getDescription().getVersion() + " was NOT ENABLED!!!");
|
||||||
log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of CommandHandler (an internal library)!");
|
log.info(tag + " A plugin that has loaded before " + this.getDescription().getName() + " has an incompatible version of CommandHandler (an internal library)!");
|
||||||
@ -374,9 +385,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab and return the Teleport class.
|
* Grab and return the {@link SafeTTeleporter}.
|
||||||
*
|
*
|
||||||
* @return
|
* @return The {@link SafeTTeleporter}.
|
||||||
*/
|
*/
|
||||||
public SafeTTeleporter getTeleporter() {
|
public SafeTTeleporter getTeleporter() {
|
||||||
return new SafeTTeleporter(this);
|
return new SafeTTeleporter(this);
|
||||||
@ -409,8 +420,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
* Print messages to the server Log as well as to our DebugLog. 'debugLog' is used to seperate Heroes information
|
* Print messages to the server Log as well as to our DebugLog. 'debugLog' is used to seperate Heroes information
|
||||||
* from the Servers Log Output.
|
* from the Servers Log Output.
|
||||||
*
|
*
|
||||||
* @param level
|
* @param level The Log-{@link Level}
|
||||||
* @param msg
|
* @param msg The message
|
||||||
*/
|
*/
|
||||||
public void log(Level level, String msg) {
|
public void log(Level level, String msg) {
|
||||||
staticLog(level, msg);
|
staticLog(level, msg);
|
||||||
@ -436,8 +447,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the
|
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the
|
||||||
* standard Server Console.
|
* standard Server Console.
|
||||||
*
|
*
|
||||||
* @param level
|
* @param level The Log-{@link Level}
|
||||||
* @param msg
|
* @param msg The message
|
||||||
*/
|
*/
|
||||||
public static void staticDebugLog(Level level, String msg) {
|
public static void staticDebugLog(Level level, String msg) {
|
||||||
log.log(level, "[MVCore-Debug] " + msg);
|
log.log(level, "[MVCore-Debug] " + msg);
|
||||||
@ -447,7 +458,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
/**
|
/**
|
||||||
* Parse the Authors Array into a readable String with ',' and 'and'.
|
* Parse the Authors Array into a readable String with ',' and 'and'.
|
||||||
*
|
*
|
||||||
* @return
|
* @return The readable authors-{@link String}
|
||||||
*/
|
*/
|
||||||
private String getAuthors() {
|
private String getAuthors() {
|
||||||
String authors = "";
|
String authors = "";
|
||||||
@ -480,9 +491,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This code should get moved somewhere more appropriate, but for now, it's here.
|
* This code should get moved somewhere more appropriate, but for now, it's here.
|
||||||
*
|
|
||||||
* @param env
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public Environment getEnvFromString(String env) {
|
public Environment getEnvFromString(String env) {
|
||||||
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
||||||
@ -517,7 +525,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
|||||||
/**
|
/**
|
||||||
* Returns the number of plugins that have specifically hooked into core.
|
* Returns the number of plugins that have specifically hooked into core.
|
||||||
*
|
*
|
||||||
* @return
|
* @return The number if plugins that have hooked into core.
|
||||||
*/
|
*/
|
||||||
public int getPluginCount() {
|
public int getPluginCount() {
|
||||||
return this.pluginCount;
|
return this.pluginCount;
|
||||||
|
@ -16,7 +16,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiverse 2 Core API
|
* Multiverse 2 Core API
|
||||||
* <p/>
|
* <p>
|
||||||
* This API contains a bunch of useful things you can get out of Multiverse in general!
|
* This API contains a bunch of useful things you can get out of Multiverse in general!
|
||||||
*/
|
*/
|
||||||
public interface Core {
|
public interface Core {
|
||||||
|
@ -21,7 +21,7 @@ import org.bukkit.util.Vector;
|
|||||||
public interface MVDestination {
|
public interface MVDestination {
|
||||||
/**
|
/**
|
||||||
* Returns the identifier or prefix that is required for this destination.
|
* Returns the identifier or prefix that is required for this destination.
|
||||||
* <p/>
|
* <p>
|
||||||
* Portals have a prefix of "p" for example and OpenWarp (third party plugin) uses "ow". This is derived from a
|
* Portals have a prefix of "p" for example and OpenWarp (third party plugin) uses "ow". This is derived from a
|
||||||
* hash and cannot have duplicate values. Read that as your plugin cannot use 'p' because it's already used.
|
* hash and cannot have duplicate values. Read that as your plugin cannot use 'p' because it's already used.
|
||||||
* Please check the wiki when adding a custom destination!
|
* Please check the wiki when adding a custom destination!
|
||||||
@ -32,7 +32,7 @@ public interface MVDestination {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to determine if a Destination is valid for the type it thinks it is.
|
* Allows you to determine if a Destination is valid for the type it thinks it is.
|
||||||
* <p/>
|
* <p>
|
||||||
* An example of this would be the exact destination. A valid string would be: e:0,0,0 where an invalid one would
|
* An example of this would be the exact destination. A valid string would be: e:0,0,0 where an invalid one would
|
||||||
* be e:1:2:3. The first string would return true the second would return false. This is simply a convenience
|
* be e:1:2:3. The first string would return true the second would return false. This is simply a convenience
|
||||||
* method
|
* method
|
||||||
@ -48,11 +48,11 @@ public interface MVDestination {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the location a specific entity will spawn at.
|
* Returns the location a specific entity will spawn at.
|
||||||
* <p/>
|
* <p>
|
||||||
* To just retrieve the location as it is stored you can just pass null, but be warned some destinations may return
|
* To just retrieve the location as it is stored you can just pass null, but be warned some destinations may return
|
||||||
* null back to you if you do this. It is always safer to pass an actual entity. This is used so things like
|
* null back to you if you do this. It is always safer to pass an actual entity. This is used so things like
|
||||||
* minecarts can be teleported.
|
* minecarts can be teleported.
|
||||||
* <p/>
|
* <p>
|
||||||
* Do not forget to use {@link #getVelocity()} as destinations can use this too!
|
* Do not forget to use {@link #getVelocity()} as destinations can use this too!
|
||||||
*
|
*
|
||||||
* @param entity The entity to be teleported.
|
* @param entity The entity to be teleported.
|
||||||
@ -63,7 +63,7 @@ public interface MVDestination {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the velocity vector for this destination.
|
* Returns the velocity vector for this destination.
|
||||||
* <p/>
|
* <p>
|
||||||
* Plugins wishing to fully support MVDestinations MUST implement this.
|
* Plugins wishing to fully support MVDestinations MUST implement this.
|
||||||
*
|
*
|
||||||
* @return A vector representing the speed/direction the player should travel when arriving
|
* @return A vector representing the speed/direction the player should travel when arriving
|
||||||
@ -72,7 +72,7 @@ public interface MVDestination {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the destination string.
|
* Sets the destination string.
|
||||||
* <p/>
|
* <p>
|
||||||
* This should be used when you want to tell this destination object about a change in where it should take people.
|
* This should be used when you want to tell this destination object about a change in where it should take people.
|
||||||
* The destination param should be match the result from {@link #getIdentifier()}. A valid example would be that if
|
* The destination param should be match the result from {@link #getIdentifier()}. A valid example would be that if
|
||||||
* {@link #getIdentifier()} returned "ow" our destination string could be "ow:TownCenter" but could not be
|
* {@link #getIdentifier()} returned "ow" our destination string could be "ow:TownCenter" but could not be
|
||||||
@ -85,7 +85,7 @@ public interface MVDestination {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the destination is valid and players will be taken to it.
|
* Returns true if the destination is valid and players will be taken to it.
|
||||||
* <p/>
|
* <p>
|
||||||
* Even if destinations are in the correct format (p:MyPortal) MyPortal may not exist, and therefore this would
|
* Even if destinations are in the correct format (p:MyPortal) MyPortal may not exist, and therefore this would
|
||||||
* return false.
|
* return false.
|
||||||
*
|
*
|
||||||
@ -95,7 +95,7 @@ public interface MVDestination {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives you a general friendly description of the type of destination.
|
* Gives you a general friendly description of the type of destination.
|
||||||
* <p/>
|
* <p>
|
||||||
* For example, the PlayerDestination sets this to "Player". You can use this to show where a player will be taken.
|
* For example, the PlayerDestination sets this to "Player". You can use this to show where a player will be taken.
|
||||||
*
|
*
|
||||||
* @return A friendly string description of the type of destination.
|
* @return A friendly string description of the type of destination.
|
||||||
@ -104,7 +104,7 @@ public interface MVDestination {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gives you a specific name of the destination.
|
* Gives you a specific name of the destination.
|
||||||
* <p/>
|
* <p>
|
||||||
* For example, the PlayerDestination sets this to The Player's Name.
|
* For example, the PlayerDestination sets this to The Player's Name.
|
||||||
*
|
*
|
||||||
* @return A friendly string stating the name of the destination.
|
* @return A friendly string stating the name of the destination.
|
||||||
@ -114,7 +114,7 @@ public interface MVDestination {
|
|||||||
/**
|
/**
|
||||||
* Returns a string that can easily be saved in the config that contains all the details needed to rebuild this
|
* Returns a string that can easily be saved in the config that contains all the details needed to rebuild this
|
||||||
* destination.
|
* destination.
|
||||||
* <p/>
|
* <p>
|
||||||
* ex: e:0,0,0:50:50
|
* ex: e:0,0,0:50:50
|
||||||
*
|
*
|
||||||
* @return The savable config string.
|
* @return The savable config string.
|
||||||
@ -123,9 +123,9 @@ public interface MVDestination {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the permissions string required to go here.
|
* Returns the permissions string required to go here.
|
||||||
* <p/>
|
* <p>
|
||||||
* ex: multiverse.access.world
|
* ex: multiverse.access.world
|
||||||
* <p/>
|
* <p>
|
||||||
* NOTE: This is NOT the permission to use the teleport command.
|
* NOTE: This is NOT the permission to use the teleport command.
|
||||||
*
|
*
|
||||||
* @return the permissions string required to go here.
|
* @return the permissions string required to go here.
|
||||||
@ -134,7 +134,7 @@ public interface MVDestination {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Should the Multiverse SafeTeleporter be used?
|
* Should the Multiverse SafeTeleporter be used?
|
||||||
* <p/>
|
* <p>
|
||||||
* If not, MV will blindly take people to the location specified.
|
* If not, MV will blindly take people to the location specified.
|
||||||
*
|
*
|
||||||
* @return True if the SafeTeleporter will be used, false if not.
|
* @return True if the SafeTeleporter will be used, false if not.
|
||||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiverse 2 World Manager API
|
* Multiverse 2 World Manager API
|
||||||
* <p/>
|
* <p>
|
||||||
* This API contains all of the world managing
|
* This API contains all of the world managing
|
||||||
* functions that your heart desires!
|
* functions that your heart desires!
|
||||||
*/
|
*/
|
||||||
@ -142,7 +142,7 @@ public interface MVWorldManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
|
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
|
||||||
* <p/>
|
* <p>
|
||||||
* This way people will _always_ have some worlds in the list.
|
* This way people will _always_ have some worlds in the list.
|
||||||
*/
|
*/
|
||||||
public void loadDefaultWorlds();
|
public void loadDefaultWorlds();
|
||||||
|
@ -17,7 +17,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The API for a Multiverse Handled World.
|
* The API for a Multiverse Handled World.
|
||||||
* <p/>
|
* <p>
|
||||||
* Currently INCOMPLETE
|
* Currently INCOMPLETE
|
||||||
*/
|
*/
|
||||||
public interface MultiverseWorld {
|
public interface MultiverseWorld {
|
||||||
@ -48,8 +48,10 @@ public interface MultiverseWorld {
|
|||||||
* @param property The name of a world property to get.
|
* @param property The name of a world property to get.
|
||||||
* @return A valid MVWorldProperty.
|
* @return A valid MVWorldProperty.
|
||||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||||
|
* @deprecated Use {@link #getProperty(String, Class)} instead
|
||||||
*/
|
*/
|
||||||
public MVConfigProperty getProperty(String property) throws PropertyDoesNotExistException;
|
@Deprecated
|
||||||
|
public MVConfigProperty<?> getProperty(String property) throws PropertyDoesNotExistException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the string representation of a property.
|
* Gets the string representation of a property.
|
||||||
@ -61,6 +63,17 @@ public interface MultiverseWorld {
|
|||||||
*/
|
*/
|
||||||
public String getPropertyValue(String property) throws PropertyDoesNotExistException;
|
public String getPropertyValue(String property) 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.
|
||||||
|
* @param expected The type of the expected property. Use Object.class if this doesn't matter for you.
|
||||||
|
* @return A valid MVWorldProperty.
|
||||||
|
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||||
|
*/
|
||||||
|
public <T> MVConfigProperty<T> getProperty(String property, Class<T> expected) throws PropertyDoesNotExistException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||||
*
|
*
|
||||||
@ -97,7 +110,7 @@ public interface MultiverseWorld {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the environment of a world.
|
* Sets the environment of a world.
|
||||||
* <p/>
|
* <p>
|
||||||
* Note: This will ONLY take effect once the world is unloaded/reloaded.
|
* Note: This will ONLY take effect once the world is unloaded/reloaded.
|
||||||
*
|
*
|
||||||
* @param environment A {@link org.bukkit.World.Environment}.
|
* @param environment A {@link org.bukkit.World.Environment}.
|
||||||
@ -127,7 +140,7 @@ public interface MultiverseWorld {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the alias of this world.
|
* Gets the alias of this world.
|
||||||
* <p/>
|
* <p>
|
||||||
* This alias allows users to have a world named "world" but show up in the list as "FernIsland"
|
* This alias allows users to have a world named "world" but show up in the list as "FernIsland"
|
||||||
*
|
*
|
||||||
* @return The alias of the world as a String.
|
* @return The alias of the world as a String.
|
||||||
@ -472,7 +485,7 @@ public interface MultiverseWorld {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not Multiverse should auto-load this world.
|
* Sets whether or not Multiverse should auto-load this world.
|
||||||
* <p/>
|
* <p>
|
||||||
* True is default.
|
* True is default.
|
||||||
*
|
*
|
||||||
* @param autoLoad True if multiverse should autoload this world the spawn, false if not.
|
* @param autoLoad True if multiverse should autoload this world the spawn, false if not.
|
||||||
@ -489,7 +502,7 @@ public interface MultiverseWorld {
|
|||||||
/**
|
/**
|
||||||
* Sets whether or not a player who dies in this world will respawn in their
|
* Sets whether or not a player who dies in this world will respawn in their
|
||||||
* bed or follow the normal respawn pattern.
|
* bed or follow the normal respawn pattern.
|
||||||
* <p/>
|
* <p>
|
||||||
* True is default.
|
* True is default.
|
||||||
*
|
*
|
||||||
* @param autoLoad True if players dying in this world respawn at their bed.
|
* @param autoLoad True if players dying in this world respawn at their bed.
|
||||||
|
@ -9,7 +9,6 @@ package com.onarandombox.MultiverseCore.commands;
|
|||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
|
||||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
@ -47,7 +46,7 @@ public class CreateCommand extends MultiverseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String worldName = args.get(0);
|
String worldName = args.get(0);
|
||||||
File worldFile = new File(this.plugin.getServerFolder(), worldName);
|
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
|
||||||
String env = args.get(1);
|
String env = args.get(1);
|
||||||
String seed = CommandHandler.getFlag("-s", args);
|
String seed = CommandHandler.getFlag("-s", args);
|
||||||
String generator = CommandHandler.getFlag("-g", args);
|
String generator = CommandHandler.getFlag("-g", args);
|
||||||
|
@ -106,7 +106,7 @@ public class ImportCommand extends MultiverseCommand {
|
|||||||
this.showHelp(sender);
|
this.showHelp(sender);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File worldFile = new File(this.plugin.getServerFolder(), worldName);
|
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
|
||||||
if (this.worldManager.isMVWorld(worldName) && worldFile.exists()) {
|
if (this.worldManager.isMVWorld(worldName) && worldFile.exists()) {
|
||||||
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
|
sender.sendMessage(ChatColor.RED + "Multiverse already knows about this world!");
|
||||||
return;
|
return;
|
||||||
|
@ -9,7 +9,8 @@ package com.onarandombox.MultiverseCore.commands;
|
|||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.pneumaticraft.commandhandler.Command;
|
import com.onarandombox.MultiverseCore.localization.MessageProvider;
|
||||||
|
import com.onarandombox.MultiverseCore.localization.MultiverseMessage;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -21,15 +22,18 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ListCommand extends PaginatedCoreCommand<String> {
|
public class ListCommand extends PaginatedCoreCommand<String> {
|
||||||
|
|
||||||
|
private MessageProvider provider;
|
||||||
|
|
||||||
public ListCommand(MultiverseCore plugin) {
|
public ListCommand(MultiverseCore plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.setName("World Listing");
|
provider = plugin.getMessageProvider();
|
||||||
|
this.setName(provider.getMessage(MultiverseMessage.LIST_NAME));
|
||||||
this.setCommandUsage("/mv list");
|
this.setCommandUsage("/mv list");
|
||||||
this.setArgRange(0, 2);
|
this.setArgRange(0, 2);
|
||||||
this.addKey("mvlist");
|
this.addKey("mvlist");
|
||||||
this.addKey("mvl");
|
this.addKey("mvl");
|
||||||
this.addKey("mv list");
|
this.addKey("mv list");
|
||||||
this.setPermission("multiverse.core.list.worlds", "Displays a listing of all worlds that you can enter.", PermissionDefault.OP);
|
this.setPermission("multiverse.core.list.worlds", provider.getMessage(MultiverseMessage.LIST_DESC), PermissionDefault.OP);
|
||||||
this.setItemsPerPage(8);
|
this.setItemsPerPage(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +66,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
|||||||
}
|
}
|
||||||
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
|
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
|
||||||
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
|
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
|
||||||
worldList.add(ChatColor.GRAY + name + " - UNLOADED");
|
worldList.add(ChatColor.GRAY + name + " - " + provider.getMessage(MultiverseMessage.GENERIC_UNLOADED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return worldList;
|
return worldList;
|
||||||
@ -87,7 +91,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runCommand(CommandSender sender, List<String> args) {
|
public void runCommand(CommandSender sender, List<String> args) {
|
||||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse World List ]====");
|
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ " + this.provider.getMessage(MultiverseMessage.LIST_TITLE) + " ]====");
|
||||||
Player p = null;
|
Player p = null;
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
p = (Player) sender;
|
p = (Player) sender;
|
||||||
@ -100,7 +104,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
|||||||
if (filterObject.getFilter().length() > 0) {
|
if (filterObject.getFilter().length() > 0) {
|
||||||
availableWorlds = this.getFilteredItems(availableWorlds, filterObject.getFilter());
|
availableWorlds = this.getFilteredItems(availableWorlds, filterObject.getFilter());
|
||||||
if (availableWorlds.size() == 0) {
|
if (availableWorlds.size() == 0) {
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry... " + ChatColor.WHITE + "No worlds matched your filter: " + ChatColor.AQUA + filterObject.getFilter());
|
sender.sendMessage(ChatColor.RED + provider.getMessage(MultiverseMessage.GENERIC_SORRY) + " " + ChatColor.WHITE + provider.getMessage(MultiverseMessage.LIST_NO_MATCH) + " " + ChatColor.AQUA + filterObject.getFilter());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +122,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
|||||||
filterObject.setPage(totalPages);
|
filterObject.setPage(totalPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
|
sender.sendMessage(ChatColor.AQUA + " " + provider.getMessage(MultiverseMessage.GENERIC_PAGE) + " " + filterObject.getPage() + " " + provider.getMessage(MultiverseMessage.GENERIC_OF) + " " + totalPages);
|
||||||
|
|
||||||
this.showPage(filterObject.getPage(), sender, availableWorlds);
|
this.showPage(filterObject.getPage(), sender, availableWorlds);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
|||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.enums.Action;
|
import com.onarandombox.MultiverseCore.enums.Action;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -12,7 +12,6 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
|||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -108,7 +107,7 @@ public class ModifySetCommand extends MultiverseCommand {
|
|||||||
if (world.setProperty(property, value, sender)) {
|
if (world.setProperty(property, value, sender)) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property + ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property + ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(world.getProperty(property).getHelp());
|
sender.sendMessage(world.getProperty(property, Object.class).getHelp());
|
||||||
}
|
}
|
||||||
} catch (PropertyDoesNotExistException e) {
|
} catch (PropertyDoesNotExistException e) {
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + property + ChatColor.RED + "'");
|
sender.sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + property + ChatColor.RED + "'");
|
||||||
|
@ -10,7 +10,6 @@ package com.onarandombox.MultiverseCore.commands;
|
|||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -92,7 +91,7 @@ public class WhoCommand extends MultiverseCommand {
|
|||||||
result = "Empty";
|
result = "Empty";
|
||||||
} else {
|
} else {
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
result += player.getDisplayName() + " ";
|
result += player.getDisplayName() + " " + ChatColor.WHITE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,7 @@ public class BooleanConfigProperty implements MVConfigProperty<Boolean> {
|
|||||||
private String help;
|
private String help;
|
||||||
|
|
||||||
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String help) {
|
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String help) {
|
||||||
this.name = name;
|
this(section, name, defaultValue, name, help);
|
||||||
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, String help) {
|
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String configNode, String help) {
|
||||||
@ -29,6 +25,7 @@ public class BooleanConfigProperty implements MVConfigProperty<Boolean> {
|
|||||||
this.configNode = configNode;
|
this.configNode = configNode;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
|
this.value = defaultValue;
|
||||||
this.setValue(this.section.getBoolean(this.configNode, defaultValue));
|
this.setValue(this.section.getBoolean(this.configNode, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,11 +18,7 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
|
|||||||
private String help;
|
private String help;
|
||||||
|
|
||||||
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String help) {
|
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String help) {
|
||||||
this.name = name;
|
this(section, name, defaultValue, name, help);
|
||||||
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, String help) {
|
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String configNode, String help) {
|
||||||
@ -30,6 +26,7 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
|
|||||||
this.configNode = configNode;
|
this.configNode = configNode;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
|
this.value = defaultValue;
|
||||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,11 +18,7 @@ public class DifficultyConfigProperty implements MVConfigProperty<Difficulty> {
|
|||||||
private String help;
|
private String help;
|
||||||
|
|
||||||
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String help) {
|
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String help) {
|
||||||
this.name = name;
|
this(section, name, defaultValue, name, help);
|
||||||
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, String help) {
|
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String configNode, String help) {
|
||||||
@ -30,6 +26,7 @@ public class DifficultyConfigProperty implements MVConfigProperty<Difficulty> {
|
|||||||
this.configNode = configNode;
|
this.configNode = configNode;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
|
this.value = defaultValue;
|
||||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,7 @@ public class DoubleConfigProperty implements MVConfigProperty<Double> {
|
|||||||
private String help;
|
private String help;
|
||||||
|
|
||||||
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String help) {
|
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String help) {
|
||||||
this.name = name;
|
this(section, name, defaultValue, name, help);
|
||||||
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, String help) {
|
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String configNode, String help) {
|
||||||
@ -29,6 +25,7 @@ public class DoubleConfigProperty implements MVConfigProperty<Double> {
|
|||||||
this.configNode = configNode;
|
this.configNode = configNode;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
|
this.value = defaultValue;
|
||||||
this.setValue(this.section.getDouble(this.configNode, defaultValue));
|
this.setValue(this.section.getDouble(this.configNode, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,11 +18,7 @@ public class GameModeConfigProperty implements MVConfigProperty<GameMode> {
|
|||||||
private String help;
|
private String help;
|
||||||
|
|
||||||
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String help) {
|
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String help) {
|
||||||
this.name = name;
|
this(section, name, defaultValue, name, help);
|
||||||
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, String help) {
|
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String configNode, String help) {
|
||||||
@ -30,6 +26,7 @@ public class GameModeConfigProperty implements MVConfigProperty<GameMode> {
|
|||||||
this.configNode = configNode;
|
this.configNode = configNode;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
|
this.value = defaultValue;
|
||||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,7 @@ public class IntegerConfigProperty implements MVConfigProperty<Integer> {
|
|||||||
private String help;
|
private String help;
|
||||||
|
|
||||||
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String help) {
|
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String help) {
|
||||||
this.name = name;
|
this(section, name, defaultValue, name, help);
|
||||||
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, String help) {
|
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String configNode, String help) {
|
||||||
@ -29,6 +25,7 @@ public class IntegerConfigProperty implements MVConfigProperty<Integer> {
|
|||||||
this.configNode = configNode;
|
this.configNode = configNode;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
|
this.value = defaultValue;
|
||||||
this.setValue(this.section.getInt(this.configNode, defaultValue));
|
this.setValue(this.section.getInt(this.configNode, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,7 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
|
|||||||
private String help;
|
private String help;
|
||||||
|
|
||||||
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String help) {
|
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String help) {
|
||||||
this.name = name;
|
this(section, name, defaultValue, name, help);
|
||||||
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, String help) {
|
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String configNode, String help) {
|
||||||
@ -31,7 +27,8 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
|
|||||||
this.configNode = configNode;
|
this.configNode = configNode;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
this.setValue(this.getLocationFromConfig(this.configNode, defaultValue));
|
this.value = defaultValue;
|
||||||
|
this.setValue(this.getLocationFromConfig(defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,7 +43,7 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean parseValue(String value) {
|
public boolean parseValue(String value) {
|
||||||
Location parsed = LocationManipulation.getLocationFromString(value);
|
Location parsed = LocationManipulation.stringToLocation(value);
|
||||||
return this.setValue(parsed);
|
return this.setValue(parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,17 +74,18 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
|
|||||||
this.section.set(configNode + ".pitch", this.value.getPitch());
|
this.section.set(configNode + ".pitch", this.value.getPitch());
|
||||||
this.section.set(configNode + ".yaw", this.value.getYaw());
|
this.section.set(configNode + ".yaw", this.value.getYaw());
|
||||||
this.section.set(configNode + ".world", this.value.getWorld().getName());
|
this.section.set(configNode + ".world", this.value.getWorld().getName());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Location getLocationFromConfig(String node, Location defaultValue) {
|
private Location getLocationFromConfig(Location defaultValue) {
|
||||||
double x = this.section.getDouble(configNode + ".x", defaultValue.getX());
|
double x = this.section.getDouble(this.configNode + ".x", defaultValue.getX());
|
||||||
double y = this.section.getDouble(configNode + ".y", defaultValue.getY());
|
double y = this.section.getDouble(this.configNode + ".y", defaultValue.getY());
|
||||||
double z = this.section.getDouble(configNode + ".z", defaultValue.getZ());
|
double z = this.section.getDouble(this.configNode + ".z", defaultValue.getZ());
|
||||||
double p = this.section.getDouble(configNode + ".pitch", defaultValue.getPitch());
|
double pitch = this.section.getDouble(this.configNode + ".pitch", defaultValue.getPitch());
|
||||||
double yaw = this.section.getDouble(configNode + ".yaw", defaultValue.getYaw());
|
double yaw = this.section.getDouble(this.configNode + ".yaw", defaultValue.getYaw());
|
||||||
String w = this.section.getString(configNode + ".world", defaultValue.getWorld().getName());
|
String w = this.section.getString(this.configNode + ".world", defaultValue.getWorld().getName());
|
||||||
Location found = LocationManipulation.getLocationFromString(w + ":" + x + "," + y + "," + z + ":" + p + ":" + yaw);
|
Location found = LocationManipulation.stringToLocation(w + ":" + x + "," + y + "," + z + ":" + yaw + ":" + pitch);
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class MVConfigMigrator {
|
public abstract class MVConfigMigrator {
|
||||||
public List<String> createdDefaults = new ArrayList<String>();
|
public List<String> createdDefaults = new ArrayList<String>();
|
||||||
|
|
||||||
|
@ -17,11 +17,7 @@ public class StringConfigProperty implements MVConfigProperty<String> {
|
|||||||
private String help;
|
private String help;
|
||||||
|
|
||||||
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String help) {
|
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String help) {
|
||||||
this.name = name;
|
this(section, name, defaultValue, defaultValue, help);
|
||||||
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, String help) {
|
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String configNode, String help) {
|
||||||
@ -29,6 +25,7 @@ public class StringConfigProperty implements MVConfigProperty<String> {
|
|||||||
this.configNode = configNode;
|
this.configNode = configNode;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.help = help;
|
this.help = help;
|
||||||
|
this.value = defaultValue;
|
||||||
this.parseValue(this.section.getString(this.configNode, defaultValue));
|
this.parseValue(this.section.getString(this.configNode, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,9 +53,9 @@ public class MVTeleportEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player who requested the Teleport
|
* Gets the {@link CommandSender} who requested the Teleport
|
||||||
*
|
*
|
||||||
* @return
|
* @return The {@link CommandSender} who requested the Teleport
|
||||||
*/
|
*/
|
||||||
public CommandSender getTeleporter() {
|
public CommandSender getTeleporter() {
|
||||||
return this.teleporter;
|
return this.teleporter;
|
||||||
|
@ -14,9 +14,9 @@ import org.bukkit.event.Event;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired *before* the property is actually changed.
|
* This event is fired *before* the property is actually changed.
|
||||||
* <p/>
|
* <p>
|
||||||
* If it is cancled, no change will happen.
|
* If it is cancled, no change will happen.
|
||||||
* <p/>
|
* <p>
|
||||||
* If you want to get the values of the world before the change, query the world.
|
* If you want to get the values of the world before the change, query the world.
|
||||||
* If you want to get the value being changed, use getProperty()
|
* If you want to get the value being changed, use getProperty()
|
||||||
*/
|
*/
|
||||||
|
@ -11,9 +11,6 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
|||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
||||||
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
|
@ -173,10 +173,7 @@ public class MVPlayerListener extends PlayerListener {
|
|||||||
// TODO: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what
|
// TODO: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what
|
||||||
// TODO: we want to do here.
|
// TODO: we want to do here.
|
||||||
if (newloc != null) {
|
if (newloc != null) {
|
||||||
System.out.println("Found a new location!");
|
|
||||||
event.setFrom(newloc);
|
event.setFrom(newloc);
|
||||||
} else {
|
|
||||||
System.out.println("Did NOT find a new location!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Wait for the adjust, then return!
|
// Wait for the adjust, then return!
|
||||||
|
@ -4,7 +4,15 @@ package com.onarandombox.MultiverseCore.localization;
|
|||||||
* An enum containing all messages/strings used by Multiverse.
|
* An enum containing all messages/strings used by Multiverse.
|
||||||
*/
|
*/
|
||||||
public enum MultiverseMessage {
|
public enum MultiverseMessage {
|
||||||
TEST_STRING("a test-string from the enum");
|
TEST_STRING("a test-string from the enum"),
|
||||||
|
LIST_NAME("World Listing"),
|
||||||
|
LIST_TITLE("Multiverse World List"),
|
||||||
|
LIST_DESC("Displays a listing of all worlds that you can enter."),
|
||||||
|
LIST_NO_MATCH("No worlds matched your filter:"),
|
||||||
|
GENERIC_SORRY("Sorry..."),
|
||||||
|
GENERIC_OF("of"),
|
||||||
|
GENERIC_PAGE("Page"),
|
||||||
|
GENERIC_UNLOADED("UNLOADED");
|
||||||
|
|
||||||
private final String def;
|
private final String def;
|
||||||
|
|
||||||
|
@ -143,7 +143,6 @@ public class SimpleMessageProvider implements LazyLocaleMessageProvider {
|
|||||||
public void setLocale(Locale locale) {
|
public void setLocale(Locale locale) {
|
||||||
if (locale == null)
|
if (locale == null)
|
||||||
throw new IllegalArgumentException("Can't set locale to null!");
|
throw new IllegalArgumentException("Can't set locale to null!");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
maybeLoadLocale(locale);
|
maybeLoadLocale(locale);
|
||||||
} catch (LocalizationLoadingException e) {
|
} catch (LocalizationLoadingException e) {
|
||||||
|
@ -42,7 +42,7 @@ public class AnchorManager {
|
|||||||
Set<String> anchorKeys = anchors.getKeys(false);
|
Set<String> anchorKeys = anchors.getKeys(false);
|
||||||
for (String key : anchorKeys) {
|
for (String key : anchorKeys) {
|
||||||
//world:x,y,z:pitch:yaw
|
//world:x,y,z:pitch:yaw
|
||||||
Location anchorLocation = LocationManipulation.getLocationFromString(anchors.getString(key, ""));
|
Location anchorLocation = LocationManipulation.stringToLocation(anchors.getString(key, ""));
|
||||||
if (anchorLocation != null) {
|
if (anchorLocation != null) {
|
||||||
MultiverseCore.staticLog(Level.INFO, "Loading anchor: '" + key + "'...");
|
MultiverseCore.staticLog(Level.INFO, "Loading anchor: '" + key + "'...");
|
||||||
this.anchors.put(key, anchorLocation);
|
this.anchors.put(key, anchorLocation);
|
||||||
@ -77,7 +77,7 @@ public class AnchorManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean saveAnchorLocation(String anchor, String location) {
|
public boolean saveAnchorLocation(String anchor, String location) {
|
||||||
Location parsed = LocationManipulation.getLocationFromString(location);
|
Location parsed = LocationManipulation.stringToLocation(location);
|
||||||
return parsed != null && this.saveAnchorLocation(anchor, parsed);
|
return parsed != null && this.saveAnchorLocation(anchor, parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,10 +43,11 @@ public class BlockSafety {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function checks whether the block at the coordinates given is safe or not by checking for Laval/Fire/Air
|
* This function checks whether the block at the coordinates given is safe or not by checking for Lava/Fire/Air
|
||||||
* etc. This also ensures there is enough space for a player to spawn!
|
* etc. This also ensures there is enough space for a player to spawn!
|
||||||
*
|
*
|
||||||
* @return
|
* @param l The {@link Location}
|
||||||
|
* @return Whether the player can spawn safely at the given {@link Location}
|
||||||
*/
|
*/
|
||||||
public boolean playerCanSpawnHereSafely(Location l) {
|
public boolean playerCanSpawnHereSafely(Location l) {
|
||||||
World world = l.getWorld();
|
World world = l.getWorld();
|
||||||
@ -107,9 +108,6 @@ public class BlockSafety {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* If someone has a better way of this... Please either tell us, or submit a pull request!
|
* If someone has a better way of this... Please either tell us, or submit a pull request!
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private boolean isSolidBlock(Material type) {
|
private boolean isSolidBlock(Material type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -196,10 +194,10 @@ public class BlockSafety {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks recursively below location L for 2 blocks of water
|
* Checks recursively below a {@link Location} for 2 blocks of water
|
||||||
*
|
*
|
||||||
* @param l
|
* @param l The {@link Location}
|
||||||
* @return
|
* @return Whether there are 2 blocks of water
|
||||||
*/
|
*/
|
||||||
public boolean hasTwoBlocksofWaterBelow(Location l) {
|
public boolean hasTwoBlocksofWaterBelow(Location l) {
|
||||||
if (l.getBlockY() < 0) {
|
if (l.getBlockY() < 0) {
|
||||||
|
@ -15,6 +15,7 @@ import org.bukkit.entity.Vehicle;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Formatter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -35,51 +36,80 @@ public class LocationManipulation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a Location into a Colon separated string to allow us to store it in text.
|
* Convert a Location into a Colon separated string to allow us to store it in text.
|
||||||
* world:x,y,z:pitch:yaw
|
* <p>
|
||||||
|
* WORLD:X,Y,Z:yaw:pitch
|
||||||
|
* <p>
|
||||||
|
* The corresponding String2Loc function is {@link #stringToLocation}
|
||||||
*
|
*
|
||||||
* @param location
|
* @param location The Location to save.
|
||||||
* @return
|
* @return The location as a string in this format: WORLD:x,y,z:yaw:pitch
|
||||||
*/
|
*/
|
||||||
public static String locationToString(Location location) {
|
public static String locationToString(Location location) {
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
StringBuilder l = new StringBuilder();
|
StringBuilder l = new StringBuilder();
|
||||||
l.append(location.getWorld().getName() + ":");
|
Formatter formatter = new Formatter(l);
|
||||||
l.append(location.getBlockX() + ",");
|
formatter.format("%s:%.2f,%.2f,%.2f:%.2f:%.2f", location.getWorld().getName(), location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||||
l.append(location.getBlockY() + ",");
|
return formatter.toString();
|
||||||
l.append(location.getBlockZ() + ":");
|
|
||||||
l.append(location.getYaw() + ":");
|
|
||||||
l.append(location.getPitch());
|
|
||||||
return l.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a String to a Location.
|
* Returns a new location from a given string. The format is as follows:
|
||||||
|
* <p>
|
||||||
|
* WORLD:X,Y,Z:yaw:pitch
|
||||||
|
* <p>
|
||||||
|
* The corresponding Location2String function is {@link #stringToLocation}
|
||||||
*
|
*
|
||||||
* @param world
|
* @param locationString The location represented as a string (WORLD:X,Y,Z:yaw:pitch)
|
||||||
* @param xStr
|
* @return A new location defined by the string or null if the string was invalid.
|
||||||
* @param yStr
|
|
||||||
* @param zStr
|
|
||||||
* @param yawStr
|
|
||||||
* @param pitchStr
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public Location stringToLocation(World world, String xStr, String yStr, String zStr, String yawStr, String pitchStr) {
|
public static Location stringToLocation(String locationString) {
|
||||||
double x = Double.parseDouble(xStr);
|
//format:
|
||||||
double y = Double.parseDouble(yStr);
|
//world:x,y,z:pitch:yaw
|
||||||
double z = Double.parseDouble(zStr);
|
if (locationString == null) {
|
||||||
float yaw = Float.valueOf(yawStr);
|
return null;
|
||||||
float pitch = Float.valueOf(pitchStr);
|
}
|
||||||
|
|
||||||
return new Location(world, x, y, z, yaw, pitch);
|
// Split the whole string, format is:
|
||||||
|
// {'world', 'x,y,z'[, 'pitch', 'yaw']}
|
||||||
|
String[] split = locationString.split(":");
|
||||||
|
if (split.length < 2 || split.length > 4) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// Split the xyz string, format is:
|
||||||
|
// {'x', 'y', 'z'}
|
||||||
|
String[] xyzsplit = split[1].split(",");
|
||||||
|
if (xyzsplit.length != 3) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the world is valid
|
||||||
|
World w = Bukkit.getWorld(split[0]);
|
||||||
|
if (w == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
float pitch = 0;
|
||||||
|
float yaw = 0;
|
||||||
|
if (split.length >= 3) {
|
||||||
|
yaw = (float) Double.parseDouble(split[2]);
|
||||||
|
}
|
||||||
|
if (split.length == 4) {
|
||||||
|
pitch = (float) Double.parseDouble(split[3]);
|
||||||
|
}
|
||||||
|
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]), yaw, pitch);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a colored string with the coords
|
* Returns a colored string with the coords
|
||||||
*
|
*
|
||||||
* @param l
|
* @param l The {@link Location}
|
||||||
* @return
|
* @return The {@link String}
|
||||||
*/
|
*/
|
||||||
public static String strCoords(Location l) {
|
public static String strCoords(Location l) {
|
||||||
String result = "";
|
String result = "";
|
||||||
@ -97,8 +127,8 @@ public class LocationManipulation {
|
|||||||
/**
|
/**
|
||||||
* Converts a location to a printable readable formatted string including pitch/yaw
|
* Converts a location to a printable readable formatted string including pitch/yaw
|
||||||
*
|
*
|
||||||
* @param l
|
* @param l The {@link Location}
|
||||||
* @return
|
* @return The {@link String}
|
||||||
*/
|
*/
|
||||||
public static String strCoordsRaw(Location l) {
|
public static String strCoordsRaw(Location l) {
|
||||||
String result = "";
|
String result = "";
|
||||||
@ -116,8 +146,8 @@ public class LocationManipulation {
|
|||||||
/**
|
/**
|
||||||
* Return the NESW Direction a Location is facing.
|
* Return the NESW Direction a Location is facing.
|
||||||
*
|
*
|
||||||
* @param location
|
* @param location The {@link Location}
|
||||||
* @return
|
* @return The NESW Direction
|
||||||
*/
|
*/
|
||||||
public static String getDirection(Location location) {
|
public static String getDirection(Location location) {
|
||||||
double r = (location.getYaw() % 360) + 180;
|
double r = (location.getYaw() % 360) + 180;
|
||||||
@ -146,10 +176,10 @@ public class LocationManipulation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the float yaw position for the given cardianl direction
|
* Returns the float yaw position for the given cardinal direction
|
||||||
*
|
*
|
||||||
* @param orientation
|
* @param orientation The cardinal direction
|
||||||
* @return
|
* @return The yaw
|
||||||
*/
|
*/
|
||||||
public static float getYaw(String orientation) {
|
public static float getYaw(String orientation) {
|
||||||
if (orientation == null) {
|
if (orientation == null) {
|
||||||
@ -164,8 +194,8 @@ public class LocationManipulation {
|
|||||||
/**
|
/**
|
||||||
* Returns a speed float from a given vector.
|
* Returns a speed float from a given vector.
|
||||||
*
|
*
|
||||||
* @param v
|
* @param v The {@link Vector}
|
||||||
* @return
|
* @return The speed
|
||||||
*/
|
*/
|
||||||
public static float getSpeed(Vector v) {
|
public static float getSpeed(Vector v) {
|
||||||
return (float) Math.sqrt(v.getX() * v.getX() + v.getZ() * v.getZ());
|
return (float) Math.sqrt(v.getX() * v.getX() + v.getZ() * v.getZ());
|
||||||
@ -177,9 +207,9 @@ public class LocationManipulation {
|
|||||||
/**
|
/**
|
||||||
* Returns a translated vector from the given direction
|
* Returns a translated vector from the given direction
|
||||||
*
|
*
|
||||||
* @param v
|
* @param v The old {@link Vector}
|
||||||
* @param direction
|
* @param direction The new direction
|
||||||
* @return
|
* @return The translated {@link Vector}
|
||||||
*/
|
*/
|
||||||
public static Vector getTranslatedVector(Vector v, String direction) {
|
public static Vector getTranslatedVector(Vector v, String direction) {
|
||||||
if (direction == null) {
|
if (direction == null) {
|
||||||
@ -209,10 +239,10 @@ public class LocationManipulation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next Location that an entity is traveling at
|
* Returns the next Location that a {@link Vehicle} is traveling at
|
||||||
*
|
*
|
||||||
* @param v
|
* @param v The {@link Vehicle}
|
||||||
* @return
|
* @return The {@link Location}
|
||||||
*/
|
*/
|
||||||
public static Location getNextBlock(Vehicle v) {
|
public static Location getNextBlock(Vehicle v) {
|
||||||
Vector vector = v.getVelocity();
|
Vector vector = v.getVelocity();
|
||||||
@ -221,43 +251,4 @@ public class LocationManipulation {
|
|||||||
int z = vector.getZ() < 0 ? vector.getZ() == 0 ? 0 : -1 : 1;
|
int z = vector.getZ() < 0 ? vector.getZ() == 0 ? 0 : -1 : 1;
|
||||||
return location.add(x, 0, z);
|
return location.add(x, 0, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getLocationFromString(String value) {
|
|
||||||
//format:
|
|
||||||
//world:x,y,z:pitch:yaw
|
|
||||||
if (value == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Split the whole string, format is:
|
|
||||||
// {'world', 'x,y,z'[, 'pitch', 'yaw']}
|
|
||||||
String[] split = value.split(":");
|
|
||||||
if (split.length < 2 || split.length > 4) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// Split the xyz string, format is:
|
|
||||||
// {'x', 'y', 'z'}
|
|
||||||
String[] xyzsplit = split[1].split(",");
|
|
||||||
if (xyzsplit.length != 3) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify the world is valid
|
|
||||||
World w = Bukkit.getWorld(split[0]);
|
|
||||||
if (w == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (split.length == 2) {
|
|
||||||
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]));
|
|
||||||
}
|
|
||||||
if (split.length == 3) {
|
|
||||||
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]), (float) Double.parseDouble(split[2]), (float) 0.0);
|
|
||||||
}
|
|
||||||
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]), (float) Double.parseDouble(split[2]), (float) Double.parseDouble(split[3]));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ public class MVPermissions implements PermissionsInterface {
|
|||||||
/**
|
/**
|
||||||
* Check if a Player can teleport to the Destination world from there current world.
|
* Check if a Player can teleport to the Destination world from there current world.
|
||||||
*
|
*
|
||||||
* @param p The player to check.
|
* @param p The {@link Player} to check.
|
||||||
* @param w
|
* @param w The {@link MultiverseWorld} the player wants to teleport to.
|
||||||
* @return
|
* @return Whether the player can teleport to the given {@link MultiverseWorld}.
|
||||||
*/
|
*/
|
||||||
public boolean canTravelFromWorld(Player p, MultiverseWorld w) {
|
public boolean canTravelFromWorld(Player p, MultiverseWorld w) {
|
||||||
List<String> blackList = w.getWorldBlacklist();
|
List<String> blackList = w.getWorldBlacklist();
|
||||||
@ -72,9 +72,9 @@ public class MVPermissions implements PermissionsInterface {
|
|||||||
/**
|
/**
|
||||||
* Check if the Player has the permissions to enter this world.
|
* Check if the Player has the permissions to enter this world.
|
||||||
*
|
*
|
||||||
* @param p
|
* @param p The {@link Player} player that wants to enter
|
||||||
* @param w
|
* @param w The {@link MultiverseWorld} he wants to enter
|
||||||
* @return
|
* @return Whether he has the permission to enter the world
|
||||||
*/
|
*/
|
||||||
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
||||||
// If we're not enforcing access, anyone can enter.
|
// If we're not enforcing access, anyone can enter.
|
||||||
@ -285,9 +285,6 @@ public class MVPermissions implements PermissionsInterface {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
|
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
|
||||||
*
|
|
||||||
* @param seperated
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private String getParentPerm(String[] seperated) {
|
private String getParentPerm(String[] seperated) {
|
||||||
if (seperated.length == 1) {
|
if (seperated.length == 1) {
|
||||||
|
@ -35,8 +35,6 @@ public class MVPlayerSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab whether the cooldown on Portal use has expired or not.
|
* Grab whether the cooldown on Portal use has expired or not.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean getTeleportable() {
|
public boolean getTeleportable() {
|
||||||
Long time = (new Date()).getTime();
|
Long time = (new Date()).getTime();
|
||||||
|
@ -106,7 +106,7 @@ public class PermissionTools {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if player can go to a world given their current status.
|
* Checks to see if player can go to a world given their current status.
|
||||||
* <p/>
|
* <p>
|
||||||
* The return is a little backwards, and will return a value safe for event.setCancelled.
|
* The return is a little backwards, and will return a value safe for event.setCancelled.
|
||||||
*
|
*
|
||||||
* @param fromWorld The MultiverseWorld they are in.
|
* @param fromWorld The MultiverseWorld they are in.
|
||||||
|
@ -85,11 +85,10 @@ public class UpdateChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the given Version String to a Normalised Version String so we can compare it.
|
* Convert the given Version String to a Normalized Version String so we can compare it.
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version The version string
|
||||||
*
|
* @return The normalized version string
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static String normalisedVersion(String version) {
|
public static String normalisedVersion(String version) {
|
||||||
return normalisedVersion(version, ".", 4);
|
return normalisedVersion(version, ".", 4);
|
||||||
|
@ -8,7 +8,6 @@ import java.net.MalformedURLException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class PastebinPasteService implements PasteService {
|
public class PastebinPasteService implements PasteService {
|
||||||
|
@ -1 +1,17 @@
|
|||||||
TEST_STRING: a test-string from the resource
|
TEST_STRING: a test-string from the resource
|
||||||
|
|
||||||
|
# Generic Strings
|
||||||
|
GENERIC_SORRY: Sorry...
|
||||||
|
GENERIC_PAGE: Page
|
||||||
|
GENERIC_OF: of
|
||||||
|
GENERIC_UNLOADED: UNLOADED
|
||||||
|
|
||||||
|
# Commands
|
||||||
|
|
||||||
|
# List Command
|
||||||
|
LIST_NAME: World Listing
|
||||||
|
LIST_DESC: Displays a listing of all worlds that you can enter.
|
||||||
|
|
||||||
|
LIST_TITLE: Multiverse World List
|
||||||
|
LIST_NO_MATCH: No worlds matched your filter:
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.test;
|
package com.onarandombox.MultiverseCore.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
@ -7,15 +7,13 @@
|
|||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test;
|
package com.onarandombox.MultiverseCore.test;
|
||||||
|
|
||||||
import static junit.framework.Assert.*;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import static org.mockito.Mockito.*;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
|
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||||
import java.io.File;
|
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||||
|
import com.onarandombox.MultiverseCore.test.utils.WorldCreatorMatcher;
|
||||||
import org.bukkit.Bukkit;
|
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
@ -30,18 +28,18 @@ import org.mockito.internal.verification.VerificationModeFactory;
|
|||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import java.io.File;
|
||||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
|
||||||
import com.onarandombox.MultiverseCore.test.utils.WorldCreatorMatcher;
|
import static junit.framework.Assert.*;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ PluginManager.class, MultiverseCore.class, Permission.class, Bukkit.class, WorldManager.class })
|
@PrepareForTest({ PluginManager.class, MultiverseCore.class, Permission.class, Bukkit.class, WorldManager.class })
|
||||||
public class TestWorldStuff {
|
public class TestWorldStuff {
|
||||||
|
|
||||||
TestInstanceCreator creator;
|
private TestInstanceCreator creator;
|
||||||
Server mockServer;
|
private Server mockServer;
|
||||||
CommandSender mockCommandSender;
|
private CommandSender mockCommandSender;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@ -76,7 +74,7 @@ public class TestWorldStuff {
|
|||||||
// Initialize a fake command
|
// Initialize a fake command
|
||||||
Command mockCommand = mock(Command.class);
|
Command mockCommand = mock(Command.class);
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
when(mockCommand.getName()).thenReturn("mv");
|
||||||
String[] normalArgs = new String[] { "import", "world", "normal" };
|
String[] normalArgs = new String[]{ "import", "world", "normal" };
|
||||||
|
|
||||||
// Ensure we have a fresh copy of MV, 0 worlds.
|
// Ensure we have a fresh copy of MV, 0 worlds.
|
||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
@ -109,21 +107,21 @@ public class TestWorldStuff {
|
|||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Import the first world.
|
// Import the first world.
|
||||||
String[] normalArgs = new String[] { "import", "world", "normal" };
|
String[] normalArgs = new String[]{ "import", "world", "normal" };
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
||||||
|
|
||||||
// We should now have one world imported!
|
// We should now have one world imported!
|
||||||
assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Import the second world.
|
// Import the second world.
|
||||||
String[] netherArgs = new String[] { "import", "world_nether", "nether" };
|
String[] netherArgs = new String[]{ "import", "world_nether", "nether" };
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", netherArgs);
|
plugin.onCommand(mockCommandSender, mockCommand, "", netherArgs);
|
||||||
|
|
||||||
// We should now have 2 worlds imported!
|
// We should now have 2 worlds imported!
|
||||||
assertEquals(2, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(2, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Import the third world.
|
// Import the third world.
|
||||||
String[] skyArgs = new String[] { "import", "world_skylands", "end" };
|
String[] skyArgs = new String[]{ "import", "world_the_end", "end" };
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", skyArgs);
|
plugin.onCommand(mockCommandSender, mockCommand, "", skyArgs);
|
||||||
|
|
||||||
// We should now have 2 worlds imported!
|
// We should now have 2 worlds imported!
|
||||||
@ -132,7 +130,7 @@ public class TestWorldStuff {
|
|||||||
// Verify that the commandSender has been called 3 times.
|
// Verify that the commandSender has been called 3 times.
|
||||||
verify(mockCommandSender).sendMessage("Starting import of world 'world'...");
|
verify(mockCommandSender).sendMessage("Starting import of world 'world'...");
|
||||||
verify(mockCommandSender).sendMessage("Starting import of world 'world_nether'...");
|
verify(mockCommandSender).sendMessage("Starting import of world 'world_nether'...");
|
||||||
verify(mockCommandSender).sendMessage("Starting import of world 'world_skylands'...");
|
verify(mockCommandSender).sendMessage("Starting import of world 'world_the_end'...");
|
||||||
verify(mockCommandSender, VerificationModeFactory.times(3)).sendMessage("Complete!");
|
verify(mockCommandSender, VerificationModeFactory.times(3)).sendMessage("Complete!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +153,7 @@ public class TestWorldStuff {
|
|||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Create the world
|
// Create the world
|
||||||
String[] normalArgs = new String[] { "create", "newworld", "normal" };
|
String[] normalArgs = new String[]{ "create", "newworld", "normal" };
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
||||||
|
|
||||||
// We should now have one world!
|
// We should now have one world!
|
||||||
@ -168,4 +166,56 @@ public class TestWorldStuff {
|
|||||||
WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("newworld"));
|
WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("newworld"));
|
||||||
verify(mockServer).createWorld(Matchers.argThat(matcher));
|
verify(mockServer).createWorld(Matchers.argThat(matcher));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testModifyGameMode() {
|
||||||
|
// Pull a core instance from the server.
|
||||||
|
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
||||||
|
Command mockCommand = mock(Command.class);
|
||||||
|
when(mockCommand.getName()).thenReturn("mv");
|
||||||
|
|
||||||
|
// Ensure that there are no worlds imported. This is a fresh setup.
|
||||||
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
this.createInitialWorlds(plugin, mockCommand);
|
||||||
|
|
||||||
|
// Ensure that the default worlds have been created.
|
||||||
|
assertEquals(3, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
MultiverseWorld mainWorld = creator.getCore().getMVWorldManager().getMVWorld("world");
|
||||||
|
|
||||||
|
// Ensure that the default mode was normal.
|
||||||
|
assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());
|
||||||
|
|
||||||
|
// Set the mode to creative in world.
|
||||||
|
plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "mode", "creative", "world" });
|
||||||
|
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + "mode" + ChatColor.WHITE + " was set to " + ChatColor.GREEN + "creative");
|
||||||
|
// Ensure the world is now a creative world
|
||||||
|
assertEquals(GameMode.CREATIVE, mainWorld.getGameMode());
|
||||||
|
|
||||||
|
// More tests, with alternate syntax.
|
||||||
|
plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "gamemode", "0", "world" });
|
||||||
|
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + "gamemode" + ChatColor.WHITE + " was set to " + ChatColor.GREEN + "0");
|
||||||
|
assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());
|
||||||
|
|
||||||
|
// Now fail one.
|
||||||
|
plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "mode", "fish", "world" });
|
||||||
|
try {
|
||||||
|
verify(mockCommandSender).sendMessage(mainWorld.getProperty("mode", Object.class).getHelp());
|
||||||
|
} catch (PropertyDoesNotExistException e) {
|
||||||
|
fail("Mode property did not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "blah", "fish", "world" });
|
||||||
|
verify(mockCommandSender).sendMessage(ChatColor.RED + "Sorry, You can't set: '"+ChatColor.GRAY+ "blah" + ChatColor.RED + "'");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createInitialWorlds(Plugin plugin, Command command) {
|
||||||
|
plugin.onCommand(mockCommandSender, command, "", new String[]{ "import", "world", "normal" });
|
||||||
|
plugin.onCommand(mockCommandSender, command, "", new String[]{ "import", "world_nether", "nether" });
|
||||||
|
plugin.onCommand(mockCommandSender, command, "", new String[]{ "import", "world_the_end", "end" });
|
||||||
|
verify(mockCommandSender).sendMessage("Starting import of world 'world'...");
|
||||||
|
verify(mockCommandSender).sendMessage("Starting import of world 'world_nether'...");
|
||||||
|
verify(mockCommandSender).sendMessage("Starting import of world 'world_the_end'...");
|
||||||
|
verify(mockCommandSender, times(3)).sendMessage("Complete!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,7 +263,7 @@ public class MockBlock implements Block{
|
|||||||
/**
|
/**
|
||||||
* Captures the current state of this block. You may then cast that state
|
* Captures the current state of this block. You may then cast that state
|
||||||
* into any accepted type, such as Furnace or Sign.
|
* into any accepted type, such as Furnace or Sign.
|
||||||
* <p/>
|
* <p>
|
||||||
* The returned object will never be updated, and you are not guaranteed that
|
* The returned object will never be updated, and you are not guaranteed that
|
||||||
* (for example) a sign is still a sign after you capture its state.
|
* (for example) a sign is still a sign after you capture its state.
|
||||||
*
|
*
|
||||||
@ -352,7 +352,7 @@ public class MockBlock implements Block{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this block is empty.
|
* Checks if this block is empty.
|
||||||
* <p/>
|
* <p>
|
||||||
* A block is considered empty when {@link #getType()} returns {@link org.bukkit.Material#AIR}.
|
* A block is considered empty when {@link #getType()} returns {@link org.bukkit.Material#AIR}.
|
||||||
*
|
*
|
||||||
* @return true if this block is empty
|
* @return true if this block is empty
|
||||||
@ -364,7 +364,7 @@ public class MockBlock implements Block{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this block is liquid.
|
* Checks if this block is liquid.
|
||||||
* <p/>
|
* <p>
|
||||||
* A block is considered liquid when {@link #getType()} returns {@link org.bukkit.Material#WATER}, {@link
|
* A block is considered liquid when {@link #getType()} returns {@link org.bukkit.Material#WATER}, {@link
|
||||||
* org.bukkit.Material#STATIONARY_WATER}, {@link org.bukkit.Material#LAVA} or {@link
|
* org.bukkit.Material#STATIONARY_WATER}, {@link org.bukkit.Material#LAVA} or {@link
|
||||||
* org.bukkit.Material#STATIONARY_LAVA}.
|
* org.bukkit.Material#STATIONARY_LAVA}.
|
||||||
|
@ -7,9 +7,6 @@
|
|||||||
|
|
||||||
package com.onarandombox.MultiverseCore.test.utils;
|
package com.onarandombox.MultiverseCore.test.utils;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -18,6 +15,9 @@ import org.bukkit.permissions.PermissionAttachment;
|
|||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class TestCommandSender implements CommandSender {
|
public class TestCommandSender implements CommandSender {
|
||||||
|
|
||||||
private Server server;
|
private Server server;
|
||||||
@ -67,7 +67,6 @@ public class TestCommandSender implements CommandSender {
|
|||||||
* Checks if this object contains an override for the specified permission, by fully qualified name
|
* Checks if this object contains an override for the specified permission, by fully qualified name
|
||||||
*
|
*
|
||||||
* @param name Name of the permission
|
* @param name Name of the permission
|
||||||
*
|
|
||||||
* @return true if the permission is set, otherwise false
|
* @return true if the permission is set, otherwise false
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -79,7 +78,6 @@ public class TestCommandSender implements CommandSender {
|
|||||||
* Checks if this object contains an override for the specified {@link org.bukkit.permissions.Permission}
|
* Checks if this object contains an override for the specified {@link org.bukkit.permissions.Permission}
|
||||||
*
|
*
|
||||||
* @param perm Permission to check
|
* @param perm Permission to check
|
||||||
*
|
|
||||||
* @return true if the permission is set, otherwise false
|
* @return true if the permission is set, otherwise false
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -89,11 +87,10 @@ public class TestCommandSender implements CommandSender {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the specified permission, if set.
|
* Gets the value of the specified permission, if set.
|
||||||
* <p/>
|
* <p>
|
||||||
* If a permission override is not set on this object, the default value of the permission will be returned.
|
* If a permission override is not set on this object, the default value of the permission will be returned.
|
||||||
*
|
*
|
||||||
* @param name Name of the permission
|
* @param name Name of the permission
|
||||||
*
|
|
||||||
* @return Value of the permission
|
* @return Value of the permission
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -103,11 +100,10 @@ public class TestCommandSender implements CommandSender {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the value of the specified permission, if set.
|
* Gets the value of the specified permission, if set.
|
||||||
* <p/>
|
* <p>
|
||||||
* If a permission override is not set on this object, the default value of the permission will be returned
|
* If a permission override is not set on this object, the default value of the permission will be returned
|
||||||
*
|
*
|
||||||
* @param perm Permission to get
|
* @param perm Permission to get
|
||||||
*
|
|
||||||
* @return Value of the permission
|
* @return Value of the permission
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -121,7 +117,6 @@ public class TestCommandSender implements CommandSender {
|
|||||||
* @param plugin Plugin responsible for this attachment, may not be null or disabled
|
* @param plugin Plugin responsible for this attachment, may not be null or disabled
|
||||||
* @param name Name of the permission to attach
|
* @param name Name of the permission to attach
|
||||||
* @param value Value of the permission
|
* @param value Value of the permission
|
||||||
*
|
|
||||||
* @return The PermissionAttachment that was just created
|
* @return The PermissionAttachment that was just created
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -133,7 +128,6 @@ public class TestCommandSender implements CommandSender {
|
|||||||
* Adds a new empty {@link org.bukkit.permissions.PermissionAttachment} to this object
|
* Adds a new empty {@link org.bukkit.permissions.PermissionAttachment} to this object
|
||||||
*
|
*
|
||||||
* @param plugin Plugin responsible for this attachment, may not be null or disabled
|
* @param plugin Plugin responsible for this attachment, may not be null or disabled
|
||||||
*
|
|
||||||
* @return The PermissionAttachment that was just created
|
* @return The PermissionAttachment that was just created
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -149,7 +143,6 @@ public class TestCommandSender implements CommandSender {
|
|||||||
* @param name Name of the permission to attach
|
* @param name Name of the permission to attach
|
||||||
* @param value Value of the permission
|
* @param value Value of the permission
|
||||||
* @param ticks Amount of ticks to automatically remove this attachment after
|
* @param ticks Amount of ticks to automatically remove this attachment after
|
||||||
*
|
|
||||||
* @return The PermissionAttachment that was just created
|
* @return The PermissionAttachment that was just created
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -162,7 +155,6 @@ public class TestCommandSender implements CommandSender {
|
|||||||
*
|
*
|
||||||
* @param plugin Plugin responsible for this attachment, may not be null or disabled
|
* @param plugin Plugin responsible for this attachment, may not be null or disabled
|
||||||
* @param ticks Amount of ticks to automatically remove this attachment after
|
* @param ticks Amount of ticks to automatically remove this attachment after
|
||||||
*
|
|
||||||
* @return The PermissionAttachment that was just created
|
* @return The PermissionAttachment that was just created
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -174,7 +166,6 @@ public class TestCommandSender implements CommandSender {
|
|||||||
* Removes the given {@link org.bukkit.permissions.PermissionAttachment} from this object
|
* Removes the given {@link org.bukkit.permissions.PermissionAttachment} from this object
|
||||||
*
|
*
|
||||||
* @param attachment Attachment to remove
|
* @param attachment Attachment to remove
|
||||||
*
|
|
||||||
* @throws IllegalArgumentException Thrown when the specified attachment isn't part of this object
|
* @throws IllegalArgumentException Thrown when the specified attachment isn't part of this object
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -183,7 +174,7 @@ public class TestCommandSender implements CommandSender {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Recalculates the permissions for this object, if the attachments have changed values.
|
* Recalculates the permissions for this object, if the attachments have changed values.
|
||||||
* <p/>
|
* <p>
|
||||||
* This should very rarely need to be called from a plugin.
|
* This should very rarely need to be called from a plugin.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,6 +46,7 @@ public class TestInstanceCreator {
|
|||||||
|
|
||||||
public static final File pluginDirectory = new File("bin/test/server/plugins/coretest");
|
public static final File pluginDirectory = new File("bin/test/server/plugins/coretest");
|
||||||
public static final File serverDirectory = new File("bin/test/server");
|
public static final File serverDirectory = new File("bin/test/server");
|
||||||
|
public static final File worldsDirectory = new File("bin/test/server");
|
||||||
|
|
||||||
public boolean setUp() {
|
public boolean setUp() {
|
||||||
try {
|
try {
|
||||||
@ -81,7 +82,7 @@ public class TestInstanceCreator {
|
|||||||
File worldNetherFile = new File(core.getServerFolder(), "world_nether");
|
File worldNetherFile = new File(core.getServerFolder(), "world_nether");
|
||||||
Util.log("Creating world-folder: " + worldNetherFile.getAbsolutePath());
|
Util.log("Creating world-folder: " + worldNetherFile.getAbsolutePath());
|
||||||
worldNetherFile.mkdirs();
|
worldNetherFile.mkdirs();
|
||||||
File worldSkylandsFile = new File(core.getServerFolder(), "world_skylands");
|
File worldSkylandsFile = new File(core.getServerFolder(), "world_the_end");
|
||||||
Util.log("Creating world-folder: " + worldSkylandsFile.getAbsolutePath());
|
Util.log("Creating world-folder: " + worldSkylandsFile.getAbsolutePath());
|
||||||
worldSkylandsFile.mkdirs();
|
worldSkylandsFile.mkdirs();
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ public class TestInstanceCreator {
|
|||||||
when(mockServer.getName()).thenReturn("TestBukkit");
|
when(mockServer.getName()).thenReturn("TestBukkit");
|
||||||
Logger.getLogger("Minecraft").setParent(Util.logger);
|
Logger.getLogger("Minecraft").setParent(Util.logger);
|
||||||
when(mockServer.getLogger()).thenReturn(Util.logger);
|
when(mockServer.getLogger()).thenReturn(Util.logger);
|
||||||
|
when(mockServer.getWorldContainer()).thenReturn(worldsDirectory);
|
||||||
|
|
||||||
// Give the server some worlds
|
// Give the server some worlds
|
||||||
when(mockServer.getWorld(anyString())).thenAnswer(new Answer<World>() {
|
when(mockServer.getWorld(anyString())).thenAnswer(new Answer<World>() {
|
||||||
|
@ -42,10 +42,10 @@ public class WorldCreatorMatcher extends ArgumentMatcher<WorldCreator> {
|
|||||||
Util.log("Checking Environments...");
|
Util.log("Checking Environments...");
|
||||||
return false;
|
return false;
|
||||||
} else if (careAboutSeeds && ((WorldCreator) creator).seed() != this.worldCreator.seed()) {
|
} else if (careAboutSeeds && ((WorldCreator) creator).seed() != this.worldCreator.seed()) {
|
||||||
System.out.print("Checking Seeds...");
|
Util.log("Checking Seeds...");
|
||||||
return false;
|
return false;
|
||||||
} else if (careAboutGenerators && !((WorldCreator) creator).generator().equals(this.worldCreator.generator())) {
|
} else if (careAboutGenerators && !((WorldCreator) creator).generator().equals(this.worldCreator.generator())) {
|
||||||
System.out.print("Checking Gens...");
|
Util.log("Checking Gens...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Util.log("Creators matched!!!");
|
Util.log("Creators matched!!!");
|
||||||
|
Loading…
Reference in New Issue
Block a user