mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 20:16:06 +01:00
Merge branch 'master' of github.com:Multiverse/Multiverse-Core into generate-structures
Conflicts: pom.xml src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java
This commit is contained in:
commit
309518723f
7
.gitmodules
vendored
7
.gitmodules
vendored
@ -1,7 +0,0 @@
|
|||||||
[submodule "lib/allpay"]
|
|
||||||
path = lib/allpay
|
|
||||||
url = git://github.com/FernFerret/AllPay.git
|
|
||||||
[submodule "lib/commandhandler"]
|
|
||||||
path = lib/commandhandler
|
|
||||||
url = git://github.com/PneumatiCraft/CommandHandler.git
|
|
||||||
branch = notrie
|
|
@ -1,11 +1,8 @@
|
|||||||
Building
|
Building
|
||||||
========
|
========
|
||||||
Update the submodules after you clone and before you build with maven.
|
Simply build the source with maven:
|
||||||
|
|
||||||
```
|
$ mvn install
|
||||||
$ git submodule update --init --recursive
|
|
||||||
$ mvn install
|
|
||||||
```
|
|
||||||
|
|
||||||
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
|
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 7abba1f0040862e9fabdafb3d44c6cf0b914cc7c
|
|
@ -1 +0,0 @@
|
|||||||
Subproject commit 46a3ab6e4e444cd84f836aa6d36ed02cf6347454
|
|
126
pom.xml
126
pom.xml
@ -67,28 +67,6 @@
|
|||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Build Helper - Additional Source Folders -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>build-helper-maven-plugin</artifactId>
|
|
||||||
<version>1.7</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>add-wsdl-source</id>
|
|
||||||
<phase>generate-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>add-source</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<sources>
|
|
||||||
<source>${project.basedir}/lib/allpay/src/main/java</source>
|
|
||||||
<source>${project.basedir}/lib/commandhandler/src</source>
|
|
||||||
<source>${project.basedir}/lib/commandhandler/lib/ShellParser/src</source>
|
|
||||||
</sources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||||
<artifactId>maven-replacer-plugin</artifactId>
|
<artifactId>maven-replacer-plugin</artifactId>
|
||||||
@ -158,6 +136,42 @@
|
|||||||
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
|
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>1.5</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>me.main__.util:SerializationConfig</include>
|
||||||
|
<include>com.fernferret.allpay:AllPay</include>
|
||||||
|
<include>com.pneumaticraft.commandhandler:CommandHandler</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.fernferret.allpay</pattern>
|
||||||
|
<shadedPattern>com.fernferret.allpay.multiverse</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>me.main__.util</pattern>
|
||||||
|
<shadedPattern>me.main__.util.multiverse</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.pneumaticraft.commandhandler</pattern>
|
||||||
|
<shadedPattern>com.pneumaticraft.commandhandler.multiverse</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@ -166,7 +180,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.1-R2-SNAPSHOT</version>
|
<version>1.1-R3</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -178,69 +192,33 @@
|
|||||||
<version>dev-SNAPSHOT</version>
|
<version>dev-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- End of Spout -->
|
<!-- End of Spout -->
|
||||||
<!-- Start of Economy Dependencies -->
|
<!-- SerializationConfig Dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cosine.boseconomy</groupId>
|
<groupId>me.main__.util</groupId>
|
||||||
<artifactId>BOSEconomy</artifactId>
|
<artifactId>SerializationConfig</artifactId>
|
||||||
<version>0.6.2</version>
|
<version>1.1</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- End of SerializationConfig Dependency -->
|
||||||
|
<!-- Start of AllPay Dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.crafter.tickleman.RealShop</groupId>
|
<groupId>com.fernferret.allpay</groupId>
|
||||||
<artifactId>RealShop</artifactId>
|
<artifactId>AllPay</artifactId>
|
||||||
<version>0.63</version>
|
<version>6</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- End of AllPay Dependency -->
|
||||||
|
<!-- Start of CommandHandler Dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.iCo6</groupId>
|
<groupId>com.pneumaticraft.commandhandler</groupId>
|
||||||
<artifactId>iConomy</artifactId>
|
<artifactId>CommandHandler</artifactId>
|
||||||
<version>6.0</version>
|
<version>6</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- End of CommandHandler Dependency -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.iConomy</groupId>
|
|
||||||
<artifactId>iConomy</artifactId>
|
|
||||||
<version>5.0</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.nijiko.coelho.iConomy</groupId>
|
|
||||||
<artifactId>iConomy</artifactId>
|
|
||||||
<version>4.65</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.earth2me.essentials</groupId>
|
|
||||||
<artifactId>Essentials</artifactId>
|
|
||||||
<version>2.4.2</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>me.ashtheking.currency</groupId>
|
|
||||||
<artifactId>MultiCurrency</artifactId>
|
|
||||||
<version>0.09</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>ca.agnate</groupId>
|
|
||||||
<artifactId>EconXP</artifactId>
|
|
||||||
<version>1.0.0</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- End of Economy Dependencies -->
|
|
||||||
<!-- Start of Test Dependencies -->
|
<!-- Start of Test Dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
@ -12,6 +12,7 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
|||||||
import com.onarandombox.MultiverseCore.configuration.ConfigPropertyFactory;
|
import com.onarandombox.MultiverseCore.configuration.ConfigPropertyFactory;
|
||||||
import com.onarandombox.MultiverseCore.configuration.MVActiveConfigProperty;
|
import com.onarandombox.MultiverseCore.configuration.MVActiveConfigProperty;
|
||||||
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
|
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
|
||||||
|
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||||
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;
|
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;
|
||||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||||
@ -156,6 +157,8 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
this.propertyList.put("adjustspawn", fac.getNewProperty("adjustspawn", true,
|
this.propertyList.put("adjustspawn", fac.getNewProperty("adjustspawn", true,
|
||||||
"Sorry, 'adjustspawn' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
|
"Sorry, 'adjustspawn' must either be:" + ChatColor.GREEN + " true " + ChatColor.WHITE
|
||||||
+ "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
+ "or" + ChatColor.RED + " false" + ChatColor.WHITE + "."));
|
||||||
|
this.propertyList.put("portalform", fac.getNewProperty("portalform", AllowedPortalType.ALL,
|
||||||
|
"Allow portal forming must be NONE, ALL, NETHER or END."));
|
||||||
if (!fixSpawn) {
|
if (!fixSpawn) {
|
||||||
this.setAdjustSpawn(false);
|
this.setAdjustSpawn(false);
|
||||||
}
|
}
|
||||||
@ -511,6 +514,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
return (MVConfigProperty<T>) this.propertyList.get(this.propertyAliases.get(name));
|
return (MVConfigProperty<T>) this.propertyList.get(this.propertyAliases.get(name));
|
||||||
}
|
}
|
||||||
} catch (ClassCastException e) {
|
} catch (ClassCastException e) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -556,6 +560,7 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
try {
|
try {
|
||||||
if (property.getMethod() == null) {
|
if (property.getMethod() == null) {
|
||||||
// This property did not have a method.
|
// This property did not have a method.
|
||||||
|
this.saveConfig();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Method method = this.getClass().getMethod(property.getMethod());
|
Method method = this.getClass().getMethod(property.getMethod());
|
||||||
@ -570,6 +575,8 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
// TODO: I don't care about 3 catches,
|
||||||
|
// TODO: I hate pokemon errors :/ - FernFerret
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1159,6 +1166,22 @@ public class MVWorld implements MultiverseWorld {
|
|||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void allowPortalMaking(AllowedPortalType type) {
|
||||||
|
this.setKnownProperty("portalform", type.toString(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AllowedPortalType getAllowedPortals() {
|
||||||
|
return this.getKnownProperty("portalform", AllowedPortalType.class).getValue();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the active time-property to set the "actual" property.
|
* Used by the active time-property to set the "actual" property.
|
||||||
* @return True if the property was successfully set.
|
* @return True if the property was successfully set.
|
||||||
|
@ -14,6 +14,7 @@ import com.onarandombox.MultiverseCore.api.Core;
|
|||||||
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||||
import com.onarandombox.MultiverseCore.api.MVPlugin;
|
import com.onarandombox.MultiverseCore.api.MVPlugin;
|
||||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||||
|
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||||
@ -30,8 +31,12 @@ import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
|||||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
||||||
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||||
|
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
|
||||||
import com.onarandombox.MultiverseCore.utils.*;
|
import com.onarandombox.MultiverseCore.utils.*;
|
||||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||||
|
|
||||||
|
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -58,21 +63,14 @@ import java.util.logging.Logger;
|
|||||||
* The implementation of the Multiverse-{@link Core}.
|
* The implementation of the Multiverse-{@link Core}.
|
||||||
*/
|
*/
|
||||||
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
private static final int PROTOCOL = 12;
|
private static final int PROTOCOL = 13;
|
||||||
// Global Multiverse config variable, states whether or not
|
// TODO: Investigate if this one is really needed to be static.
|
||||||
// Multiverse should stop other plugins from teleporting players
|
// Doubt it. -- FernFerret
|
||||||
// to worlds.
|
private static Map<String, String> teleportQueue = new HashMap<String, String>();
|
||||||
// TODO This is REALLY bad style! We have to change this!
|
|
||||||
// No, I'm NOT going to suppress these warnings because we HAVE TO CHANGE THIS!
|
|
||||||
public static boolean EnforceAccess;
|
|
||||||
public static boolean PrefixChat;
|
|
||||||
public static boolean DisplayPermErrors;
|
|
||||||
public static boolean TeleportIntercept;
|
|
||||||
public static boolean FirstSpawnOverride;
|
|
||||||
public static Map<String, String> teleportQueue = new HashMap<String, String>();
|
|
||||||
public static int GlobalDebug = 0;
|
|
||||||
|
|
||||||
private AnchorManager anchorManager = new AnchorManager(this);
|
private AnchorManager anchorManager = new AnchorManager(this);
|
||||||
|
// TODO please let's make this non-static
|
||||||
|
private static MultiverseCoreConfiguration config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to find out who is teleporting a player.
|
* This method is used to find out who is teleporting a player.
|
||||||
@ -153,8 +151,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
private MVEntityListener entityListener = new MVEntityListener(this);
|
private MVEntityListener entityListener = new MVEntityListener(this);
|
||||||
private MVPluginListener pluginListener = new MVPluginListener(this);
|
private MVPluginListener pluginListener = new MVPluginListener(this);
|
||||||
private MVWeatherListener weatherListener = new MVWeatherListener(this);
|
private MVWeatherListener weatherListener = new MVWeatherListener(this);
|
||||||
|
private MVPortalListener portalListener = new MVPortalListener(this);
|
||||||
//public UpdateChecker updateCheck;
|
|
||||||
|
|
||||||
// HashMap to contain information relating to the Players.
|
// HashMap to contain information relating to the Players.
|
||||||
private HashMap<String, MVPlayerSession> playerSessions;
|
private HashMap<String, MVPlayerSession> playerSessions;
|
||||||
@ -163,8 +160,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
private int pluginCount;
|
private int pluginCount;
|
||||||
private DestinationFactory destFactory;
|
private DestinationFactory destFactory;
|
||||||
private SpoutInterface spoutInterface = null;
|
private SpoutInterface spoutInterface = null;
|
||||||
private static final double ALLPAY_VERSION = 5;
|
|
||||||
private static final double CH_VERSION = 4;
|
|
||||||
private MultiverseMessaging messaging;
|
private MultiverseMessaging messaging;
|
||||||
private BlockSafety blockSafety;
|
private BlockSafety blockSafety;
|
||||||
private LocationManipulation locationManipulation;
|
private LocationManipulation locationManipulation;
|
||||||
@ -174,6 +169,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
// Register our config
|
||||||
|
SerializationConfig.registerAll(MultiverseCoreConfiguration.class);
|
||||||
// Create our DataFolder
|
// Create our DataFolder
|
||||||
getDataFolder().mkdirs();
|
getDataFolder().mkdirs();
|
||||||
// Setup our Debug Log
|
// Setup our Debug Log
|
||||||
@ -188,8 +185,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
* @deprecated This is deprecated.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Deprecated
|
||||||
public FileConfiguration getMVConfiguration() {
|
public FileConfiguration getMVConfiguration() {
|
||||||
return this.multiverseConfig;
|
return this.multiverseConfig;
|
||||||
}
|
}
|
||||||
@ -207,12 +206,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
//this.worldManager = new WorldManager(this);
|
|
||||||
// Perform initial checks for AllPay
|
|
||||||
if (!this.validateAllpay() || !this.validateCH()) {
|
|
||||||
this.getServer().getPluginManager().disablePlugin(this);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.messaging = new MVMessaging();
|
this.messaging = new MVMessaging();
|
||||||
this.banker = new AllPay(this, LOG_TAG + " ");
|
this.banker = new AllPay(this, LOG_TAG + " ");
|
||||||
// Output a little snippet to show it's enabled.
|
// Output a little snippet to show it's enabled.
|
||||||
@ -253,12 +246,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
this.anchorManager.loadAnchors();
|
this.anchorManager.loadAnchors();
|
||||||
|
|
||||||
// Now set the firstspawnworld (after the worlds are loaded):
|
// Now set the firstspawnworld (after the worlds are loaded):
|
||||||
// Default as the server.props world.
|
this.worldManager.setFirstSpawnWorld(config.getFirstSpawnWorld());
|
||||||
this.worldManager.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld", getDefaultWorldName()));
|
|
||||||
// We have to set this one here, if it's not present, we don't know the name of the default world.
|
|
||||||
// and this one won't be in the defaults yml file.
|
|
||||||
try {
|
try {
|
||||||
this.multiverseConfig.set("firstspawnworld", this.worldManager.getFirstSpawnWorld().getName());
|
config.setFirstSpawnWorld(this.worldManager.getFirstSpawnWorld().getName());
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
// A test that had no worlds loaded was being run. This should never happen in production
|
// A test that had no worlds loaded was being run. This should never happen in production
|
||||||
}
|
}
|
||||||
@ -270,40 +260,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateAllpay() {
|
|
||||||
try {
|
|
||||||
this.banker = new AllPay(this, "Verify");
|
|
||||||
if (this.banker.getVersion() >= ALLPAY_VERSION) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Throwable t) {
|
|
||||||
}
|
|
||||||
LOGGER.info(String.format("%s - Version %s was NOT ENABLED!!!", LOG_TAG, this.getDescription().getVersion()));
|
|
||||||
LOGGER.info(String.format("%s A plugin that has loaded before %s has an incompatible version of AllPay (an internal library)!",
|
|
||||||
LOG_TAG, this.getDescription().getName()));
|
|
||||||
LOGGER.info(String.format("%s The Following Plugins MAY out of date: %s", LOG_TAG, AllPay.pluginsThatUseUs.toString()));
|
|
||||||
LOGGER.info(String.format("%s This plugin needs AllPay v%f or higher and another plugin has loaded v%f!",
|
|
||||||
LOG_TAG, ALLPAY_VERSION, this.banker.getVersion()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean validateCH() {
|
|
||||||
try {
|
|
||||||
this.commandHandler = new CommandHandler(this, null);
|
|
||||||
if (this.commandHandler.getVersion() >= CH_VERSION) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (Throwable t) {
|
|
||||||
}
|
|
||||||
LOGGER.info(String.format("%s - Version %s was NOT ENABLED!!!", LOG_TAG, this.getDescription().getVersion()));
|
|
||||||
LOGGER.info(String.format("%s A plugin that has loaded before %s has an incompatible version of CommandHandler (an internal library)!",
|
|
||||||
LOG_TAG, this.getDescription().getName()));
|
|
||||||
LOGGER.info(String.format("%s Please contact this plugin author!!!", LOG_TAG));
|
|
||||||
LOGGER.info(String.format("%s This plugin needs CommandHandler v%f or higher and another plugin has loaded v%f!",
|
|
||||||
LOG_TAG, CH_VERSION, this.commandHandler.getVersion()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeDestinationFactory() {
|
private void initializeDestinationFactory() {
|
||||||
this.destFactory = new DestinationFactory(this);
|
this.destFactory = new DestinationFactory(this);
|
||||||
this.destFactory.registerDestinationType(WorldDestination.class, "");
|
this.destFactory.registerDestinationType(WorldDestination.class, "");
|
||||||
@ -324,6 +280,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
pm.registerEvents(this.entityListener, this);
|
pm.registerEvents(this.entityListener, this);
|
||||||
pm.registerEvents(this.pluginListener, this);
|
pm.registerEvents(this.pluginListener, this);
|
||||||
pm.registerEvents(this.weatherListener, this);
|
pm.registerEvents(this.weatherListener, this);
|
||||||
|
pm.registerEvents(this.portalListener, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -335,46 +293,80 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
||||||
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
|
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
|
||||||
this.multiverseConfig.setDefaults(coreDefaults);
|
this.multiverseConfig.setDefaults(coreDefaults);
|
||||||
this.multiverseConfig.options().copyDefaults(true);
|
this.multiverseConfig.options().copyDefaults(false);
|
||||||
this.saveMVConfig();
|
this.multiverseConfig.options().copyHeader(true);
|
||||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
|
||||||
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
||||||
|
|
||||||
// Setup the Debug option, we'll default to false because this option will not be in the default config.
|
MultiverseCoreConfiguration wantedConfig = null;
|
||||||
GlobalDebug = this.multiverseConfig.getInt("debug", 0);
|
try {
|
||||||
// Lets cache these values due to the fact that they will be accessed many times.
|
wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration");
|
||||||
EnforceAccess = this.multiverseConfig.getBoolean("enforceaccess", false);
|
} catch (Exception e) {
|
||||||
PrefixChat = this.multiverseConfig.getBoolean("worldnameprefix", true);
|
// We're just thinking "no risk no fun" and therefore have to catch and forget this exception
|
||||||
// Should MV Intercept teleports by other plugins?
|
} finally {
|
||||||
TeleportIntercept = this.multiverseConfig.getBoolean("teleportintercept", true);
|
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
||||||
// Should MV do the first spawn stuff?
|
}
|
||||||
FirstSpawnOverride = this.multiverseConfig.getBoolean("firstspawnoverride", true);
|
|
||||||
// Should permissions errors display to users?
|
|
||||||
DisplayPermErrors = this.multiverseConfig.getBoolean("displaypermerrors", true);
|
|
||||||
|
|
||||||
this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
this.messaging.setCooldown(config.getMessageCooldown());
|
||||||
// Update the version of the config!
|
|
||||||
this.multiverseConfig.set("version", coreDefaults.get("version"));
|
|
||||||
|
|
||||||
// Remove old values.
|
// Remove old values.
|
||||||
this.multiverseConfig.set("enforcegamemodes", null);
|
this.multiverseConfig.set("enforcegamemodes", null);
|
||||||
this.multiverseConfig.set("bedrespawn", null);
|
this.multiverseConfig.set("bedrespawn", null);
|
||||||
this.multiverseConfig.set("opfallback", null);
|
this.multiverseConfig.set("opfallback", null);
|
||||||
|
|
||||||
|
// Old Config Format
|
||||||
|
this.migrate22Values();
|
||||||
this.saveMVConfigs();
|
this.saveMVConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Safely return a world name.
|
* Thes are the MV config 2.0-2.2 values,
|
||||||
* (The tests call this with no worlds loaded)
|
* they should be migrated to the new format.
|
||||||
*
|
|
||||||
* @return The default world name.
|
|
||||||
*/
|
*/
|
||||||
private String getDefaultWorldName() {
|
private void migrate22Values() {
|
||||||
if (this.getServer().getWorlds().size() > 0) {
|
if (this.multiverseConfig.isSet("worldnameprefix")) {
|
||||||
return this.getServer().getWorlds().get(0).getName();
|
this.log(Level.INFO, "Migrating 'worldnameprefix'...");
|
||||||
|
this.config.setPrefixChat(this.multiverseConfig.getBoolean("worldnameprefix"));
|
||||||
|
this.multiverseConfig.set("worldnameprefix", null);
|
||||||
|
}
|
||||||
|
if (this.multiverseConfig.isSet("firstspawnworld")) {
|
||||||
|
this.log(Level.INFO, "Migrating 'firstspawnworld'...");
|
||||||
|
this.config.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld"));
|
||||||
|
this.multiverseConfig.set("firstspawnworld", null);
|
||||||
|
}
|
||||||
|
if (this.multiverseConfig.isSet("enforceaccess")) {
|
||||||
|
this.log(Level.INFO, "Migrating 'enforceaccess'...");
|
||||||
|
this.config.setEnforceAccess(this.multiverseConfig.getBoolean("enforceaccess"));
|
||||||
|
this.multiverseConfig.set("enforceaccess", null);
|
||||||
|
}
|
||||||
|
if (this.multiverseConfig.isSet("displaypermerrors")) {
|
||||||
|
this.log(Level.INFO, "Migrating 'displaypermerrors'...");
|
||||||
|
this.config.setDisplayPermErrors(this.multiverseConfig.getBoolean("displaypermerrors"));
|
||||||
|
this.multiverseConfig.set("displaypermerrors", null);
|
||||||
|
}
|
||||||
|
if (this.multiverseConfig.isSet("teleportintercept")) {
|
||||||
|
this.log(Level.INFO, "Migrating 'teleportintercept'...");
|
||||||
|
this.config.setTeleportIntercept(this.multiverseConfig.getBoolean("teleportintercept"));
|
||||||
|
this.multiverseConfig.set("teleportintercept", null);
|
||||||
|
}
|
||||||
|
if (this.multiverseConfig.isSet("firstspawnoverride")) {
|
||||||
|
this.log(Level.INFO, "Migrating 'firstspawnoverride'...");
|
||||||
|
this.config.setFirstSpawnOverride(this.multiverseConfig.getBoolean("firstspawnoverride"));
|
||||||
|
this.multiverseConfig.set("firstspawnoverride", null);
|
||||||
|
}
|
||||||
|
if (this.multiverseConfig.isSet("messagecooldown")) {
|
||||||
|
this.log(Level.INFO, "Migrating 'messagecooldown'...");
|
||||||
|
this.config.setMessageCooldown(this.multiverseConfig.getInt("messagecooldown"));
|
||||||
|
this.multiverseConfig.set("messagecooldown", null);
|
||||||
|
}
|
||||||
|
if (this.multiverseConfig.isSet("debug")) {
|
||||||
|
this.log(Level.INFO, "Migrating 'debug'...");
|
||||||
|
this.config.setGlobalDebug(this.multiverseConfig.getInt("debug"));
|
||||||
|
this.multiverseConfig.set("debug", null);
|
||||||
|
}
|
||||||
|
if (this.multiverseConfig.isSet("version")) {
|
||||||
|
this.log(Level.INFO, "Migrating 'version'...");
|
||||||
|
this.multiverseConfig.set("version", null);
|
||||||
}
|
}
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -444,7 +436,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
if (this.playerSessions.containsKey(player.getName())) {
|
if (this.playerSessions.containsKey(player.getName())) {
|
||||||
return this.playerSessions.get(player.getName());
|
return this.playerSessions.get(player.getName());
|
||||||
} else {
|
} else {
|
||||||
this.playerSessions.put(player.getName(), new MVPlayerSession(player, this.multiverseConfig, this));
|
this.playerSessions.put(player.getName(), new MVPlayerSession(player, config));
|
||||||
return this.playerSessions.get(player.getName());
|
return this.playerSessions.get(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -479,7 +471,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
}
|
}
|
||||||
ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args));
|
ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args));
|
||||||
allArgs.add(0, command.getName());
|
allArgs.add(0, command.getName());
|
||||||
return this.commandHandler.locateAndRunCommand(sender, allArgs, DisplayPermErrors);
|
return this.commandHandler.locateAndRunCommand(sender, allArgs, config.getDisplayPermErrors());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -497,13 +489,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
* @param msg The message to log.
|
* @param msg The message to log.
|
||||||
*/
|
*/
|
||||||
public static void staticLog(Level level, String msg) {
|
public static void staticLog(Level level, String msg) {
|
||||||
if (level == Level.FINE && GlobalDebug >= 1) {
|
if (level == Level.FINE && config.getGlobalDebug() >= 1) {
|
||||||
staticDebugLog(Level.INFO, msg);
|
staticDebugLog(Level.INFO, msg);
|
||||||
return;
|
return;
|
||||||
} else if (level == Level.FINER && GlobalDebug >= 2) {
|
} else if (level == Level.FINER && config.getGlobalDebug() >= 2) {
|
||||||
staticDebugLog(Level.INFO, msg);
|
staticDebugLog(Level.INFO, msg);
|
||||||
return;
|
return;
|
||||||
} else if (level == Level.FINEST && GlobalDebug >= 3) {
|
} else if (level == Level.FINEST && config.getGlobalDebug() >= 3) {
|
||||||
staticDebugLog(Level.INFO, msg);
|
staticDebugLog(Level.INFO, msg);
|
||||||
return;
|
return;
|
||||||
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
|
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
|
||||||
@ -729,6 +721,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
*/
|
*/
|
||||||
public boolean saveMVConfig() {
|
public boolean saveMVConfig() {
|
||||||
try {
|
try {
|
||||||
|
this.multiverseConfig.set("multiverse-configuration", config);
|
||||||
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
|
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -854,4 +847,22 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
public void setSafeTTeleporter(SafeTTeleporter safeTTeleporter) {
|
public void setSafeTTeleporter(SafeTTeleporter safeTTeleporter) {
|
||||||
this.safeTTeleporter = safeTTeleporter;
|
this.safeTTeleporter = safeTTeleporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MultiverseCoreConfig getMVConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is currently used by other plugins.
|
||||||
|
* It will be removed in 2.4
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static MultiverseCoreConfiguration getStaticConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,222 @@
|
|||||||
|
package com.onarandombox.MultiverseCore;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||||
|
|
||||||
|
import me.main__.util.SerializationConfig.Property;
|
||||||
|
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our configuration.
|
||||||
|
*/
|
||||||
|
public class MultiverseCoreConfiguration extends SerializationConfig implements MultiverseCoreConfig {
|
||||||
|
@Property
|
||||||
|
private boolean enforceaccess;
|
||||||
|
@Property
|
||||||
|
private boolean prefixchat;
|
||||||
|
@Property
|
||||||
|
private boolean teleportintercept;
|
||||||
|
@Property
|
||||||
|
private boolean firstspawnoverride;
|
||||||
|
@Property
|
||||||
|
private boolean displaypermerrors;
|
||||||
|
@Property
|
||||||
|
private int globaldebug;
|
||||||
|
@Property
|
||||||
|
private int messagecooldown;
|
||||||
|
@Property
|
||||||
|
private double version;
|
||||||
|
@Property
|
||||||
|
private String firstspawnworld;
|
||||||
|
@Property
|
||||||
|
private int teleportcooldown;
|
||||||
|
|
||||||
|
public MultiverseCoreConfiguration() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiverseCoreConfiguration(Map<String, Object> values) {
|
||||||
|
super(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setDefaults() {
|
||||||
|
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||||
|
enforceaccess = false;
|
||||||
|
prefixchat = true;
|
||||||
|
teleportintercept = true;
|
||||||
|
firstspawnoverride = true;
|
||||||
|
displaypermerrors = true;
|
||||||
|
globaldebug = 0;
|
||||||
|
messagecooldown = 5000;
|
||||||
|
teleportcooldown = 1000;
|
||||||
|
this.version = 2.9;
|
||||||
|
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
// And here we go:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean getEnforceAccess() {
|
||||||
|
return this.enforceaccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setEnforceAccess(boolean enforceAccess) {
|
||||||
|
this.enforceaccess = enforceAccess;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean getPrefixChat() {
|
||||||
|
return this.prefixchat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setPrefixChat(boolean prefixChat) {
|
||||||
|
this.prefixchat = prefixChat;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean getTeleportIntercept() {
|
||||||
|
return this.teleportintercept;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setTeleportIntercept(boolean teleportIntercept) {
|
||||||
|
this.teleportintercept = teleportIntercept;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean getFirstSpawnOverride() {
|
||||||
|
return this.firstspawnoverride;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setFirstSpawnOverride(boolean firstSpawnOverride) {
|
||||||
|
this.firstspawnoverride = firstSpawnOverride;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean getDisplayPermErrors() {
|
||||||
|
return this.displaypermerrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setDisplayPermErrors(boolean displayPermErrors) {
|
||||||
|
this.displaypermerrors = displayPermErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getGlobalDebug() {
|
||||||
|
return this.globaldebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setGlobalDebug(int globalDebug) {
|
||||||
|
this.globaldebug = globalDebug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getMessageCooldown() {
|
||||||
|
return this.messagecooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setMessageCooldown(int messageCooldown) {
|
||||||
|
this.messagecooldown = messageCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public double getVersion() {
|
||||||
|
return this.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setVersion(int version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getFirstSpawnWorld() {
|
||||||
|
return this.firstspawnworld;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setFirstSpawnWorld(String firstSpawnWorld) {
|
||||||
|
this.firstspawnworld = firstSpawnWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getTeleportCooldown() {
|
||||||
|
return this.teleportcooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setTeleportCooldown(int teleportCooldown) {
|
||||||
|
this.teleportcooldown = teleportCooldown;
|
||||||
|
}
|
||||||
|
}
|
@ -26,7 +26,9 @@ public interface Core {
|
|||||||
* Gets the Multiverse config file.
|
* Gets the Multiverse config file.
|
||||||
*
|
*
|
||||||
* @return The Multiverse config file.
|
* @return The Multiverse config file.
|
||||||
|
* @deprecated Don't modify the config-file manually!
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
FileConfiguration getMVConfiguration();
|
FileConfiguration getMVConfiguration();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -215,4 +217,9 @@ public interface Core {
|
|||||||
*/
|
*/
|
||||||
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
|
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the {@link MultiverseCoreConfig}.
|
||||||
|
* @return The configuration.
|
||||||
|
*/
|
||||||
|
MultiverseCoreConfig getMVConfig();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,136 @@
|
|||||||
|
package com.onarandombox.MultiverseCore.api;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configuration of MultiverseCore.
|
||||||
|
*/
|
||||||
|
public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||||
|
/**
|
||||||
|
* Sets a property using a {@link String}.
|
||||||
|
* @param property The name of the property.
|
||||||
|
* @param value The value.
|
||||||
|
* @return True on success, false if the operation failed.
|
||||||
|
*/
|
||||||
|
boolean setProperty(String property, String value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets portalCooldown.
|
||||||
|
* @param portalCooldown The new value.
|
||||||
|
*/
|
||||||
|
void setTeleportCooldown(int portalCooldown);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets portalCooldown.
|
||||||
|
* @return portalCooldown.
|
||||||
|
*/
|
||||||
|
int getTeleportCooldown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets firstSpawnWorld.
|
||||||
|
* @param firstSpawnWorld The new value.
|
||||||
|
*/
|
||||||
|
void setFirstSpawnWorld(String firstSpawnWorld);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets firstSpawnWorld.
|
||||||
|
* @return firstSpawnWorld.
|
||||||
|
*/
|
||||||
|
String getFirstSpawnWorld();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets version.
|
||||||
|
* @param version The new value.
|
||||||
|
*/
|
||||||
|
void setVersion(int version);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets version.
|
||||||
|
* @return version.
|
||||||
|
*/
|
||||||
|
double getVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets messageCooldown.
|
||||||
|
* @param messageCooldown The new value.
|
||||||
|
*/
|
||||||
|
void setMessageCooldown(int messageCooldown);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets messageCooldown.
|
||||||
|
* @return messageCooldown.
|
||||||
|
*/
|
||||||
|
int getMessageCooldown();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets globalDebug.
|
||||||
|
* @param globalDebug The new value.
|
||||||
|
*/
|
||||||
|
void setGlobalDebug(int globalDebug);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets globalDebug.
|
||||||
|
* @return globalDebug.
|
||||||
|
*/
|
||||||
|
int getGlobalDebug();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets displayPermErrors.
|
||||||
|
* @param displayPermErrors The new value.
|
||||||
|
*/
|
||||||
|
void setDisplayPermErrors(boolean displayPermErrors);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets displayPermErrors.
|
||||||
|
* @return displayPermErrors.
|
||||||
|
*/
|
||||||
|
boolean getDisplayPermErrors();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets firstSpawnOverride.
|
||||||
|
* @param firstSpawnOverride The new value.
|
||||||
|
*/
|
||||||
|
void setFirstSpawnOverride(boolean firstSpawnOverride);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets firstSpawnOverride.
|
||||||
|
* @return firstSpawnOverride.
|
||||||
|
*/
|
||||||
|
boolean getFirstSpawnOverride();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets teleportIntercept.
|
||||||
|
* @param teleportIntercept The new value.
|
||||||
|
*/
|
||||||
|
void setTeleportIntercept(boolean teleportIntercept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets teleportIntercept.
|
||||||
|
* @return teleportIntercept.
|
||||||
|
*/
|
||||||
|
boolean getTeleportIntercept();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets prefixChat.
|
||||||
|
* @param prefixChat The new value.
|
||||||
|
*/
|
||||||
|
void setPrefixChat(boolean prefixChat);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets prefixChat.
|
||||||
|
* @return prefixChat.
|
||||||
|
*/
|
||||||
|
boolean getPrefixChat();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets enforceAccess.
|
||||||
|
* @param enforceAccess The new value.
|
||||||
|
*/
|
||||||
|
void setEnforceAccess(boolean enforceAccess);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets enforceAccess.
|
||||||
|
* @return enforceAccess.
|
||||||
|
*/
|
||||||
|
boolean getEnforceAccess();
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
package com.onarandombox.MultiverseCore.api;
|
package com.onarandombox.MultiverseCore.api;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
|
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
|
||||||
|
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -573,4 +574,18 @@ public interface MultiverseWorld {
|
|||||||
* @return The Type of this world.
|
* @return The Type of this world.
|
||||||
*/
|
*/
|
||||||
WorldType getWorldType();
|
WorldType getWorldType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets The types of portals that are allowed in this world.
|
||||||
|
*
|
||||||
|
* @param type The type of portals allowed in this world.
|
||||||
|
*/
|
||||||
|
void allowPortalMaking(AllowedPortalType type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets which type(s) of portals are allowed to be constructed in this world.
|
||||||
|
*
|
||||||
|
* @return The type of portals that are allowed.
|
||||||
|
*/
|
||||||
|
AllowedPortalType getAllowedPortals();
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,12 @@
|
|||||||
package com.onarandombox.MultiverseCore.commands;
|
package com.onarandombox.MultiverseCore.commands;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.enums.ConfigProperty;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.permissions.PermissionDefault;
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows you to set Global MV Variables.
|
* Allows you to set Global MV Variables.
|
||||||
@ -28,7 +28,6 @@ public class ConfigCommand extends MultiverseCommand {
|
|||||||
this.addKey("mvconfig");
|
this.addKey("mvconfig");
|
||||||
this.addKey("mv conf");
|
this.addKey("mv conf");
|
||||||
this.addKey("mvconf");
|
this.addKey("mvconf");
|
||||||
this.addCommandExample("All values: " + ConfigProperty.getAllValues());
|
|
||||||
this.addCommandExample("/mv config show");
|
this.addCommandExample("/mv config show");
|
||||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
|
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
|
||||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
|
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
|
||||||
@ -38,55 +37,31 @@ public class ConfigCommand extends MultiverseCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void runCommand(CommandSender sender, List<String> args) {
|
public void runCommand(CommandSender sender, List<String> args) {
|
||||||
if (args.size() <= 1) {
|
if (args.size() <= 1) {
|
||||||
String[] allProps = ConfigProperty.getAllValues().split(" ");
|
StringBuilder builder = new StringBuilder();
|
||||||
String currentvals = "";
|
Map<String, Object> serializedConfig = this.plugin.getMVConfig().serialize();
|
||||||
for (String prop : allProps) {
|
for (Map.Entry<String, Object> entry : serializedConfig.entrySet()) {
|
||||||
currentvals += ChatColor.GREEN;
|
builder.append(ChatColor.GREEN);
|
||||||
currentvals += prop;
|
builder.append(entry.getKey());
|
||||||
currentvals += ChatColor.WHITE;
|
builder.append(ChatColor.WHITE).append(" = ").append(ChatColor.GOLD);
|
||||||
currentvals += " = ";
|
builder.append(entry.getValue().toString());
|
||||||
currentvals += ChatColor.GOLD;
|
builder.append(ChatColor.WHITE).append(", ");
|
||||||
currentvals += this.plugin.getMVConfiguration().get(prop, "NOT SET");
|
|
||||||
currentvals += ChatColor.WHITE;
|
|
||||||
currentvals += ", ";
|
|
||||||
}
|
}
|
||||||
sender.sendMessage(currentvals.substring(0, currentvals.length() - 2));
|
String message = builder.toString();
|
||||||
|
message = message.substring(0, message.length() - 2);
|
||||||
|
sender.sendMessage(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!this.plugin.getMVConfig().setProperty(args.get(0).toLowerCase(), args.get(1))) {
|
||||||
|
sender.sendMessage(String.format("%sSetting '%s' to '%s' failed!", ChatColor.RED, args.get(0).toLowerCase(), args.get(1)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// special rule
|
||||||
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
|
if (args.get(0).equalsIgnoreCase("firstspawnworld")) {
|
||||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), args.get(1));
|
|
||||||
// Don't forget to set the world!
|
// Don't forget to set the world!
|
||||||
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
|
this.plugin.getMVWorldManager().setFirstSpawnWorld(args.get(1));
|
||||||
} else if (args.get(0).equalsIgnoreCase("messagecooldown") || args.get(0).equalsIgnoreCase("teleportcooldown")
|
|
||||||
|| args.get(0).equalsIgnoreCase("debug")) {
|
|
||||||
try {
|
|
||||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Integer.parseInt(args.get(1)));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be an integer!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ConfigProperty property = null;
|
|
||||||
try {
|
|
||||||
property = ConfigProperty.valueOf(args.get(0).toLowerCase());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA
|
|
||||||
+ args.get(0) + ChatColor.WHITE + " you can't set " + ChatColor.AQUA + args.get(0));
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Valid values are:");
|
|
||||||
sender.sendMessage(ConfigProperty.getAllValues());
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property != null) {
|
|
||||||
try {
|
|
||||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), Boolean.parseBoolean(args.get(1)));
|
|
||||||
} catch (Exception e) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Sorry, " + ChatColor.AQUA + args.get(0) + ChatColor.WHITE + " must be true or false!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.plugin.saveMVConfigs()) {
|
if (this.plugin.saveMVConfigs()) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
|
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
|
||||||
this.plugin.loadConfigs();
|
this.plugin.loadConfigs();
|
||||||
|
@ -29,7 +29,8 @@ public class CreateCommand extends MultiverseCommand {
|
|||||||
public CreateCommand(MultiverseCore plugin) {
|
public CreateCommand(MultiverseCore plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.setName("Create World");
|
this.setName("Create World");
|
||||||
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n] -a [true|false]");
|
this.setCommandUsage(String.format("/mv create %s{NAME} {ENV} %s-s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n] -a [true|false]",
|
||||||
|
ChatColor.GREEN, ChatColor.GOLD));
|
||||||
this.setArgRange(2, 11); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
this.setArgRange(2, 11); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||||
this.addKey("mvcreate");
|
this.addKey("mvcreate");
|
||||||
this.addKey("mvc");
|
this.addKey("mvc");
|
||||||
|
@ -36,14 +36,14 @@ public class DebugCommand extends MultiverseCommand {
|
|||||||
public void runCommand(CommandSender sender, List<String> args) {
|
public void runCommand(CommandSender sender, List<String> args) {
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
if (args.get(0).equalsIgnoreCase("off")) {
|
if (args.get(0).equalsIgnoreCase("off")) {
|
||||||
MultiverseCore.GlobalDebug = 0;
|
plugin.getMVConfig().setGlobalDebug(0);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
int debugLevel = Integer.parseInt(args.get(0));
|
int debugLevel = Integer.parseInt(args.get(0));
|
||||||
if (debugLevel > 3 || debugLevel < 0) {
|
if (debugLevel > 3 || debugLevel < 0) {
|
||||||
throw new NumberFormatException();
|
throw new NumberFormatException();
|
||||||
}
|
}
|
||||||
MultiverseCore.GlobalDebug = debugLevel;
|
plugin.getMVConfig().setGlobalDebug(debugLevel);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
|
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
|
||||||
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
||||||
@ -55,10 +55,10 @@ public class DebugCommand extends MultiverseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void displayDebugMode(CommandSender sender) {
|
private void displayDebugMode(CommandSender sender) {
|
||||||
if (MultiverseCore.GlobalDebug == 0) {
|
if (plugin.getMVConfig().getGlobalDebug() == 0) {
|
||||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + MultiverseCore.GlobalDebug);
|
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + plugin.getMVConfig().getGlobalDebug());
|
||||||
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ public class EnvironmentCommand extends MultiverseCommand {
|
|||||||
* @return The environment as {@link org.bukkit.World.Environment}
|
* @return The environment as {@link org.bukkit.World.Environment}
|
||||||
*/
|
*/
|
||||||
public static World.Environment getEnvFromString(String env) {
|
public static World.Environment getEnvFromString(String env) {
|
||||||
|
env = env.toUpperCase();
|
||||||
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
// Don't reference the enum directly as there aren't that many, and we can be more forgiving to users this way
|
||||||
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
|
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
|
||||||
env = "NETHER";
|
env = "NETHER";
|
||||||
|
@ -34,7 +34,7 @@ public class ImportCommand extends MultiverseCommand {
|
|||||||
super(plugin);
|
super(plugin);
|
||||||
this.setName("Import World");
|
this.setName("Import World");
|
||||||
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n] -t [TYPE] -a [true|false]");
|
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n] -t [TYPE] -a [true|false]");
|
||||||
this.setArgRange(2, 5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
this.setArgRange(1, 9); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||||
this.addKey("mvimport");
|
this.addKey("mvimport");
|
||||||
this.addKey("mvim");
|
this.addKey("mvim");
|
||||||
this.addKey("mv import");
|
this.addKey("mv import");
|
||||||
|
@ -61,9 +61,13 @@ public class InfoCommand extends MultiverseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (args.size() == 1) {
|
} else if (args.size() == 1) {
|
||||||
if (this.worldManager.getMVWorld(args.get(0)) != null) {
|
if (this.worldManager.isMVWorld(args.get(0))) {
|
||||||
// then we have a world!
|
// then we have a world!
|
||||||
worldName = args.get(0);
|
worldName = args.get(0);
|
||||||
|
} else if(this.worldManager.getUnloadedWorlds().contains(args.get(0))){
|
||||||
|
sender.sendMessage("That world exists, but it is unloaded!");
|
||||||
|
sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, args.get(0)));
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
@ -93,8 +97,11 @@ public class InfoCommand extends MultiverseCommand {
|
|||||||
p = (Player) sender;
|
p = (Player) sender;
|
||||||
}
|
}
|
||||||
showPage(pageNum, sender, this.buildEntireCommand(this.worldManager.getMVWorld(worldName), p));
|
showPage(pageNum, sender, this.buildEntireCommand(this.worldManager.getMVWorld(worldName), p));
|
||||||
|
} else if (this.worldManager.getUnloadedWorlds().contains(worldName)) {
|
||||||
|
sender.sendMessage("That world exists, but it is unloaded!");
|
||||||
|
sender.sendMessage(String.format("You can load it with: %s/mv load %s", ChatColor.AQUA, worldName));
|
||||||
} else if (this.plugin.getServer().getWorld(worldName) != null) {
|
} else if (this.plugin.getServer().getWorld(worldName) != null) {
|
||||||
sender.sendMessage("That world exists, but multiverse does not know about it!");
|
sender.sendMessage("That world exists, but Multiverse does not know about it!");
|
||||||
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
|
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
|
||||||
sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
|
sender.sendMessage("For available environments type " + ChatColor.GREEN + "/mv env");
|
||||||
}
|
}
|
||||||
|
@ -52,14 +52,16 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
|||||||
} else if (env == Environment.THE_END) {
|
} else if (env == Environment.THE_END) {
|
||||||
color = ChatColor.AQUA;
|
color = ChatColor.AQUA;
|
||||||
}
|
}
|
||||||
String outputCache = world.getColoredWorldString() + ChatColor.WHITE + " - " + color + world.getEnvironment();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append(world.getColoredWorldString()).append(ChatColor.WHITE);
|
||||||
|
builder.append(" - ").append(color).append(world.getEnvironment());
|
||||||
if (world.isHidden()) {
|
if (world.isHidden()) {
|
||||||
if (p == null || p.hasPermission("multiverse.core.modify")) {
|
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.core.modify", true)) {
|
||||||
// Prefix hidden worlds with an "[H]"
|
// Prefix hidden worlds with an "[H]"
|
||||||
worldList.add(ChatColor.GRAY + "[H]" + outputCache);
|
worldList.add(ChatColor.GRAY + "[H]" + builder.toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
worldList.add(outputCache);
|
worldList.add(builder.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
|
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
|
||||||
|
@ -110,7 +110,7 @@ public class TeleportCommand extends MultiverseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MultiverseCore.EnforceAccess && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
|
if (plugin.getMVConfig().getEnforceAccess() && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
|
||||||
if (teleportee.equals(teleporter)) {
|
if (teleportee.equals(teleporter)) {
|
||||||
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
||||||
} else {
|
} else {
|
||||||
|
@ -53,16 +53,16 @@ public class VersionCommand extends MultiverseCommand {
|
|||||||
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
|
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n');
|
buffer.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] Dumping Config Values: (version ")
|
buffer.append("[Multiverse-Core] Dumping Config Values: (version ")
|
||||||
.append(this.plugin.getMVConfiguration().getDouble("version", -1)).append(")").append('\n');
|
.append(this.plugin.getMVConfig().getVersion()).append(")").append('\n');
|
||||||
buffer.append("[Multiverse-Core] messagecooldown: ").append(this.plugin.getMessaging().getCooldown()).append('\n');
|
buffer.append("[Multiverse-Core] messagecooldown: ").append(plugin.getMessaging().getCooldown()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] teleportcooldown: ").append("Not yet IMPLEMENTED").append('\n');
|
buffer.append("[Multiverse-Core] teleportcooldown: ").append(plugin.getMVConfig().getTeleportCooldown()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] worldnameprefix: ").append(MultiverseCore.PrefixChat).append('\n');
|
buffer.append("[Multiverse-Core] worldnameprefix: ").append(plugin.getMVConfig().getPrefixChat()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] enforceaccess: ").append(MultiverseCore.EnforceAccess).append('\n');
|
buffer.append("[Multiverse-Core] enforceaccess: ").append(plugin.getMVConfig().getEnforceAccess()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] displaypermerrors: ").append(MultiverseCore.DisplayPermErrors).append('\n');
|
buffer.append("[Multiverse-Core] displaypermerrors: ").append(plugin.getMVConfig().getDisplayPermErrors()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] teleportintercept: ").append(MultiverseCore.TeleportIntercept).append('\n');
|
buffer.append("[Multiverse-Core] teleportintercept: ").append(plugin.getMVConfig().getTeleportIntercept()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] firstspawnoverride: ").append(MultiverseCore.FirstSpawnOverride).append('\n');
|
buffer.append("[Multiverse-Core] firstspawnoverride: ").append(plugin.getMVConfig().getFirstSpawnOverride()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] firstspawnworld: ").append(this.plugin.getMVConfiguration().getString("firstspawnworld", "NOT SET")).append('\n');
|
buffer.append("[Multiverse-Core] firstspawnworld: ").append(plugin.getMVConfig().getFirstSpawnWorld()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] debug: ").append(MultiverseCore.GlobalDebug).append('\n');
|
buffer.append("[Multiverse-Core] debug: ").append(plugin.getMVConfig().getGlobalDebug()).append('\n');
|
||||||
buffer.append("[Multiverse-Core] Special Code: FRN002").append('\n');
|
buffer.append("[Multiverse-Core] Special Code: FRN002").append('\n');
|
||||||
|
|
||||||
MVVersionEvent versionEvent = new MVVersionEvent(buffer.toString());
|
MVVersionEvent versionEvent = new MVVersionEvent(buffer.toString());
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.onarandombox.MultiverseCore.configuration;
|
package com.onarandombox.MultiverseCore.configuration;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||||
import org.bukkit.Difficulty;
|
import org.bukkit.Difficulty;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -233,9 +234,9 @@ public class ConfigPropertyFactory {
|
|||||||
return new GameModeConfigProperty(this.section, name, defaultValue, node, help);
|
return new GameModeConfigProperty(this.section, name, defaultValue, node, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GameMode
|
// Location
|
||||||
/**
|
/**
|
||||||
* Constructs a new ConfigProperty.
|
* Constructs a new LocationConfigProperty.
|
||||||
*
|
*
|
||||||
* @param name The name of this ConfigProperty.
|
* @param name The name of this ConfigProperty.
|
||||||
* @param defaultValue The default-value.
|
* @param defaultValue The default-value.
|
||||||
@ -273,6 +274,19 @@ public class ConfigPropertyFactory {
|
|||||||
return new LocationConfigProperty(this.section, name, defaultValue, node, help, method);
|
return new LocationConfigProperty(this.section, name, defaultValue, node, help, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GameMode
|
||||||
|
/**
|
||||||
|
* Constructs a new ConfigProperty.
|
||||||
|
*
|
||||||
|
* @param name The name of this ConfigProperty.
|
||||||
|
* @param defaultValue The default-value.
|
||||||
|
* @param help The text that's displayed when a user failed to set the property.
|
||||||
|
* @return The ConfigProperty.
|
||||||
|
*/
|
||||||
|
public PortalTypeConfigProperty getNewProperty(String name, AllowedPortalType defaultValue, String help) {
|
||||||
|
return new PortalTypeConfigProperty(this.section, name, defaultValue, help);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new ActiveStringConfigProperty
|
* Constructs a new ActiveStringConfigProperty
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,97 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
package com.onarandombox.MultiverseCore.configuration;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link AllowedPortalType} config-property.
|
||||||
|
*/
|
||||||
|
public class PortalTypeConfigProperty implements MVConfigProperty<AllowedPortalType> {
|
||||||
|
private String name;
|
||||||
|
private AllowedPortalType value;
|
||||||
|
private String configNode;
|
||||||
|
private ConfigurationSection section;
|
||||||
|
private String help;
|
||||||
|
|
||||||
|
public PortalTypeConfigProperty(ConfigurationSection section, String name, AllowedPortalType defaultValue, String help) {
|
||||||
|
this(section, name, defaultValue, name, help);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PortalTypeConfigProperty(ConfigurationSection section, String name, AllowedPortalType defaultValue, String configNode, String help) {
|
||||||
|
this.name = name;
|
||||||
|
this.configNode = configNode;
|
||||||
|
this.section = section;
|
||||||
|
this.help = help;
|
||||||
|
this.value = defaultValue;
|
||||||
|
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AllowedPortalType getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean setValue(AllowedPortalType value) {
|
||||||
|
if (value == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.value = value;
|
||||||
|
this.section.set(configNode, this.value.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean parseValue(String value) {
|
||||||
|
try {
|
||||||
|
return this.setValue(AllowedPortalType.valueOf(value.toUpperCase()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getConfigNode() {
|
||||||
|
return this.configNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getHelp() {
|
||||||
|
return this.help;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
package com.onarandombox.MultiverseCore.enums;
|
||||||
|
|
||||||
|
import org.bukkit.PortalType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom enum that adds all/none for allowing portal creation.
|
||||||
|
*/
|
||||||
|
public enum AllowedPortalType {
|
||||||
|
/**
|
||||||
|
* No portals are allowed.
|
||||||
|
*/
|
||||||
|
NONE(PortalType.CUSTOM),
|
||||||
|
/**
|
||||||
|
* All portal types are allowed.
|
||||||
|
*/
|
||||||
|
ALL(PortalType.CUSTOM),
|
||||||
|
/**
|
||||||
|
* Only Nether style portals are allowed.
|
||||||
|
*/
|
||||||
|
NETHER(PortalType.NETHER),
|
||||||
|
/**
|
||||||
|
* Only Ender style portals are allowed.
|
||||||
|
*/
|
||||||
|
END(PortalType.ENDER);
|
||||||
|
|
||||||
|
private PortalType type;
|
||||||
|
|
||||||
|
AllowedPortalType(PortalType type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the text.
|
||||||
|
* @return The text.
|
||||||
|
*/
|
||||||
|
public PortalType getActualPortalType() {
|
||||||
|
return this.type;
|
||||||
|
}
|
||||||
|
}
|
@ -1,64 +0,0 @@
|
|||||||
/******************************************************************************
|
|
||||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
|
||||||
* Multiverse 2 is licensed under the BSD License. *
|
|
||||||
* For more information please check the README.md file included *
|
|
||||||
* with this project. *
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
package com.onarandombox.MultiverseCore.enums;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An enum containing all config-properties that can be set.
|
|
||||||
*/
|
|
||||||
public enum ConfigProperty {
|
|
||||||
/**
|
|
||||||
* How long to leave in between sending a message to the player. (NOT YET IMPLEMENTED)
|
|
||||||
*/
|
|
||||||
messagecooldown,
|
|
||||||
/**
|
|
||||||
* How fast are people allowed to use /MVTP (NOT YET IMPLEMENTED).
|
|
||||||
*/
|
|
||||||
teleportcooldown,
|
|
||||||
/**
|
|
||||||
* Prefix chat-messages with world-names.
|
|
||||||
*/
|
|
||||||
worldnameprefix,
|
|
||||||
/**
|
|
||||||
* If value is set to false, Multiverse will NOT enforce world access permissions.
|
|
||||||
*/
|
|
||||||
enforceaccess,
|
|
||||||
/**
|
|
||||||
* Whether users should get detailed information about the permissions they would need.
|
|
||||||
*/
|
|
||||||
displaypermerrors,
|
|
||||||
/**
|
|
||||||
* Debug-information.
|
|
||||||
*/
|
|
||||||
debug,
|
|
||||||
/**
|
|
||||||
* The world new users will spawn in.
|
|
||||||
*/
|
|
||||||
firstspawnworld,
|
|
||||||
/**
|
|
||||||
* Whether Multiverse should intercept teleports.
|
|
||||||
*/
|
|
||||||
teleportintercept,
|
|
||||||
/**
|
|
||||||
* Whether Multiverse should override the first spawn.
|
|
||||||
*/
|
|
||||||
firstspawnoverride;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a string containing all values in this enum.
|
|
||||||
*
|
|
||||||
* @return That {@link String}.
|
|
||||||
*/
|
|
||||||
public static String getAllValues() {
|
|
||||||
String buffer = "";
|
|
||||||
for (ConfigProperty c : ConfigProperty.values()) {
|
|
||||||
// All values will NOT Contain spaces.
|
|
||||||
buffer += c.toString() + " ";
|
|
||||||
}
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
}
|
|
@ -55,7 +55,7 @@ public class MVPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
// Check whether the Server is set to prefix the chat with the World name.
|
// Check whether the Server is set to prefix the chat with the World name.
|
||||||
// If not we do nothing, if so we need to check if the World has an Alias.
|
// If not we do nothing, if so we need to check if the World has an Alias.
|
||||||
if (MultiverseCore.PrefixChat) {
|
if (plugin.getMVConfig().getPrefixChat()) {
|
||||||
String world = event.getPlayer().getWorld().getName();
|
String world = event.getPlayer().getWorld().getName();
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
// If we're not a MV world, don't do anything
|
// If we're not a MV world, don't do anything
|
||||||
@ -127,7 +127,7 @@ public class MVPlayerListener implements Listener {
|
|||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
if (!p.hasPlayedBefore()) {
|
if (!p.hasPlayedBefore()) {
|
||||||
this.plugin.log(Level.FINE, "Player joined first!");
|
this.plugin.log(Level.FINE, "Player joined first!");
|
||||||
if (MultiverseCore.FirstSpawnOverride) {
|
if (plugin.getMVConfig().getFirstSpawnOverride()) {
|
||||||
this.plugin.log(Level.FINE, "Moving NEW player to(firstspawnoverride): " + worldManager.getFirstSpawnWorld().getSpawnLocation());
|
this.plugin.log(Level.FINE, "Moving NEW player to(firstspawnoverride): " + worldManager.getFirstSpawnWorld().getSpawnLocation());
|
||||||
this.spawnNewPlayer(p);
|
this.spawnNewPlayer(p);
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ public class MVPlayerListener implements Listener {
|
|||||||
teleportee.getName(), event.getTo().getWorld().getName(), teleporter.getName()));
|
teleportee.getName(), event.getTo().getWorld().getName(), teleporter.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MultiverseCore.EnforceAccess) {
|
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
|
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
|
||||||
if (event.isCancelled() && teleporter != null) {
|
if (event.isCancelled() && teleporter != null) {
|
||||||
this.plugin.log(Level.FINE, String.format("Player '%s' was DENIED ACCESS to '%s' because '%s' don't have: multiverse.access.%s",
|
this.plugin.log(Level.FINE, String.format("Player '%s' was DENIED ACCESS to '%s' because '%s' don't have: multiverse.access.%s",
|
||||||
@ -262,7 +262,7 @@ public class MVPlayerListener implements Listener {
|
|||||||
event.getPlayer().getName(), event.getTo().getWorld().getName()));
|
event.getPlayer().getName(), event.getTo().getWorld().getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MultiverseCore.EnforceAccess) {
|
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
|
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
this.plugin.log(Level.FINE, String.format("Player '%s' was DENIED ACCESS to '%s' because they don't have: multiverse.access.%s",
|
this.plugin.log(Level.FINE, String.format("Player '%s' was DENIED ACCESS to '%s' because they don't have: multiverse.access.%s",
|
||||||
@ -308,7 +308,7 @@ public class MVPlayerListener implements Listener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
// Check that the player is in the new world and they haven't been teleported elsewhere or the event cancelled.
|
// Check that the player is in the new world and they haven't been teleported elsewhere or the event cancelled.
|
||||||
if (player.getWorld() == world.getCBWorld()) {
|
if (player.getWorld() == world.getCBWorld()) {
|
||||||
MultiverseCore.staticLog(Level.FINE, "Handeling gamemode for player: " + player.getName() + ", " + world.getGameMode().toString());
|
MultiverseCore.staticLog(Level.FINE, "Handling gamemode for player: " + player.getName() + ", " + world.getGameMode().toString());
|
||||||
MultiverseCore.staticLog(Level.FINE, "PWorld: " + player.getWorld());
|
MultiverseCore.staticLog(Level.FINE, "PWorld: " + player.getWorld());
|
||||||
MultiverseCore.staticLog(Level.FINE, "AWorld: " + world);
|
MultiverseCore.staticLog(Level.FINE, "AWorld: " + world);
|
||||||
player.setGameMode(world.getGameMode());
|
player.setGameMode(world.getGameMode());
|
||||||
|
@ -36,7 +36,7 @@ public class MVPluginListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void pluginEnable(PluginEnableEvent event) {
|
public void pluginEnable(PluginEnableEvent event) {
|
||||||
// Let AllPay handle all econ plugin loadings, only go for econ plugins we support
|
// Let AllPay handle all econ plugin loadings, only go for econ plugins we support
|
||||||
if (Arrays.asList(AllPay.validEconPlugins).contains(event.getPlugin().getDescription().getName())) {
|
if (Arrays.asList(AllPay.getValidEconPlugins()).contains(event.getPlugin().getDescription().getName())) {
|
||||||
this.plugin.setBank(this.plugin.getBanker().loadEconPlugin());
|
this.plugin.setBank(this.plugin.getBanker().loadEconPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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. *
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
package com.onarandombox.MultiverseCore.listeners;
|
||||||
|
|
||||||
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||||
|
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.PortalType;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityCreatePortalEvent;
|
||||||
|
import org.bukkit.event.world.PortalCreateEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A custom listener for portal related events.
|
||||||
|
*/
|
||||||
|
public class MVPortalListener implements Listener {
|
||||||
|
|
||||||
|
private MultiverseCore plugin;
|
||||||
|
|
||||||
|
public MVPortalListener(MultiverseCore core) {
|
||||||
|
this.plugin = core;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called when an entity creates a portal.
|
||||||
|
*
|
||||||
|
* @param event The event where an entity created a portal.
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void entityPortalCreate(EntityCreatePortalEvent event) {
|
||||||
|
if (event.isCancelled() || event.getBlocks().size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getBlocks().get(0).getWorld());
|
||||||
|
event.setCancelled(this.cancelPortalEvent(world, event.getPortalType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called when a portal is created as the result of another world being linked.
|
||||||
|
* @param event The event where a portal was formed due to a world link
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void portalForm(PortalCreateEvent event) {
|
||||||
|
if (event.isCancelled() || event.getBlocks().size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// There's no type attribute (as of 1.1-R1), so we have to iterate.
|
||||||
|
for (Block b : event.getBlocks()) {
|
||||||
|
if (b.getType() == Material.PORTAL) {
|
||||||
|
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(b.getWorld());
|
||||||
|
event.setCancelled(this.cancelPortalEvent(world, PortalType.NETHER));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If We're here, then the Portal was an Ender type:
|
||||||
|
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getBlocks().get(0).getWorld());
|
||||||
|
event.setCancelled(this.cancelPortalEvent(world, PortalType.ENDER));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean cancelPortalEvent(MultiverseWorld world, PortalType type) {
|
||||||
|
if (world.getAllowedPortals() == AllowedPortalType.NONE) {
|
||||||
|
return true;
|
||||||
|
} else if (world.getAllowedPortals() != AllowedPortalType.ALL) {
|
||||||
|
if (type != world.getAllowedPortals().getActualPortalType()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -98,7 +98,8 @@ public class MVPermissions implements PermissionsInterface {
|
|||||||
*/
|
*/
|
||||||
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
||||||
// If we're not enforcing access, anyone can enter.
|
// If we're not enforcing access, anyone can enter.
|
||||||
if (!MultiverseCore.EnforceAccess) {
|
if (!plugin.getMVConfig().getEnforceAccess()) {
|
||||||
|
this.plugin.log(Level.FINEST, "EnforceAccess is OFF. Player was allowed in " + w.getAlias());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||||
@ -169,9 +170,9 @@ public class MVPermissions implements PermissionsInterface {
|
|||||||
// plugin reloads, when MV asks the API if a player has a perm, it reports that they do NOT.
|
// plugin reloads, when MV asks the API if a player has a perm, it reports that they do NOT.
|
||||||
// For the moment, we're going to check all of this node's parents to see if the user has those. It stops
|
// For the moment, we're going to check all of this node's parents to see if the user has those. It stops
|
||||||
// when if finds a true or there are no more parents. --FF
|
// when if finds a true or there are no more parents. --FF
|
||||||
if (!hasPermission) {
|
// if (!hasPermission) {
|
||||||
hasPermission = this.hasAnyParentPermission(sender, node);
|
// hasPermission = this.hasAnyParentPermission(sender, node);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return hasPermission;
|
return hasPermission;
|
||||||
}
|
}
|
||||||
@ -179,10 +180,12 @@ public class MVPermissions implements PermissionsInterface {
|
|||||||
// TODO: Better player checks, most likely not needed, but safer.
|
// TODO: Better player checks, most likely not needed, but safer.
|
||||||
private boolean checkActualPermission(CommandSender sender, String node) {
|
private boolean checkActualPermission(CommandSender sender, String node) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]");
|
|
||||||
boolean hasPermission = sender.hasPermission(node);
|
boolean hasPermission = sender.hasPermission(node);
|
||||||
if (hasPermission) {
|
if (hasPermission) {
|
||||||
this.plugin.log(Level.FINER, "Player [" + player.getName() + "] HAS PERMISSION [" + node + "]!");
|
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... YES");
|
||||||
|
} else {
|
||||||
|
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... NO");
|
||||||
}
|
}
|
||||||
return hasPermission;
|
return hasPermission;
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
package com.onarandombox.MultiverseCore.utils;
|
package com.onarandombox.MultiverseCore.utils;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCoreConfiguration;
|
||||||
import org.bukkit.configuration.Configuration;
|
|
||||||
|
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -23,9 +24,9 @@ public class MVPlayerSession {
|
|||||||
private long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
|
private long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
|
||||||
private long messageLast = 0L; // Timestamp for the Players last Alert Message.
|
private long messageLast = 0L; // Timestamp for the Players last Alert Message.
|
||||||
|
|
||||||
private Configuration config; // Configuration file to find out Cooldown Timers.
|
private MultiverseCoreConfig config; // Configuration file to find out Cooldown Timers.
|
||||||
|
|
||||||
public MVPlayerSession(Player player, Configuration config, MultiverseCore multiVerseCore) {
|
public MVPlayerSession(Player player, MultiverseCoreConfig config) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
// this.bedSpawn = null;
|
// this.bedSpawn = null;
|
||||||
@ -42,6 +43,6 @@ public class MVPlayerSession {
|
|||||||
*/
|
*/
|
||||||
public boolean getTeleportable() {
|
public boolean getTeleportable() {
|
||||||
long time = (new Date()).getTime();
|
long time = (new Date()).getTime();
|
||||||
return ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
return ((time - this.teleportLast) > this.config.getTeleportCooldown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public class PermissionTools {
|
|||||||
*/
|
*/
|
||||||
public boolean playerHasMoneyToEnter(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee, boolean pay) {
|
public boolean playerHasMoneyToEnter(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee, boolean pay) {
|
||||||
Player teleporterPlayer;
|
Player teleporterPlayer;
|
||||||
if (MultiverseCore.TeleportIntercept) {
|
if (plugin.getMVConfig().getTeleportIntercept()) {
|
||||||
if (teleporter instanceof ConsoleCommandSender) {
|
if (teleporter instanceof ConsoleCommandSender) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -171,7 +171,7 @@ public class PermissionTools {
|
|||||||
this.plugin.log(Level.FINEST, "Checking '" + teleporter + "' can send '" + teleportee + "' somewhere");
|
this.plugin.log(Level.FINEST, "Checking '" + teleporter + "' can send '" + teleportee + "' somewhere");
|
||||||
|
|
||||||
Player teleporterPlayer;
|
Player teleporterPlayer;
|
||||||
if (MultiverseCore.TeleportIntercept) {
|
if (plugin.getMVConfig().getTeleportIntercept()) {
|
||||||
// The console can send anyone anywhere
|
// The console can send anyone anywhere
|
||||||
if (teleporter instanceof ConsoleCommandSender) {
|
if (teleporter instanceof ConsoleCommandSender) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -210,7 +210,7 @@ public class WorldManager implements MVWorldManager {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setFirstSpawnWorld(String world) {
|
public void setFirstSpawnWorld(String world) {
|
||||||
if (world == null) {
|
if ((world == null) && (this.plugin.getServer().getWorlds().size() > 0)) {
|
||||||
this.firstSpawn = this.plugin.getServer().getWorlds().get(0).getName();
|
this.firstSpawn = this.plugin.getServer().getWorlds().get(0).getName();
|
||||||
} else {
|
} else {
|
||||||
this.firstSpawn = world;
|
this.firstSpawn = world;
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
# This is the MV2 Config. If you mess it up, copy the values out
|
# ------------------------------------------------------------------------- #
|
||||||
# delete it, and it will be regenerated. Then use the ingame interface
|
# This is the MV2 Config. If you mess it up, copy the values out #
|
||||||
# to add your values back via the "/mv conf" command.
|
# delete it, and it will be regenerated. Then use the ingame interface #
|
||||||
# When in-game, simply type: "/mv conf ?" for help.
|
# to add your values back via the "/mv conf" command. #
|
||||||
# A config with explanations can be found here:
|
# When in-game, simply type: "/mv conf ?" for help. #
|
||||||
# https://github.com/Multiverse/Multiverse-Core/wiki/config.yml
|
# A config with explanations can be found here: #
|
||||||
|
# https://github.com/Multiverse/Multiverse-Core/wiki/config.yml #
|
||||||
worldnameprefix: true
|
# #
|
||||||
enforceaccess: true
|
# #
|
||||||
displaypermerrors: true
|
# IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !!IMPORTANT #
|
||||||
teleportintercept: true
|
# #
|
||||||
firstspawnoverride: true
|
# Do NOT delete this line from your config!!!! #
|
||||||
messagecooldown: 5000
|
# ==: com.onarandombox.MultiverseCore.MultiverseCoreConfiguration #
|
||||||
version: 2.7
|
# #
|
||||||
|
# IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !!IMPORTANT #
|
||||||
|
# ------------------------------------------------------------------------- #
|
||||||
|
@ -22,12 +22,14 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
import com.onarandombox.MultiverseCore.api.Core;
|
||||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@ -54,6 +56,7 @@ public class TestDebugMode {
|
|||||||
public void testEnableDebugMode() {
|
public void testEnableDebugMode() {
|
||||||
// Pull a core instance from the server.
|
// Pull a core instance from the server.
|
||||||
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
||||||
|
Core core = (Core) plugin;
|
||||||
|
|
||||||
// Make sure Core is not null
|
// Make sure Core is not null
|
||||||
assertNotNull(plugin);
|
assertNotNull(plugin);
|
||||||
@ -70,12 +73,12 @@ public class TestDebugMode {
|
|||||||
when(mockCommand.getName()).thenReturn("mv");
|
when(mockCommand.getName()).thenReturn("mv");
|
||||||
|
|
||||||
// Assert debug mode is off
|
// Assert debug mode is off
|
||||||
Assert.assertEquals(0, MultiverseCore.GlobalDebug);
|
Assert.assertEquals(0, core.getMVConfig().getGlobalDebug());
|
||||||
|
|
||||||
// Send the debug command.
|
// Send the debug command.
|
||||||
String[] debugArgs = new String[] { "debug", "3" };
|
String[] debugArgs = new String[] { "debug", "3" };
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", debugArgs);
|
plugin.onCommand(mockCommandSender, mockCommand, "", debugArgs);
|
||||||
|
|
||||||
Assert.assertEquals(3, MultiverseCore.GlobalDebug);
|
Assert.assertEquals(3, core.getMVConfig().getGlobalDebug());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ import org.bukkit.permissions.Permission;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.internal.verification.VerificationModeFactory;
|
import org.mockito.internal.verification.VerificationModeFactory;
|
||||||
@ -165,10 +166,10 @@ public class TestWorldProperties {
|
|||||||
assertFalse(thunderChangeOnEvent.isCancelled());
|
assertFalse(thunderChangeOnEvent.isCancelled());
|
||||||
|
|
||||||
// call player chat event
|
// call player chat event
|
||||||
MultiverseCore.PrefixChat = true;
|
core.getMVConfig().setPrefixChat(true);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||||
MultiverseCore.PrefixChat = false;
|
core.getMVConfig().setPrefixChat(false);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
||||||
|
|
||||||
@ -263,7 +264,7 @@ public class TestWorldProperties {
|
|||||||
assertTrue(thunderChangeOnEvent.isCancelled());
|
assertTrue(thunderChangeOnEvent.isCancelled());
|
||||||
|
|
||||||
// call player chat event
|
// call player chat event
|
||||||
MultiverseCore.PrefixChat = true;
|
core.getMVConfig().setPrefixChat(true);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
// never because it's hidden!
|
// never because it's hidden!
|
||||||
verify(playerChatEvent, never()).setFormat(
|
verify(playerChatEvent, never()).setFormat(
|
||||||
@ -271,7 +272,7 @@ public class TestWorldProperties {
|
|||||||
mvWorld.setHidden(false);
|
mvWorld.setHidden(false);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||||
MultiverseCore.PrefixChat = false;
|
core.getMVConfig().setPrefixChat(false);
|
||||||
core.getPlayerListener().playerChat(playerChatEvent);
|
core.getPlayerListener().playerChat(playerChatEvent);
|
||||||
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user