Compare commits

..
Author SHA1 Message Date
main() b39839b216 Merge branch 'master' of github.com:Multiverse/Multiverse-Core into generate-structures 2012-02-26 16:53:38 +01:00
main() 309518723f Merge branch 'master' of github.com:Multiverse/Multiverse-Core into generate-structures
Conflicts:
	pom.xml
	src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java
	src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java
2012-02-04 19:59:26 +01:00
Eric Stokes 4631fd0a61 Implement new generate structures 2012-01-29 10:42:06 -07:00
209 changed files with 3993 additions and 8840 deletions

No files matched your search

-44
View File
@@ -1,44 +0,0 @@
# Eclipse stuff
/.classpath
/.project
/.settings
/.checkstyle
# netbeans
/nbproject
# we use maven!
/build.xml
# maven
/target
# vim
.*.sw[a-p]
# various other potential build files
/build
/bin
/dist
/manifest.mf
/world
# Mac filesystem dust
*.DS_Store
# intellij
*.iml
*.ipr
*.iws
.idea/
# Fern's utils
uploadtoserver.sh
# Testing files:
debug.log
# Doxygen
/docs/html
debug.txt
-140
View File
@@ -1,140 +0,0 @@
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Multiverse 2 Copyright (c) the Multiverse Team 2012. ~
~ Multiverse 2 is licensed under the BSD License. ~
~ For more information please check the README.md file included ~
~ with this project. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- Future reference: valid severity values are 'ignore', 'info', 'warning', 'error' -->
<module name="Checker">
<module name="JavadocPackage">
<property name="allowLegacy" value="true"/>
</module>
<module name="NewlineAtEndOfFile">
<property name="severity" value="info"/>
</module>
<module name="Translation"/>
<module name="FileLength"/>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="RegexpSingleline">
<property name="message" value="Line has trailing spaces."/>
<property name="format" value="\s+$"/>
</module>
<module name="SuppressWithNearbyCommentFilter">
<property name="commentFormat" value="SUPPRESS CHECKSTYLE: (\w+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: (\w+)"/>
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: (\w+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: ALL"/>
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: ALL"/>
</module>
<module name="TreeWalker">
<!-- Make suppression possible -->
<module name="FileContentsHolder"/>
<!-- Actual checks -->
<module name="LineLength">
<property name="max" value="120"/>
<property name="severity" value="warning"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="package"/><!-- We don't need javadoc for private methods -->
<property name="tokens" value="METHOD_DEF"/><!-- We don't need javadoc for constructors -->
</module>
<module name="JavadocType"/>
<module name="JavadocVariable">
<property name="scope" value="package"/><!-- We don't need javadoc for private variables -->
</module>
<module name="JavadocStyle"/>
<module name="WriteTag">
<property name="tag" value="@author"/>
<property name="tagFormat" value="\S"/>
<property name="severity" value="ignore"/>
<property name="tagSeverity" value="warning"/>
</module>
<module name="ConstantName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="AvoidStarImport">
<property name="severity" value="warning"/>
</module>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter">
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
</module>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter">
<property name="severity" value="warning"/>
</module>
<module name="WhitespaceAround">
<property name="severity" value="warning"/>
</module>
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock">
<property name="tokens" value="LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_IF,LITERAL_FOR,LITERAL_TRY,LITERAL_WHILE,INSTANCE_INIT,STATIC_INIT"/>
</module>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="DoubleCheckedLocking"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
<property name="tokens" value="VARIABLE_DEF"/><!-- We don't care if parameters hide fields. -->
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber">
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3"/>
</module>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="DesignForExtension"/>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier">
<property name="packageAllowed" value="true"/>
<property name="protectedAllowed" value="true"/>
</module>
<module name="ArrayTypeStyle"/>
<module name="FinalParameters"/>
<module name="TodoComment">
<property name="severity" value="info"/>
</module>
<module name="UpperEll"/>
<module name="Indentation"/>
<module name="MissingDeprecated"/>
<module name="MissingOverride"/>
</module>
</module>
-186
View File
@@ -1,186 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mvplugin</groupId>
<artifactId>MultiverseCore</artifactId>
<version>3.0-SNAPSHOT</version>
</parent>
<artifactId>MultiverseCore-Base</artifactId>
<repositories>
<repository>
<id>onarandombox</id>
<url>http://repo.onarandombox.com/content/groups/public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>doodleproject-repo</id>
<name>DoodleProject Maven 2 Repository</name>
<url>http://doodleproject.sourceforge.net/maven2/release</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<!-- 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>
<defaultGoal>clean package</defaultGoal>
<plugins>
<!-- Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestEntries>
</manifestEntries>
</archive>
</configuration>
</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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.8</version>
<configuration>
<enableRulesSummary>true</enableRulesSummary>
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>javadoc-jar</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Start of PluginBase Dependency -->
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>Plugin</artifactId>
<version>1.5-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of PluginBase Dependency -->
<!-- Start of Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.4.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>1.4.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.4.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<!-- End of Test Dependencies -->
</dependencies>
<distributionManagement>
<repository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse/</url>
</repository>
<snapshotRepository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
@@ -1,329 +0,0 @@
package com.mvplugin.core;
import com.mvplugin.core.api.MultiverseWorld;
import com.mvplugin.core.api.WorldProperties;
import com.mvplugin.core.api.WorldProperties.Spawning;
import com.mvplugin.core.minecraft.Difficulty;
import com.mvplugin.core.minecraft.GameMode;
import com.mvplugin.core.minecraft.PlayerPosition;
import com.mvplugin.core.minecraft.PortalType;
import com.mvplugin.core.minecraft.WorldEnvironment;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
abstract class AbstractMultiverseWorld implements MultiverseWorld, Observer {
private final WorldProperties worldProperties;
protected AbstractMultiverseWorld(final WorldProperties worldProperties) {
this.worldProperties = worldProperties;
worldProperties.addObserver(this);
worldProperties.get(WorldProperties.SPAWNING).get(Spawning.ANIMALS).addObserver(this);
worldProperties.get(WorldProperties.SPAWNING).get(Spawning.MONSTERS).addObserver(this);
}
@Override
public final void update(Observable o, Object arg) {
update(arg);
}
protected abstract void update(Object property);
@Override
public WorldEnvironment getEnvironment() {
return getProperties().get(WorldProperties.ENVIRONMENT);
}
@Override
public void setEnvironment(final WorldEnvironment environment) {
getProperties().set(WorldProperties.ENVIRONMENT, environment);
}
@Override
public Difficulty getDifficulty() {
return getProperties().get(WorldProperties.DIFFICULTY);
}
@Override
public boolean setDifficulty(final Difficulty difficulty) {
// TODO Validate?
return getProperties().set(WorldProperties.DIFFICULTY, difficulty);
}
@Override
public long getSeed() {
return getProperties().get(WorldProperties.SEED);
}
@Override
public void setSeed(long seed) {
getProperties().set(WorldProperties.SEED, seed);
}
@Override
public String getGenerator() {
return getProperties().get(WorldProperties.GENERATOR);
}
@Override
public void setGenerator(final String generator) {
getProperties().set(WorldProperties.GENERATOR, generator != null ? generator : "");
}
@Override
public WorldProperties getProperties() {
return worldProperties;
}
@Override
public String getAllPropertyNames() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public String getAlias() {
return getProperties().get(WorldProperties.ALIAS);
}
@Override
public void setAlias(final String alias) {
getProperties().set(WorldProperties.ALIAS, alias != null ? alias : "");
}
@Override
public boolean canAnimalsSpawn() {
return getProperties().get(WorldProperties.SPAWNING)
.get(WorldProperties.Spawning.ANIMALS)
.get(WorldProperties.Spawning.Animals.SPAWN);
}
@Override
public void setAllowAnimalSpawn(final boolean allowAnimalSpawn) {
getProperties().get(WorldProperties.SPAWNING)
.get(WorldProperties.Spawning.ANIMALS)
.set(WorldProperties.Spawning.Animals.SPAWN, allowAnimalSpawn);
}
@Override
public List<String> getAnimalList() {
return getProperties().get(WorldProperties.SPAWNING)
.get(WorldProperties.Spawning.ANIMALS)
.get(WorldProperties.Spawning.Animals.EXCEPTIONS);
}
@Override
public boolean canMonstersSpawn() {
return getProperties().get(WorldProperties.SPAWNING)
.get(WorldProperties.Spawning.MONSTERS)
.get(WorldProperties.Spawning.Monsters.SPAWN);
}
@Override
public void setAllowMonsterSpawn(final boolean allowMonsterSpawn) {
getProperties().get(WorldProperties.SPAWNING)
.get(WorldProperties.Spawning.MONSTERS)
.set(WorldProperties.Spawning.Monsters.SPAWN, allowMonsterSpawn);
}
@Override
public List<String> getMonsterList() {
return getProperties().get(WorldProperties.SPAWNING)
.get(WorldProperties.Spawning.ANIMALS)
.get(WorldProperties.Spawning.Monsters.EXCEPTIONS);
}
@Override
public boolean isPVPEnabled() {
return getProperties().get(WorldProperties.PVP);
}
@Override
public void setPVPMode(final boolean pvpMode) {
getProperties().set(WorldProperties.PVP, pvpMode);
}
@Override
public boolean isHidden() {
return getProperties().get(WorldProperties.HIDDEN);
}
@Override
public void setHidden(final boolean hidden) {
getProperties().set(WorldProperties.HIDDEN, hidden);
}
@Override
public boolean getPrefixChat() {
return getProperties().get(WorldProperties.PREFIX_CHAT);
}
@Override
public void setPrefixChat(final boolean prefixChat) {
getProperties().set(WorldProperties.PREFIX_CHAT, prefixChat);
}
@Override
public boolean isWeatherEnabled() {
return getProperties().get(WorldProperties.ALLOW_WEATHER);
}
@Override
public void setEnableWeather(final boolean enableWeather) {
getProperties().set(WorldProperties.ALLOW_WEATHER, enableWeather);
}
@Override
public boolean isKeepingSpawnInMemory() {
return getProperties().get(WorldProperties.KEEP_SPAWN);
}
@Override
public void setKeepSpawnInMemory(final boolean keepSpawnInMemory) {
getProperties().set(WorldProperties.KEEP_SPAWN, keepSpawnInMemory);
}
@Override
public PlayerPosition getSpawnLocation() {
return getProperties().get(WorldProperties.SPAWN_LOCATION);
}
@Override
public void setSpawnLocation(final PlayerPosition spawnLocation) {
getProperties().set(WorldProperties.SPAWN_LOCATION, spawnLocation);
}
@Override
public boolean getHunger() {
return getProperties().get(WorldProperties.HUNGER);
}
@Override
public void setHunger(final boolean hungerEnabled) {
getProperties().set(WorldProperties.HUNGER, hungerEnabled);
}
@Override
public GameMode getGameMode() {
return getProperties().get(WorldProperties.GAME_MODE);
}
@Override
public boolean setGameMode(final GameMode gameMode) {
// Todo validate?
return getProperties().set(WorldProperties.GAME_MODE, gameMode);
}
@Override
public double getPrice() {
return getProperties().get(WorldProperties.ENTRY_FEE).get(WorldProperties.EntryFee.AMOUNT);
}
@Override
public void setPrice(final double price) {
getProperties().get(WorldProperties.ENTRY_FEE).set(WorldProperties.EntryFee.AMOUNT, price);
}
@Override
public int getCurrency() {
return getProperties().get(WorldProperties.ENTRY_FEE).get(WorldProperties.EntryFee.CURRENCY);
}
@Override
public void setCurrency(final int item) {
getProperties().get(WorldProperties.ENTRY_FEE).set(WorldProperties.EntryFee.CURRENCY, item);
}
@Override
public String getRespawnToWorld() {
return getProperties().get(WorldProperties.RESPAWN_WORLD);
}
@Override
public boolean setRespawnToWorld(final String respawnWorld) {
// TODO validation?
return getProperties().set(WorldProperties.RESPAWN_WORLD, respawnWorld);
}
@Override
public double getScaling() {
return getProperties().get(WorldProperties.SCALE);
}
@Override
public boolean setScaling(final double scaling) {
// TODO validation?
return getProperties().set(WorldProperties.SCALE, scaling);
}
@Override
public boolean getAutoHeal() {
return getProperties().get(WorldProperties.AUTO_HEAL);
}
@Override
public void setAutoHeal(final boolean heal) {
getProperties().set(WorldProperties.AUTO_HEAL, heal);
}
@Override
public boolean getAdjustSpawn() {
return getProperties().get(WorldProperties.ADJUST_SPAWN);
}
@Override
public void setAdjustSpawn(final boolean adjust) {
getProperties().set(WorldProperties.ADJUST_SPAWN, adjust);
}
@Override
public boolean getAutoLoad() {
return getProperties().get(WorldProperties.AUTO_LOAD);
}
@Override
public void setAutoLoad(final boolean autoLoad) {
getProperties().set(WorldProperties.AUTO_LOAD, autoLoad);
}
@Override
public boolean getBedRespawn() {
return getProperties().get(WorldProperties.BED_RESPAWN);
}
@Override
public void setBedRespawn(final boolean bedRespawn) {
getProperties().set(WorldProperties.BED_RESPAWN, bedRespawn);
}
@Override
public void setPlayerLimit(final int limit) {
getProperties().set(WorldProperties.PLAYER_LIMIT, limit);
}
@Override
public int getPlayerLimit() {
return getProperties().get(WorldProperties.PLAYER_LIMIT);
}
@Override
public void allowPortalMaking(final PortalType type) {
getProperties().set(WorldProperties.PORTAL_FORM, type);
}
@Override
public PortalType getAllowedPortals() {
return getProperties().get(WorldProperties.PORTAL_FORM);
}
@Override
public List<String> getWorldBlacklist() {
return getProperties().get(WorldProperties.BLACK_LIST);
}
@Override
public void save() {
getProperties().flush();
}
}
@@ -1,112 +0,0 @@
package com.mvplugin.core;
import com.dumptruckman.minecraft.pluginbase.messaging.BundledMessage;
import com.mvplugin.core.api.MultiverseCore;
import com.mvplugin.core.api.MultiverseWorld;
import com.mvplugin.core.api.WorldManager;
import com.mvplugin.core.minecraft.WorldEnvironment;
import com.mvplugin.core.minecraft.WorldType;
import com.mvplugin.core.util.Language;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
abstract class AbstractWorldManager implements WorldManager {
protected final MultiverseCore core;
protected final Map<String, MultiverseWorld> worldsMap;
protected AbstractWorldManager(final MultiverseCore core) {
this.core = core;
this.worldsMap = new HashMap<String, MultiverseWorld>();
}
@Override
public MultiverseWorld addWorld(String name, WorldEnvironment env, String seedString, WorldType type, Boolean generateStructures, String generator) throws WorldCreationException {
return this.addWorld(name, env, seedString, type, generateStructures, generator, true);
}
@Override
public MultiverseWorld addWorld(String name,
WorldEnvironment env,
String seedString,
WorldType type,
Boolean generateStructures,
String generator,
boolean useSpawnAdjust) throws WorldCreationException {
final WorldCreationSettings settings = new WorldCreationSettings(name);
if (seedString != null && !seedString.isEmpty()) {
try {
settings.seed(Long.parseLong(seedString));
} catch (NumberFormatException numberformatexception) {
settings.seed((long) seedString.hashCode());
}
}
settings.type(type);
settings.generateStructures(generateStructures);
// TODO: Use the fancy kind with the commandSender | dumptruckman has no idea what this means..
if (generator != null && !generator.isEmpty()) {
settings.generator(generator);
}
settings.adjustSpawn(useSpawnAdjust);
return addWorld(settings);
}
@Override
public MultiverseWorld addWorld(WorldCreationSettings settings) throws WorldCreationException {
if (this.worldsMap.containsKey(settings.name())) {
throw new WorldCreationException(new BundledMessage(Language.WORLD_ALREADY_EXISTS, settings.name()));
}
MultiverseWorld mvWorld = createWorld(settings);
mvWorld.setAdjustSpawn(settings.adjustSpawn());
this.worldsMap.put(settings.name(), mvWorld);
return mvWorld;
}
/**
* Creates a world with the given properties.
*
* If a Minecraft world is already loaded with this name, null will be returned. If a Minecraft world already
* exists but it not loaded, it will be loaded instead.
*
* @param name The name for the world. May not be null.
* @param env The environment for the world. May not be null.
* @param seed The seed for the world. Null means a random seed will be used if creating a new Minecraft world.
* @param type The world type for the world. Null means the Minecraft default will be used if creating a new
* Minecraft world or, if loading a world, the loaded world's type will be used.
* @param generateStructures Whether or not to generate structures for the world. Null means the Minecraft default
* will be used if creating a new world or, if loading a world, the loaded world's
* setting will be used.
* @param generator The name of the generator for the world. Null may be used to specify no generator.
* @return A new {@link W} or null if a Minecraft world by this name is already loaded.
* @throws WorldCreationException If any problems occured while trying to create the world.
*/
/**
* Creates a world with the given properties.
*
* If a Minecraft world is already loaded with this name, null will be returned. If a Minecraft world already
* exists but it not loaded, it will be loaded instead.
*
* @param settings
* @return
* @throws WorldCreationException
*/
protected abstract MultiverseWorld createWorld(WorldCreationSettings settings) throws WorldCreationException;
@Override
public boolean isMVWorld(final String name) {
return this.worldsMap.containsKey(name);
}
@Override
public Collection<MultiverseWorld> getMVWorlds() {
return Collections.unmodifiableCollection(this.worldsMap.values());
}
}
@@ -1,24 +0,0 @@
package com.mvplugin.core;
import com.dumptruckman.minecraft.pluginbase.messaging.BundledMessage;
import com.dumptruckman.minecraft.pluginbase.messaging.ChatColor;
public class MultiverseException extends Exception {
private final BundledMessage languageMessage;
public MultiverseException(BundledMessage b) {
super(String.format(ChatColor.translateAlternateColorCodes('&', b.getMessage().getDefault().get(0)), b.getArgs()));
this.languageMessage = b;
}
public MultiverseException(BundledMessage b, Throwable throwable) {
super(String.format(ChatColor.translateAlternateColorCodes('&', b.getMessage().getDefault().get(0)), b.getArgs()), throwable);
this.languageMessage = b;
}
public BundledMessage getBundledMessage() {
return this.languageMessage;
}
}
@@ -1,21 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.mvplugin.core;
/**
* Thrown when a world-property doesn't exist.
*/
public class UnknownPropertyException extends Exception {
public UnknownPropertyException(String name) {
super(name);
}
public UnknownPropertyException(String name, Throwable cause) {
super(name, cause);
}
}
@@ -1,14 +0,0 @@
package com.mvplugin.core;
import com.dumptruckman.minecraft.pluginbase.messaging.BundledMessage;
public class WorldCreationException extends MultiverseException {
public WorldCreationException(BundledMessage languageMessage) {
super(languageMessage);
}
public WorldCreationException(BundledMessage languageMessage, Throwable throwable) {
super(languageMessage, throwable);
}
}
@@ -1,11 +0,0 @@
package com.mvplugin.core.api;
import com.dumptruckman.minecraft.pluginbase.config.BaseConfig;
import com.dumptruckman.minecraft.pluginbase.properties.Properties;
/**
* This is where you will find all of the configuration options for the Multiverse-Core plugin and potentially some
* options used here and in other Multiverse plugins.
*/
public interface CoreConfig extends BaseConfig, Properties {
}
@@ -1,28 +0,0 @@
package com.mvplugin.core.api;
import com.dumptruckman.minecraft.pluginbase.plugin.PluginBase;
/**
* Multiverse 3 Core API
* <p>
* This API contains a bunch of useful things you can get out of Multiverse in general!
* This is the class you should cast your plugin to unless you need more Implementation specific API.
*/
public interface MultiverseCore extends MultiversePlugin, PluginBase {
/**
* Gets the Multiverse world manager.
*
* The world manager allows you to perform various tasks related to Minecraft worlds.
*
* @return {@link WorldManager}.
*/
WorldManager getWorldManager();
/**
* Gets the Multiverse-Core configuration.
*
* @return The Multiverse-Core configuration.
*/
CoreConfig getMVConfig();
}
@@ -1,31 +0,0 @@
package com.mvplugin.core.api;
/**
* Implement this if you would
*/
public interface MultiversePlugin {
/**
* Gets the reference to MultiverseCore.
*
* @return A valid {@link MultiverseCore}.
*/
MultiverseCore getCore();
/**
* Sets the reference to MultiverseCore.
*
* @param core A valid {@link MultiverseCore}.
*/
void setCore(MultiverseCore core);
/**
* Allows Multiverse or a plugin to query another Multiverse plugin to see what version its protocol is.
*
* This number should change when something will break the code. Generally your plugin should be checking the
* Multiverse-Core's protocol version to ensure compatibility.
*
* @return The protocol version.
*/
int getProtocolVersion();
}
@@ -1,508 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.mvplugin.core.api;
import com.mvplugin.core.minecraft.Difficulty;
import com.mvplugin.core.minecraft.GameMode;
import com.mvplugin.core.minecraft.PlayerPosition;
import com.mvplugin.core.minecraft.PortalType;
import com.mvplugin.core.minecraft.WorldEnvironment;
import com.mvplugin.core.minecraft.WorldType;
import java.util.List;
import java.util.UUID;
/**
* The API for a Multiverse Handled World.
*/
public interface MultiverseWorld {
/**
* Gets the name of this world. The name cannot be changed.
* <p>
* Note for plugin developers: Usually {@link #getAlias()}
* is what you want to use instead of this method.
*
* @return The name of the world as a String.
*/
String getName();
/**
* Gets the UUID for this world.
*
* This is what Minecraft uses to keep tracks of worlds.
*
* @return The UUID for this world.
*/
UUID getWorldUID();
/**
* Returns the WorldProperties object that contains the backing for all the values of a Multiverse World.
*
* All of these properties are generally gettable and settable via the MultiverseWorld class. Specific uses for
* the returned object may be to set properties in a different way and to perform more complex actions related
* to properties.
*
* @return The properties for this world.
*/
WorldProperties getProperties();
/**
* Gets the type of this world. As of 1.2 this will be:
* FLAT, NORMAL or VERSION_1_1
* <p>
* This is <b>not</b> the generator.
*
* @return The Type of this world.
*/
WorldType getWorldType();
/**
* Gets the environment of this world.
*
* This environment matches that of the actual game world.
*
* @return The environment of this world.
*/
WorldEnvironment getEnvironment();
/**
* Sets the environment of a world.
* <p>
* Note: This will ONLY take effect once the world is unloaded/reloaded.
*
* @param environment The new environment for the world.
*/
void setEnvironment(WorldEnvironment environment);
/**
* Gets the difficulty of this world.
*
* @return The difficulty of this world.
*/
Difficulty getDifficulty();
/**
* Sets the difficulty of this world and returns {@code true} on success.
* Valid string values are either an integer of difficulty(0-3) or
* the name that resides in the Bukkit enum, ex. PEACEFUL
*
* @param difficulty The new difficulty.
* @return True if success, false if the operation failed... for whatever reason.
*/
boolean setDifficulty(Difficulty difficulty);
/**
* Gets the world seed of this world.
*
* @return The Long version of the seed.
*/
long getSeed();
/**
* Sets the seed of this world.
*
* @param seed A Long that is the seed.
*/
void setSeed(long seed);
/**
* Gets the generator of this world.
*
* @return The name of the generator.
*/
String getGenerator();
/**
* Sets the generator of this world.
*
* @param generator The new generator's name.
*/
void setGenerator(String generator);
/**
* Gets all the names of all properties that can be SET.
*
* @return All property names, with alternating colors.
*/
String getAllPropertyNames();
/**
* Gets the alias of this world.
* <p>
* 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.
*/
String getAlias();
/**
* Sets the alias of the world.
*
* @param alias A string that is the new alias.
*/
void setAlias(String alias);
// animals&monster stuff
/**
* Gets whether or not animals are allowed to spawn in this world.
*
* @return True if ANY animal can, false if no animals can spawn.
*/
boolean canAnimalsSpawn();
/**
* Sets whether or not animals can spawn.
* If there are values in {@link #getAnimalList()} and this is false,
* those animals become the exceptions, and will spawn
*
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowAnimalSpawn(boolean allowAnimalSpawn);
/**
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
*
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
*/
List<String> getAnimalList();
/**
* Gets whether or not monsters are allowed to spawn in this world.
*
* @return True if ANY monster can, false if no monsters can spawn.
*/
boolean canMonstersSpawn();
/**
* Sets whether or not monsters can spawn.
* If there are values in {@link #getMonsterList()} and this is false,
* those monsters become the exceptions, and will spawn
*
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
/**
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} result.
*
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
*/
List<String> getMonsterList();
// end of animal&monster stuff
/**
* Gets whether or not PVP is enabled in this world in some form (fake or not).
*
* @return True if players can take damage from other players.
*/
boolean isPVPEnabled();
/**
* Turn pvp on or off. This setting is used to set the world's PVP mode.
*
* @param pvpMode True to enable PVP damage, false to disable it.
*/
void setPVPMode(boolean pvpMode);
/**
* Gets whether or not this world will display in mv who and mv list regardless if a user has the
* access permissions to go to this world.
*
* @return True if the world will be hidden, false if not.
* @see {@link #getPrefixChat()}
*/
boolean isHidden();
/**
* Sets whether or not this world will display in mv who and mv list regardless if a user has the
* access permissions to go to this world.
*
* @param hidden Set
*/
void setHidden(boolean hidden);
/**
* Gets whether or not this world will display it's name/alias as a prefix in chat.
*
* If the global configuration setting for prefixChat is false, this setting has no effect.
*
* @return True if the world name/alias will be used as a prefix in chat, false if not.
*/
boolean getPrefixChat();
/**
* Sets whether or not this world will display it's name/alias as a prefix in chat.
*
* If the global configuration setting for prefixChat is false, this setting has no effect.
*
* @param prefixChat True if the world name/alias will be used as a prefix in chat, false if not.
*/
void setPrefixChat(boolean prefixChat);
/**
* Gets whether weather is enabled in this world.
*
* @return True if weather events will occur, false if not.
*/
boolean isWeatherEnabled();
/**
* Sets whether or not there will be weather events in a given world.
* If set to false, Multiverse will disable the weather in the world immediately.
*
* @param enableWeather True if weather events should occur in a world, false if not.
*/
void setEnableWeather(boolean enableWeather);
/**
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
*
* @return True if CraftBukkit is keeping spawn chunks in memory.
*/
boolean isKeepingSpawnInMemory();
/**
* If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
* If not, CraftBukkit will attempt to free memory when players have not used that world.
* This will not happen immediately.
*
* @param keepSpawnInMemory If true, CraftBukkit will keep the spawn chunks loaded in memory.
*/
void setKeepSpawnInMemory(boolean keepSpawnInMemory);
/**
* Gets the spawn location of this world.
*
* @return The spawn location of this world.
*/
PlayerPosition getSpawnLocation();
/**
* Sets the spawn location for a world.
*
* @param spawnLocation The spawn location for a world.
*/
void setSpawnLocation(PlayerPosition spawnLocation);
/**
* Gets whether or not the hunger level of players will go down in a world.
*
* @return True if it will go down, false if it will remain steady.
*/
boolean getHunger();
/**
* Sets whether or not the hunger level of players will go down in a world.
*
* @param hungerEnabled True if hunger will go down, false to keep it at
* the level they entered a world with.
*/
void setHunger(boolean hungerEnabled);
/**
* Gets the GameMode of this world.
*
* @return The GameMode of this world.
*/
GameMode getGameMode();
/**
* Sets the game mode of this world.
*
* @param gameMode The new {@link GameMode}.
* @return True if the game mode was successfully changed, false if not.
*/
boolean setGameMode(GameMode gameMode);
/**
* Gets the amount of currency it requires to enter this world.
*
* @return The amount it costs to enter this world.
*/
double getPrice();
/**
* Sets the price for entry to this world.
* You can think of this like an amount.
* The type can be set with {@link #setCurrency(int)}
*
* @param price The Amount of money/item to enter the world.
*/
void setPrice(double price);
/**
* Gets the Type of currency that will be used when users enter this world.
*
* @return The Type of currency that will be used when users enter this world.
*/
int getCurrency();
/**
* Sets the type of item that will be required given the price is not 0.
* Use -1 to use an AllPay economy, or any valid itemid
*
* @param item The Type of currency that will be used when users enter this world.
*/
void setCurrency(int item);
/**
* Gets the world players will respawn in if they die in this one.
*
* @return A world that exists on the server.
*/
String getRespawnToWorld();
/**
* Sets the world players will respawn in if they die in this one.
* Returns true upon success, false upon failure.
*
* @param respawnWorld The name of a world that exists on the server.
* @return True if respawnWorld existed, false if not.
*/
boolean setRespawnToWorld(String respawnWorld);
/**
* Gets the scaling value of this world.Really only has an effect if you use
* Multiverse-NetherPortals.
*
* @return This world's non-negative, non-zero scale.
*/
double getScaling();
/**
* Sets the scale of this world. Really only has an effect if you use
* Multiverse-NetherPortals.
*
* @param scaling A scaling value, cannot be negative or 0.
* @return Whether the scale was set successfully.
*/
boolean setScaling(double scaling);
/**
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
*
* @return True if the world should heal (default), false if not.
*/
boolean getAutoHeal();
/**
* Sets whether or not a world will auto-heal players if the difficulty is on peaceful.
*
* @param heal True if the world will heal.
*/
void setAutoHeal(boolean heal);
/**
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
*
* @return True if Multiverse should adjust the spawn, false if not.
*/
boolean getAdjustSpawn();
/**
* Sets whether or not Multiverse should auto-adjust the spawn for this world.
*
* @param adjust True if multiverse should adjust the spawn, false if not.
*/
void setAdjustSpawn(boolean adjust);
/**
* Gets whether or not Multiverse should auto-load this world.
*
* @return True if Multiverse should auto-load this world.
*/
boolean getAutoLoad();
/**
* Sets whether or not Multiverse should auto-load this world.
* <p>
* True is default.
*
* @param autoLoad True if multiverse should autoload this world the spawn, false if not.
*/
void setAutoLoad(boolean autoLoad);
/**
* Gets whether or not a player who dies in this world will respawn in their
* bed or follow the normal respawn pattern.
*
* @return True if players dying in this world should respawn at their bed.
*/
boolean getBedRespawn();
/**
* Sets whether or not a player who dies in this world will respawn in their
* bed or follow the normal respawn pattern.
* <p>
* True is default.
*
* @param bedRespawn True if players dying in this world respawn at their bed.
*/
void setBedRespawn(boolean bedRespawn);
/**
* Sets the player limit for this world after which players without an override
* permission node will not be allowed in. A value of -1 or less signifies no limit
*
* @param limit The new limit
*/
void setPlayerLimit(int limit);
/**
* Gets the player limit for this world after which players without an override
* permission node will not be allowed in. A value of -1 or less signifies no limit
*
* @return The player limit
*/
int getPlayerLimit();
/**
* Same as {@link #getTime()}, but returns a string.
* @return The time as a short string: 12:34pm
*/
String getTime();
/**
* Sets the current time in a world.
* <p>
* This method will take the following formats:
* 11:37am
* 4:30p
* day(morning), night, noon, midnight
*
* @param timeAsString The formatted time to set the world to.
* @return True if the time was set, false if not.
*/
boolean setTime(String timeAsString);
/**
* Sets The types of portals that are allowed in this world.
*
* @param type The type of portals allowed in this world.
*/
void allowPortalMaking(PortalType type);
/**
* Gets which type(s) of portals are allowed to be constructed in this world.
*
* @return The type of portals that are allowed.
*/
PortalType getAllowedPortals();
// properties that are not "getter+setter" style
/**
* Gets a list of all the worlds that players CANNOT travel to from this world,
* regardless of their access permissions.
*
* @return A List of world names.
*/
List<String> getWorldBlacklist();
void save();
}
@@ -1,11 +0,0 @@
package com.mvplugin.core.api;
import com.dumptruckman.minecraft.pluginbase.permission.Perm;
import com.dumptruckman.minecraft.pluginbase.permission.PermFactory;
public interface Perms {
Perm ALL_MULTIVERSE = PermFactory.newPerm("multiverse.*").child(Perm.ALL).build();
Perm CMD_IMPORT = PermFactory.newPerm("cmd.import").commandPermission().build();
}
@@ -1,353 +0,0 @@
package com.mvplugin.core.api;
import com.dumptruckman.minecraft.pluginbase.messaging.Message;
import com.dumptruckman.minecraft.pluginbase.properties.PropertyValidator;
import com.mvplugin.core.WorldCreationException;
import com.mvplugin.core.minecraft.Generator;
import com.mvplugin.core.minecraft.WorldEnvironment;
import com.mvplugin.core.minecraft.WorldType;
import com.mvplugin.core.util.PropertyDescriptions;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
/**
* Multiverse 2 World Manager API
* <p>
* This API contains all of the world managing
* functions that your heart desires!
*/
public interface WorldManager {
public class WorldCreationSettings {
private final String name;
private WorldEnvironment env;
private Long seed;
private WorldType type;
private Boolean generateStructures;
private String generator;
private boolean adjustSpawn = true;
public WorldCreationSettings(final String name) {
if (name == null) {
throw new IllegalArgumentException("name cannot be null!");
}
this.name = name;
}
public String name() {
return name;
}
public WorldEnvironment env() {
return env;
}
public Long seed() {
return seed;
}
public WorldType type() {
return type;
}
public Boolean generateStructures() {
return generateStructures;
}
public String generator() {
return generator;
}
public boolean adjustSpawn() {
return adjustSpawn;
}
public WorldCreationSettings env(WorldEnvironment e) {
this.env = e;
return this;
}
public WorldCreationSettings seed(Long l) {
this.seed = l;
return this;
}
public WorldCreationSettings type(WorldType t) {
this.type = t;
return this;
}
public WorldCreationSettings generateStructures(Boolean b) {
this.generateStructures = b;
return this;
}
public WorldCreationSettings generator(String g) {
this.generator = g;
return this;
}
public WorldCreationSettings adjustSpawn(boolean a) {
this.adjustSpawn = a;
return this;
}
}
/**
* Gets an existing WorldProperties object or creates a new one based on the name.
*
* TODO explain that they should use getWorld() in general.
*
* @param worldName The name of the world to get properties for.
* @return The world properties for the given world name.
* @throws IOException In case there are any issues accessing the persistence for the world properties.
*/
WorldProperties getWorldProperties(final String worldName) throws IOException;
/**
* Add a new World to the Multiverse Setup.
*
* @param name World Name
* @param env Environment Type
* @param seedString The seed in the form of a string.
* If the seed is a Long,
* it will be interpreted as such.
* @param type The Type of the world to be made.
* @param generateStructures If true, this world will get NPC villages.
* @param generator The Custom generator plugin to use.
* @return The new world.
* @throws WorldCreationException If world creation fails.
*/
MultiverseWorld addWorld(String name,
WorldEnvironment env,
String seedString,
WorldType type,
Boolean generateStructures,
String generator) throws WorldCreationException;
/**
* Add a new World to the Multiverse Setup.
*
* @param name World Name
* @param env Environment Type
* @param seedString The seed in the form of a string.
* If the seed is a Long,
* it will be interpreted as such.
* @param type The Type of the world to be made.
* @param generateStructures If true, this world will get NPC villages.
* @param generator The Custom generator plugin to use.
* @param useSpawnAdjust If true, multiverse will search for a safe spawn. If not, It will not modify the level.dat.
* @return The new world.
* @throws WorldCreationException If world creation fails.
*/
MultiverseWorld addWorld(String name,
WorldEnvironment env,
String seedString,
WorldType type,
Boolean generateStructures,
String generator,
boolean useSpawnAdjust) throws WorldCreationException;
/**
* Adds a new World to the Multiverse Setup.
* @param settings Settings for the world creation.
* @return The new world.
* @throws WorldCreationException If world creation fails.
*/
MultiverseWorld addWorld(WorldCreationSettings settings) throws WorldCreationException;
/**
* Make a copy of a world.
*
* @param oldName Name of world to be copied
* @param newName Name of world to be created
* @param generator The Custom generator plugin to use.
* @return True if the world is copied successfully, false if not.
*/
//TODO boolean cloneWorld(String oldName, String newName, String generator);
/**
* Remove the world from the Multiverse list, from the
* config and deletes the folder.
*
* @param name The name of the world to remove
* @return True if success, false if failure.
*/
//TODO boolean deleteWorld(String name);
/**
* Remove the world from the Multiverse list, from the
* config if wanted, and deletes the folder.
*
* @param name The name of the world to remove
* @param removeConfig If true(default), we'll remove the entries from the
* config. If false, they'll stay and the world may come back.
* @return True if success, false if failure.
*/
//TODO boolean deleteWorld(String name, boolean removeConfig);
/**
*
* @param name The name of the world to remove
* @param removeFromConfig If true(default), we'll remove the entries from the
* config. If false, they'll stay and the world may come back.
* @param deleteWorldFolder If true the world folder will be completely deleted. If false
* only the contents of the world folder will be deleted
* @return True if success, false if failure.
*/
//TODO boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder);
/**
* Unload a world from Multiverse.
*
* @param name Name of the world to unload
* @return True if the world was unloaded, false if not.
*/
//TODO boolean unloadWorld(String name);
/**
* Loads the world. Only use this if the world has been
* unloaded with {@link #unloadWorld(String)}.
*
* @param name The name of the world to load
* @return True if success, false if failure.
*/
//TODO boolean loadWorld(String name);
/**
* Removes all players from the specified world.
*
* @param name World to remove players from.
*/
//TODO void removePlayersFromWorld(String name);
/**
* Test if a given chunk generator is valid.
*
* @param generator The generator name.
* @param generatorID The generator id.
* @param worldName The worldName to use as the default.
* @return A {@link Generator} or null
*/
//TODO Generator getChunkGenerator(String generator, String generatorID, String worldName);
/**
* Returns a list of all the worlds Multiverse knows about.
*
* @return A list of {@link MultiverseWorld}.
*/
Collection<MultiverseWorld> getMVWorlds();
/**
* Returns a {@link MultiverseWorld} if it exists, and null if it does not.
* This will search name AND alias.
*
* @param name The name or alias of the world to get.
* @return A {@link MultiverseWorld} or null.
*/
//TODO W getMVWorld(String name);
/**
* Checks to see if the given name is a valid {@link MultiverseWorld}.
*
* @param name The name or alias of the world to check.
* @return True if the world exists, false if not.
*/
boolean isMVWorld(String name);
/**
* Load the Worlds & Settings from the configuration file.
*
* @param forceLoad If set to true, this will perform a total
* reset and not just load new worlds.
*/
//TODO void loadWorlds(boolean forceLoad);
/**
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
* <p>
* This way people will _always_ have some worlds in the list.
*/
//TODO void loadDefaultWorlds();
//TODO WorldPurger getWorldPurger();
/**
* Gets the world players will spawn in on first join.
* Currently this always returns worlds.get(0) from Bukkit.
*
* @return A Multiverse world that players will spawn in or null if no MV world has been set.
*/
//TODO MultiverseWorld getSpawnWorld();
/**
* Gets the list of worlds in the config, but unloaded.
*
* @return A List of worlds as strings.
*/
List<String> getUnloadedWorlds();
/**
* Saves the world config to disk.
*
* @return True if success, false if fail.
*/
//TODO boolean saveWorldsConfig();
/**
* Remove the world from the Multiverse list and from the config.
*
* @param name The name of the world to remove
* @return True if success, false if failure.
*/
//TODO boolean removeWorldFromConfig(String name);
/**
* Sets the initial spawn world for new players.
*
* @param world The World new players should spawn in.
*/
//TODO void setFirstSpawnWorld(String world);
/**
* Gets the world players should spawn in first.
*
* @return The {@link MultiverseWorld} new players should spawn in.
*/
//TODO MultiverseWorld getFirstSpawnWorld();
/**
* Regenerates a world.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed IF the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*/
//TODO boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
class RespawnWorldValidator implements PropertyValidator<String> {
private final WorldManager worldManager;
public RespawnWorldValidator(WorldManager worldManager) {
this.worldManager = worldManager;
}
@Override
public boolean isValid(String s) {
return worldManager.isMVWorld(s);
}
@Override
public Message getInvalidMessage() {
return PropertyDescriptions.INVALID_RESPAWN_WORLD;
}
}
}
@@ -1,226 +0,0 @@
package com.mvplugin.core.api;
import com.dumptruckman.minecraft.pluginbase.messaging.Message;
import com.dumptruckman.minecraft.pluginbase.properties.ListProperty;
import com.dumptruckman.minecraft.pluginbase.properties.NestedProperties;
import com.dumptruckman.minecraft.pluginbase.properties.NestedProperty;
import com.dumptruckman.minecraft.pluginbase.properties.Properties;
import com.dumptruckman.minecraft.pluginbase.properties.PropertyFactory;
import com.dumptruckman.minecraft.pluginbase.properties.PropertyValidator;
import com.dumptruckman.minecraft.pluginbase.properties.SimpleProperty;
import com.mvplugin.core.minecraft.Difficulty;
import com.mvplugin.core.minecraft.GameMode;
import com.mvplugin.core.minecraft.PlayerPosition;
import com.mvplugin.core.minecraft.PortalType;
import com.mvplugin.core.minecraft.WorldEnvironment;
import com.mvplugin.core.util.PropertyDescriptions;
/**
* Houses all of the properties for a Multiverse world.
*/
public interface WorldProperties extends Properties {
SimpleProperty<String> ALIAS = PropertyFactory.newProperty(String.class, "alias", "")
.comment("World aliases allow you to name a world differently than what the folder name is.")
.comment("This lets you choose fancy names for your worlds while keeping the folders nice and neat.")
.comment("You may add minecraft color and formatting codes here prepended with a &")
.description(PropertyDescriptions.ALIAS)
.build();
SimpleProperty<Boolean> HIDDEN = PropertyFactory.newProperty(Boolean.class, "hidden", false)
.comment("The hidden property allows you to have a world that exists but does not show up in lists.")
.description(PropertyDescriptions.HIDDEN)
.build();
SimpleProperty<Boolean> PREFIX_CHAT = PropertyFactory.newProperty(Boolean.class, "prefixChat", true)
.comment("The prefixChat property adds the world's name (or alias) as a prefix to chat messages.")
.comment("Please note, this property can be disabled globally in the configuration.")
.description(PropertyDescriptions.PREFIX_CHAT)
.build();
SimpleProperty<Long> SEED = PropertyFactory.newProperty(Long.class, "seed", 0L)
.comment("The seed property allows you to change the world's seed.")
.description(PropertyDescriptions.SEED)
.build();
SimpleProperty<String> GENERATOR = PropertyFactory.newProperty(String.class, "generator", "")
.comment("The generator property allows you to specify the generator used to generate this world.")
.description(PropertyDescriptions.GENERATOR)
.build();
SimpleProperty<WorldEnvironment> ENVIRONMENT = PropertyFactory.newProperty(WorldEnvironment.class, "environment", WorldEnvironment.NORMAL)
.comment("The environment property the Minecraft world environment such as NORMAL, NETHER, THE_END")
.description(PropertyDescriptions.ENVIRONMENT)
.build();
SimpleProperty<Integer> PLAYER_LIMIT = PropertyFactory.newProperty(Integer.class, "playerLimit", -1)
.comment("The player limit property limits the number of players in a world at a time.")
.comment("A value of -1 or lower signifies no player limit.")
.description(PropertyDescriptions.PLAYER_LIMIT)
.build();
SimpleProperty<Boolean> ADJUST_SPAWN = PropertyFactory.newProperty(Boolean.class, "adjustSpawn", true)
.comment("The adjust spawn property determines whether or not Multiverse will make adjustments to the world's spawn location if it is unsafe.")
.description(PropertyDescriptions.ADJUST_SPAWN)
.build();
SimpleProperty<Boolean> AUTO_LOAD = PropertyFactory.newProperty(Boolean.class, "autoLoad", true)
.comment("The autoLoad dictates whether this world is loaded automatically on startup or not.")
.description(PropertyDescriptions.AUTO_LOAD)
.build();
SimpleProperty<Boolean> BED_RESPAWN = PropertyFactory.newProperty(Boolean.class, "bedRespawn", true)
.comment("The bedRespawn property specifies if a player dying in this world should respawn in their bed or not.")
.description(PropertyDescriptions.BED_RESPAWN)
.build();
SimpleProperty<Boolean> HUNGER = PropertyFactory.newProperty(Boolean.class, "hunger", true)
.comment("The hunger property specifies if hunger is depleted in this world")
.description(PropertyDescriptions.HUNGER)
.build();
ListProperty<String> BLACK_LIST = PropertyFactory.newListProperty(String.class, "worldBlacklist")
.comment("The worldBlackList property allows you to specify worlds that people cannot go to from this specified world.")
.description(PropertyDescriptions.BLACK_LIST)
.build();
SimpleProperty<Boolean> PVP = PropertyFactory.newProperty(Boolean.class, "pvp", true)
.comment("The pvp property states whether or not players may harm each other in this world. If set to true, they may.")
.comment("Bear in mind, many other plugins may have conflicts with this setting.")
.description(PropertyDescriptions.PVP)
.build();
SimpleProperty<Double> SCALE = PropertyFactory.newProperty(Double.class, "scale", 1D)
.comment("The scale property represents the scaling of worlds when using Multiverse-NetherPortals.")
.comment("Setting this value will have no effect on anything but Multiverse-NetherPortals.")
.description(PropertyDescriptions.SCALE)
.validator(new ScaleValidator())
.build();
class ScaleValidator implements PropertyValidator<Double> {
@Override
public boolean isValid(Double scale) {
return scale > 0D;
}
@Override
public Message getInvalidMessage() {
return PropertyDescriptions.INVALID_SCALE;
}
}
SimpleProperty<String> RESPAWN_WORLD = PropertyFactory.newProperty(String.class, "respawnWorld", "")
.comment("The respawnWorld property is the world you will respawn to if you die in this world.")
.comment("This value can be the same as this world.")
.description(PropertyDescriptions.RESPAWN_WORLD)
.build();
SimpleProperty<Boolean> ALLOW_WEATHER = PropertyFactory.newProperty(Boolean.class, "allowWeather", true)
.comment("The allowWeather property specifies whether or not to allow weather events in this world.")
.description(PropertyDescriptions.ALLOW_WEATHER)
.build();
SimpleProperty<Difficulty> DIFFICULTY = PropertyFactory.newProperty(Difficulty.class, "difficulty", Difficulty.EASY)
.comment("The difficulty property allows you to set the difficulty for the world.")
.comment("World difficulty affects spawn rates, hunger rates, and other things that make the game more or less difficult.")
.description(PropertyDescriptions.DIFFICULTY)
.build();
SimpleProperty<Boolean> AUTO_HEAL = PropertyFactory.newProperty(Boolean.class, "autoHeal", true)
.comment("The autoHeal property will specify whether ot not players will regain health in PEACEFUL difficulty only.")
.comment("This setting has no effect on worlds with a difficulty greater than peaceful or 0.")
.description(PropertyDescriptions.AUTO_HEAL)
.build();
SimpleProperty<PortalType> PORTAL_FORM = PropertyFactory.newProperty(PortalType.class, "portalForm", PortalType.ALL)
.comment("The portalFrom property allows you to specify which type of portals are allowed to be created in this world.")
.description(PropertyDescriptions.PORTAL_FORM)
.build();
SimpleProperty<GameMode> GAME_MODE = PropertyFactory.newProperty(GameMode.class, "gameMode", GameMode.SURVIVAL)
.comment("The gameMode property allows you to specify the GameMode for this world.")
.comment("Players entering this world will automatically be switched to this GameMode unless they are exempted.")
.description(PropertyDescriptions.GAME_MODE)
.build();
SimpleProperty<Boolean> KEEP_SPAWN = PropertyFactory.newProperty(Boolean.class, "keepSpawnInMemory", true)
.comment("The keepSpawnInMemory property specifies whether or not to keep the spawn chunks loaded in memory when players aren't in the spawn area.")
.comment("Setting this to false will potentially save you some memory.")
.description(PropertyDescriptions.KEEP_SPAWN)
.build();
SimpleProperty<PlayerPosition> SPAWN_LOCATION = PropertyFactory.newProperty(PlayerPosition.class, "spawnLocation", PlayerPosition.NULL_LOCATION)
.comment("The spawnLocation property specifies where in the world players will spawn.")
.comment("The world specified here has no effect.")
.description(PropertyDescriptions.SPAWN_LOCATION)
.build();
NestedProperty<EntryFee> ENTRY_FEE = PropertyFactory.newNestedProperty(EntryFee.class, "entryFee")
.build();
public static interface EntryFee extends NestedProperties {
SimpleProperty<Double> AMOUNT = PropertyFactory.newProperty(Double.class, "amount", 0D)
.comment("The amount property specifies how much a player has to pay to enter this world.")
.comment("What the player has to pay is specified by the 'currency' property")
.description(PropertyDescriptions.AMOUNT)
.build();
SimpleProperty<Integer> CURRENCY = PropertyFactory.newProperty(Integer.class, "currency", -1)
.comment("The currency property specifies what type of currency the player must pay (if any) to enter this world.")
.comment("Currency can be an economy money by specifying -1 or a block type by specifying the block id.")
.description(PropertyDescriptions.CURRENCY)
.build();
}
NestedProperty<Spawning> SPAWNING = PropertyFactory.newNestedProperty(Spawning.class, "spawning")
.build();
public static interface Spawning extends NestedProperties {
NestedProperty<Animals> ANIMALS = PropertyFactory.newNestedProperty(Animals.class, "animals")
.build();
NestedProperty<Monsters> MONSTERS = PropertyFactory.newNestedProperty(Monsters.class, "monsters")
.build();
public static interface Animals extends NestedProperties {
SimpleProperty<Boolean> SPAWN = PropertyFactory.newProperty(Boolean.class, "spawn", true)
.comment("The animals spawn property specifies whether or not to spawn animals in this world.")
.description(PropertyDescriptions.ANIMALS_SPAWN)
.build();
SimpleProperty<Integer> SPAWN_RATE = PropertyFactory.newProperty(Integer.class, "spawnRate", -1)
.comment("The animals spawnRate property defines how many ticks in between attempting to spawn animals.")
.comment("A value of -1 indicates the default should be used and is recommended unless you know what you are doing.")
.description(PropertyDescriptions.ANIMALS_SPAWN_RATE)
.build();
ListProperty<String> EXCEPTIONS = PropertyFactory.newListProperty(String.class, "exceptions")
.comment("The animals exceptions property defines what animals are exempt from the animals spawn property.")
.description(PropertyDescriptions.ANIMALS_SPAWN_EXCEPTIONS)
.build();
}
public static interface Monsters extends NestedProperties {
SimpleProperty<Boolean> SPAWN = PropertyFactory.newProperty(Boolean.class, "spawn", true)
.comment("The monsters spawn property specifies whether or not to spawn monsters in this world.")
.description(PropertyDescriptions.MONSTERS_SPAWN)
.build();
SimpleProperty<Integer> SPAWN_RATE = PropertyFactory.newProperty(Integer.class, "spawnRate", -1)
.comment("The monsters spawnRate property defines how many ticks in between attempting to spawn monsters.")
.comment("A value of -1 indicates the default should be used and is recommended unless you know what you are doing.")
.description(PropertyDescriptions.MONSTERS_SPAWN_RATE)
.build();
ListProperty<String> EXCEPTIONS = PropertyFactory.newListProperty(String.class, "exceptions")
.comment("The monsters exceptions property defines what monsters are exempt from the monsters spawn property.")
.description(PropertyDescriptions.MONSTERS_SPAWN_EXCEPTIONS)
.build();
}
}
}
@@ -1,63 +0,0 @@
package com.mvplugin.core.api;
import com.dumptruckman.minecraft.pluginbase.entity.BasePlayer;
import com.mvplugin.core.minecraft.Entity;
import java.util.List;
/**
* Used to remove animals from worlds that don't belong there.
*/
public interface WorldPurger {
/**
* Synchronizes the given worlds with their settings.
*
* @param worlds A list of {@link com.mvplugin.core.api.MultiverseWorld}
*/
void purgeWorlds(List<MultiverseWorld> worlds);
void purgeWorld(MultiverseWorld world);
/**
* Clear all animals/monsters that do not belong to a world according to the config.
*
* @param mvworld The {@link MultiverseWorld}.
* @param thingsToKill A {@link java.util.List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated.
*/
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters);
/**
* Clear all animals/monsters that do not belong to a world according to the config.
*
* @param mvworld The {@link MultiverseWorld}.
* @param thingsToKill A {@link java.util.List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated.
* @param sender The {@link BasePlayer} that initiated the action. He will/should be notified.
*/
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters, BasePlayer sender);
/**
* Determines whether the specified creature should be killed.
*
* @param e The creature.
* @param thingsToKill A {@link java.util.List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated.
* @return {@code true} if the creature should be killed, otherwise {@code false}.
*/
boolean shouldWeKillThisCreature(Entity e, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters);
/**
* Determines whether the specified creature should be killed and automatically reads the params from a world object.
*
* @param w The world.
* @param e The creature.
* @return {@code true} if the creature should be killed, otherwise {@code false}.
*/
boolean shouldWeKillThisCreature(MultiverseWorld w, Entity e);
}
@@ -1,5 +0,0 @@
/**
* The Multiverse-API, containing lots of interfaces that can be quite useful for other
* plugins when interacting with Multiverse.
*/
package com.mvplugin.core.api;
@@ -1,8 +0,0 @@
package com.mvplugin.core.command;
class CommandHelp {
static void init() { }
}
@@ -1,188 +0,0 @@
package com.mvplugin.core.command;
import com.dumptruckman.minecraft.pluginbase.entity.BasePlayer;
import com.dumptruckman.minecraft.pluginbase.messaging.ChatColor;
import com.dumptruckman.minecraft.pluginbase.messaging.Message;
import com.dumptruckman.minecraft.pluginbase.permission.Perm;
import com.dumptruckman.minecraft.pluginbase.plugin.command.CommandInfo;
import com.mvplugin.core.WorldCreationException;
import com.mvplugin.core.api.MultiverseCore;
import com.mvplugin.core.api.MultiverseWorld;
import com.mvplugin.core.api.Perms;
import com.mvplugin.core.minecraft.WorldEnvironment;
import com.mvplugin.core.util.Language;
import com.sk89q.minecraft.util.commands.CommandContext;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@CommandInfo(
primaryAlias = "import",
desc = "Import a world.",
usage = "{NAME} {ENVIRONMENT}",
prefixedAliases = "im",
directlyPrefixedAliases = "import",
flags = "g:n",
min = 1,
max = 2
)
public class ImportCommand extends MultiverseCommand {
public static final Message IMPORT_HELP = new Message("command.import.help",
"Imports a world into the server from a folder with the given name.",
"The folder must exist in the location where worlds are normally located and must contain Minecraft world data.",
"You must specify a world environment such as NORMAL or NETHER.",
"You may also specify a generator to use along with an optional generator ID.",
"The generator name is case sensitive!",
"Flags:",
" -g {GENERATOR[:ID]} Specify a generator.",
" -n Do not adjust spawn",
"Examples:",
" /mv import &6gargamel&a normal",
" /mv import &6hell_world&a nether",
" /mv import &6Cleanroom&a normal -g &3CleanroomGenerator");
public static final Message POTENTIAL_WORLD_LIST = new Message("command.import.potential_world_list",
"&b====[ These look like worlds ]====", "%s");
public static final Message NO_POTENTIAL_WORLDS = new Message("command.import.no_potential_worlds",
"&cNo potential worlds found. Sorry!");
public static final Message INVALID_ENVIRONMENT = new Message("command.import.invalid_environment",
"&cThat is not a valid environment.");
public static final Message STARTING_IMPORT = new Message("command.import.starting_import",
"Starting import of world '%s'...");
public static final Message IMPORT_COMPLETE = new Message("command.import.import_complete",
"&aImport complete!");
public static final Message IMPORT_FAILED = new Message("command.import.import_failed",
"&cImport failed!");
@Override
public Perm getPerm() {
return Perms.CMD_IMPORT;
}
@Override
public Message getHelp() {
return IMPORT_HELP;
}
@Override
public boolean runCommand(MultiverseCore core, BasePlayer sender, CommandContext context) {
final String worldName = context.getString(0);
if (worldName.toLowerCase().equals("--list") || worldName.toLowerCase().equals("-l")) {
final String worldList = this.getPotentialWorlds(core);
if (worldList.length() > 2) {
core.getMessager().message(sender, POTENTIAL_WORLD_LIST, worldList);
} else {
core.getMessager().message(sender, NO_POTENTIAL_WORLDS);
}
return true;
}
// Since we made an exception for the list, we have to make sure they have at least 2 params:
// Note the exception is --list, which is covered above.
if (context.argsLength() == 1) {
return false;
}
// Make sure we don't already know about this world.
if (core.getWorldManager().isMVWorld(worldName)) {
core.getMessager().message(sender, Language.WORLD_ALREADY_EXISTS, worldName);
return true;
}
File worldFile = new File(core.getServerInterface().getWorldContainer(), worldName);
String generator = context.getFlag('g');
boolean useSpawnAdjust = !context.hasFlag('n');
String env = context.getString(1);
WorldEnvironment environment = WorldEnvironment.getFromString(env);
if (environment == null) {
core.getMessager().message(sender, INVALID_ENVIRONMENT);
// TODO EnvironmentCommand.showEnvironments(sender);
return true;
}
if (worldFile.exists() && env != null) {
core.getMessager().messageAndLog(sender, STARTING_IMPORT, worldName);
try {
core.getWorldManager().addWorld(worldName, environment, null, null, null, generator, useSpawnAdjust);
core.getMessager().messageAndLog(sender, IMPORT_COMPLETE);
} catch (WorldCreationException e) {
core.getMessager().messageAndLog(sender, IMPORT_FAILED);
core.getMessager().messageAndLog(sender, e.getBundledMessage().getMessage(), e.getBundledMessage().getArgs());
}
} else if (env == null) {
core.getMessager().message(sender, IMPORT_FAILED);
// TODO locale
sender.sendMessage("That world environment did not exist.");
sender.sendMessage("For a list of available world types, type: " + ChatColor.AQUA + "/mvenv");
} else {
core.getMessager().message(sender, IMPORT_FAILED);
String worldList = this.getPotentialWorlds(core);
// TODO locale
sender.sendMessage("That world folder does not exist. These look like worlds to me:");
sender.sendMessage(worldList);
}
return true;
}
/**
* A very basic check to see if a folder has a level.dat file.
* If it does, we can safely assume it's a world folder.
*
* @param worldFolder The File that may be a world.
* @return True if it looks like a world, false if not.
*/
private static boolean checkIfIsWorld(File worldFolder) {
if (worldFolder.isDirectory()) {
File[] files = worldFolder.listFiles(new FilenameFilter() {
@Override
public boolean accept(File file, String name) {
return name.equalsIgnoreCase("level.dat");
}
});
if (files != null && files.length > 0) {
return true;
}
}
return false;
}
private String getPotentialWorlds(final MultiverseCore core) {
final File worldFolder = core.getServerInterface().getWorldContainer();
if (worldFolder == null) {
return "";
}
File[] files = worldFolder.listFiles();
String worldList = "";
Collection<MultiverseWorld> worlds = core.getWorldManager().getMVWorlds();
List<String> worldStrings = new ArrayList<String>();
for (MultiverseWorld world : worlds) {
worldStrings.add(world.getName());
}
for (String world : core.getWorldManager().getUnloadedWorlds()) {
worldStrings.add(world);
}
ChatColor currColor = ChatColor.WHITE;
for (File file : files) {
if (file.isDirectory() && checkIfIsWorld(file) && !worldStrings.contains(file.getName())) {
worldList += currColor + file.getName() + " ";
if (currColor == ChatColor.WHITE) {
currColor = ChatColor.YELLOW;
} else {
currColor = ChatColor.WHITE;
}
}
}
return worldList;
}
}
@@ -1,12 +0,0 @@
package com.mvplugin.core.command;
import com.dumptruckman.minecraft.pluginbase.plugin.command.Command;
import com.mvplugin.core.api.MultiverseCore;
abstract class MultiverseCommand extends Command<MultiverseCore> {
static {
// Statically initialize help language
CommandHelp.init();
}
}
@@ -1,8 +0,0 @@
package com.mvplugin.core.minecraft;
public enum Difficulty {
PEACEFUL,
EASY,
NORMAL,
HARD
}
@@ -1,4 +0,0 @@
package com.mvplugin.core.minecraft;
public class Entity {
}
@@ -1,8 +0,0 @@
package com.mvplugin.core.minecraft;
public enum GameMode {
ADVENTURE,
CREATIVE,
SURVIVAL
}
@@ -1,4 +0,0 @@
package com.mvplugin.core.minecraft;
public interface Generator {
}
@@ -1,45 +0,0 @@
package com.mvplugin.core.minecraft;
public final class PlayerPosition {
public static final PlayerPosition NULL_LOCATION = new PlayerPosition("", 0, 0, 0, 0, 0);
private final double x, y, z;
private final float pitch, yaw;
private final String world;
public PlayerPosition(final String world, final double x,
final double y, final double z,
final float pitch, final float yaw) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.pitch = pitch;
this.yaw = yaw;
}
public String getWorld() {
return world;
}
public float getPitch() {
return pitch;
}
public float getYaw() {
return this.yaw;
}
public double getX() {
return this.x;
}
public double getY() {
return this.y;
}
public double getZ() {
return this.z;
}
}
@@ -1,21 +0,0 @@
package com.mvplugin.core.minecraft;
public enum PortalType {
/**
* No portals are allowed.
*/
NONE,
/**
* All portal types are allowed.
*/
ALL,
/**
* Only Nether style portals are allowed.
*/
NETHER,
/**
* Only Ender style portals are allowed.
*/
END;
}
@@ -1,17 +0,0 @@
package com.mvplugin.core.minecraft;
public enum WorldEnvironment {
NETHER,
NORMAL,
THE_END
;
public static WorldEnvironment getFromString(final String name) {
for (final WorldEnvironment env : WorldEnvironment.values()) {
if (name.equalsIgnoreCase(env.toString())) {
return env;
}
}
return null;
}
}
@@ -1,8 +0,0 @@
package com.mvplugin.core.minecraft;
public enum WorldType {
FLAT,
LARGE_BIOMES,
NORMAL,
VERSION_1_1
}
@@ -1,9 +0,0 @@
package com.mvplugin.core.util;
import com.dumptruckman.minecraft.pluginbase.messaging.Message;
public class Language {
public static final Message WORLD_ALREADY_EXISTS = new Message("worlds.world_exists",
"&aMultiverse&f already knows about '&b%s&f'!");
}
@@ -1,121 +0,0 @@
package com.mvplugin.core.util;
import com.dumptruckman.minecraft.pluginbase.messaging.Message;
/**
* Houses localized (english) descriptions of the Multiverse world properties.
*/
public class PropertyDescriptions {
public static void init() { }
public static final Message ALIAS = new Message("world_properties.descriptions.alias",
"World aliases allow you to name a world differently than what the folder name is.",
"This lets you choose fancy names for your worlds while keeping the folders nice and neat.",
"You may add minecraft color and formatting codes here prepended with a &");
public static final Message HIDDEN = new Message("world_properties.descriptions.hidden",
"The hidden property allows you to have a world that exists but does not show up in lists.");
public static final Message PREFIX_CHAT = new Message("world_properties.descriptions.prefixChat",
"The prefixChat property adds the world's name (or alias) as a prefix to chat messages.");
public static final Message SEED = new Message("world_properties.descriptions.seed",
"The seed property allows you to change the world's seed.");
public static final Message GENERATOR = new Message("world_properties.descriptions.generator",
"The generator property allows you to specify the generator used to generate this world.");
public static final Message ENVIRONMENT = new Message("world_properties.descriptions.environment",
"The environment property the Minecraft world environment such as NORMAL, NETHER, THE_END");
public static final Message PLAYER_LIMIT = new Message("world_properties.descriptions.playerLimit",
"The player limit property limits the number of players in a world at a time.",
"A value of -1 or lower signifies no player limit.");
public static final Message ADJUST_SPAWN = new Message("world_properties.descriptions.adjustSpawn",
"The adjust spawn property determines whether or not Multiverse will make adjustments to the world's spawn location if it is unsafe.");
public static final Message AUTO_LOAD = new Message("world_properties.descriptions.autoLoad",
"The autoLoad property dictates whether this world is loaded automatically on startup or not.");
public static final Message BED_RESPAWN = new Message("world_properties.descriptions.bedRespawn",
"The bedRespawn property specifies if a player dying in this world should respawn in their bed or not.");
public static final Message HUNGER = new Message("world_properties.descriptions.hunger",
"The hunger property specifies if hunger is depleted in this world");
public static final Message BLACK_LIST = new Message("world_properties.descriptions.worldBlacklist",
"The worldBlackList property allows you to specify worlds that people cannot go to from this specified world.");
public static final Message PVP = new Message("world_properties.descriptions.pvp",
"The pvp property states whether or not players may harm each other in this world. If set to true, they may.");
public static final Message SCALE = new Message("world_properties.descriptions.scale",
"The scale property represents the scaling of worlds when using Multiverse-NetherPortals.",
"Setting this value will have no effect on anything but Multiverse-NetherPortals.");
public static final Message RESPAWN_WORLD = new Message("world_properties.descriptions.respawnWorld",
"The respawnWorld property is the world you will respawn to if you die in this world.",
"This value can be the same as this world.");
public static final Message ALLOW_WEATHER = new Message("world_properties.descriptions.allowWeather",
"The allowWeather property specifies whether or not to allow weather events in this world.");
public static final Message DIFFICULTY = new Message("world_properties.descriptions.difficulty",
"The difficulty property allows you to set the difficulty for the world.",
"World difficulty affects spawn rates, hunger rates, and other things that make the game more or less difficult.");
public static final Message AUTO_HEAL = new Message("world_properties.descriptions.autoHeal",
"The autoHeal property will specify whether ot not players will regain health in PEACEFUL difficulty only.",
"This setting has no effect on worlds with a difficulty greater than peaceful or 0.");
public static final Message PORTAL_FORM = new Message("world_properties.descriptions.portalForm",
"The portalFrom property allows you to specify which type of portals are allowed to be created in this world.");
public static final Message GAME_MODE = new Message("world_properties.descriptions.gameMode",
"The gameMode property allows you to specify the GameMode for this world.",
"Players entering this world will automatically be switched to this GameMode unless they are exempted.");
public static final Message KEEP_SPAWN = new Message("world_properties.descriptions.keepSpawnInMemory",
"The keepSpawnInMemory property specifies whether or not to keep the spawn chunks loaded in memory when players aren't in the spawn area.",
"Setting this to false will potentially save you some memory.");
public static final Message SPAWN_LOCATION = new Message("world_properties.descriptions.spawnLocation",
"The spawnLocation property specifies where in the world players will spawn.");
public static final Message AMOUNT = new Message("world_properties.descriptions.amount",
"The amount property specifies how much a player has to pay to enter this world.",
"What the player has to pay is specified by the 'currency' property");
public static final Message CURRENCY = new Message("world_properties.descriptions.currency",
"The currency property specifies what type of currency the player must pay (if any) to enter this world.",
"Currency can be an economy money by specifying -1 or a block type by specifying the block id.");
public static final Message ANIMALS_SPAWN = new Message("world_properties.descriptions.animals.spawn",
"The animals spawn property specifies whether or not to spawn animals in this world.");
public static final Message ANIMALS_SPAWN_RATE = new Message("world_properties.descriptions.animals.spawnRate",
"The animals spawnRate property defines how many ticks in between attempting to spawn animals.",
"A value of -1 indicates the default should be used and is recommended unless you know what you are doing.");
public static final Message ANIMALS_SPAWN_EXCEPTIONS = new Message("world_properties.descriptions.animals.exceptions",
"The animals exceptions property defines what animals are exempt from the animals spawn property.");
public static final Message MONSTERS_SPAWN = new Message("world_properties.descriptions.monsters.spawn",
"The monsters spawn property specifies whether or not to spawn monsters in this world.");
public static final Message MONSTERS_SPAWN_RATE = new Message("world_properties.descriptions.monsters.spawnRate",
"The monsters spawnRate property defines how many ticks in between attempting to spawn monsters.",
"A value of -1 indicates the default should be used and is recommended unless you know what you are doing.");
public static final Message MONSTERS_SPAWN_EXCEPTIONS = new Message("world_properties.descriptions.monsters.exceptions",
"The monsters exceptions property defines what monsters are exempt from the monsters spawn property.");
public static final Message INVALID_SCALE = new Message("world_properties.validation.scale",
"Scale must be a number higher than 0!");
public static final Message INVALID_RESPAWN_WORLD = new Message("world_properties.validation.respawnWorld",
"Respawn world must be a world known to Multiverse!");
}
-44
View File
@@ -1,44 +0,0 @@
# Eclipse stuff
/.classpath
/.project
/.settings
/.checkstyle
# netbeans
/nbproject
# we use maven!
/build.xml
# maven
/target
# vim
.*.sw[a-p]
# various other potential build files
/build
/bin
/dist
/manifest.mf
/world
# Mac filesystem dust
*.DS_Store
# intellij
*.iml
*.ipr
*.iws
.idea/
# Fern's utils
uploadtoserver.sh
# Testing files:
debug.log
# Doxygen
/docs/html
debug.txt
-143
View File
@@ -1,143 +0,0 @@
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Multiverse 2 Copyright (c) the Multiverse Team 2011. ~
~ Multiverse 2 is licensed under the BSD License. ~
~ For more information please check the README.md file included ~
~ with this project. ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!-- Future reference: valid severity values are 'ignore', 'info', 'warning', 'error' -->
<module name="Checker">
<module name="JavadocPackage">
<property name="allowLegacy" value="true"/>
</module>
<module name="NewlineAtEndOfFile" />
<module name="Translation"/>
<module name="FileLength"/>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="RegexpSingleline">
<property name="message" value="Line has trailing spaces."/>
<property name="format" value="\s+$"/>
</module>
<module name="SuppressWithNearbyCommentFilter">
<property name="commentFormat" value="SUPPRESS CHECKSTYLE: (\w+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: (\w+)"/>
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: (\w+)"/>
<property name="checkFormat" value="$1"/>
</module>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="BEGIN CHECKSTYLE-SUPPRESSION\: ALL"/>
<property name="onCommentFormat" value="END CHECKSTYLE-SUPPRESSION\: ALL"/>
</module>
<module name="TreeWalker">
<!-- Make suppression possible -->
<module name="FileContentsHolder"/>
<!-- Actual checks -->
<module name="LineLength">
<property name="max" value="160"/>
<property name="severity" value="warning"/>
</module>
<module name="JavadocMethod">
<property name="scope" value="package"/><!-- We don't need javadoc for private methods -->
<property name="tokens" value="METHOD_DEF"/><!-- We don't need javadoc for constructors -->
</module>
<module name="JavadocType"/>
<module name="JavadocVariable">
<property name="scope" value="package"/><!-- We don't need javadoc for private variables -->
</module>
<module name="JavadocStyle"/>
<module name="WriteTag">
<property name="tag" value="@author"/>
<property name="tagFormat" value="\S"/>
<property name="severity" value="ignore"/>
<property name="tagSeverity" value="warning"/>
</module>
<module name="ConstantName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<module name="AvoidStarImport">
<property name="severity" value="warning"/>
<property name="excludes" value="com.onarandombox.MultiverseCore.utils,com.onarandombox.MultiverseCore.configuration,com.onarandombox.MultiverseCore.commands,com.onarandombox.MultiverseCore.destination"/>
</module>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<module name="MethodLength">
<property name="severity" value="warning"/>
<property name="countEmpty" value="false"/>
</module>
<module name="ParameterNumber"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter">
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
</module>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter">
<property name="severity" value="warning"/>
</module>
<module name="WhitespaceAround">
<property name="severity" value="warning"/>
</module>
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock">
<property name="tokens" value="LITERAL_DO,LITERAL_ELSE,LITERAL_FINALLY,LITERAL_IF,LITERAL_FOR,LITERAL_TRY,LITERAL_WHILE,INSTANCE_INIT,STATIC_INIT"/>
</module>
<module name="LeftCurly"/>
<module name="RightCurly"/>
<module name="DoubleCheckedLocking"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
<property name="tokens" value="VARIABLE_DEF"/><!-- We don't care if parameters hide fields. -->
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber">
<property name="ignoreNumbers" value="-1, 0, 0.5, 1, 2, 3"/>
</module>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Don't like errors for `final` missing
<module name="DesignForExtension"/>
<module name="FinalClass"/>
-->
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier">
<property name="protectedAllowed" value="true"/>
</module>
<module name="ArrayTypeStyle"/>
<!-- Don't like errors for `final` missing
<module name="FinalParameters"/>
-->
<module name="TodoComment">
<property name="severity" value="info"/>
</module>
<module name="UpperEll"/>
<module name="Indentation"/>
<module name="MissingDeprecated"/>
<module name="MissingOverride"/>
</module>
</module>
-322
View File
@@ -1,322 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mvplugin</groupId>
<artifactId>MultiverseCore</artifactId>
<version>3.0-SNAPSHOT</version>
</parent>
<artifactId>MultiverseCore-Bukkit</artifactId>
<repositories>
<repository>
<id>onarandombox</id>
<url>http://repo.onarandombox.com/content/groups/public</url>
</repository>
<repository>
<id>Bukkit Official</id>
<url>http://repo.bukkit.org/content/repositories/public</url>
</repository>
<!-- Required for Metrics -->
<repository>
<id>mcstats</id>
<url>http://repo.mcstats.org/content/repositories/snapshots</url>
</repository>
<!-- Required for Vault -->
<repository>
<id>herocraft</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>doodleproject-repo</id>
<name>DoodleProject Maven 2 Repository</name>
<url>http://doodleproject.sourceforge.net/maven2/release</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<ciManagement>
<system>jenkins</system>
<url>http://ci.onarandombox.com</url>
</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>
<defaultGoal>clean package</defaultGoal>
<plugins>
<!-- Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.8</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/classes/plugin.yml</file>
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}-b${project.build.number}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<!-- Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestEntries>
</manifestEntries>
</archive>
</configuration>
</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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.8</version>
<configuration>
<enableRulesSummary>true</enableRulesSummary>
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>javadoc-jar</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.mvplugin:MultiverseCore-Base</include>
<include>com.dumptruckman.minecraft:BukkitPlugin</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.dumptruckman.minecraft.pluginbase</pattern>
<shadedPattern>com.mvplugin.pluginbase</shadedPattern>
</relocation>
</relocations>
<!--
<include>me.main__.util:SerializationConfig</include>
<include>com.pneumaticraft.commandhandler:CommandHandler</include>
<include>com.dumptruckman.minecraft:buscript</include>
<include>com.dumptruckman.minecraft:BukkitPlugin</include>
<include>org.mcstats:metrics</include>
<include>com.fernferret.allpay:AllPay</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.fernferret.allpay</pattern>
<shadedPattern>com.fernferret.allpay.multiverse</shadedPattern>
</relocation>
<relocation>
<pattern>me.main__.util</pattern>
<shadedPattern>me.main__.util.multiverse</shadedPattern>
</relocation>
<relocation>
<pattern>com.pneumaticraft.commandhandler</pattern>
<shadedPattern>com.pneumaticraft.commandhandler.multiverse</shadedPattern>
</relocation>
<relocation>
<pattern>buscript</pattern>
<shadedPattern>buscript.multiverse</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.pluginbase.util.Logging</pattern>
<shadedPattern>com.onarandombox.multiverse.core.util.CoreLogging</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.pluginbase.util.DebugLog</pattern>
<shadedPattern>com.onarandombox.multiverse.util.DebugFileLogger</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.pluginbase</pattern>
<shadedPattern>com.dumptruckman.minecraft.pluginbase.multiverse</shadedPattern>
</relocation>
<relocation>
<pattern>org.mcstats</pattern>
<shadedPattern>org.mcstats.multiverse</shadedPattern>
</relocation>
</relocations>
-->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.mvplugin</groupId>
<artifactId>MultiverseCore-Base</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- PluginBase Dependency -->
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>BukkitPlugin</artifactId>
<version>1.5-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- Bukkit Dependency -->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.3.2-R2.1-SNAPSHOT</version>
<!-- If you want the lates, use this -->
<!-- <version>LATEST</version> -->
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- Start of Economy Dependency -->
<dependency>
<groupId>com.fernferret.allpay</groupId>
<artifactId>AllPay</artifactId>
<version>10</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.2.19-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Economy Dependency -->
<!-- Start of CommandHandler Dependency -->
<dependency>
<groupId>com.pneumaticraft.commandhandler</groupId>
<artifactId>CommandHandler</artifactId>
<version>7</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of CommandHandler Dependency -->
<!-- Start of Buscript Dependency -->
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>buscript</artifactId>
<version>1.0</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Buscript Dependency -->
<!-- Start of Metrics Dependency -->
<dependency>
<groupId>org.mcstats</groupId>
<artifactId>metrics</artifactId>
<version>1.2-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Metrics Dependency -->
</dependencies>
<distributionManagement>
<repository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse/</url>
</repository>
<snapshotRepository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
@@ -1,82 +0,0 @@
package com.mvplugin.core;
import com.mvplugin.core.api.BukkitMultiverseWorld;
import com.mvplugin.core.api.WorldProperties;
import com.mvplugin.core.api.WorldProperties.Spawning.Animals;
import com.mvplugin.core.minecraft.PlayerPosition;
import com.mvplugin.core.minecraft.WorldType;
import com.mvplugin.core.util.Convert;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.util.UUID;
class BukkitWorld extends AbstractMultiverseWorld implements BukkitMultiverseWorld {
private final String name;
private final UUID worldUID;
private final WorldType worldType;
BukkitWorld(final World world, final WorldProperties worldProperties) {
super(worldProperties);
this.name = world.getName();
this.worldUID = world.getUID();
this.worldType = Convert.fromBukkit(world.getWorldType());
}
@Override
protected void update(Object obj) {
if (obj == WorldProperties.DIFFICULTY) {
getBukkitWorld().setDifficulty(Convert.toBukkit(getDifficulty()));
} else if (obj == WorldProperties.ALLOW_WEATHER) {
if (!isWeatherEnabled()) {
final World world = getBukkitWorld();
world.setWeatherDuration(0);
world.setStorm(false);
world.setThunderDuration(0);
world.setThundering(false);
}
} else if (obj == WorldProperties.PVP) {
getBukkitWorld().setPVP(isPVPEnabled());
} else if (obj == WorldProperties.SPAWN_LOCATION) {
final PlayerPosition pos = getSpawnLocation();
getBukkitWorld().setSpawnLocation((int) pos.getX(), (int) pos.getY(), (int) pos.getZ());
} else if (obj == Animals.SPAWN_RATE) {
//getBukkitWorld().set
}
}
@Override
public String getName() {
return this.name;
}
@Override
public UUID getWorldUID() {
return this.worldUID;
}
@Override
public WorldType getWorldType() {
return worldType;
}
@Override
public World getBukkitWorld() {
final World world = Bukkit.getWorld(worldUID);
if (world == null) {
throw new IllegalStateException("Multiverse lost track of Bukkit world '" + this.name + "'");
}
return world;
}
@Override
public String getTime() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public boolean setTime(String timeAsString) {
return false; //To change body of implemented methods use File | Settings | File Templates.
}
}
@@ -1,198 +0,0 @@
package com.mvplugin.core;
import com.dumptruckman.minecraft.pluginbase.logging.Logging;
import com.dumptruckman.minecraft.pluginbase.messaging.BundledMessage;
import com.mvplugin.core.api.BukkitMultiverseWorld;
import com.mvplugin.core.api.WorldProperties;
import com.mvplugin.core.util.BukkitLanguage;
import com.mvplugin.core.util.Convert;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
public class BukkitWorldManager extends AbstractWorldManager {
private final MultiverseCorePlugin plugin;
private final File worldsFolder;
private final Map<String, WorldProperties> worldPropertiesMap;
private final Map<String, String> defaultGens;
public BukkitWorldManager(MultiverseCorePlugin plugin) {
super(plugin);
this.plugin = plugin;
this.worldsFolder = new File(plugin.getDataFolder(), "worlds");
this.worldPropertiesMap = new HashMap<String, WorldProperties>();
this.defaultGens = new HashMap<String, String>();
initializeDefaultWorldGenerators();
initializeWorlds();
}
private void initializeDefaultWorldGenerators() {
File[] files = this.plugin.getServerFolder().listFiles(new FilenameFilter() {
@Override
public boolean accept(File file, String s) {
return s.equalsIgnoreCase("bukkit.yml");
}
});
if (files != null && files.length == 1) {
FileConfiguration bukkitConfig = YamlConfiguration.loadConfiguration(files[0]);
if (bukkitConfig.isConfigurationSection("worlds")) {
Set<String> keys = bukkitConfig.getConfigurationSection("worlds").getKeys(false);
for (String key : keys) {
defaultGens.put(key, bukkitConfig.getString("worlds." + key + ".generator", ""));
}
}
} else {
Logging.warning("Could not read 'bukkit.yml'. Any Default worldgenerators will not be loaded!");
}
}
private void initializeWorlds() {
StringBuilder builder = new StringBuilder();
for (final World w : this.plugin.getServer().getWorlds()) {
try {
worldsMap.put(w.getName(), getBukkitWorld(w));
if (builder.length() != 0) {
builder.append(", ");
}
builder.append(w.getName());
} catch (IOException e) {
Logging.severe("Multiverse could not initialize loaded Bukkit world '%s'", w.getName());
}
}
for (File file : getPotentialWorldFiles()) {
final String worldName = getWorldNameFromFile(file);
if (worldsMap.containsKey(worldName)) {
continue;
}
try {
WorldProperties worldProperties = getWorldProperties(file);
if (worldProperties.get(WorldProperties.AUTO_LOAD)) {
addWorld(worldName, worldProperties.get(WorldProperties.ENVIRONMENT), null, null,
null, worldProperties.get(WorldProperties.GENERATOR),
worldProperties.get(WorldProperties.ADJUST_SPAWN));
if (builder.length() != 0) {
builder.append(", ");
}
builder.append(worldName);
} else {
Logging.fine("Not loading '%s' because it is set to autoLoad: false", worldName);
}
} catch (IOException e) {
Logging.getLogger().log(Level.WARNING, String.format("Could not load world from file '%s'", file), e);
} catch (WorldCreationException e) {
Logging.getLogger().log(Level.WARNING, String.format("Error while attempting to load world '%s'", worldName), e);
}
}
// Simple Output to the Console to show how many Worlds were loaded.
Logging.config("Multiverse is now managing: %s", builder.toString());
}
private String getWorldNameFromFile(final File file) {
final String simpleName = file.getName();
if (simpleName.endsWith(".yml")) {
return simpleName.substring(0, simpleName.indexOf(".yml"));
}
return simpleName;
}
private File[] getPotentialWorldFiles() {
return worldsFolder.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".yml");
}
});
}
private WorldProperties getWorldProperties(final File file) throws IOException {
final YamlWorldProperties worldProperties = new YamlWorldProperties(file);
worldProperties.setPropertyValidator(WorldProperties.RESPAWN_WORLD, new RespawnWorldValidator(this));
return worldProperties;
}
@Override
public WorldProperties getWorldProperties(String worldName) throws IOException {
final World world = Bukkit.getWorld(worldName);
if (world != null) {
worldName = world.getName();
}
if (worldPropertiesMap.containsKey(worldName)) {
return worldPropertiesMap.get(worldName);
} else {
final WorldProperties worldProperties = getWorldProperties(new File(worldsFolder, worldName + ".yml"));
worldPropertiesMap.put(worldName, worldProperties);
return worldProperties;
}
}
/**
* {@inheritDoc}
*/
@Override
public BukkitMultiverseWorld createWorld(final WorldCreationSettings settings) throws WorldCreationException {
if (Bukkit.getWorld(settings.name()) != null) {
return null;
}
final WorldCreator c = WorldCreator.name(settings.name());
if (settings.env() != null) {
c.environment(Convert.toBukkit(settings.env()));
}
if (settings.type() != null) {
c.type(Convert.toBukkit(settings.type()));
}
if (settings.seed() != null) {
c.seed(settings.seed());
}
if (settings.generateStructures() != null) {
c.generateStructures(settings.generateStructures());
}
if (settings.generator() != null) {
final String[] split = settings.generator().split(":", 2);
final String id = (split.length > 1) ? split[1] : null;
final Plugin plugin = Bukkit.getPluginManager().getPlugin(split[0]);
if (plugin == null) {
throw new WorldCreationException(new BundledMessage(BukkitLanguage.WGEN_UNKNOWN_GENERATOR, settings.generator()));
} else if (!plugin.isEnabled()) {
throw new WorldCreationException(new BundledMessage(BukkitLanguage.WGEN_DISABLED_GENERATOR, settings.generator()));
} else {
c.generator(plugin.getDefaultWorldGenerator(settings.name(), id));
}
}
try {
final World w = c.createWorld();
return getBukkitWorld(w);
} catch (Exception e) {
throw new WorldCreationException(new BundledMessage(BukkitLanguage.CREATE_WORLD_ERROR, settings.name()), e);
}
}
private BukkitWorld getBukkitWorld(final World world) throws IOException {
return new BukkitWorld(world, getWorldProperties(world.getName()));
}
@Override
public List<String> getUnloadedWorlds() {
return Collections.unmodifiableList(new ArrayList<String>(worldPropertiesMap.keySet()));
}
}
@@ -1,90 +0,0 @@
package com.mvplugin.core;
import com.dumptruckman.minecraft.pluginbase.plugin.AbstractBukkitPlugin;
import com.dumptruckman.minecraft.pluginbase.properties.Properties;
import com.mvplugin.core.api.CoreConfig;
import com.mvplugin.core.api.MultiverseCore;
import com.mvplugin.core.command.ImportCommand;
import com.mvplugin.core.util.PropertyDescriptions;
import java.io.IOException;
/**
* The primary Bukkit plugin implementation of Multiverse-Core.
*
* See {@link MultiverseCore} for a more detailed external api javadocs.
*/
public class MultiverseCorePlugin extends AbstractBukkitPlugin implements MultiverseCore {
private static final int PROTOCOL = 19;
private static final String COMMAND_PREFIX = "mv";
private BukkitWorldManager worldManager;
public MultiverseCorePlugin() {
this.setPermissionName("multiverse.core");
}
@Override
protected void onPluginLoad() {
PropertyDescriptions.init();
}
@Override
public void onPluginEnable() {
worldManager = new BukkitWorldManager(this);
}
@Override
protected void onReloadConfig() {
worldManager = new BukkitWorldManager(this);
}
@Override
protected void registerCommands() {
registerCommand(ImportCommand.class);
}
@Override
public String getCommandPrefix() {
return COMMAND_PREFIX;
}
@Override
protected Properties getNewConfig() throws IOException {
return new YamlCoreConfig(this);
}
@Override
public CoreConfig config() {
return (CoreConfig) super.config();
}
@Override
public CoreConfig getMVConfig() {
return config();
}
@Override
protected boolean useDatabase() {
return false;
}
@Override
public BukkitWorldManager getWorldManager() {
return this.worldManager;
}
@Override
public MultiverseCore getCore() {
return this;
}
@Override
public void setCore(MultiverseCore core) { }
@Override
public int getProtocolVersion() {
return PROTOCOL;
}
}
@@ -1,17 +0,0 @@
package com.mvplugin.core;
import com.dumptruckman.minecraft.pluginbase.properties.YamlProperties;
import com.mvplugin.core.api.CoreConfig;
import java.io.File;
import java.io.IOException;
/**
* A yaml implementation of Multiverse-Core's primary configuration file.
*/
class YamlCoreConfig extends YamlProperties implements CoreConfig {
public YamlCoreConfig(MultiverseCorePlugin plugin) throws IOException {
super(true, true, new File(plugin.getDataFolder(), "config.yml"), CoreConfig.class);
}
}
@@ -1,76 +0,0 @@
package com.mvplugin.core;
import com.dumptruckman.minecraft.pluginbase.properties.PropertySerializer;
import com.dumptruckman.minecraft.pluginbase.properties.YamlProperties;
import com.mvplugin.core.api.WorldProperties;
import com.mvplugin.core.minecraft.PlayerPosition;
import org.bukkit.configuration.ConfigurationSection;
import java.io.File;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* YAML implementation of {@link WorldProperties} which will store all the world properties in a
* YAML file named after the world.
*/
class YamlWorldProperties extends YamlProperties implements WorldProperties {
YamlWorldProperties(File configFile) throws IOException {
super(false, true, configFile, WorldProperties.class);
}
@Override
protected void registerSerializers() {
super.registerSerializers();
setPropertySerializer(PlayerPosition.class, new PlayerPositionSerializer());
}
private static class PlayerPositionSerializer implements PropertySerializer<PlayerPosition> {
@Override
public PlayerPosition deserialize(Object o) {
String world = "";
double x = 0D;
double y = 0D;
double z = 0D;
float pitch = 0F;
float yaw = 0F;
if (o instanceof ConfigurationSection) {
o = ((ConfigurationSection) o).getValues(false);
}
if (o instanceof Map) {
Map map = (Map) o;
world = map.get("world").toString();
try {
x = Double.valueOf(map.get("x").toString());
} catch (Exception ignore) { }
try {
y = Double.valueOf(map.get("y").toString());
} catch (Exception ignore) { }
try {
z = Double.valueOf(map.get("z").toString());
} catch (Exception ignore) { }
try {
pitch = Float.valueOf(map.get("pitch").toString());
} catch (Exception ignore) { }
try {
yaw = Float.valueOf(map.get("yaw").toString());
} catch (Exception ignore) { }
}
return new PlayerPosition(world, x, y, z, pitch, yaw);
}
@Override
public Object serialize(PlayerPosition playerPosition) {
Map<String, Object> result = new LinkedHashMap<String, Object>(6);
result.put("world", playerPosition.getWorld() != null ? playerPosition.getWorld() : "");
result.put("x", playerPosition.getX());
result.put("y", playerPosition.getY());
result.put("z", playerPosition.getZ());
result.put("pitch", playerPosition.getPitch());
result.put("yaw", playerPosition.getYaw());
return result;
}
}
}
@@ -1,16 +0,0 @@
package com.mvplugin.core.api;
import org.bukkit.World;
/**
* Additional API for a Multiverse handled world specifically for Bukkit.
*/
public interface BukkitMultiverseWorld extends MultiverseWorld {
/**
* Gets the Bukkit {@link World} associated with this MultiverseWorld.
*
* @return The Bukkit world associated with this Multiverse world.
*/
World getBukkitWorld();
}
@@ -1,12 +0,0 @@
package com.mvplugin.core.util;
import com.dumptruckman.minecraft.pluginbase.messaging.Message;
public class BukkitLanguage {
public static final Message CREATE_WORLD_ERROR = new Message("worlds.create_world_error",
"&aBukkit&f experienced a problem while attempting to create '&b%s&f'!");
public static final Message WGEN_UNKNOWN_GENERATOR = new Message("worlds.create.unknown_generator",
"I can't create a &bBukkit&f world that uses the generator &c%s&f because it doesn't exist!");
public static final Message WGEN_DISABLED_GENERATOR = new Message("worlds.create.unknown_generator",
"I can't create a &bBukkit&f world that uses the generator &c%s&f because it is not enabled!");
}
@@ -1,33 +0,0 @@
package com.mvplugin.core.util;
import com.mvplugin.core.minecraft.PlayerPosition;
import com.mvplugin.core.minecraft.WorldEnvironment;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldType;
public final class Convert {
private Convert() {}
public static Difficulty toBukkit(com.mvplugin.core.minecraft.Difficulty d) {
return Difficulty.valueOf(d.name());
}
public static WorldType toBukkit(com.mvplugin.core.minecraft.WorldType t) {
return WorldType.valueOf(t.name());
}
public static com.mvplugin.core.minecraft.WorldType fromBukkit(WorldType t) {
return com.mvplugin.core.minecraft.WorldType.valueOf(t.name());
}
public static Environment toBukkit(WorldEnvironment e) {
return Environment.valueOf(e.name());
}
public static Location toBukkit(PlayerPosition position, World world) {
return new Location(world, position.getX(), position.getY(), position.getZ());
}
}
-4
View File
@@ -1,4 +0,0 @@
name: Multiverse-Core
main: com.mvplugin.core.MultiverseCorePlugin
authors: ['Rigby', 'fernferret', 'lithium3141', 'main--', 'dumptruckman']
version: maven-version-number
+1 -4
View File
@@ -76,10 +76,7 @@
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<module name="MethodLength">
<property name="severity" value="warning"/>
<property name="countEmpty" value="false"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
File diff suppressed because it is too large. Load diff
@@ -1,161 +0,0 @@
package com.onarandombox.MultiverseCore.api;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.utils.DebugLog;
import com.pneumaticraft.commandhandler.CommandHandler;
/**
* Make things easier for MV-Plugins!
*/
public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
private MultiverseCore core;
/**
* Prefix for standard log entrys.
*/
protected String logTag;
private DebugLog debugLog;
/**
* {@inheritDoc}
*
* Note: You can't override this, use {@link #onPluginEnable()} instead!
* @see #onPluginEnable()
*/
@Override
public final void onEnable() {
MultiverseCore theCore = (MultiverseCore) this.getServer().getPluginManager().getPlugin("Multiverse-Core");
if (theCore == null) {
this.getLogger().severe("Core not found! The plugin dev needs to add a dependency!");
this.getLogger().severe("Disabling!");
this.getServer().getPluginManager().disablePlugin(this);
return;
}
if (theCore.getProtocolVersion() < this.getProtocolVersion()) {
this.getLogger().severe("You need a newer version of Multiverse-Core!");
this.getLogger().severe("Disabling!");
this.getServer().getPluginManager().disablePlugin(this);
return;
}
this.setCore(theCore);
this.getServer().getLogger().info(String.format("%s - Version %s enabled - By %s",
this.getDescription().getName(), this.getDescription().getVersion(), getAuthors()));
getDataFolder().mkdirs();
File debugLogFile = new File(getDataFolder(), "debug.log");
try {
debugLogFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
debugLog = new DebugLog(this.getDescription().getName(), getDataFolder() + File.separator + "debug.log");
debugLog.setTag(String.format("[%s-Debug]", this.getDescription().getName()));
this.onPluginEnable();
}
/**
* Parse the Authors Array into a readable String with ',' and 'and'.
*
* @return The readable authors-{@link String}
*/
protected String getAuthors() {
String authors = "";
List<String> auths = this.getDescription().getAuthors();
if (auths.size() == 0) {
return "";
}
if (auths.size() == 1) {
return auths.get(0);
}
for (int i = 0; i < auths.size(); i++) {
if (i == this.getDescription().getAuthors().size() - 1) {
authors += " and " + this.getDescription().getAuthors().get(i);
} else {
authors += ", " + this.getDescription().getAuthors().get(i);
}
}
return authors.substring(2);
}
/**
* Called when the plugin is enabled.
* @see #onEnable()
*/
protected abstract void onPluginEnable();
/**
* You can register commands here.
* @param handler The CommandHandler.
*/
protected abstract void registerCommands(CommandHandler handler);
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!this.isEnabled()) {
sender.sendMessage("This plugin is Disabled!");
return true;
}
ArrayList<String> allArgs = new ArrayList<String>(args.length + 1);
allArgs.add(command.getName());
allArgs.addAll(Arrays.asList(args));
return this.getCore().getCommandHandler().locateAndRunCommand(sender, allArgs);
}
@Override
public void log(Level level, String msg) {
int debugLevel = this.getCore().getMVConfig().getGlobalDebug();
if ((level == Level.FINE && debugLevel >= 1) || (level == Level.FINER && debugLevel >= 2)
|| (level == Level.FINEST && debugLevel >= 3)) {
debugLog.log(level, msg);
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
String message = new StringBuilder(getLogTag()).append(msg).toString();
this.getServer().getLogger().log(level, message);
debugLog.log(level, message);
}
}
private String getLogTag() {
if (logTag == null)
logTag = String.format("[%s]", this.getDescription().getName());
return logTag;
}
/**
* Sets the debug log-tag.
* @param tag The new tag.
*/
protected final void setDebugLogTag(String tag) {
this.debugLog.setTag(tag);
}
@Override
public final String dumpVersionInfo(String buffer) {
throw new UnsupportedOperationException("This is gone.");
}
@Override
public final MultiverseCore getCore() {
if (this.core == null)
throw new IllegalStateException("Core is null!");
return this.core;
}
@Override
public final void setCore(MultiverseCore core) {
this.core = core;
}
}
@@ -1,60 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
/**
* Creates a clone of a world.
*/
public class CloneCommand extends MultiverseCommand {
private MVWorldManager worldManager;
public CloneCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Clone World");
this.setCommandUsage("/mv clone" + ChatColor.GREEN + " {TARGET} {NAME}" + ChatColor.GOLD + " -g [GENERATOR[:ID]]");
this.setArgRange(2, 4); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.addKey("mvclone");
this.addKey("mvcl");
this.addKey("mv cl");
this.addKey("mv clone");
this.addCommandExample("/mv clone " + ChatColor.GOLD + "world" + ChatColor.GREEN + " world_backup");
this.addCommandExample("/mv clone " + ChatColor.GOLD + "skyblock_pristine" + ChatColor.GREEN + " skyblock");
this.addCommandExample("To clone a world that uses a generator:");
this.addCommandExample("/mv clone " + ChatColor.GOLD + "CleanRoom"
+ ChatColor.GREEN + " CleanRoomCopy" + ChatColor.DARK_AQUA + " -g CleanRoomGenerator");
this.setPermission("multiverse.core.clone", "Clones a world.", PermissionDefault.OP);
this.worldManager = this.plugin.getMVWorldManager();
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
Class<?>[] paramTypes = {String.class, String.class, String.class};
List<Object> objectArgs = new ArrayList<Object>();
objectArgs.add(args.get(0));
objectArgs.add(args.get(1));
objectArgs.add(CommandHandler.getFlag("-g", args));
if (!this.worldManager.isMVWorld(args.get(0))) {
// If no world was found, we can't clone.
sender.sendMessage("Sorry, Multiverse doesn't know about world " + args.get(0) + ", so we can't clone it!");
sender.sendMessage("Check the " + ChatColor.GREEN + "/mv list" + ChatColor.WHITE + " command to verify it is listed.");
return;
}
this.plugin.getCommandHandler().queueCommand(sender, "mvclone", "cloneWorld", objectArgs,
paramTypes, ChatColor.GREEN + "World Cloned!", ChatColor.RED + "World could NOT be cloned!");
}
}
@@ -1,54 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.util.List;
/**
* States who is in what world.
*/
public class ScriptCommand extends MultiverseCommand {
public ScriptCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Runs a script.");
this.setCommandUsage("/mv script" + ChatColor.GOLD + " {script} [target]");
this.setArgRange(1, 2);
this.addKey("mv script");
this.addKey("mvscript");
this.addCommandExample(String.format("/mv script %sscript.txt", ChatColor.GOLD));
this.addCommandExample(String.format("/mv script %stest.txt %ssomeplayer", ChatColor.GOLD, ChatColor.GREEN));
this.setPermission("multiverse.core.script", "Runs a script.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
File file = new File(plugin.getScriptAPI().getScriptFolder(), args.get(0));
if (!file.exists()) {
sender.sendMessage("That script file does not exist in the Multiverse-Core scripts directory!");
return;
}
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
String target = null;
if (args.size() == 2) {
target = args.get(1);
}
plugin.getScriptAPI().executeScript(file, target, player);
sender.sendMessage(String.format("Script '%s%s%s' finished!", ChatColor.GOLD, file.getName(), ChatColor.WHITE));
}
}
@@ -1,52 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.util.List;
/**
* Enables debug-information.
*/
public class SilentCommand extends MultiverseCommand {
public SilentCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Turn silent mode on/off?");
this.setCommandUsage("/mv silent" + ChatColor.GOLD + " [true|false|on|off]");
this.setArgRange(0, 1);
this.addKey("mv silent");
this.addKey("mvsilent");
this.addCommandExample("/mv silent " + ChatColor.GOLD + "true");
this.setPermission("multiverse.core.silent", "Reduces the amount of startup messages.", PermissionDefault.OP);
}
@Override
public void runCommand(CommandSender sender, List<String> args) {
if (args.size() == 1) {
if (args.get(0).equalsIgnoreCase("on")) {
args.set(0, "true");
}
plugin.getMVConfig().setSilentStart(Boolean.valueOf(args.get(0)));
plugin.saveMVConfigs();
}
this.displaySilentMode(sender);
}
private void displaySilentMode(CommandSender sender) {
if (plugin.getMVConfig().getSilentStart()) {
sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.GREEN + "ON");
} else {
sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.RED + "OFF");
}
}
}
@@ -1,66 +0,0 @@
package com.onarandombox.MultiverseCore.configuration;
import java.util.Map;
import me.main__.util.SerializationConfig.Property;
import me.main__.util.SerializationConfig.SerializationConfig;
import org.bukkit.configuration.serialization.SerializableAs;
/**
* Entryfee-settings.
*/
@SerializableAs("MVEntryFee")
public class EntryFee extends SerializationConfig {
@Property
private double amount;
@Property
private int currency;
public EntryFee() {
super();
}
public EntryFee(Map<String, Object> values) {
super(values);
}
/**
* {@inheritDoc}
*/
@Override
protected void setDefaults() {
amount = 0D;
currency = -1;
}
/**
* @return the amount
*/
public double getAmount() {
return amount;
}
/**
* @return the currency
*/
public int getCurrency() {
return currency;
}
/**
* Sets the amount.
* @param amount The new value.
*/
public void setAmount(double amount) {
this.amount = amount;
}
/**
* Sets the currency.
* @param currency The new value.
*/
public void setCurrency(int currency) {
this.currency = currency;
}
}
@@ -1,98 +0,0 @@
package com.onarandombox.MultiverseCore.configuration;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
/**
* Just like a regular {@link Location}, however {@code world} is usually {@code null}
* or just a weak reference and it implements {@link ConfigurationSerializable}.
*/
@SerializableAs("MVSpawnLocation")
public class SpawnLocation extends Location implements ConfigurationSerializable {
private Reference<World> worldRef;
public SpawnLocation(double x, double y, double z) {
super(null, x, y, z);
}
public SpawnLocation(double x, double y, double z, float yaw, float pitch) {
super(null, x, y, z, yaw, pitch);
}
public SpawnLocation(Location loc) {
this(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
}
/**
* {@inheritDoc}
*/
@Override
public World getWorld() {
return (this.worldRef != null) ? this.worldRef.get() : null;
}
/**
* {@inheritDoc}
*/
@Override
public void setWorld(World world) {
this.worldRef = new WeakReference<World>(world);
}
/**
* {@inheritDoc}
*/
@Override
public Chunk getChunk() {
if ((this.worldRef != null) && (this.worldRef.get() != null))
return this.worldRef.get().getChunkAt(this);
return null;
}
/**
* {@inheritDoc}
*/
@Override
public Block getBlock() {
if ((this.worldRef != null) && (this.worldRef.get() != null))
return this.worldRef.get().getBlockAt(this);
return null;
}
/**
* {@inheritDoc}
*/
@Override
public Map<String, Object> serialize() {
Map<String, Object> serialized = new HashMap<String, Object>(5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
serialized.put("x", this.getX());
serialized.put("y", this.getY());
serialized.put("z", this.getZ());
serialized.put("pitch", this.getPitch());
serialized.put("yaw", this.getYaw());
return serialized;
}
/**
* Let Bukkit be able to deserialize this.
* @param args The map.
* @return The deserialized object.
*/
public static SpawnLocation deserialize(Map<String, Object> args) {
double x = ((Number) args.get("x")).doubleValue();
double y = ((Number) args.get("y")).doubleValue();
double z = ((Number) args.get("z")).doubleValue();
float pitch = ((Number) args.get("pitch")).floatValue();
float yaw = ((Number) args.get("yaw")).floatValue();
return new SpawnLocation(x, y, z, yaw, pitch);
}
}
@@ -1,50 +0,0 @@
package com.onarandombox.MultiverseCore.configuration;
import java.util.Map;
import me.main__.util.SerializationConfig.Property;
import me.main__.util.SerializationConfig.SerializationConfig;
import org.bukkit.configuration.serialization.SerializableAs;
/**
* Spawning-Settings.
*/
@SerializableAs("MVSpawnSettings")
public class SpawnSettings extends SerializationConfig {
@Property
private SubSpawnSettings animals;
@Property
private SubSpawnSettings monsters;
public SpawnSettings() {
super();
}
public SpawnSettings(Map<String, Object> values) {
super(values);
}
/**
* {@inheritDoc}
*/
@Override
public void setDefaults() {
animals = new SubSpawnSettings();
monsters = new SubSpawnSettings();
}
/**
* @return the animal-settings
*/
public SubSpawnSettings getAnimalSettings() {
return animals;
}
/**
* @return the monster-settings
*/
public SubSpawnSettings getMonsterSettings() {
return monsters;
}
}
@@ -1,76 +0,0 @@
package com.onarandombox.MultiverseCore.configuration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import me.main__.util.SerializationConfig.Property;
import me.main__.util.SerializationConfig.SerializationConfig;
import org.bukkit.configuration.serialization.SerializableAs;
/**
* SpawnSubSettings.
*/
@SerializableAs("MVSpawnSubSettings")
public class SubSpawnSettings extends SerializationConfig {
@Property
private boolean spawn;
@Property
private int spawnrate;
@Property
private List<String> exceptions;
public SubSpawnSettings() {
super();
}
public SubSpawnSettings(Map<String, Object> values) {
super(values);
}
/**
* {@inheritDoc}
*/
@Override
public void setDefaults() {
spawn = true;
exceptions = new ArrayList<String>();
spawnrate = -1;
}
/**
* @return spawn
*/
public boolean doSpawn() {
return spawn;
}
/**
* @param spawn The new value.
*/
public void setSpawn(boolean spawn) {
this.spawn = spawn;
}
/**
* @return The exceptions
*/
public List<String> getExceptions() {
return exceptions;
}
/**
* @param rate The new spawn rate
*/
public void setSpawnRate(int rate) {
this.spawnrate = rate;
}
/**
* @return The spawn rate
*/
public int getSpawnRate() {
return this.spawnrate;
}
}
@@ -1,27 +0,0 @@
package com.onarandombox.MultiverseCore.configuration;
import org.bukkit.Bukkit;
import com.onarandombox.MultiverseCore.MVWorld;
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;
import me.main__.util.SerializationConfig.ChangeDeniedException;
import me.main__.util.SerializationConfig.ObjectUsingValidator;
/**
* Validates world-property-changes.
* @param <T> The type of the property that should be validated.
*/
public class WorldPropertyValidator<T> extends ObjectUsingValidator<T, MVWorld> {
/**
* {@inheritDoc}
*/
@Override
public T validateChange(String property, T newValue, T oldValue, MVWorld object) throws ChangeDeniedException {
MVWorldPropertyChangeEvent<T> event = new MVWorldPropertyChangeEvent<T>(object, null, property, newValue);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled())
throw new ChangeDeniedException();
return event.getTheNewValue();
}
}
@@ -1,49 +0,0 @@
package com.onarandombox.MultiverseCore.enums;
import org.bukkit.ChatColor;
/**
* A regular {@link ChatColor} represented by an english string.
* @see ChatColor
*/
public enum EnglishChatStyle {
// BEGIN CHECKSTYLE-SUPPRESSION: JavadocVariable
/** No style. */
NORMAL(null),
MAGIC(ChatColor.MAGIC),
BOLD(ChatColor.BOLD),
STRIKETHROUGH(ChatColor.STRIKETHROUGH),
UNDERLINE(ChatColor.UNDERLINE),
ITALIC(ChatColor.ITALIC);
// END CHECKSTYLE-SUPPRESSION: JavadocVariable
private final ChatColor color;
EnglishChatStyle(ChatColor color) {
this.color = color;
}
/**
* Gets the color.
* @return The color as {@link ChatColor}.
*/
public ChatColor getColor() {
return color;
}
/**
* Constructs an {@link EnglishChatStyle} from a {@link String}.
* @param text The {@link String}.
* @return The {@link EnglishChatStyle}.
*/
public static EnglishChatStyle fromString(String text) {
if (text != null) {
for (EnglishChatStyle c : EnglishChatStyle.values()) {
if (text.equalsIgnoreCase(c.name())) {
return c;
}
}
}
return null;
}
}
@@ -1,35 +0,0 @@
package com.onarandombox.MultiverseCore.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
/**
* A wrapper for the {@link AsyncPlayerChatEvent}.
*/
public class AsyncChatEvent implements ChatEvent {
private final AsyncPlayerChatEvent event;
public AsyncChatEvent(AsyncPlayerChatEvent event) {
this.event = event;
}
@Override
public boolean isCancelled() {
return event.isCancelled();
}
@Override
public String getFormat() {
return event.getFormat();
}
@Override
public void setFormat(String s) {
event.setFormat(s);
}
@Override
public Player getPlayer() {
return event.getPlayer();
}
}
@@ -1,29 +0,0 @@
package com.onarandombox.MultiverseCore.listeners;
import org.bukkit.entity.Player;
/**
* A wrapper for the two chat-events in Bukkit.
*/
public interface ChatEvent {
/**
* @return Whether this event is cancelled.
*/
boolean isCancelled();
/**
* @return The format.
*/
String getFormat();
/**
* Sets the format.
* @param s The new format.
*/
void setFormat(String s);
/**
* @return The player.
*/
Player getPlayer();
}
@@ -1,34 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.listeners;
import java.util.logging.Level;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import com.onarandombox.MultiverseCore.MultiverseCore;
/**
* Multiverse's {@link org.bukkit.event.Listener} for players.
*/
public class MVAsyncPlayerChatListener extends MVChatListener {
public MVAsyncPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
super(plugin, playerListener);
plugin.log(Level.FINE, "Created AsyncPlayerChatEvent listener.");
}
/**
* This method is called when a player wants to chat.
* @param event The Event that was fired.
*/
@EventHandler
public void playerChat(AsyncPlayerChatEvent event) {
this.playerChat(new AsyncChatEvent(event));
}
}
@@ -1,52 +0,0 @@
package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.event.Listener;
/**
* Multiverse's {@link org.bukkit.event.Listener} for players.
*/
public abstract class MVChatListener implements Listener {
private final MultiverseCore plugin;
private final MVWorldManager worldManager;
private final MVPlayerListener playerListener;
public MVChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
this.plugin = plugin;
this.worldManager = plugin.getMVWorldManager();
this.playerListener = playerListener;
}
/**
* This handles a {@link ChatEvent}.
* @param event The {@link ChatEvent}.
*/
public void playerChat(ChatEvent event) {
if (event.isCancelled()) {
return;
}
// Check whether the Server is set to prefix the chat with the World name.
// If not we do nothing, if so we need to check if the World has an Alias.
if (plugin.getMVConfig().getPrefixChat()) {
String world = playerListener.getPlayerWorld().get(event.getPlayer().getName());
if (world == null) {
world = event.getPlayer().getWorld().getName();
playerListener.getPlayerWorld().put(event.getPlayer().getName(), world);
}
String prefix = "";
// If we're not a MV world, don't do anything
if (!this.worldManager.isMVWorld(world)) {
return;
}
MultiverseWorld mvworld = this.worldManager.getMVWorld(world);
if (mvworld.isHidden()) {
return;
}
prefix = mvworld.getColoredWorldString();
String format = event.getFormat();
event.setFormat("[" + prefix + "]" + format);
}
}
}
@@ -1,35 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.listeners;
import java.util.logging.Level;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerChatEvent;
import com.onarandombox.MultiverseCore.MultiverseCore;
/**
* Multiverse's {@link org.bukkit.event.Listener} for players.
*/
@SuppressWarnings("deprecation") // this exists only for downwards compatibility
public class MVPlayerChatListener extends MVChatListener {
public MVPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
super(plugin, playerListener);
plugin.log(Level.FINE, "Registered PlayerChatEvent listener.");
}
/**
* This method is called when a player wants to chat.
* @param event The Event that was fired.
*/
@EventHandler
public void playerChat(PlayerChatEvent event) {
this.playerChat(new NormalChatEvent(event));
}
}
@@ -1,37 +0,0 @@
package com.onarandombox.MultiverseCore.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
/**
* A wrapper for the {@link PlayerChatEvent}.
* @deprecated This is deprecated like the {@link PlayerChatEvent}.
*/
@Deprecated
public class NormalChatEvent implements ChatEvent {
private final PlayerChatEvent event;
public NormalChatEvent(PlayerChatEvent event) {
this.event = event;
}
@Override
public boolean isCancelled() {
return event.isCancelled();
}
@Override
public String getFormat() {
return event.getFormat();
}
@Override
public void setFormat(String s) {
event.setFormat(s);
}
@Override
public Player getPlayer() {
return event.getPlayer();
}
}
@@ -1,122 +0,0 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Logger;
/**
* File-utilities.
*/
public class FileUtils {
protected FileUtils() {
throw new UnsupportedOperationException();
}
/**
* Used to delete a folder.
*
* @param file The folder to delete.
* @return true if the folder was successfully deleted.
*/
public static boolean deleteFolder(File file) {
if (file.exists()) {
boolean ret = true;
// If the file exists, and it has more than one file in it.
if (file.isDirectory()) {
for (File f : file.listFiles()) {
ret = ret && deleteFolder(f);
}
}
return ret && file.delete();
} else {
return false;
}
}
/**
* Used to delete the contents of a folder, without deleting the folder itself.
*
* @param file The folder whose contents to delete.
* @return true if the contents were successfully deleted
*/
public static boolean deleteFolderContents(File file) {
if (file.exists()) {
boolean ret = true;
// If the file exists, and it has more than one file in it.
if (file.isDirectory()) {
for (File f : file.listFiles()) {
ret = ret && deleteFolder(f);
}
}
return ret;
} else {
return false;
}
}
private static final int COPY_BLOCK_SIZE = 1024;
/**
* Helper method to copy the world-folder.
* @param source Source-File
* @param target Target-File
* @param log A logger that logs the operation
*
* @return if it had success
*/
public static boolean copyFolder(File source, File target, Logger log) {
InputStream in = null;
OutputStream out = null;
try {
if (source.isDirectory()) {
if (!target.exists())
target.mkdir();
String[] children = source.list();
// for (int i=0; i<children.length; i++) {
for (String child : children) {
copyFolder(new File(source, child), new File(target, child), log);
}
} else {
in = new FileInputStream(source);
out = new FileOutputStream(target);
byte[] buf = new byte[COPY_BLOCK_SIZE];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
}
return true;
} catch (FileNotFoundException e) {
log.warning("Exception while copying file: " + e.getMessage());
} catch (IOException e) {
log.warning("Exception while copying file: " + e.getMessage());
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ignore) { }
}
if (out != null) {
try {
out.close();
} catch (IOException ignore) { }
}
}
return false;
}
}
@@ -1,72 +0,0 @@
package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
/**
* A class we use to interface with Vault when it is present.
*/
public class VaultHandler implements Listener {
private Economy economy;
public VaultHandler(final Plugin plugin) {
Bukkit.getPluginManager().registerEvents(new VaultListener(), plugin);
setupVaultEconomy();
}
private boolean setupVaultEconomy() {
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
final RegisteredServiceProvider<Economy> economyProvider =
Bukkit.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
Logging.fine("Vault economy enabled.");
economy = economyProvider.getProvider();
} else {
Logging.finer("Vault economy not detected.");
economy = null;
}
} else {
Logging.finer("Vault was not found.");
economy = null;
}
return (economy != null);
}
/**
* Listens for Vault plugin events.
*/
private class VaultListener implements Listener {
@EventHandler
private void vaultEnabled(PluginEnableEvent event) {
if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) {
setupVaultEconomy();
}
}
@EventHandler
private void vaultDisabled(PluginDisableEvent event) {
if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) {
Logging.fine("Vault economy disabled");
setupVaultEconomy();
}
}
}
/**
* Returns the Vault economy system if Vault is present and has an economy system enabled.
*
* @return The vault economy system or null if not configured.
*/
public Economy getEconomy() {
return economy;
}
}
@@ -1,34 +0,0 @@
package com.onarandombox.MultiverseCore.utils.webpaste;
import java.io.IOException;
/**
* An {@link URLShortener} using {@code bit.ly}.
*/
public class BitlyURLShortener extends HttpAPIClient implements URLShortener {
private static final String GENERIC_BITLY_REQUEST_FORMAT = "https://api-ssl.bitly.com/v3/shorten?format=txt&apiKey=%s&login=%s&longUrl=%s";
// I think it's no problem that these are public
private static final String USERNAME = "multiverse2";
private static final String API_KEY = "R_9dbff4862a3bc0c4218a7d78cc10d0e0";
public BitlyURLShortener() {
super(String.format(GENERIC_BITLY_REQUEST_FORMAT, API_KEY, USERNAME, "%s"));
}
/**
* {@inheritDoc}
*/
@Override
public String shorten(String longUrl) {
try {
String result = this.exec(longUrl);
if (!result.startsWith("http://j.mp/")) // ... then it's failed :/
throw new IOException(result);
return result;
} catch (IOException e) {
e.printStackTrace();
return longUrl; // sorry ...
}
}
}
@@ -1,50 +0,0 @@
package com.onarandombox.MultiverseCore.utils.webpaste;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
/**
* HTTP API-client.
*/
public abstract class HttpAPIClient {
/**
* The URL for this API-request.
*/
protected final String urlFormat;
public HttpAPIClient(String urlFormat) {
this.urlFormat = urlFormat;
}
/**
* Executes this API-Request.
* @param args Format-args.
* @return The result (as text).
* @throws IOException When the I/O-operation failed.
*/
protected final String exec(Object... args) throws IOException {
URLConnection conn = new URL(String.format(this.urlFormat, args)).openConnection();
conn.connect();
StringBuilder ret = new StringBuilder();
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while (!reader.ready()); // wait until reader is ready, may not be necessary, SUPPRESS CHECKSTYLE: EmptyStatement
while (reader.ready()) {
ret.append(reader.readLine()).append('\n');
}
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException ignore) { }
}
}
return ret.toString();
}
}
@@ -1,13 +0,0 @@
package com.onarandombox.MultiverseCore.utils.webpaste;
/**
* URL-Shortener.
*/
public interface URLShortener {
/**
* Shorten an URL.
* @param longUrl The long form.
* @return The shortened URL.
*/
String shorten(String longUrl);
}
@@ -1,158 +0,0 @@
package com.onarandombox.MultiverseCore.test;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.plugin.PluginDescriptionFile;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
public class TestEntitySpawnRules {
TestInstanceCreator creator;
MultiverseCore core;
MVEntityListener listener;
MultiverseWorld mvWorld;
World cbworld;
Sheep sheep;
Zombie zombie;
CreatureSpawnEvent sheepEvent;
CreatureSpawnEvent zombieEvent;
@Before
public void setUp() throws Exception {
creator = new TestInstanceCreator();
assertTrue(creator.setUp());
core = creator.getCore();
listener = core.getEntityListener();
mvWorld = mock(MultiverseWorld.class);
cbworld = mock(World.class);
when(mvWorld.getCBWorld()).thenReturn(cbworld);
MVWorldManager worldman = mock(MVWorldManager.class);
when(worldman.isMVWorld(anyString())).thenReturn(true);
when(worldman.getMVWorld(anyString())).thenReturn(mvWorld);
Field worldmanfield = MVEntityListener.class.getDeclaredField("worldManager");
worldmanfield.setAccessible(true);
worldmanfield.set(listener, worldman);
core.getMVConfig().setGlobalDebug(3);
}
@After
public void tearDown() throws Exception {
creator.tearDown();
}
private static CreatureSpawnEvent mockSpawnEvent(LivingEntity e, SpawnReason reason) {
CreatureSpawnEvent event = mock(CreatureSpawnEvent.class);
when(event.getEntity()).thenReturn(e);
EntityType type = e.getType();
when(event.getEntityType()).thenReturn(type);
when(event.getSpawnReason()).thenReturn(reason);
return event;
}
private void spawnAll(SpawnReason reason) {
sheepEvent = mockSpawnEvent(sheep, reason);
zombieEvent = mockSpawnEvent(zombie, reason);
listener.creatureSpawn(sheepEvent);
listener.creatureSpawn(zombieEvent);
}
private void spawnAllNatural() {
spawnAll(SpawnReason.NATURAL);
}
private void adjustSettings(boolean animalSpawn, boolean monsterSpawn,
List<String> animalExceptions, List<String> monsterExceptions) {
when(this.mvWorld.canAnimalsSpawn()).thenReturn(animalSpawn);
when(this.mvWorld.canMonstersSpawn()).thenReturn(monsterSpawn);
when(this.mvWorld.getAnimalList()).thenReturn(animalExceptions);
when(this.mvWorld.getMonsterList()).thenReturn(monsterExceptions);
}
@Test
public void test() {
// test 1: no spawning at all allowed
adjustSettings(false, false, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(true);
// test 2: only monsters
adjustSettings(false, true, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(false);
// test 3: all spawning allowed
adjustSettings(true, true, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(false);
verify(zombieEvent).setCancelled(false);
// test 4: no spawning with zombie exception
adjustSettings(false, false, Collections.EMPTY_LIST, Arrays.asList("ZOMBIE"));
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(false);
// test 5: all spawning with sheep exception
adjustSettings(true, true, Arrays.asList("SHEEP"), Collections.EMPTY_LIST);
createAnimals();
spawnAllNatural();
verify(sheepEvent).setCancelled(true);
verify(zombieEvent).setCancelled(false);
// test 6: eggs
adjustSettings(false, false, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
createAnimals();
spawnAll(SpawnReason.SPAWNER_EGG);
verify(sheepEvent, never()).setCancelled(anyBoolean());
verify(zombieEvent, never()).setCancelled(anyBoolean());
}
private void createAnimals() {
sheep = mock(Sheep.class);
when(sheep.getType()).thenReturn(EntityType.SHEEP);
when(sheep.getWorld()).thenReturn(this.cbworld);
zombie = mock(Zombie.class);
when(zombie.getType()).thenReturn(EntityType.ZOMBIE);
when(zombie.getWorld()).thenReturn(this.cbworld);
when(cbworld.getEntities()).thenReturn(Arrays.asList((Entity) sheep, (Entity) zombie));
}
}
@@ -1,61 +0,0 @@
package com.onarandombox.MultiverseCore.test;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import org.bukkit.Server;
import org.bukkit.World.Environment;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginDescriptionFile;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
@RunWith(PowerMockRunner.class)
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
public class TestModifyCommand {
TestInstanceCreator creator;
Server mockServer;
MultiverseCore core;
CommandSender mockCommandSender;
@Before
public void setUp() throws Exception {
creator = new TestInstanceCreator();
assertTrue(creator.setUp());
mockServer = creator.getServer();
mockCommandSender = creator.getCommandSender();
core = creator.getCore();
// create world
assertTrue(core.getMVWorldManager().addWorld("world", Environment.NORMAL, null, null, null, null));
}
@After
public void tearDown() throws Exception {
creator.tearDown();
}
@Test
public void testSetHidden() {
Command cmd = mock(Command.class);
when(cmd.getName()).thenReturn("mv");
MultiverseWorld world = core.getMVWorldManager().getMVWorld("world");
assertNotNull(world);
assertFalse(world.isHidden()); // ensure it's not hidden now
assertTrue(core.onCommand(mockCommandSender, cmd, "", // run the command
new String[] { "modify", "set", "hidden", "true", "world" }));
assertTrue(world.isHidden()); // test if it worked
}
}
+253 -35
View File
@@ -1,45 +1,263 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mvplugin</groupId>
<artifactId>MultiverseCore</artifactId>
<version>3.0-SNAPSHOT</version>
<name>Multiverse-Core</name>
<url>http://ci.onarandombox.org</url>
<description>World Management Plugin</description>
<packaging>pom</packaging>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.onarandombox.multiversecore</groupId>
<artifactId>Multiverse-Core</artifactId>
<version>2.4</version>
<name>Multiverse-Core</name>
<description>World Management Plugin</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>UNKNOWN</project.build.number>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>LOCAL</project.build.number>
</properties>
<repositories>
<repository>
<id>onarandombox</id>
<url>http://repo.onarandombox.com/content/groups/public</url>
</repository>
<repository>
<id>Bukkit Official</id>
<url>http://repo.bukkit.org/content/repositories/public</url>
</repository>
</repositories>
<!-- Modules -->
<modules>
<module>base</module>
<module>bukkit</module>
</modules>
<pluginRepositories>
<pluginRepository>
<id>doodleproject-repo</id>
<name>DoodleProject Maven 2 Repository</name>
<url>http://doodleproject.sourceforge.net/maven2/release</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<ciManagement>
<system>jenkins</system>
<url>http://ci.onarandombox.com</url>
</ciManagement>
<ciManagement>
<system>jenkins</system>
<url>http://ci.onarandombox.com</url>
</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>
<defaultGoal>clean package</defaultGoal>
<plugins>
<!-- Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3.8</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/classes/plugin.yml</file>
<replacements>
<replacement>
<token>maven-version-number</token>
<value>${project.version}-b${project.build.number}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<!-- Jar Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifestEntries>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!-- Maven Source Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.8</version>
<configuration>
<enableRulesSummary>true</enableRulesSummary>
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>me.main__.util:SerializationConfig</include>
<include>com.fernferret.allpay:AllPay</include>
<include>com.pneumaticraft.commandhandler:CommandHandler</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.fernferret.allpay</pattern>
<shadedPattern>com.fernferret.allpay.multiverse</shadedPattern>
</relocation>
<relocation>
<pattern>me.main__.util</pattern>
<shadedPattern>me.main__.util.multiverse</shadedPattern>
</relocation>
<relocation>
<pattern>com.pneumaticraft.commandhandler</pattern>
<shadedPattern>com.pneumaticraft.commandhandler.multiverse</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Bukkit Dependency -->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.1-R5-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- Bukkit Dependency -->
<!-- Start of Spout -->
<dependency>
<groupId>org.getspout</groupId>
<artifactId>spoutpluginapi</artifactId>
<version>dev-SNAPSHOT</version>
</dependency>
<!-- End of Spout -->
<!-- SerializationConfig Dependency -->
<dependency>
<groupId>me.main__.util</groupId>
<artifactId>SerializationConfig</artifactId>
<version>1.3</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of SerializationConfig Dependency -->
<!-- Start of AllPay Dependency -->
<dependency>
<groupId>com.fernferret.allpay</groupId>
<artifactId>AllPay</artifactId>
<version>8</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of AllPay Dependency -->
<!-- Start of CommandHandler Dependency -->
<dependency>
<groupId>com.pneumaticraft.commandhandler</groupId>
<artifactId>CommandHandler</artifactId>
<version>6</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of CommandHandler Dependency -->
<!-- Start of Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.4.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<version>1.4.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.4.9</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<!-- End of Test Dependencies -->
</dependencies>
<distributionManagement>
<repository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse/</url>
<url>http://repo.onarandombox.com/content/repositories/multiverse</url>
</repository>
<snapshotRepository>
<id>OnARandomBox</id>
<url>http://repo.onarandombox.com/content/repositories/multiverse-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<scm>
<connection>scm:git:git://github.com/multiverse/Multiverse-Core.git</connection>
<url>https://github.com/multiverse/Multiverse-Core</url>
<developerConnection>scm:git:git@github.com:multiverse/Multiverse-Core.git</developerConnection>
</scm>
</project>
</project>
File diff suppressed because it is too large. Load diff
@@ -7,8 +7,6 @@
package com.onarandombox.MultiverseCore;
import buscript.Buscript;
import com.dumptruckman.minecraft.util.Logging;
import com.fernferret.allpay.AllPay;
import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.api.BlockSafety;
@@ -20,39 +18,7 @@ import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.commands.AnchorCommand;
import com.onarandombox.MultiverseCore.commands.CheckCommand;
import com.onarandombox.MultiverseCore.commands.CloneCommand;
import com.onarandombox.MultiverseCore.commands.ConfigCommand;
import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
import com.onarandombox.MultiverseCore.commands.CoordCommand;
import com.onarandombox.MultiverseCore.commands.CreateCommand;
import com.onarandombox.MultiverseCore.commands.DebugCommand;
import com.onarandombox.MultiverseCore.commands.DeleteCommand;
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
import com.onarandombox.MultiverseCore.commands.GeneratorCommand;
import com.onarandombox.MultiverseCore.commands.HelpCommand;
import com.onarandombox.MultiverseCore.commands.ImportCommand;
import com.onarandombox.MultiverseCore.commands.InfoCommand;
import com.onarandombox.MultiverseCore.commands.ListCommand;
import com.onarandombox.MultiverseCore.commands.LoadCommand;
import com.onarandombox.MultiverseCore.commands.ModifyAddCommand;
import com.onarandombox.MultiverseCore.commands.ModifyClearCommand;
import com.onarandombox.MultiverseCore.commands.ModifyCommand;
import com.onarandombox.MultiverseCore.commands.ModifyRemoveCommand;
import com.onarandombox.MultiverseCore.commands.ModifySetCommand;
import com.onarandombox.MultiverseCore.commands.PurgeCommand;
import com.onarandombox.MultiverseCore.commands.RegenCommand;
import com.onarandombox.MultiverseCore.commands.ReloadCommand;
import com.onarandombox.MultiverseCore.commands.RemoveCommand;
import com.onarandombox.MultiverseCore.commands.ScriptCommand;
import com.onarandombox.MultiverseCore.commands.SetSpawnCommand;
import com.onarandombox.MultiverseCore.commands.SilentCommand;
import com.onarandombox.MultiverseCore.commands.SpawnCommand;
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
import com.onarandombox.MultiverseCore.commands.UnloadCommand;
import com.onarandombox.MultiverseCore.commands.VersionCommand;
import com.onarandombox.MultiverseCore.commands.WhoCommand;
import com.onarandombox.MultiverseCore.commands.*;
import com.onarandombox.MultiverseCore.destination.AnchorDestination;
import com.onarandombox.MultiverseCore.destination.BedDestination;
import com.onarandombox.MultiverseCore.destination.CannonDestination;
@@ -61,67 +27,50 @@ import com.onarandombox.MultiverseCore.destination.ExactDestination;
import com.onarandombox.MultiverseCore.destination.PlayerDestination;
import com.onarandombox.MultiverseCore.destination.WorldDestination;
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
import com.onarandombox.MultiverseCore.listeners.MVChatListener;
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerChatListener;
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVMessaging;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.VaultHandler;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
import com.onarandombox.MultiverseCore.utils.*;
import com.pneumaticraft.commandhandler.CommandHandler;
import me.main__.util.SerializationConfig.SerializationConfig;
import org.bukkit.ChatColor;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World.Environment;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.mcstats.Metrics;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* The implementation of the Multiverse-{@link Core}.
*/
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private static final int PROTOCOL = 18;
private static final int PROTOCOL = 14;
// TODO: Investigate if this one is really needed to be static.
// Doubt it. -- FernFerret
private static Map<String, String> teleportQueue = new HashMap<String, String>();
private AnchorManager anchorManager = new AnchorManager(this);
// TODO please let's make this non-static
private volatile MultiverseCoreConfiguration config;
private static MultiverseCoreConfiguration config;
/**
* This method is used to find out who is teleporting a player.
@@ -144,7 +93,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* @param teleportee The name of the player that was teleported.
*/
public static void addPlayerToTeleportQueue(String teleporter, String teleportee) {
Logging.finest("Adding mapping '%s' => '%s' to teleport queue", teleporter, teleportee);
staticLog(Level.FINEST, "Adding mapping '" + teleporter + "' => '" + teleportee + "' to teleport queue");
teleportQueue.put(teleportee, teleporter);
}
@@ -180,6 +129,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
return MultiverseCore.PROTOCOL;
}
// Useless stuff to keep us going.
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private static DebugLog debugLog;
// Setup our Map for our Commands using the CommandHandler.
private CommandHandler commandHandler;
@@ -191,25 +144,22 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Configurations
private FileConfiguration multiverseConfig = null;
private final MVWorldManager worldManager = new WorldManager(this);
private MVWorldManager worldManager = new WorldManager(this);
// Setup the block/player/entity listener.
private final MVPlayerListener playerListener = new MVPlayerListener(this);
private final MVEntityListener entityListener = new MVEntityListener(this);
private final MVPluginListener pluginListener = new MVPluginListener(this);
private final MVWeatherListener weatherListener = new MVWeatherListener(this);
private final MVPortalListener portalListener = new MVPortalListener(this);
private MVChatListener chatListener;
private MVPlayerListener playerListener = new MVPlayerListener(this);
private MVEntityListener entityListener = new MVEntityListener(this);
private MVPluginListener pluginListener = new MVPluginListener(this);
private MVWeatherListener weatherListener = new MVWeatherListener(this);
private MVPortalListener portalListener = new MVPortalListener(this);
// HashMap to contain information relating to the Players.
private HashMap<String, MVPlayerSession> playerSessions;
private VaultHandler vaultHandler;
private GenericBank bank = null;
private AllPay banker;
private Buscript buscript;
private int pluginCount;
private DestinationFactory destFactory;
//private SpoutInterface spoutInterface = null;
private SpoutInterface spoutInterface = null;
private MultiverseMessaging messaging;
private BlockSafety blockSafety;
private LocationManipulation locationManipulation;
@@ -221,13 +171,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
public void onLoad() {
// Register our config
SerializationConfig.registerAll(MultiverseCoreConfiguration.class);
// Register our world
SerializationConfig.registerAll(MVWorld.class);
// Create our DataFolder
getDataFolder().mkdirs();
// Setup our Debug Log
Logging.init(this);
SerializationConfig.initLogging(Logging.getLogger());
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
// Setup our BlockSafety
this.blockSafety = new SimpleBlockSafety(this);
// Setup our LocationManipulation
@@ -248,19 +195,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
/**
* {@inheritDoc}
* @deprecated Now using Vault.
*/
@Override
@Deprecated
public GenericBank getBank() {
return this.bank;
}
@Override
public VaultHandler getVaultHandler() {
return vaultHandler;
}
/**
* {@inheritDoc}
*/
@@ -268,7 +208,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
public void onEnable() {
this.messaging = new MVMessaging();
this.banker = new AllPay(this, LOG_TAG + " ");
this.vaultHandler = new VaultHandler(this);
// Output a little snippet to show it's enabled.
this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " (API v" + PROTOCOL + ") Enabled - By " + getAuthors());
// Load the defaultWorldGenerators
this.worldManager.getDefaultWorldGenerators();
@@ -297,8 +238,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Setup & Load our Configuration files.
loadConfigs();
if (this.multiverseConfig != null) {
Logging.setDebugLevel(getMVConfig().getGlobalDebug());
Logging.setShowingConfig(!getMVConfig().getSilentStart());
this.worldManager.loadDefaultWorlds();
this.worldManager.loadWorlds(true);
} else {
@@ -307,138 +246,18 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.anchorManager.loadAnchors();
// Now set the firstspawnworld (after the worlds are loaded):
this.worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnWorld());
this.worldManager.setFirstSpawnWorld(config.getFirstSpawnWorld());
try {
getMVConfig().setFirstSpawnWorld(this.worldManager.getFirstSpawnWorld().getName());
config.setFirstSpawnWorld(this.worldManager.getFirstSpawnWorld().getName());
} catch (NullPointerException e) {
// A test that had no worlds loaded was being run. This should never happen in production
}
this.saveMVConfig();
// Register async or sync player chat according to config
try {
Class.forName("org.bukkit.event.player.AsyncPlayerChatEvent");
} catch (ClassNotFoundException e) {
getMVConfig().setUseAsyncChat(false);
}
if (getMVConfig().getUseAsyncChat()) {
this.chatListener = new MVAsyncPlayerChatListener(this, this.playerListener);
} else {
this.chatListener = new MVPlayerChatListener(this, this.playerListener);
}
getServer().getPluginManager().registerEvents(this.chatListener, this);
/*
// Check to see if spout was already loaded (most likely):
if (this.getServer().getPluginManager().getPlugin("Spout") != null) {
this.setSpout();
this.log(Level.INFO, "Spout integration enabled.");
}
*/
this.initializeBuscript();
this.setupMetrics();
// Output a little snippet to show it's enabled.
Logging.config("Version %s (API v%s) Enabled - By %s", this.getDescription().getVersion(), PROTOCOL, getAuthors());
}
/**
* Initializes the buscript javascript library.
*/
private void initializeBuscript() {
buscript = new Buscript(this);
// Add global variable "multiverse" to javascript environment
buscript.getGlobalScope().put("multiverse", buscript.getGlobalScope(), this);
}
/**
* Plotter for Environment-Values.
*/
private static final class EnvironmentPlotter extends Metrics.Plotter {
private MultiverseCore core;
private final Environment env;
public EnvironmentPlotter(MultiverseCore core, Environment env) {
super(envToString(env));
this.core = core;
this.env = env;
}
private static String envToString(Environment env) {
return new StringBuilder().append(env.name().toUpperCase().charAt(0))
.append(env.name().toLowerCase().substring(1)).toString();
}
@Override
public int getValue() {
int count = 0;
for (MultiverseWorld w : core.getMVWorldManager().getMVWorlds())
if (w.getEnvironment() == env)
count++;
core.log(Level.FINE, String.format("Tracking %d worlds of type %s", count, env));
return count;
}
}
/**
* Plotter for Generator-Values.
*/
private static final class GeneratorPlotter extends Metrics.Plotter {
private MultiverseCore core;
private final String gen;
public GeneratorPlotter(MultiverseCore core, String gen) {
super(gen);
this.core = core;
this.gen = gen;
}
@Override
public int getValue() {
int count = 0;
for (MultiverseWorld w : core.getMVWorldManager().getMVWorlds())
if (gen.equals(w.getGenerator()))
count++;
core.log(Level.FINE, String.format("Tracking %d worlds of type %s", count, gen));
return count;
}
}
private void setupMetrics() {
try {
Metrics m = new Metrics(this);
Metrics.Graph envGraph = m.createGraph("worlds_by_env");
for (Environment env : Environment.values())
envGraph.addPlotter(new EnvironmentPlotter(this, env));
m.addCustomData(new Metrics.Plotter("Loaded worlds") {
@Override
public int getValue() {
return getMVWorldManager().getMVWorlds().size();
}
});
m.addCustomData(new Metrics.Plotter("Total number of worlds") {
@Override
public int getValue() {
return getMVWorldManager().getMVWorlds().size()
+ getMVWorldManager().getUnloadedWorlds().size();
}
});
Set<String> gens = new HashSet<String>();
for (MultiverseWorld w : this.getMVWorldManager().getMVWorlds())
gens.add(w.getGenerator());
gens.remove(null);
gens.remove("null");
Metrics.Graph genGraph = m.createGraph("custom_gens");
for (String gen : gens)
genGraph.addPlotter(new GeneratorPlotter(this, gen));
m.start();
log(Level.FINE, "Metrics have run!");
} catch (IOException e) {
log(Level.WARNING, "There was an issue while enabling metrics: " + e.getMessage());
}
}
private void initializeDestinationFactory() {
@@ -476,18 +295,18 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.multiverseConfig.setDefaults(coreDefaults);
this.multiverseConfig.options().copyDefaults(false);
this.multiverseConfig.options().copyHeader(true);
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
MultiverseCoreConfiguration wantedConfig = null;
try {
wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration");
} catch (Exception ignore) {
} catch (Exception e) {
// We're just thinking "no risk no fun" and therefore have to catch and forget this exception
} finally {
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
}
this.migrateWorldConfig();
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
this.messaging.setCooldown(getMVConfig().getMessageCooldown());
this.messaging.setCooldown(config.getMessageCooldown());
// Remove old values.
this.multiverseConfig.set("enforcegamemodes", null);
@@ -505,274 +324,51 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*/
private void migrate22Values() {
if (this.multiverseConfig.isSet("worldnameprefix")) {
Logging.config("Migrating 'worldnameprefix'...");
this.getMVConfig().setPrefixChat(this.multiverseConfig.getBoolean("worldnameprefix"));
this.log(Level.INFO, "Migrating 'worldnameprefix'...");
this.config.setPrefixChat(this.multiverseConfig.getBoolean("worldnameprefix"));
this.multiverseConfig.set("worldnameprefix", null);
}
if (this.multiverseConfig.isSet("firstspawnworld")) {
Logging.config("Migrating 'firstspawnworld'...");
this.getMVConfig().setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld"));
this.log(Level.INFO, "Migrating 'firstspawnworld'...");
this.config.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld"));
this.multiverseConfig.set("firstspawnworld", null);
}
if (this.multiverseConfig.isSet("enforceaccess")) {
Logging.config("Migrating 'enforceaccess'...");
this.getMVConfig().setEnforceAccess(this.multiverseConfig.getBoolean("enforceaccess"));
this.log(Level.INFO, "Migrating 'enforceaccess'...");
this.config.setEnforceAccess(this.multiverseConfig.getBoolean("enforceaccess"));
this.multiverseConfig.set("enforceaccess", null);
}
if (this.multiverseConfig.isSet("displaypermerrors")) {
Logging.config("Migrating 'displaypermerrors'...");
this.getMVConfig().setDisplayPermErrors(this.multiverseConfig.getBoolean("displaypermerrors"));
this.log(Level.INFO, "Migrating 'displaypermerrors'...");
this.config.setDisplayPermErrors(this.multiverseConfig.getBoolean("displaypermerrors"));
this.multiverseConfig.set("displaypermerrors", null);
}
if (this.multiverseConfig.isSet("teleportintercept")) {
Logging.config("Migrating 'teleportintercept'...");
this.getMVConfig().setTeleportIntercept(this.multiverseConfig.getBoolean("teleportintercept"));
this.log(Level.INFO, "Migrating 'teleportintercept'...");
this.config.setTeleportIntercept(this.multiverseConfig.getBoolean("teleportintercept"));
this.multiverseConfig.set("teleportintercept", null);
}
if (this.multiverseConfig.isSet("firstspawnoverride")) {
Logging.config("Migrating 'firstspawnoverride'...");
this.getMVConfig().setFirstSpawnOverride(this.multiverseConfig.getBoolean("firstspawnoverride"));
this.log(Level.INFO, "Migrating 'firstspawnoverride'...");
this.config.setFirstSpawnOverride(this.multiverseConfig.getBoolean("firstspawnoverride"));
this.multiverseConfig.set("firstspawnoverride", null);
}
if (this.multiverseConfig.isSet("messagecooldown")) {
Logging.config("Migrating 'messagecooldown'...");
this.getMVConfig().setMessageCooldown(this.multiverseConfig.getInt("messagecooldown"));
this.log(Level.INFO, "Migrating 'messagecooldown'...");
this.config.setMessageCooldown(this.multiverseConfig.getInt("messagecooldown"));
this.multiverseConfig.set("messagecooldown", null);
}
if (this.multiverseConfig.isSet("debug")) {
Logging.config("Migrating 'debug'...");
this.getMVConfig().setGlobalDebug(this.multiverseConfig.getInt("debug"));
this.log(Level.INFO, "Migrating 'debug'...");
this.config.setGlobalDebug(this.multiverseConfig.getInt("debug"));
this.multiverseConfig.set("debug", null);
}
if (this.multiverseConfig.isSet("version")) {
Logging.config("Migrating 'version'...");
this.log(Level.INFO, "Migrating 'version'...");
this.multiverseConfig.set("version", null);
}
}
/**
* Migrate the worlds.yml to SerializationConfig.
*/
private void migrateWorldConfig() { // SUPPRESS CHECKSTYLE: MethodLength
FileConfiguration wconf = YamlConfiguration
.loadConfiguration(new File(getDataFolder(), "worlds.yml"));
if (!wconf.isConfigurationSection("worlds")) { // empty config
this.log(Level.FINE, "No worlds to migrate!");
return;
}
Map<String, Object> values = wconf.getConfigurationSection("worlds").getValues(false);
boolean wasChanged = false;
Map<String, Object> newValues = new LinkedHashMap<String, Object>(values.size());
for (Map.Entry<String, Object> entry : values.entrySet()) {
if (entry.getValue() instanceof MVWorld) {
// fine
newValues.put(entry.getKey(), entry.getValue());
} else if (entry.getValue() instanceof ConfigurationSection) {
this.log(Level.FINE, "Migrating: " + entry.getKey());
// we have to migrate this
MVWorld world = new MVWorld(Collections.EMPTY_MAP);
world.setPluginAndWorld(this, entry.getKey());
ConfigurationSection section = (ConfigurationSection) entry.getValue();
// migrate animals and monsters
if (section.isConfigurationSection("animals")) {
ConfigurationSection animalSection = section.getConfigurationSection("animals");
if (animalSection.contains("spawn")) {
if (animalSection.isBoolean("spawn"))
world.setAllowAnimalSpawn(animalSection.getBoolean("spawn"));
else
world.setAllowAnimalSpawn(Boolean.parseBoolean(animalSection.getString("spawn")));
}
if (animalSection.isList("exceptions")) {
world.getAnimalList().clear();
world.getAnimalList().addAll(animalSection.getStringList("exceptions"));
}
}
if (section.isConfigurationSection("monsters")) {
ConfigurationSection monsterSection = section.getConfigurationSection("monsters");
if (monsterSection.contains("spawn")) {
if (monsterSection.isBoolean("spawn"))
world.setAllowMonsterSpawn(monsterSection.getBoolean("spawn"));
else
world.setAllowMonsterSpawn(Boolean.parseBoolean(monsterSection.getString("spawn")));
}
if (monsterSection.isList("exceptions")) {
world.getMonsterList().clear();
world.getMonsterList().addAll(monsterSection.getStringList("exceptions"));
}
}
// migrate entryfee
if (section.isConfigurationSection("entryfee")) {
ConfigurationSection feeSection = section.getConfigurationSection("entryfee");
if (feeSection.isInt("currency"))
world.setCurrency(feeSection.getInt("currency"));
if (feeSection.isDouble("amount"))
world.setPrice(feeSection.getDouble("amount"));
else if (feeSection.isInt("amount"))
world.setPrice(feeSection.getInt("amount"));
}
// migrate pvp
if (section.isBoolean("pvp")) {
world.setPVPMode(section.getBoolean("pvp"));
}
// migrate alias
if (section.isConfigurationSection("alias")) {
ConfigurationSection aliasSection = section.getConfigurationSection("alias");
if (aliasSection.isString("color"))
world.setColor(aliasSection.getString("color"));
if (aliasSection.isString("name"))
world.setAlias(aliasSection.getString("name"));
}
// migrate worldblacklist
if (section.isList("worldblacklist")) {
world.getWorldBlacklist().clear();
world.getWorldBlacklist().addAll(section.getStringList("worldblacklist"));
}
// migrate scale
if (section.isDouble("scale")) {
world.setScaling(section.getDouble("scale"));
}
// migrate gamemode
if (section.isString("gamemode")) {
final GameMode gameMode = GameMode.valueOf(section.getString("gamemode").toUpperCase());
if (gameMode != null) {
world.setGameMode(gameMode);
}
}
// migrate hunger
if (section.isBoolean("hunger")) {
world.setHunger(section.getBoolean("hunger"));
}
// migrate hidden
if (section.isBoolean("hidden")) {
world.setHidden(section.getBoolean("hidden"));
}
// migrate autoheal
if (section.isBoolean("autoheal")) {
world.setAutoHeal(section.getBoolean("autoheal"));
}
// migrate portalform
if (section.isString("portalform")) {
try {
world.setPropertyValue("portalform", section.getString("portalform"));
} catch (PropertyDoesNotExistException e) {
throw new RuntimeException("Who forgot to update the migrator?", e);
}
}
// migrate environment
if (section.isString("environment")) {
try {
world.setPropertyValue("environment", section.getString("environment"));
} catch (PropertyDoesNotExistException e) {
throw new RuntimeException("Who forgot to update the migrator?", e);
}
}
// migrate generator
if (section.isString("generator")) {
world.setGenerator(section.getString("generator"));
}
// migrate seed
if (section.isLong("seed")) {
world.setSeed(section.getLong("seed"));
}
// migrate weather
if (section.isBoolean("allowweather")) {
world.setEnableWeather(section.getBoolean("allowweather"));
}
// migrate adjustspawn
if (section.isBoolean("adjustspawn")) {
world.setAdjustSpawn(section.getBoolean("adjustspawn"));
}
// migrate autoload
if (section.isBoolean("autoload")) {
world.setAutoLoad(section.getBoolean("autoload"));
}
// migrate bedrespawn
if (section.isBoolean("bedrespawn")) {
world.setBedRespawn(section.getBoolean("bedrespawn"));
}
// migrate spawn
if (section.isConfigurationSection("spawn")) {
ConfigurationSection spawnSect = section.getConfigurationSection("spawn");
Location spawnLoc = world.getSpawnLocation();
if (spawnSect.isDouble("yaw"))
spawnLoc.setYaw((float) spawnSect.getDouble("yaw"));
if (spawnSect.isDouble("pitch"))
spawnLoc.setPitch((float) spawnSect.getDouble("pitch"));
if (spawnSect.isDouble("x"))
spawnLoc.setX(spawnSect.getDouble("x"));
if (spawnSect.isDouble("y"))
spawnLoc.setY(spawnSect.getDouble("y"));
if (spawnSect.isDouble("z"))
spawnLoc.setZ(spawnSect.getDouble("z"));
world.setSpawnLocation(spawnLoc);
}
// migrate difficulty
if (section.isString("difficulty")) {
final Difficulty difficulty = Difficulty.valueOf(section.getString("difficulty").toUpperCase());
if (difficulty != null) {
world.setDifficulty(difficulty);
}
}
// migrate keepspawninmemory
if (section.isBoolean("keepspawninmemory")) {
world.setKeepSpawnInMemory(section.getBoolean("keepspawninmemory"));
}
newValues.put(entry.getKey(), world);
wasChanged = true;
} else {
// huh?
this.log(Level.WARNING, "Removing unknown entry in the config: " + entry);
// just don't add to newValues
wasChanged = true;
}
}
if (wasChanged) {
// clear config
wconf.set("worlds", null);
// and rebuild it
ConfigurationSection rootSection = wconf.createSection("worlds");
for (Map.Entry<String, Object> entry : newValues.entrySet()) {
rootSection.set(entry.getKey(), entry.getValue());
}
try {
wconf.save(new File(getDataFolder(), "worlds.yml"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* {@inheritDoc}
*/
@@ -791,7 +387,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.commandHandler.registerCommand(new ListCommand(this));
this.commandHandler.registerCommand(new InfoCommand(this));
this.commandHandler.registerCommand(new CreateCommand(this));
this.commandHandler.registerCommand(new CloneCommand(this));
this.commandHandler.registerCommand(new ImportCommand(this));
this.commandHandler.registerCommand(new ReloadCommand(this));
this.commandHandler.registerCommand(new SetSpawnCommand(this));
@@ -818,10 +413,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Misc Commands
this.commandHandler.registerCommand(new EnvironmentCommand(this));
this.commandHandler.registerCommand(new DebugCommand(this));
this.commandHandler.registerCommand(new SilentCommand(this));
this.commandHandler.registerCommand(new GeneratorCommand(this));
this.commandHandler.registerCommand(new CheckCommand(this));
this.commandHandler.registerCommand(new ScriptCommand(this));
}
/**
@@ -829,10 +422,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*/
@Override
public void onDisable() {
this.saveMVConfigs();
debugLog.close();
this.banker = null;
this.bank = null;
Logging.shutdown();
log(Level.INFO, "- Disabled");
}
/**
@@ -843,7 +436,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
if (this.playerSessions.containsKey(player.getName())) {
return this.playerSessions.get(player.getName());
} else {
this.playerSessions.put(player.getName(), new MVPlayerSession(player, getMVConfig()));
this.playerSessions.put(player.getName(), new MVPlayerSession(player, config));
return this.playerSessions.get(player.getName());
}
}
@@ -878,17 +471,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
}
ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args));
allArgs.add(0, command.getName());
try {
return this.commandHandler.locateAndRunCommand(sender, allArgs, getMVConfig().getDisplayPermErrors());
} catch (Exception e) {
e.printStackTrace();
sender.sendMessage(ChatColor.RED + "An internal error occurred when attempting to perform this command.");
if (sender.isOp())
sender.sendMessage(ChatColor.RED + "Details were printed to the server console and logs, please add that to your bug report.");
else
sender.sendMessage(ChatColor.RED + "Try again and contact the server owner or an admin if this problem persists.");
return true;
}
return this.commandHandler.locateAndRunCommand(sender, allArgs, config.getDisplayPermErrors());
}
/**
@@ -896,7 +479,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*/
@Override
public void log(Level level, String msg) {
Logging.log(level, msg);
staticLog(level, msg);
}
/**
@@ -904,28 +487,33 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*
* @param level The Log-{@link Level}.
* @param msg The message to log.
*
* @deprecated Replaced by {@link Logging}. Please refrain from using this from a third party plugin as the
* messages will appear to originate from Multiverse-Core.
*/
@Deprecated
public static void staticLog(Level level, String msg) {
Logging.log(level, msg);
if (level == Level.FINE && config.getGlobalDebug() >= 1) {
staticDebugLog(Level.INFO, msg);
return;
} else if (level == Level.FINER && config.getGlobalDebug() >= 2) {
staticDebugLog(Level.INFO, msg);
return;
} else if (level == Level.FINEST && config.getGlobalDebug() >= 3) {
staticDebugLog(Level.INFO, msg);
return;
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
LOGGER.log(level, String.format("%s %s", LOG_TAG, msg));
debugLog.log(level, String.format("%s %s", LOG_TAG, msg));
}
}
/**
* Print messages to the Debug Log, if the servers in Debug Mode then we also want 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.
*
* @param level The Log-{@link Level}
* @param msg The message
*
* @deprecated Replaced by {@link Logging}. Please refrain from using this from a third party plugin as the
* messages will appear to originate from Multiverse-Core.
*/
@Deprecated
public static void staticDebugLog(Level level, String msg) {
Logging.log(level, msg);
LOGGER.log(level, "[MVCore-Debug] " + msg);
debugLog.log(level, "[MVCore-Debug] " + msg);
}
/**
@@ -934,7 +522,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
@Override
public String getAuthors() {
String authors = "";
List<String> auths = this.getDescription().getAuthors();
ArrayList<String> auths = this.getDescription().getAuthors();
if (auths.size() == 0) {
return "";
}
@@ -1019,20 +607,16 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
/**
* {@inheritDoc}
* @deprecated Now using Vault.
*/
@Override
@Deprecated
public AllPay getBanker() {
return this.banker;
}
/**
* {@inheritDoc}
* @deprecated Now using Vault.
*/
@Override
@Deprecated
public void setBank(GenericBank bank) {
this.bank = bank;
}
@@ -1078,10 +662,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.serverFolder = newServerFolder;
}
/*
/**
* Initializes Spout.
* /
*/
public void setSpout() {
this.spoutInterface = new SpoutInterface();
this.commandHandler.registerCommand(new SpoutCommand(this));
@@ -1091,11 +674,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* Gets our {@link SpoutInterface}.
*
* @return The {@link SpoutInterface} we're using.
* /
*/
public SpoutInterface getSpout() {
return this.spoutInterface;
}
*/
/**
* {@inheritDoc}
@@ -1114,15 +696,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
return this.playerListener;
}
/**
* Gets the {@link MVChatListener}.
*
* @return The {@link MVChatListener}.
*/
public MVChatListener getChatListener() {
return this.chatListener;
}
/**
* Gets the {@link MVEntityListener}.
*
@@ -1148,7 +721,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*/
public boolean saveMVConfig() {
try {
this.multiverseConfig.set("multiverse-configuration", getMVConfig());
this.multiverseConfig.set("multiverse-configuration", config);
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
return true;
} catch (IOException e) {
@@ -1185,27 +758,38 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
return this.worldManager.deleteWorld(name);
}
/**
* NOT deprecated for the time as queued commands use this.
* However, this is not in the API and other plugins should therefore not use it.
*
* @param oldName World to copy
* @param newName World to create
* @param generator The Custom generator plugin to use.
* @return True if success, false if fail.
*/
public Boolean cloneWorld(String oldName, String newName, String generator) {
return this.worldManager.cloneWorld(oldName, newName, generator);
}
/**
* {@inheritDoc}
* @deprecated This is deprecated!
*/
@Override
@Deprecated
public Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed) {
return this.worldManager.regenWorld(name, useNewSeed, randomSeed, seed);
MultiverseWorld world = this.worldManager.getMVWorld(name);
if (world == null) {
return false;
}
List<Player> ps = world.getCBWorld().getPlayers();
if (useNewSeed) {
// Set the worldseed.
if (randomSeed) {
Random random = new Random();
Long newseed = random.nextLong();
seed = newseed.toString();
}
((WorldManager) this.worldManager).getConfigWorlds().set("worlds." + name + ".seed", seed);
}
if (this.worldManager.deleteWorld(name, false)) {
this.worldManager.loadWorlds(false);
SafeTTeleporter teleporter = this.getSafeTTeleporter();
Location newSpawn = this.getServer().getWorld(name).getSpawnLocation();
// Send all players that were in the old world, BACK to it!
for (Player p : ps) {
teleporter.safelyTeleport(null, p, newSpawn, true);
}
return true;
}
return false;
}
/**
@@ -1280,11 +864,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*/
@Deprecated
public static MultiverseCoreConfiguration getStaticConfig() {
return MultiverseCoreConfiguration.getInstance();
}
@Override
public Buscript getScriptAPI() {
return buscript;
return config;
}
}
@@ -1,87 +1,52 @@
package com.onarandombox.MultiverseCore;
import com.dumptruckman.minecraft.util.Logging;
import java.util.Map;
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
import me.main__.util.SerializationConfig.NoSuchPropertyException;
import me.main__.util.SerializationConfig.Property;
import me.main__.util.SerializationConfig.SerializationConfig;
import java.util.Map;
/**
* Our configuration.
*/
public class MultiverseCoreConfiguration extends SerializationConfig implements MultiverseCoreConfig {
private static MultiverseCoreConfiguration instance;
/**
* Sets the statically saved instance.
* @param instance The new instance.
*/
public static void setInstance(MultiverseCoreConfiguration instance) {
MultiverseCoreConfiguration.instance = instance;
}
/**
* @return True if the static instance of config is set.
*/
public static boolean isSet() {
return instance != null;
}
/**
* Gets the statically saved instance.
* @return The statically saved instance.
*/
public static MultiverseCoreConfiguration getInstance() {
if (instance == null)
throw new IllegalStateException("The instance wasn't set!");
return instance;
}
@Property
private volatile boolean enforceaccess;
private boolean enforceaccess;
@Property
private volatile boolean prefixchat;
private boolean prefixchat;
@Property
private volatile boolean useasyncchat;
private boolean teleportintercept;
@Property
private volatile boolean teleportintercept;
private boolean firstspawnoverride;
@Property
private volatile boolean firstspawnoverride;
private boolean displaypermerrors;
@Property
private volatile boolean displaypermerrors;
private int globaldebug;
@Property
private volatile int globaldebug;
private int messagecooldown;
@Property
private volatile boolean silentstart;
private double version;
@Property
private volatile int messagecooldown;
private String firstspawnworld;
@Property
private volatile double version;
@Property
private volatile String firstspawnworld;
@Property
private volatile int teleportcooldown;
private int teleportcooldown;
public MultiverseCoreConfiguration() {
super();
MultiverseCoreConfiguration.setInstance(this);
}
public MultiverseCoreConfiguration(Map<String, Object> values) {
super(values);
MultiverseCoreConfiguration.setInstance(this);
}
/**
* {@inheritDoc}
*/
@Override
protected void setDefaults() {
public void setDefaults() {
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
enforceaccess = false;
useasyncchat = true;
prefixchat = true;
teleportintercept = true;
firstspawnoverride = true;
@@ -90,22 +55,9 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
messagecooldown = 5000;
teleportcooldown = 1000;
this.version = 2.9;
silentstart = false;
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
}
/**
* {@inheritDoc}
*/
@Override
public boolean setConfigProperty(String property, String value) {
try {
return this.setProperty(property, value, true);
} catch (NoSuchPropertyException e) {
return false;
}
}
// And here we go:
/**
@@ -202,7 +154,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
@Override
public void setGlobalDebug(int globalDebug) {
this.globaldebug = globalDebug;
Logging.setDebugLevel(globalDebug);
}
/**
@@ -268,25 +219,4 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
public void setTeleportCooldown(int teleportCooldown) {
this.teleportcooldown = teleportCooldown;
}
@Override
public void setUseAsyncChat(boolean useAsyncChat) {
this.useasyncchat = useAsyncChat;
}
@Override
public boolean getUseAsyncChat() {
return this.useasyncchat;
}
@Override
public void setSilentStart(boolean silentStart) {
Logging.setShowingConfig(!silentStart);
this.silentstart = silentStart;
}
@Override
public boolean getSilentStart() {
return silentstart;
}
}
@@ -35,13 +35,6 @@ public interface BlockSafety {
*/
boolean playerCanSpawnHereSafely(Location l);
/**
* Gets a safe bed spawn location OR null if the bed is invalid.
* @param l The location of the bead head (block with the pillow on it).
* @return Safe location around the bed or null if no location was found.
*/
Location getSafeBedSpawn(Location l);
/**
* Gets the location of the top block at the specified {@link Location}.
* @param l Any {@link Location}.
@@ -7,17 +7,10 @@
package com.onarandombox.MultiverseCore.api;
import buscript.Buscript;
import com.fernferret.allpay.AllPay;
import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
import com.onarandombox.MultiverseCore.utils.VaultHandler;
import com.onarandombox.MultiverseCore.utils.*;
import com.pneumaticraft.commandhandler.CommandHandler;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
@@ -42,19 +35,9 @@ public interface Core {
* Gets the Banking system that Multiverse-Core has hooked into.
*
* @return A {@link GenericBank} that can be used for payments.
* @deprecated Now using vault, see {@link VaultHandler#getEconomy}
*/
@Deprecated
GenericBank getBank();
/**
* Returns the Vault handler used by Multiverse. The returned object will have all methods necessary for
* interfacing with Vault.
*
* @return the Vault handler for Multiverse.
*/
VaultHandler getVaultHandler();
/**
* Reloads the Multiverse Configuration files:
* worlds.yml and config.yml.
@@ -145,28 +128,21 @@ public interface Core {
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*
* @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String)} instead.
*/
@Deprecated
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed);
/**
* Sets the {@link GenericBank}-Bank AllPay is using.
*
* @param bank The new {@link GenericBank}
* @deprecated Now using vault, see {@link VaultHandler#getEconomy}
*/
@Deprecated
void setBank(GenericBank bank);
/**
* Gets this plugin's {@link AllPay}-Banker.
*
* @return An {@link AllPay}-Banker
* @deprecated Now using vault, see {@link VaultHandler#getEconomy}
*/
@Deprecated
AllPay getBanker();
/**
@@ -246,11 +222,4 @@ public interface Core {
* @return The configuration.
*/
MultiverseCoreConfig getMVConfig();
/**
* Gets the buscript object for Multiverse. This is what handles Javascript processing.
*
* @return The Multiverse buscript object.
*/
Buscript getScriptAPI();
}
@@ -60,16 +60,6 @@ public interface MVWorldManager {
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
String generator, boolean useSpawnAdjust);
/**
* Make a copy of a world.
*
* @param oldName Name of world to be copied
* @param newName Name of world to be created
* @param generator The Custom generator plugin to use.
* @return True if the world is copied successfully, false if not.
*/
boolean cloneWorld(String oldName, String newName, String generator);
/**
* Remove the world from the Multiverse list, from the
* config and deletes the folder.
@@ -90,17 +80,6 @@ public interface MVWorldManager {
*/
boolean deleteWorld(String name, boolean removeConfig);
/**
*
* @param name The name of the world to remove
* @param removeFromConfig If true(default), we'll remove the entries from the
* config. If false, they'll stay and the world may come back.
* @param deleteWorldFolder If true the world folder will be completely deleted. If false
* only the contents of the world folder will be deleted
* @return True if success, false if failure.
*/
boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder);
/**
* Unload a world from Multiverse.
*
@@ -266,16 +245,4 @@ public interface MVWorldManager {
* @return The {@link MultiverseWorld} new players should spawn in.
*/
MultiverseWorld getFirstSpawnWorld();
/**
* Regenerates a world.
*
* @param name Name of the world to regenerate
* @param useNewSeed If a new seed should be used
* @param randomSeed IF the new seed should be random
* @param seed The seed of the world.
*
* @return True if success, false if fail.
*/
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
}
@@ -12,7 +12,7 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
* @param value The value.
* @return True on success, false if the operation failed.
*/
boolean setConfigProperty(String property, String value);
boolean setProperty(String property, String value);
/**
* Sets portalCooldown.
@@ -133,30 +133,4 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
* @return enforceAccess.
*/
boolean getEnforceAccess();
/**
* Sets useasyncchat.
* @param useAsyncChat The new value.
*/
void setUseAsyncChat(boolean useAsyncChat);
/**
* Gets useasyncchat.
* @return useasyncchat.
*/
boolean getUseAsyncChat();
/**
* Sets whether to suppress startup messages.
*
* @param silentStart true to suppress messages.
*/
void setSilentStart(boolean silentStart);
/**
* Whether we are suppressing startup messages.
*
* @return true if we are suppressing startup messages.
*/
boolean getSilentStart();
}
@@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.api;
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
@@ -25,6 +26,7 @@ import java.util.List;
* The API for a Multiverse Handled World.
*/
public interface MultiverseWorld {
/**
* Returns the Bukkit world object that this world describes.
*
@@ -33,24 +35,79 @@ public interface MultiverseWorld {
World getCBWorld();
/**
* Gets the name of this world. The name cannot be changed.
* <p>
* Note for plugin developers: Usually {@link #getAlias()}
* is what you want to use instead of this method.
* Adds the property to the given value.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @return The name of the world as a String.
* @param property The name of a world property to set.
* @param value A value in string representation, it will be parsed to the correct type.
* @param sender The sender who wants this value to be set.
* @return True if the value was set, false if not.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
String getName();
boolean setProperty(String property, String value, CommandSender sender) throws PropertyDoesNotExistException;
/**
* Gets the type of this world. As of 1.2 this will be:
* FLAT, NORMAL or VERSION_1_1
* <p>
* This is <b>not</b> the generator.
* Gets the actual MVConfigProperty from this world.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @return The Type of this world.
* @param property The name of a world property to get.
* @return A valid MVWorldProperty.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
* @deprecated Use {@link #getProperty(String, Class)} instead
*/
WorldType getWorldType();
@Deprecated
MVConfigProperty<?> getProperty(String property) throws PropertyDoesNotExistException;
/**
* Gets the string representation of a property.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @param property The name of a world property to get.
* @return A valid MVWorldProperty.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
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.
* @param <T> The type of the expected property.
*
* @return A valid MVWorldProperty.
*
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
<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}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
* @return True if it was cleared, false if not.
*/
boolean clearVariable(String property);
/**
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was added, false if not.
*/
boolean addToVariable(String property, String value);
/**
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
* from.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was removed, false if not.
*/
boolean removeFromVariable(String property, String value);
/**
* Gets the environment of this world.
@@ -68,168 +125,27 @@ public interface MultiverseWorld {
*/
void setEnvironment(World.Environment environment);
/**
* Gets the difficulty of this world.
*
* @return The difficulty of this world.
*/
Difficulty getDifficulty();
/**
* Sets the difficulty of this world and returns true if success.
* Valid string values are either an integer of difficulty(0-3) or
* the name that resides in the Bukkit enum, ex. {@code PEACEFUL}
*
* @param difficulty The difficulty to set the world to as a string.
* @return True if success, false if the provided string
* could not be translated to a difficulty.
* @deprecated Use {@link #setDifficulty(Difficulty)} or, if you have to
* pass a string, use {@link #setPropertyValue(String, String)} instead.
*/
@Deprecated
boolean setDifficulty(String difficulty);
/**
* Sets the difficulty of this world and returns {@code true} on success.
* Valid string values are either an integer of difficulty(0-3) or
* the name that resides in the Bukkit enum, ex. PEACEFUL
*
* @param difficulty The new difficulty.
* @return True if success, false if the operation failed... for whatever reason.
*/
boolean setDifficulty(Difficulty difficulty);
/**
* Gets the world seed of this world.
*
* @return The Long version of the seed.
*/
long getSeed();
Long getSeed();
/**
* Sets the seed of this world.
*
* @param seed A Long that is the seed.
*/
void setSeed(long seed);
void setSeed(Long seed);
/**
* Gets the generator of this world.
* Gets the name of this world. This cannot be changed.
*
* @return The name of the generator.
* @return The name of the world as a String.
*/
String getGenerator();
String getName();
/**
* Sets the generator of this world.
*
* @param generator The new generator's name.
*/
void setGenerator(String generator);
/**
* Gets the help-message for a property.
* @param property The name of the property.
* @return The help-message.
* @throws PropertyDoesNotExistException Thrown if the property was not found.
*/
String getPropertyHelp(String property) throws PropertyDoesNotExistException;
/**
* Gets a property as {@link String}.
*
* @param property The name of a world property to get.
* @return The string-representation of that property.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
String getPropertyValue(String property) throws PropertyDoesNotExistException;
/**
* Sets a property to a given value.
*
* @param property The name of a world property to set.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was set, false if not.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
*/
boolean setPropertyValue(String property, String value) throws PropertyDoesNotExistException;
/**
* Gets the actual MVConfigProperty from this world.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @param property The name of a world property to get.
* @param expected The type of the expected property. Use Object.class if this doesn't matter for you.
* @param <T> The type of the expected property.
*
* @return A valid MVWorldProperty.
*
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
* @deprecated We don't use {@link com.onarandombox.MultiverseCore.configuration.MVConfigProperty} any longer!
*/
@Deprecated
<T> com.onarandombox.MultiverseCore.configuration.MVConfigProperty<T> getProperty(String property, Class<T> expected) throws PropertyDoesNotExistException;
// old config
/**
* Adds the property to the given value.
* It will throw a PropertyDoesNotExistException if the property is not found.
*
* @param property The name of a world property to set.
* @param value A value in string representation, it will be parsed to the correct type.
* @param sender The sender who wants this value to be set.
* @return True if the value was set, false if not.
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
* @deprecated Use {@link #setPropertyValue(String, String)} instead.
*/
@Deprecated
boolean setProperty(String property, String value, CommandSender sender) throws PropertyDoesNotExistException;
/**
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was added, false if not.
* @deprecated We changed the entire world-config-system. This is not compatible any more.
*/
@Deprecated
boolean addToVariable(String property, String value);
/**
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
* from.
* @param value A value in string representation, it will be parsed to the correct type.
* @return True if the value was removed, false if not.
* @deprecated We changed the entire world-config-system. This is not compatible any more.
*/
@Deprecated
boolean removeFromVariable(String property, String value);
/**
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
*
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
* @return True if it was cleared, false if not.
* @deprecated We changed the entire world-config-system. This is not compatible any more.
*/
@Deprecated
boolean clearVariable(String property);
/**
* Clears a list property (sets it to []).
*
* @param property The property to clear.
* @return True if success, false if fail.
* @deprecated We changed the entire world-config-system. This is not compatible any more.
*/
@Deprecated
boolean clearList(String property);
// end of old config stuff
// permission stuff
/**
* Gets the lowercased name of the world. This method is required, since the permissables
* lowercase all permissions when recalculating.
@@ -242,21 +158,6 @@ public interface MultiverseWorld {
*/
String getPermissibleName();
/**
* Gets the permission required to enter this world.
*
* @return The permission required to be exempt from charges to/from this world.
*/
Permission getAccessPermission();
/**
* Gets the permission required to be exempt when entering.
*
* @return The permission required to be exempt when entering.
*/
Permission getExemptPermission();
// end of permission stuff
/**
* Gets the alias of this world.
* <p>
@@ -273,13 +174,6 @@ public interface MultiverseWorld {
*/
void setAlias(String alias);
/**
* Gets the color that this world's name/alias will display as.
*
* @return The color of this world.
*/
ChatColor getColor();
/**
* Sets the color that this world's name/alias will display as.
*
@@ -289,29 +183,18 @@ public interface MultiverseWorld {
boolean setColor(String color);
/**
* Gets the style that this world's name/alias will display as.
* Gets the color that this world's name/alias will display as.
*
* @return The style of this world. {@code null} for "normal" style.
* @return The color of this world.
*/
ChatColor getStyle();
/**
* Sets the style that this world's name/alias will display as.
*
* @param style A valid style name.
* @return True if the style was set, false if not.
*/
boolean setStyle(String style);
ChatColor getColor();
/**
* Tells you if someone entered a valid color.
*
* @param color A string that may translate to a color.
* @return True if it is a color, false if not.
*
* @deprecated This has been moved: {@link com.onarandombox.MultiverseCore.enums.EnglishChatColor#isValidAliasColor(String)}
*/
@Deprecated
boolean isValidAliasColor(String color);
/**
@@ -321,7 +204,6 @@ public interface MultiverseWorld {
*/
String getColoredWorldString();
// animals&monster stuff
/**
* Gets whether or not animals are allowed to spawn in this world.
*
@@ -329,22 +211,6 @@ public interface MultiverseWorld {
*/
boolean canAnimalsSpawn();
/**
* Sets whether or not animals can spawn.
* If there are values in {@link #getAnimalList()} and this is false,
* those animals become the exceptions, and will spawn
*
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowAnimalSpawn(boolean allowAnimalSpawn);
/**
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
*
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
*/
List<String> getAnimalList();
/**
* Gets whether or not monsters are allowed to spawn in this world.
*
@@ -353,31 +219,7 @@ public interface MultiverseWorld {
boolean canMonstersSpawn();
/**
* Sets whether or not monsters can spawn.
* If there are values in {@link #getMonsterList()} and this is false,
* those monsters become the exceptions, and will spawn
*
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
/**
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} result.
*
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
*/
List<String> getMonsterList();
// end of animal&monster stuff
/**
* Gets whether or not PVP is enabled in this world in some form (fake or not).
*
* @return True if players can take damage from other players.
*/
boolean isPVPEnabled();
/**
* Turn pvp on or off. This setting is used to set the world's PVP mode.
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
*
* @param pvpMode True to enable PVP damage, false to disable it.
*/
@@ -392,6 +234,13 @@ public interface MultiverseWorld {
@Deprecated
boolean getFakePVP();
/**
* Gets whether or not PVP is enabled in this world in some form (fake or not).
*
* @return True if players can take damage from other players.
*/
boolean isPVPEnabled();
/**
* Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
* access permissions to go to this world.
@@ -408,13 +257,6 @@ public interface MultiverseWorld {
*/
void setHidden(boolean hidden);
/**
* Gets whether weather is enabled in this world.
*
* @return True if weather events will occur, false if not.
*/
boolean isWeatherEnabled();
/**
* Sets whether or not there will be weather events in a given world.
* If set to false, Multiverse will disable the weather in the world immediately.
@@ -424,11 +266,11 @@ public interface MultiverseWorld {
void setEnableWeather(boolean enableWeather);
/**
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
* Gets whether weather is enabled in this world.
*
* @return True if CraftBukkit is keeping spawn chunks in memory.
* @return True if weather events will occur, false if not.
*/
boolean isKeepingSpawnInMemory();
boolean isWeatherEnabled();
/**
* If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
@@ -440,11 +282,29 @@ public interface MultiverseWorld {
void setKeepSpawnInMemory(boolean keepSpawnInMemory);
/**
* Gets the spawn location of this world.
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
*
* @return The spawn location of this world.
* @return True if CraftBukkit is keeping spawn chunks in memory.
*/
Location getSpawnLocation();
boolean isKeepingSpawnInMemory();
/**
* Sets the difficulty of this world and returns true if success.
* Valid string values are either an integer of difficulty(0-3) or
* the name that resides in the Bukkit enum, ex. PEACEFUL
*
* @param difficulty The difficulty to set the world to as a string.
* @return True if success, false if the provided string
* could not be translated to a difficulty.
*/
boolean setDifficulty(String difficulty);
/**
* Gets the difficulty of this world.
*
* @return The difficulty of this world.
*/
Difficulty getDifficulty();
/**
* Sets the spawn location for a world.
@@ -454,11 +314,11 @@ public interface MultiverseWorld {
void setSpawnLocation(Location spawnLocation);
/**
* Gets whether or not the hunger level of players will go down in a world.
* Gets the spawn location of this world.
*
* @return True if it will go down, false if it will remain steady.
* @return The spawn location of this world.
*/
boolean getHunger();
Location getSpawnLocation();
/**
* Sets whether or not the hunger level of players will go down in a world.
@@ -469,11 +329,11 @@ public interface MultiverseWorld {
void setHunger(boolean hungerEnabled);
/**
* Gets the GameMode of this world.
* Gets whether or not the hunger level of players will go down in a world.
*
* @return The GameMode of this world.
* @return True if it will go down, false if it will remain steady.
*/
GameMode getGameMode();
boolean getHunger();
/**
* Sets the game mode of this world.
@@ -481,26 +341,29 @@ public interface MultiverseWorld {
* @param gameMode A valid game mode string (either
* an int ex. 0 or a string ex. creative).
* @return True if the game mode was successfully changed, false if not.
* @deprecated Use {@link #setGameMode(GameMode)} instead. If you have to
* pass a string, use {@link #setPropertyValue(String, String)}.
*/
@Deprecated
boolean setGameMode(String gameMode);
/**
* Sets the game mode of this world.
* Gets the GameMode of this world.
*
* @param gameMode The new {@link GameMode}.
* @return True if the game mode was successfully changed, false if not.
* @return The GameMode of this world.
*/
boolean setGameMode(GameMode gameMode);
GameMode getGameMode();
/**
* Gets the amount of currency it requires to enter this world.
* Gets the permission required to enter this world.
*
* @return The amount it costs to enter this world.
* @return The permission required to be exempt from charges to/from this world.
*/
double getPrice();
Permission getAccessPermission();
/**
* Gets the permission required to be exempt when entering.
*
* @return The permission required to be exempt when entering.
*/
Permission getExemptPermission();
/**
* Sets the price for entry to this world.
@@ -512,11 +375,11 @@ public interface MultiverseWorld {
void setPrice(double price);
/**
* Gets the Type of currency that will be used when users enter this world.
* Gets the amount of currency it requires to enter this world.
*
* @return The Type of currency that will be used when users enter this world.
* @return The amount it costs to enter this world.
*/
int getCurrency();
double getPrice();
/**
* Sets the type of item that will be required given the price is not 0.
@@ -527,11 +390,11 @@ public interface MultiverseWorld {
void setCurrency(int item);
/**
* Gets the world players will respawn in if they die in this one.
* Gets the Type of currency that will be used when users enter this world.
*
* @return A world that exists on the server.
* @return The Type of currency that will be used when users enter this world.
*/
World getRespawnToWorld();
int getCurrency();
/**
* Sets the world players will respawn in if they die in this one.
@@ -543,12 +406,11 @@ public interface MultiverseWorld {
boolean setRespawnToWorld(String respawnWorld);
/**
* Gets the scaling value of this world.Really only has an effect if you use
* Multiverse-NetherPortals.
* Gets the world players will respawn in if they die in this one.
*
* @return This world's non-negative, non-zero scale.
* @return A world that exists on the server.
*/
double getScaling();
World getRespawnToWorld();
/**
* Sets the scale of this world. Really only has an effect if you use
@@ -560,11 +422,60 @@ public interface MultiverseWorld {
boolean setScaling(double scaling);
/**
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
* Gets the scaling value of this world.Really only has an effect if you use
* Multiverse-NetherPortals.
*
* @return True if the world should heal (default), false if not.
* @return This world's non-negative, non-zero scale.
*/
boolean getAutoHeal();
double getScaling();
/**
* Gets a list of all the worlds that players CANNOT travel to from this world,
* regardless of their access permissions.
*
* @return A List of world names.
*/
List<String> getWorldBlacklist();
/**
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
*
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
*/
List<String> getAnimalList();
/**
* Sets whether or not animals can spawn.
* If there are values in {@link #getAnimalList()} and this is false,
* those animals become the exceptions, and will spawn
*
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowAnimalSpawn(boolean allowAnimalSpawn);
/**
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} ()} result.
*
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
*/
List<String> getMonsterList();
/**
* Sets whether or not monsters can spawn.
* If there are values in {@link #getMonsterList()} and this is false,
* those monsters become the exceptions, and will spawn
*
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
*/
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
/**
* Clears a list property (sets it to []).
*
* @param property The property to clear.
* @return True if success, false if fail.
*/
boolean clearList(String property);
/**
* Sets whether or not a world will auto-heal players if the difficulty is on peaceful.
@@ -574,11 +485,11 @@ public interface MultiverseWorld {
void setAutoHeal(boolean heal);
/**
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
*
* @return True if Multiverse should adjust the spawn, false if not.
* @return True if the world should heal (default), false if not.
*/
boolean getAdjustSpawn();
boolean getAutoHeal();
/**
* Sets whether or not Multiverse should auto-adjust the spawn for this world.
@@ -588,11 +499,11 @@ public interface MultiverseWorld {
void setAdjustSpawn(boolean adjust);
/**
* Gets whether or not Multiverse should auto-load this world.
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
*
* @return True if Multiverse should auto-load this world.
* @return True if Multiverse should adjust the spawn, false if not.
*/
boolean getAutoLoad();
boolean getAdjustSpawn();
/**
* Sets whether or not Multiverse should auto-load this world.
@@ -604,12 +515,11 @@ public interface MultiverseWorld {
void setAutoLoad(boolean autoLoad);
/**
* Gets whether or not a player who dies in this world will respawn in their
* bed or follow the normal respawn pattern.
* Gets whether or not Multiverse should auto-load this world.
*
* @return True if players dying in this world should respawn at their bed.
* @return True if Multiverse should auto-load this world.
*/
boolean getBedRespawn();
boolean getAutoLoad();
/**
* Sets whether or not a player who dies in this world will respawn in their
@@ -622,26 +532,19 @@ public interface MultiverseWorld {
void setBedRespawn(boolean autoLoad);
/**
* Sets the player limit for this world after which players without an override
* permission node will not be allowed in. A value of -1 or less signifies no limit
* Gets whether or not a player who dies in this world will respawn in their
* bed or follow the normal respawn pattern.
*
* @param limit The new limit
* @return True if players dying in this world should respawn at their bed.
*/
void setPlayerLimit(int limit);
boolean getBedRespawn();
/**
* Gets the player limit for this world after which players without an override
* permission node will not be allowed in. A value of -1 or less signifies no limit
* Gets all the names of all properties that can be SET.
*
* @return The player limit
* @return All property names, with alternating colors.
*/
int getPlayerLimit();
/**
* Same as {@link #getTime()}, but returns a string.
* @return The time as a short string: 12:34pm
*/
String getTime();
String getAllPropertyNames();
/**
* Sets the current time in a world.
@@ -656,6 +559,22 @@ public interface MultiverseWorld {
*/
boolean setTime(String timeAsString);
/**
* Same as {@link #getTime()}, but returns a string.
* @return The time as a short string: 12:34pm
*/
String getTime();
/**
* Gets the type of this world. As of 1.1-R1 this will be:
* FLAT or NORMAL
* <p>
* This is *not* the generator.
*
* @return The Type of this world.
*/
WorldType getWorldType();
/**
* Sets The types of portals that are allowed in this world.
*
@@ -669,20 +588,4 @@ public interface MultiverseWorld {
* @return The type of portals that are allowed.
*/
AllowedPortalType getAllowedPortals();
// properties that are not "getter+setter" style
/**
* Gets a list of all the worlds that players CANNOT travel to from this world,
* regardless of their access permissions.
*
* @return A List of world names.
*/
List<String> getWorldBlacklist();
/**
* Gets all the names of all properties that can be SET.
*
* @return All property names, with alternating colors.
*/
String getAllPropertyNames();
}
@@ -3,14 +3,14 @@ package com.onarandombox.MultiverseCore.api;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
/**
* Used to remove animals from worlds that don't belong there.
*/
public interface WorldPurger {
/**
* Synchronizes the given worlds with their settings.
* Synchronizes the given world with it's settings.
*
* @param worlds A list of {@link MultiverseWorld}
*/
@@ -46,23 +46,4 @@ public interface WorldPurger {
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
boolean negateMonsters, CommandSender sender);
/**
* Determines whether the specified creature should be killed.
*
* @param e The creature.
* @param thingsToKill A {@link List} of animals/monsters to be killed.
* @param negateAnimals Whether the monsters in the list should be negated.
* @param negateMonsters Whether the animals in the list should be negated.
* @return {@code true} if the creature should be killed, otherwise {@code false}.
*/
boolean shouldWeKillThisCreature(Entity e, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters);
/**
* Determines whether the specified creature should be killed and automatically reads the params from a world object.
*
* @param w The world.
* @param e The creature.
* @return {@code true} if the creature should be killed, otherwise {@code false}.
*/
boolean shouldWeKillThisCreature(MultiverseWorld w, Entity e);
}
@@ -11,7 +11,6 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
@@ -35,11 +34,7 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "otherthing");
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething " + ChatColor.RED + "-d");
this.addCommandExample("/mv anchors ");
this.setPermission("multiverse.core.anchor.list", "Allows a player to list all anchors.", PermissionDefault.OP);
this.addAdditonalPermission(new Permission("multiverse.core.anchor.create",
"Allows a player to create anchors.", PermissionDefault.OP));
this.addAdditonalPermission(new Permission("multiverse.core.anchor.delete",
"Allows a player to delete anchors.", PermissionDefault.OP));
this.setPermission("multiverse.core.anchor", "Allows management of Anchor Destinations.", PermissionDefault.OP);
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
}
@@ -54,11 +49,6 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
}
private void showList(CommandSender sender, List<String> args) {
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.list", true)) {
sender.sendMessage(ChatColor.RED + "You don't have the permission to list anchors!");
return;
}
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse Anchor List ]====");
Player p = null;
if (sender instanceof Player) {
@@ -115,14 +105,10 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
return;
}
if (args.size() == 2 && args.get(1).equalsIgnoreCase("-d")) {
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.delete", true)) {
sender.sendMessage(ChatColor.RED + "You don't have the permission to delete anchors!");
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
} else {
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
} else {
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
}
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
}
return;
}
@@ -132,16 +118,13 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
return;
}
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.create", true)) {
sender.sendMessage(ChatColor.RED + "You don't have the permission to create anchors!");
Player player = (Player) sender;
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
} else {
Player player = (Player) sender;
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
} else {
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
}
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
}
}
@Override
@@ -51,7 +51,7 @@ public class ConfigCommand extends MultiverseCommand {
sender.sendMessage(message);
return;
}
if (!this.plugin.getMVConfig().setConfigProperty(args.get(0).toLowerCase(), args.get(1))) {
if (!this.plugin.getMVConfig().setProperty(args.get(0).toLowerCase(), args.get(1))) {
sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, args.get(0).toLowerCase(), args.get(1)));
return;
}
@@ -18,8 +18,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -67,13 +65,7 @@ public class CreateCommand extends MultiverseCommand {
}
}
if (this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "Multiverse cannot create " + ChatColor.GOLD + ChatColor.UNDERLINE
+ "another" + ChatColor.RESET + ChatColor.RED + " world named " + worldName);
return;
}
if (worldFile.exists()) {
if (worldFile.exists() || this.worldManager.isMVWorld(worldName)) {
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
return;
@@ -96,19 +88,7 @@ public class CreateCommand extends MultiverseCommand {
EnvironmentCommand.showWorldTypes(sender);
return;
}
// Determine if the generator is valid. #918
if (generator != null) {
List<String> genarray = new ArrayList<String>(Arrays.asList(generator.split(":")));
if (genarray.size() < 2) {
// If there was only one arg specified, pad with another empty one.
genarray.add("");
}
if (this.worldManager.getChunkGenerator(genarray.get(0), genarray.get(1), "test") == null) {
// We have an invalid generator.
sender.sendMessage("Invalid generator! '" + generator + "'. " + ChatColor.RED + "Aborting world creation.");
return;
}
}
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
if (this.worldManager.addWorld(worldName, environment, seed, type, allowStructures, generator, useSpawnAdjust)) {
@@ -23,7 +23,7 @@ public class DebugCommand extends MultiverseCommand {
public DebugCommand(MultiverseCore plugin) {
super(plugin);
this.setName("Turn Debug on/off?");
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off|silent]");
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off]");
this.setArgRange(0, 1);
this.addKey("mv debug");
this.addKey("mv d");
@@ -48,18 +48,17 @@ public class DebugCommand extends MultiverseCommand {
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
}
}
plugin.saveMVConfigs();
}
this.displayDebugMode(sender);
}
private void displayDebugMode(CommandSender sender) {
final int debugLevel = plugin.getMVConfig().getGlobalDebug();
if (debugLevel == 0) {
if (plugin.getMVConfig().getGlobalDebug() == 0) {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
} else {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel);
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + plugin.getMVConfig().getGlobalDebug());
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
}
}
@@ -53,8 +53,8 @@ public class EnvironmentCommand extends MultiverseCommand {
*/
public static void showWorldTypes(CommandSender sender) {
sender.sendMessage(ChatColor.YELLOW + "Valid World Types are:");
sender.sendMessage(String.format("%sNORMAL%s, %sFLAT, %sLARGEBIOMES %sor %sVERSION_1_1",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, ChatColor.RED, ChatColor.WHITE, ChatColor.GOLD));
sender.sendMessage(String.format("%sNORMAL %sor %sFLAT",
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA));
}
@Override
@@ -75,9 +75,6 @@ public class EnvironmentCommand extends MultiverseCommand {
type = "NORMAL";
if (type.equalsIgnoreCase("flat"))
type = "FLAT";
if (type.equalsIgnoreCase("largebiomes")) {
type = "LARGE_BIOMES";
}
try {
// Now that we've converted a potentially unfriendly value
// to a friendly one, get it from the ENUM!
@@ -7,7 +7,6 @@
package com.onarandombox.MultiverseCore.commands;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@@ -16,6 +15,7 @@ import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
/**
* Returns a list of loaded generator plugins.
@@ -37,7 +37,7 @@ public class GeneratorCommand extends MultiverseCommand {
@Override
public void runCommand(CommandSender sender, List<String> args) {
Logging.info("PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
this.plugin.log(Level.INFO, "PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
Plugin[] plugins = this.plugin.getServer().getPluginManager().getPlugins();
List<String> generators = new ArrayList<String>();
for (Plugin p : plugins) {
@@ -52,7 +52,7 @@ public class ImportCommand extends MultiverseCommand {
* @param worldFolder The File that may be a world.
* @return True if it looks like a world, false if not.
*/
private static boolean checkIfIsWorld(File worldFolder) {
private boolean checkIfIsWorld(File worldFolder) {
if (worldFolder.isDirectory()) {
File[] files = worldFolder.listFiles(new FilenameFilter() {
@Override
@@ -124,13 +124,8 @@ public class InfoCommand extends MultiverseCommand {
message.add(new FancyMessage("Spawn Location: ", plugin.getLocationManipulation().strCoords(spawn), colors));
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
if (world.getPrice() > 0) {
final String formattedAmount;
if (world.getCurrency() <= 0 && plugin.getVaultHandler().getEconomy() != null) {
formattedAmount = plugin.getVaultHandler().getEconomy().format(world.getPrice());
} else {
formattedAmount = this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency());
}
message.add(new FancyMessage("Price to enter this world: ", formattedAmount, colors));
message.add(new FancyMessage("Price to enter this world: ",
this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency()), colors));
} else {
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
}
@@ -195,7 +190,7 @@ public class InfoCommand extends MultiverseCommand {
return worldInfo;
}
private static String toCommaSeperated(List<String> list) {
private String toCommaSeperated(List<String> list) {
if (list == null || list.size() == 0) {
return "";
}
@@ -221,7 +216,7 @@ public class InfoCommand extends MultiverseCommand {
return positive ? ChatColor.GREEN : ChatColor.RED;
}
private static void showPage(int page, CommandSender sender, List<List<FancyText>> doc) {
private void showPage(int page, CommandSender sender, List<List<FancyText>> doc) {
page = page < 0 ? 0 : page;
page = page > doc.size() - 1 ? doc.size() - 1 : page;
boolean altColor = false;
Loaded 100 of 209 files, more files were not shown because too many files have changed in this diff. Show more