Compare commits
113
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d65cc8215c | ||
|
|
c6feb127de | ||
|
|
21a3eeacc8 | ||
|
|
48768b5d6c | ||
|
|
96294c092c | ||
|
|
9a3fde2f13 | ||
|
|
6520a31938 | ||
|
|
f1779c9e68 | ||
|
|
9cc35d7b12 | ||
|
|
02347e05d8 | ||
|
|
a4196a901a | ||
|
|
9b2dd0d6c9 | ||
|
|
0efb28be19 | ||
|
|
5d9941d073 | ||
|
|
82cfbaba4e | ||
|
|
9868c66cdb | ||
|
|
3a32857683 | ||
|
|
d7a3e1839e | ||
|
|
1496d940bf | ||
|
|
77480915a1 | ||
|
|
bd57ec19d2 | ||
|
|
da54f9769b | ||
|
|
2e4b814d6d | ||
|
|
3f93fb3648 | ||
|
|
176e729a87 | ||
|
|
62f79e7592 | ||
|
|
f60f770b98 | ||
|
|
3c434d18e3 | ||
|
|
c9b52c81a6 | ||
|
|
5be6ea2766 | ||
|
|
98f5e1e4ee | ||
|
|
de6fc6481e | ||
|
|
dcc6b828a8 | ||
|
|
7da91f7875 | ||
|
|
d84f930a54 | ||
|
|
bdd5e8bd91 | ||
|
|
d1280a9031 | ||
|
|
08b8f01c44 | ||
|
|
fd227960b9 | ||
|
|
0efc0b965b | ||
|
|
bbe134bd1a | ||
|
|
91f7debb08 | ||
|
|
871a601e37 | ||
|
|
bd7ad20b7b | ||
|
|
873d878252 | ||
|
|
8c63cac4c5 | ||
|
|
c233b74c98 | ||
|
|
283913010f | ||
|
|
109582335b | ||
|
|
3f09fbd710 | ||
|
|
ccb96ead10 | ||
|
|
5c48899d92 | ||
|
|
5f5d7084fa | ||
|
|
7b9c26d40a | ||
|
|
0c96da48f9 | ||
|
|
fbbe031b2c | ||
|
|
868ac57a4a | ||
|
|
7c21a114db | ||
|
|
e7573d3bd7 | ||
|
|
772d5a222d | ||
|
|
9eaca3e093 | ||
|
|
2eb61af76f | ||
|
|
ad9d4e41ff | ||
|
|
6a2e0e5810 | ||
|
|
a9c6582487 | ||
|
|
b66028e0e0 | ||
|
|
ae95a4c4f9 | ||
|
|
3ac4e55dc2 | ||
|
|
950991ff1b | ||
|
|
a1b07065b2 | ||
|
|
a1075224d3 | ||
|
|
d707a9f9a8 | ||
|
|
90b04aa798 | ||
|
|
5d1532e811 | ||
|
|
443d62580b | ||
|
|
541819ea8f | ||
|
|
b09ea0e66a | ||
|
|
8272e121f4 | ||
|
|
5d2534f497 | ||
|
|
1e7eef90f9 | ||
|
|
44df567936 | ||
|
|
d595cb9a31 | ||
|
|
49fd9e81d1 | ||
|
|
e8a72d19e1 | ||
|
|
dde3b63fb9 | ||
|
|
87d4d4e1f4 | ||
|
|
7aca740296 | ||
|
|
6c9bc6951f | ||
|
|
74726b44ab | ||
|
|
18a57bf975 | ||
|
|
b2578b1736 | ||
|
|
eec765bc48 | ||
|
|
060c0b1b44 | ||
|
|
ba90228586 | ||
|
|
8017172f0e | ||
|
|
b4ea5e9299 | ||
|
|
59f2c8b62e | ||
|
|
9a28158e5f | ||
|
|
4d97453881 | ||
|
|
8488f9db3c | ||
|
|
51586c7dd5 | ||
|
|
7b74384a8e | ||
|
|
33afa4d0d7 | ||
|
|
0980e0a201 | ||
|
|
8bab4ae606 | ||
|
|
a1299239a2 | ||
|
|
7cdb52e740 | ||
|
|
e2d6652ef1 | ||
|
|
814725a2ba | ||
|
|
da6e6145f2 | ||
|
|
ee715b13b0 | ||
|
|
a18611fb76 | ||
|
|
9173a15eb9 |
No files matched your search
@@ -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
|
||||
========
|
||||
Update the submodules after you clone and before you build with maven.
|
||||
Simply build the source with maven:
|
||||
|
||||
```
|
||||
$ git submodule update --init --recursive
|
||||
$ mvn install
|
||||
```
|
||||
$ mvn install
|
||||
|
||||
More details are available on the [build instructions wiki page](https://github.com/Multiverse/Multiverse-Core/wiki/Building).
|
||||
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
<module name="JavadocPackage">
|
||||
<property name="allowLegacy" value="true"/>
|
||||
</module>
|
||||
<module name="NewlineAtEndOfFile">
|
||||
<property name="severity" value="info"/>
|
||||
</module>
|
||||
<module name="NewlineAtEndOfFile" />
|
||||
<module name="Translation"/>
|
||||
<module name="FileLength"/>
|
||||
<module name="FileTabCharacter">
|
||||
@@ -78,7 +76,10 @@
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true"/>
|
||||
</module>
|
||||
<module name="MethodLength"/>
|
||||
<module name="MethodLength">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="countEmpty" value="false"/>
|
||||
</module>
|
||||
<module name="ParameterNumber"/>
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="MethodParamPad"/>
|
||||
|
||||
-1
Submodule lib/allpay deleted from 7abba1f004.
Submodule lib/commandhandler deleted from 46a3ab6e4e.
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>2.4</version>
|
||||
<name>Multiverse-Core</name>
|
||||
<description>World Management Plugin</description>
|
||||
<properties>
|
||||
@@ -16,6 +16,10 @@
|
||||
<id>onarandombox</id>
|
||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Bukkit Official</id>
|
||||
<url>http://repo.bukkit.org/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
@@ -63,28 +67,6 @@
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</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>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>maven-replacer-plugin</artifactId>
|
||||
@@ -154,6 +136,42 @@
|
||||
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>me.main__.util:SerializationConfig</include>
|
||||
<include>com.fernferret.allpay:AllPay</include>
|
||||
<include>com.pneumaticraft.commandhandler:CommandHandler</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.fernferret.allpay</pattern>
|
||||
<shadedPattern>com.fernferret.allpay.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>me.main__.util</pattern>
|
||||
<shadedPattern>me.main__.util.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.pneumaticraft.commandhandler</pattern>
|
||||
<shadedPattern>com.pneumaticraft.commandhandler.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -162,81 +180,47 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.1-R1-SNAPSHOT</version>
|
||||
<version>1.2.5-R1.0</version>
|
||||
<!-- If you want the lates, use this -->
|
||||
<!-- <version>LATEST</version> -->
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Bukkit Dependency -->
|
||||
<!-- Start of Spout -->
|
||||
<!-- Start of Spout (disabled because we aren't using it)
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutpluginapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- End of Spout -->
|
||||
<!-- Start of Economy Dependencies -->
|
||||
End of Spout -->
|
||||
<!-- SerializationConfig Dependency -->
|
||||
<dependency>
|
||||
<groupId>cosine.boseconomy</groupId>
|
||||
<artifactId>BOSEconomy</artifactId>
|
||||
<version>0.6.2</version>
|
||||
<groupId>me.main__.util</groupId>
|
||||
<artifactId>SerializationConfig</artifactId>
|
||||
<version>1.6</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- End of SerializationConfig Dependency -->
|
||||
<!-- Start of AllPay Dependency -->
|
||||
<dependency>
|
||||
<groupId>fr.crafter.tickleman.RealShop</groupId>
|
||||
<artifactId>RealShop</artifactId>
|
||||
<version>0.63</version>
|
||||
<groupId>com.fernferret.allpay</groupId>
|
||||
<artifactId>AllPay</artifactId>
|
||||
<version>10</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- End of AllPay Dependency -->
|
||||
<!-- Start of CommandHandler Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.iCo6</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>6.0</version>
|
||||
<groupId>com.pneumaticraft.commandhandler</groupId>
|
||||
<artifactId>CommandHandler</artifactId>
|
||||
<version>7</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</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 -->
|
||||
<!-- End of CommandHandler Dependency -->
|
||||
<!-- Start of Test Dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -9,10 +9,15 @@ package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.fernferret.allpay.AllPay;
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.api.MVPlugin;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.commands.*;
|
||||
import com.onarandombox.MultiverseCore.destination.AnchorDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.BedDestination;
|
||||
@@ -22,24 +27,23 @@ import com.onarandombox.MultiverseCore.destination.ExactDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.PlayerDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.utils.DebugLog;
|
||||
import com.onarandombox.MultiverseCore.utils.MVMessaging;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.SpoutInterface;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
|
||||
import com.onarandombox.MultiverseCore.utils.*;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -50,7 +54,9 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
@@ -61,21 +67,14 @@ import java.util.logging.Logger;
|
||||
* The implementation of the Multiverse-{@link Core}.
|
||||
*/
|
||||
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
private static final int PROTOCOL = 12;
|
||||
// Global Multiverse config variable, states whether or not
|
||||
// Multiverse should stop other plugins from teleporting players
|
||||
// to worlds.
|
||||
// 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 static final int PROTOCOL = 14;
|
||||
// TODO: Investigate if this one is really needed to be static.
|
||||
// Doubt it. -- FernFerret
|
||||
private static Map<String, String> teleportQueue = new HashMap<String, String>();
|
||||
|
||||
private AnchorManager anchorManager = new AnchorManager(this);
|
||||
// TODO please let's make this non-static
|
||||
private MultiverseCoreConfiguration config;
|
||||
|
||||
/**
|
||||
* This method is used to find out who is teleporting a player.
|
||||
@@ -153,12 +152,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
// Setup the block/player/entity listener.
|
||||
private MVPlayerListener playerListener = new MVPlayerListener(this);
|
||||
|
||||
private MVEntityListener entityListener = new MVEntityListener(this);
|
||||
private MVPluginListener pluginListener = new MVPluginListener(this);
|
||||
private MVWeatherListener weatherListener = new MVWeatherListener(this);
|
||||
|
||||
//public UpdateChecker updateCheck;
|
||||
private MVPortalListener portalListener = new MVPortalListener(this);
|
||||
|
||||
// HashMap to contain information relating to the Players.
|
||||
private HashMap<String, MVPlayerSession> playerSessions;
|
||||
@@ -166,25 +163,38 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
private AllPay banker;
|
||||
private int pluginCount;
|
||||
private DestinationFactory destFactory;
|
||||
private SpoutInterface spoutInterface = null;
|
||||
private static final double ALLPAY_VERSION = 5;
|
||||
private static final double CH_VERSION = 4;
|
||||
private MVMessaging messaging;
|
||||
//private SpoutInterface spoutInterface = null;
|
||||
private MultiverseMessaging messaging;
|
||||
private BlockSafety blockSafety;
|
||||
private LocationManipulation locationManipulation;
|
||||
private SafeTTeleporter safeTTeleporter;
|
||||
|
||||
private File serverFolder = new File(System.getProperty("user.dir"));
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Register our config
|
||||
SerializationConfig.registerAll(MultiverseCoreConfiguration.class);
|
||||
// Register our world
|
||||
SerializationConfig.registerAll(MVWorld.class);
|
||||
// Create our DataFolder
|
||||
getDataFolder().mkdirs();
|
||||
// Setup our Debug Log
|
||||
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
|
||||
// Setup our BlockSafety
|
||||
this.blockSafety = new SimpleBlockSafety(this);
|
||||
// Setup our LocationManipulation
|
||||
this.locationManipulation = new SimpleLocationManipulation();
|
||||
// Setup our SafeTTeleporter
|
||||
this.safeTTeleporter = new SimpleSafeTTeleporter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public FileConfiguration getMVConfiguration() {
|
||||
return this.multiverseConfig;
|
||||
}
|
||||
@@ -202,12 +212,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
@Override
|
||||
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.banker = new AllPay(this, LOG_TAG + " ");
|
||||
// Output a little snippet to show it's enabled.
|
||||
@@ -248,55 +252,20 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.anchorManager.loadAnchors();
|
||||
|
||||
// Now set the firstspawnworld (after the worlds are loaded):
|
||||
// Default as the server.props world.
|
||||
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.
|
||||
this.worldManager.setFirstSpawnWorld(config.getFirstSpawnWorld());
|
||||
try {
|
||||
this.multiverseConfig.set("firstspawnworld", this.worldManager.getFirstSpawnWorld().getName());
|
||||
config.setFirstSpawnWorld(this.worldManager.getFirstSpawnWorld().getName());
|
||||
} catch (NullPointerException e) {
|
||||
// A test that had no worlds loaded was being run. This should never happen in production
|
||||
}
|
||||
this.saveMVConfig();
|
||||
/*
|
||||
// Check to see if spout was already loaded (most likely):
|
||||
if (this.getServer().getPluginManager().getPlugin("Spout") != null) {
|
||||
this.setSpout();
|
||||
this.log(Level.INFO, "Spout integration enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
@@ -319,6 +288,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
pm.registerEvents(this.entityListener, this);
|
||||
pm.registerEvents(this.pluginListener, this);
|
||||
pm.registerEvents(this.weatherListener, this);
|
||||
pm.registerEvents(this.portalListener, this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,53 +301,296 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
||||
Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml"));
|
||||
this.multiverseConfig.setDefaults(coreDefaults);
|
||||
this.multiverseConfig.options().copyDefaults(true);
|
||||
this.saveMVConfig();
|
||||
this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
|
||||
this.multiverseConfig.options().copyDefaults(false);
|
||||
this.multiverseConfig.options().copyHeader(true);
|
||||
|
||||
this.migrateWorldConfig();
|
||||
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.
|
||||
GlobalDebug = this.multiverseConfig.getInt("debug", 0);
|
||||
// Lets cache these values due to the fact that they will be accessed many times.
|
||||
EnforceAccess = this.multiverseConfig.getBoolean("enforceaccess", false);
|
||||
PrefixChat = this.multiverseConfig.getBoolean("worldnameprefix", true);
|
||||
// Should MV Intercept teleports by other plugins?
|
||||
TeleportIntercept = this.multiverseConfig.getBoolean("teleportintercept", true);
|
||||
// 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);
|
||||
MultiverseCoreConfiguration wantedConfig = null;
|
||||
try {
|
||||
wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration");
|
||||
} catch (Exception e) {
|
||||
// We're just thinking "no risk no fun" and therefore have to catch and forget this exception
|
||||
} finally {
|
||||
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
||||
}
|
||||
|
||||
this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
// Update the version of the config!
|
||||
this.multiverseConfig.set("version", coreDefaults.get("version"));
|
||||
this.messaging.setCooldown(config.getMessageCooldown());
|
||||
|
||||
// Remove old values.
|
||||
this.multiverseConfig.set("enforcegamemodes", null);
|
||||
this.multiverseConfig.set("bedrespawn", null);
|
||||
this.multiverseConfig.set("opfallback", null);
|
||||
|
||||
// Old Config Format
|
||||
this.migrate22Values();
|
||||
this.saveMVConfigs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely return a world name.
|
||||
* (The tests call this with no worlds loaded)
|
||||
*
|
||||
* @return The default world name.
|
||||
* Thes are the MV config 2.0-2.2 values,
|
||||
* they should be migrated to the new format.
|
||||
*/
|
||||
private String getDefaultWorldName() {
|
||||
if (this.getServer().getWorlds().size() > 0) {
|
||||
return this.getServer().getWorlds().get(0).getName();
|
||||
private void migrate22Values() {
|
||||
if (this.multiverseConfig.isSet("worldnameprefix")) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate the worlds.yml to SerializationConfig.
|
||||
*/
|
||||
private void migrateWorldConfig() {
|
||||
FileConfiguration wconf = YamlConfiguration
|
||||
.loadConfiguration(new File(getDataFolder(), "worlds.yml"));
|
||||
|
||||
if (!wconf.isConfigurationSection("worlds")) // empty config
|
||||
return;
|
||||
|
||||
Map<String, Object> values = wconf.getConfigurationSection("worlds").getValues(false);
|
||||
|
||||
boolean wasChanged = false;
|
||||
Map<String, Object> newValues = new LinkedHashMap<String, Object>(values.size());
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
if (entry.getValue() instanceof MVWorld) {
|
||||
// fine
|
||||
newValues.put(entry.getKey(), entry.getValue());
|
||||
} else if (entry.getValue() instanceof ConfigurationSection) {
|
||||
// we have to migrate this
|
||||
MVWorld world = new MVWorld(Collections.EMPTY_MAP);
|
||||
ConfigurationSection section = (ConfigurationSection) entry.getValue();
|
||||
|
||||
// migrate animals and monsters
|
||||
if (section.isConfigurationSection("animals")) {
|
||||
ConfigurationSection animalSection = section.getConfigurationSection("animals");
|
||||
if (animalSection.contains("spawn")) {
|
||||
if (animalSection.isBoolean("spawn"))
|
||||
world.setAllowAnimalSpawn(animalSection.getBoolean("spawn"));
|
||||
else
|
||||
world.setAllowAnimalSpawn(Boolean.parseBoolean(animalSection.getString("spawn")));
|
||||
}
|
||||
if (animalSection.isList("exceptions")) {
|
||||
world.getAnimalList().clear();
|
||||
world.getAnimalList().addAll(animalSection.getStringList("exceptions"));
|
||||
}
|
||||
}
|
||||
if (section.isConfigurationSection("monsters")) {
|
||||
ConfigurationSection monsterSection = section.getConfigurationSection("monsters");
|
||||
if (monsterSection.contains("spawn")) {
|
||||
if (monsterSection.isBoolean("spawn"))
|
||||
world.setAllowMonsterSpawn(monsterSection.getBoolean("spawn"));
|
||||
else
|
||||
world.setAllowMonsterSpawn(Boolean.parseBoolean(monsterSection.getString("spawn")));
|
||||
}
|
||||
if (monsterSection.isList("exceptions")) {
|
||||
world.getMonsterList().clear();
|
||||
world.getMonsterList().addAll(monsterSection.getStringList("exceptions"));
|
||||
}
|
||||
}
|
||||
|
||||
// migrate entryfee
|
||||
if (section.isConfigurationSection("entryfee")) {
|
||||
ConfigurationSection feeSection = section.getConfigurationSection("entryfee");
|
||||
if (feeSection.isInt("currency"))
|
||||
world.setCurrency(feeSection.getInt("currency"));
|
||||
|
||||
if (feeSection.isDouble("amount"))
|
||||
world.setPrice(feeSection.getDouble("amount"));
|
||||
else if (feeSection.isInt("amount"))
|
||||
world.setPrice(feeSection.getInt("amount"));
|
||||
}
|
||||
|
||||
// migrate pvp
|
||||
if (section.isBoolean("pvp")) {
|
||||
world.setPVPMode(section.getBoolean("pvp"));
|
||||
}
|
||||
|
||||
// migrate alias
|
||||
if (section.isConfigurationSection("alias")) {
|
||||
ConfigurationSection aliasSection = section.getConfigurationSection("alias");
|
||||
if (aliasSection.isString("color"))
|
||||
world.setColor(aliasSection.getString("color"));
|
||||
if (aliasSection.isString("name"))
|
||||
world.setAlias(aliasSection.getString("name"));
|
||||
}
|
||||
|
||||
// migrate worldblacklist
|
||||
if (section.isList("worldblacklist")) {
|
||||
world.getWorldBlacklist().clear();
|
||||
world.getWorldBlacklist().addAll(section.getStringList("worldblacklist"));
|
||||
}
|
||||
|
||||
// migrate scale
|
||||
if (section.isDouble("scale")) {
|
||||
world.setScaling(section.getDouble("scale"));
|
||||
}
|
||||
|
||||
// migrate gamemode
|
||||
if (section.isString("gamemode")) {
|
||||
try {
|
||||
world.setPropertyValue("gamemode", section.getString("gamemode"));
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||
}
|
||||
}
|
||||
|
||||
// migrate hunger
|
||||
if (section.isBoolean("hunger")) {
|
||||
world.setHunger(section.getBoolean("hunger"));
|
||||
}
|
||||
|
||||
// migrate hidden
|
||||
if (section.isBoolean("hidden")) {
|
||||
world.setHidden(section.getBoolean("hidden"));
|
||||
}
|
||||
|
||||
// migrate autoheal
|
||||
if (section.isBoolean("autoheal")) {
|
||||
world.setAutoHeal(section.getBoolean("autoheal"));
|
||||
}
|
||||
|
||||
// migrate portalform
|
||||
if (section.isString("portalform")) {
|
||||
try {
|
||||
world.setPropertyValue("portalform", section.getString("portalform"));
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||
}
|
||||
}
|
||||
|
||||
// migrate environment
|
||||
if (section.isString("environment")) {
|
||||
try {
|
||||
world.setPropertyValue("environment", section.getString("environment"));
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||
}
|
||||
}
|
||||
|
||||
// migrate generator
|
||||
if (section.isString("generator")) {
|
||||
world.setGenerator(section.getString("generator"));
|
||||
}
|
||||
|
||||
// migrate seed
|
||||
if (section.isLong("seed")) {
|
||||
world.setSeed(section.getLong("seed"));
|
||||
}
|
||||
|
||||
// migrate weather
|
||||
if (section.isBoolean("allowweather")) {
|
||||
world.setEnableWeather(section.getBoolean("allowweather"));
|
||||
}
|
||||
|
||||
// migrate adjustspawn
|
||||
if (section.isBoolean("adjustspawn")) {
|
||||
world.setAdjustSpawn(section.getBoolean("adjustspawn"));
|
||||
}
|
||||
|
||||
// migrate autoload
|
||||
if (section.isBoolean("autoload")) {
|
||||
world.setAutoLoad(section.getBoolean("autoload"));
|
||||
}
|
||||
|
||||
// migrate bedrespawn
|
||||
if (section.isBoolean("bedrespawn")) {
|
||||
world.setBedRespawn(section.getBoolean("bedrespawn"));
|
||||
}
|
||||
|
||||
// migrate spawn
|
||||
if (section.isConfigurationSection("spawn")) {
|
||||
ConfigurationSection spawnSect = section.getConfigurationSection("spawn");
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
if (spawnSect.isDouble("yaw"))
|
||||
spawnLoc.setYaw((float) spawnSect.getDouble("yaw"));
|
||||
if (spawnSect.isDouble("pitch"))
|
||||
spawnLoc.setPitch((float) spawnSect.getDouble("pitch"));
|
||||
if (spawnSect.isDouble("x"))
|
||||
spawnLoc.setX(spawnSect.getDouble("x"));
|
||||
if (spawnSect.isDouble("y"))
|
||||
spawnLoc.setY(spawnSect.getDouble("y"));
|
||||
if (spawnSect.isDouble("z"))
|
||||
spawnLoc.setZ(spawnSect.getDouble("z"));
|
||||
|
||||
world.setSpawnLocation(spawnLoc);
|
||||
}
|
||||
|
||||
newValues.put(entry.getKey(), world);
|
||||
wasChanged = true;
|
||||
} else {
|
||||
// huh?
|
||||
this.log(Level.WARNING, "Removing unknown entry in the config: " + entry);
|
||||
// just don't add to newValues
|
||||
wasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (wasChanged) {
|
||||
// clear config
|
||||
wconf.set("worlds", null);
|
||||
|
||||
// and rebuild it
|
||||
ConfigurationSection rootSection = wconf.createSection("worlds");
|
||||
for (Map.Entry<String, Object> entry : newValues.entrySet()) {
|
||||
rootSection.set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
try {
|
||||
wconf.save(new File(getDataFolder(), "worlds.yml"));
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public MVMessaging getMessaging() {
|
||||
public MultiverseMessaging getMessaging() {
|
||||
return this.messaging;
|
||||
}
|
||||
|
||||
@@ -425,6 +639,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.saveMVConfigs();
|
||||
debugLog.close();
|
||||
this.banker = null;
|
||||
this.bank = null;
|
||||
@@ -439,17 +654,20 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
if (this.playerSessions.containsKey(player.getName())) {
|
||||
return this.playerSessions.get(player.getName());
|
||||
} else {
|
||||
this.playerSessions.put(player.getName(), new MVPlayerSession(player, this.multiverseConfig, this));
|
||||
this.playerSessions.put(player.getName(), new MVPlayerSession(player, config));
|
||||
return this.playerSessions.get(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Override
|
||||
public SafeTTeleporter getTeleporter() {
|
||||
return new SafeTTeleporter(this);
|
||||
@Deprecated
|
||||
public com.onarandombox.MultiverseCore.utils.SafeTTeleporter getTeleporter() {
|
||||
return new com.onarandombox.MultiverseCore.utils.SafeTTeleporter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -471,7 +689,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
}
|
||||
ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args));
|
||||
allArgs.add(0, command.getName());
|
||||
return this.commandHandler.locateAndRunCommand(sender, allArgs, DisplayPermErrors);
|
||||
return this.commandHandler.locateAndRunCommand(sender, allArgs, config.getDisplayPermErrors());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -489,13 +707,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
* @param msg The message to log.
|
||||
*/
|
||||
public static void staticLog(Level level, String msg) {
|
||||
if (level == Level.FINE && GlobalDebug >= 1) {
|
||||
if (level == Level.FINE && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 1) {
|
||||
staticDebugLog(Level.INFO, msg);
|
||||
return;
|
||||
} else if (level == Level.FINER && GlobalDebug >= 2) {
|
||||
} else if (level == Level.FINER && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 2) {
|
||||
staticDebugLog(Level.INFO, msg);
|
||||
return;
|
||||
} else if (level == Level.FINEST && GlobalDebug >= 3) {
|
||||
} else if (level == Level.FINEST && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 3) {
|
||||
staticDebugLog(Level.INFO, msg);
|
||||
return;
|
||||
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
|
||||
@@ -522,7 +740,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
@Override
|
||||
public String getAuthors() {
|
||||
String authors = "";
|
||||
ArrayList<String> auths = this.getDescription().getAuthors();
|
||||
List<String> auths = this.getDescription().getAuthors();
|
||||
if (auths.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
@@ -638,7 +856,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
public void teleportPlayer(CommandSender teleporter, Player p, Location l) {
|
||||
// This command is the override, and MUST NOT TELEPORT SAFELY
|
||||
this.getTeleporter().safelyTeleport(teleporter, p, l, false);
|
||||
this.getSafeTTeleporter().safelyTeleport(teleporter, p, l, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -662,9 +880,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.serverFolder = newServerFolder;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Initializes Spout.
|
||||
*/
|
||||
* /
|
||||
public void setSpout() {
|
||||
this.spoutInterface = new SpoutInterface();
|
||||
this.commandHandler.registerCommand(new SpoutCommand(this));
|
||||
@@ -674,10 +893,11 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
* Gets our {@link SpoutInterface}.
|
||||
*
|
||||
* @return The {@link SpoutInterface} we're using.
|
||||
*/
|
||||
* /
|
||||
public SpoutInterface getSpout() {
|
||||
return this.spoutInterface;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -696,6 +916,24 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return this.playerListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link MVEntityListener}.
|
||||
*
|
||||
* @return The {@link MVEntityListener}.
|
||||
*/
|
||||
public MVEntityListener getEntityListener() {
|
||||
return this.entityListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link MVWeatherListener}.
|
||||
*
|
||||
* @return The {@link MVWeatherListener}.
|
||||
*/
|
||||
public MVWeatherListener getWeatherListener() {
|
||||
return this.weatherListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the Multiverse-Config.
|
||||
*
|
||||
@@ -703,6 +941,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
public boolean saveMVConfig() {
|
||||
try {
|
||||
this.multiverseConfig.set("multiverse-configuration", config);
|
||||
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
@@ -762,7 +1001,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
}
|
||||
if (this.worldManager.deleteWorld(name, false)) {
|
||||
this.worldManager.loadWorlds(false);
|
||||
SafeTTeleporter teleporter = this.getTeleporter();
|
||||
SafeTTeleporter teleporter = this.getSafeTTeleporter();
|
||||
Location newSpawn = this.getServer().getWorld(name).getSpawnLocation();
|
||||
// Send all players that were in the old world, BACK to it!
|
||||
for (Player p : ps) {
|
||||
@@ -781,4 +1020,70 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return this.anchorManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public BlockSafety getBlockSafety() {
|
||||
return blockSafety;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setBlockSafety(BlockSafety bs) {
|
||||
this.blockSafety = bs;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public LocationManipulation getLocationManipulation() {
|
||||
return locationManipulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setLocationManipulation(LocationManipulation locationManipulation) {
|
||||
this.locationManipulation = locationManipulation;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SafeTTeleporter getSafeTTeleporter() {
|
||||
return safeTTeleporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setSafeTTeleporter(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 The Multiverse config.
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public static MultiverseCoreConfiguration getStaticConfig() {
|
||||
return MultiverseCoreConfiguration.getInstance();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
/**
|
||||
* Our configuration.
|
||||
*/
|
||||
public class MultiverseCoreConfiguration extends SerializationConfig implements MultiverseCoreConfig {
|
||||
private static MultiverseCoreConfiguration instance;
|
||||
|
||||
/**
|
||||
* Sets the statically saved instance.
|
||||
* @param instance The new instance.
|
||||
*/
|
||||
public static void setInstance(MultiverseCoreConfiguration instance) {
|
||||
MultiverseCoreConfiguration.instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the statically saved instance.
|
||||
* @return The statically saved instance.
|
||||
*/
|
||||
public static MultiverseCoreConfiguration getInstance() {
|
||||
if (instance == null)
|
||||
throw new IllegalStateException("The instance wasn't set!");
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Property
|
||||
private 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();
|
||||
MultiverseCoreConfiguration.setInstance(this);
|
||||
}
|
||||
|
||||
public MultiverseCoreConfiguration(Map<String, Object> values) {
|
||||
super(values);
|
||||
MultiverseCoreConfiguration.setInstance(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setConfigProperty(String property, String value) {
|
||||
try {
|
||||
return this.setProperty(property, value, true);
|
||||
} catch (NoSuchPropertyException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// And here we go:
|
||||
|
||||
/**
|
||||
* {@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
|
||||
/**
|
||||
* Used to get block/location-related information.
|
||||
*/
|
||||
public interface BlockSafety {
|
||||
/**
|
||||
* This function checks whether the block at the given coordinates are above air or not.
|
||||
* @param l The {@link Location} of the block.
|
||||
* @return True if the block at that {@link Location} is above air.
|
||||
*/
|
||||
boolean isBlockAboveAir(Location l);
|
||||
|
||||
/**
|
||||
* Checks if a player can spawn safely at the given coordinates.
|
||||
* @param world The {@link World}.
|
||||
* @param x The x-coordinate.
|
||||
* @param y The y-coordinate.
|
||||
* @param z The z-coordinate.
|
||||
* @return True if a player can spawn safely at the given coordinates.
|
||||
*/
|
||||
boolean playerCanSpawnHereSafely(World world, double x, double y, double z);
|
||||
|
||||
/**
|
||||
* This function checks whether the block at the coordinates given is safe or not by checking for Lava/Fire/Air
|
||||
* etc. This also ensures there is enough space for a player to spawn!
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return Whether the player can spawn safely at the given {@link Location}
|
||||
*/
|
||||
boolean playerCanSpawnHereSafely(Location l);
|
||||
|
||||
/**
|
||||
* Gets the location of the top block at the specified {@link Location}.
|
||||
* @param l Any {@link Location}.
|
||||
* @return The {@link Location} of the top-block.
|
||||
*/
|
||||
Location getTopBlock(Location l);
|
||||
|
||||
/**
|
||||
* Gets the location of the top block at the specified {@link Location}.
|
||||
* @param l Any {@link Location}.
|
||||
* @return The {@link Location} of the top-block.
|
||||
*/
|
||||
Location getBottomBlock(Location l);
|
||||
|
||||
/**
|
||||
* Checks if an entity would be on track at the specified {@link Location}.
|
||||
* @param l The {@link Location}.
|
||||
* @return True if an entity would be on tracks at the specified {@link Location}.
|
||||
*/
|
||||
boolean isEntitiyOnTrack(Location l);
|
||||
|
||||
/**
|
||||
* Checks if the specified {@link Minecart} can spawn safely.
|
||||
* @param cart The {@link Minecart}.
|
||||
* @return True if the minecart can spawn safely.
|
||||
*/
|
||||
boolean canSpawnCartSafely(Minecart cart);
|
||||
|
||||
/**
|
||||
* Checks if the specified {@link Vehicle} can spawn safely.
|
||||
* @param vehicle The {@link Vehicle}.
|
||||
* @return True if the vehicle can spawn safely.
|
||||
*/
|
||||
boolean canSpawnVehicleSafely(Vehicle vehicle);
|
||||
}
|
||||
@@ -26,7 +26,9 @@ public interface Core {
|
||||
* Gets the Multiverse config file.
|
||||
*
|
||||
* @return The Multiverse config file.
|
||||
* @deprecated Don't modify the config-file manually!
|
||||
*/
|
||||
@Deprecated
|
||||
FileConfiguration getMVConfiguration();
|
||||
|
||||
/**
|
||||
@@ -46,9 +48,9 @@ public interface Core {
|
||||
* Gets the Multiverse message system. This allows you to send messages
|
||||
* to users at specified intervals.
|
||||
*
|
||||
* @return The loaded {@link MVMessaging}.
|
||||
* @return The loaded {@link MultiverseMessaging}.
|
||||
*/
|
||||
MVMessaging getMessaging();
|
||||
MultiverseMessaging getMessaging();
|
||||
|
||||
/**
|
||||
* Gets the {@link MVPlayerSession} for the given player.
|
||||
@@ -66,8 +68,11 @@ public interface Core {
|
||||
* safe teleports.
|
||||
*
|
||||
* @return A non-null {@link SafeTTeleporter}.
|
||||
*
|
||||
* @deprecated Use {@link #getSafeTTeleporter()} instead.
|
||||
*/
|
||||
SafeTTeleporter getTeleporter();
|
||||
@Deprecated
|
||||
com.onarandombox.MultiverseCore.utils.SafeTTeleporter getTeleporter();
|
||||
|
||||
/**
|
||||
* Multiverse uses an advanced permissions setup, this object
|
||||
@@ -163,4 +168,58 @@ public interface Core {
|
||||
* @return The readable authors-{@link String}
|
||||
*/
|
||||
String getAuthors();
|
||||
|
||||
/**
|
||||
* Gets the {@link BlockSafety} this {@link Core} is using.
|
||||
* @return The {@link BlockSafety} this {@link Core} is using.
|
||||
* @see BlockSafety
|
||||
* @see SimpleBlockSafety
|
||||
*/
|
||||
BlockSafety getBlockSafety();
|
||||
|
||||
/**
|
||||
* Sets the {@link BlockSafety} this {@link Core} is using.
|
||||
* @param blockSafety The new {@link BlockSafety}.
|
||||
* @see BlockSafety
|
||||
* @see SimpleBlockSafety
|
||||
*/
|
||||
void setBlockSafety(BlockSafety blockSafety);
|
||||
|
||||
/**
|
||||
* Gets the {@link LocationManipulation} this {@link Core} is using.
|
||||
* @return The {@link LocationManipulation} this {@link Core} is using.
|
||||
* @see LocationManipulation
|
||||
* @see SimpleLocationManipulation
|
||||
*/
|
||||
LocationManipulation getLocationManipulation();
|
||||
|
||||
/**
|
||||
* Sets the {@link LocationManipulation} this {@link Core} is using.
|
||||
* @param locationManipulation The new {@link LocationManipulation}.
|
||||
* @see LocationManipulation
|
||||
* @see SimpleLocationManipulation
|
||||
*/
|
||||
void setLocationManipulation(LocationManipulation locationManipulation);
|
||||
|
||||
/**
|
||||
* Gets the {@link SafeTTeleporter} this {@link Core} is using.
|
||||
* @return The {@link SafeTTeleporter} this {@link Core} is using.
|
||||
* @see SafeTTeleporter
|
||||
* @see SimpleSafeTTeleporter
|
||||
*/
|
||||
SafeTTeleporter getSafeTTeleporter();
|
||||
|
||||
/**
|
||||
* Sets the {@link SafeTTeleporter} this {@link Core} is using.
|
||||
* @param safeTTeleporter The new {@link SafeTTeleporter}.
|
||||
* @see SafeTTeleporter
|
||||
* @see SimpleSafeTTeleporter
|
||||
*/
|
||||
void setSafeTTeleporter(SafeTTeleporter safeTTeleporter);
|
||||
|
||||
/**
|
||||
* Gets the {@link MultiverseCoreConfig}.
|
||||
* @return The configuration.
|
||||
*/
|
||||
MultiverseCoreConfig getMVConfig();
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* Used to manipulate locations.
|
||||
*/
|
||||
public interface LocationManipulation {
|
||||
/**
|
||||
* Convert a Location into a Colon separated string to allow us to store it in text.
|
||||
* <p>
|
||||
* WORLD:X,Y,Z:yaw:pitch
|
||||
* <p>
|
||||
* The corresponding String2Loc function is {@link #stringToLocation}
|
||||
*
|
||||
* @param location The Location to save.
|
||||
* @return The location as a string in this format: WORLD:x,y,z:yaw:pitch
|
||||
*/
|
||||
String locationToString(Location location);
|
||||
|
||||
/**
|
||||
* This method simply does some rounding, rather than forcing a call to the server to get the blockdata.
|
||||
*
|
||||
* @param l The location to round to the block location
|
||||
* @return A rounded location.
|
||||
*/
|
||||
Location getBlockLocation(Location l);
|
||||
|
||||
/**
|
||||
* Returns a new location from a given string. The format is as follows:
|
||||
* <p>
|
||||
* WORLD:X,Y,Z:yaw:pitch
|
||||
* <p>
|
||||
* The corresponding Location2String function is {@link #stringToLocation}
|
||||
*
|
||||
* @param locationString The location represented as a string (WORLD:X,Y,Z:yaw:pitch)
|
||||
* @return A new location defined by the string or null if the string was invalid.
|
||||
*/
|
||||
Location stringToLocation(String locationString);
|
||||
|
||||
/**
|
||||
* Returns a colored string with the coords.
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return The {@link String}
|
||||
*/
|
||||
String strCoords(Location l);
|
||||
|
||||
/**
|
||||
* Converts a location to a printable readable formatted string including pitch/yaw.
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return The {@link String}
|
||||
*/
|
||||
String strCoordsRaw(Location l);
|
||||
|
||||
/**
|
||||
* Return the NESW Direction a Location is facing.
|
||||
*
|
||||
* @param location The {@link Location}
|
||||
* @return The NESW Direction
|
||||
*/
|
||||
String getDirection(Location location);
|
||||
|
||||
/**
|
||||
* Returns the float yaw position for the given cardinal direction.
|
||||
*
|
||||
* @param orientation The cardinal direction
|
||||
* @return The yaw
|
||||
*/
|
||||
float getYaw(String orientation);
|
||||
|
||||
/**
|
||||
* Returns a speed float from a given vector.
|
||||
*
|
||||
* @param v The {@link Vector}
|
||||
* @return The speed
|
||||
*/
|
||||
float getSpeed(Vector v);
|
||||
|
||||
/**
|
||||
* Returns a translated vector from the given direction.
|
||||
*
|
||||
* @param v The old {@link Vector}
|
||||
* @param direction The new direction
|
||||
* @return The translated {@link Vector}
|
||||
*/
|
||||
Vector getTranslatedVector(Vector v, String direction);
|
||||
|
||||
/**
|
||||
* Returns the next Location that a {@link Vehicle} is traveling at.
|
||||
*
|
||||
* @param v The {@link Vehicle}
|
||||
* @return The {@link Location}
|
||||
*/
|
||||
Location getNextBlock(Vehicle v);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public interface MVDestination {
|
||||
boolean isThisType(JavaPlugin plugin, String destination);
|
||||
|
||||
/**
|
||||
* Returns the location a specific entity will spawn at.
|
||||
* Returns the location a specific entity will spawn at when being teleported to this Destination.
|
||||
* <p>
|
||||
* To just retrieve the location as it is stored you can just pass null, but be warned some destinations may return
|
||||
* null back to you if you do this. It is always safer to pass an actual entity. This is used so things like
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleWorldPurger;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
@@ -28,31 +30,35 @@ public interface MVWorldManager {
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
*
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generateStructures If true, this world will get NPC villages.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator);
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator);
|
||||
|
||||
/**
|
||||
* Add a new World to the Multiverse Setup.
|
||||
*
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @param name World Name
|
||||
* @param env Environment Type
|
||||
* @param seedString The seed in the form of a string.
|
||||
* If the seed is a Long,
|
||||
* it will be interpreted as such.
|
||||
* @param type The Type of the world to be made.
|
||||
* @param generateStructures If true, this world will get NPC villages.
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @param useSpawnAdjust If true, multiverse will search for a safe spawn. If not, It will not modify the level.dat.
|
||||
* @return True if the world is added, false if not.
|
||||
*/
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator, boolean useSpawnAdjust);
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator, boolean useSpawnAdjust);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
@@ -168,9 +174,21 @@ public interface MVWorldManager {
|
||||
* Return the World Purger.
|
||||
*
|
||||
* @return A valid {@link PurgeWorlds}.
|
||||
* @deprecated {@link PurgeWorlds} is deprecated!
|
||||
*/
|
||||
@Deprecated
|
||||
PurgeWorlds getWorldPurger();
|
||||
|
||||
/**
|
||||
* Gets the {@link WorldPurger}.
|
||||
* <p>
|
||||
* TODO: Remove {@link #getWorldPurger()} and replace it with this method.
|
||||
* @return The {@link WorldPurger} this {@link MVWorldManager} is using.
|
||||
* @see WorldPurger
|
||||
* @see SimpleWorldPurger
|
||||
*/
|
||||
WorldPurger getTheWorldPurger();
|
||||
|
||||
/**
|
||||
* Gets the world players will spawn in on first join.
|
||||
* Currently this always returns worlds.get(0) from Bukkit.
|
||||
|
||||
@@ -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 setConfigProperty(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();
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* Multiverse-messaging.
|
||||
*/
|
||||
public interface MultiverseMessaging {
|
||||
/**
|
||||
* Sets the message-cooldown.
|
||||
* @param milliseconds The new message-cooldown in milliseconds.
|
||||
*/
|
||||
void setCooldown(int milliseconds);
|
||||
|
||||
/**
|
||||
* Sends a message to the specified sender if the cooldown has passed.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param message The message to send.
|
||||
* @param ignoreCooldown If true this message will always be sent. Useful for things like menus
|
||||
* @return true if the message was sent, false if not.
|
||||
*/
|
||||
boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown);
|
||||
|
||||
/**
|
||||
* Sends a group of messages to the specified sender if the cooldown has passed.
|
||||
* This method is needed, since sending many messages in quick succession would violate
|
||||
* the cooldown.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param messages The messages to send.
|
||||
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
|
||||
* @return true if the message was sent, false if not.
|
||||
*/
|
||||
boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown);
|
||||
|
||||
/**
|
||||
* Sends a group of messages to the specified sender if the cooldown has passed.
|
||||
* This method is needed, since sending many messages in quick succession would violate
|
||||
* the cooldown.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param messages The messages to send.
|
||||
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
|
||||
* @return true if the message was sent, false if not.
|
||||
*/
|
||||
boolean sendMessages(CommandSender sender, Collection<String> messages, boolean ignoreCooldown);
|
||||
|
||||
/**
|
||||
* Gets the message-cooldown.
|
||||
* @return The message-cooldown.
|
||||
*/
|
||||
int getCooldown();
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.configuration.MVConfigProperty;
|
||||
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
* The API for a Multiverse Handled World.
|
||||
*/
|
||||
public interface MultiverseWorld {
|
||||
|
||||
/**
|
||||
* Returns the Bukkit world object that this world describes.
|
||||
*
|
||||
@@ -34,79 +33,24 @@ public interface MultiverseWorld {
|
||||
World getCBWorld();
|
||||
|
||||
/**
|
||||
* Adds the property to the given value.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
* Gets the name of this world. The name cannot be changed.
|
||||
* <p>
|
||||
* Note for plugin developers: Usually {@link #getAlias()}
|
||||
* is what you want to use instead of this method.
|
||||
*
|
||||
* @param property The name of a world property to set.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @param sender The sender who wants this value to be set.
|
||||
* @return True if the value was set, false if not.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
* @return The name of the world as a String.
|
||||
*/
|
||||
boolean setProperty(String property, String value, CommandSender sender) throws PropertyDoesNotExistException;
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the actual MVConfigProperty from this world.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
* Gets the type of this world. As of 1.2 this will be:
|
||||
* FLAT, NORMAL or VERSION_1_1
|
||||
* <p>
|
||||
* This is <b>not</b> the generator.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
* @return A valid MVWorldProperty.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
* @deprecated Use {@link #getProperty(String, Class)} instead
|
||||
* @return The Type of this world.
|
||||
*/
|
||||
@Deprecated
|
||||
MVConfigProperty<?> getProperty(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Gets the string representation of a property.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
* @return A valid MVWorldProperty.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
String getPropertyValue(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Gets the actual MVConfigProperty from this world.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
* @param expected The type of the expected property. Use Object.class if this doesn't matter for you.
|
||||
* @param <T> The type of the expected property.
|
||||
*
|
||||
* @return A valid MVWorldProperty.
|
||||
*
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
<T> MVConfigProperty<T> getProperty(String property, Class<T> expected) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
|
||||
* @return True if it was cleared, false if not.
|
||||
*/
|
||||
boolean clearVariable(String property);
|
||||
|
||||
/**
|
||||
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was added, false if not.
|
||||
*/
|
||||
boolean addToVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
|
||||
* from.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was removed, false if not.
|
||||
*/
|
||||
boolean removeFromVariable(String property, String value);
|
||||
WorldType getWorldType();
|
||||
|
||||
/**
|
||||
* Gets the environment of this world.
|
||||
@@ -124,27 +68,168 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
void setEnvironment(World.Environment environment);
|
||||
|
||||
/**
|
||||
* Gets the difficulty of this world.
|
||||
*
|
||||
* @return The difficulty of this world.
|
||||
*/
|
||||
Difficulty getDifficulty();
|
||||
|
||||
/**
|
||||
* Sets the difficulty of this world and returns true if success.
|
||||
* Valid string values are either an integer of difficulty(0-3) or
|
||||
* the name that resides in the Bukkit enum, ex. {@code PEACEFUL}
|
||||
*
|
||||
* @param difficulty The difficulty to set the world to as a string.
|
||||
* @return True if success, false if the provided string
|
||||
* could not be translated to a difficulty.
|
||||
* @deprecated Use {@link #setDifficulty(Difficulty)} or, if you have to
|
||||
* pass a string, use {@link #setPropertyValue(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setDifficulty(String difficulty);
|
||||
|
||||
/**
|
||||
* Sets the difficulty of this world and returns {@code true} on success.
|
||||
* Valid string values are either an integer of difficulty(0-3) or
|
||||
* the name that resides in the Bukkit enum, ex. PEACEFUL
|
||||
*
|
||||
* @param difficulty The new difficulty.
|
||||
* @return True if success, false if the operation failed... for whatever reason.
|
||||
*/
|
||||
boolean setDifficulty(Difficulty difficulty);
|
||||
|
||||
/**
|
||||
* Gets the world seed of this world.
|
||||
*
|
||||
* @return The Long version of the seed.
|
||||
*/
|
||||
Long getSeed();
|
||||
long getSeed();
|
||||
|
||||
/**
|
||||
* Sets the seed of this world.
|
||||
*
|
||||
* @param seed A Long that is the seed.
|
||||
*/
|
||||
void setSeed(Long seed);
|
||||
void setSeed(long seed);
|
||||
|
||||
/**
|
||||
* Gets the name of this world. This cannot be changed.
|
||||
* Gets the generator of this world.
|
||||
*
|
||||
* @return The name of the world as a String.
|
||||
* @return The name of the generator.
|
||||
*/
|
||||
String getName();
|
||||
String getGenerator();
|
||||
|
||||
/**
|
||||
* Sets the generator of this world.
|
||||
*
|
||||
* @param generator The new generator's name.
|
||||
*/
|
||||
void setGenerator(String generator);
|
||||
|
||||
/**
|
||||
* Gets the help-message for a property.
|
||||
* @param property The name of the property.
|
||||
* @return The help-message.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found.
|
||||
*/
|
||||
String getPropertyHelp(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Gets a property as {@link String}.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
* @return The string-representation of that property.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
String getPropertyValue(String property) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Sets a property to a given value.
|
||||
*
|
||||
* @param property The name of a world property to set.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was set, false if not.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
*/
|
||||
boolean setPropertyValue(String property, String value) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Gets the actual MVConfigProperty from this world.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
*
|
||||
* @param property The name of a world property to get.
|
||||
* @param expected The type of the expected property. Use Object.class if this doesn't matter for you.
|
||||
* @param <T> The type of the expected property.
|
||||
*
|
||||
* @return A valid MVWorldProperty.
|
||||
*
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
* @deprecated We don't use {@link com.onarandombox.MultiverseCore.configuration.MVConfigProperty} any longer!
|
||||
*/
|
||||
@Deprecated
|
||||
<T> com.onarandombox.MultiverseCore.configuration.MVConfigProperty<T> getProperty(String property, Class<T> expected) throws PropertyDoesNotExistException;
|
||||
|
||||
// old config
|
||||
/**
|
||||
* Adds the property to the given value.
|
||||
* It will throw a PropertyDoesNotExistException if the property is not found.
|
||||
*
|
||||
* @param property The name of a world property to set.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @param sender The sender who wants this value to be set.
|
||||
* @return True if the value was set, false if not.
|
||||
* @throws PropertyDoesNotExistException Thrown if the property was not found in the world.
|
||||
* @deprecated Use {@link #setPropertyValue(String, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean setProperty(String property, String value, CommandSender sender) throws PropertyDoesNotExistException;
|
||||
|
||||
/**
|
||||
* Adds a value to the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to add a value to.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was added, false if not.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean addToVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Removes a value from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to remove a value
|
||||
* from.
|
||||
* @param value A value in string representation, it will be parsed to the correct type.
|
||||
* @return True if the value was removed, false if not.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean removeFromVariable(String property, String value);
|
||||
|
||||
/**
|
||||
* Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}.
|
||||
*
|
||||
* @param property The name of a {@link com.onarandombox.MultiverseCore.enums.AddProperties} to clear.
|
||||
* @return True if it was cleared, false if not.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean clearVariable(String property);
|
||||
|
||||
/**
|
||||
* Clears a list property (sets it to []).
|
||||
*
|
||||
* @param property The property to clear.
|
||||
* @return True if success, false if fail.
|
||||
* @deprecated We changed the entire world-config-system. This is not compatible any more.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean clearList(String property);
|
||||
// end of old config stuff
|
||||
|
||||
// permission stuff
|
||||
/**
|
||||
* Gets the lowercased name of the world. This method is required, since the permissables
|
||||
* lowercase all permissions when recalculating.
|
||||
@@ -157,6 +242,21 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
String getPermissibleName();
|
||||
|
||||
/**
|
||||
* Gets the permission required to enter this world.
|
||||
*
|
||||
* @return The permission required to be exempt from charges to/from this world.
|
||||
*/
|
||||
Permission getAccessPermission();
|
||||
|
||||
/**
|
||||
* Gets the permission required to be exempt when entering.
|
||||
*
|
||||
* @return The permission required to be exempt when entering.
|
||||
*/
|
||||
Permission getExemptPermission();
|
||||
// end of permission stuff
|
||||
|
||||
/**
|
||||
* Gets the alias of this world.
|
||||
* <p>
|
||||
@@ -173,6 +273,13 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
void setAlias(String alias);
|
||||
|
||||
/**
|
||||
* Gets the color that this world's name/alias will display as.
|
||||
*
|
||||
* @return The color of this world.
|
||||
*/
|
||||
ChatColor getColor();
|
||||
|
||||
/**
|
||||
* Sets the color that this world's name/alias will display as.
|
||||
*
|
||||
@@ -181,19 +288,15 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
boolean setColor(String color);
|
||||
|
||||
/**
|
||||
* Gets the color that this world's name/alias will display as.
|
||||
*
|
||||
* @return The color of this world.
|
||||
*/
|
||||
ChatColor getColor();
|
||||
|
||||
/**
|
||||
* Tells you if someone entered a valid color.
|
||||
*
|
||||
* @param color A string that may translate to a color.
|
||||
* @return True if it is a color, false if not.
|
||||
*
|
||||
* @deprecated This has been moved: {@link com.onarandombox.MultiverseCore.enums.EnglishChatColor#isValidAliasColor(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isValidAliasColor(String color);
|
||||
|
||||
/**
|
||||
@@ -203,6 +306,7 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
String getColoredWorldString();
|
||||
|
||||
// animals&monster stuff
|
||||
/**
|
||||
* Gets whether or not animals are allowed to spawn in this world.
|
||||
*
|
||||
@@ -210,6 +314,22 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
boolean canAnimalsSpawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not animals can spawn.
|
||||
* If there are values in {@link #getAnimalList()} and this is false,
|
||||
* those animals become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
void setAllowAnimalSpawn(boolean allowAnimalSpawn);
|
||||
|
||||
/**
|
||||
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
|
||||
*
|
||||
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
|
||||
*/
|
||||
List<String> getAnimalList();
|
||||
|
||||
/**
|
||||
* Gets whether or not monsters are allowed to spawn in this world.
|
||||
*
|
||||
@@ -218,7 +338,31 @@ public interface MultiverseWorld {
|
||||
boolean canMonstersSpawn();
|
||||
|
||||
/**
|
||||
* Turn pvp on or off. This setting is used to set the world's PVP mode, and thus relies on fakePVP
|
||||
* Sets whether or not monsters can spawn.
|
||||
* If there are values in {@link #getMonsterList()} and this is false,
|
||||
* those monsters become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
|
||||
|
||||
/**
|
||||
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} result.
|
||||
*
|
||||
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
|
||||
*/
|
||||
List<String> getMonsterList();
|
||||
// end of animal&monster stuff
|
||||
|
||||
/**
|
||||
* Gets whether or not PVP is enabled in this world in some form (fake or not).
|
||||
*
|
||||
* @return True if players can take damage from other players.
|
||||
*/
|
||||
boolean isPVPEnabled();
|
||||
|
||||
/**
|
||||
* Turn pvp on or off. This setting is used to set the world's PVP mode.
|
||||
*
|
||||
* @param pvpMode True to enable PVP damage, false to disable it.
|
||||
*/
|
||||
@@ -233,13 +377,6 @@ public interface MultiverseWorld {
|
||||
@Deprecated
|
||||
boolean getFakePVP();
|
||||
|
||||
/**
|
||||
* Gets whether or not PVP is enabled in this world in some form (fake or not).
|
||||
*
|
||||
* @return True if players can take damage from other players.
|
||||
*/
|
||||
boolean isPVPEnabled();
|
||||
|
||||
/**
|
||||
* Gets whether or not this world will display in chat, mvw and mvl regardless if a user has the
|
||||
* access permissions to go to this world.
|
||||
@@ -256,6 +393,13 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
void setHidden(boolean hidden);
|
||||
|
||||
/**
|
||||
* Gets whether weather is enabled in this world.
|
||||
*
|
||||
* @return True if weather events will occur, false if not.
|
||||
*/
|
||||
boolean isWeatherEnabled();
|
||||
|
||||
/**
|
||||
* Sets whether or not there will be weather events in a given world.
|
||||
* If set to false, Multiverse will disable the weather in the world immediately.
|
||||
@@ -265,11 +409,11 @@ public interface MultiverseWorld {
|
||||
void setEnableWeather(boolean enableWeather);
|
||||
|
||||
/**
|
||||
* Gets whether weather is enabled in this world.
|
||||
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
|
||||
*
|
||||
* @return True if weather events will occur, false if not.
|
||||
* @return True if CraftBukkit is keeping spawn chunks in memory.
|
||||
*/
|
||||
boolean isWeatherEnabled();
|
||||
boolean isKeepingSpawnInMemory();
|
||||
|
||||
/**
|
||||
* If true, tells Craftbukkit to keep a worlds spawn chunks loaded in memory (default: true)
|
||||
@@ -281,29 +425,11 @@ public interface MultiverseWorld {
|
||||
void setKeepSpawnInMemory(boolean keepSpawnInMemory);
|
||||
|
||||
/**
|
||||
* Gets whether or not CraftBukkit is keeping the chunks for this world in memory.
|
||||
* Gets the spawn location of this world.
|
||||
*
|
||||
* @return True if CraftBukkit is keeping spawn chunks in memory.
|
||||
* @return The spawn location of this world.
|
||||
*/
|
||||
boolean isKeepingSpawnInMemory();
|
||||
|
||||
/**
|
||||
* Sets the difficulty of this world and returns true if success.
|
||||
* Valid string values are either an integer of difficulty(0-3) or
|
||||
* the name that resides in the Bukkit enum, ex. PEACEFUL
|
||||
*
|
||||
* @param difficulty The difficulty to set the world to as a string.
|
||||
* @return True if success, false if the provided string
|
||||
* could not be translated to a difficulty.
|
||||
*/
|
||||
boolean setDifficulty(String difficulty);
|
||||
|
||||
/**
|
||||
* Gets the difficulty of this world.
|
||||
*
|
||||
* @return The difficulty of this world.
|
||||
*/
|
||||
Difficulty getDifficulty();
|
||||
Location getSpawnLocation();
|
||||
|
||||
/**
|
||||
* Sets the spawn location for a world.
|
||||
@@ -313,11 +439,11 @@ public interface MultiverseWorld {
|
||||
void setSpawnLocation(Location spawnLocation);
|
||||
|
||||
/**
|
||||
* Gets the spawn location of this world.
|
||||
* Gets whether or not the hunger level of players will go down in a world.
|
||||
*
|
||||
* @return The spawn location of this world.
|
||||
* @return True if it will go down, false if it will remain steady.
|
||||
*/
|
||||
Location getSpawnLocation();
|
||||
boolean getHunger();
|
||||
|
||||
/**
|
||||
* Sets whether or not the hunger level of players will go down in a world.
|
||||
@@ -327,22 +453,6 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
void setHunger(boolean hungerEnabled);
|
||||
|
||||
/**
|
||||
* Gets whether or not the hunger level of players will go down in a world.
|
||||
*
|
||||
* @return True if it will go down, false if it will remain steady.
|
||||
*/
|
||||
boolean getHunger();
|
||||
|
||||
/**
|
||||
* Sets the game mode of this world.
|
||||
*
|
||||
* @param gameMode A valid game mode string (either
|
||||
* an int ex. 0 or a string ex. creative).
|
||||
* @return True if the game mode was successfully changed, false if not.
|
||||
*/
|
||||
boolean setGameMode(String gameMode);
|
||||
|
||||
/**
|
||||
* Gets the GameMode of this world.
|
||||
*
|
||||
@@ -351,18 +461,31 @@ public interface MultiverseWorld {
|
||||
GameMode getGameMode();
|
||||
|
||||
/**
|
||||
* Gets the permission required to enter this world.
|
||||
* Sets the game mode of this world.
|
||||
*
|
||||
* @return The permission required to be exempt from charges to/from this world.
|
||||
* @param gameMode A valid game mode string (either
|
||||
* an int ex. 0 or a string ex. creative).
|
||||
* @return True if the game mode was successfully changed, false if not.
|
||||
* @deprecated Use {@link #setGameMode(GameMode)} instead. If you have to
|
||||
* pass a string, use {@link #setPropertyValue(String, String)}.
|
||||
*/
|
||||
Permission getAccessPermission();
|
||||
@Deprecated
|
||||
boolean setGameMode(String gameMode);
|
||||
|
||||
/**
|
||||
* Gets the permission required to be exempt when entering.
|
||||
* Sets the game mode of this world.
|
||||
*
|
||||
* @return The permission required to be exempt when entering.
|
||||
* @param gameMode The new {@link GameMode}.
|
||||
* @return True if the game mode was successfully changed, false if not.
|
||||
*/
|
||||
Permission getExemptPermission();
|
||||
boolean setGameMode(GameMode gameMode);
|
||||
|
||||
/**
|
||||
* Gets the amount of currency it requires to enter this world.
|
||||
*
|
||||
* @return The amount it costs to enter this world.
|
||||
*/
|
||||
double getPrice();
|
||||
|
||||
/**
|
||||
* Sets the price for entry to this world.
|
||||
@@ -374,11 +497,11 @@ public interface MultiverseWorld {
|
||||
void setPrice(double price);
|
||||
|
||||
/**
|
||||
* Gets the amount of currency it requires to enter this world.
|
||||
* Gets the Type of currency that will be used when users enter this world.
|
||||
*
|
||||
* @return The amount it costs to enter this world.
|
||||
* @return The Type of currency that will be used when users enter this world.
|
||||
*/
|
||||
double getPrice();
|
||||
int getCurrency();
|
||||
|
||||
/**
|
||||
* Sets the type of item that will be required given the price is not 0.
|
||||
@@ -389,11 +512,11 @@ public interface MultiverseWorld {
|
||||
void setCurrency(int item);
|
||||
|
||||
/**
|
||||
* Gets the Type of currency that will be used when users enter this world.
|
||||
* Gets the world players will respawn in if they die in this one.
|
||||
*
|
||||
* @return The Type of currency that will be used when users enter this world.
|
||||
* @return A world that exists on the server.
|
||||
*/
|
||||
int getCurrency();
|
||||
World getRespawnToWorld();
|
||||
|
||||
/**
|
||||
* Sets the world players will respawn in if they die in this one.
|
||||
@@ -405,11 +528,12 @@ public interface MultiverseWorld {
|
||||
boolean setRespawnToWorld(String respawnWorld);
|
||||
|
||||
/**
|
||||
* Gets the world players will respawn in if they die in this one.
|
||||
* Gets the scaling value of this world.Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
*
|
||||
* @return A world that exists on the server.
|
||||
* @return This world's non-negative, non-zero scale.
|
||||
*/
|
||||
World getRespawnToWorld();
|
||||
double getScaling();
|
||||
|
||||
/**
|
||||
* Sets the scale of this world. Really only has an effect if you use
|
||||
@@ -421,60 +545,11 @@ public interface MultiverseWorld {
|
||||
boolean setScaling(double scaling);
|
||||
|
||||
/**
|
||||
* Gets the scaling value of this world.Really only has an effect if you use
|
||||
* Multiverse-NetherPortals.
|
||||
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
|
||||
*
|
||||
* @return This world's non-negative, non-zero scale.
|
||||
* @return True if the world should heal (default), false if not.
|
||||
*/
|
||||
double getScaling();
|
||||
|
||||
/**
|
||||
* Gets a list of all the worlds that players CANNOT travel to from this world,
|
||||
* regardless of their access permissions.
|
||||
*
|
||||
* @return A List of world names.
|
||||
*/
|
||||
List<String> getWorldBlacklist();
|
||||
|
||||
/**
|
||||
* Returns a list of animals. This list always negates the {@link #canAnimalsSpawn()} result.
|
||||
*
|
||||
* @return A list of animals that will spawn if {@link #canAnimalsSpawn()} is false.
|
||||
*/
|
||||
List<String> getAnimalList();
|
||||
|
||||
/**
|
||||
* Sets whether or not animals can spawn.
|
||||
* If there are values in {@link #getAnimalList()} and this is false,
|
||||
* those animals become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowAnimalSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
void setAllowAnimalSpawn(boolean allowAnimalSpawn);
|
||||
|
||||
/**
|
||||
* Returns a list of monsters. This list always negates the {@link #canMonstersSpawn()} ()} result.
|
||||
*
|
||||
* @return A list of monsters that will spawn if {@link #canMonstersSpawn()} is false.
|
||||
*/
|
||||
List<String> getMonsterList();
|
||||
|
||||
/**
|
||||
* Sets whether or not monsters can spawn.
|
||||
* If there are values in {@link #getMonsterList()} and this is false,
|
||||
* those monsters become the exceptions, and will spawn
|
||||
*
|
||||
* @param allowMonsterSpawn True to allow spawning of monsters, false to prevent.
|
||||
*/
|
||||
void setAllowMonsterSpawn(boolean allowMonsterSpawn);
|
||||
|
||||
/**
|
||||
* Clears a list property (sets it to []).
|
||||
*
|
||||
* @param property The property to clear.
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
boolean clearList(String property);
|
||||
boolean getAutoHeal();
|
||||
|
||||
/**
|
||||
* Sets whether or not a world will auto-heal players if the difficulty is on peaceful.
|
||||
@@ -484,11 +559,11 @@ public interface MultiverseWorld {
|
||||
void setAutoHeal(boolean heal);
|
||||
|
||||
/**
|
||||
* Gets whether or not a world will auto-heal players if the difficulty is on peaceful.
|
||||
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
|
||||
*
|
||||
* @return True if the world should heal (default), false if not.
|
||||
* @return True if Multiverse should adjust the spawn, false if not.
|
||||
*/
|
||||
boolean getAutoHeal();
|
||||
boolean getAdjustSpawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not Multiverse should auto-adjust the spawn for this world.
|
||||
@@ -498,11 +573,11 @@ public interface MultiverseWorld {
|
||||
void setAdjustSpawn(boolean adjust);
|
||||
|
||||
/**
|
||||
* Gets whether or not Multiverse should auto-adjust the spawn for this world.
|
||||
* Gets whether or not Multiverse should auto-load this world.
|
||||
*
|
||||
* @return True if Multiverse should adjust the spawn, false if not.
|
||||
* @return True if Multiverse should auto-load this world.
|
||||
*/
|
||||
boolean getAdjustSpawn();
|
||||
boolean getAutoLoad();
|
||||
|
||||
/**
|
||||
* Sets whether or not Multiverse should auto-load this world.
|
||||
@@ -514,11 +589,12 @@ public interface MultiverseWorld {
|
||||
void setAutoLoad(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Gets whether or not Multiverse should auto-load this world.
|
||||
* Gets whether or not a player who dies in this world will respawn in their
|
||||
* bed or follow the normal respawn pattern.
|
||||
*
|
||||
* @return True if Multiverse should auto-load this world.
|
||||
* @return True if players dying in this world should respawn at their bed.
|
||||
*/
|
||||
boolean getAutoLoad();
|
||||
boolean getBedRespawn();
|
||||
|
||||
/**
|
||||
* Sets whether or not a player who dies in this world will respawn in their
|
||||
@@ -531,19 +607,10 @@ public interface MultiverseWorld {
|
||||
void setBedRespawn(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Gets whether or not a player who dies in this world will respawn in their
|
||||
* bed or follow the normal respawn pattern.
|
||||
*
|
||||
* @return True if players dying in this world should respawn at their bed.
|
||||
* Same as {@link #getTime()}, but returns a string.
|
||||
* @return The time as a short string: 12:34pm
|
||||
*/
|
||||
boolean getBedRespawn();
|
||||
|
||||
/**
|
||||
* Gets all the names of all properties that can be SET.
|
||||
*
|
||||
* @return All property names, with alternating colors.
|
||||
*/
|
||||
String getAllPropertyNames();
|
||||
String getTime();
|
||||
|
||||
/**
|
||||
* Sets the current time in a world.
|
||||
@@ -559,18 +626,53 @@ public interface MultiverseWorld {
|
||||
boolean setTime(String timeAsString);
|
||||
|
||||
/**
|
||||
* Same as {@link #getTime()}, but returns a string.
|
||||
* @return The time as a short string: 12:34pm
|
||||
* Sets The types of portals that are allowed in this world.
|
||||
*
|
||||
* @param type The type of portals allowed in this world.
|
||||
*/
|
||||
String getTime();
|
||||
void allowPortalMaking(AllowedPortalType type);
|
||||
|
||||
/**
|
||||
* Gets the type of this world. As of 1.1-R1 this will be:
|
||||
* FLAT or NORMAL
|
||||
* <p>
|
||||
* This is *not* the generator.
|
||||
* Gets which type(s) of portals are allowed to be constructed in this world.
|
||||
*
|
||||
* @return The Type of this world.
|
||||
* @return The type of portals that are allowed.
|
||||
*/
|
||||
WorldType getWorldType();
|
||||
AllowedPortalType getAllowedPortals();
|
||||
|
||||
// properties that are not "getter+setter" style
|
||||
/**
|
||||
* Gets a list of all the worlds that players CANNOT travel to from this world,
|
||||
* regardless of their access permissions.
|
||||
*
|
||||
* @return A List of world names.
|
||||
*/
|
||||
List<String> getWorldBlacklist();
|
||||
|
||||
/**
|
||||
* Gets all the names of all properties that can be SET.
|
||||
*
|
||||
* @return All property names, with alternating colors.
|
||||
*/
|
||||
String getAllPropertyNames();
|
||||
|
||||
/**
|
||||
* Gets whether or not flight is allowed in this world.
|
||||
* <p>
|
||||
* It should be noted that this refers to clientside flying. Creative
|
||||
* mode will always allow server based flying.
|
||||
*
|
||||
* @return True if flight is allowed.
|
||||
*/
|
||||
boolean isFlightAllowed();
|
||||
|
||||
/**
|
||||
* Sets whether or not flight is allowed in this world.
|
||||
* <p>
|
||||
* It should be noted that this refers to clientside flying. Creative
|
||||
* mode will always allow server based flying.
|
||||
*
|
||||
* @param flightAllowed Wheter or not flight is allowed in this world.
|
||||
*/
|
||||
void setFlightAllowed(boolean flightAllowed);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import com.onarandombox.MultiverseCore.enums.TeleportResult;
|
||||
|
||||
/**
|
||||
* Used to safely teleport people.
|
||||
*/
|
||||
public interface SafeTTeleporter {
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
* @param l A {@link Location}.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
Location getSafeLocation(Location l);
|
||||
|
||||
/**
|
||||
* Gets the next safe location around the given location.
|
||||
* @param l A {@link Location}.
|
||||
* @param tolerance The tolerance.
|
||||
* @param radius The radius.
|
||||
* @return A safe {@link Location}.
|
||||
*/
|
||||
Location getSafeLocation(Location l, int tolerance, int radius);
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the MVDestination. This will perform checks to see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who performed the teleport command.
|
||||
* @param teleportee Entity to teleport
|
||||
* @param d Destination to teleport them to
|
||||
* @return true for success, false for failure
|
||||
*/
|
||||
TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d);
|
||||
|
||||
/**
|
||||
* Safely teleport the entity to the Location. This may perform checks to
|
||||
* see if the place is safe, and if
|
||||
* it's not, will adjust the final destination accordingly.
|
||||
*
|
||||
* @param teleporter Person who issued the teleport command.
|
||||
* @param teleportee Entity to teleport.
|
||||
* @param location Location to teleport them to.
|
||||
* @param safely Should the destination be checked for safety before teleport?
|
||||
* @return true for success, false for failure.
|
||||
*/
|
||||
TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, Location location,
|
||||
boolean safely);
|
||||
|
||||
/**
|
||||
* Returns a safe location for the entity to spawn at.
|
||||
*
|
||||
* @param e The entity to spawn
|
||||
* @param d The MVDestination to take the entity to.
|
||||
* @return A new location to spawn the entity at.
|
||||
*/
|
||||
Location getSafeLocation(Entity e, MVDestination d);
|
||||
|
||||
/**
|
||||
* Finds a portal-block next to the specified {@link Location}.
|
||||
* @param l The {@link Location}
|
||||
* @return The next portal-block's {@link Location}.
|
||||
*/
|
||||
Location findPortalBlockNextTo(Location l);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* Used to remove animals from worlds that don't belong there.
|
||||
*/
|
||||
public interface WorldPurger {
|
||||
|
||||
/**
|
||||
* Synchronizes the given world with it's settings.
|
||||
*
|
||||
* @param worlds A list of {@link MultiverseWorld}
|
||||
*/
|
||||
void purgeWorlds(List<MultiverseWorld> worlds);
|
||||
|
||||
/**
|
||||
* Convenience method for {@link #purgeWorld(CommandSender, MultiverseWorld, List, boolean, boolean)} that takes the settings from the world-config.
|
||||
*
|
||||
* @param world The {@link MultiverseWorld}.
|
||||
*/
|
||||
void purgeWorld(MultiverseWorld world);
|
||||
|
||||
/**
|
||||
* Clear all animals/monsters that do not belong to a world according to the config.
|
||||
*
|
||||
* @param mvworld The {@link MultiverseWorld}.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
* @param negateMonsters Whether the animals in the list should be negated.
|
||||
*/
|
||||
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
|
||||
boolean negateMonsters);
|
||||
|
||||
/**
|
||||
* Clear all animals/monsters that do not belong to a world according to the config.
|
||||
*
|
||||
* @param mvworld The {@link MultiverseWorld}.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
* @param negateMonsters Whether the animals in the list should be negated.
|
||||
* @param sender The {@link CommandSender} that initiated the action. He will/should be notified.
|
||||
*/
|
||||
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
|
||||
boolean negateMonsters, CommandSender sender);
|
||||
|
||||
}
|
||||
@@ -85,6 +85,8 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
|
||||
if (filterObject.getPage() > totalPages) {
|
||||
filterObject.setPage(totalPages);
|
||||
} else if (filterObject.getPage() < 1) {
|
||||
filterObject.setPage(1);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + " Page " + filterObject.getPage() + " of " + totalPages);
|
||||
@@ -98,7 +100,11 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
this.showList(sender, args);
|
||||
return;
|
||||
}
|
||||
if (args.size() == 2) {
|
||||
if (args.size() == 1 && (this.getPageAndFilter(args).getPage() != 1 || args.get(0).equals("1"))) {
|
||||
this.showList(sender, args);
|
||||
return;
|
||||
}
|
||||
if (args.size() == 2 && args.get(1).equalsIgnoreCase("-d")) {
|
||||
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
|
||||
} else {
|
||||
@@ -111,6 +117,7 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
sender.sendMessage("You must be a player to create Anchors.");
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
|
||||
|
||||
@@ -45,18 +45,13 @@ public class CheckCommand extends MultiverseCommand {
|
||||
}
|
||||
MVDestination dest = this.plugin.getDestFactory().getDestination(args.get(1));
|
||||
if (dest instanceof InvalidDestination) {
|
||||
sender.sendMessage("You asked if '" + args.get(0) + "' could go to " + ChatColor.GREEN + args.get(0) + ChatColor.WHITE + ",");
|
||||
sender.sendMessage(String.format("You asked if '%s' could go to %s%s%s,",
|
||||
args.get(0), ChatColor.GREEN, args.get(0), ChatColor.WHITE));
|
||||
sender.sendMessage("but I couldn't find a Destination of that name? Did you type it correctly?");
|
||||
return;
|
||||
}
|
||||
|
||||
MVPermissions perms = this.plugin.getMVPerms();
|
||||
if (perms.canEnterDestination(p, dest)) {
|
||||
sender.sendMessage(ChatColor.GREEN + args.get(0) + ChatColor.WHITE + " can travel to " + ChatColor.GREEN + args.get(1));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.AQUA + args.get(0) + ChatColor.RED + " CANNOT travel to " + ChatColor.AQUA + args.get(1));
|
||||
sender.sendMessage("Please turn debug mode to 3 then watch the console to find out why!");
|
||||
sender.sendMessage("Use: " + ChatColor.GREEN + "/mv debug 3");
|
||||
}
|
||||
perms.tellMeWhyICantDoThis(sender, p, dest);
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,12 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.enums.ConfigProperty;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Allows you to set Global MV Variables.
|
||||
@@ -28,7 +28,6 @@ public class ConfigCommand extends MultiverseCommand {
|
||||
this.addKey("mvconfig");
|
||||
this.addKey("mv conf");
|
||||
this.addKey("mvconf");
|
||||
this.addCommandExample("All values: " + ConfigProperty.getAllValues());
|
||||
this.addCommandExample("/mv config show");
|
||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "debug" + ChatColor.AQUA + " 3");
|
||||
this.addCommandExample("/mv config " + ChatColor.GREEN + "enforceaccess" + ChatColor.AQUA + " false");
|
||||
@@ -38,55 +37,31 @@ public class ConfigCommand extends MultiverseCommand {
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() <= 1) {
|
||||
String[] allProps = ConfigProperty.getAllValues().split(" ");
|
||||
String currentvals = "";
|
||||
for (String prop : allProps) {
|
||||
currentvals += ChatColor.GREEN;
|
||||
currentvals += prop;
|
||||
currentvals += ChatColor.WHITE;
|
||||
currentvals += " = ";
|
||||
currentvals += ChatColor.GOLD;
|
||||
currentvals += this.plugin.getMVConfiguration().get(prop, "NOT SET");
|
||||
currentvals += ChatColor.WHITE;
|
||||
currentvals += ", ";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Map<String, Object> serializedConfig = this.plugin.getMVConfig().serialize();
|
||||
for (Map.Entry<String, Object> entry : serializedConfig.entrySet()) {
|
||||
builder.append(ChatColor.GREEN);
|
||||
builder.append(entry.getKey());
|
||||
builder.append(ChatColor.WHITE).append(" = ").append(ChatColor.GOLD);
|
||||
builder.append(entry.getValue().toString());
|
||||
builder.append(ChatColor.WHITE).append(", ");
|
||||
}
|
||||
sender.sendMessage(currentvals.substring(0, currentvals.length() - 2));
|
||||
String message = builder.toString();
|
||||
message = message.substring(0, message.length() - 2);
|
||||
sender.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
if (!this.plugin.getMVConfig().setConfigProperty(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")) {
|
||||
this.plugin.getMVConfiguration().set(args.get(0).toLowerCase(), args.get(1));
|
||||
// Don't forget to set the world!
|
||||
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()) {
|
||||
sender.sendMessage(ChatColor.GREEN + "SUCCESS!" + ChatColor.WHITE + " Values were updated successfully!");
|
||||
this.plugin.loadConfigs();
|
||||
|
||||
@@ -10,7 +10,6 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -61,8 +60,8 @@ public class CoordCommand extends MultiverseCommand {
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + LocationManipulation.strCoords(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + LocationManipulation.getDirection(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Coordinates: " + ChatColor.WHITE + plugin.getLocationManipulation().strCoords(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Direction: " + ChatColor.WHITE + plugin.getLocationManipulation().getDirection(p.getLocation()));
|
||||
p.sendMessage(ChatColor.AQUA + "Block: " + ChatColor.WHITE + Material.getMaterial(world.getBlockTypeIdAt(p.getLocation())));
|
||||
} else {
|
||||
sender.sendMessage("This command needs to be used from a Player.");
|
||||
|
||||
@@ -29,8 +29,9 @@ public class CreateCommand extends MultiverseCommand {
|
||||
public CreateCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Create World");
|
||||
this.setCommandUsage("/mv create" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -s [SEED] -g [GENERATOR[:ID]] -t [WORLDTYPE] [-n]");
|
||||
this.setArgRange(2, 9); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
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.addKey("mvcreate");
|
||||
this.addKey("mvc");
|
||||
this.addKey("mv create");
|
||||
@@ -51,6 +52,11 @@ public class CreateCommand extends MultiverseCommand {
|
||||
String env = args.get(1);
|
||||
String seed = CommandHandler.getFlag("-s", args);
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
boolean allowStructures = true;
|
||||
String structureString = CommandHandler.getFlag("-a", args);
|
||||
if (structureString != null) {
|
||||
allowStructures = Boolean.parseBoolean(structureString);
|
||||
}
|
||||
String typeString = CommandHandler.getFlag("-t", args);
|
||||
boolean useSpawnAdjust = true;
|
||||
for (String s : args) {
|
||||
@@ -58,6 +64,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
useSpawnAdjust = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (worldFile.exists() || this.worldManager.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
|
||||
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
|
||||
@@ -84,7 +91,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
|
||||
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
|
||||
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, type, generator, useSpawnAdjust)) {
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, type, allowStructures, generator, useSpawnAdjust)) {
|
||||
Command.broadcastCommandMessage(sender, "Complete!");
|
||||
} else {
|
||||
Command.broadcastCommandMessage(sender, "FAILED.");
|
||||
|
||||
@@ -36,14 +36,14 @@ public class DebugCommand extends MultiverseCommand {
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("off")) {
|
||||
MultiverseCore.GlobalDebug = 0;
|
||||
plugin.getMVConfig().setGlobalDebug(0);
|
||||
} else {
|
||||
try {
|
||||
int debugLevel = Integer.parseInt(args.get(0));
|
||||
if (debugLevel > 3 || debugLevel < 0) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
MultiverseCore.GlobalDebug = debugLevel;
|
||||
plugin.getMVConfig().setGlobalDebug(debugLevel);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
|
||||
+ " 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) {
|
||||
if (MultiverseCore.GlobalDebug == 0) {
|
||||
if (plugin.getMVConfig().getGlobalDebug() == 0) {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||
} 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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ public class EnvironmentCommand extends MultiverseCommand {
|
||||
*/
|
||||
public static void showWorldTypes(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Valid World Types are:");
|
||||
sender.sendMessage(String.format("%sNORMAL %sor %sFLAT",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA));
|
||||
sender.sendMessage(String.format("%sNORMAL%s, %sFLAT %sor %sVERSION_1_1",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, ChatColor.WHITE, ChatColor.GOLD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,6 +91,7 @@ public class EnvironmentCommand extends MultiverseCommand {
|
||||
* @return The environment as {@link org.bukkit.World.Environment}
|
||||
*/
|
||||
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
|
||||
if (env.equalsIgnoreCase("HELL") || env.equalsIgnoreCase("NETHER"))
|
||||
env = "NETHER";
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
@@ -33,14 +32,14 @@ public class ImportCommand extends MultiverseCommand {
|
||||
public ImportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Import World");
|
||||
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV} " + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n] -t [TYPE]");
|
||||
this.setArgRange(2, 5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.setCommandUsage("/mv import" + ChatColor.GREEN + " {NAME} {ENV}" + ChatColor.GOLD + " -g [GENERATOR[:ID]] [-n]");
|
||||
this.setArgRange(1, 5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.addKey("mvimport");
|
||||
this.addKey("mvim");
|
||||
this.addKey("mv import");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "gargamel" + ChatColor.GREEN + " normal");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "flatroom" + ChatColor.GREEN + " normal" + ChatColor.AQUA + " -t flat");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "hell_world" + ChatColor.GREEN + " nether");
|
||||
this.addCommandExample("To import a world that uses a generator, you'll need the generator:");
|
||||
this.addCommandExample("/mv import " + ChatColor.GOLD + "CleanRoom" + ChatColor.GREEN + " normal" + ChatColor.DARK_AQUA + " CleanRoomGenerator");
|
||||
this.setPermission("multiverse.core.import", "Imports a new world of the specified type.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
@@ -53,7 +52,7 @@ public class ImportCommand extends MultiverseCommand {
|
||||
* @param worldFolder The File that may be a world.
|
||||
* @return True if it looks like a world, false if not.
|
||||
*/
|
||||
private boolean checkIfIsWorld(File worldFolder) {
|
||||
private static boolean checkIfIsWorld(File worldFolder) {
|
||||
if (worldFolder.isDirectory()) {
|
||||
File[] files = worldFolder.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
@@ -128,7 +127,6 @@ public class ImportCommand extends MultiverseCommand {
|
||||
File worldFile = new File(this.plugin.getServer().getWorldContainer(), worldName);
|
||||
|
||||
String generator = CommandHandler.getFlag("-g", args);
|
||||
String typeString = CommandHandler.getFlag("-t", args);
|
||||
boolean useSpawnAdjust = true;
|
||||
for (String s : args) {
|
||||
if (s.equalsIgnoreCase("-n")) {
|
||||
@@ -144,20 +142,9 @@ public class ImportCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// If they didn't specify a type, default to NORMAL
|
||||
if (typeString == null) {
|
||||
typeString = "NORMAL";
|
||||
}
|
||||
WorldType type = EnvironmentCommand.getWorldTypeFromString(typeString);
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid World Type.");
|
||||
EnvironmentCommand.showWorldTypes(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldFile.exists() && env != null) {
|
||||
Command.broadcastCommandMessage(sender, String.format("Starting import of world '%s'...", worldName));
|
||||
if (this.worldManager.addWorld(worldName, environment, null, type, generator, useSpawnAdjust))
|
||||
if (this.worldManager.addWorld(worldName, environment, null, null, null, generator, useSpawnAdjust))
|
||||
Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Complete!");
|
||||
else
|
||||
Command.broadcastCommandMessage(sender, ChatColor.RED + "Failed!");
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.FancyColorScheme;
|
||||
import com.onarandombox.MultiverseCore.utils.FancyHeader;
|
||||
import com.onarandombox.MultiverseCore.utils.FancyMessage;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -62,9 +61,13 @@ public class InfoCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
} 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!
|
||||
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 {
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
@@ -72,7 +75,8 @@ public class InfoCommand extends MultiverseCommand {
|
||||
try {
|
||||
pageNum = Integer.parseInt(args.get(0)) - 1;
|
||||
} catch (NumberFormatException e) {
|
||||
pageNum = 0;
|
||||
sender.sendMessage("That world does not exist.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("You must enter a" + ChatColor.LIGHT_PURPLE + " world" + ChatColor.WHITE + " from the console!");
|
||||
@@ -94,8 +98,11 @@ public class InfoCommand extends MultiverseCommand {
|
||||
p = (Player) sender;
|
||||
}
|
||||
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) {
|
||||
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("For available environments type " + ChatColor.GREEN + "/mv env");
|
||||
}
|
||||
@@ -110,10 +117,11 @@ public class InfoCommand extends MultiverseCommand {
|
||||
message.add(new FancyMessage("World Name: ", world.getName(), colors));
|
||||
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
|
||||
message.add(new FancyMessage("Game Mode: ", world.getGameMode().toString(), colors));
|
||||
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
|
||||
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
|
||||
|
||||
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
|
||||
Location spawn = world.getSpawnLocation();
|
||||
message.add(new FancyMessage("Spawn Location: ", LocationManipulation.strCoords(spawn), colors));
|
||||
message.add(new FancyMessage("Spawn Location: ", plugin.getLocationManipulation().strCoords(spawn), colors));
|
||||
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
|
||||
if (world.getPrice() > 0) {
|
||||
message.add(new FancyMessage("Price to enter this world: ",
|
||||
@@ -136,7 +144,8 @@ public class InfoCommand extends MultiverseCommand {
|
||||
// Page 2
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("More World Settings", colors));
|
||||
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
|
||||
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
|
||||
message.add(new FancyMessage("Structures: ", world.getCBWorld().canGenerateStructures() + "", colors));
|
||||
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
|
||||
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
|
||||
message.add(new FancyMessage("Keep spawn in memory: ", world.isKeepingSpawnInMemory() + "", colors));
|
||||
@@ -181,7 +190,7 @@ public class InfoCommand extends MultiverseCommand {
|
||||
return worldInfo;
|
||||
}
|
||||
|
||||
private String toCommaSeperated(List<String> list) {
|
||||
private static String toCommaSeperated(List<String> list) {
|
||||
if (list == null || list.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
@@ -207,7 +216,7 @@ public class InfoCommand extends MultiverseCommand {
|
||||
return positive ? ChatColor.GREEN : ChatColor.RED;
|
||||
}
|
||||
|
||||
private void showPage(int page, CommandSender sender, List<List<FancyText>> doc) {
|
||||
private static void showPage(int page, CommandSender sender, List<List<FancyText>> doc) {
|
||||
page = page < 0 ? 0 : page;
|
||||
page = page > doc.size() - 1 ? doc.size() - 1 : page;
|
||||
boolean altColor = false;
|
||||
|
||||
@@ -52,14 +52,16 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
||||
} else if (env == Environment.THE_END) {
|
||||
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 (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]"
|
||||
worldList.add(ChatColor.GRAY + "[H]" + outputCache);
|
||||
worldList.add(ChatColor.GRAY + "[H]" + builder.toString());
|
||||
}
|
||||
} else {
|
||||
worldList.add(outputCache);
|
||||
worldList.add(builder.toString());
|
||||
}
|
||||
}
|
||||
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
|
||||
|
||||
@@ -81,6 +81,7 @@ public class ModifyAddCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO fix this
|
||||
if (world.addToVariable(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA
|
||||
+ value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
|
||||
|
||||
@@ -75,6 +75,7 @@ public class ModifyClearCommand extends MultiverseCommand {
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/cgB2B");
|
||||
return;
|
||||
}
|
||||
// TODO fix this
|
||||
if (world.clearList(property)) {
|
||||
sender.sendMessage(property + " was cleared. It contains 0 values now.");
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + property + ChatColor.WHITE + " was "
|
||||
|
||||
@@ -81,6 +81,7 @@ public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
sender.sendMessage("Please visit our Github Wiki for more information: http://goo.gl/4W8cY");
|
||||
return;
|
||||
}
|
||||
// TODO fix this
|
||||
if (world.removeFromVariable(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE
|
||||
+ " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
|
||||
|
||||
@@ -102,22 +102,21 @@ public class ModifySetCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !world.isValidAliasColor(value)) {
|
||||
if ((property.equalsIgnoreCase("aliascolor") || property.equalsIgnoreCase("color")) && !EnglishChatColor.isValidAliasColor(value)) {
|
||||
sender.sendMessage(value + " is not a valid color. Please pick one of the following:");
|
||||
sender.sendMessage(EnglishChatColor.getAllColors());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (world.setProperty(property, value, sender)) {
|
||||
if (world.setPropertyValue(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property
|
||||
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||
} else {
|
||||
sender.sendMessage(world.getProperty(property, Object.class).getHelp());
|
||||
sender.sendMessage(ChatColor.RED + world.getPropertyHelp(property));
|
||||
}
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + property + ChatColor.RED + "'");
|
||||
// TODO: Display the list
|
||||
sender.sendMessage(ChatColor.GOLD + "For a full list of thingys, see our wiki.");
|
||||
sender.sendMessage("Valid world-properties: " + world.getAllPropertyNames());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.utils.MVMessaging;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||
import com.pneumaticraft.commandhandler.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -24,9 +24,9 @@ public abstract class MultiverseCommand extends Command {
|
||||
*/
|
||||
protected MultiverseCore plugin;
|
||||
/**
|
||||
* The reference to {@link MVMessaging}.
|
||||
* The reference to {@link MultiverseMessaging}.
|
||||
*/
|
||||
protected MVMessaging messaging;
|
||||
protected MultiverseMessaging messaging;
|
||||
|
||||
public MultiverseCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -10,7 +10,7 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.PurgeWorlds;
|
||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -65,7 +65,7 @@ public class PurgeCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
if (!worldName.equalsIgnoreCase("all") && !this.worldManager.isMVWorld(worldName)) {
|
||||
((MultiverseCore) this.plugin).showNotMVWorldMessage(sender, worldName);
|
||||
this.plugin.showNotMVWorldMessage(sender, worldName);
|
||||
sender.sendMessage("It cannot be purged.");
|
||||
return;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class PurgeCommand extends MultiverseCommand {
|
||||
worldsToRemoveEntitiesFrom.add(this.worldManager.getMVWorld(worldName));
|
||||
}
|
||||
|
||||
PurgeWorlds purger = this.worldManager.getWorldPurger();
|
||||
WorldPurger purger = this.worldManager.getTheWorldPurger();
|
||||
ArrayList<String> thingsToKill = new ArrayList<String>();
|
||||
if (deathName.equalsIgnoreCase("all") || deathName.equalsIgnoreCase("animals") || deathName.equalsIgnoreCase("monsters")) {
|
||||
thingsToKill.add(deathName.toUpperCase());
|
||||
@@ -86,7 +86,7 @@ public class PurgeCommand extends MultiverseCommand {
|
||||
Collections.addAll(thingsToKill, deathName.toUpperCase().split(","));
|
||||
}
|
||||
for (MultiverseWorld w : worldsToRemoveEntitiesFrom) {
|
||||
purger.purgeWorld(sender, w, thingsToKill, false, false);
|
||||
purger.purgeWorld(w, thingsToKill, false, false, sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,8 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -56,7 +55,7 @@ public class SetSpawnCommand extends MultiverseCommand {
|
||||
MultiverseWorld foundWorld = this.plugin.getMVWorldManager().getMVWorld(w.getName());
|
||||
if (foundWorld != null) {
|
||||
foundWorld.setSpawnLocation(p.getLocation());
|
||||
BlockSafety bs = new BlockSafety();
|
||||
BlockSafety bs = this.plugin.getBlockSafety();
|
||||
if (!bs.playerCanSpawnHereSafely(p.getLocation()) && foundWorld.getAdjustSpawn()) {
|
||||
sender.sendMessage("It looks like that location would normally be unsafe. But I trust you.");
|
||||
sender.sendMessage("I'm turning off the Safe-T-Teleporter for spawns to this world.");
|
||||
@@ -64,7 +63,7 @@ public class SetSpawnCommand extends MultiverseCommand {
|
||||
sender.sendMessage(ChatColor.AQUA + "/mvm set adjustspawn true " + foundWorld.getAlias());
|
||||
foundWorld.setAdjustSpawn(false);
|
||||
}
|
||||
sender.sendMessage("Spawn was set to: " + LocationManipulation.strCoords(p.getLocation()));
|
||||
sender.sendMessage("Spawn was set to: " + plugin.getLocationManipulation().strCoords(p.getLocation()));
|
||||
} else {
|
||||
w.setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
sender.sendMessage("Multiverse does not know about this world, only X,Y and Z set. Please import it to set the spawn fully (Pitch/Yaws).");
|
||||
|
||||
@@ -85,6 +85,6 @@ public class SpawnCommand extends MultiverseCommand {
|
||||
} else {
|
||||
spawnLocation = player.getWorld().getSpawnLocation();
|
||||
}
|
||||
this.plugin.getTeleporter().safelyTeleport(player, player, spawnLocation, false);
|
||||
this.plugin.getSafeTTeleporter().safelyTeleport(player, player, spawnLocation, false);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Edit a world with spout.
|
||||
*/
|
||||
* /
|
||||
public class SpoutCommand extends MultiverseCommand {
|
||||
|
||||
public SpoutCommand(MultiverseCore plugin) {
|
||||
@@ -51,7 +51,7 @@ public class SpoutCommand extends MultiverseCommand {
|
||||
}
|
||||
PopupScreen pop = new GenericPopup();
|
||||
GenericButton button = new GenericButton("Fish");
|
||||
// TODO maybe use constants for these
|
||||
// TO-DO maybe use constants for these
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
button.setX(50);
|
||||
button.setY(50);
|
||||
@@ -63,3 +63,4 @@ public class SpoutCommand extends MultiverseCommand {
|
||||
p.getMainScreen().attachPopupScreen(pop);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -14,8 +14,7 @@ import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.WorldDestination;
|
||||
import com.onarandombox.MultiverseCore.enums.TeleportResult;
|
||||
import com.onarandombox.MultiverseCore.event.MVTeleportEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -43,7 +42,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mvtp");
|
||||
this.addKey("mv tp");
|
||||
this.playerTeleporter = new SafeTTeleporter(this.plugin);
|
||||
this.playerTeleporter = this.plugin.getSafeTTeleporter();
|
||||
this.setPermission(menu);
|
||||
}
|
||||
|
||||
@@ -51,12 +50,8 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// Check if the command was sent from a Player.
|
||||
CommandSender teleporter = sender;
|
||||
Player teleportee = null;
|
||||
if (sender instanceof Player) {
|
||||
teleporter = (Player) sender;
|
||||
}
|
||||
|
||||
String destinationName;
|
||||
|
||||
@@ -111,7 +106,7 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
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)) {
|
||||
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
||||
} else {
|
||||
@@ -163,7 +158,8 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
}
|
||||
TeleportResult result = this.playerTeleporter.safelyTeleport(teleporter, teleportee, d);
|
||||
if (result == TeleportResult.FAIL_UNSAFE) {
|
||||
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName() + " to " + LocationManipulation.strCoordsRaw(d.getLocation(teleportee)));
|
||||
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName()
|
||||
+ " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee)));
|
||||
this.plugin.log(Level.FINE, "Queueing Command");
|
||||
Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
|
||||
List<Object> items = new ArrayList<Object>();
|
||||
|
||||
@@ -9,10 +9,13 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.BitlyURLShortener;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteFailedException;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteService;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.PasteServiceType;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.URLShortener;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -25,6 +28,7 @@ import java.util.logging.Level;
|
||||
* Dumps version info to the console.
|
||||
*/
|
||||
public class VersionCommand extends MultiverseCommand {
|
||||
private static final URLShortener SHORTENER = new BitlyURLShortener();
|
||||
|
||||
public VersionCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -39,7 +43,7 @@ public class VersionCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
public void runCommand(final CommandSender sender, final List<String> args) {
|
||||
// Check if the command was sent from a Player.
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage("Version info dumped to console. Please check your server logs.");
|
||||
@@ -53,41 +57,46 @@ public class VersionCommand extends MultiverseCommand {
|
||||
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] Dumping Config Values: (version ")
|
||||
.append(this.plugin.getMVConfiguration().getDouble("version", -1)).append(")").append('\n');
|
||||
buffer.append("[Multiverse-Core] messagecooldown: ").append(this.plugin.getMessaging().getCooldown()).append('\n');
|
||||
buffer.append("[Multiverse-Core] teleportcooldown: ").append("Not yet IMPLEMENTED").append('\n');
|
||||
buffer.append("[Multiverse-Core] worldnameprefix: ").append(MultiverseCore.PrefixChat).append('\n');
|
||||
buffer.append("[Multiverse-Core] enforceaccess: ").append(MultiverseCore.EnforceAccess).append('\n');
|
||||
buffer.append("[Multiverse-Core] displaypermerrors: ").append(MultiverseCore.DisplayPermErrors).append('\n');
|
||||
buffer.append("[Multiverse-Core] teleportintercept: ").append(MultiverseCore.TeleportIntercept).append('\n');
|
||||
buffer.append("[Multiverse-Core] firstspawnoverride: ").append(MultiverseCore.FirstSpawnOverride).append('\n');
|
||||
buffer.append("[Multiverse-Core] firstspawnworld: ").append(this.plugin.getMVConfiguration().getString("firstspawnworld", "NOT SET")).append('\n');
|
||||
buffer.append("[Multiverse-Core] debug: ").append(MultiverseCore.GlobalDebug).append('\n');
|
||||
.append(this.plugin.getMVConfig().getVersion()).append(")").append('\n');
|
||||
buffer.append("[Multiverse-Core] messagecooldown: ").append(plugin.getMessaging().getCooldown()).append('\n');
|
||||
buffer.append("[Multiverse-Core] teleportcooldown: ").append(plugin.getMVConfig().getTeleportCooldown()).append('\n');
|
||||
buffer.append("[Multiverse-Core] worldnameprefix: ").append(plugin.getMVConfig().getPrefixChat()).append('\n');
|
||||
buffer.append("[Multiverse-Core] enforceaccess: ").append(plugin.getMVConfig().getEnforceAccess()).append('\n');
|
||||
buffer.append("[Multiverse-Core] displaypermerrors: ").append(plugin.getMVConfig().getDisplayPermErrors()).append('\n');
|
||||
buffer.append("[Multiverse-Core] teleportintercept: ").append(plugin.getMVConfig().getTeleportIntercept()).append('\n');
|
||||
buffer.append("[Multiverse-Core] firstspawnoverride: ").append(plugin.getMVConfig().getFirstSpawnOverride()).append('\n');
|
||||
buffer.append("[Multiverse-Core] firstspawnworld: ").append(plugin.getMVConfig().getFirstSpawnWorld()).append('\n');
|
||||
buffer.append("[Multiverse-Core] debug: ").append(plugin.getMVConfig().getGlobalDebug()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Special Code: FRN002").append('\n');
|
||||
|
||||
MVVersionEvent versionEvent = new MVVersionEvent(buffer.toString());
|
||||
this.plugin.getServer().getPluginManager().callEvent(versionEvent);
|
||||
|
||||
// log to console
|
||||
String data = versionEvent.getVersionInfo();
|
||||
final String data = versionEvent.getVersionInfo();
|
||||
String[] lines = data.split("\n");
|
||||
for (String line : lines) {
|
||||
this.plugin.log(Level.INFO, line);
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
String pasteUrl = "";
|
||||
if (args.get(0).equalsIgnoreCase("-p")) {
|
||||
pasteUrl = postToService(PasteServiceType.PASTIE, true, data); // private post to pastie
|
||||
} else if (args.get(0).equalsIgnoreCase("-b")) {
|
||||
pasteUrl = postToService(PasteServiceType.PASTEBIN, true, data); // private post to pastie
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
this.plugin.getServer().getScheduler().scheduleAsyncDelayedTask(this.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (args.size() == 1) {
|
||||
String pasteUrl;
|
||||
if (args.get(0).equalsIgnoreCase("-p")) {
|
||||
pasteUrl = postToService(PasteServiceType.PASTIE, true, data); // private post to pastie
|
||||
} else if (args.get(0).equalsIgnoreCase("-b")) {
|
||||
pasteUrl = postToService(PasteServiceType.PASTEBIN, true, data); // private post to pastie
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
|
||||
this.plugin.log(Level.INFO, "Version info dumped here: " + pasteUrl);
|
||||
}
|
||||
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
|
||||
plugin.log(Level.INFO, "Version info dumped here: " + pasteUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +109,7 @@ public class VersionCommand extends MultiverseCommand {
|
||||
private static String postToService(PasteServiceType type, boolean isPrivate, String pasteData) {
|
||||
PasteService ps = PasteServiceFactory.getService(type, isPrivate);
|
||||
try {
|
||||
return ps.postData(ps.encodeData(pasteData), ps.getPostURL());
|
||||
return SHORTENER.shorten(ps.postData(ps.encodeData(pasteData), ps.getPostURL()));
|
||||
} catch (PasteFailedException e) {
|
||||
System.out.print(e);
|
||||
return "Error posting to service";
|
||||
|
||||
@@ -15,7 +15,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -28,11 +27,14 @@ public class WhoCommand extends MultiverseCommand {
|
||||
public WhoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Who?");
|
||||
this.setCommandUsage("/mv who" + ChatColor.GOLD + " [WORLD]");
|
||||
this.setCommandUsage("/mv who" + ChatColor.GOLD + " [WORLD|--all]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv who");
|
||||
this.addKey("mvw");
|
||||
this.addKey("mvwho");
|
||||
this.addCommandExample("/mv who");
|
||||
this.addCommandExample(String.format("/mv who %s--all", ChatColor.GREEN));
|
||||
this.addCommandExample(String.format("/mv who %smyworld", ChatColor.GOLD));
|
||||
this.setPermission("multiverse.core.list.who", "States who is in what world.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
@@ -48,57 +50,57 @@ public class WhoCommand extends MultiverseCommand {
|
||||
showAll = false;
|
||||
}
|
||||
|
||||
List<MultiverseWorld> worlds = new ArrayList<MultiverseWorld>();
|
||||
|
||||
if (args.size() > 0) {
|
||||
MultiverseWorld world = this.worldManager.getMVWorld(args.get(0));
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("--all") || args.get(0).equalsIgnoreCase("-a")) {
|
||||
showAll = true;
|
||||
worlds = new ArrayList<MultiverseWorld>(this.worldManager.getMVWorlds());
|
||||
} else if (world != null) {
|
||||
if (!world.isHidden()) {
|
||||
worlds.add(world);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "World does not exist");
|
||||
// single world mode
|
||||
MultiverseWorld world = this.worldManager.getMVWorld(args.get(0));
|
||||
if (world == null) {
|
||||
sender.sendMessage(ChatColor.RED + "That world does not exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.plugin.getMVPerms().canEnterWorld(p, world)) {
|
||||
sender.sendMessage(ChatColor.RED + "You aren't allowed to access to this world!");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(String.format("%s--- Players in %s%s ---", ChatColor.AQUA,
|
||||
world.getColoredWorldString(), ChatColor.AQUA));
|
||||
sender.sendMessage(buildPlayerString(world));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
worlds = new ArrayList<MultiverseWorld>(this.worldManager.getMVWorlds());
|
||||
}
|
||||
|
||||
if (worlds.size() == 0) {
|
||||
sender.sendMessage("Multiverse does not know about any of your worlds :(");
|
||||
} else if (worlds.size() == 1) {
|
||||
sender.sendMessage(ChatColor.AQUA + "--- Players in" + worlds.get(0).getColoredWorldString() + ChatColor.AQUA + " ---");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.AQUA + "--- There are players in ---");
|
||||
}
|
||||
|
||||
for (MultiverseWorld world : worlds) {
|
||||
if (!(this.worldManager.isMVWorld(world.getName()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p != null && (!this.plugin.getMVPerms().canEnterWorld(p, world))) {
|
||||
continue;
|
||||
}
|
||||
List<Player> players = world.getCBWorld().getPlayers();
|
||||
|
||||
String result = "";
|
||||
if (players.size() <= 0 && !showAll) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (players.size() <= 0) {
|
||||
result = "Empty";
|
||||
} else {
|
||||
for (Player player : players) {
|
||||
result += player.getDisplayName() + " " + ChatColor.WHITE;
|
||||
// multiworld mode
|
||||
sender.sendMessage(ChatColor.AQUA + "--- Worlds and their players ---");
|
||||
boolean shownOne = false;
|
||||
for (MultiverseWorld world : this.worldManager.getMVWorlds()) {
|
||||
if (this.plugin.getMVPerms().canEnterWorld(p, world)) { // only show world if the player can access it
|
||||
if (showAll || !world.getCBWorld().getPlayers().isEmpty()) { // either show all or show if the world is not empty
|
||||
sender.sendMessage(String.format("%s%s - %s", world.getColoredWorldString(), ChatColor.WHITE, buildPlayerString(world)));
|
||||
shownOne = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!shownOne) {
|
||||
sender.sendMessage("No worlds found.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(world.getColoredWorldString() + ChatColor.WHITE + " - " + result);
|
||||
private static String buildPlayerString(MultiverseWorld world) {
|
||||
List<Player> players = world.getCBWorld().getPlayers();
|
||||
if (players.size() == 0) {
|
||||
return "No players found.";
|
||||
} else {
|
||||
StringBuilder playerBuilder = new StringBuilder();
|
||||
for (Player player : players) {
|
||||
playerBuilder.append(player.getDisplayName()).append(", ");
|
||||
}
|
||||
String bString = playerBuilder.toString();
|
||||
return bString.substring(0, bString.length() - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2012. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
/**
|
||||
* A {@link String} config-property that will NOT be saved to the config.
|
||||
*/
|
||||
public class ActiveStringConfigProperty implements MVActiveConfigProperty<String> {
|
||||
private String name;
|
||||
private String value;
|
||||
private String method;
|
||||
private String help;
|
||||
|
||||
public ActiveStringConfigProperty(String name, String defaultValue, String help) {
|
||||
this.name = name;
|
||||
this.help = help;
|
||||
this.value = defaultValue;
|
||||
this.parseValue(defaultValue);
|
||||
}
|
||||
|
||||
public ActiveStringConfigProperty(String name, String defaultValue, String help, String method) {
|
||||
this(name, defaultValue, help);
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setMethod(String methodName) {
|
||||
this.method = methodName;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getPropertyClass() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
this.setValue(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
this.value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
-135
@@ -1,135 +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.configuration;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* A {@link Boolean} config-property.
|
||||
*/
|
||||
public class BooleanConfigProperty implements MVActiveConfigProperty<Boolean> {
|
||||
private String name;
|
||||
private Boolean value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
private String method;
|
||||
|
||||
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String help) {
|
||||
this(section, name, defaultValue, name, help);
|
||||
}
|
||||
|
||||
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.value = defaultValue;
|
||||
this.setValue(this.section.getBoolean(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String configNode, String help, String method) {
|
||||
this(section, name, defaultValue, configNode, help);
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Boolean getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Boolean value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
this.value = value;
|
||||
this.section.set(configNode, this.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
if (value.toLowerCase().equals("true") || value.toLowerCase().equals("false")) {
|
||||
this.setValue(Boolean.parseBoolean(value));
|
||||
return true;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the method that will be executed.
|
||||
*
|
||||
* @return The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the method that will be executed.
|
||||
*
|
||||
* @param methodName The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public void setMethod(String methodName) {
|
||||
this.method = methodName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class of the object we're looking at.
|
||||
*
|
||||
* @return the class of the object we're looking at.
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getPropertyClass() {
|
||||
return Boolean.class;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +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.configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* A {@link EnglishChatColor} config-property.
|
||||
*/
|
||||
public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
|
||||
private String name;
|
||||
private EnglishChatColor value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String help) {
|
||||
this(section, name, defaultValue, name, help);
|
||||
}
|
||||
|
||||
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.value = defaultValue;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public EnglishChatColor getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(EnglishChatColor value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
this.value = value;
|
||||
this.section.set(configNode, this.value.getText());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
EnglishChatColor color = EnglishChatColor.fromString(value);
|
||||
if (color == null) {
|
||||
return false;
|
||||
}
|
||||
this.setValue(color);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
}
|
||||
}
|
||||
-292
@@ -1,292 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2012. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/** A factory to create config properties for a given world. */
|
||||
public class ConfigPropertyFactory {
|
||||
private ConfigurationSection section;
|
||||
|
||||
public ConfigPropertyFactory(ConfigurationSection section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
// Booleans
|
||||
/**
|
||||
* 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 BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String help) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String node, String help) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ActiveBooleanConfigProperty
|
||||
*
|
||||
* This property will execute 'method' after it has been successfully set.
|
||||
*
|
||||
* @param name The name of this ConifgProperty
|
||||
* @param defaultValue The default value.
|
||||
* @param help What string is shown for help.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param method The method that should be executed.
|
||||
* @return The ActiveStringConfigProperty
|
||||
*/
|
||||
public BooleanConfigProperty getNewProperty(String name, boolean defaultValue, String help, String node, String method) {
|
||||
return new BooleanConfigProperty(this.section, name, defaultValue, help, node, method);
|
||||
}
|
||||
|
||||
// Integers
|
||||
/**
|
||||
* 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 IntegerConfigProperty getNewProperty(String name, int defaultValue, String help) {
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public IntegerConfigProperty getNewProperty(String name, int defaultValue, String node, String help) {
|
||||
return new IntegerConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// Doubles
|
||||
/**
|
||||
* 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 DoubleConfigProperty getNewProperty(String name, double defaultValue, String help) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String node, String help) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @param method The name of the method that's used to set this property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public DoubleConfigProperty getNewProperty(String name, double defaultValue, String node, String help, String method) {
|
||||
return new DoubleConfigProperty(this.section, name, defaultValue, node, help, method);
|
||||
}
|
||||
|
||||
// Strings
|
||||
/**
|
||||
* 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 StringConfigProperty getNewProperty(String name, String defaultValue, String help) {
|
||||
return new StringConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public StringConfigProperty getNewProperty(String name, String defaultValue, String node, String help) {
|
||||
return new StringConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// Colors
|
||||
/**
|
||||
* 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 ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue, String help) {
|
||||
return new ColorConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public ColorConfigProperty getNewProperty(String name, EnglishChatColor defaultValue, String node, String help) {
|
||||
return new ColorConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// Difficulty
|
||||
/**
|
||||
* 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 DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue, String help) {
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public DifficultyConfigProperty getNewProperty(String name, Difficulty defaultValue, String node, String help) {
|
||||
return new DifficultyConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// 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 GameModeConfigProperty getNewProperty(String name, GameMode defaultValue, String help) {
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public GameModeConfigProperty getNewProperty(String name, GameMode defaultValue, String node, String help) {
|
||||
return new GameModeConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
// 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 LocationConfigProperty getNewProperty(String name, Location defaultValue, String help) {
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String node, String help) {
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, node, help);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ConfigProperty.
|
||||
*
|
||||
* @param name The name of this ConfigProperty.
|
||||
* @param defaultValue The default-value.
|
||||
* @param node The name of the configuration-node this ConfigProperty will be stored as.
|
||||
* @param help The text that's displayed when a user failed to set the property.
|
||||
* @param method The name of the method that's used to set this property.
|
||||
* @return The ConfigProperty.
|
||||
*/
|
||||
public LocationConfigProperty getNewProperty(String name, Location defaultValue, String node, String help, String method) {
|
||||
return new LocationConfigProperty(this.section, name, defaultValue, node, help, method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new ActiveStringConfigProperty
|
||||
*
|
||||
* This property will execute 'method' after it has been successfully set.
|
||||
* This string will NOT be saved to the config file.
|
||||
*
|
||||
* @param name The name of this ConifgProperty
|
||||
* @param defaultValue The default value.
|
||||
* @param help What string is shown for help.
|
||||
* @param method The method that should be executed.
|
||||
* @param saveToConfig Should the variable save to the config?
|
||||
* @return The ActiveStringConfigProperty
|
||||
*/
|
||||
public ActiveStringConfigProperty getNewProperty(String name, String defaultValue, String help, String method, boolean saveToConfig) {
|
||||
return new ActiveStringConfigProperty(name, defaultValue, help, method);
|
||||
}
|
||||
}
|
||||
-129
@@ -1,129 +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.configuration;
|
||||
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* A {@link Difficulty} config-property.
|
||||
*/
|
||||
public class DifficultyConfigProperty implements MVActiveConfigProperty<Difficulty> {
|
||||
private String name;
|
||||
private Difficulty value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String help) {
|
||||
this(section, name, defaultValue, name, help);
|
||||
}
|
||||
|
||||
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.value = defaultValue;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Difficulty getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Difficulty 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(Difficulty.getByValue(Integer.parseInt(value)));
|
||||
} catch (NumberFormatException nfe) {
|
||||
try {
|
||||
return this.setValue(Difficulty.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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the method that will be executed.
|
||||
*
|
||||
* @return The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return "setActualDifficulty";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the method that will be executed.
|
||||
*
|
||||
* @param methodName The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public void setMethod(String methodName) {
|
||||
// Unused here. This will only ever be setDifficulty.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getPropertyClass() {
|
||||
return Difficulty.class;
|
||||
}
|
||||
}
|
||||
-133
@@ -1,133 +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.configuration;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* A {@link Double} config-property.
|
||||
*/
|
||||
public class DoubleConfigProperty implements MVActiveConfigProperty<Double> {
|
||||
private String name;
|
||||
private Double value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
private String method;
|
||||
|
||||
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String help) {
|
||||
this(section, name, defaultValue, name, help);
|
||||
}
|
||||
|
||||
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.value = defaultValue;
|
||||
this.setValue(this.section.getDouble(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String configNode, String help, String method) {
|
||||
this(section, name, defaultValue, configNode, help);
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Double getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Double value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
this.value = value;
|
||||
this.section.set(configNode, this.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
try {
|
||||
this.setValue(Double.parseDouble(value));
|
||||
return true;
|
||||
} catch (NumberFormatException 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the method that will be executed.
|
||||
*
|
||||
* @return The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the method that will be executed.
|
||||
*
|
||||
* @param methodName The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public void setMethod(String methodName) {
|
||||
this.method = methodName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class of the object we're looking at.
|
||||
*
|
||||
* @return the class of the object we're looking at.
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getPropertyClass() {
|
||||
return Double.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
/**
|
||||
* Entryfee-settings.
|
||||
*/
|
||||
@SerializableAs("MVEntryFee")
|
||||
public class EntryFee extends SerializationConfig {
|
||||
@Property
|
||||
private double amount;
|
||||
@Property
|
||||
private int currency;
|
||||
|
||||
public EntryFee() {
|
||||
super();
|
||||
}
|
||||
|
||||
public EntryFee(Map<String, Object> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void setDefaults() {
|
||||
amount = 0D;
|
||||
currency = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount
|
||||
*/
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the currency
|
||||
*/
|
||||
public int getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the amount.
|
||||
* @param amount The new value.
|
||||
*/
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the currency.
|
||||
* @param currency The new value.
|
||||
*/
|
||||
public void setCurrency(int currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
}
|
||||
-129
@@ -1,129 +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.configuration;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* A {@link GameMode} config-property.
|
||||
*/
|
||||
public class GameModeConfigProperty implements MVActiveConfigProperty<GameMode> {
|
||||
private String name;
|
||||
private GameMode value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String help) {
|
||||
this(section, name, defaultValue, name, help);
|
||||
}
|
||||
|
||||
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.value = defaultValue;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public GameMode getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(GameMode 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(GameMode.getByValue(Integer.parseInt(value)));
|
||||
} catch (NumberFormatException nfe) {
|
||||
try {
|
||||
return this.setValue(GameMode.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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the method that will be executed.
|
||||
*
|
||||
* @return The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return "setActualGameMode";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the method that will be executed.
|
||||
*
|
||||
* @param methodName The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public void setMethod(String methodName) {
|
||||
// Not required. Gamemode will only ever be one.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getPropertyClass() {
|
||||
return GameMode.class;
|
||||
}
|
||||
}
|
||||
-97
@@ -1,97 +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.configuration;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* A {@link Integer} config-property.
|
||||
*/
|
||||
public class IntegerConfigProperty implements MVConfigProperty<Integer> {
|
||||
private String name;
|
||||
private Integer value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String help) {
|
||||
this(section, name, defaultValue, name, help);
|
||||
}
|
||||
|
||||
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.value = defaultValue;
|
||||
this.setValue(this.section.getInt(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Integer value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
this.value = value;
|
||||
this.section.set(configNode, this.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
try {
|
||||
this.setValue(Integer.parseInt(value));
|
||||
return true;
|
||||
} catch (NumberFormatException 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();
|
||||
}
|
||||
}
|
||||
-151
@@ -1,151 +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.configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* A {@link Location} config-property.
|
||||
*/
|
||||
public class LocationConfigProperty implements MVActiveConfigProperty<Location> {
|
||||
private String name;
|
||||
private Location value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
private String method;
|
||||
|
||||
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String help) {
|
||||
this(section, name, defaultValue, name, help);
|
||||
}
|
||||
|
||||
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.value = defaultValue;
|
||||
this.setValue(this.getLocationFromConfig(defaultValue));
|
||||
}
|
||||
|
||||
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String configNode, String help, String method) {
|
||||
this(section, name, defaultValue, configNode, help);
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
Location parsed = LocationManipulation.stringToLocation(value);
|
||||
return this.setValue(parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(Location value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
this.value = value;
|
||||
this.section.set(configNode + ".x", this.value.getX());
|
||||
this.section.set(configNode + ".y", this.value.getY());
|
||||
this.section.set(configNode + ".z", this.value.getZ());
|
||||
this.section.set(configNode + ".pitch", this.value.getPitch());
|
||||
this.section.set(configNode + ".yaw", this.value.getYaw());
|
||||
this.section.set(configNode + ".world", this.value.getWorld().getName());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Location getLocationFromConfig(Location defaultValue) {
|
||||
double x = this.section.getDouble(this.configNode + ".x", defaultValue.getX());
|
||||
double y = this.section.getDouble(this.configNode + ".y", defaultValue.getY());
|
||||
double z = this.section.getDouble(this.configNode + ".z", defaultValue.getZ());
|
||||
double pitch = this.section.getDouble(this.configNode + ".pitch", defaultValue.getPitch());
|
||||
double yaw = this.section.getDouble(this.configNode + ".yaw", defaultValue.getYaw());
|
||||
String w = this.section.getString(this.configNode + ".world", defaultValue.getWorld().getName());
|
||||
Location found = LocationManipulation.stringToLocation(w + ":" + x + "," + y + "," + z + ":" + yaw + ":" + pitch);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return LocationManipulation.strCoordsRaw(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the method that will be executed.
|
||||
*
|
||||
* @return The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public String getMethod() {
|
||||
return this.method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the method that will be executed.
|
||||
*
|
||||
* @param methodName The name of the method in MVWorld to be called.
|
||||
*/
|
||||
@Override
|
||||
public void setMethod(String methodName) {
|
||||
this.method = methodName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class of the object we're looking at.
|
||||
*
|
||||
* @return the class of the object we're looking at.
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getPropertyClass() {
|
||||
return Location.class;
|
||||
}
|
||||
}
|
||||
+2
@@ -10,8 +10,10 @@ package com.onarandombox.MultiverseCore.configuration;
|
||||
/**
|
||||
* An "active" {@link MVConfigProperty} that uses the specified method to be "actually" set.
|
||||
* @param <T> The type of the config-property.
|
||||
* @deprecated This is deprecated.
|
||||
* @see MVConfigProperty
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MVActiveConfigProperty<T> extends MVConfigProperty<T> {
|
||||
/**
|
||||
* Gets the method that will be executed.
|
||||
|
||||
@@ -1,75 +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.configuration;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.LoggablePlugin;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/*
|
||||
* This is a mess, so I'm just going to suppress all warnings here.
|
||||
* BEGIN CHECKSTYLE-SUPPRESSION: ALL
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated This isn't used any more, is it?
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class MVConfigMigrator {
|
||||
|
||||
public List<String> createdDefaults = new ArrayList<String>();
|
||||
|
||||
public abstract boolean migrate(String name, File folder);
|
||||
|
||||
protected final void migrateListItem(Configuration newConfig, Configuration oldConfig, String key, String oldProperty, String newProperty) {
|
||||
List<String> list = Arrays.asList(oldConfig.getString("worlds." + key + oldProperty).split(","));
|
||||
if (list.size() > 0) {
|
||||
if (list.get(0).length() == 0) {
|
||||
list = new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
newConfig.setProperty("worlds." + key + newProperty, list);
|
||||
}
|
||||
|
||||
protected final File detectMultiverseFolders(File folder, LoggablePlugin mvPlugin) {
|
||||
File oldFolder = null;
|
||||
mvPlugin.log(Level.INFO, "Starting Multiverse Configuration Migrator(MVCM)!");
|
||||
// They still have MV 1 installed! Good!
|
||||
if (mvPlugin.getServer().getPluginManager().getPlugin("MultiVerse") != null) {
|
||||
mvPlugin.log(Level.INFO, "Found MultiVerse 1. Starting Config Migration...");
|
||||
Plugin plugin = mvPlugin.getServer().getPluginManager().getPlugin("MultiVerse");
|
||||
oldFolder = plugin.getDataFolder();
|
||||
} else {
|
||||
// They didn't have MV 1 enabled... let's try and find the folder...
|
||||
File[] folders = folder.getParentFile().listFiles();
|
||||
List<File> folderList = Arrays.asList(folders);
|
||||
for (File f : folderList) {
|
||||
if (f.getName().equalsIgnoreCase("MultiVerse")) {
|
||||
mvPlugin.log(Level.INFO, "Found the MultiVerse 1 config folder. Starting Config Migration...");
|
||||
oldFolder = f;
|
||||
}
|
||||
}
|
||||
if (oldFolder == null) {
|
||||
mvPlugin.log(Level.INFO, "Did not find the MV1 Folder. If you did not have MultiVerse 1 installed and this is the FIRST time you're running MV2, this message is GOOD. ");
|
||||
mvPlugin.log(Level.INFO, "If you did, your configs were **NOT** migrated! Go Here: INSERTURLFORHELP");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return oldFolder;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* END CHECKSTYLE-SUPPRESSION: ALL
|
||||
*/
|
||||
@@ -11,7 +11,9 @@ package com.onarandombox.MultiverseCore.configuration;
|
||||
* A generic config-property.
|
||||
*
|
||||
* @param <T> The type of the config-property.
|
||||
* @deprecated This is deprecated.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MVConfigProperty<T> {
|
||||
/**
|
||||
* Gets the name of this property.
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
/**
|
||||
* Just like a regular {@link Location}, however {@code world} is usually {@code null}
|
||||
* or just a weak reference and it implements {@link ConfigurationSerializable}.
|
||||
*/
|
||||
@SerializableAs("MVSpawnLocation")
|
||||
public class SpawnLocation extends Location implements ConfigurationSerializable {
|
||||
private Reference<World> worldRef;
|
||||
|
||||
public SpawnLocation(double x, double y, double z) {
|
||||
super(null, x, y, z);
|
||||
}
|
||||
|
||||
public SpawnLocation(double x, double y, double z, float yaw, float pitch) {
|
||||
super(null, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
public SpawnLocation(Location loc) {
|
||||
this(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return (this.worldRef != null) ? this.worldRef.get() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setWorld(World world) {
|
||||
this.worldRef = new WeakReference<World>(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Chunk getChunk() {
|
||||
if ((this.worldRef != null) && (this.worldRef.get() != null))
|
||||
return this.worldRef.get().getChunkAt(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
if ((this.worldRef != null) && (this.worldRef.get() != null))
|
||||
return this.worldRef.get().getBlockAt(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> serialized = new HashMap<String, Object>(5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
serialized.put("x", this.getX());
|
||||
serialized.put("y", this.getY());
|
||||
serialized.put("z", this.getZ());
|
||||
serialized.put("pitch", this.getPitch());
|
||||
serialized.put("yaw", this.getYaw());
|
||||
return serialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Let Bukkit be able to deserialize this.
|
||||
* @param args The map.
|
||||
* @return The deserialized object.
|
||||
*/
|
||||
public static SpawnLocation deserialize(Map<String, Object> args) {
|
||||
double x = ((Number) args.get("x")).doubleValue();
|
||||
double y = ((Number) args.get("y")).doubleValue();
|
||||
double z = ((Number) args.get("z")).doubleValue();
|
||||
float pitch = ((Number) args.get("pitch")).floatValue();
|
||||
float yaw = ((Number) args.get("yaw")).floatValue();
|
||||
return new SpawnLocation(x, y, z, yaw, pitch);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
/**
|
||||
* Spawning-Settings.
|
||||
*/
|
||||
@SerializableAs("MVSpawnSettings")
|
||||
public class SpawnSettings extends SerializationConfig {
|
||||
@Property
|
||||
private SubSpawnSettings animals;
|
||||
@Property
|
||||
private SubSpawnSettings monsters;
|
||||
|
||||
public SpawnSettings() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SpawnSettings(Map<String, Object> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setDefaults() {
|
||||
animals = new SubSpawnSettings();
|
||||
monsters = new SubSpawnSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the animal-settings
|
||||
*/
|
||||
public SubSpawnSettings getAnimalSettings() {
|
||||
return animals;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the monster-settings
|
||||
*/
|
||||
public SubSpawnSettings getMonsterSettings() {
|
||||
return monsters;
|
||||
}
|
||||
}
|
||||
@@ -1,96 +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.configuration;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* A {@link String} config-property.
|
||||
*/
|
||||
public class StringConfigProperty implements MVConfigProperty<String> {
|
||||
private String name;
|
||||
private String value;
|
||||
private String configNode;
|
||||
private ConfigurationSection section;
|
||||
private String help;
|
||||
|
||||
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String help) {
|
||||
this(section, name, defaultValue, defaultValue, help);
|
||||
}
|
||||
|
||||
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String configNode, String help) {
|
||||
this.name = name;
|
||||
this.configNode = configNode;
|
||||
this.section = section;
|
||||
this.help = help;
|
||||
this.value = defaultValue;
|
||||
this.parseValue(this.section.getString(this.configNode, defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean parseValue(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
this.setValue(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getConfigNode() {
|
||||
return this.configNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return this.help;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean setValue(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
this.value = value;
|
||||
this.section.set(configNode, this.value);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
/**
|
||||
* SpawnSubSettings.
|
||||
*/
|
||||
@SerializableAs("MVSpawnSubSettings")
|
||||
public class SubSpawnSettings extends SerializationConfig {
|
||||
@Property
|
||||
private boolean spawn;
|
||||
@Property
|
||||
private List<String> exceptions;
|
||||
|
||||
public SubSpawnSettings() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SubSpawnSettings(Map<String, Object> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setDefaults() {
|
||||
spawn = true;
|
||||
exceptions = new ArrayList<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return spawn
|
||||
*/
|
||||
public boolean doSpawn() {
|
||||
return spawn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param spawn The new value.
|
||||
*/
|
||||
public void setSpawn(boolean spawn) {
|
||||
this.spawn = spawn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the exceptions
|
||||
*/
|
||||
public List<String> getExceptions() {
|
||||
return exceptions;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.event.MVWorldPropertyChangeEvent;
|
||||
|
||||
import me.main__.util.SerializationConfig.ChangeDeniedException;
|
||||
import me.main__.util.SerializationConfig.ObjectUsingValidator;
|
||||
|
||||
/**
|
||||
* Validates world-property-changes.
|
||||
* @param <T> The type of the property that should be validated.
|
||||
*/
|
||||
public class WorldPropertyValidator<T> extends ObjectUsingValidator<T, MVWorld> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public T validateChange(String property, T newValue, T oldValue, MVWorld object) throws ChangeDeniedException {
|
||||
MVWorldPropertyChangeEvent<T> event = new MVWorldPropertyChangeEvent<T>(object, null, property, newValue);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
throw new ChangeDeniedException();
|
||||
return event.getTheNewValue();
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class DestinationFactory {
|
||||
Class<? extends MVDestination> myClass = this.destList.get(idenChar);
|
||||
try {
|
||||
MVDestination mydest = myClass.newInstance();
|
||||
if (!mydest.isThisType((MultiverseCore) this.plugin, destination)) {
|
||||
if (!mydest.isThisType(this.plugin, destination)) {
|
||||
return new InvalidDestination();
|
||||
}
|
||||
mydest.setDestination(this.plugin, destination);
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.LocationManipulation;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -70,7 +70,7 @@ public class WorldDestination implements MVDestination {
|
||||
return spawnLoc;
|
||||
}
|
||||
|
||||
private Location getAcurateSpawnLocation(Entity e, MultiverseWorld world) {
|
||||
private static Location getAcurateSpawnLocation(Entity e, MultiverseWorld world) {
|
||||
if (world != null) {
|
||||
return world.getSpawnLocation();
|
||||
} else {
|
||||
@@ -93,6 +93,9 @@ public class WorldDestination implements MVDestination {
|
||||
*/
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
// TODO Taking a JavaPlugin here is rather useless, if we keep casting it up to MultiverseCore.
|
||||
// We should change that.
|
||||
Core core = (Core) plugin;
|
||||
String[] items = destination.split(":");
|
||||
if (items.length > 3) {
|
||||
isValid = false;
|
||||
@@ -100,19 +103,19 @@ public class WorldDestination implements MVDestination {
|
||||
}
|
||||
if (items.length == 1 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
|
||||
isValid = true;
|
||||
this.world = ((MultiverseCore) plugin).getMVWorldManager().getMVWorld(items[0]);
|
||||
this.world = core.getMVWorldManager().getMVWorld(items[0]);
|
||||
return;
|
||||
}
|
||||
if (items.length == 2 && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[0])) {
|
||||
this.world = ((MultiverseCore) plugin).getMVWorldManager().getMVWorld(items[0]);
|
||||
this.yaw = LocationManipulation.getYaw(items[1]);
|
||||
this.world = core.getMVWorldManager().getMVWorld(items[0]);
|
||||
this.yaw = core.getLocationManipulation().getYaw(items[1]);
|
||||
return;
|
||||
}
|
||||
if (items[0].equalsIgnoreCase("w") && ((MultiverseCore) plugin).getMVWorldManager().isMVWorld(items[1])) {
|
||||
this.world = ((MultiverseCore) plugin).getMVWorldManager().getMVWorld(items[1]);
|
||||
isValid = true;
|
||||
if (items.length == 3) {
|
||||
this.yaw = LocationManipulation.getYaw(items[2]);
|
||||
this.yaw = core.getLocationManipulation().getYaw(items[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -99,4 +99,13 @@ public enum EnglishChatColor {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks if the given-color name is a valid color.
|
||||
* @param aliasColor A color-name.
|
||||
* @return True if the name is a valid color, false if it isn't.
|
||||
*/
|
||||
public static boolean isValidAliasColor(String aliasColor) {
|
||||
return (EnglishChatColor.fromString(aliasColor) != null);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,14 +16,30 @@ import java.util.List;
|
||||
* Called when the Multiverse-config should be reloaded.
|
||||
*/
|
||||
public class MVConfigReloadEvent extends Event {
|
||||
private static final long serialVersionUID = 3647950355746345397L;
|
||||
private List<String> configsLoaded;
|
||||
|
||||
public MVConfigReloadEvent(List<String> configsLoaded) {
|
||||
super("MVConfigReload");
|
||||
this.configsLoaded = configsLoaded;
|
||||
}
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handler list. This is required by the event system.
|
||||
* @return A list of HANDLERS.
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a config to this event.
|
||||
* @param config The config to add.
|
||||
|
||||
+40
-1
@@ -11,6 +11,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* This event is thrown when a portal is touched.
|
||||
@@ -19,13 +20,31 @@ public class MVPlayerTouchedPortalEvent extends Event implements Cancellable {
|
||||
private Player p;
|
||||
private Location l;
|
||||
private boolean isCancelled;
|
||||
private boolean canUse = true;
|
||||
|
||||
public MVPlayerTouchedPortalEvent(Player p, Location l) {
|
||||
super("MVPlayerTouchedPortalEvent");
|
||||
this.p = p;
|
||||
this.l = l;
|
||||
}
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handler list. This is required by the event system.
|
||||
* @return A list of HANDLERS.
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Location} of the portal-block that was touched.
|
||||
* @return The {@link Location} of the portal-block that was touched.
|
||||
@@ -42,6 +61,26 @@ public class MVPlayerTouchedPortalEvent extends Event implements Cancellable {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether or not the player in this event can use this portal.
|
||||
*
|
||||
* @return True if the player can use this portal.
|
||||
*/
|
||||
public boolean canUseThisPortal() {
|
||||
return this.canUse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether or not the player in this event can use this portal.
|
||||
* <p>
|
||||
* Setting this to false will cause the player to bounce back!
|
||||
*
|
||||
* @param canUse Whether or not the user can go through this portal.
|
||||
*/
|
||||
public void setCanUseThisPortal(boolean canUse) {
|
||||
this.canUse = canUse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.isCancelled;
|
||||
|
||||
@@ -10,6 +10,7 @@ package com.onarandombox.MultiverseCore.event;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a player is respawning.
|
||||
@@ -21,12 +22,29 @@ public class MVRespawnEvent extends Event {
|
||||
|
||||
|
||||
public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) {
|
||||
super("MVRespawn");
|
||||
this.player = p;
|
||||
this.location = spawningAt;
|
||||
this.respawnMethod = respawnMethod;
|
||||
}
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handler list. This is required by the event system.
|
||||
* @return A list of HANDLERS.
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Player} that's respawning.
|
||||
* @return The {@link Player} that's respawning.
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Event that gets called when a player use the /mvtp command.
|
||||
@@ -26,13 +28,30 @@ public class MVTeleportEvent extends Event implements Cancellable {
|
||||
private boolean isCancelled;
|
||||
|
||||
public MVTeleportEvent(MVDestination dest, Player teleportee, CommandSender teleporter, boolean safeTeleport) {
|
||||
super("SafeTTeleporter");
|
||||
this.teleportee = teleportee;
|
||||
this.teleporter = teleporter;
|
||||
this.dest = dest;
|
||||
this.useSafeTeleport = safeTeleport;
|
||||
}
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handler list. This is required by the event system.
|
||||
* @return A list of HANDLERS.
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player who will be teleported by this event.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.onarandombox.MultiverseCore.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when somebody requests version information about Multiverse.
|
||||
@@ -10,8 +11,25 @@ public class MVVersionEvent extends Event {
|
||||
private final StringBuilder versionInfoBuilder;
|
||||
|
||||
public MVVersionEvent(String versionInfo) {
|
||||
super("MVVersionEvent");
|
||||
versionInfoBuilder = new StringBuilder(versionInfo);
|
||||
this.versionInfoBuilder = new StringBuilder(versionInfo);
|
||||
}
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handler list. This is required by the event system.
|
||||
* @return A list of HANDLERS.
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -19,7 +37,7 @@ public class MVVersionEvent extends Event {
|
||||
* @return The version-info.
|
||||
*/
|
||||
public String getVersionInfo() {
|
||||
return versionInfoBuilder.toString();
|
||||
return this.versionInfoBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,6 +45,6 @@ public class MVVersionEvent extends Event {
|
||||
* @param moreVersionInfo The version-info to add. Should end with '\n'.
|
||||
*/
|
||||
public void appendVersionInfo(String moreVersionInfo) {
|
||||
versionInfoBuilder.append(moreVersionInfo);
|
||||
this.versionInfoBuilder.append(moreVersionInfo);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +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.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
/**
|
||||
* Called when somebody requests version information about Multiverse.
|
||||
* @deprecated Use {@link MVVersionEvent} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class MVVersionRequestEvent extends Event {
|
||||
|
||||
private String pasteBinBuffer;
|
||||
|
||||
public MVVersionRequestEvent(String pasteBinBuffer) {
|
||||
super("MVVersion");
|
||||
this.pasteBinBuffer = pasteBinBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pasteBinBuffer.
|
||||
* @return The pasteBinBuffer.
|
||||
* @deprecated Use {@link MVVersionEvent} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getPasteBinBuffer() {
|
||||
return this.pasteBinBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the pasteBinBuffer.
|
||||
* @param buffer The new pasteBinBuffer.
|
||||
* @deprecated Use {@link MVVersionEvent} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPasteBinBuffer(String buffer) {
|
||||
this.pasteBinBuffer = buffer;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called when a world is about to be deleted by Multiverse.
|
||||
@@ -15,8 +16,6 @@ public class MVWorldDeleteEvent extends Event implements Cancellable {
|
||||
private final boolean removeFromConfig;
|
||||
|
||||
public MVWorldDeleteEvent(MultiverseWorld world, boolean removeFromConfig) {
|
||||
super("MVWorldDeleteEvent");
|
||||
|
||||
if (world == null)
|
||||
throw new IllegalArgumentException("world can't be null!");
|
||||
|
||||
@@ -24,6 +23,24 @@ public class MVWorldDeleteEvent extends Event implements Cancellable {
|
||||
this.removeFromConfig = removeFromConfig;
|
||||
}
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handler list. This is required by the event system.
|
||||
* @return A list of HANDLERS.
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
+49
-6
@@ -11,6 +11,7 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* This event is fired *before* the property is actually changed.
|
||||
@@ -18,24 +19,42 @@ import org.bukkit.event.Event;
|
||||
* If it is cancelled, no change will happen.
|
||||
* <p>
|
||||
* If you want to get the values of the world before the change, query the world.
|
||||
* If you want to get the value being changed, use getProperty()
|
||||
* To get the name of the property that was changed, use {@link #getPropertyName()}.
|
||||
* To get the new value, use {@link #getTheNewValue()}. To change it, use {@link #setTheNewValue(Object)}.
|
||||
* @param <T> The type of the property that was set.
|
||||
*/
|
||||
public class MVWorldPropertyChangeEvent extends Event implements Cancellable {
|
||||
public class MVWorldPropertyChangeEvent<T> extends Event implements Cancellable {
|
||||
private MultiverseWorld world;
|
||||
private CommandSender changer;
|
||||
private boolean isCancelled = false;
|
||||
private String value;
|
||||
private String name;
|
||||
private T value;
|
||||
|
||||
|
||||
public MVWorldPropertyChangeEvent(MultiverseWorld world, CommandSender changer, String name, String value) {
|
||||
super("MVWorldPropertyChange");
|
||||
public MVWorldPropertyChangeEvent(MultiverseWorld world, CommandSender changer, String name, T value) {
|
||||
this.world = world;
|
||||
this.changer = changer;
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the handler list. This is required by the event system.
|
||||
* @return A list of handlers.
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the changed world property's name.
|
||||
* @return The changed world property's name.
|
||||
@@ -47,16 +66,38 @@ public class MVWorldPropertyChangeEvent extends Event implements Cancellable {
|
||||
/**
|
||||
* Gets the new value.
|
||||
* @return The new value.
|
||||
* @deprecated Use {@link #getTheNewValue()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getNewValue() {
|
||||
return this.value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the new value.
|
||||
* @return The new value.
|
||||
*/
|
||||
public T getTheNewValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new value.
|
||||
* <p>
|
||||
* This method is only a stub, it'll <b>always</b> throw an {@link UnsupportedOperationException}!
|
||||
* @param value The new new value.
|
||||
* @deprecated Use {@link #setTheNewValue(Object)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setNewValue(String value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new value.
|
||||
* @param value The new value.
|
||||
*/
|
||||
public void setTheNewValue(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -71,6 +112,8 @@ public class MVWorldPropertyChangeEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Gets the person (or console) who was responsible for the change.
|
||||
* <p>
|
||||
* This may be null!
|
||||
*
|
||||
* @return The person (or console) who was responsible for the change.
|
||||
*/
|
||||
|
||||
+4
@@ -14,4 +14,8 @@ public class PropertyDoesNotExistException extends Exception {
|
||||
public PropertyDoesNotExistException(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public PropertyDoesNotExistException(String name, Throwable cause) {
|
||||
super(name, cause);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -85,9 +85,9 @@ public class MVEntityListener implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void creatureSpawn(CreatureSpawnEvent event) {
|
||||
|
||||
// Check to see if the Creature is spawned by a plugin, we don't want to prevent this behaviour.
|
||||
if (event.getSpawnReason() == SpawnReason.CUSTOM) {
|
||||
// TODO: Allow the egg thing to be a config param. Doubt this will be per world; seems silly.
|
||||
if (event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,14 +99,13 @@ public class MVEntityListener implements Listener {
|
||||
if (!(this.worldManager.isMVWorld(world.getName())))
|
||||
return;
|
||||
|
||||
CreatureType creature = event.getCreatureType();
|
||||
|
||||
EntityType type = event.getEntityType();
|
||||
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
|
||||
|
||||
/**
|
||||
* Handle people with non-standard animals: ie a patched craftbukkit.
|
||||
*/
|
||||
if (creature == null) {
|
||||
if (type == null) {
|
||||
this.plugin.log(Level.FINER, "Found a null typed creature.");
|
||||
return;
|
||||
}
|
||||
@@ -114,18 +113,18 @@ public class MVEntityListener implements Listener {
|
||||
/**
|
||||
* Animal Handling
|
||||
*/
|
||||
if (event.getEntity() instanceof Animals || event.getEntity() instanceof Squid) {
|
||||
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getAnimalList(), mvworld.canAnimalsSpawn(), creature.toString().toUpperCase()));
|
||||
if (!event.isCancelled() && (event.getEntity() instanceof Animals || event.getEntity() instanceof Squid)) {
|
||||
event.setCancelled(shouldWeKillThisCreature(mvworld.getAnimalList(), mvworld.canAnimalsSpawn(), type.getName().toUpperCase()));
|
||||
}
|
||||
/**
|
||||
* Monster Handling
|
||||
*/
|
||||
if (event.getEntity() instanceof Monster || event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime) {
|
||||
event.setCancelled(this.shouldWeKillThisCreature(mvworld.getMonsterList(), mvworld.canMonstersSpawn(), creature.toString().toUpperCase()));
|
||||
if (!event.isCancelled() && (event.getEntity() instanceof Monster || event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime)) {
|
||||
event.setCancelled(shouldWeKillThisCreature(mvworld.getMonsterList(), mvworld.canMonstersSpawn(), type.getName().toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldWeKillThisCreature(List<String> creatureList, boolean allowCreatureSpawning, String creature) {
|
||||
private static boolean shouldWeKillThisCreature(List<String> creatureList, boolean allowCreatureSpawning, String creature) {
|
||||
if (creatureList.isEmpty() && allowCreatureSpawning) {
|
||||
// 1. There are no exceptions and animals are allowed. Save it.
|
||||
return false;
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
||||
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -56,7 +55,7 @@ public class MVPlayerListener implements Listener {
|
||||
}
|
||||
// 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 (MultiverseCore.PrefixChat) {
|
||||
if (plugin.getMVConfig().getPrefixChat()) {
|
||||
String world = event.getPlayer().getWorld().getName();
|
||||
String prefix = "";
|
||||
// If we're not a MV world, don't do anything
|
||||
@@ -127,14 +126,20 @@ public class MVPlayerListener implements Listener {
|
||||
public void playerJoin(PlayerJoinEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
if (!p.hasPlayedBefore()) {
|
||||
this.plugin.log(Level.FINE, "Player joined first!");
|
||||
if (MultiverseCore.FirstSpawnOverride) {
|
||||
this.plugin.log(Level.FINE, "Moving NEW player to(firstspawnoverride): " + worldManager.getFirstSpawnWorld().getSpawnLocation());
|
||||
this.spawnNewPlayer(p);
|
||||
this.plugin.log(Level.FINER, "Player joined for the FIRST time!");
|
||||
if (plugin.getMVConfig().getFirstSpawnOverride()) {
|
||||
this.plugin.log(Level.FINE, String.format("Moving NEW player to(firstspawnoverride): %s",
|
||||
worldManager.getFirstSpawnWorld().getSpawnLocation()));
|
||||
this.sendPlayerToDefaultWorld(p);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Player joined AGAIN!");
|
||||
this.plugin.log(Level.FINER, "Player joined AGAIN!");
|
||||
if (this.plugin.getMVConfig().getEnforceAccess() // check this only if we're enforcing access!
|
||||
&& !this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + p.getWorld().getName(), false)) {
|
||||
p.sendMessage("[MV] - Sorry you can't be in this world anymore!");
|
||||
this.sendPlayerToDefaultWorld(p);
|
||||
}
|
||||
}
|
||||
// Handle the Players GameMode setting for the new world.
|
||||
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
|
||||
@@ -165,8 +170,9 @@ public class MVPlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void playerTeleport(PlayerTeleportEvent event) {
|
||||
this.plugin.log(Level.FINEST, "Got teleport event for player '" + event.getPlayer().getName() + "' with cause '" + event.getCause() + "'");
|
||||
|
||||
this.plugin.log(Level.FINER, String.format(
|
||||
"Got teleport event for player '%s' with cause '%s'",
|
||||
event.getPlayer().getName(), event.getCause()));
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
@@ -175,41 +181,56 @@ public class MVPlayerListener implements Listener {
|
||||
String teleporterName = MultiverseCore.getPlayerTeleporter(teleportee.getName());
|
||||
if (teleporterName != null) {
|
||||
if (teleporterName.equals("CONSOLE")) {
|
||||
this.plugin.log(Level.FINEST, "We know the teleporter is the console! Magical!");
|
||||
this.plugin.log(Level.FINER, "We know the teleporter is the console! Magical!");
|
||||
teleporter = this.plugin.getServer().getConsoleSender();
|
||||
} else {
|
||||
teleporter = this.plugin.getServer().getPlayer(teleporterName);
|
||||
}
|
||||
}
|
||||
this.plugin.log(Level.FINEST, String.format("Inferred sender '%s' from name '%s', fetched from name '%s'",
|
||||
this.plugin.log(Level.FINER, String.format("Inferred sender '%s' from name '%s', fetched from name '%s'",
|
||||
teleporter, teleporterName, teleportee.getName()));
|
||||
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
|
||||
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
|
||||
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
|
||||
// The player is Teleporting to the same world.
|
||||
this.plugin.log(Level.FINER, "Player '" + teleportee.getName() + "' is teleporting to the same world.");
|
||||
this.plugin.log(Level.FINER, String.format("Player '%s' is teleporting to the same world.",
|
||||
teleportee.getName()));
|
||||
this.stateSuccess(teleportee.getName(), toWorld.getAlias());
|
||||
return;
|
||||
}
|
||||
// TODO: Refactor these lines.
|
||||
// Charge the teleporter
|
||||
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, teleporter, teleportee, true));
|
||||
if (event.isCancelled() && teleporter != null) {
|
||||
this.plugin.log(Level.FINE, String.format("Player '%s' was DENIED ACCESS to '%s' because '%s' don't have the FUNDS required to enter it.",
|
||||
teleportee.getName(), event.getTo().getWorld().getName(), teleporter.getName()));
|
||||
this.plugin.log(Level.FINE, String.format(
|
||||
"Player '%s' was DENIED ACCESS to '%s' because '%s' don't have the FUNDS required to enter it.",
|
||||
teleportee.getName(), toWorld.getAlias(), teleporter.getName()));
|
||||
|
||||
return;
|
||||
}
|
||||
if (MultiverseCore.EnforceAccess) {
|
||||
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
|
||||
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",
|
||||
teleportee.getName(), event.getTo().getWorld().getName(), teleporter.getName(), event.getTo().getWorld().getName()));
|
||||
this.plugin.log(Level.FINE, String.format(
|
||||
"Player '%s' was DENIED ACCESS to '%s' because '%s' don't have: multiverse.access.%s",
|
||||
teleportee.getName(), toWorld.getAlias(), teleporter.getName(),
|
||||
event.getTo().getWorld().getName()));
|
||||
} else {
|
||||
this.stateSuccess(teleportee.getName(), toWorld.getAlias());
|
||||
}
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, String.format("Player '%s' was allowed to go to '%s' because enforceaccess is off.",
|
||||
teleportee.getName(), event.getTo().getWorld().getName()));
|
||||
this.plugin.log(Level.FINE, String.format(
|
||||
"Player '%s' was allowed to go to '%s' because enforceaccess is off.",
|
||||
teleportee.getName(), toWorld.getAlias()));
|
||||
}
|
||||
}
|
||||
|
||||
private void stateSuccess(String playerName, String worldName) {
|
||||
this.plugin.log(Level.FINE, String.format(
|
||||
"MV-Core is allowing Player '%s' to go to '%s'.",
|
||||
playerName, worldName));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called to adjust the portal location to the actual portal location (and not
|
||||
* right outside of it.
|
||||
@@ -217,7 +238,6 @@ public class MVPlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void playerPortalCheck(PlayerPortalEvent event) {
|
||||
this.plugin.log(Level.FINE, "CALLING CORE-ADJUST!!!");
|
||||
if (event.isCancelled() || event.getFrom() == null) {
|
||||
return;
|
||||
}
|
||||
@@ -225,7 +245,7 @@ public class MVPlayerListener implements Listener {
|
||||
// REMEMBER! getTo MAY be NULL HERE!!!
|
||||
// If the player was actually outside of the portal, adjust the from location
|
||||
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.PORTAL) {
|
||||
Location newloc = SafeTTeleporter.findPortalBlockNextTo(event.getFrom());
|
||||
Location newloc = this.plugin.getSafeTTeleporter().findPortalBlockNextTo(event.getFrom());
|
||||
// TODO: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what
|
||||
// TODO: we want to do here.
|
||||
if (newloc != null) {
|
||||
@@ -263,7 +283,7 @@ public class MVPlayerListener implements Listener {
|
||||
event.getPlayer().getName(), event.getTo().getWorld().getName()));
|
||||
return;
|
||||
}
|
||||
if (MultiverseCore.EnforceAccess) {
|
||||
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
|
||||
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",
|
||||
@@ -275,10 +295,11 @@ public class MVPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnNewPlayer(final Player player) {
|
||||
// Spawn the player 1 tick after the login. I'm sure there's GOT to be a better way to do this...
|
||||
private void sendPlayerToDefaultWorld(final Player player) {
|
||||
// Remove the player 1 tick after the login. I'm sure there's GOT to be a better way to do this...
|
||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.teleport(plugin.getMVWorldManager().getFirstSpawnWorld().getSpawnLocation());
|
||||
}
|
||||
@@ -291,6 +312,9 @@ public class MVPlayerListener implements Listener {
|
||||
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
|
||||
if (mvWorld != null) {
|
||||
this.handleGameMode(player, mvWorld);
|
||||
} else {
|
||||
this.plugin.log(Level.FINER, String.format(
|
||||
"Not handling gamemode for world '%s' not managed by Multiverse.", world.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,17 +325,17 @@ public class MVPlayerListener implements Listener {
|
||||
*/
|
||||
public void handleGameMode(final Player player, final MultiverseWorld world) {
|
||||
// We perform this task one tick later to MAKE SURE that the player actually reaches the
|
||||
// destination world, otherwise we'd be changing the player mode if they havent moved anywhere.
|
||||
// destination world, otherwise we'd be changing the player mode if they haven't moved anywhere.
|
||||
if (!this.pt.playerCanIgnoreGameModeRestriction(world, player)) {
|
||||
this.plugin.log(Level.FINE, "Handeling gamemode for player: " + player.getName());
|
||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 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()) {
|
||||
MultiverseCore.staticLog(Level.FINE, "Handeling gamemode for player: " + player.getName() + ", " + world.getGameMode().toString());
|
||||
MultiverseCore.staticLog(Level.FINE, "PWorld: " + player.getWorld());
|
||||
MultiverseCore.staticLog(Level.FINE, "AWorld: " + world);
|
||||
MultiverseCore.staticLog(Level.FINEST, "From World: " + player.getWorld());
|
||||
MultiverseCore.staticLog(Level.FINEST, "To World: " + world);
|
||||
player.setGameMode(world.getGameMode());
|
||||
} else {
|
||||
MultiverseCore.staticLog(Level.FINE,
|
||||
@@ -321,7 +345,39 @@ public class MVPlayerListener implements Listener {
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Player: " + player.getName() + " is IMMUNE to gamemode changes!");
|
||||
this.plugin.log(Level.FINE, String.format("Player: %s is IMMUNE to gamemode changes!", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the allowflight attribute for the specified {@link Player}.
|
||||
* @param player The {@link Player}.
|
||||
* @param world The world the player is in.
|
||||
*/
|
||||
public void handleAllowFlight(final Player player, final MultiverseWorld world) {
|
||||
// We perform this task one tick later to MAKE SURE that the player actually reaches the
|
||||
// destination world, otherwise we'd be changing the player mode if they haven't moved anywhere.
|
||||
if (!this.pt.playerCanIgnoreAllowFlightRestriction(world, player)) {
|
||||
this.plugin.log(Level.FINE, "Handeling flight for player: " + player.getName());
|
||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// 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()) {
|
||||
player.setAllowFlight(world.isFlightAllowed());
|
||||
MultiverseCore.staticLog(Level.FINER,
|
||||
String.format("%s's allowFlight was set to %b!",
|
||||
player.getName(), world.isFlightAllowed()));
|
||||
} else {
|
||||
MultiverseCore.staticLog(Level.FINE,
|
||||
String.format("allowFlight was NOT changed for player '%s' because he is now in world '%s' instead of world '%s'",
|
||||
player.getName(), player.getWorld().getName(), world.getName()));
|
||||
}
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Player: " + player.getName() + " is IMMUNE to flight changes!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Multiverse's Plugin {@link Listener}.
|
||||
@@ -36,14 +35,16 @@ public class MVPluginListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void pluginEnable(PluginEnableEvent event) {
|
||||
// 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());
|
||||
}
|
||||
|
||||
/*
|
||||
if (event.getPlugin().getDescription().getName().equals("Spout")) {
|
||||
this.plugin.setSpout();
|
||||
this.plugin.log(Level.INFO, "Spout integration enabled.");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/******************************************************************************
|
||||
* 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());
|
||||
// We have to do it like this due to a bug in 1.1-R3
|
||||
if (cancelPortalEvent(world, event.getPortalType())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
if (cancelPortalEvent(world, PortalType.NETHER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If We're here, then the Portal was an Ender type:
|
||||
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getBlocks().get(0).getWorld());
|
||||
if (cancelPortalEvent(world, PortalType.ENDER)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static 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;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class AnchorManager {
|
||||
Set<String> anchorKeys = anchorsSection.getKeys(false);
|
||||
for (String key : anchorKeys) {
|
||||
//world:x,y,z:pitch:yaw
|
||||
Location anchorLocation = LocationManipulation.stringToLocation(anchorsSection.getString(key, ""));
|
||||
Location anchorLocation = plugin.getLocationManipulation().stringToLocation(anchorsSection.getString(key, ""));
|
||||
if (anchorLocation != null) {
|
||||
MultiverseCore.staticLog(Level.INFO, "Loading anchor: '" + key + "'...");
|
||||
this.anchors.put(key, anchorLocation);
|
||||
@@ -98,7 +98,7 @@ public class AnchorManager {
|
||||
* @return True if the anchor was successfully saved.
|
||||
*/
|
||||
public boolean saveAnchorLocation(String anchor, String location) {
|
||||
Location parsed = LocationManipulation.stringToLocation(location);
|
||||
Location parsed = plugin.getLocationManipulation().stringToLocation(location);
|
||||
return parsed != null && this.saveAnchorLocation(anchor, parsed);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class AnchorManager {
|
||||
if (l == null) {
|
||||
return false;
|
||||
}
|
||||
this.anchorConfig.set("anchors." + anchor, LocationManipulation.locationToString(l));
|
||||
this.anchorConfig.set("anchors." + anchor, plugin.getLocationManipulation().locationToString(l));
|
||||
this.anchors.put(anchor, l);
|
||||
return this.saveAnchors();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Used to determine block/location-related facts.
|
||||
*
|
||||
* @deprecated Use instead: {@link com.onarandombox.MultiverseCore.api.BlockSafety} and {@link SimpleBlockSafety}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlockSafety {
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,9 +11,6 @@ import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.Handler;
|
||||
@@ -41,9 +38,7 @@ public class DebugLog {
|
||||
try {
|
||||
this.fh = new FileHandler(file, true);
|
||||
this.log.setUseParentHandlers(false);
|
||||
List<Handler> handlerList = new ArrayList<Handler>();
|
||||
handlerList.addAll(Arrays.asList(this.log.getHandlers()));
|
||||
for (Handler handler : handlerList) {
|
||||
for (Handler handler : this.log.getHandlers()) {
|
||||
this.log.removeHandler(handler);
|
||||
}
|
||||
this.log.addHandler(this.fh);
|
||||
|
||||
@@ -20,9 +20,11 @@ public class FancyMessage implements FancyText {
|
||||
|
||||
/**
|
||||
* Allows easy creation of an alternating colored list.
|
||||
* TODO: Documentation! Why does CheckStyle just ignore this?
|
||||
*
|
||||
* @param title
|
||||
* @param message
|
||||
* @param scheme
|
||||
*/
|
||||
public FancyMessage(String title, String message, FancyColorScheme scheme) {
|
||||
this.title = title;
|
||||
|
||||
@@ -25,19 +25,16 @@ public class FileUtils {
|
||||
*/
|
||||
public static boolean deleteFolder(File file) {
|
||||
if (file.exists()) {
|
||||
boolean ret = true;
|
||||
// If the file exists, and it has more than one file in it.
|
||||
if (file.isDirectory()) {
|
||||
for (File f : file.listFiles()) {
|
||||
if (!FileUtils.deleteFolder(f)) {
|
||||
return false;
|
||||
}
|
||||
ret = ret && deleteFolder(f);
|
||||
}
|
||||
}
|
||||
file.delete();
|
||||
return !file.exists();
|
||||
return ret && file.delete();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,10 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Utility class to manipulate locations.
|
||||
*
|
||||
* @deprecated Use instead: {@link com.onarandombox.MultiverseCore.api.LocationManipulation} and {@link SimpleLocationManipulation}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class LocationManipulation {
|
||||
private LocationManipulation() { }
|
||||
|
||||
@@ -246,7 +249,6 @@ public class LocationManipulation {
|
||||
}
|
||||
float speed = getSpeed(v);
|
||||
float halfSpeed = (float) (speed / 2.0);
|
||||
// TODO: Mathmatacize this:
|
||||
if (direction.equalsIgnoreCase("n")) {
|
||||
return new Vector(0, 0, -1 * speed);
|
||||
} else if (direction.equalsIgnoreCase("ne")) {
|
||||
|
||||
@@ -10,14 +10,16 @@ package com.onarandombox.MultiverseCore.utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseMessaging;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Utility-class for messaging.
|
||||
* The default-implementation of {@link MultiverseMessaging}.
|
||||
*/
|
||||
public class MVMessaging {
|
||||
public class MVMessaging implements MultiverseMessaging {
|
||||
private Map<String, Long> sentList;
|
||||
private int cooldown;
|
||||
|
||||
@@ -27,49 +29,39 @@ public class MVMessaging {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the message-cooldown.
|
||||
* @param milliseconds The new message-cooldown in milliseconds.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setCooldown(int milliseconds) {
|
||||
this.cooldown = milliseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the specified sender if the cooldown has passed.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param message The message to send.
|
||||
* @param ignoreCooldown If true this message will always be sent. Useful for things like menus
|
||||
* @return true if the message was sent, false if not.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean sendMessage(CommandSender sender, String message, boolean ignoreCooldown) {
|
||||
return this.sendMessages(sender, new String[]{ message }, ignoreCooldown);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a group of messages to the specified sender if the cooldown has passed.
|
||||
* This method is needed, since sending many messages in quick succession would violate
|
||||
* the cooldown.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param messages The messages to send.
|
||||
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
|
||||
* @return true if the message was sent, false if not.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean sendMessages(CommandSender sender, String[] messages, boolean ignoreCooldown) {
|
||||
if (!(sender instanceof Player) || ignoreCooldown) {
|
||||
|
||||
this.sendMessages(sender, messages);
|
||||
sendMessages(sender, messages);
|
||||
return true;
|
||||
}
|
||||
if (!this.sentList.containsKey(sender.getName())) {
|
||||
this.sendMessages(sender, messages);
|
||||
sendMessages(sender, messages);
|
||||
this.sentList.put(sender.getName(), System.currentTimeMillis());
|
||||
return true;
|
||||
} else {
|
||||
long time = System.currentTimeMillis();
|
||||
if (time >= this.sentList.get(sender.getName()) + this.cooldown) {
|
||||
this.sendMessages(sender, messages);
|
||||
sendMessages(sender, messages);
|
||||
this.sentList.put(sender.getName(), System.currentTimeMillis());
|
||||
return true;
|
||||
}
|
||||
@@ -78,29 +70,23 @@ public class MVMessaging {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a group of messages to the specified sender if the cooldown has passed.
|
||||
* This method is needed, since sending many messages in quick succession would violate
|
||||
* the cooldown.
|
||||
*
|
||||
* @param sender The person/console to send the message to.
|
||||
* @param messages The messages to send.
|
||||
* @param ignoreCooldown If true these messages will always be sent. Useful for things like menus
|
||||
* @return true if the message was sent, false if not.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean sendMessages(CommandSender sender, Collection<String> messages, boolean ignoreCooldown) {
|
||||
return this.sendMessages(sender, messages.toArray(new String[0]), ignoreCooldown);
|
||||
}
|
||||
|
||||
private void sendMessages(CommandSender sender, String[] messages) {
|
||||
private static void sendMessages(CommandSender sender, String[] messages) {
|
||||
for (String s : messages) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the message-cooldown.
|
||||
* @return The message-cooldown.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.pneumaticraft.commandhandler.PermissionsInterface;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -43,11 +44,22 @@ public class MVPermissions implements PermissionsInterface {
|
||||
* @return True if they should bypass restrictions.
|
||||
*/
|
||||
public boolean canIgnoreGameModeRestriction(Player p, MultiverseWorld w) {
|
||||
if (p.hasPermission("mv.bypass.gamemode.*")) {
|
||||
this.plugin.log(Level.FINER, "Player has mv.bypass.gamemode.* their gamemode is ignored!");
|
||||
return p.hasPermission("mv.bypass.gamemode." + w.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Player can ignore GameMode restrictions for world they travel to.
|
||||
*
|
||||
* @param p The {@link Player} to check.
|
||||
* @param w The {@link MultiverseWorld} the player wants to teleport to.
|
||||
* @return True if they should bypass restrictions.
|
||||
*/
|
||||
public boolean canIgnoreAllowFlightRestriction(Player p, MultiverseWorld w) {
|
||||
if (p.hasPermission("mv.bypass.allowflight.*")) {
|
||||
this.plugin.log(Level.FINER, "Player has mv.bypass.allowflight.* they can fly!");
|
||||
return true;
|
||||
}
|
||||
return p.hasPermission("mv.bypass.gamemode." + w.getName());
|
||||
return p.hasPermission("mv.bypass.allowflight." + w.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +110,8 @@ public class MVPermissions implements PermissionsInterface {
|
||||
*/
|
||||
public boolean canEnterWorld(Player p, MultiverseWorld w) {
|
||||
// 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 this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||
@@ -142,6 +155,87 @@ public class MVPermissions implements PermissionsInterface {
|
||||
return this.hasPermission(p, d.getRequiredPermission(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells a {@link CommandSender} why another {@link CommandSender} can or can not access a certain {@link MVDestination}.
|
||||
* @param asker The {@link CommandSender} that's asking.
|
||||
* @param playerInQuestion The {@link CommandSender} whose permissions we want to know.
|
||||
* @param d The {@link MVDestination}.
|
||||
*/
|
||||
public void tellMeWhyICantDoThis(CommandSender asker, CommandSender playerInQuestion, MVDestination d) {
|
||||
boolean cango = true;
|
||||
if (!(playerInQuestion instanceof Player)) {
|
||||
asker.sendMessage(String.format("The console can do %severything%s.", ChatColor.RED, ChatColor.WHITE));
|
||||
return;
|
||||
}
|
||||
Player p = (Player) playerInQuestion;
|
||||
if (d == null) {
|
||||
asker.sendMessage(String.format("The provided Destination is %sNULL%s, and therefore %sINVALID%s.",
|
||||
ChatColor.RED, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE));
|
||||
cango = false;
|
||||
}
|
||||
// We know it'll be a player here due to the first line of this method.
|
||||
if (d.getLocation(p) == null) {
|
||||
asker.sendMessage(String.format(
|
||||
"The player will spawn at an %sindeterminate location%s. Talk to the MV Devs if you see this",
|
||||
ChatColor.RED, ChatColor.WHITE));
|
||||
cango = false;
|
||||
}
|
||||
String worldName = d.getLocation(p).getWorld().getName();
|
||||
if (!this.worldMgr.isMVWorld(worldName)) {
|
||||
asker.sendMessage(String.format("The destination resides in a world(%s%s%s) that is not managed by Multiverse.",
|
||||
ChatColor.AQUA, worldName, ChatColor.WHITE));
|
||||
asker.sendMessage(String.format("Type %s/mv import ?%s to see the import command's help page.",
|
||||
ChatColor.DARK_AQUA, ChatColor.WHITE));
|
||||
cango = false;
|
||||
}
|
||||
if (!this.hasPermission(p, "multiverse.access." + worldName, false)) {
|
||||
asker.sendMessage(String.format("The player (%s%s%s) does not have the required world entry permission (%s%s%s) to go to the destination (%s%s%s).",
|
||||
ChatColor.AQUA, p.getDisplayName(), ChatColor.WHITE,
|
||||
ChatColor.GREEN, "multiverse.access." + worldName, ChatColor.WHITE,
|
||||
ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE));
|
||||
cango = false;
|
||||
}
|
||||
if (!this.hasPermission(p, d.getRequiredPermission(), false)) {
|
||||
asker.sendMessage(String.format("The player (%s%s%s) does not have the required entry permission (%s%s%s) to go to the destination (%s%s%s).",
|
||||
ChatColor.AQUA, p.getDisplayName(), ChatColor.WHITE,
|
||||
ChatColor.GREEN, d.getRequiredPermission(), ChatColor.WHITE,
|
||||
ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE));
|
||||
cango = false;
|
||||
}
|
||||
if (cango) {
|
||||
asker.sendMessage(String.format("The player (%s%s%s) CAN go to the destination (%s%s%s).",
|
||||
ChatColor.AQUA, p.getDisplayName(), ChatColor.WHITE,
|
||||
ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE));
|
||||
} else {
|
||||
asker.sendMessage(String.format("The player (%s%s%s) cannot access the destination %s%s%s. Therefore they can't use mvtp at all for this.",
|
||||
ChatColor.AQUA, p.getDisplayName(), ChatColor.WHITE,
|
||||
ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE));
|
||||
return;
|
||||
}
|
||||
if (!this.hasPermission(p, "multiverse.teleport.self." + d.getIdentifier(), false)) {
|
||||
asker.sendMessage(String.format("The player (%s%s%s) does not have the required teleport permission (%s%s%s) to use %s/mvtp %s%s.",
|
||||
ChatColor.AQUA, p.getDisplayName(), ChatColor.WHITE,
|
||||
ChatColor.GREEN, "multiverse.teleport.self." + d.getIdentifier(), ChatColor.WHITE,
|
||||
ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE));
|
||||
} else {
|
||||
asker.sendMessage(String.format("The player (%s%s%s) has the required teleport permission (%s%s%s) to use %s/mvtp %s%s.",
|
||||
ChatColor.AQUA, p.getDisplayName(), ChatColor.WHITE,
|
||||
ChatColor.GREEN, "multiverse.teleport.self." + d.getIdentifier(), ChatColor.WHITE,
|
||||
ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE));
|
||||
}
|
||||
if (!this.hasPermission(p, "multiverse.teleport.other." + d.getIdentifier(), false)) {
|
||||
asker.sendMessage(String.format("The player (%s%s%s) does not have the required teleport permission (%s%s%s) to send others to %s%s%s via mvtp.",
|
||||
ChatColor.AQUA, p.getDisplayName(), ChatColor.WHITE,
|
||||
ChatColor.GREEN, "multiverse.teleport.other." + d.getIdentifier(), ChatColor.WHITE,
|
||||
ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE));
|
||||
} else {
|
||||
asker.sendMessage(String.format("The player (%s%s%s) has required teleport permission (%s%s%s) to send others to %s%s%s via mvtp.",
|
||||
ChatColor.AQUA, p.getDisplayName(), ChatColor.WHITE,
|
||||
ChatColor.GREEN, "multiverse.teleport.other." + d.getIdentifier(), ChatColor.WHITE,
|
||||
ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a player has a permission.
|
||||
*
|
||||
@@ -150,6 +244,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
* @param isOpRequired @Deprecated. This is not used for anything anymore.
|
||||
* @return True if they have that permission or any parent.
|
||||
*/
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender, String node, boolean isOpRequired) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
@@ -163,26 +258,24 @@ public class MVPermissions implements PermissionsInterface {
|
||||
if (node.equals("")) {
|
||||
return true;
|
||||
}
|
||||
boolean hasPermission = checkActualPermission(sender, node);
|
||||
|
||||
// I consider this a workaround. At the moment, when we add a node AND recalc the permissions, until the perms
|
||||
// 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
|
||||
// when if finds a true or there are no more parents. --FF
|
||||
if (!hasPermission) {
|
||||
hasPermission = this.hasAnyParentPermission(sender, node);
|
||||
}
|
||||
|
||||
return hasPermission;
|
||||
return checkActualPermission(sender, node);
|
||||
}
|
||||
|
||||
// TODO: Better player checks, most likely not needed, but safer.
|
||||
private boolean checkActualPermission(CommandSender sender, String node) {
|
||||
Player player = (Player) sender;
|
||||
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]");
|
||||
|
||||
boolean hasPermission = sender.hasPermission(node);
|
||||
if (!sender.isPermissionSet(node)) {
|
||||
this.plugin.log(Level.FINER, String.format("The node [%s%s%s] was %sNOT%s set for [%s%s%s].",
|
||||
ChatColor.RED, node, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.AQUA,
|
||||
player.getDisplayName(), ChatColor.WHITE));
|
||||
}
|
||||
if (hasPermission) {
|
||||
this.plugin.log(Level.FINER, "Player [" + player.getName() + "] HAS PERMISSION [" + node + "]!");
|
||||
this.plugin.log(Level.FINER, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... YES");
|
||||
} else {
|
||||
this.plugin.log(Level.FINER, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... NO");
|
||||
}
|
||||
return hasPermission;
|
||||
}
|
||||
@@ -196,6 +289,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
* @param node The permission node to check (possibly already a parent).
|
||||
* @return True if they have any parent perm, false if none.
|
||||
*/
|
||||
// TODO remove this...?
|
||||
private boolean hasAnyParentPermission(CommandSender sender, String node) {
|
||||
String parentPerm = this.pullOneLevelOff(node);
|
||||
// Base case
|
||||
@@ -216,7 +310,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
* @param node The root node to check.
|
||||
* @return The parent of the node
|
||||
*/
|
||||
private String pullOneLevelOff(String node) {
|
||||
private static String pullOneLevelOff(String node) {
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -321,7 +415,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
/**
|
||||
* If the given permission was 'multiverse.core.tp.self', this would return 'multiverse.core.tp.*'.
|
||||
*/
|
||||
private String getParentPerm(String[] seperated) {
|
||||
private static String getParentPerm(String[] seperated) {
|
||||
if (seperated.length == 1) {
|
||||
return null;
|
||||
}
|
||||
@@ -331,5 +425,4 @@ public class MVPermissions implements PermissionsInterface {
|
||||
}
|
||||
return returnString + "*";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -23,9 +22,9 @@ public class MVPlayerSession {
|
||||
private long teleportLast = 0L; // Timestamp for the Players last Portal Teleportation.
|
||||
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.config = config;
|
||||
// this.bedSpawn = null;
|
||||
@@ -42,6 +41,6 @@ public class MVPlayerSession {
|
||||
*/
|
||||
public boolean getTeleportable() {
|
||||
long time = (new Date()).getTime();
|
||||
return ((time - this.teleportLast) > this.config.getInt("portalcooldown", 5000)); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
return ((time - this.teleportLast) > this.config.getTeleportCooldown());
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.destination.CannonDestination;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TravelAgent;
|
||||
@@ -106,7 +107,7 @@ public class MVTravelAgent implements TravelAgent {
|
||||
if (this.destination instanceof CannonDestination) {
|
||||
this.core.log(Level.FINE, "Using Stock TP method. This cannon will have 0 velocity");
|
||||
}
|
||||
SafeTTeleporter teleporter = new SafeTTeleporter(this.core);
|
||||
SafeTTeleporter teleporter = this.core.getSafeTTeleporter();
|
||||
Location newLoc = this.destination.getLocation(this.player);
|
||||
if (this.destination.useSafeTeleporter()) {
|
||||
newLoc = teleporter.getSafeLocation(this.player, this.destination);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class PermissionTools {
|
||||
* @param separatedPermissionString The array of a dot separated perm string.
|
||||
* @return The dot separated parent permission string.
|
||||
*/
|
||||
private String getParentPerm(String[] separatedPermissionString) {
|
||||
private static String getParentPerm(String[] separatedPermissionString) {
|
||||
if (separatedPermissionString.length == 1) {
|
||||
return null;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class PermissionTools {
|
||||
*/
|
||||
public boolean playerHasMoneyToEnter(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee, boolean pay) {
|
||||
Player teleporterPlayer;
|
||||
if (MultiverseCore.TeleportIntercept) {
|
||||
if (plugin.getMVConfig().getTeleportIntercept()) {
|
||||
if (teleporter instanceof ConsoleCommandSender) {
|
||||
return true;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ public class PermissionTools {
|
||||
this.plugin.log(Level.FINEST, "Checking '" + teleporter + "' can send '" + teleportee + "' somewhere");
|
||||
|
||||
Player teleporterPlayer;
|
||||
if (MultiverseCore.TeleportIntercept) {
|
||||
if (plugin.getMVConfig().getTeleportIntercept()) {
|
||||
// The console can send anyone anywhere
|
||||
if (teleporter instanceof ConsoleCommandSender) {
|
||||
return true;
|
||||
@@ -246,4 +246,21 @@ public class PermissionTools {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a player should bypass allow-flight restrictions.
|
||||
*
|
||||
* @param toWorld world travelling to.
|
||||
* @param teleportee player travelling.
|
||||
* @return True if they should bypass restrictions
|
||||
*/
|
||||
public boolean playerCanIgnoreAllowFlightRestriction(MultiverseWorld toWorld, Player teleportee) {
|
||||
if (toWorld != null) {
|
||||
return this.plugin.getMVPerms().canIgnoreAllowFlightRestriction(teleportee, toWorld);
|
||||
} else {
|
||||
// TODO: Determine if this value is false because a world didn't exist
|
||||
// or if it was because a world wasn't imported.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Animals;
|
||||
@@ -25,7 +26,10 @@ import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Utility class that removes animals from worlds that don't belong there.
|
||||
*
|
||||
* @deprecated Use instead: {@link WorldPurger} and {@link SimpleWorldPurger}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class PurgeWorlds {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
@@ -52,7 +56,7 @@ public class PurgeWorlds {
|
||||
/**
|
||||
* Convenience method for {@link #purgeWorld(CommandSender, MultiverseWorld, List, boolean, boolean)} that takes the settings from the world-config.
|
||||
*
|
||||
* @param sender The {@link CommandSender} that initiated the action (TODO: Do we really need this?)
|
||||
* @param sender The {@link CommandSender} that initiated the action
|
||||
* @param world The {@link MultiverseWorld}.
|
||||
*/
|
||||
public void purgeWorld(CommandSender sender, MultiverseWorld world) {
|
||||
@@ -66,7 +70,7 @@ public class PurgeWorlds {
|
||||
|
||||
/**
|
||||
* Clear all animals/monsters that do not belong to a world according to the config.
|
||||
* @param sender The {@link CommandSender} that initiated the action. (TODO: Do we really need this?)
|
||||
* @param sender The {@link CommandSender} that initiated the action.
|
||||
* @param mvworld The {@link MultiverseWorld}.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
@@ -123,14 +127,13 @@ public class PurgeWorlds {
|
||||
*/
|
||||
private boolean killMonster(MultiverseWorld mvworld, Entity e, List<String> creaturesToKill, boolean negate) {
|
||||
String entityName = "";
|
||||
//TODO: Fixme once either Rigby puts his awesome thing in OR Enderdragon gets a toString, OR both.
|
||||
if (e instanceof EnderDragon) {
|
||||
entityName = "ENDERDRAGON";
|
||||
} else {
|
||||
entityName = e.toString().replaceAll("Craft", "").toUpperCase();
|
||||
}
|
||||
if (e instanceof Slime || e instanceof Monster || e instanceof Ghast || e instanceof EnderDragon) {
|
||||
this.plugin.log(Level.FINER, "Looking at a monster: " + e);
|
||||
this.plugin.log(Level.FINEST, "Looking at a monster: " + e);
|
||||
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("MONSTERS")) {
|
||||
if (!negate) {
|
||||
this.plugin.log(Level.FINEST, "Removing a monster: " + e);
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.enums.TeleportResult;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -26,7 +28,10 @@ import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The {@link SafeTTeleporter}.
|
||||
*
|
||||
* @deprecated Use instead: {@link com.onarandombox.MultiverseCore.api.SafeTTeleporter} and {@link SimpleSafeTTeleporter}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class SafeTTeleporter {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
@@ -34,7 +39,7 @@ public class SafeTTeleporter {
|
||||
|
||||
public SafeTTeleporter(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.bs = new BlockSafety();
|
||||
this.bs = plugin.getBlockSafety();
|
||||
}
|
||||
|
||||
private static final int DEFAULT_TOLERANCE = 6;
|
||||
@@ -58,12 +63,11 @@ public class SafeTTeleporter {
|
||||
*/
|
||||
public Location getSafeLocation(Location l, int tolerance, int radius) {
|
||||
// Check around the player first in a configurable radius:
|
||||
// TODO: Make this configurable
|
||||
Location safe = checkAboveAndBelowLocation(l, tolerance, radius);
|
||||
if (safe != null) {
|
||||
safe.setX(safe.getBlockX() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
safe.setZ(safe.getBlockZ() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.plugin.log(Level.FINE, "Hey! I found one: " + LocationManipulation.strCoordsRaw(safe));
|
||||
this.plugin.log(Level.FINE, "Hey! I found one: " + plugin.getLocationManipulation().strCoordsRaw(safe));
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Uh oh! No safe place found!");
|
||||
}
|
||||
@@ -77,7 +81,7 @@ public class SafeTTeleporter {
|
||||
}
|
||||
// We want half of it, so we can go up and down
|
||||
tolerance /= 2;
|
||||
this.plugin.log(Level.FINER, "Given Location of: " + LocationManipulation.strCoordsRaw(l));
|
||||
this.plugin.log(Level.FINER, "Given Location of: " + plugin.getLocationManipulation().strCoordsRaw(l));
|
||||
this.plugin.log(Level.FINER, "Checking +-" + tolerance + " with a radius of " + radius);
|
||||
|
||||
// For now this will just do a straight up block.
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The default-implementation of {@link BlockSafety}.
|
||||
*/
|
||||
public class SimpleBlockSafety implements BlockSafety {
|
||||
private final Core plugin;
|
||||
|
||||
public SimpleBlockSafety(Core plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isBlockAboveAir(Location l) {
|
||||
Location downOne = l.clone();
|
||||
downOne.setY(downOne.getY() - 1);
|
||||
return (downOne.getBlock().getType() == Material.AIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean playerCanSpawnHereSafely(World world, double x, double y, double z) {
|
||||
Location l = new Location(world, x, y, z);
|
||||
return playerCanSpawnHereSafely(l);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean playerCanSpawnHereSafely(Location l) {
|
||||
if (l == null) {
|
||||
// Can't safely spawn at a null location!
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = l.getWorld();
|
||||
Location actual = l.clone();
|
||||
Location upOne = l.clone();
|
||||
Location downOne = l.clone();
|
||||
upOne.setY(upOne.getY() + 1);
|
||||
downOne.setY(downOne.getY() - 1);
|
||||
|
||||
if (isSolidBlock(world.getBlockAt(actual).getType())
|
||||
|| isSolidBlock(upOne.getBlock().getType())) {
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here (Actual)? ("
|
||||
+ actual.getBlock().getType() + ")[" + isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here (upOne)? ("
|
||||
+ upOne.getBlock().getType() + ")[" + isSolidBlock(upOne.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here (downOne)? ("
|
||||
+ downOne.getBlock().getType() + ")[" + isSolidBlock(downOne.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (downOne.getBlock().getType() == Material.FIRE) {
|
||||
MultiverseCore.staticLog(Level.FINER, "There's fire below! ("
|
||||
+ actual.getBlock().getType() + ")[" + isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isBlockAboveAir(actual)) {
|
||||
MultiverseCore.staticLog(Level.FINER, "Is block above air [" + isBlockAboveAir(actual) + "]");
|
||||
MultiverseCore.staticLog(Level.FINER, "Has 2 blocks of water below [" + this.hasTwoBlocksofWaterBelow(actual) + "]");
|
||||
return this.hasTwoBlocksofWaterBelow(actual);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getTopBlock(Location l) {
|
||||
Location check = l.clone();
|
||||
check.setY(127); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
while (check.getY() > 0) {
|
||||
if (this.playerCanSpawnHereSafely(check)) {
|
||||
return check;
|
||||
}
|
||||
check.setY(check.getY() - 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getBottomBlock(Location l) {
|
||||
Location check = l.clone();
|
||||
check.setY(0);
|
||||
while (check.getY() < 127) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
if (this.playerCanSpawnHereSafely(check)) {
|
||||
return check;
|
||||
}
|
||||
check.setY(check.getY() + 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* If someone has a better way of this... Please either tell us, or submit a pull request!
|
||||
*/
|
||||
private static boolean isSolidBlock(Material type) {
|
||||
switch (type) {
|
||||
case AIR:
|
||||
return false;
|
||||
case SNOW:
|
||||
return false;
|
||||
case TRAP_DOOR:
|
||||
return false;
|
||||
case TORCH:
|
||||
return false;
|
||||
case YELLOW_FLOWER:
|
||||
return false;
|
||||
case RED_ROSE:
|
||||
return false;
|
||||
case RED_MUSHROOM:
|
||||
return false;
|
||||
case BROWN_MUSHROOM:
|
||||
return false;
|
||||
case REDSTONE:
|
||||
return false;
|
||||
case REDSTONE_WIRE:
|
||||
return false;
|
||||
case RAILS:
|
||||
return false;
|
||||
case POWERED_RAIL:
|
||||
return false;
|
||||
case REDSTONE_TORCH_ON:
|
||||
return false;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
return false;
|
||||
case DEAD_BUSH:
|
||||
return false;
|
||||
case SAPLING:
|
||||
return false;
|
||||
case STONE_BUTTON:
|
||||
return false;
|
||||
case LEVER:
|
||||
return false;
|
||||
case LONG_GRASS:
|
||||
return false;
|
||||
case PORTAL:
|
||||
return false;
|
||||
case STONE_PLATE:
|
||||
return false;
|
||||
case WOOD_PLATE:
|
||||
return false;
|
||||
case SEEDS:
|
||||
return false;
|
||||
case SUGAR_CANE_BLOCK:
|
||||
return false;
|
||||
case WALL_SIGN:
|
||||
return false;
|
||||
case SIGN_POST:
|
||||
return false;
|
||||
case WOODEN_DOOR:
|
||||
return false;
|
||||
case STATIONARY_WATER:
|
||||
return false;
|
||||
case WATER:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isEntitiyOnTrack(Location l) {
|
||||
Material currentBlock = l.getBlock().getType();
|
||||
return (currentBlock == Material.POWERED_RAIL || currentBlock == Material.DETECTOR_RAIL || currentBlock == Material.RAILS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks recursively below a {@link Location} for 2 blocks of water.
|
||||
*
|
||||
* @param l The {@link Location}
|
||||
* @return Whether there are 2 blocks of water
|
||||
*/
|
||||
private boolean hasTwoBlocksofWaterBelow(Location l) {
|
||||
if (l.getBlockY() < 0) {
|
||||
return false;
|
||||
}
|
||||
Location oneBelow = l.clone();
|
||||
oneBelow.subtract(0, 1, 0);
|
||||
if (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER) {
|
||||
Location twoBelow = oneBelow.clone();
|
||||
twoBelow.subtract(0, 1, 0);
|
||||
return (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER);
|
||||
}
|
||||
if (oneBelow.getBlock().getType() != Material.AIR) {
|
||||
return false;
|
||||
}
|
||||
return hasTwoBlocksofWaterBelow(oneBelow);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean canSpawnCartSafely(Minecart cart) {
|
||||
if (this.isBlockAboveAir(cart.getLocation())) {
|
||||
return true;
|
||||
}
|
||||
if (this.isEntitiyOnTrack(plugin.getLocationManipulation().getNextBlock(cart))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean canSpawnVehicleSafely(Vehicle vehicle) {
|
||||
if (this.isBlockAboveAir(vehicle.getLocation())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The default-implementation of {@link LocationManipulation}.
|
||||
*/
|
||||
public class SimpleLocationManipulation implements LocationManipulation {
|
||||
private static final Map<String, Integer> ORIENTATION_INTS;
|
||||
|
||||
static {
|
||||
Map<String, Integer> orientationInts = new HashMap<String, Integer>();
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
orientationInts.put("n", 180);
|
||||
orientationInts.put("ne", 225);
|
||||
orientationInts.put("e", 270);
|
||||
orientationInts.put("se", 315);
|
||||
orientationInts.put("s", 0);
|
||||
orientationInts.put("sw", 45);
|
||||
orientationInts.put("w", 90);
|
||||
orientationInts.put("nw", 135);
|
||||
|
||||
// "freeze" the map:
|
||||
ORIENTATION_INTS = Collections.unmodifiableMap(orientationInts);
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String locationToString(Location location) {
|
||||
if (location == null) {
|
||||
return "";
|
||||
}
|
||||
return String.format("%s:%.2f,%.2f,%.2f:%.2f:%.2f", location.getWorld().getName(),
|
||||
location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getBlockLocation(Location l) {
|
||||
l.setX(l.getBlockX());
|
||||
l.setY(l.getBlockY());
|
||||
l.setZ(l.getBlockZ());
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location stringToLocation(String locationString) {
|
||||
//format:
|
||||
//world:x,y,z:pitch:yaw
|
||||
if (locationString == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Split the whole string, format is:
|
||||
// {'world', 'x,y,z'[, 'pitch', 'yaw']}
|
||||
String[] split = locationString.split(":");
|
||||
if (split.length < 2 || split.length > 4) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
return null;
|
||||
}
|
||||
// Split the xyz string, format is:
|
||||
// {'x', 'y', 'z'}
|
||||
String[] xyzsplit = split[1].split(",");
|
||||
if (xyzsplit.length != 3) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Verify the world is valid
|
||||
World w = Bukkit.getWorld(split[0]);
|
||||
if (w == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
float pitch = 0;
|
||||
float yaw = 0;
|
||||
if (split.length >= 3) {
|
||||
yaw = (float) Double.parseDouble(split[2]);
|
||||
}
|
||||
if (split.length == 4) { // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
pitch = (float) Double.parseDouble(split[3]);
|
||||
}
|
||||
return new Location(w, Double.parseDouble(xyzsplit[0]), Double.parseDouble(xyzsplit[1]), Double.parseDouble(xyzsplit[2]), yaw, pitch);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String strCoords(Location l) {
|
||||
String result = "";
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
result += ChatColor.WHITE + "X: " + ChatColor.AQUA + df.format(l.getX()) + " ";
|
||||
result += ChatColor.WHITE + "Y: " + ChatColor.AQUA + df.format(l.getY()) + " ";
|
||||
result += ChatColor.WHITE + "Z: " + ChatColor.AQUA + df.format(l.getZ()) + " ";
|
||||
result += ChatColor.WHITE + "P: " + ChatColor.GOLD + df.format(l.getPitch()) + " ";
|
||||
result += ChatColor.WHITE + "Y: " + ChatColor.GOLD + df.format(l.getYaw()) + " ";
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String strCoordsRaw(Location l) {
|
||||
if (l == null) {
|
||||
return "null";
|
||||
}
|
||||
String result = "";
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
result += "X: " + df.format(l.getX()) + " ";
|
||||
result += "Y: " + df.format(l.getY()) + " ";
|
||||
result += "Z: " + df.format(l.getZ()) + " ";
|
||||
result += "P: " + df.format(l.getPitch()) + " ";
|
||||
result += "Y: " + df.format(l.getYaw()) + " ";
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getDirection(Location location) {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
double r = (location.getYaw() % 360) + 180;
|
||||
// Remember, these numbers are every 45 degrees with a 22.5 offset, to detect boundaries.
|
||||
String dir;
|
||||
if (r < 22.5)
|
||||
dir = "n";
|
||||
else if (r < 67.5)
|
||||
dir = "ne";
|
||||
else if (r < 112.5)
|
||||
dir = "e";
|
||||
else if (r < 157.5)
|
||||
dir = "se";
|
||||
else if (r < 202.5)
|
||||
dir = "s";
|
||||
else if (r < 247.5)
|
||||
dir = "sw";
|
||||
else if (r < 292.5)
|
||||
dir = "w";
|
||||
else if (r < 337.5)
|
||||
dir = "nw";
|
||||
else
|
||||
dir = "n";
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public float getYaw(String orientation) {
|
||||
if (orientation == null) {
|
||||
return 0;
|
||||
}
|
||||
if (ORIENTATION_INTS.containsKey(orientation.toLowerCase())) {
|
||||
return ORIENTATION_INTS.get(orientation.toLowerCase());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public float getSpeed(Vector v) {
|
||||
return (float) Math.sqrt(v.getX() * v.getX() + v.getZ() * v.getZ());
|
||||
}
|
||||
|
||||
// X, Y, Z
|
||||
// -W/+E,0, -N/+S
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Vector getTranslatedVector(Vector v, String direction) {
|
||||
if (direction == null) {
|
||||
return v;
|
||||
}
|
||||
float speed = getSpeed(v);
|
||||
float halfSpeed = (float) (speed / 2.0);
|
||||
// TODO: Mathmatacize this:
|
||||
if (direction.equalsIgnoreCase("n")) {
|
||||
return new Vector(0, 0, -1 * speed);
|
||||
} else if (direction.equalsIgnoreCase("ne")) {
|
||||
return new Vector(halfSpeed, 0, -1 * halfSpeed);
|
||||
} else if (direction.equalsIgnoreCase("e")) {
|
||||
return new Vector(speed, 0, 0);
|
||||
} else if (direction.equalsIgnoreCase("se")) {
|
||||
return new Vector(halfSpeed, 0, halfSpeed);
|
||||
} else if (direction.equalsIgnoreCase("s")) {
|
||||
return new Vector(0, 0, speed);
|
||||
} else if (direction.equalsIgnoreCase("sw")) {
|
||||
return new Vector(-1 * halfSpeed, 0, halfSpeed);
|
||||
} else if (direction.equalsIgnoreCase("w")) {
|
||||
return new Vector(-1 * speed, 0, 0);
|
||||
} else if (direction.equalsIgnoreCase("nw")) {
|
||||
return new Vector(-1 * halfSpeed, 0, -1 * halfSpeed);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getNextBlock(Vehicle v) {
|
||||
Vector vector = v.getVelocity();
|
||||
Location location = v.getLocation();
|
||||
int x = vector.getX() < 0 ? vector.getX() == 0 ? 0 : -1 : 1;
|
||||
int z = vector.getZ() < 0 ? vector.getZ() == 0 ? 0 : -1 : 1;
|
||||
return location.add(x, 0, z);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.destination.InvalidDestination;
|
||||
import com.onarandombox.MultiverseCore.enums.TeleportResult;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The default-implementation of {@link SafeTTeleporter}.
|
||||
*/
|
||||
public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
|
||||
public SimpleSafeTTeleporter(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private static final int DEFAULT_TOLERANCE = 6;
|
||||
private static final int DEFAULT_RADIUS = 9;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getSafeLocation(Location l) {
|
||||
return this.getSafeLocation(l, DEFAULT_TOLERANCE, DEFAULT_RADIUS);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getSafeLocation(Location l, int tolerance, int radius) {
|
||||
// Check around the player first in a configurable radius:
|
||||
// TODO: Make this configurable
|
||||
Location safe = checkAboveAndBelowLocation(l, tolerance, radius);
|
||||
if (safe != null) {
|
||||
safe.setX(safe.getBlockX() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
safe.setZ(safe.getBlockZ() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.plugin.log(Level.FINE, "Hey! I found one: " + plugin.getLocationManipulation().strCoordsRaw(safe));
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Uh oh! No safe place found!");
|
||||
}
|
||||
return safe;
|
||||
}
|
||||
|
||||
private Location checkAboveAndBelowLocation(Location l, int tolerance, int radius) {
|
||||
// Tolerance must be an even number:
|
||||
if (tolerance % 2 != 0) {
|
||||
tolerance += 1;
|
||||
}
|
||||
// We want half of it, so we can go up and down
|
||||
tolerance /= 2;
|
||||
this.plugin.log(Level.FINER, "Given Location of: " + plugin.getLocationManipulation().strCoordsRaw(l));
|
||||
this.plugin.log(Level.FINER, "Checking +-" + tolerance + " with a radius of " + radius);
|
||||
|
||||
// For now this will just do a straight up block.
|
||||
Location locToCheck = l.clone();
|
||||
// Check the main level
|
||||
Location safe = this.checkAroundLocation(locToCheck, radius);
|
||||
if (safe != null) {
|
||||
return safe;
|
||||
}
|
||||
// We've already checked zero right above this.
|
||||
int currentLevel = 1;
|
||||
while (currentLevel <= tolerance) {
|
||||
// Check above
|
||||
locToCheck = l.clone();
|
||||
locToCheck.add(0, currentLevel, 0);
|
||||
safe = this.checkAroundLocation(locToCheck, radius);
|
||||
if (safe != null) {
|
||||
return safe;
|
||||
}
|
||||
|
||||
// Check below
|
||||
locToCheck = l.clone();
|
||||
locToCheck.subtract(0, currentLevel, 0);
|
||||
safe = this.checkAroundLocation(locToCheck, radius);
|
||||
if (safe != null) {
|
||||
return safe;
|
||||
}
|
||||
currentLevel++;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* For my crappy algorithm, radius MUST be odd.
|
||||
*/
|
||||
private Location checkAroundLocation(Location l, int diameter) {
|
||||
if (diameter % 2 == 0) {
|
||||
diameter += 1;
|
||||
}
|
||||
Location checkLoc = l.clone();
|
||||
|
||||
// Start at 3, the min diameter around a block
|
||||
int loopcounter = 3;
|
||||
while (loopcounter <= diameter) {
|
||||
boolean foundSafeArea = checkAroundSpecificDiameter(checkLoc, loopcounter);
|
||||
// If a safe area was found:
|
||||
if (foundSafeArea) {
|
||||
// Return the checkLoc, it is the safe location.
|
||||
return checkLoc;
|
||||
}
|
||||
// Otherwise, let's reset our location
|
||||
checkLoc = l.clone();
|
||||
// And increment the radius
|
||||
loopcounter += 2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkAroundSpecificDiameter(Location checkLoc, int circle) {
|
||||
// Adjust the circle to get how many blocks to step out.
|
||||
// A radius of 3 makes the block step 1
|
||||
// A radius of 5 makes the block step 2
|
||||
// A radius of 7 makes the block step 3
|
||||
// ...
|
||||
int adjustedCircle = ((circle - 1) / 2);
|
||||
checkLoc.add(adjustedCircle, 0, 0);
|
||||
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
// Now we go to the right that adjustedCircle many
|
||||
for (int i = 0; i < adjustedCircle; i++) {
|
||||
checkLoc.add(0, 0, 1);
|
||||
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then down adjustedCircle *2
|
||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||
checkLoc.add(-1, 0, 0);
|
||||
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then left adjustedCircle *2
|
||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||
checkLoc.add(0, 0, -1);
|
||||
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then up Then left adjustedCircle *2
|
||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||
checkLoc.add(1, 0, 0);
|
||||
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Then finish up by doing adjustedCircle - 1
|
||||
for (int i = 0; i < adjustedCircle - 1; i++) {
|
||||
checkLoc.add(0, 0, 1);
|
||||
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d) {
|
||||
if (d instanceof InvalidDestination) {
|
||||
this.plugin.log(Level.FINER, "Entity tried to teleport to an invalid destination");
|
||||
return TeleportResult.FAIL_INVALID;
|
||||
}
|
||||
Player teleporteePlayer = null;
|
||||
if (teleportee instanceof Player) {
|
||||
teleporteePlayer = ((Player) teleportee);
|
||||
} else if (teleportee.getPassenger() instanceof Player) {
|
||||
teleporteePlayer = ((Player) teleportee.getPassenger());
|
||||
}
|
||||
|
||||
if (teleporteePlayer == null) {
|
||||
return TeleportResult.FAIL_INVALID;
|
||||
}
|
||||
MultiverseCore.addPlayerToTeleportQueue(teleporter.getName(), teleporteePlayer.getName());
|
||||
|
||||
Location safeLoc = d.getLocation(teleportee);
|
||||
if (d.useSafeTeleporter()) {
|
||||
safeLoc = this.getSafeLocation(teleportee, d);
|
||||
}
|
||||
|
||||
if (safeLoc != null) {
|
||||
if (teleportee.teleport(safeLoc)) {
|
||||
if (!d.getVelocity().equals(new Vector(0, 0, 0))) {
|
||||
teleportee.setVelocity(d.getVelocity());
|
||||
}
|
||||
return TeleportResult.SUCCESS;
|
||||
}
|
||||
return TeleportResult.FAIL_OTHER;
|
||||
}
|
||||
return TeleportResult.FAIL_UNSAFE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, Location location, boolean safely) {
|
||||
if (safely) {
|
||||
location = this.getSafeLocation(location);
|
||||
}
|
||||
|
||||
if (location != null) {
|
||||
if (teleportee.teleport(location)) {
|
||||
return TeleportResult.SUCCESS;
|
||||
}
|
||||
return TeleportResult.FAIL_OTHER;
|
||||
}
|
||||
return TeleportResult.FAIL_UNSAFE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location getSafeLocation(Entity e, MVDestination d) {
|
||||
Location l = d.getLocation(e);
|
||||
if (plugin.getBlockSafety().playerCanSpawnHereSafely(l)) {
|
||||
plugin.log(Level.FINE, "The first location you gave me was safe.");
|
||||
return l;
|
||||
}
|
||||
if (e instanceof Minecart) {
|
||||
Minecart m = (Minecart) e;
|
||||
if (!plugin.getBlockSafety().canSpawnCartSafely(m)) {
|
||||
return null;
|
||||
}
|
||||
} else if (e instanceof Vehicle) {
|
||||
Vehicle v = (Vehicle) e;
|
||||
if (!plugin.getBlockSafety().canSpawnVehicleSafely(v)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Location safeLocation = this.getSafeLocation(l);
|
||||
if (safeLocation != null) {
|
||||
// Add offset to account for a vehicle on dry land!
|
||||
if (e instanceof Minecart && !plugin.getBlockSafety().isEntitiyOnTrack(safeLocation)) {
|
||||
safeLocation.setY(safeLocation.getBlockY() + .5);
|
||||
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
|
||||
}
|
||||
this.plugin.log(Level.FINE, "Had to look for a bit, but I found a safe place for ya!");
|
||||
return safeLocation;
|
||||
}
|
||||
if (e instanceof Player) {
|
||||
Player p = (Player) e;
|
||||
this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false);
|
||||
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||
} else if (e.getPassenger() instanceof Player) {
|
||||
Player p = (Player) e.getPassenger();
|
||||
this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false);
|
||||
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||
}
|
||||
this.plugin.log(Level.FINE, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Location findPortalBlockNextTo(Location l) {
|
||||
Block b = l.getWorld().getBlockAt(l);
|
||||
Location foundLocation = null;
|
||||
if (b.getType() == Material.PORTAL) {
|
||||
return l;
|
||||
}
|
||||
if (b.getRelative(BlockFace.NORTH).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.NORTH).getLocation(), foundLocation);
|
||||
}
|
||||
if (b.getRelative(BlockFace.SOUTH).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.SOUTH).getLocation(), foundLocation);
|
||||
}
|
||||
if (b.getRelative(BlockFace.EAST).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.EAST).getLocation(), foundLocation);
|
||||
}
|
||||
if (b.getRelative(BlockFace.WEST).getType() == Material.PORTAL) {
|
||||
foundLocation = getCloserBlock(l, b.getRelative(BlockFace.WEST).getLocation(), foundLocation);
|
||||
}
|
||||
return foundLocation;
|
||||
}
|
||||
|
||||
private static Location getCloserBlock(Location source, Location blockA, Location blockB) {
|
||||
// If B wasn't given, return a.
|
||||
if (blockB == null) {
|
||||
return blockA;
|
||||
}
|
||||
// Center our calculations
|
||||
blockA.add(.5, 0, .5);
|
||||
blockB.add(.5, 0, .5);
|
||||
|
||||
// Retrieve the distance to the normalized blocks
|
||||
double testA = source.distance(blockA);
|
||||
double testB = source.distance(blockB);
|
||||
|
||||
// Compare and return
|
||||
if (testA <= testB) {
|
||||
return blockA;
|
||||
}
|
||||
return blockB;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Squid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Utility class that removes animals from worlds that don't belong there.
|
||||
*/
|
||||
public class SimpleWorldPurger implements WorldPurger {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
|
||||
public SimpleWorldPurger(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void purgeWorlds(List<MultiverseWorld> worlds) {
|
||||
if (worlds == null || worlds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (MultiverseWorld world : worlds) {
|
||||
this.purgeWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void purgeWorld(MultiverseWorld world) {
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList<String> allMobs = new ArrayList<String>(world.getAnimalList());
|
||||
allMobs.addAll(world.getMonsterList());
|
||||
purgeWorld(world, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill,
|
||||
boolean negateAnimals, boolean negateMonsters, CommandSender sender) {
|
||||
if (mvworld == null) {
|
||||
return;
|
||||
}
|
||||
World world = mvworld.getCBWorld();
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
int entitiesKilled = 0;
|
||||
boolean specifiedAll = thingsToKill.contains("ALL");
|
||||
boolean specifiedAnimals = thingsToKill.contains("ANIMALS") || specifiedAll;
|
||||
boolean specifiedMonsters = thingsToKill.contains("MONSTERS") || specifiedAll;
|
||||
for (Entity e : world.getEntities()) {
|
||||
boolean negate = false;
|
||||
boolean specified = false;
|
||||
if (e instanceof Squid || e instanceof Animals) {
|
||||
// it's an animal
|
||||
if (specifiedAnimals && !negateAnimals) {
|
||||
this.plugin.log(Level.FINEST, "Removing an entity because I was told to remove all animals: " + e);
|
||||
e.remove();
|
||||
entitiesKilled++;
|
||||
continue;
|
||||
}
|
||||
if (specifiedAnimals)
|
||||
specified = true;
|
||||
negate = negateAnimals;
|
||||
} else if (e instanceof Monster || e instanceof Ghast || e instanceof Slime) {
|
||||
// it's a monster
|
||||
if (specifiedMonsters && !negateMonsters) {
|
||||
this.plugin.log(Level.FINEST, "Removing an entity because I was told to remove all monsters: " + e);
|
||||
e.remove();
|
||||
entitiesKilled++;
|
||||
continue;
|
||||
}
|
||||
if (specifiedMonsters)
|
||||
specified = true;
|
||||
negate = negateMonsters;
|
||||
}
|
||||
for (String s : thingsToKill) {
|
||||
EntityType type = EntityType.fromName(s);
|
||||
if (type != null && type.equals(e.getType())) {
|
||||
specified = true;
|
||||
if (!negate) {
|
||||
this.plugin.log(Level.FINEST, "Removing an entity because it WAS specified and we are NOT negating: " + e);
|
||||
e.remove();
|
||||
entitiesKilled++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!specified && negate) {
|
||||
this.plugin.log(Level.FINEST, "Removing an entity because it was NOT specified and we ARE negating: " + e);
|
||||
e.remove();
|
||||
entitiesKilled++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (sender != null) {
|
||||
sender.sendMessage(entitiesKilled + " entities purged from the world '" + world.getName() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) {
|
||||
purgeWorld(mvworld, thingsToKill, negateAnimals, negateMonsters, null);
|
||||
}
|
||||
}
|
||||
@@ -4,14 +4,14 @@
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
|
||||
/**
|
||||
* A helper-class holding the {@link SpoutManager}.
|
||||
*/
|
||||
* /
|
||||
public class SpoutInterface {
|
||||
private SpoutManager spoutManager;
|
||||
|
||||
@@ -22,8 +22,9 @@ public class SpoutInterface {
|
||||
/**
|
||||
* Gets the {@link SpoutManager}.
|
||||
* @return The {@link SpoutManager}.
|
||||
*/
|
||||
* /
|
||||
public SpoutManager getManager() {
|
||||
return this.spoutManager;
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -8,6 +8,7 @@
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
@@ -54,6 +55,7 @@ public class UpdateChecker {
|
||||
}
|
||||
|
||||
public void checkUpdate() {
|
||||
BufferedReader rd = null;
|
||||
try {
|
||||
URL url = new URL("http://bukkit.onarandombox.com/multiverse/version.php?n=" + URLEncoder.encode(this.name, "UTF-8") + "&v=" + this.cversion);
|
||||
URLConnection conn = url.openConnection();
|
||||
@@ -65,7 +67,7 @@ public class UpdateChecker {
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
String version = null;
|
||||
|
||||
@@ -76,7 +78,6 @@ public class UpdateChecker {
|
||||
}
|
||||
|
||||
if (version == null) {
|
||||
rd.close();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -92,6 +93,12 @@ public class UpdateChecker {
|
||||
rd.close();
|
||||
} catch (Exception e) {
|
||||
// No need to alert the user of any error here... it's not important.
|
||||
} finally {
|
||||
if (rd != null) {
|
||||
try {
|
||||
rd.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,14 @@ import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -34,6 +36,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
@@ -41,18 +44,18 @@ import java.util.logging.Level;
|
||||
*/
|
||||
public class WorldManager implements MVWorldManager {
|
||||
private MultiverseCore plugin;
|
||||
private PurgeWorlds worldPurger;
|
||||
private WorldPurger worldPurger;
|
||||
private Map<String, MVWorld> worldsFromTheConfig;
|
||||
private Map<String, MultiverseWorld> worlds;
|
||||
private List<String> unloadedWorlds;
|
||||
private FileConfiguration configWorlds = null;
|
||||
private Map<String, String> defaultGens;
|
||||
private String firstSpawn;
|
||||
|
||||
public WorldManager(MultiverseCore core) {
|
||||
this.plugin = core;
|
||||
this.worldsFromTheConfig = new HashMap<String, MVWorld>();
|
||||
this.worlds = new HashMap<String, MultiverseWorld>();
|
||||
this.unloadedWorlds = new ArrayList<String>();
|
||||
this.worldPurger = new PurgeWorlds(this.plugin);
|
||||
this.worldPurger = new SimpleWorldPurger(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +70,7 @@ public class WorldManager implements MVWorldManager {
|
||||
return s.equalsIgnoreCase("bukkit.yml");
|
||||
}
|
||||
});
|
||||
if (files.length == 1) {
|
||||
if (files != null && files.length == 1) {
|
||||
FileConfiguration bukkitConfig = YamlConfiguration.loadConfiguration(files[0]);
|
||||
if (bukkitConfig.isConfigurationSection("worlds")) {
|
||||
Set<String> keys = bukkitConfig.getConfigurationSection("worlds").getKeys(false);
|
||||
@@ -75,6 +78,8 @@ public class WorldManager implements MVWorldManager {
|
||||
defaultGens.put(key, bukkitConfig.getString("worlds." + key + ".generator", ""));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.plugin.log(Level.WARNING, "Could not read 'bukkit.yml'. Any Default worldgenerators will not be loaded!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,16 +87,17 @@ public class WorldManager implements MVWorldManager {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator) {
|
||||
return this.addWorld(name, env, seedString, type, generator, true);
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator) {
|
||||
return this.addWorld(name, env, seedString, type, generateStructures, generator, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, String generator, boolean useSpawnAdjust) {
|
||||
plugin.log(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + type.toString() + ", " + generator);
|
||||
public boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator, boolean useSpawnAdjust) {
|
||||
Long seed = null;
|
||||
WorldCreator c = new WorldCreator(name);
|
||||
if (seedString != null && seedString.length() > 0) {
|
||||
@@ -108,9 +114,17 @@ public class WorldManager implements MVWorldManager {
|
||||
c.generator(generator);
|
||||
}
|
||||
c.environment(env);
|
||||
c.type(type);
|
||||
if (type != null) {
|
||||
c.type(type);
|
||||
}
|
||||
if (generateStructures != null) {
|
||||
c.generateStructures(generateStructures);
|
||||
}
|
||||
|
||||
// Important: doLoad() needs the MVWorld-object in worldsFromTheConfig
|
||||
if (!worldsFromTheConfig.containsKey(name))
|
||||
worldsFromTheConfig.put(name, new MVWorld(useSpawnAdjust));
|
||||
|
||||
World world;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Loading World & Settings - '").append(name).append("'");
|
||||
builder.append(" - Env: ").append(env);
|
||||
@@ -123,40 +137,16 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
this.plugin.log(Level.INFO, builder.toString());
|
||||
|
||||
try {
|
||||
world = c.createWorld();
|
||||
} catch (Exception e) {
|
||||
this.plugin.log(Level.SEVERE, "The world '" + name + "' could NOT be loaded because it contains errors!");
|
||||
this.plugin.log(Level.SEVERE, "Try using Chukster to repair your world! '" + name + "'");
|
||||
this.plugin.log(Level.SEVERE, "http://forums.bukkit.org/threads/admin-chunkster.8186/");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world == null) {
|
||||
if (!doLoad(c)) {
|
||||
this.plugin.log(Level.SEVERE, "Failed to Create/Load the world '" + name + "'");
|
||||
return false;
|
||||
}
|
||||
|
||||
MultiverseWorld mvworld = new MVWorld(world, this.configWorlds, this.plugin,
|
||||
this.plugin.getServer().getWorld(name).getSeed(), generator, useSpawnAdjust);
|
||||
this.worldPurger.purgeWorld(null, mvworld);
|
||||
this.worlds.put(name, mvworld);
|
||||
if (this.unloadedWorlds.contains(name)) {
|
||||
this.unloadedWorlds.remove(name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// set generator (special case because we can't read it from org.bukkit.World)
|
||||
this.worlds.get(name).setGenerator(generator);
|
||||
|
||||
/**
|
||||
* Verifies that a given Plugin generator string exists.
|
||||
*
|
||||
* @param generator The name of the generator plugin. This should be something like CleanRoomGenerator.
|
||||
* @return True if the plugin exists and is enabled, false if not.
|
||||
*/
|
||||
// TODO maybe remove this since it's unused?
|
||||
private boolean pluginExists(String generator) {
|
||||
Plugin myPlugin = this.plugin.getServer().getPluginManager().getPlugin(generator);
|
||||
return myPlugin != null && myPlugin.isEnabled();
|
||||
this.saveWorldsConfig();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,15 +174,11 @@ public class WorldManager implements MVWorldManager {
|
||||
if (!unloadWorld(name)) {
|
||||
return false;
|
||||
}
|
||||
if (this.configWorlds.get("worlds." + name) != null) {
|
||||
if (this.worldsFromTheConfig.containsKey(name)) {
|
||||
this.worldsFromTheConfig.remove(name);
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was removed from config.yml");
|
||||
this.configWorlds.set("worlds." + name, null);
|
||||
|
||||
this.saveWorldsConfig();
|
||||
// Remove it from the list of unloaded worlds.
|
||||
if (this.unloadedWorlds.contains(name)) {
|
||||
this.unloadedWorlds.remove(name);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was already removed from config.yml");
|
||||
@@ -205,7 +191,7 @@ public class WorldManager implements MVWorldManager {
|
||||
*/
|
||||
@Override
|
||||
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();
|
||||
} else {
|
||||
this.firstSpawn = world;
|
||||
@@ -240,15 +226,17 @@ public class WorldManager implements MVWorldManager {
|
||||
if (this.unloadWorldFromBukkit(name, true)) {
|
||||
this.worlds.remove(name);
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was unloaded from memory.");
|
||||
this.unloadedWorlds.add(name);
|
||||
|
||||
this.worldsFromTheConfig.get(name).tearDown();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
this.plugin.log(Level.WARNING, "World '" + name + "' could not be unloaded. Is it a default world?");
|
||||
}
|
||||
} else if (this.plugin.getServer().getWorld(name) != null) {
|
||||
this.plugin.log(Level.WARNING, "Hmm Multiverse does not know about this world but it's loaded in memory.");
|
||||
this.plugin.log(Level.WARNING, "To unload it using multiverse, use:");
|
||||
this.plugin.log(Level.WARNING, "/mv import " + name + " " + this.plugin.getServer().getWorld(name).getEnvironment().toString());
|
||||
this.plugin.log(Level.WARNING, "To let Multiverse know about it, use:");
|
||||
this.plugin.log(Level.WARNING, String.format("/mv import %s %s", name, this.plugin.getServer().getWorld(name).getEnvironment().toString()));
|
||||
} else {
|
||||
this.plugin.log(Level.INFO, "Multiverse does not know about " + name + " and it's not loaded by Bukkit.");
|
||||
}
|
||||
@@ -262,35 +250,58 @@ public class WorldManager implements MVWorldManager {
|
||||
public boolean loadWorld(String name) {
|
||||
// Check if the World is already loaded
|
||||
if (this.worlds.containsKey(name)) {
|
||||
// Ensure it's not unloaded, since it IS loaded.
|
||||
if (this.unloadedWorlds.contains(name)) {
|
||||
this.unloadedWorlds.remove(name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Grab all the Worlds from the Config.
|
||||
Set<String> worldKeys = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
|
||||
|
||||
// Check that the list is not null and that the config contains the world
|
||||
if ((worldKeys != null) && (worldKeys.contains(name))) {
|
||||
// Grab the initial values from the config file.
|
||||
String environment = this.configWorlds.getString("worlds." + name + ".environment", "NORMAL"); // Grab the Environment as a String.
|
||||
String type = this.configWorlds.getString("worlds." + name + ".type", "NORMAL");
|
||||
String seedString = this.configWorlds.getString("worlds." + name + ".seed", "");
|
||||
String generatorString = this.configWorlds.getString("worlds." + name + ".generator");
|
||||
|
||||
addWorld(name, EnvironmentCommand.getEnvFromString(environment), seedString,
|
||||
EnvironmentCommand.getWorldTypeFromString(type), generatorString);
|
||||
if (this.unloadedWorlds.contains(name)) {
|
||||
this.unloadedWorlds.remove(name);
|
||||
}
|
||||
return true;
|
||||
// Check that the world is in the config
|
||||
if (worldsFromTheConfig.containsKey(name)) {
|
||||
return doLoad(name);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void brokenWorld(String name) {
|
||||
this.plugin.log(Level.SEVERE, "The world '" + name + "' could NOT be loaded because it contains errors!");
|
||||
this.plugin.log(Level.SEVERE, "Try using Chukster to repair your world! '" + name + "'");
|
||||
this.plugin.log(Level.SEVERE, "http://forums.bukkit.org/threads/admin-chunkster.8186/");
|
||||
}
|
||||
|
||||
private boolean doLoad(String name) {
|
||||
if (!worldsFromTheConfig.containsKey(name))
|
||||
throw new IllegalArgumentException("That world doesn't exist!");
|
||||
|
||||
MVWorld world = worldsFromTheConfig.get(name);
|
||||
WorldCreator creator = WorldCreator.name(name);
|
||||
|
||||
creator.environment(world.getEnvironment()).seed(world.getSeed());
|
||||
if ((world.getGenerator() != null) && (!world.getGenerator().equals("null")))
|
||||
creator.generator(world.getGenerator());
|
||||
|
||||
return doLoad(creator);
|
||||
}
|
||||
|
||||
private boolean doLoad(WorldCreator creator) {
|
||||
String worldName = creator.name();
|
||||
if (!worldsFromTheConfig.containsKey(worldName))
|
||||
throw new IllegalArgumentException("That world doesn't exist!");
|
||||
if (worlds.containsKey(worldName))
|
||||
throw new IllegalArgumentException("That world is already loaded!");
|
||||
MVWorld mvworld = worldsFromTheConfig.get(worldName);
|
||||
World cbworld;
|
||||
try {
|
||||
cbworld = creator.createWorld();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
brokenWorld(worldName);
|
||||
return false;
|
||||
}
|
||||
mvworld.init(cbworld, plugin);
|
||||
this.worldPurger.purgeWorld(mvworld);
|
||||
this.worlds.put(worldName, mvworld);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -371,7 +382,7 @@ public class WorldManager implements MVWorldManager {
|
||||
if (w != null) {
|
||||
World safeWorld = this.plugin.getServer().getWorlds().get(0);
|
||||
List<Player> ps = w.getPlayers();
|
||||
SafeTTeleporter teleporter = this.plugin.getTeleporter();
|
||||
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter();
|
||||
for (Player p : ps) {
|
||||
// We're removing players forcefully from a world, they'd BETTER spawn safely.
|
||||
teleporter.safelyTeleport(null, p, safeWorld.getSpawnLocation(), true);
|
||||
@@ -462,28 +473,22 @@ public class WorldManager implements MVWorldManager {
|
||||
public void loadDefaultWorlds() {
|
||||
this.ensureConfigIsPrepared();
|
||||
List<World> myWorlds = this.plugin.getServer().getWorlds();
|
||||
Set<String> worldStrings = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
|
||||
for (World w : myWorlds) {
|
||||
String name = w.getName();
|
||||
if (!worldStrings.contains(name)) {
|
||||
if (!worldsFromTheConfig.containsKey(name)) {
|
||||
String generator = null;
|
||||
if (this.defaultGens.containsKey(name)) {
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", w.getWorldType(), this.defaultGens.get(name));
|
||||
} else {
|
||||
this.addWorld(name, w.getEnvironment(), w.getSeed() + "", w.getWorldType(), null);
|
||||
generator = this.defaultGens.get(name);
|
||||
}
|
||||
|
||||
this.addWorld(name, w.getEnvironment(), String.valueOf(w.getSeed()), w.getWorldType(), w.canGenerateStructures(), generator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureConfigIsPrepared() {
|
||||
this.configWorlds.options().pathSeparator(SEPARATOR);
|
||||
if (this.configWorlds.getConfigurationSection("worlds") == null) {
|
||||
this.configWorlds.createSection("worlds");
|
||||
try {
|
||||
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||
} catch (IOException e) {
|
||||
this.plugin.log(Level.SEVERE, "Failed to save worlds.yml. Please check your file permissions.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,13 +501,10 @@ public class WorldManager implements MVWorldManager {
|
||||
int count = 0;
|
||||
this.ensureConfigIsPrepared();
|
||||
this.ensureSecondNamespaceIsPrepared();
|
||||
// Grab all the Worlds from the Config.
|
||||
Set<String> worldKeys = this.configWorlds.getConfigurationSection("worlds").getKeys(false);
|
||||
|
||||
// Force the worlds to be loaded, ie don't just load new worlds.
|
||||
if (forceLoad) {
|
||||
// Remove all world permissions.
|
||||
|
||||
Permission allAccess = this.plugin.getServer().getPluginManager().getPermission("multiverse.access.*");
|
||||
Permission allExempt = this.plugin.getServer().getPluginManager().getPermission("multiverse.exempt.*");
|
||||
for (MultiverseWorld w : this.worlds.values()) {
|
||||
@@ -516,7 +518,7 @@ public class WorldManager implements MVWorldManager {
|
||||
this.plugin.getServer().getPluginManager().removePermission(w.getAccessPermission().getName());
|
||||
this.plugin.getServer().getPluginManager().removePermission(w.getExemptPermission().getName());
|
||||
// Special namespace for gamemodes
|
||||
this.plugin.getServer().getPluginManager().removePermission("mv.gamemode.bypass." + w.getName());
|
||||
this.plugin.getServer().getPluginManager().removePermission("mv.bypass.gamemode." + w.getName());
|
||||
}
|
||||
// Recalc the all permission
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allAccess);
|
||||
@@ -524,45 +526,19 @@ public class WorldManager implements MVWorldManager {
|
||||
this.worlds.clear();
|
||||
}
|
||||
|
||||
// Check that the list is not null.
|
||||
if (worldKeys != null) {
|
||||
for (String worldKey : worldKeys) {
|
||||
// Check if the World is already loaded within the Plugin.
|
||||
if (this.worlds.containsKey(worldKey)) {
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<String, MVWorld> entry : worldsFromTheConfig.entrySet()) {
|
||||
if (worlds.containsKey(entry.getKey()))
|
||||
continue;
|
||||
if (!entry.getValue().getAutoLoad())
|
||||
continue;
|
||||
|
||||
// If autoload was set to false, don't load this one.
|
||||
if (!this.configWorlds.getBoolean("worlds." + worldKey + ".autoload", true)) {
|
||||
if (!this.unloadedWorlds.contains(worldKey)) {
|
||||
this.unloadedWorlds.add(worldKey);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Grab the initial values from the config file.
|
||||
String environment = this.configWorlds.getString("worlds." + worldKey + ".environment", "NORMAL");
|
||||
String type = this.configWorlds.getString("worlds." + worldKey + ".type", "NORMAL");
|
||||
String seedString = this.configWorlds.getString("worlds." + worldKey + ".seed", null);
|
||||
if (seedString == null) {
|
||||
seedString = this.configWorlds.getLong("worlds." + worldKey + ".seed") + "";
|
||||
}
|
||||
|
||||
String generatorString = this.configWorlds.getString("worlds." + worldKey + ".generator");
|
||||
if (environment.equalsIgnoreCase("skylands")) {
|
||||
this.plugin.log(Level.WARNING, "Found SKYLANDS world. Not importing automatically, as it won't work atm :(");
|
||||
continue;
|
||||
}
|
||||
// TODO: UNCOMMENT BEFORE RELEASE
|
||||
addWorld(worldKey, EnvironmentCommand.getEnvFromString(environment), seedString,
|
||||
EnvironmentCommand.getWorldTypeFromString(type), generatorString);
|
||||
|
||||
// Increment the world count
|
||||
if (doLoad(entry.getKey()))
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// Simple Output to the Console to show how many Worlds were loaded.
|
||||
this.plugin.log(Level.INFO, count + " - World(s) loaded.");
|
||||
this.saveWorldsConfig();
|
||||
}
|
||||
|
||||
private void ensureSecondNamespaceIsPrepared() {
|
||||
@@ -575,21 +551,70 @@ public class WorldManager implements MVWorldManager {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated This is deprecated!
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public PurgeWorlds getWorldPurger() {
|
||||
return this.worldPurger;
|
||||
return new PurgeWorlds(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the config from a file.
|
||||
*
|
||||
* @param file The file to load.
|
||||
* @return A loaded configuration.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public WorldPurger getTheWorldPurger() {
|
||||
return worldPurger;
|
||||
}
|
||||
|
||||
private static final char SEPARATOR = '\uF8FF';
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public FileConfiguration loadWorldConfig(File file) {
|
||||
this.configWorlds = YamlConfiguration.loadConfiguration(file);
|
||||
this.ensureConfigIsPrepared();
|
||||
try {
|
||||
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
// load world-objects
|
||||
Stack<String> worldKeys = new Stack<String>();
|
||||
worldKeys.addAll(this.configWorlds.getConfigurationSection("worlds").getKeys(false));
|
||||
Map<String, MVWorld> newWorldsFromTheConfig = new HashMap<String, MVWorld>();
|
||||
while (!worldKeys.isEmpty()) {
|
||||
String key = worldKeys.pop();
|
||||
String path = "worlds" + SEPARATOR + key;
|
||||
Object obj = this.configWorlds.get(path);
|
||||
if ((obj != null) && (obj instanceof MVWorld)) {
|
||||
String worldName = key.replaceAll(String.valueOf(SEPARATOR), ".");
|
||||
if (this.worldsFromTheConfig.containsKey(worldName)) {
|
||||
// Object-Recycling :D
|
||||
MVWorld oldMVWorld = (MVWorld) this.worlds.get(worldName);
|
||||
oldMVWorld.copyValues((MVWorld) obj);
|
||||
newWorldsFromTheConfig.put(worldName, oldMVWorld);
|
||||
} else {
|
||||
// we have to use a new one
|
||||
World cbworld = this.plugin.getServer().getWorld(worldName);
|
||||
MVWorld mvworld = (MVWorld) obj;
|
||||
if (cbworld != null)
|
||||
mvworld.init(cbworld, this.plugin);
|
||||
newWorldsFromTheConfig.put(worldName, mvworld);
|
||||
}
|
||||
} else if (this.configWorlds.isConfigurationSection(path)) {
|
||||
ConfigurationSection section = this.configWorlds.getConfigurationSection(path);
|
||||
Set<String> subkeys = section.getKeys(false);
|
||||
for (String subkey : subkeys) {
|
||||
worldKeys.push(key + SEPARATOR + subkey);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.worldsFromTheConfig = newWorldsFromTheConfig;
|
||||
this.worlds.keySet().retainAll(this.worldsFromTheConfig.keySet());
|
||||
return this.configWorlds;
|
||||
}
|
||||
|
||||
@@ -599,6 +624,11 @@ public class WorldManager implements MVWorldManager {
|
||||
@Override
|
||||
public boolean saveWorldsConfig() {
|
||||
try {
|
||||
this.configWorlds.options().pathSeparator(SEPARATOR);
|
||||
this.configWorlds.set("worlds", null);
|
||||
for (Map.Entry<String, ? extends MultiverseWorld> entry : worldsFromTheConfig.entrySet()) {
|
||||
this.configWorlds.set("worlds" + SEPARATOR + entry.getKey(), entry.getValue());
|
||||
}
|
||||
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
@@ -620,7 +650,9 @@ public class WorldManager implements MVWorldManager {
|
||||
*/
|
||||
@Override
|
||||
public List<String> getUnloadedWorlds() {
|
||||
return this.unloadedWorlds;
|
||||
List<String> allNames = new ArrayList<String>(this.worldsFromTheConfig.keySet());
|
||||
allNames.removeAll(worlds.keySet());
|
||||
return allNames;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* An {@link URLShortener} using {@code bit.ly}.
|
||||
*/
|
||||
public class BitlyURLShortener extends HttpAPIClient implements URLShortener {
|
||||
private static final String GENERIC_BITLY_REQUEST_FORMAT = "https://api-ssl.bitly.com/v3/shorten?format=txt&apiKey=%s&login=%s&longUrl=%s";
|
||||
|
||||
// I think it's no problem that these are public
|
||||
private static final String USERNAME = "multiverse2";
|
||||
private static final String API_KEY = "R_9dbff4862a3bc0c4218a7d78cc10d0e0";
|
||||
|
||||
public BitlyURLShortener() {
|
||||
super(String.format(GENERIC_BITLY_REQUEST_FORMAT, API_KEY, USERNAME, "%s"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String shorten(String longUrl) {
|
||||
try {
|
||||
String result = this.exec(longUrl);
|
||||
if (!result.startsWith("http://j.mp/")) // ... then it's failed :/
|
||||
throw new IOException(result);
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return longUrl; // sorry ...
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* HTTP API-client.
|
||||
*/
|
||||
public abstract class HttpAPIClient {
|
||||
/**
|
||||
* The URL for this API-request.
|
||||
*/
|
||||
protected final String urlFormat;
|
||||
|
||||
public HttpAPIClient(String urlFormat) {
|
||||
this.urlFormat = urlFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes this API-Request.
|
||||
* @param args Format-args.
|
||||
* @return The result (as text).
|
||||
* @throws IOException When the I/O-operation failed.
|
||||
*/
|
||||
protected final String exec(Object... args) throws IOException {
|
||||
|
||||
URLConnection conn = new URL(String.format(this.urlFormat, args)).openConnection();
|
||||
conn.connect();
|
||||
StringBuilder ret = new StringBuilder();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
while (!reader.ready()); // wait until reader is ready, may not be necessary, SUPPRESS CHECKSTYLE: EmptyStatement
|
||||
|
||||
while (reader.ready()) {
|
||||
ret.append(reader.readLine()).append('\n');
|
||||
}
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
}
|
||||
return ret.toString();
|
||||
}
|
||||
}
|
||||
+16
-19
@@ -1,6 +1,7 @@
|
||||
package com.onarandombox.MultiverseCore.utils.webpaste;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -8,7 +9,6 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Pastes to {@code pastebin.com}.
|
||||
@@ -55,38 +55,35 @@ public class PastebinPasteService implements PasteService {
|
||||
*/
|
||||
@Override
|
||||
public String postData(String encodedData, URL url) throws PasteFailedException {
|
||||
OutputStreamWriter wr = null;
|
||||
BufferedReader rd = null;
|
||||
try {
|
||||
URLConnection conn = url.openConnection();
|
||||
conn.setDoOutput(true);
|
||||
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
wr.write(encodedData);
|
||||
wr.flush();
|
||||
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
String pastebinUrl = "";
|
||||
while ((line = rd.readLine()) != null) {
|
||||
pastebinUrl = line;
|
||||
}
|
||||
wr.close();
|
||||
rd.close();
|
||||
return pastebinUrl;
|
||||
} catch (Exception e) {
|
||||
throw new PasteFailedException(e);
|
||||
} finally {
|
||||
if (wr != null) {
|
||||
try {
|
||||
wr.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
if (rd != null) {
|
||||
try {
|
||||
rd.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO maybe remove this?
|
||||
private Pattern getURLMatchingPattern() {
|
||||
if (this.isPrivate) {
|
||||
return Pattern.compile(".*http://pastie.org/.*key=([0-9a-z]+).*");
|
||||
} else {
|
||||
return Pattern.compile(".*http://pastie.org/([0-9]+).*");
|
||||
}
|
||||
}
|
||||
|
||||
// TODO maybe remove this?
|
||||
private String formatURL(String pastieID) {
|
||||
return "http://pastie.org/" + (this.isPrivate ? "private/" : "") + pastieID;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user