Compare commits
55
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1708d1dedd | ||
|
|
32c92fc39d | ||
|
|
68a84a5041 | ||
|
|
64835ea400 | ||
|
|
4e9abcb62d | ||
|
|
f5943d87a1 | ||
|
|
50dd916b0c | ||
|
|
8cdb221695 | ||
|
|
841cd14098 | ||
|
|
818222c39a | ||
|
|
8c3f662579 | ||
|
|
c3acaa4298 | ||
|
|
eb4eee83ad | ||
|
|
c29f937fd8 | ||
|
|
9b67bf355d | ||
|
|
19df3066a6 | ||
|
|
8227626613 | ||
|
|
228e0562a4 | ||
|
|
020dee2ab0 | ||
|
|
40fff5c241 | ||
|
|
f8fd549da9 | ||
|
|
b55cf778bc | ||
|
|
b643b3a3eb | ||
|
|
7c827c1c8a | ||
|
|
6c313d1486 | ||
|
|
483bd83175 | ||
|
|
c425b4d50b | ||
|
|
f0bac0a84d | ||
|
|
a235b09e8d | ||
|
|
ac8965f1f0 | ||
|
|
2a56398d10 | ||
|
|
27639fc13d | ||
|
|
b0bb8729f1 | ||
|
|
d42001dd33 | ||
|
|
c21e640dbd | ||
|
|
b1c915f903 | ||
|
|
1899b45611 | ||
|
|
2aee358ec1 | ||
|
|
ea38d3dc4e | ||
|
|
a230a340c7 | ||
|
|
48ccb2585d | ||
|
|
0ac858c361 | ||
|
|
0395ead29d | ||
|
|
227fb9ba81 | ||
|
|
8c0a750d3e | ||
|
|
ea0d1c6702 | ||
|
|
5ed096fb8f | ||
|
|
693f1f2bf1 | ||
|
|
8aa5428a14 | ||
|
|
16eebc462b | ||
|
|
9adef4b2ab | ||
|
|
16b854e8a6 | ||
|
|
a09fa7781f | ||
|
|
ec22c930d0 | ||
|
|
1d369378b4 |
No files matched your search
@@ -12,7 +12,6 @@
|
||||
|
||||
# maven
|
||||
/target
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
notifications:
|
||||
email: false
|
||||
before_install:
|
||||
- sed -i.bak -e 's|https://nexus.codehaus.org/snapshots/|https://oss.sonatype.org/content/repositories/codehaus-snapshots/|g' ~/.m2/settings.xml
|
||||
@@ -13,4 +13,3 @@ Copyright (c) 2011, The Multiverse Team All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the The Multiverse Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# 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
|
||||
@@ -0,0 +1,140 @@
|
||||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ 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
@@ -0,0 +1,186 @@
|
||||
<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>
|
||||
@@ -0,0 +1,329 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/******************************************************************************
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
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 {
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,508 @@
|
||||
/******************************************************************************
|
||||
* 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();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* The Multiverse-API, containing lots of interfaces that can be quite useful for other
|
||||
* plugins when interacting with Multiverse.
|
||||
*/
|
||||
package com.mvplugin.core.api;
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mvplugin.core.command;
|
||||
|
||||
class CommandHelp {
|
||||
|
||||
static void init() { }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mvplugin.core.minecraft;
|
||||
|
||||
public enum Difficulty {
|
||||
PEACEFUL,
|
||||
EASY,
|
||||
NORMAL,
|
||||
HARD
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.mvplugin.core.minecraft;
|
||||
|
||||
public class Entity {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mvplugin.core.minecraft;
|
||||
|
||||
public enum GameMode {
|
||||
|
||||
ADVENTURE,
|
||||
CREATIVE,
|
||||
SURVIVAL
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.mvplugin.core.minecraft;
|
||||
|
||||
public interface Generator {
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mvplugin.core.minecraft;
|
||||
|
||||
public enum WorldType {
|
||||
FLAT,
|
||||
LARGE_BIOMES,
|
||||
NORMAL,
|
||||
VERSION_1_1
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
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'!");
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
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!");
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
# 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
|
||||
@@ -0,0 +1,143 @@
|
||||
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~ 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
@@ -0,0 +1,322 @@
|
||||
<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>
|
||||
@@ -0,0 +1,82 @@
|
||||
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.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
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()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
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();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
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!");
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
name: Multiverse-Core
|
||||
main: com.mvplugin.core.MultiverseCorePlugin
|
||||
authors: ['Rigby', 'fernferret', 'lithium3141', 'main--', 'dumptruckman']
|
||||
version: maven-version-number
|
||||
@@ -1,3 +0,0 @@
|
||||
machine:
|
||||
java:
|
||||
version: oraclejdk8
|
||||
@@ -104,6 +104,7 @@
|
||||
</module>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly"/>
|
||||
<module name="DoubleCheckedLocking"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
<module name="HiddenField">
|
||||
@@ -115,6 +116,7 @@
|
||||
<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
|
||||
|
||||
+535
-278
File diff suppressed because it is too large.
Load diff
+135
-131
@@ -7,26 +7,10 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
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.logging.Level;
|
||||
|
||||
import buscript.Buscript;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MVWorld.NullLocation;
|
||||
import com.fernferret.allpay.AllPay;
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||
@@ -46,8 +30,6 @@ 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.GameruleCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GamerulesCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GeneratorCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ImportCommand;
|
||||
@@ -78,32 +60,26 @@ import com.onarandombox.MultiverseCore.destination.DestinationFactory;
|
||||
import com.onarandombox.MultiverseCore.destination.ExactDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.PlayerDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
||||
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
|
||||
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.MVMapListener;
|
||||
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.listeners.MVWorldInitListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWorldListener;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.utils.MVEconomist;
|
||||
import com.onarandombox.MultiverseCore.utils.MVMessaging;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.utils.MaterialConverter;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
|
||||
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
@@ -114,21 +90,31 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
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.logging.Level;
|
||||
|
||||
/**
|
||||
* The implementation of the Multiverse-{@link Core}.
|
||||
*/
|
||||
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
private static final int PROTOCOL = 24;
|
||||
private static final int PROTOCOL = 18;
|
||||
// TODO: Investigate if this one is really needed to be static.
|
||||
// Doubt it. -- FernFerret
|
||||
private static Map<String, String> teleportQueue = new HashMap<String, String>();
|
||||
@@ -137,21 +123,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// TODO please let's make this non-static
|
||||
private volatile MultiverseCoreConfiguration config;
|
||||
|
||||
public MultiverseCore() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for unit testing.
|
||||
* @param loader The PluginLoader to use.
|
||||
* @param description The Description file to use.
|
||||
* @param dataFolder The folder that other datafiles can be found in.
|
||||
* @param file The location of the plugin.
|
||||
*/
|
||||
public MultiverseCore(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
|
||||
super(loader, description, dataFolder, file);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to find out who is teleporting a player.
|
||||
* @param playerName The teleported player (the teleportee).
|
||||
@@ -177,6 +148,11 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
teleportQueue.put(teleportee, teleporter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "The Multiverse-Core Plugin";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated This is now deprecated, nobody needs it any longer.
|
||||
@@ -220,22 +196,24 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// 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 final MVWorldListener worldListener = new MVWorldListener(this);
|
||||
private MVChatListener chatListener;
|
||||
|
||||
// HashMap to contain information relating to the Players.
|
||||
private HashMap<String, MVPlayerSession> playerSessions;
|
||||
private MVEconomist economist;
|
||||
private VaultHandler vaultHandler;
|
||||
private GenericBank bank = null;
|
||||
private AllPay banker;
|
||||
private Buscript buscript;
|
||||
private int pluginCount;
|
||||
private DestinationFactory destFactory;
|
||||
//private SpoutInterface spoutInterface = null;
|
||||
private MultiverseMessaging messaging;
|
||||
private BlockSafety blockSafety;
|
||||
private LocationManipulation locationManipulation;
|
||||
private SafeTTeleporter safeTTeleporter;
|
||||
private UnsafeCallWrapper unsafeCallWrapper;
|
||||
|
||||
private File serverFolder = new File(System.getProperty("user.dir"));
|
||||
|
||||
@@ -244,7 +222,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Register our config
|
||||
SerializationConfig.registerAll(MultiverseCoreConfiguration.class);
|
||||
// Register our world
|
||||
SerializationConfig.registerAll(WorldProperties.class);
|
||||
SerializationConfig.registerAll(MVWorld.class);
|
||||
// Create our DataFolder
|
||||
getDataFolder().mkdirs();
|
||||
// Setup our Debug Log
|
||||
@@ -256,18 +234,31 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.locationManipulation = new SimpleLocationManipulation();
|
||||
// Setup our SafeTTeleporter
|
||||
this.safeTTeleporter = new SimpleSafeTTeleporter(this);
|
||||
this.unsafeCallWrapper = new UnsafeCallWrapper(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public VaultHandler getVaultHandler() {
|
||||
return getEconomist().getVaultHandler();
|
||||
public FileConfiguration getMVConfiguration() {
|
||||
return this.multiverseConfig;
|
||||
}
|
||||
|
||||
public MVEconomist getEconomist() {
|
||||
return economist;
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated Now using Vault.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public GenericBank getBank() {
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VaultHandler getVaultHandler() {
|
||||
return vaultHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,10 +266,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getServer().getPluginManager().registerEvents(new MVWorldInitListener(this), this);
|
||||
|
||||
this.messaging = new MVMessaging();
|
||||
this.economist = new MVEconomist(this);
|
||||
this.banker = new AllPay(this, LOG_TAG + " ");
|
||||
this.vaultHandler = new VaultHandler(this);
|
||||
// Load the defaultWorldGenerators
|
||||
this.worldManager.getDefaultWorldGenerators();
|
||||
|
||||
@@ -286,6 +276,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Setup Permissions, we'll do an initial check for the Permissions plugin then fall back on isOP().
|
||||
this.ph = new MVPermissions(this);
|
||||
|
||||
this.bank = this.banker.loadEconPlugin();
|
||||
|
||||
// Setup the command manager
|
||||
this.commandHandler = new CommandHandler(this, this.ph);
|
||||
// Call the Function to assign all the Commands to their Class.
|
||||
@@ -305,6 +297,7 @@ 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);
|
||||
@@ -333,15 +326,19 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
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());
|
||||
|
||||
getLogger().info("Help dumptruckman keep this project alive. Become a patron! https://www.patreon.com/dumptruckman");
|
||||
getLogger().info("One time donations are also appreciated: https://www.paypal.me/dumptruckman");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,7 +347,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
private void initializeBuscript() {
|
||||
buscript = new Buscript(this);
|
||||
// Add global variable "multiverse" to javascript environment
|
||||
buscript.setScriptVariable("multiverse", this);
|
||||
buscript.getGlobalScope().put("multiverse", buscript.getGlobalScope(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -410,18 +407,17 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
try {
|
||||
Metrics m = new Metrics(this);
|
||||
|
||||
Metrics.Graph envGraph = m.createGraph("Worlds by environment");
|
||||
Metrics.Graph envGraph = m.createGraph("worlds_by_env");
|
||||
for (Environment env : Environment.values())
|
||||
envGraph.addPlotter(new EnvironmentPlotter(this, env));
|
||||
|
||||
Metrics.Graph loadedWorldsGraph = m.createGraph("Worlds by environment");
|
||||
loadedWorldsGraph.addPlotter(new Metrics.Plotter("Loaded worlds") {
|
||||
m.addCustomData(new Metrics.Plotter("Loaded worlds") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return getMVWorldManager().getMVWorlds().size();
|
||||
}
|
||||
});
|
||||
loadedWorldsGraph.addPlotter(new Metrics.Plotter("Total number of worlds") {
|
||||
m.addCustomData(new Metrics.Plotter("Total number of worlds") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return getMVWorldManager().getMVWorlds().size()
|
||||
@@ -434,13 +430,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
gens.add(w.getGenerator());
|
||||
gens.remove(null);
|
||||
gens.remove("null");
|
||||
Metrics.Graph genGraph = m.createGraph("Custom Generators");
|
||||
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 (Exception e) {
|
||||
} catch (IOException e) {
|
||||
log(Level.WARNING, "There was an issue while enabling metrics: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -463,11 +459,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvents(this.playerListener, this);
|
||||
pm.registerEvents(this.entityListener, this);
|
||||
pm.registerEvents(this.pluginListener, this);
|
||||
pm.registerEvents(this.weatherListener, this);
|
||||
pm.registerEvents(this.portalListener, this);
|
||||
log(Level.INFO, "We are aware of the warning about the deprecated event. There is no alternative that allows us to do what we need to do. The performance impact is negligible.");
|
||||
pm.registerEvents(this.worldListener, this);
|
||||
pm.registerEvents(new MVMapListener(this), this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -477,19 +472,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
public void loadConfigs() {
|
||||
// Now grab the Configuration Files.
|
||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
||||
InputStream resourceURL = this.getClass().getResourceAsStream("/defaults/config.yml");
|
||||
|
||||
// Read in our default config with UTF-8 now
|
||||
Configuration coreDefaults;
|
||||
try {
|
||||
coreDefaults = YamlConfiguration.loadConfiguration(new BufferedReader(new InputStreamReader(resourceURL, "UTF-8")));
|
||||
this.multiverseConfig.setDefaults(coreDefaults);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Logging.severe("Couldn't load default config with UTF-8 encoding. Details follow:");
|
||||
e.printStackTrace();
|
||||
Logging.severe("Default configs NOT loaded.");
|
||||
}
|
||||
|
||||
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
|
||||
this.multiverseConfig.setDefaults(coreDefaults);
|
||||
this.multiverseConfig.options().copyDefaults(false);
|
||||
this.multiverseConfig.options().copyHeader(true);
|
||||
|
||||
@@ -513,12 +497,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Old Config Format
|
||||
this.migrate22Values();
|
||||
this.saveMVConfigs();
|
||||
|
||||
int level = Logging.getDebugLevel();
|
||||
Logging.setDebugLevel(getMVConfig().getGlobalDebug());
|
||||
if (level != Logging.getDebugLevel()) {
|
||||
getServer().getPluginManager().callEvent(new MVDebugModeEvent(level));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -572,22 +550,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
}
|
||||
}
|
||||
|
||||
private static final char PATH_SEPARATOR = '\uF8FF';
|
||||
|
||||
/**
|
||||
* Migrate the worlds.yml to SerializationConfig.
|
||||
*/
|
||||
private void migrateWorldConfig() { // SUPPRESS CHECKSTYLE: MethodLength
|
||||
FileConfiguration wconf = new YamlConfiguration();
|
||||
wconf.options().pathSeparator(PATH_SEPARATOR);
|
||||
File worldsFile = new File(getDataFolder(), "worlds.yml");
|
||||
try {
|
||||
wconf.load(worldsFile);
|
||||
} catch (IOException e) {
|
||||
log(Level.WARNING, "Cannot load worlds.yml");
|
||||
} catch (InvalidConfigurationException e) {
|
||||
log(Level.WARNING, "Your worlds.yml is invalid!");
|
||||
}
|
||||
FileConfiguration wconf = YamlConfiguration
|
||||
.loadConfiguration(new File(getDataFolder(), "worlds.yml"));
|
||||
|
||||
if (!wconf.isConfigurationSection("worlds")) { // empty config
|
||||
this.log(Level.FINE, "No worlds to migrate!");
|
||||
@@ -599,13 +567,14 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
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 WorldProperties) {
|
||||
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
|
||||
WorldProperties world = new WorldProperties(Collections.EMPTY_MAP);
|
||||
MVWorld world = new MVWorld(Collections.EMPTY_MAP);
|
||||
world.setPluginAndWorld(this, entry.getKey());
|
||||
ConfigurationSection section = (ConfigurationSection) entry.getValue();
|
||||
|
||||
// migrate animals and monsters
|
||||
@@ -639,9 +608,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// migrate entryfee
|
||||
if (section.isConfigurationSection("entryfee")) {
|
||||
ConfigurationSection feeSection = section.getConfigurationSection("entryfee");
|
||||
if (feeSection.isInt("currency")) {
|
||||
world.setCurrency(MaterialConverter.convertConfigType(feeSection, "currency"));
|
||||
}
|
||||
if (feeSection.isInt("currency"))
|
||||
world.setCurrency(feeSection.getInt("currency"));
|
||||
|
||||
if (feeSection.isDouble("amount"))
|
||||
world.setPrice(feeSection.getDouble("amount"));
|
||||
@@ -700,8 +668,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// migrate portalform
|
||||
if (section.isString("portalform")) {
|
||||
try {
|
||||
world.setProperty("portalform", section.getString("portalform"), true);
|
||||
} catch (NoSuchPropertyException e) {
|
||||
world.setPropertyValue("portalform", section.getString("portalform"));
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||
}
|
||||
}
|
||||
@@ -709,8 +677,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// migrate environment
|
||||
if (section.isString("environment")) {
|
||||
try {
|
||||
world.setProperty("environment", section.getString("environment"), true);
|
||||
} catch (NoSuchPropertyException e) {
|
||||
world.setPropertyValue("environment", section.getString("environment"));
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||
}
|
||||
}
|
||||
@@ -748,7 +716,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// migrate spawn
|
||||
if (section.isConfigurationSection("spawn")) {
|
||||
ConfigurationSection spawnSect = section.getConfigurationSection("spawn");
|
||||
Location spawnLoc = new NullLocation();
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
if (spawnSect.isDouble("yaw"))
|
||||
spawnLoc.setYaw((float) spawnSect.getDouble("yaw"));
|
||||
if (spawnSect.isDouble("pitch"))
|
||||
@@ -765,14 +733,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
// migrate difficulty
|
||||
if (section.isString("difficulty")) {
|
||||
Difficulty difficulty;
|
||||
try {
|
||||
difficulty = Difficulty.valueOf(section.getString("difficulty").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.log(Level.WARNING, "Could not parse difficulty: " + section.getString("difficulty"));
|
||||
this.log(Level.WARNING, "Setting world " + entry.getKey() + " difficulty to NORMAL");
|
||||
difficulty = Difficulty.NORMAL;
|
||||
}
|
||||
final Difficulty difficulty = Difficulty.valueOf(section.getString("difficulty").toUpperCase());
|
||||
if (difficulty != null) {
|
||||
world.setDifficulty(difficulty);
|
||||
}
|
||||
@@ -861,8 +822,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.commandHandler.registerCommand(new GeneratorCommand(this));
|
||||
this.commandHandler.registerCommand(new CheckCommand(this));
|
||||
this.commandHandler.registerCommand(new ScriptCommand(this));
|
||||
this.commandHandler.registerCommand(new GameruleCommand(this));
|
||||
this.commandHandler.registerCommand(new GamerulesCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -871,6 +830,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.saveMVConfigs();
|
||||
this.banker = null;
|
||||
this.bank = null;
|
||||
Logging.shutdown();
|
||||
}
|
||||
|
||||
@@ -887,6 +848,17 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public com.onarandombox.MultiverseCore.utils.SafeTTeleporter getTeleporter() {
|
||||
return new com.onarandombox.MultiverseCore.utils.SafeTTeleporter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -1045,6 +1017,26 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.pluginCount -= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -1086,6 +1078,25 @@ 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets our {@link SpoutInterface}.
|
||||
*
|
||||
* @return The {@link SpoutInterface} we're using.
|
||||
* /
|
||||
public SpoutInterface getSpout() {
|
||||
return this.spoutInterface;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -1218,9 +1229,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
@Override
|
||||
public void setBlockSafety(BlockSafety bs) {
|
||||
if (bs == null) {
|
||||
throw new NullPointerException("block safety may not be null.");
|
||||
}
|
||||
this.blockSafety = bs;
|
||||
}
|
||||
|
||||
@@ -1279,8 +1287,4 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
public Buscript getScriptAPI() {
|
||||
return buscript;
|
||||
}
|
||||
|
||||
public UnsafeCallWrapper getUnsafeCallWrapper() {
|
||||
return this.unsafeCallWrapper;
|
||||
}
|
||||
}
|
||||
+6
-65
@@ -1,12 +1,12 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.dumptruckman.minecraft.util.*;
|
||||
import com.onarandombox.MultiverseCore.api.*;
|
||||
import com.onarandombox.MultiverseCore.event.MVDebugModeEvent;
|
||||
import me.main__.util.SerializationConfig.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
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.*;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Our configuration.
|
||||
@@ -44,8 +44,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
@Property
|
||||
private volatile boolean prefixchat;
|
||||
@Property
|
||||
private volatile String prefixchatformat;
|
||||
@Property
|
||||
private volatile boolean useasyncchat;
|
||||
@Property
|
||||
private volatile boolean teleportintercept;
|
||||
@@ -65,12 +63,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
private volatile String firstspawnworld;
|
||||
@Property
|
||||
private volatile int teleportcooldown;
|
||||
@Property
|
||||
private volatile boolean defaultportalsearch;
|
||||
@Property
|
||||
private volatile int portalsearchradius;
|
||||
@Property
|
||||
private volatile boolean autopurge;
|
||||
|
||||
public MultiverseCoreConfiguration() {
|
||||
super();
|
||||
@@ -91,7 +83,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
enforceaccess = false;
|
||||
useasyncchat = true;
|
||||
prefixchat = true;
|
||||
prefixchatformat = "[%world%]%chat%";
|
||||
teleportintercept = true;
|
||||
firstspawnoverride = true;
|
||||
displaypermerrors = true;
|
||||
@@ -100,9 +91,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
teleportcooldown = 1000;
|
||||
this.version = 2.9;
|
||||
silentstart = false;
|
||||
defaultportalsearch = false;
|
||||
portalsearchradius = 128;
|
||||
autopurge = true;
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
@@ -151,22 +139,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
public void setPrefixChat(boolean prefixChat) {
|
||||
this.prefixchat = prefixChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getPrefixChatFormat() {
|
||||
return this.prefixchatformat;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setPrefixChatFormat(String prefixChatFormat) {
|
||||
this.prefixchatformat = prefixChatFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -231,7 +203,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
public void setGlobalDebug(int globalDebug) {
|
||||
this.globaldebug = globalDebug;
|
||||
Logging.setDebugLevel(globalDebug);
|
||||
Bukkit.getPluginManager().callEvent(new MVDebugModeEvent(globalDebug));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,34 +289,4 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
public boolean getSilentStart() {
|
||||
return silentstart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseDefaultPortalSearch(boolean useDefaultPortalSearch) {
|
||||
defaultportalsearch = useDefaultPortalSearch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsingDefaultPortalSearch() {
|
||||
return defaultportalsearch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPortalSearchRadius(int searchRadius) {
|
||||
this.portalsearchradius = searchRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPortalSearchRadius() {
|
||||
return portalsearchradius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoPurgeEnabled() {
|
||||
return autopurge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoPurgeEnabled(boolean autopurge) {
|
||||
this.autopurge = autopurge;
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+51
-12
@@ -8,9 +8,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.MVEconomist;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
||||
@@ -18,6 +19,7 @@ import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
@@ -27,24 +29,32 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public interface Core {
|
||||
|
||||
/**
|
||||
* Gets the Multiverse config file.
|
||||
*
|
||||
* @return The Multiverse config file.
|
||||
* @deprecated Don't modify the config-file manually!
|
||||
*/
|
||||
@Deprecated
|
||||
FileConfiguration getMVConfiguration();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @deprecated we are now using {@link #getEconomist()} for all economy needs.
|
||||
*/
|
||||
@Deprecated
|
||||
VaultHandler getVaultHandler();
|
||||
|
||||
/**
|
||||
* Retrieves Multiverse's friendly economist. The economist can be used for dealing with economies without
|
||||
* worrying about any of the messy details.
|
||||
*
|
||||
* @return the economy manager for Multiverse.
|
||||
*/
|
||||
MVEconomist getEconomist();
|
||||
|
||||
/**
|
||||
* Reloads the Multiverse Configuration files:
|
||||
* worlds.yml and config.yml.
|
||||
@@ -70,6 +80,17 @@ public interface Core {
|
||||
*/
|
||||
MVPlayerSession getPlayerSession(Player player);
|
||||
|
||||
/**
|
||||
* Gets the instantiated Safe-T-Teleporter for performing
|
||||
* safe teleports.
|
||||
*
|
||||
* @return A non-null {@link SafeTTeleporter}.
|
||||
*
|
||||
* @deprecated Use {@link #getSafeTTeleporter()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
com.onarandombox.MultiverseCore.utils.SafeTTeleporter getTeleporter();
|
||||
|
||||
/**
|
||||
* Multiverse uses an advanced permissions setup, this object
|
||||
* simplifies getting/setting permissions.
|
||||
@@ -97,7 +118,7 @@ public interface Core {
|
||||
/**
|
||||
* Gets the primary class responsible for managing Multiverse Worlds.
|
||||
*
|
||||
* @return {@link MVWorldManager}.
|
||||
* @return {@link WorldManager}.
|
||||
*/
|
||||
MVWorldManager getMVWorldManager();
|
||||
|
||||
@@ -130,6 +151,24 @@ public interface Core {
|
||||
@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();
|
||||
|
||||
/**
|
||||
* Decrements the number of plugins that have specifically hooked into core.
|
||||
*/
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -30,14 +30,14 @@ public interface MVPlugin extends LoggablePlugin {
|
||||
/**
|
||||
* Gets the reference to MultiverseCore.
|
||||
*
|
||||
* @return A valid {@link com.onarandombox.MultiverseCore}.
|
||||
* @return A valid {@link MultiverseCore}.
|
||||
*/
|
||||
MultiverseCore getCore();
|
||||
|
||||
/**
|
||||
* Sets the reference to MultiverseCore.
|
||||
*
|
||||
* @param core A valid {@link com.onarandombox.MultiverseCore}.
|
||||
* @param core A valid {@link MultiverseCore}.
|
||||
*/
|
||||
void setCore(MultiverseCore core);
|
||||
|
||||
+7
-43
@@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
@@ -64,30 +65,16 @@ public interface MVWorldManager {
|
||||
*
|
||||
* @param oldName Name of world to be copied
|
||||
* @param newName Name of world to be created
|
||||
* @param generator The Custom generator plugin to use. Ignored.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @return True if the world is copied successfully, false if not.
|
||||
* @deprecated Use {@link #cloneWorld(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean cloneWorld(String oldName, String newName, String generator);
|
||||
|
||||
/**
|
||||
* Make a copy of a world.
|
||||
* Remove the world from the Multiverse list, from the
|
||||
* config and deletes the folder.
|
||||
*
|
||||
* @param oldName
|
||||
* Name of world to be copied
|
||||
* @param newName
|
||||
* Name of world to be created
|
||||
* @return True if the world is copied successfully, false if not.
|
||||
*/
|
||||
boolean cloneWorld(String oldName, String newName);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the config and deletes
|
||||
* the folder.
|
||||
*
|
||||
* @param name
|
||||
* The name of the world to remove
|
||||
* @param name The name of the world to remove
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name);
|
||||
@@ -122,15 +109,6 @@ public interface MVWorldManager {
|
||||
*/
|
||||
boolean unloadWorld(String name);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse with option to prevent calling unloadWorld in Bukkit.
|
||||
*
|
||||
* @param name Name of the world to unload
|
||||
* @param unloadBukkit True if Bukkit world should be unloaded
|
||||
* @return True if the world was unloaded, false if not.
|
||||
*/
|
||||
boolean unloadWorld(String name, boolean unloadBukkit);
|
||||
|
||||
/**
|
||||
* Loads the world. Only use this if the world has been
|
||||
* unloaded with {@link #unloadWorld(String)}.
|
||||
@@ -199,7 +177,7 @@ public interface MVWorldManager {
|
||||
boolean isMVWorld(World world);
|
||||
|
||||
/**
|
||||
* Load the Worlds & Settings from the configuration file.
|
||||
* 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.
|
||||
@@ -207,7 +185,7 @@ public interface MVWorldManager {
|
||||
void loadWorlds(boolean forceLoad);
|
||||
|
||||
/**
|
||||
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
|
||||
* Loads the Worlds & Settings for any worlds that bukkit loaded before us.
|
||||
* <p>
|
||||
* This way people will _always_ have some worlds in the list.
|
||||
*/
|
||||
@@ -300,18 +278,4 @@ public interface MVWorldManager {
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
|
||||
|
||||
boolean isKeepingSpawnInMemory(World world);
|
||||
|
||||
/**
|
||||
* Checks whether Multiverse knows about a provided unloaded world. This
|
||||
* method will check the parameter against the alias mappings.
|
||||
*
|
||||
* @param name The name of the unloaded world
|
||||
* @param includeLoaded The value to return if the world is loaded
|
||||
*
|
||||
* @return True if the world exists and is unloaded. False if the world
|
||||
* does not exist. {@code includeLoaded} if the world exists and is loaded.
|
||||
*/
|
||||
boolean hasUnloadedWorld(String name, boolean includeLoaded);
|
||||
}
|
||||
-54
@@ -121,18 +121,6 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
* @return prefixChat.
|
||||
*/
|
||||
boolean getPrefixChat();
|
||||
|
||||
/**
|
||||
* Sets prefixChatFormat.
|
||||
* @param prefixChatFormat The new value.
|
||||
*/
|
||||
void setPrefixChatFormat(String prefixChatFormat);
|
||||
|
||||
/**
|
||||
* Gets prefixChatFormat.
|
||||
* @return prefixChatFormat.
|
||||
*/
|
||||
String getPrefixChatFormat();
|
||||
|
||||
/**
|
||||
* Sets enforceAccess.
|
||||
@@ -171,46 +159,4 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
* @return true if we are suppressing startup messages.
|
||||
*/
|
||||
boolean getSilentStart();
|
||||
|
||||
/**
|
||||
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
|
||||
*
|
||||
* @param useDefaultPortalSearch True to let Bukkit determine portal search radius on its own.
|
||||
*/
|
||||
void setUseDefaultPortalSearch(boolean useDefaultPortalSearch);
|
||||
|
||||
/**
|
||||
* Gets whether or not Bukkit will be determining portal search radius on its own or if Multiverse should help.
|
||||
*
|
||||
* @return True means Bukkit will use its own default values.
|
||||
*/
|
||||
boolean isUsingDefaultPortalSearch();
|
||||
|
||||
/**
|
||||
* Sets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @param searchRadius The portal search radius.
|
||||
*/
|
||||
void setPortalSearchRadius(int searchRadius);
|
||||
|
||||
/**
|
||||
* Gets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @return The portal search radius.
|
||||
*/
|
||||
int getPortalSearchRadius();
|
||||
|
||||
/**
|
||||
* Gets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @return True if automatic purge is enabled.
|
||||
*/
|
||||
boolean isAutoPurgeEnabled();
|
||||
|
||||
/**
|
||||
* Sets whether or not the automatic purge of entities is enabled.
|
||||
*
|
||||
* @param autopurge True if automatic purge should be enabled.
|
||||
*/
|
||||
void setAutoPurgeEnabled(boolean autopurge);
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+38
-24
@@ -9,16 +9,15 @@ package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -155,6 +154,37 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
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}.
|
||||
*
|
||||
@@ -475,28 +505,26 @@ public interface MultiverseWorld {
|
||||
/**
|
||||
* Sets the price for entry to this world.
|
||||
* You can think of this like an amount.
|
||||
* The type can be set with {@link #setCurrency(Material)}
|
||||
* 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. A value of null indicates a non-item
|
||||
* based currency is used.
|
||||
* 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.
|
||||
* @return The Type of currency that will be used when users enter this world.
|
||||
*/
|
||||
@Nullable
|
||||
Material getCurrency();
|
||||
int getCurrency();
|
||||
|
||||
/**
|
||||
* Sets the type of item that will be required given the price is not 0.
|
||||
* Use a value of null to specify a non-item based currency.
|
||||
* 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(@Nullable Material item);
|
||||
void setCurrency(int item);
|
||||
|
||||
/**
|
||||
* Gets the world players will respawn in if they die in this one.
|
||||
@@ -657,18 +685,4 @@ public interface MultiverseWorld {
|
||||
* @return All property names, with alternating colors.
|
||||
*/
|
||||
String getAllPropertyNames();
|
||||
|
||||
/**
|
||||
* Whether or not players are allowed to fly in this world.
|
||||
*
|
||||
* @return True if players allowed to fly in this world.
|
||||
*/
|
||||
boolean getAllowFlight();
|
||||
|
||||
/**
|
||||
* Sets whether or not players are allowed to fly in this world.
|
||||
*
|
||||
* @param allowFlight True to allow flight in this world.
|
||||
*/
|
||||
void setAllowFlight(final boolean allowFlight);
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ import com.onarandombox.MultiverseCore.enums.TeleportResult;
|
||||
/**
|
||||
* Used to safely teleport people.
|
||||
*/
|
||||
public interface SafeTTeleporter extends Teleporter {
|
||||
public interface SafeTTeleporter {
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
+1
-1
@@ -17,7 +17,7 @@ public interface WorldPurger {
|
||||
void purgeWorlds(List<MultiverseWorld> worlds);
|
||||
|
||||
/**
|
||||
* Convenience method for {@link #purgeWorld(MultiverseWorld, java.util.List, boolean, boolean)} that takes the settings from the world-config.
|
||||
* Convenience method for {@link #purgeWorld(CommandSender, MultiverseWorld, List, boolean, boolean)} that takes the settings from the world-config.
|
||||
*
|
||||
* @param world The {@link MultiverseWorld}.
|
||||
*/
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+17
-12
@@ -7,14 +7,15 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Creates a clone of a world.
|
||||
@@ -33,23 +34,27 @@ public class CloneCommand extends MultiverseCommand {
|
||||
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) {
|
||||
String oldName = args.get(0);
|
||||
if (!this.worldManager.hasUnloadedWorld(oldName, true)) {
|
||||
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 " + oldName + ", so we can't clone it!");
|
||||
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;
|
||||
}
|
||||
if (this.plugin.getMVWorldManager().cloneWorld(oldName, args.get(1))) {
|
||||
sender.sendMessage(ChatColor.GREEN + "World cloned!");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "World could NOT be cloned!");
|
||||
}
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvclone", "cloneWorld", objectArgs,
|
||||
paramTypes, ChatColor.GREEN + "World Cloned!", ChatColor.RED + "World could NOT be cloned!");
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -62,7 +62,7 @@ public class CoordCommand extends MultiverseCommand {
|
||||
df.setMaximumFractionDigits(2);
|
||||
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + plugin.getLocationManipulation().strCoords(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + plugin.getLocationManipulation().getDirection(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + world.getBlockAt(p.getLocation()).getType());
|
||||
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
|
||||
} else {
|
||||
sender.sendMessage("This command needs to be used from a Player.");
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+3
-7
@@ -27,19 +27,15 @@ public class DeleteCommand extends MultiverseCommand {
|
||||
this.setArgRange(1, 1);
|
||||
this.addKey("mvdelete");
|
||||
this.addKey("mv delete");
|
||||
this.addCommandExample("/mv delete " + ChatColor.GOLD + "MyWorld");
|
||||
this.addCommandExample("/mv create " + ChatColor.GOLD + "MyWorld");
|
||||
this.setPermission("multiverse.core.delete", "Deletes a world on your server. " + ChatColor.RED + "PERMANENTLY.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
String worldName = args.get(0);
|
||||
|
||||
Class<?>[] paramTypes = {String.class};
|
||||
List<Object> objectArgs = new ArrayList<Object>(args);
|
||||
this.plugin.getCommandHandler()
|
||||
.queueCommand(sender, "mvdelete", "deleteWorld", objectArgs,
|
||||
paramTypes, ChatColor.GREEN + "World '" + worldName + "' Deleted!",
|
||||
ChatColor.RED + "World '" + worldName + "' could NOT be deleted!");
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvdelete", "deleteWorld", objectArgs,
|
||||
paramTypes, ChatColor.GREEN + "World Deleted!", ChatColor.RED + "World could NOT be deleted!");
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -71,14 +71,12 @@ public class EnvironmentCommand extends MultiverseCommand {
|
||||
*/
|
||||
public static WorldType getWorldTypeFromString(String type) {
|
||||
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
||||
if (type.equalsIgnoreCase("normal")) {
|
||||
if (type.equalsIgnoreCase("normal"))
|
||||
type = "NORMAL";
|
||||
} else if (type.equalsIgnoreCase("flat")) {
|
||||
if (type.equalsIgnoreCase("flat"))
|
||||
type = "FLAT";
|
||||
} else if (type.equalsIgnoreCase("largebiomes")) {
|
||||
if (type.equalsIgnoreCase("largebiomes")) {
|
||||
type = "LARGE_BIOMES";
|
||||
} else if (type.equalsIgnoreCase("amplified")) {
|
||||
type = "AMPLIFIED";
|
||||
}
|
||||
try {
|
||||
// Now that we've converted a potentially unfriendly value
|
||||
File renamed without changes.
File renamed without changes.
+13
-22
@@ -57,7 +57,7 @@ public class ImportCommand extends MultiverseCommand {
|
||||
File[] files = worldFolder.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return name.toLowerCase().endsWith(".dat");
|
||||
return name.equalsIgnoreCase("level.dat");
|
||||
}
|
||||
});
|
||||
if (files != null && files.length > 0) {
|
||||
@@ -95,15 +95,10 @@ public class ImportCommand extends MultiverseCommand {
|
||||
}
|
||||
return worldList;
|
||||
}
|
||||
|
||||
private String trimWorldName(String userInput) {
|
||||
// Removes relative paths.
|
||||
return userInput.replaceAll("^[./\\\\]+", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
String worldName = trimWorldName(args.get(0));
|
||||
String worldName = args.get(0);
|
||||
|
||||
if (worldName.toLowerCase().equals("--list") || worldName.toLowerCase().equals("-l")) {
|
||||
String worldList = this.getPotentialWorlds();
|
||||
@@ -117,7 +112,7 @@ public class ImportCommand extends MultiverseCommand {
|
||||
}
|
||||
// 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 (args.size() == 1 || worldName.length() < 1) {
|
||||
if (args.size() == 1) {
|
||||
this.showHelp(sender);
|
||||
return;
|
||||
}
|
||||
@@ -147,25 +142,21 @@ public class ImportCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!worldFile.exists()) {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
String worldList = this.getPotentialWorlds();
|
||||
sender.sendMessage("That world folder does not exist. These look like worlds to me:");
|
||||
sender.sendMessage(worldList);
|
||||
} else if (!checkIfIsWorld(worldFile)) {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
sender.sendMessage(String.format("'%s' does not appear to be a world. It is lacking a .dat file.",
|
||||
worldName));
|
||||
} else if (env == null) {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
sender.sendMessage("That world environment did not exist.");
|
||||
sender.sendMessage("For a list of available world types, type: " + ChatColor.AQUA + "/mvenv");
|
||||
} else {
|
||||
if (worldFile.exists() && env != null) {
|
||||
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
|
||||
if (this.worldManager.addWorld(worldName, environment, null, null, null, generator, useSpawnAdjust))
|
||||
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Complete!");
|
||||
else
|
||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
|
||||
} else if (env == null) {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
sender.sendMessage("That world environment did not exist.");
|
||||
sender.sendMessage("For a list of available world types, type: " + ChatColor.AQUA + "/mvenv");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "FAILED.");
|
||||
String worldList = this.getPotentialWorlds();
|
||||
sender.sendMessage("That world folder does not exist. These look like worlds to me:");
|
||||
sender.sendMessage(worldList);
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-11
@@ -122,16 +122,15 @@ public class InfoCommand extends MultiverseCommand {
|
||||
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
|
||||
Location spawn = world.getSpawnLocation();
|
||||
message.add(new FancyMessage("Spawn Location: ", plugin.getLocationManipulation().strCoords(spawn), colors));
|
||||
message.add(new FancyMessage("World Scale: ", String.valueOf(world.getScaling()), colors));
|
||||
message.add(new FancyMessage("World Seed: ", String.valueOf(world.getSeed()), colors));
|
||||
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
|
||||
if (world.getPrice() > 0) {
|
||||
message.add(new FancyMessage("Price to enter this world: ",
|
||||
plugin.getEconomist().formatPrice(world.getPrice(), world.getCurrency()),
|
||||
colors));
|
||||
} else if (world.getPrice() < 0) {
|
||||
message.add(new FancyMessage("Reward for entering this world: ",
|
||||
plugin.getEconomist().formatPrice(-world.getPrice(), world.getCurrency()),
|
||||
colors));
|
||||
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));
|
||||
} else {
|
||||
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
|
||||
}
|
||||
@@ -181,8 +180,8 @@ public class InfoCommand extends MultiverseCommand {
|
||||
message.add(new FancyHeader("Animal Settings", colors));
|
||||
message.add(new FancyMessage("Multiverse Setting: ", world.canAnimalsSpawn() + "", colors));
|
||||
message.add(new FancyMessage("Bukkit Setting: ", world.getCBWorld().getAllowAnimals() + "", colors));
|
||||
if (world.getAnimalList().size() > 0) {
|
||||
if (world.canAnimalsSpawn()) {
|
||||
if (world.getMonsterList().size() > 0) {
|
||||
if (world.canMonstersSpawn()) {
|
||||
message.add(new FancyMessage("Animals that" + ChatColor.RED + " CAN NOT "
|
||||
+ ChatColor.GREEN + "spawn: ", toCommaSeperated(world.getAnimalList()), colors));
|
||||
} else {
|
||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -77,7 +77,7 @@ public class ModifyAddCommand extends MultiverseCommand {
|
||||
|
||||
if (!ModifyCommand.validateAction(Action.Add, property)) {
|
||||
sender.sendMessage("Sorry, you can't ADD to " + property);
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: https://goo.gl/OMGwzx");
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ public class ModifyClearCommand extends MultiverseCommand {
|
||||
|
||||
if (!ModifyCommand.validateAction(Action.Clear, property)) {
|
||||
sender.sendMessage("Sorry, you can't use CLEAR with " + property);
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: https://goo.gl/q1h01S");
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/cgB2B");
|
||||
return;
|
||||
}
|
||||
// TODO fix this
|
||||
File renamed without changes.
+1
-1
@@ -78,7 +78,7 @@ public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
|
||||
if (!ModifyCommand.validateAction(Action.Remove, property)) {
|
||||
sender.sendMessage("Sorry, you can't REMOVE anything from" + property);
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: https://goo.gl/OMGwzx");
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
|
||||
return;
|
||||
}
|
||||
// TODO fix this
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,76 @@
|
||||
/******************************************************************************
|
||||
* 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.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Sets the spawn for a world.
|
||||
*/
|
||||
public class SetSpawnCommand extends MultiverseCommand {
|
||||
public SetSpawnCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Set World Spawn");
|
||||
this.setCommandUsage("/mv setspawn");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mvsetspawn");
|
||||
this.addKey("mvss");
|
||||
this.addKey("mv set spawn");
|
||||
this.addKey("mv setspawn");
|
||||
this.addKey("mvset spawn");
|
||||
this.addCommandExample("/mv set spawn");
|
||||
this.setPermission("multiverse.core.spawn.set", "Sets the spawn for the current world.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
setWorldSpawn(sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the actual spawn-setting-work.
|
||||
*
|
||||
* @param sender The {@link CommandSender} that's setting the spawn.
|
||||
*/
|
||||
protected void setWorldSpawn(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
Location l = p.getLocation();
|
||||
World w = p.getWorld();
|
||||
MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName());
|
||||
if (foundWorld != null) {
|
||||
foundWorld.setSpawnLocation(p.getLocation());
|
||||
BlockSafety bs = this.plugin.getBlockSafety();
|
||||
if (!bs.playerCanSpawnHereSafely(p.getLocation()) && foundWorld.getAdjustSpawn()) {
|
||||
sender.sendMessage("It looks like that location would normally be unsafe. But I trust you.");
|
||||
sender.sendMessage("I'm turning off the Safe-T-Teleporter for spawns to this world.");
|
||||
sender.sendMessage("If you want this turned back on just do:");
|
||||
sender.sendMessage(ChatColor.AQUA + "/mvm set adjustspawn true " + foundWorld.getAlias());
|
||||
foundWorld.setAdjustSpawn(false);
|
||||
}
|
||||
sender.sendMessage("Spawn was set to: " + plugin.getLocationManipulation().strCoords(p.getLocation()));
|
||||
} else {
|
||||
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
sender.sendMessage("Multiverse does not know about this world, only X,Y and Z set. Please import it to set the spawn fully (Pitch/Yaws).");
|
||||
}
|
||||
|
||||
} else {
|
||||
sender.sendMessage("You cannot use this command from the console.");
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,66 @@
|
||||
/******************************************************************************
|
||||
* 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 org.getspout.spoutapi.gui.GenericButton;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.PopupScreen;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Edit a world with spout.
|
||||
* /
|
||||
public class SpoutCommand extends MultiverseCommand {
|
||||
|
||||
public SpoutCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Edit World with Spout");
|
||||
this.setCommandUsage("/mv spout");
|
||||
this.setArgRange(0, 0);
|
||||
this.addKey("mv spout");
|
||||
this.setPermission("multiverse.core.spout", "Edit a world with spout.", PermissionDefault.OP);
|
||||
this.addCommandExample("/mv spout");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "This command must be run as a player!");
|
||||
return;
|
||||
}
|
||||
if (plugin.getSpout() == null) {
|
||||
sender.sendMessage(ChatColor.RED + "You need spout installed on this server to use it with Multiverse!");
|
||||
return;
|
||||
}
|
||||
SpoutPlayer p = (SpoutPlayer) sender;
|
||||
if (!p.isSpoutCraftEnabled()) {
|
||||
sender.sendMessage(ChatColor.RED + p.getName() + "You need to be using the Spoutcraft client to run this command!");
|
||||
return;
|
||||
}
|
||||
PopupScreen pop = new GenericPopup();
|
||||
GenericButton button = new GenericButton("Fish");
|
||||
// TO-DO maybe use constants for these
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
button.setX(50);
|
||||
button.setY(50);
|
||||
button.setWidth(100);
|
||||
button.setHeight(40);
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
pop.attachWidget(this.plugin, button);
|
||||
sender.sendMessage(ChatColor.GREEN + "YAY!");
|
||||
p.getMainScreen().attachPopupScreen(pop);
|
||||
}
|
||||
}
|
||||
*/
|
||||
+2
-6
@@ -8,9 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.Teleporter;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.CustomTeleporterDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
||||
@@ -158,9 +156,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
this.messaging.sendMessage(teleporter, "Sorry Boss, I tried everything, but just couldn't teleport ya there!", false);
|
||||
return;
|
||||
}
|
||||
Teleporter teleportObject = (d instanceof CustomTeleporterDestination) ?
|
||||
((CustomTeleporterDestination)d).getTeleporter() : this.playerTeleporter;
|
||||
TeleportResult result = teleportObject.teleport(teleporter, teleportee, d);
|
||||
TeleportResult result = this.playerTeleporter.safelyTeleport(teleporter, teleportee, d);
|
||||
if (result == TeleportResult.FAIL_UNSAFE) {
|
||||
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName()
|
||||
+ " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee)));
|
||||
@@ -174,7 +170,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
if (!teleportee.equals(teleporter)) {
|
||||
player = teleportee.getName();
|
||||
}
|
||||
String message = String.format("%sMultiverse %sdid not teleport %s%s %sto %s%s %sbecause it was unsafe.",
|
||||
String message = String.format("%sMultiverse %sdid not teleport %s%s%sto %s%s%sbecause it was unsafe.",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, player, ChatColor.WHITE, ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE);
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvteleport", "teleportPlayer", items,
|
||||
paramTypes, message, "Would you like to try anyway?", "", "", UNSAFE_TELEPORT_EXPIRE_DELAY);
|
||||
Loaded 100 of 220 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user