Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
355e824408 |
No files matched your search
@@ -20,16 +20,6 @@
|
||||
<id>Bukkit Official</id>
|
||||
<url>http://repo.bukkit.org/content/repositories/public</url>
|
||||
</repository>
|
||||
<!-- Required for Metrics -->
|
||||
<repository>
|
||||
<id>mcstats</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<!-- Required for Vault -->
|
||||
<repository>
|
||||
<id>herocraft</id>
|
||||
<url>http://ci.herocraftonline.com/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
@@ -111,6 +101,12 @@
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Maven Source Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.1.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
@@ -140,33 +136,6 @@
|
||||
<configLocation>${project.basedir}/config/mv_checks.xml</configLocation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.1.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.8.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc-jar</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@@ -181,12 +150,8 @@
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>me.main__.util:SerializationConfig</include>
|
||||
<include>com.pneumaticraft.commandhandler:CommandHandler</include>
|
||||
<include>com.dumptruckman.minecraft:buscript</include>
|
||||
<include>org.mcstats:metrics</include>
|
||||
<include>com.dumptruckman.minecraft:Logging</include>
|
||||
<include>com.dumptruckman.minecraft:Permissions-Bukkit</include>
|
||||
<include>com.fernferret.allpay:AllPay</include>
|
||||
<include>com.pneumaticraft.commandhandler:CommandHandler</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
@@ -202,26 +167,6 @@
|
||||
<pattern>com.pneumaticraft.commandhandler</pattern>
|
||||
<shadedPattern>com.pneumaticraft.commandhandler.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>buscript</pattern>
|
||||
<shadedPattern>buscript.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>org.mcstats.multiverse</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
|
||||
<shadedPattern>com.onarandombox.MultiverseCore.utils.CoreLogging</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.dumptruckman.minecraft.pluginbase</pattern>
|
||||
<shadedPattern>com.onarandombox.MultiverseCore.pluginbase</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.dumptruckman.minecraft.util.DebugLog</pattern>
|
||||
<shadedPattern>com.onarandombox.MultiverseCore.utils.DebugFileLogger</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
@@ -235,7 +180,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.4.5-R0.2</version>
|
||||
<version>1.2.5-R1.0</version>
|
||||
<!-- If you want the lates, use this -->
|
||||
<!-- <version>LATEST</version> -->
|
||||
<type>jar</type>
|
||||
@@ -253,12 +198,12 @@
|
||||
<dependency>
|
||||
<groupId>me.main__.util</groupId>
|
||||
<artifactId>SerializationConfig</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>1.6b</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of SerializationConfig Dependency -->
|
||||
<!-- Start of Economy Dependency -->
|
||||
<!-- Start of AllPay Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.fernferret.allpay</groupId>
|
||||
<artifactId>AllPay</artifactId>
|
||||
@@ -266,14 +211,7 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>1.2.19-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Economy Dependency -->
|
||||
<!-- End of AllPay Dependency -->
|
||||
<!-- Start of CommandHandler Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.pneumaticraft.commandhandler</groupId>
|
||||
@@ -283,42 +221,6 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of CommandHandler Dependency -->
|
||||
<!-- Start of Buscript Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>buscript</artifactId>
|
||||
<version>1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Buscript Dependency -->
|
||||
<!-- Start of Metrics Dependency -->
|
||||
<dependency>
|
||||
<groupId>org.mcstats</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Metrics Dependency -->
|
||||
<!-- Start of Logging Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>Logging</artifactId>
|
||||
<version>1.0.9</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Logging Dependency -->
|
||||
<!-- Start of Permissions lib Dependency -->
|
||||
<dependency>
|
||||
<groupId>com.dumptruckman.minecraft</groupId>
|
||||
<artifactId>Permissions-Bukkit</artifactId>
|
||||
<version>1.5-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Permissions lib Dependency -->
|
||||
<!-- Start of Test Dependencies -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -7,12 +7,8 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import buscript.Buscript;
|
||||
import com.dumptruckman.minecraft.pluginbase.permission.BukkitPermFactory;
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.fernferret.allpay.AllPay;
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.MVWorld.NullLocation;
|
||||
import com.onarandombox.MultiverseCore.api.BlockSafety;
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
import com.onarandombox.MultiverseCore.api.LocationManipulation;
|
||||
@@ -24,7 +20,6 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.commands.AnchorCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CheckCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CloneCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ConfigCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CoordCommand;
|
||||
@@ -32,8 +27,6 @@ import com.onarandombox.MultiverseCore.commands.CreateCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.DebugCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.DeleteCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.EnvironmentCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GameruleCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GamerulesCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.GeneratorCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.HelpCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ImportCommand;
|
||||
@@ -49,9 +42,7 @@ import com.onarandombox.MultiverseCore.commands.PurgeCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.RegenCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ReloadCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.RemoveCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.ScriptCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SetSpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SilentCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.SpawnCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.TeleportCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.UnloadCommand;
|
||||
@@ -65,32 +56,25 @@ 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.listeners.MVAsyncPlayerChatListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVChatListener;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVMapListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerChatListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||
import com.onarandombox.MultiverseCore.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.SimpleBlockSafety;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
@@ -100,7 +84,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.mcstats.Metrics;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -108,25 +91,25 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* The implementation of the Multiverse-{@link Core}.
|
||||
*/
|
||||
public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
private static final int PROTOCOL = 18;
|
||||
private static final int PROTOCOL = 15;
|
||||
// TODO: Investigate if this one is really needed to be static.
|
||||
// Doubt it. -- FernFerret
|
||||
private static Map<String, String> teleportQueue = new HashMap<String, String>();
|
||||
|
||||
private AnchorManager anchorManager = new AnchorManager(this);
|
||||
// TODO please let's make this non-static
|
||||
private volatile MultiverseCoreConfiguration config;
|
||||
private MultiverseCoreConfiguration config;
|
||||
|
||||
/**
|
||||
* This method is used to find out who is teleporting a player.
|
||||
@@ -149,7 +132,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
* @param teleportee The name of the player that was teleported.
|
||||
*/
|
||||
public static void addPlayerToTeleportQueue(String teleporter, String teleportee) {
|
||||
Logging.finest("Adding mapping '%s' => '%s' to teleport queue", teleporter, teleportee);
|
||||
staticLog(Level.FINEST, "Adding mapping '" + teleporter + "' => '" + teleportee + "' to teleport queue");
|
||||
teleportQueue.put(teleportee, teleporter);
|
||||
}
|
||||
|
||||
@@ -185,6 +168,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return MultiverseCore.PROTOCOL;
|
||||
}
|
||||
|
||||
// Useless stuff to keep us going.
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private static DebugLog debugLog;
|
||||
|
||||
// Setup our Map for our Commands using the CommandHandler.
|
||||
private CommandHandler commandHandler;
|
||||
|
||||
@@ -196,22 +183,19 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Configurations
|
||||
private FileConfiguration multiverseConfig = null;
|
||||
|
||||
private final MVWorldManager worldManager = new WorldManager(this);
|
||||
private MVWorldManager worldManager = new WorldManager(this);
|
||||
|
||||
// Setup the block/player/entity listener.
|
||||
private final MVPlayerListener playerListener = new MVPlayerListener(this);
|
||||
private final MVEntityListener entityListener = new MVEntityListener(this);
|
||||
private final MVPluginListener pluginListener = new MVPluginListener(this);
|
||||
private final MVWeatherListener weatherListener = new MVWeatherListener(this);
|
||||
private final MVPortalListener portalListener = new MVPortalListener(this);
|
||||
private MVChatListener chatListener;
|
||||
private MVPlayerListener playerListener = new MVPlayerListener(this);
|
||||
private MVEntityListener entityListener = new MVEntityListener(this);
|
||||
private MVPluginListener pluginListener = new MVPluginListener(this);
|
||||
private MVWeatherListener weatherListener = new MVWeatherListener(this);
|
||||
private MVPortalListener portalListener = new MVPortalListener(this);
|
||||
|
||||
// HashMap to contain information relating to the Players.
|
||||
private HashMap<String, MVPlayerSession> playerSessions;
|
||||
private VaultHandler vaultHandler;
|
||||
private GenericBank bank = null;
|
||||
private AllPay banker;
|
||||
private Buscript buscript;
|
||||
private int pluginCount;
|
||||
private DestinationFactory destFactory;
|
||||
//private SpoutInterface spoutInterface = null;
|
||||
@@ -224,18 +208,16 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Register permission handler
|
||||
BukkitPermFactory.registerPermissionName(getClass(), "multiverse");
|
||||
BukkitPermFactory.registerPermissionName(Core.class, "multiverse");
|
||||
// Register our config
|
||||
SerializationConfig.registerAll(MultiverseCoreConfiguration.class);
|
||||
// Register our world
|
||||
SerializationConfig.registerAll(WorldProperties.class);
|
||||
SerializationConfig.registerAll(MVWorld.class);
|
||||
// Create our DataFolder
|
||||
getDataFolder().mkdirs();
|
||||
// Setup our Debug Log
|
||||
Logging.init(this);
|
||||
SerializationConfig.initLogging(Logging.getLogger());
|
||||
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
|
||||
debugLog.setStandardLogger(LOGGER);
|
||||
SerializationConfig.initLogging(debugLog);
|
||||
// Setup our BlockSafety
|
||||
this.blockSafety = new SimpleBlockSafety(this);
|
||||
// Setup our LocationManipulation
|
||||
@@ -256,19 +238,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated Now using Vault.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public GenericBank getBank() {
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VaultHandler getVaultHandler() {
|
||||
return vaultHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -276,7 +251,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
public void onEnable() {
|
||||
this.messaging = new MVMessaging();
|
||||
this.banker = new AllPay(this, LOG_TAG + " ");
|
||||
this.vaultHandler = new VaultHandler(this);
|
||||
// Output a little snippet to show it's enabled.
|
||||
this.log(Level.INFO, "- Version " + this.getDescription().getVersion() + " (API v" + PROTOCOL + ") Enabled - By " + getAuthors());
|
||||
// Load the defaultWorldGenerators
|
||||
this.worldManager.getDefaultWorldGenerators();
|
||||
|
||||
@@ -305,8 +281,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Setup & Load our Configuration files.
|
||||
loadConfigs();
|
||||
if (this.multiverseConfig != null) {
|
||||
Logging.setDebugLevel(getMVConfig().getGlobalDebug());
|
||||
Logging.setShowingConfig(!getMVConfig().getSilentStart());
|
||||
this.worldManager.loadDefaultWorlds();
|
||||
this.worldManager.loadWorlds(true);
|
||||
} else {
|
||||
@@ -315,25 +289,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.anchorManager.loadAnchors();
|
||||
|
||||
// Now set the firstspawnworld (after the worlds are loaded):
|
||||
this.worldManager.setFirstSpawnWorld(getMVConfig().getFirstSpawnWorld());
|
||||
this.worldManager.setFirstSpawnWorld(config.getFirstSpawnWorld());
|
||||
try {
|
||||
getMVConfig().setFirstSpawnWorld(this.worldManager.getFirstSpawnWorld().getName());
|
||||
config.setFirstSpawnWorld(this.worldManager.getFirstSpawnWorld().getName());
|
||||
} catch (NullPointerException e) {
|
||||
// A test that had no worlds loaded was being run. This should never happen in production
|
||||
}
|
||||
this.saveMVConfig();
|
||||
// Register async or sync player chat according to config
|
||||
try {
|
||||
Class.forName("org.bukkit.event.player.AsyncPlayerChatEvent");
|
||||
} catch (ClassNotFoundException e) {
|
||||
getMVConfig().setUseAsyncChat(false);
|
||||
}
|
||||
if (getMVConfig().getUseAsyncChat()) {
|
||||
this.chatListener = new MVAsyncPlayerChatListener(this, this.playerListener);
|
||||
} else {
|
||||
this.chatListener = new MVPlayerChatListener(this, this.playerListener);
|
||||
}
|
||||
getServer().getPluginManager().registerEvents(this.chatListener, this);
|
||||
/*
|
||||
// Check to see if spout was already loaded (most likely):
|
||||
if (this.getServer().getPluginManager().getPlugin("Spout") != null) {
|
||||
@@ -341,112 +303,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.log(Level.INFO, "Spout integration enabled.");
|
||||
}
|
||||
*/
|
||||
|
||||
this.initializeBuscript();
|
||||
this.setupMetrics();
|
||||
|
||||
// Output a little snippet to show it's enabled.
|
||||
Logging.config("Version %s (API v%s) Enabled - By %s", this.getDescription().getVersion(), PROTOCOL, getAuthors());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the buscript javascript library.
|
||||
*/
|
||||
private void initializeBuscript() {
|
||||
buscript = new Buscript(this);
|
||||
// Add global variable "multiverse" to javascript environment
|
||||
buscript.getGlobalScope().put("multiverse", buscript.getGlobalScope(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plotter for Environment-Values.
|
||||
*/
|
||||
private static final class EnvironmentPlotter extends Metrics.Plotter {
|
||||
private MultiverseCore core;
|
||||
private final Environment env;
|
||||
|
||||
public EnvironmentPlotter(MultiverseCore core, Environment env) {
|
||||
super(envToString(env));
|
||||
this.core = core;
|
||||
this.env = env;
|
||||
}
|
||||
|
||||
private static String envToString(Environment env) {
|
||||
return new StringBuilder().append(env.name().toUpperCase().charAt(0))
|
||||
.append(env.name().toLowerCase().substring(1)).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
int count = 0;
|
||||
for (MultiverseWorld w : core.getMVWorldManager().getMVWorlds())
|
||||
if (w.getEnvironment() == env)
|
||||
count++;
|
||||
core.log(Level.FINE, String.format("Tracking %d worlds of type %s", count, env));
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plotter for Generator-Values.
|
||||
*/
|
||||
private static final class GeneratorPlotter extends Metrics.Plotter {
|
||||
private MultiverseCore core;
|
||||
private final String gen;
|
||||
|
||||
public GeneratorPlotter(MultiverseCore core, String gen) {
|
||||
super(gen);
|
||||
this.core = core;
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getValue() {
|
||||
int count = 0;
|
||||
for (MultiverseWorld w : core.getMVWorldManager().getMVWorlds())
|
||||
if (gen.equals(w.getGenerator()))
|
||||
count++;
|
||||
core.log(Level.FINE, String.format("Tracking %d worlds of type %s", count, gen));
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
private void setupMetrics() {
|
||||
try {
|
||||
Metrics m = new Metrics(this);
|
||||
|
||||
Metrics.Graph envGraph = m.createGraph("worlds_by_env");
|
||||
for (Environment env : Environment.values())
|
||||
envGraph.addPlotter(new EnvironmentPlotter(this, env));
|
||||
|
||||
m.addCustomData(new Metrics.Plotter("Loaded worlds") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return getMVWorldManager().getMVWorlds().size();
|
||||
}
|
||||
});
|
||||
m.addCustomData(new Metrics.Plotter("Total number of worlds") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return getMVWorldManager().getMVWorlds().size()
|
||||
+ getMVWorldManager().getUnloadedWorlds().size();
|
||||
}
|
||||
});
|
||||
|
||||
Set<String> gens = new HashSet<String>();
|
||||
for (MultiverseWorld w : this.getMVWorldManager().getMVWorlds())
|
||||
gens.add(w.getGenerator());
|
||||
gens.remove(null);
|
||||
gens.remove("null");
|
||||
Metrics.Graph genGraph = m.createGraph("custom_gens");
|
||||
for (String gen : gens)
|
||||
genGraph.addPlotter(new GeneratorPlotter(this, gen));
|
||||
|
||||
m.start();
|
||||
log(Level.FINE, "Metrics have run!");
|
||||
} catch (IOException e) {
|
||||
log(Level.WARNING, "There was an issue while enabling metrics: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeDestinationFactory() {
|
||||
@@ -470,7 +326,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
pm.registerEvents(this.pluginListener, this);
|
||||
pm.registerEvents(this.weatherListener, this);
|
||||
pm.registerEvents(this.portalListener, this);
|
||||
pm.registerEvents(new MVMapListener(this), this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -488,14 +344,15 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
MultiverseCoreConfiguration wantedConfig = null;
|
||||
try {
|
||||
wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration");
|
||||
} catch (Exception ignore) {
|
||||
} catch (Exception e) {
|
||||
// We're just thinking "no risk no fun" and therefore have to catch and forget this exception
|
||||
} finally {
|
||||
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
||||
}
|
||||
this.migrateWorldConfig();
|
||||
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
||||
|
||||
this.messaging.setCooldown(getMVConfig().getMessageCooldown());
|
||||
this.messaging.setCooldown(config.getMessageCooldown());
|
||||
|
||||
// Remove old values.
|
||||
this.multiverseConfig.set("enforcegamemodes", null);
|
||||
@@ -513,47 +370,47 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
private void migrate22Values() {
|
||||
if (this.multiverseConfig.isSet("worldnameprefix")) {
|
||||
Logging.config("Migrating 'worldnameprefix'...");
|
||||
this.getMVConfig().setPrefixChat(this.multiverseConfig.getBoolean("worldnameprefix"));
|
||||
this.log(Level.INFO, "Migrating 'worldnameprefix'...");
|
||||
this.config.setPrefixChat(this.multiverseConfig.getBoolean("worldnameprefix"));
|
||||
this.multiverseConfig.set("worldnameprefix", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("firstspawnworld")) {
|
||||
Logging.config("Migrating 'firstspawnworld'...");
|
||||
this.getMVConfig().setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld"));
|
||||
this.log(Level.INFO, "Migrating 'firstspawnworld'...");
|
||||
this.config.setFirstSpawnWorld(this.multiverseConfig.getString("firstspawnworld"));
|
||||
this.multiverseConfig.set("firstspawnworld", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("enforceaccess")) {
|
||||
Logging.config("Migrating 'enforceaccess'...");
|
||||
this.getMVConfig().setEnforceAccess(this.multiverseConfig.getBoolean("enforceaccess"));
|
||||
this.log(Level.INFO, "Migrating 'enforceaccess'...");
|
||||
this.config.setEnforceAccess(this.multiverseConfig.getBoolean("enforceaccess"));
|
||||
this.multiverseConfig.set("enforceaccess", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("displaypermerrors")) {
|
||||
Logging.config("Migrating 'displaypermerrors'...");
|
||||
this.getMVConfig().setDisplayPermErrors(this.multiverseConfig.getBoolean("displaypermerrors"));
|
||||
this.log(Level.INFO, "Migrating 'displaypermerrors'...");
|
||||
this.config.setDisplayPermErrors(this.multiverseConfig.getBoolean("displaypermerrors"));
|
||||
this.multiverseConfig.set("displaypermerrors", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("teleportintercept")) {
|
||||
Logging.config("Migrating 'teleportintercept'...");
|
||||
this.getMVConfig().setTeleportIntercept(this.multiverseConfig.getBoolean("teleportintercept"));
|
||||
this.log(Level.INFO, "Migrating 'teleportintercept'...");
|
||||
this.config.setTeleportIntercept(this.multiverseConfig.getBoolean("teleportintercept"));
|
||||
this.multiverseConfig.set("teleportintercept", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("firstspawnoverride")) {
|
||||
Logging.config("Migrating 'firstspawnoverride'...");
|
||||
this.getMVConfig().setFirstSpawnOverride(this.multiverseConfig.getBoolean("firstspawnoverride"));
|
||||
this.log(Level.INFO, "Migrating 'firstspawnoverride'...");
|
||||
this.config.setFirstSpawnOverride(this.multiverseConfig.getBoolean("firstspawnoverride"));
|
||||
this.multiverseConfig.set("firstspawnoverride", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("messagecooldown")) {
|
||||
Logging.config("Migrating 'messagecooldown'...");
|
||||
this.getMVConfig().setMessageCooldown(this.multiverseConfig.getInt("messagecooldown"));
|
||||
this.log(Level.INFO, "Migrating 'messagecooldown'...");
|
||||
this.config.setMessageCooldown(this.multiverseConfig.getInt("messagecooldown"));
|
||||
this.multiverseConfig.set("messagecooldown", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("debug")) {
|
||||
Logging.config("Migrating 'debug'...");
|
||||
this.getMVConfig().setGlobalDebug(this.multiverseConfig.getInt("debug"));
|
||||
this.log(Level.INFO, "Migrating 'debug'...");
|
||||
this.config.setGlobalDebug(this.multiverseConfig.getInt("debug"));
|
||||
this.multiverseConfig.set("debug", null);
|
||||
}
|
||||
if (this.multiverseConfig.isSet("version")) {
|
||||
Logging.config("Migrating 'version'...");
|
||||
this.log(Level.INFO, "Migrating 'version'...");
|
||||
this.multiverseConfig.set("version", null);
|
||||
}
|
||||
}
|
||||
@@ -561,11 +418,11 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
/**
|
||||
* Migrate the worlds.yml to SerializationConfig.
|
||||
*/
|
||||
private void migrateWorldConfig() { // SUPPRESS CHECKSTYLE: MethodLength
|
||||
private void migrateWorldConfig() {
|
||||
FileConfiguration wconf = YamlConfiguration
|
||||
.loadConfiguration(new File(getDataFolder(), "worlds.yml"));
|
||||
|
||||
if (!wconf.isConfigurationSection("worlds")) { // empty config
|
||||
if (!wconf.isConfigurationSection("worlds")) {// empty config
|
||||
this.log(Level.FINE, "No worlds to migrate!");
|
||||
return;
|
||||
}
|
||||
@@ -575,13 +432,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
boolean wasChanged = false;
|
||||
Map<String, Object> newValues = new LinkedHashMap<String, Object>(values.size());
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
if (entry.getValue() instanceof WorldProperties) {
|
||||
if (entry.getValue() instanceof MVWorld) {
|
||||
// fine
|
||||
newValues.put(entry.getKey(), entry.getValue());
|
||||
} else if (entry.getValue() instanceof ConfigurationSection) {
|
||||
this.log(Level.FINE, "Migrating: " + entry.getKey());
|
||||
// we have to migrate this
|
||||
WorldProperties world = new WorldProperties(Collections.EMPTY_MAP);
|
||||
MVWorld world = new MVWorld(Collections.EMPTY_MAP);
|
||||
ConfigurationSection section = (ConfigurationSection) entry.getValue();
|
||||
|
||||
// migrate animals and monsters
|
||||
@@ -651,9 +508,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
// migrate gamemode
|
||||
if (section.isString("gamemode")) {
|
||||
final GameMode gameMode = GameMode.valueOf(section.getString("gamemode").toUpperCase());
|
||||
if (gameMode != null) {
|
||||
world.setGameMode(gameMode);
|
||||
try {
|
||||
world.setPropertyValue("gamemode", section.getString("gamemode"));
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -675,8 +533,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// migrate portalform
|
||||
if (section.isString("portalform")) {
|
||||
try {
|
||||
world.setProperty("portalform", section.getString("portalform"), true);
|
||||
} catch (NoSuchPropertyException e) {
|
||||
world.setPropertyValue("portalform", section.getString("portalform"));
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||
}
|
||||
}
|
||||
@@ -684,8 +542,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// migrate environment
|
||||
if (section.isString("environment")) {
|
||||
try {
|
||||
world.setProperty("environment", section.getString("environment"), true);
|
||||
} catch (NoSuchPropertyException e) {
|
||||
world.setPropertyValue("environment", section.getString("environment"));
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
throw new RuntimeException("Who forgot to update the migrator?", e);
|
||||
}
|
||||
}
|
||||
@@ -723,7 +581,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// migrate spawn
|
||||
if (section.isConfigurationSection("spawn")) {
|
||||
ConfigurationSection spawnSect = section.getConfigurationSection("spawn");
|
||||
Location spawnLoc = new NullLocation();
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
if (spawnSect.isDouble("yaw"))
|
||||
spawnLoc.setYaw((float) spawnSect.getDouble("yaw"));
|
||||
if (spawnSect.isDouble("pitch"))
|
||||
@@ -738,19 +596,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
world.setSpawnLocation(spawnLoc);
|
||||
}
|
||||
|
||||
// migrate difficulty
|
||||
if (section.isString("difficulty")) {
|
||||
final Difficulty difficulty = Difficulty.valueOf(section.getString("difficulty").toUpperCase());
|
||||
if (difficulty != null) {
|
||||
world.setDifficulty(difficulty);
|
||||
}
|
||||
}
|
||||
|
||||
// migrate keepspawninmemory
|
||||
if (section.isBoolean("keepspawninmemory")) {
|
||||
world.setKeepSpawnInMemory(section.getBoolean("keepspawninmemory"));
|
||||
}
|
||||
|
||||
newValues.put(entry.getKey(), world);
|
||||
wasChanged = true;
|
||||
} else {
|
||||
@@ -798,7 +643,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
this.commandHandler.registerCommand(new ListCommand(this));
|
||||
this.commandHandler.registerCommand(new InfoCommand(this));
|
||||
this.commandHandler.registerCommand(new CreateCommand(this));
|
||||
this.commandHandler.registerCommand(new CloneCommand(this));
|
||||
this.commandHandler.registerCommand(new ImportCommand(this));
|
||||
this.commandHandler.registerCommand(new ReloadCommand(this));
|
||||
this.commandHandler.registerCommand(new SetSpawnCommand(this));
|
||||
@@ -825,12 +669,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Misc Commands
|
||||
this.commandHandler.registerCommand(new EnvironmentCommand(this));
|
||||
this.commandHandler.registerCommand(new DebugCommand(this));
|
||||
this.commandHandler.registerCommand(new SilentCommand(this));
|
||||
this.commandHandler.registerCommand(new GeneratorCommand(this));
|
||||
this.commandHandler.registerCommand(new CheckCommand(this));
|
||||
this.commandHandler.registerCommand(new ScriptCommand(this));
|
||||
this.commandHandler.registerCommand(new GameruleCommand(this));
|
||||
this.commandHandler.registerCommand(new GamerulesCommand(this));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -839,9 +679,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.saveMVConfigs();
|
||||
debugLog.close();
|
||||
this.banker = null;
|
||||
this.bank = null;
|
||||
Logging.shutdown();
|
||||
log(Level.INFO, "- Disabled");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -852,7 +693,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
if (this.playerSessions.containsKey(player.getName())) {
|
||||
return this.playerSessions.get(player.getName());
|
||||
} else {
|
||||
this.playerSessions.put(player.getName(), new MVPlayerSession(player, getMVConfig()));
|
||||
this.playerSessions.put(player.getName(), new MVPlayerSession(player, config));
|
||||
return this.playerSessions.get(player.getName());
|
||||
}
|
||||
}
|
||||
@@ -887,17 +728,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
}
|
||||
ArrayList<String> allArgs = new ArrayList<String>(Arrays.asList(args));
|
||||
allArgs.add(0, command.getName());
|
||||
try {
|
||||
return this.commandHandler.locateAndRunCommand(sender, allArgs, getMVConfig().getDisplayPermErrors());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sender.sendMessage(ChatColor.RED + "An internal error occurred when attempting to perform this command.");
|
||||
if (sender.isOp())
|
||||
sender.sendMessage(ChatColor.RED + "Details were printed to the server console and logs, please add that to your bug report.");
|
||||
else
|
||||
sender.sendMessage(ChatColor.RED + "Try again and contact the server owner or an admin if this problem persists.");
|
||||
return true;
|
||||
}
|
||||
return this.commandHandler.locateAndRunCommand(sender, allArgs, config.getDisplayPermErrors());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -905,7 +736,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
@Override
|
||||
public void log(Level level, String msg) {
|
||||
Logging.log(level, msg);
|
||||
staticLog(level, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -913,28 +744,30 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*
|
||||
* @param level The Log-{@link Level}.
|
||||
* @param msg The message to log.
|
||||
*
|
||||
* @deprecated Replaced by {@link Logging}. Please refrain from using this from a third party plugin as the
|
||||
* messages will appear to originate from Multiverse-Core.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void staticLog(Level level, String msg) {
|
||||
Logging.log(level, msg);
|
||||
if (level == Level.FINE && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 1) {
|
||||
staticDebugLog(Level.INFO, msg);
|
||||
} else if (level == Level.FINER && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 2) {
|
||||
staticDebugLog(Level.INFO, msg);
|
||||
} else if (level == Level.FINEST && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 3) {
|
||||
staticDebugLog(Level.INFO, msg);
|
||||
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
|
||||
String message = LOG_TAG + " " + msg;
|
||||
LOGGER.log(level, message);
|
||||
debugLog.log(level, message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print messages to the Debug Log, if the servers in Debug Mode then we also want to print the messages to the
|
||||
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the
|
||||
* standard Server Console.
|
||||
*
|
||||
* @param level The Log-{@link Level}
|
||||
* @param msg The message
|
||||
*
|
||||
* @deprecated Replaced by {@link Logging}. Please refrain from using this from a third party plugin as the
|
||||
* messages will appear to originate from Multiverse-Core.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void staticDebugLog(Level level, String msg) {
|
||||
Logging.log(level, msg);
|
||||
debugLog.log(level, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1028,20 +861,16 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated Now using Vault.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public AllPay getBanker() {
|
||||
return this.banker;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated Now using Vault.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setBank(GenericBank bank) {
|
||||
this.bank = bank;
|
||||
}
|
||||
@@ -1123,15 +952,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return this.playerListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link MVChatListener}.
|
||||
*
|
||||
* @return The {@link MVChatListener}.
|
||||
*/
|
||||
public MVChatListener getChatListener() {
|
||||
return this.chatListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link MVEntityListener}.
|
||||
*
|
||||
@@ -1157,7 +977,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
*/
|
||||
public boolean saveMVConfig() {
|
||||
try {
|
||||
this.multiverseConfig.set("multiverse-configuration", getMVConfig());
|
||||
this.multiverseConfig.set("multiverse-configuration", config);
|
||||
this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
@@ -1194,27 +1014,38 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
return this.worldManager.deleteWorld(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* NOT deprecated for the time as queued commands use this.
|
||||
* However, this is not in the API and other plugins should therefore not use it.
|
||||
*
|
||||
* @param oldName World to copy
|
||||
* @param newName World to create
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
public Boolean cloneWorld(String oldName, String newName, String generator) {
|
||||
return this.worldManager.cloneWorld(oldName, newName, generator);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated This is deprecated!
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed) {
|
||||
return this.worldManager.regenWorld(name, useNewSeed, randomSeed, seed);
|
||||
MultiverseWorld world = this.worldManager.getMVWorld(name);
|
||||
if (world == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Player> ps = world.getCBWorld().getPlayers();
|
||||
|
||||
if (useNewSeed) {
|
||||
// Set the worldseed.
|
||||
if (randomSeed) {
|
||||
Random random = new Random();
|
||||
Long newseed = random.nextLong();
|
||||
seed = newseed.toString();
|
||||
}
|
||||
((WorldManager) this.worldManager).getConfigWorlds().set("worlds." + name + ".seed", seed);
|
||||
}
|
||||
if (this.worldManager.deleteWorld(name, false)) {
|
||||
this.worldManager.loadWorlds(false);
|
||||
SafeTTeleporter teleporter = this.getSafeTTeleporter();
|
||||
Location newSpawn = this.getServer().getWorld(name).getSpawnLocation();
|
||||
// Send all players that were in the old world, BACK to it!
|
||||
for (Player p : ps) {
|
||||
teleporter.safelyTeleport(null, p, newSpawn, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1291,9 +1122,4 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
public static MultiverseCoreConfiguration getStaticConfig() {
|
||||
return MultiverseCoreConfiguration.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Buscript getScriptAPI() {
|
||||
return buscript;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
@@ -40,33 +39,25 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
}
|
||||
|
||||
@Property
|
||||
private volatile boolean enforceaccess;
|
||||
private boolean enforceaccess;
|
||||
@Property
|
||||
private volatile boolean prefixchat;
|
||||
private boolean prefixchat;
|
||||
@Property
|
||||
private volatile boolean useasyncchat;
|
||||
private boolean teleportintercept;
|
||||
@Property
|
||||
private volatile boolean teleportintercept;
|
||||
private boolean firstspawnoverride;
|
||||
@Property
|
||||
private volatile boolean firstspawnoverride;
|
||||
private boolean displaypermerrors;
|
||||
@Property
|
||||
private volatile boolean displaypermerrors;
|
||||
private int globaldebug;
|
||||
@Property
|
||||
private volatile int globaldebug;
|
||||
private int messagecooldown;
|
||||
@Property
|
||||
private volatile boolean silentstart;
|
||||
private double version;
|
||||
@Property
|
||||
private volatile int messagecooldown;
|
||||
private String firstspawnworld;
|
||||
@Property
|
||||
private volatile double version;
|
||||
@Property
|
||||
private volatile String firstspawnworld;
|
||||
@Property
|
||||
private volatile int teleportcooldown;
|
||||
@Property
|
||||
private volatile boolean defaultportalsearch;
|
||||
@Property
|
||||
private volatile int portalsearchradius;
|
||||
private int teleportcooldown;
|
||||
|
||||
public MultiverseCoreConfiguration() {
|
||||
super();
|
||||
@@ -82,10 +73,9 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void setDefaults() {
|
||||
public void setDefaults() {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
enforceaccess = false;
|
||||
useasyncchat = true;
|
||||
prefixchat = true;
|
||||
teleportintercept = true;
|
||||
firstspawnoverride = true;
|
||||
@@ -94,9 +84,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
messagecooldown = 5000;
|
||||
teleportcooldown = 1000;
|
||||
this.version = 2.9;
|
||||
silentstart = false;
|
||||
defaultportalsearch = false;
|
||||
portalsearchradius = 16;
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
@@ -208,7 +195,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
@Override
|
||||
public void setGlobalDebug(int globalDebug) {
|
||||
this.globaldebug = globalDebug;
|
||||
Logging.setDebugLevel(globalDebug);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,45 +260,4 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
public void setTeleportCooldown(int teleportCooldown) {
|
||||
this.teleportcooldown = teleportCooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseAsyncChat(boolean useAsyncChat) {
|
||||
this.useasyncchat = useAsyncChat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getUseAsyncChat() {
|
||||
return this.useasyncchat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSilentStart(boolean silentStart) {
|
||||
Logging.setShowingConfig(!silentStart);
|
||||
this.silentstart = silentStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSilentStart() {
|
||||
return silentstart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseDefaultPortalSearch(boolean useDefaultPortalSearch) {
|
||||
defaultportalsearch = useDefaultPortalSearch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsingDefaultPortalSearch() {
|
||||
return defaultportalsearch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPortalSearchRadius(int searchRadius) {
|
||||
this.portalsearchradius = searchRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPortalSearchRadius() {
|
||||
return portalsearchradius;
|
||||
}
|
||||
}
|
||||
@@ -1,633 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MVWorld.NullLocation;
|
||||
import com.onarandombox.MultiverseCore.configuration.EntryFee;
|
||||
import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
|
||||
import com.onarandombox.MultiverseCore.configuration.SpawnSettings;
|
||||
import com.onarandombox.MultiverseCore.configuration.WorldPropertyValidator;
|
||||
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatColor;
|
||||
import com.onarandombox.MultiverseCore.enums.EnglishChatStyle;
|
||||
import me.main__.util.SerializationConfig.IllegalPropertyValueException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import me.main__.util.SerializationConfig.Serializor;
|
||||
import me.main__.util.SerializationConfig.Validator;
|
||||
import me.main__.util.SerializationConfig.VirtualProperty;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@SerializableAs("MVWorld")
|
||||
public class WorldProperties extends SerializationConfig {
|
||||
|
||||
private static final Map<String, String> PROPERTY_ALIASES;
|
||||
|
||||
static {
|
||||
PROPERTY_ALIASES = new HashMap<String, String>();
|
||||
PROPERTY_ALIASES.put("curr", "currency");
|
||||
PROPERTY_ALIASES.put("scaling", "scale");
|
||||
PROPERTY_ALIASES.put("aliascolor", "color");
|
||||
PROPERTY_ALIASES.put("heal", "autoHeal");
|
||||
PROPERTY_ALIASES.put("storm", "allowWeather");
|
||||
PROPERTY_ALIASES.put("weather", "allowWeather");
|
||||
PROPERTY_ALIASES.put("spawnmemory", "keepSpawnInMemory");
|
||||
PROPERTY_ALIASES.put("memory", "keepSpawnInMemory");
|
||||
PROPERTY_ALIASES.put("mode", "gameMode");
|
||||
PROPERTY_ALIASES.put("diff", "difficulty");
|
||||
PROPERTY_ALIASES.put("spawnlocation", "spawn");
|
||||
PROPERTY_ALIASES.put("limit", "playerLimit");
|
||||
PROPERTY_ALIASES.put("animals", "spawning.animals.spawn");
|
||||
PROPERTY_ALIASES.put("monsters", "spawning.monsters.spawn");
|
||||
PROPERTY_ALIASES.put("animalsrate", "spawning.animals.spawnrate");
|
||||
PROPERTY_ALIASES.put("monstersrate", "spawning.monsters.spawnrate");
|
||||
PROPERTY_ALIASES.put("flight", "allowFlight");
|
||||
PROPERTY_ALIASES.put("fly", "allowFlight");
|
||||
PROPERTY_ALIASES.put("allowfly", "allowFlight");
|
||||
}
|
||||
|
||||
public WorldProperties(Map<String, Object> values) {
|
||||
super(values);
|
||||
}
|
||||
|
||||
public WorldProperties() {
|
||||
super();
|
||||
}
|
||||
|
||||
public WorldProperties(final boolean fixSpawn, final Environment environment) {
|
||||
super();
|
||||
if (!fixSpawn) {
|
||||
this.adjustSpawn = false;
|
||||
}
|
||||
setScaling(getDefaultScale(environment));
|
||||
}
|
||||
|
||||
void setMVWorld(MVWorld world) {
|
||||
registerObjectUsing(world);
|
||||
registerGlobalValidator(new WorldPropertyValidator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializor for the color-property.
|
||||
*/
|
||||
private static final class EnumPropertySerializor<T extends Enum<T>> implements Serializor<T, String> {
|
||||
@Override
|
||||
public String serialize(T from) {
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(String serialized, Class<T> wanted) throws IllegalPropertyValueException {
|
||||
try {
|
||||
return Enum.valueOf(wanted, serialized.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalPropertyValueException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializor for the difficulty-property.
|
||||
*/
|
||||
private static final class DifficultyPropertySerializor implements Serializor<Difficulty, String> {
|
||||
@Override
|
||||
public String serialize(Difficulty from) {
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Difficulty deserialize(String serialized, Class<Difficulty> wanted) throws IllegalPropertyValueException {
|
||||
try {
|
||||
return Difficulty.getByValue(Integer.parseInt(serialized));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
try {
|
||||
return Difficulty.valueOf(serialized.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
throw new IllegalPropertyValueException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializor for the gameMode-property.
|
||||
*/
|
||||
private static final class GameModePropertySerializor implements Serializor<GameMode, String> {
|
||||
@Override
|
||||
public String serialize(GameMode from) {
|
||||
return from.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode deserialize(String serialized, Class<GameMode> wanted) throws IllegalPropertyValueException {
|
||||
try {
|
||||
return GameMode.getByValue(Integer.parseInt(serialized));
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
try {
|
||||
return GameMode.valueOf(serialized.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
throw new IllegalPropertyValueException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializor for the time-property.
|
||||
*/
|
||||
private static final class TimePropertySerializor implements Serializor<Long, String> {
|
||||
// BEGIN CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
private static final String TIME_REGEX = "(\\d\\d?):?(\\d\\d)(a|p)?m?";
|
||||
private static final Map<String, String> TIME_ALIASES;
|
||||
static {
|
||||
Map<String, String> staticTimes = new HashMap<String, String>();
|
||||
staticTimes.put("morning", "8:00");
|
||||
staticTimes.put("day", "12:00");
|
||||
staticTimes.put("noon", "12:00");
|
||||
staticTimes.put("midnight", "0:00");
|
||||
staticTimes.put("night", "20:00");
|
||||
|
||||
// now set TIME_ALIASES to a "frozen" map
|
||||
TIME_ALIASES = Collections.unmodifiableMap(staticTimes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String serialize(Long from) {
|
||||
// I'm tired, so they get time in 24 hour for now.
|
||||
// Someone else can add 12 hr format if they want :P
|
||||
|
||||
int hours = (int) ((from / 1000 + 8) % 24);
|
||||
int minutes = (int) (60 * (from % 1000) / 1000);
|
||||
|
||||
return String.format("%d:%02d", hours, minutes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long deserialize(String serialized, Class<Long> wanted) throws IllegalPropertyValueException {
|
||||
if (TIME_ALIASES.containsKey(serialized.toLowerCase())) {
|
||||
serialized = TIME_ALIASES.get(serialized.toLowerCase());
|
||||
}
|
||||
// Regex that extracts a time in the following formats:
|
||||
// 11:11pm, 11:11, 23:11, 1111, 1111p, and the aliases at the top of this file.
|
||||
Pattern pattern = Pattern.compile(TIME_REGEX, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(serialized);
|
||||
matcher.find();
|
||||
int hour = 0;
|
||||
double minute = 0;
|
||||
int count = matcher.groupCount();
|
||||
if (count >= 2) {
|
||||
hour = Integer.parseInt(matcher.group(1));
|
||||
minute = Integer.parseInt(matcher.group(2));
|
||||
}
|
||||
// If there were 4 matches (all, hour, min, am/pm)
|
||||
if (count == 4) {
|
||||
// We want 24 hour time for calcs, but if they
|
||||
// added a p[m], turn it into a 24 hr one.
|
||||
if (matcher.group(3).equals("p")) {
|
||||
hour += 12;
|
||||
}
|
||||
}
|
||||
// Translate 24th hour to 0th hour.
|
||||
if (hour == 24) {
|
||||
hour = 0;
|
||||
}
|
||||
// Clamp the hour
|
||||
if (hour > 23 || hour < 0) {
|
||||
throw new IllegalPropertyValueException("Illegal hour!");
|
||||
}
|
||||
// Clamp the minute
|
||||
if (minute > 59 || minute < 0) {
|
||||
throw new IllegalPropertyValueException("Illegal minute!");
|
||||
}
|
||||
// 60 seconds in a minute, time needs to be in hrs * 1000, per
|
||||
// the bukkit docs.
|
||||
double totaltime = (hour + (minute / 60.0)) * 1000;
|
||||
// Somehow there's an 8 hour offset...
|
||||
totaltime -= 8000;
|
||||
if (totaltime < 0) {
|
||||
totaltime = 24000 + totaltime;
|
||||
}
|
||||
|
||||
return (long) totaltime;
|
||||
}
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// Begin properties
|
||||
@Property(description = "Sorry, 'hidden' must either be: true or false.")
|
||||
private volatile boolean hidden;
|
||||
@Property(description = "Alias must be a valid string.")
|
||||
private volatile String alias;
|
||||
@Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'color' must be a valid color-name.")
|
||||
private volatile EnglishChatColor color;
|
||||
@Property(serializor = EnumPropertySerializor.class, description = "Sorry, 'style' must be a valid style-name.")
|
||||
private volatile EnglishChatStyle style;
|
||||
@Property(description = "Sorry, 'pvp' must either be: true or false.", virtualType = Boolean.class, persistVirtual = true)
|
||||
volatile VirtualProperty<Boolean> pvp;
|
||||
@Property(description = "Scale must be a positive double value. ex: 2.3")
|
||||
private volatile double scale;
|
||||
@Property(description = "You must set this to the NAME not alias of a world.")
|
||||
private volatile String respawnWorld;
|
||||
@Property(description = "Sorry, this must either be: true or false.")
|
||||
private volatile boolean allowWeather;
|
||||
@Property(serializor = DifficultyPropertySerializor.class, virtualType = Difficulty.class, persistVirtual = true,
|
||||
description = "Difficulty must be set as one of the following: peaceful easy normal hard")
|
||||
volatile VirtualProperty<Difficulty> difficulty;
|
||||
@Property(description = "Sorry, 'animals' must either be: true or false.")
|
||||
private volatile SpawnSettings spawning;
|
||||
@Property
|
||||
private volatile EntryFee entryfee;
|
||||
@Property(description = "Sorry, 'hunger' must either be: true or false.")
|
||||
private volatile boolean hunger;
|
||||
@Property(description = "Sorry, 'autoheal' must either be: true or false.")
|
||||
private volatile boolean autoHeal;
|
||||
@Property(description = "Sorry, 'adjustspawn' must either be: true or false.")
|
||||
private volatile boolean adjustSpawn;
|
||||
@Property(serializor = EnumPropertySerializor.class, description = "Allow portal forming must be NONE, ALL, NETHER or END.")
|
||||
private volatile AllowedPortalType portalForm;
|
||||
@Property(serializor = GameModePropertySerializor.class, description = "GameMode must be set as one of the following: survival creative")
|
||||
private volatile GameMode gameMode;
|
||||
@Property(description = "Sorry, this must either be: true or false.", virtualType = Boolean.class, persistVirtual = true)
|
||||
volatile VirtualProperty<Boolean> keepSpawnInMemory;
|
||||
@Property
|
||||
volatile SpawnLocation spawnLocation;
|
||||
@Property(virtualType = Location.class,
|
||||
description = "There is no help available for this variable. Go bug Rigby90 about it.")
|
||||
volatile VirtualProperty<Location> spawn;
|
||||
@Property(description = "Set this to false ONLY if you don't want this world to load itself on server restart.")
|
||||
private volatile boolean autoLoad;
|
||||
@Property(description = "If a player dies in this world, shoudld they go to their bed?")
|
||||
private volatile boolean bedRespawn;
|
||||
@Property
|
||||
private volatile List<String> worldBlacklist;
|
||||
@Property(serializor = TimePropertySerializor.class, virtualType = Long.class,
|
||||
description = "Set the time to whatever you want! (Will NOT freeze time)")
|
||||
volatile VirtualProperty<Long> time;
|
||||
@Property
|
||||
volatile Environment environment;
|
||||
@Property
|
||||
volatile long seed;
|
||||
@Property
|
||||
private volatile String generator;
|
||||
@Property
|
||||
private volatile int playerLimit;
|
||||
@Property
|
||||
private volatile boolean allowFlight;
|
||||
// End of properties
|
||||
// --------------------------------------------------------------
|
||||
|
||||
void setValidator(String fieldName, Validator validator) {
|
||||
registerValidator(fieldName, validator); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void copyValues(SerializationConfig other) {
|
||||
super.copyValues(other);
|
||||
}
|
||||
|
||||
/**
|
||||
* This prepares the MVWorld for unloading.
|
||||
*/
|
||||
public void cacheVirtualProperties() {
|
||||
try {
|
||||
this.buildVPropChanges();
|
||||
} catch (IllegalStateException e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void setDefaults() {
|
||||
this.hidden = false;
|
||||
this.alias = new String();
|
||||
this.color = EnglishChatColor.WHITE;
|
||||
this.style = EnglishChatStyle.NORMAL;
|
||||
this.scale = 1D;
|
||||
this.respawnWorld = new String();
|
||||
this.allowWeather = true;
|
||||
this.spawning = new SpawnSettings();
|
||||
this.entryfee = new EntryFee();
|
||||
this.hunger = true;
|
||||
this.autoHeal = true;
|
||||
this.adjustSpawn = true;
|
||||
this.portalForm = AllowedPortalType.ALL;
|
||||
this.gameMode = GameMode.SURVIVAL;
|
||||
this.spawnLocation = new NullLocation();
|
||||
this.autoLoad = true;
|
||||
this.bedRespawn = true;
|
||||
this.worldBlacklist = new ArrayList<String>();
|
||||
this.generator = null;
|
||||
this.playerLimit = -1;
|
||||
this.allowFlight = true;
|
||||
}
|
||||
|
||||
private static double getDefaultScale(Environment environment) {
|
||||
if (environment == Environment.NETHER) {
|
||||
return 8.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
} else if (environment == Environment.THE_END) {
|
||||
return 16.0; // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* getAliases().
|
||||
* @return The alias-map.
|
||||
* @see SerializationConfig
|
||||
*/
|
||||
protected static Map<String, String> getAliases() {
|
||||
return PROPERTY_ALIASES;
|
||||
}
|
||||
|
||||
void flushChanges() {
|
||||
this.flushPendingVPropChanges();
|
||||
}
|
||||
|
||||
String getAlias() {
|
||||
return this.alias;
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
this.setPropertyValueUnchecked("alias", alias);
|
||||
}
|
||||
|
||||
public Environment getEnvironment() {
|
||||
return this.environment;
|
||||
}
|
||||
|
||||
public void setEnvironment(Environment environment) {
|
||||
this.setPropertyValueUnchecked("environment", environment);
|
||||
}
|
||||
|
||||
public long getSeed() {
|
||||
return this.seed;
|
||||
}
|
||||
|
||||
public void setSeed(long seed) {
|
||||
this.setPropertyValueUnchecked("seed", seed);
|
||||
}
|
||||
|
||||
public String getGenerator() {
|
||||
return this.generator;
|
||||
}
|
||||
|
||||
public void setGenerator(String generator) {
|
||||
this.setPropertyValueUnchecked("generator", generator);
|
||||
}
|
||||
|
||||
public int getPlayerLimit() {
|
||||
return this.playerLimit;
|
||||
}
|
||||
|
||||
public void setPlayerLimit(int limit) {
|
||||
this.setPropertyValueUnchecked("playerLimit", limit);
|
||||
}
|
||||
|
||||
public boolean canAnimalsSpawn() {
|
||||
return this.spawning.getAnimalSettings().doSpawn();
|
||||
}
|
||||
|
||||
public void setAllowAnimalSpawn(boolean animals) {
|
||||
this.setPropertyValueUnchecked("spawning.animals.spawn", animals);
|
||||
}
|
||||
|
||||
public List<String> getAnimalList() {
|
||||
// These don't fire events at the moment. Should they?
|
||||
return this.spawning.getAnimalSettings().getExceptions();
|
||||
}
|
||||
|
||||
public boolean canMonstersSpawn() {
|
||||
return this.spawning.getMonsterSettings().doSpawn();
|
||||
}
|
||||
|
||||
public void setAllowMonsterSpawn(boolean monsters) {
|
||||
this.setPropertyValueUnchecked("spawning.monsters.spawn", monsters);
|
||||
}
|
||||
|
||||
public int getAnimalSpawnRate() {
|
||||
return this.spawning.getAnimalSettings().getSpawnRate();
|
||||
}
|
||||
|
||||
public int getMonsterSpawnRate() {
|
||||
return this.spawning.getMonsterSettings().getSpawnRate();
|
||||
}
|
||||
|
||||
public List<String> getMonsterList() {
|
||||
// These don't fire events at the moment. Should they?
|
||||
return this.spawning.getMonsterSettings().getExceptions();
|
||||
}
|
||||
|
||||
public boolean isPVPEnabled() {
|
||||
return this.pvp.get();
|
||||
}
|
||||
|
||||
public void setPVPMode(boolean pvp) {
|
||||
this.setPropertyValueUnchecked("pvp", pvp);
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return this.hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.setPropertyValueUnchecked("hidden", hidden);
|
||||
}
|
||||
|
||||
public List<String> getWorldBlacklist() {
|
||||
return this.worldBlacklist;
|
||||
}
|
||||
|
||||
public double getScaling() {
|
||||
return this.scale;
|
||||
}
|
||||
|
||||
public boolean setScaling(double scaling) {
|
||||
return this.setPropertyValueUnchecked("scale", scaling);
|
||||
}
|
||||
|
||||
public boolean setColor(String aliasColor) {
|
||||
return this.setPropertyUnchecked("color", aliasColor);
|
||||
}
|
||||
|
||||
public boolean setColor(EnglishChatColor color) {
|
||||
return this.setPropertyValueUnchecked("color", color);
|
||||
}
|
||||
|
||||
public EnglishChatColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public String getRespawnToWorld() {
|
||||
return this.respawnWorld;
|
||||
}
|
||||
|
||||
public boolean setRespawnToWorld(String respawnToWorld) {
|
||||
return this.setPropertyValueUnchecked("respawnWorld", respawnToWorld);
|
||||
}
|
||||
|
||||
public int getCurrency() {
|
||||
return this.entryfee.getCurrency();
|
||||
}
|
||||
|
||||
public void setCurrency(int currency) {
|
||||
this.setPropertyValueUnchecked("entryfee.currency", currency);
|
||||
}
|
||||
|
||||
public double getPrice() {
|
||||
return this.entryfee.getAmount();
|
||||
}
|
||||
|
||||
public void setPrice(double price) {
|
||||
this.setPropertyValueUnchecked("entryfee.amount", price);
|
||||
}
|
||||
|
||||
public boolean setGameMode(String mode) {
|
||||
return this.setPropertyUnchecked("gameMode", mode);
|
||||
}
|
||||
|
||||
public boolean setGameMode(GameMode mode) {
|
||||
return this.setPropertyValueUnchecked("gameMode", mode);
|
||||
}
|
||||
|
||||
public GameMode getGameMode() {
|
||||
return this.gameMode;
|
||||
}
|
||||
|
||||
public void setEnableWeather(boolean weather) {
|
||||
this.setPropertyValueUnchecked("allowWeather", weather);
|
||||
}
|
||||
|
||||
public boolean isWeatherEnabled() {
|
||||
return this.allowWeather;
|
||||
}
|
||||
|
||||
public boolean isKeepingSpawnInMemory() {
|
||||
return this.keepSpawnInMemory.get();
|
||||
}
|
||||
|
||||
public void setKeepSpawnInMemory(boolean value) {
|
||||
this.setPropertyValueUnchecked("keepSpawnInMemory", value);
|
||||
}
|
||||
|
||||
public boolean getHunger() {
|
||||
return this.hunger;
|
||||
}
|
||||
|
||||
public void setHunger(boolean hunger) {
|
||||
this.setPropertyValueUnchecked("hunger", hunger);
|
||||
}
|
||||
|
||||
public Location getSpawnLocation() {
|
||||
return this.spawn.get();
|
||||
}
|
||||
|
||||
public void setSpawnLocation(Location l) {
|
||||
this.setPropertyValueUnchecked("spawn", l);
|
||||
}
|
||||
|
||||
public Difficulty getDifficulty() {
|
||||
return this.difficulty.get();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean setDifficulty(String difficulty) {
|
||||
return this.setPropertyUnchecked("difficulty", difficulty);
|
||||
}
|
||||
|
||||
public boolean setDifficulty(Difficulty difficulty) {
|
||||
return this.setPropertyValueUnchecked("difficulty", difficulty);
|
||||
}
|
||||
|
||||
public boolean getAutoHeal() {
|
||||
return this.autoHeal;
|
||||
}
|
||||
|
||||
public void setAutoHeal(boolean heal) {
|
||||
this.setPropertyValueUnchecked("autoHeal", heal);
|
||||
}
|
||||
|
||||
public void setAdjustSpawn(boolean adjust) {
|
||||
this.setPropertyValueUnchecked("adjustSpawn", adjust);
|
||||
}
|
||||
|
||||
public boolean getAdjustSpawn() {
|
||||
return this.adjustSpawn;
|
||||
}
|
||||
|
||||
public void setAutoLoad(boolean load) {
|
||||
this.setPropertyValueUnchecked("autoLoad", load);
|
||||
}
|
||||
|
||||
public boolean getAutoLoad() {
|
||||
return this.autoLoad;
|
||||
}
|
||||
|
||||
public void setBedRespawn(boolean respawn) {
|
||||
this.setPropertyValueUnchecked("bedRespawn", respawn);
|
||||
}
|
||||
|
||||
public boolean getBedRespawn() {
|
||||
return this.bedRespawn;
|
||||
}
|
||||
|
||||
public String getAllPropertyNames() {
|
||||
ChatColor myColor = ChatColor.AQUA;
|
||||
StringBuilder result = new StringBuilder();
|
||||
Map<String, Object> serialized = this.serialize();
|
||||
for (String key : serialized.keySet()) {
|
||||
result.append(myColor).append(key).append(' ');
|
||||
myColor = (myColor == ChatColor.AQUA) ? ChatColor.GOLD : ChatColor.AQUA;
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public String getTime() {
|
||||
return this.getPropertyUnchecked("time");
|
||||
}
|
||||
|
||||
public boolean setTime(String timeAsString) {
|
||||
return this.setPropertyUnchecked("time", timeAsString);
|
||||
}
|
||||
|
||||
public AllowedPortalType getAllowedPortals() {
|
||||
return portalForm;
|
||||
}
|
||||
|
||||
public void allowPortalMaking(AllowedPortalType portalType) {
|
||||
this.setPropertyValueUnchecked("portalForm", portalType);
|
||||
}
|
||||
|
||||
public EnglishChatStyle getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
public boolean setStyle(String style) {
|
||||
return this.setPropertyUnchecked("style", style);
|
||||
}
|
||||
|
||||
public boolean getAllowFlight() {
|
||||
return this.allowFlight;
|
||||
}
|
||||
|
||||
public void setAllowFlight(final boolean allowFlight) {
|
||||
this.setPropertyValueUnchecked("allowFlight", allowFlight);
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,6 @@ public interface BlockSafety {
|
||||
*/
|
||||
boolean playerCanSpawnHereSafely(Location l);
|
||||
|
||||
/**
|
||||
* Gets a safe bed spawn location OR null if the bed is invalid.
|
||||
* @param l The location of the bead head (block with the pillow on it).
|
||||
* @return Safe location around the bed or null if no location was found.
|
||||
*/
|
||||
Location getSafeBedSpawn(Location l);
|
||||
|
||||
/**
|
||||
* Gets the location of the top block at the specified {@link Location}.
|
||||
* @param l Any {@link Location}.
|
||||
|
||||
@@ -7,17 +7,10 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import buscript.Buscript;
|
||||
import com.fernferret.allpay.AllPay;
|
||||
import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.destination.DestinationFactory;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
||||
import com.onarandombox.MultiverseCore.utils.*;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -42,19 +35,9 @@ public interface Core {
|
||||
* Gets the Banking system that Multiverse-Core has hooked into.
|
||||
*
|
||||
* @return A {@link GenericBank} that can be used for payments.
|
||||
* @deprecated Now using vault, see {@link VaultHandler#getEconomy}
|
||||
*/
|
||||
@Deprecated
|
||||
GenericBank getBank();
|
||||
|
||||
/**
|
||||
* Returns the Vault handler used by Multiverse. The returned object will have all methods necessary for
|
||||
* interfacing with Vault.
|
||||
*
|
||||
* @return the Vault handler for Multiverse.
|
||||
*/
|
||||
VaultHandler getVaultHandler();
|
||||
|
||||
/**
|
||||
* Reloads the Multiverse Configuration files:
|
||||
* worlds.yml and config.yml.
|
||||
@@ -145,28 +128,21 @@ public interface Core {
|
||||
* @param seed The seed of the world.
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*
|
||||
* @deprecated Use {@link MVWorldManager#regenWorld(String, boolean, boolean, String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Boolean regenWorld(String name, Boolean useNewSeed, Boolean randomSeed, String seed);
|
||||
|
||||
/**
|
||||
* Sets the {@link GenericBank}-Bank AllPay is using.
|
||||
*
|
||||
* @param bank The new {@link GenericBank}
|
||||
* @deprecated Now using vault, see {@link VaultHandler#getEconomy}
|
||||
*/
|
||||
@Deprecated
|
||||
void setBank(GenericBank bank);
|
||||
|
||||
/**
|
||||
* Gets this plugin's {@link AllPay}-Banker.
|
||||
*
|
||||
* @return An {@link AllPay}-Banker
|
||||
* @deprecated Now using vault, see {@link VaultHandler#getEconomy}
|
||||
*/
|
||||
@Deprecated
|
||||
AllPay getBanker();
|
||||
|
||||
/**
|
||||
@@ -246,11 +222,4 @@ public interface Core {
|
||||
* @return The configuration.
|
||||
*/
|
||||
MultiverseCoreConfig getMVConfig();
|
||||
|
||||
/**
|
||||
* Gets the buscript object for Multiverse. This is what handles Javascript processing.
|
||||
*
|
||||
* @return The Multiverse buscript object.
|
||||
*/
|
||||
Buscript getScriptAPI();
|
||||
}
|
||||
@@ -9,7 +9,6 @@ package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -131,14 +130,6 @@ public interface MVDestination {
|
||||
*/
|
||||
String getRequiredPermission();
|
||||
|
||||
/**
|
||||
* Checks whether the given permissible has the permission to go to this destination.
|
||||
*
|
||||
* @param permissible Whoever we need to check permissions for.
|
||||
* @return True if they are allowed to go to this destination based on permissions.
|
||||
*/
|
||||
boolean hasRequiredPermission(Permissible permissible);
|
||||
|
||||
/**
|
||||
* Should the Multiverse SafeTeleporter be used?
|
||||
* <p>
|
||||
|
||||
@@ -30,14 +30,14 @@ public interface MVPlugin extends LoggablePlugin {
|
||||
/**
|
||||
* Gets the reference to MultiverseCore.
|
||||
*
|
||||
* @return A valid {@link com.onarandombox.MultiverseCore}.
|
||||
* @return A valid {@link MultiverseCore}.
|
||||
*/
|
||||
MultiverseCore getCore();
|
||||
|
||||
/**
|
||||
* Sets the reference to MultiverseCore.
|
||||
*
|
||||
* @param core A valid {@link com.onarandombox.MultiverseCore}.
|
||||
* @param core A valid {@link MultiverseCore}.
|
||||
*/
|
||||
void setCore(MultiverseCore core);
|
||||
|
||||
|
||||
@@ -60,16 +60,6 @@ public interface MVWorldManager {
|
||||
boolean addWorld(String name, Environment env, String seedString, WorldType type, Boolean generateStructures,
|
||||
String generator, boolean useSpawnAdjust);
|
||||
|
||||
/**
|
||||
* Make a copy of a world.
|
||||
*
|
||||
* @param oldName Name of world to be copied
|
||||
* @param newName Name of world to be created
|
||||
* @param generator The Custom generator plugin to use.
|
||||
* @return True if the world is copied successfully, false if not.
|
||||
*/
|
||||
boolean cloneWorld(String oldName, String newName, String generator);
|
||||
|
||||
/**
|
||||
* Remove the world from the Multiverse list, from the
|
||||
* config and deletes the folder.
|
||||
@@ -90,17 +80,6 @@ public interface MVWorldManager {
|
||||
*/
|
||||
boolean deleteWorld(String name, boolean removeConfig);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name The name of the world to remove
|
||||
* @param removeFromConfig If true(default), we'll remove the entries from the
|
||||
* config. If false, they'll stay and the world may come back.
|
||||
* @param deleteWorldFolder If true the world folder will be completely deleted. If false
|
||||
* only the contents of the world folder will be deleted
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder);
|
||||
|
||||
/**
|
||||
* Unload a world from Multiverse.
|
||||
*
|
||||
@@ -266,16 +245,4 @@ public interface MVWorldManager {
|
||||
* @return The {@link MultiverseWorld} new players should spawn in.
|
||||
*/
|
||||
MultiverseWorld getFirstSpawnWorld();
|
||||
|
||||
/**
|
||||
* Regenerates a world.
|
||||
*
|
||||
* @param name Name of the world to regenerate
|
||||
* @param useNewSeed If a new seed should be used
|
||||
* @param randomSeed IF the new seed should be random
|
||||
* @param seed The seed of the world.
|
||||
*
|
||||
* @return True if success, false if fail.
|
||||
*/
|
||||
boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed);
|
||||
}
|
||||
@@ -133,58 +133,4 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
* @return enforceAccess.
|
||||
*/
|
||||
boolean getEnforceAccess();
|
||||
|
||||
/**
|
||||
* Sets useasyncchat.
|
||||
* @param useAsyncChat The new value.
|
||||
*/
|
||||
void setUseAsyncChat(boolean useAsyncChat);
|
||||
|
||||
/**
|
||||
* Gets useasyncchat.
|
||||
* @return useasyncchat.
|
||||
*/
|
||||
boolean getUseAsyncChat();
|
||||
|
||||
/**
|
||||
* Sets whether to suppress startup messages.
|
||||
*
|
||||
* @param silentStart true to suppress messages.
|
||||
*/
|
||||
void setSilentStart(boolean silentStart);
|
||||
|
||||
/**
|
||||
* Whether we are suppressing startup messages.
|
||||
*
|
||||
* @return true if we are suppressing startup messages.
|
||||
*/
|
||||
boolean getSilentStart();
|
||||
|
||||
/**
|
||||
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
|
||||
*
|
||||
* @param useDefaultPortalSearch True to let Bukkit determine portal search radius on its own.
|
||||
*/
|
||||
void setUseDefaultPortalSearch(boolean useDefaultPortalSearch);
|
||||
|
||||
/**
|
||||
* Gets whether or not Bukkit will be determining portal search radius on its own or if Multiverse should help.
|
||||
*
|
||||
* @return True means Bukkit will use its own default values.
|
||||
*/
|
||||
boolean isUsingDefaultPortalSearch();
|
||||
|
||||
/**
|
||||
* Sets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @param searchRadius The portal search radius.
|
||||
*/
|
||||
void setPortalSearchRadius(int searchRadius);
|
||||
|
||||
/**
|
||||
* Gets the radius at which vanilla style portals will be searched for to connect to worlds together.
|
||||
*
|
||||
* @return The portal search radius.
|
||||
*/
|
||||
int getPortalSearchRadius();
|
||||
}
|
||||
@@ -49,6 +49,7 @@ public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
|
||||
}
|
||||
this.setCore(theCore);
|
||||
|
||||
// Turn on Logging
|
||||
this.getServer().getLogger().info(String.format("%s - Version %s enabled - By %s",
|
||||
this.getDescription().getName(), this.getDescription().getVersion(), getAuthors()));
|
||||
getDataFolder().mkdirs();
|
||||
@@ -58,7 +59,7 @@ public abstract class MultiversePlugin extends JavaPlugin implements MVPlugin {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
debugLog = new DebugLog(this.getDescription().getName(), getDataFolder() + File.separator + "debug.log");
|
||||
debugLog = new DebugLog("Multiverse-Adventure", getDataFolder() + File.separator + "debug.log");
|
||||
debugLog.setTag(String.format("[%s-Debug]", this.getDescription().getName()));
|
||||
|
||||
this.onPluginEnable();
|
||||
|
||||
@@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import com.onarandombox.MultiverseCore.enums.AllowedPortalType;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -245,18 +246,14 @@ public interface MultiverseWorld {
|
||||
* Gets the permission required to enter this world.
|
||||
*
|
||||
* @return The permission required to be exempt from charges to/from this world.
|
||||
* @deprecated Now using {@link com.onarandombox.MultiverseCore.utils.Permissions#ACCESS}.
|
||||
*/
|
||||
@Deprecated
|
||||
Permission getAccessPermission();
|
||||
|
||||
/**
|
||||
* Gets the permission required to be exempt when entering.
|
||||
*
|
||||
* @return The permission required to be exempt when entering.
|
||||
* @deprecated Now using {@link com.onarandombox.MultiverseCore.utils.Permissions#COST_EXEMPT}.
|
||||
*/
|
||||
@Deprecated
|
||||
Permission getExemptPermission();
|
||||
// end of permission stuff
|
||||
|
||||
@@ -624,22 +621,6 @@ public interface MultiverseWorld {
|
||||
*/
|
||||
void setBedRespawn(boolean autoLoad);
|
||||
|
||||
/**
|
||||
* Sets the player limit for this world after which players without an override
|
||||
* permission node will not be allowed in. A value of -1 or less signifies no limit
|
||||
*
|
||||
* @param limit The new limit
|
||||
*/
|
||||
void setPlayerLimit(int limit);
|
||||
|
||||
/**
|
||||
* Gets the player limit for this world after which players without an override
|
||||
* permission node will not be allowed in. A value of -1 or less signifies no limit
|
||||
*
|
||||
* @return The player limit
|
||||
*/
|
||||
int getPlayerLimit();
|
||||
|
||||
/**
|
||||
* Same as {@link #getTime()}, but returns a string.
|
||||
* @return The time as a short string: 12:34pm
|
||||
@@ -688,18 +669,4 @@ public interface MultiverseWorld {
|
||||
* @return All property names, with alternating colors.
|
||||
*/
|
||||
String getAllPropertyNames();
|
||||
|
||||
/**
|
||||
* Whether or not players are allowed to fly in this world.
|
||||
*
|
||||
* @return True if players allowed to fly in this world.
|
||||
*/
|
||||
boolean getAllowFlight();
|
||||
|
||||
/**
|
||||
* Sets whether or not players are allowed to fly in this world.
|
||||
*
|
||||
* @param allowFlight True to allow flight in this world.
|
||||
*/
|
||||
void setAllowFlight(final boolean allowFlight);
|
||||
}
|
||||
@@ -3,14 +3,14 @@ package com.onarandombox.MultiverseCore.api;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
/**
|
||||
* Used to remove animals from worlds that don't belong there.
|
||||
*/
|
||||
public interface WorldPurger {
|
||||
|
||||
/**
|
||||
* Synchronizes the given worlds with their settings.
|
||||
* Synchronizes the given world with it's settings.
|
||||
*
|
||||
* @param worlds A list of {@link MultiverseWorld}
|
||||
*/
|
||||
@@ -46,23 +46,4 @@ public interface WorldPurger {
|
||||
void purgeWorld(MultiverseWorld mvworld, List<String> thingsToKill, boolean negateAnimals,
|
||||
boolean negateMonsters, CommandSender sender);
|
||||
|
||||
/**
|
||||
* Determines whether the specified creature should be killed.
|
||||
*
|
||||
* @param e The creature.
|
||||
* @param thingsToKill A {@link List} of animals/monsters to be killed.
|
||||
* @param negateAnimals Whether the monsters in the list should be negated.
|
||||
* @param negateMonsters Whether the animals in the list should be negated.
|
||||
* @return {@code true} if the creature should be killed, otherwise {@code false}.
|
||||
*/
|
||||
boolean shouldWeKillThisCreature(Entity e, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters);
|
||||
|
||||
/**
|
||||
* Determines whether the specified creature should be killed and automatically reads the params from a world object.
|
||||
*
|
||||
* @param w The world.
|
||||
* @param e The creature.
|
||||
* @return {@code true} if the creature should be killed, otherwise {@code false}.
|
||||
*/
|
||||
boolean shouldWeKillThisCreature(MultiverseWorld w, Entity e);
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -35,11 +34,7 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "otherthing");
|
||||
this.addCommandExample("/mv anchor " + ChatColor.GREEN + "awesomething " + ChatColor.RED + "-d");
|
||||
this.addCommandExample("/mv anchors ");
|
||||
this.setPermission("multiverse.core.anchor.list", "Allows a player to list all anchors.", PermissionDefault.OP);
|
||||
this.addAdditonalPermission(new Permission("multiverse.core.anchor.create",
|
||||
"Allows a player to create anchors.", PermissionDefault.OP));
|
||||
this.addAdditonalPermission(new Permission("multiverse.core.anchor.delete",
|
||||
"Allows a player to delete anchors.", PermissionDefault.OP));
|
||||
this.setPermission("multiverse.core.anchor", "Allows management of Anchor Destinations.", PermissionDefault.OP);
|
||||
this.setItemsPerPage(8); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
}
|
||||
|
||||
@@ -54,11 +49,6 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
}
|
||||
|
||||
private void showList(CommandSender sender, List<String> args) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.list", true)) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to list anchors!");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "====[ Multiverse Anchor List ]====");
|
||||
Player p = null;
|
||||
if (sender instanceof Player) {
|
||||
@@ -115,14 +105,10 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
return;
|
||||
}
|
||||
if (args.size() == 2 && args.get(1).equalsIgnoreCase("-d")) {
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.delete", true)) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to delete anchors!");
|
||||
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
|
||||
} else {
|
||||
if (this.plugin.getAnchorManager().deleteAnchor(args.get(0))) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.RED + "deleted!");
|
||||
} else {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
|
||||
}
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "deleted!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -132,16 +118,13 @@ public class AnchorCommand extends PaginatedCoreCommand<String> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.plugin.getMVPerms().hasPermission(sender, "multiverse.core.anchor.create", true)) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have the permission to create anchors!");
|
||||
Player player = (Player) sender;
|
||||
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
|
||||
} else {
|
||||
Player player = (Player) sender;
|
||||
if (this.plugin.getAnchorManager().saveAnchorLocation(args.get(0), player.getLocation())) {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was successfully " + ChatColor.GREEN + "created!");
|
||||
} else {
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
|
||||
}
|
||||
sender.sendMessage("Anchor '" + args.get(0) + "' was " + ChatColor.RED + " NOT " + ChatColor.WHITE + "created!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Creates a clone of a world.
|
||||
*/
|
||||
public class CloneCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
public CloneCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Clone World");
|
||||
this.setCommandUsage("/mv clone" + ChatColor.GREEN + " {TARGET} {NAME}" + ChatColor.GOLD + " -g [GENERATOR[:ID]]");
|
||||
this.setArgRange(2, 4); // SUPPRESS CHECKSTYLE: MagicNumberCheck
|
||||
this.addKey("mvclone");
|
||||
this.addKey("mvcl");
|
||||
this.addKey("mv cl");
|
||||
this.addKey("mv clone");
|
||||
this.addCommandExample("/mv clone " + ChatColor.GOLD + "world" + ChatColor.GREEN + " world_backup");
|
||||
this.addCommandExample("/mv clone " + ChatColor.GOLD + "skyblock_pristine" + ChatColor.GREEN + " skyblock");
|
||||
this.addCommandExample("To clone a world that uses a generator:");
|
||||
this.addCommandExample("/mv clone " + ChatColor.GOLD + "CleanRoom"
|
||||
+ ChatColor.GREEN + " CleanRoomCopy" + ChatColor.DARK_AQUA + " -g CleanRoomGenerator");
|
||||
this.setPermission("multiverse.core.clone", "Clones a world.", PermissionDefault.OP);
|
||||
this.worldManager = this.plugin.getMVWorldManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Class<?>[] paramTypes = {String.class, String.class, String.class};
|
||||
List<Object> objectArgs = new ArrayList<Object>();
|
||||
objectArgs.add(args.get(0));
|
||||
objectArgs.add(args.get(1));
|
||||
objectArgs.add(CommandHandler.getFlag("-g", args));
|
||||
if (!this.worldManager.isMVWorld(args.get(0))) {
|
||||
// If no world was found, we can't clone.
|
||||
sender.sendMessage("Sorry, Multiverse doesn't know about world " + args.get(0) + ", so we can't clone it!");
|
||||
sender.sendMessage("Check the " + ChatColor.GREEN + "/mv list" + ChatColor.WHITE + " command to verify it is listed.");
|
||||
return;
|
||||
}
|
||||
this.plugin.getCommandHandler().queueCommand(sender, "mvclone", "cloneWorld", objectArgs,
|
||||
paramTypes, ChatColor.GREEN + "World Cloned!", ChatColor.RED + "World could NOT be cloned!");
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -67,13 +65,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.worldManager.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.RED + "Multiverse cannot create " + ChatColor.GOLD + ChatColor.UNDERLINE
|
||||
+ "another" + ChatColor.RESET + ChatColor.RED + " world named " + worldName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldFile.exists()) {
|
||||
if (worldFile.exists() || this.worldManager.isMVWorld(worldName)) {
|
||||
sender.sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
|
||||
sender.sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
|
||||
return;
|
||||
@@ -96,19 +88,7 @@ public class CreateCommand extends MultiverseCommand {
|
||||
EnvironmentCommand.showWorldTypes(sender);
|
||||
return;
|
||||
}
|
||||
// Determine if the generator is valid. #918
|
||||
if (generator != null) {
|
||||
List<String> genarray = new ArrayList<String>(Arrays.asList(generator.split(":")));
|
||||
if (genarray.size() < 2) {
|
||||
// If there was only one arg specified, pad with another empty one.
|
||||
genarray.add("");
|
||||
}
|
||||
if (this.worldManager.getChunkGenerator(genarray.get(0), genarray.get(1), "test") == null) {
|
||||
// We have an invalid generator.
|
||||
sender.sendMessage("Invalid generator! '" + generator + "'. " + ChatColor.RED + "Aborting world creation.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Command.broadcastCommandMessage(sender, "Starting creation of world '" + worldName + "'...");
|
||||
|
||||
if (this.worldManager.addWorld(worldName, environment, seed, type, allowStructures, generator, useSpawnAdjust)) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class DebugCommand extends MultiverseCommand {
|
||||
public DebugCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Turn Debug on/off?");
|
||||
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off|silent]");
|
||||
this.setCommandUsage("/mv debug" + ChatColor.GOLD + " [1|2|3|off]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv debug");
|
||||
this.addKey("mv d");
|
||||
@@ -48,18 +48,17 @@ public class DebugCommand extends MultiverseCommand {
|
||||
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE
|
||||
+ " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
||||
}
|
||||
|
||||
}
|
||||
plugin.saveMVConfigs();
|
||||
}
|
||||
this.displayDebugMode(sender);
|
||||
}
|
||||
|
||||
private void displayDebugMode(CommandSender sender) {
|
||||
final int debugLevel = plugin.getMVConfig().getGlobalDebug();
|
||||
if (debugLevel == 0) {
|
||||
if (plugin.getMVConfig().getGlobalDebug() == 0) {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel);
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + plugin.getMVConfig().getGlobalDebug());
|
||||
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ public class EnvironmentCommand extends MultiverseCommand {
|
||||
*/
|
||||
public static void showWorldTypes(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Valid World Types are:");
|
||||
sender.sendMessage(String.format("%sNORMAL%s, %sFLAT, %sLARGEBIOMES %sor %sVERSION_1_1",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, ChatColor.RED, ChatColor.WHITE, ChatColor.GOLD));
|
||||
sender.sendMessage(String.format("%sNORMAL%s, %sFLAT %sor %sVERSION_1_1",
|
||||
ChatColor.GREEN, ChatColor.WHITE, ChatColor.AQUA, ChatColor.WHITE, ChatColor.GOLD));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,9 +75,6 @@ public class EnvironmentCommand extends MultiverseCommand {
|
||||
type = "NORMAL";
|
||||
if (type.equalsIgnoreCase("flat"))
|
||||
type = "FLAT";
|
||||
if (type.equalsIgnoreCase("largebiomes")) {
|
||||
type = "LARGE_BIOMES";
|
||||
}
|
||||
try {
|
||||
// Now that we've converted a potentially unfriendly value
|
||||
// to a friendly one, get it from the ENUM!
|
||||
|
||||
@@ -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.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Allows management of Anchor Destinations.
|
||||
*/
|
||||
public class GameruleCommand extends MultiverseCommand {
|
||||
|
||||
public GameruleCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Set a Minecraft Game Rule for a World.");
|
||||
this.setCommandUsage("/mv gamerule " + ChatColor.GREEN + "{RULE} {VALUE}" + ChatColor.GOLD + " [WORLD]");
|
||||
this.setArgRange(2, 3);
|
||||
this.addKey("mv gamerule");
|
||||
this.addKey("mv rule");
|
||||
this.addKey("mvgamerule");
|
||||
this.addKey("mvrule");
|
||||
this.addCommandExample("/mv gamerule " + ChatColor.GREEN + "doMobLoot false");
|
||||
this.addCommandExample("/mvrule " + ChatColor.GREEN + "keepInventory true " + ChatColor.RED + "world_nether");
|
||||
this.setPermission("multiverse.core.gamerule.set", "Allows a player to set a gamerule.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// We NEED a world from the command line
|
||||
final Player p;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
} else {
|
||||
p = null;
|
||||
}
|
||||
|
||||
if (args.size() == 2 && p == null) {
|
||||
sender.sendMessage("From the command line, WORLD is required.");
|
||||
sender.sendMessage(this.getCommandDesc());
|
||||
sender.sendMessage(this.getCommandUsage());
|
||||
sender.sendMessage("Nothing changed.");
|
||||
return;
|
||||
}
|
||||
|
||||
final String gameRule = args.get(0);
|
||||
final String value = args.get(1);
|
||||
final World world;
|
||||
if (args.size() == 2) {
|
||||
world = p.getWorld();
|
||||
} else {
|
||||
world = Bukkit.getWorld(args.get(2));
|
||||
}
|
||||
|
||||
if (world.setGameRuleValue(gameRule, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule
|
||||
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Failure!" + ChatColor.WHITE + " Gamerule " + ChatColor.AQUA + gameRule
|
||||
+ ChatColor.WHITE + " cannot be set to " + ChatColor.RED + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Allows management of Anchor Destinations.
|
||||
*/
|
||||
public class GamerulesCommand extends MultiverseCommand {
|
||||
|
||||
public GamerulesCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("List the Minecraft Game Rules for a World.");
|
||||
this.setCommandUsage("/mv gamerules" + ChatColor.GOLD + " [WORLD]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv gamerules");
|
||||
this.addKey("mv rules");
|
||||
this.addKey("mvgamerules");
|
||||
this.addKey("mvrules");
|
||||
this.addCommandExample("/mv gamerules");
|
||||
this.addCommandExample("/mvrules " + ChatColor.RED + "world_nether");
|
||||
this.setPermission("multiverse.core.gamerule.list", "Allows a player to list gamerules.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
// We NEED a world from the command line
|
||||
final Player p;
|
||||
if (sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
} else {
|
||||
p = null;
|
||||
}
|
||||
|
||||
if (args.size() == 0 && p == null) {
|
||||
sender.sendMessage("From the command line, WORLD is required.");
|
||||
sender.sendMessage(this.getCommandDesc());
|
||||
sender.sendMessage(this.getCommandUsage());
|
||||
sender.sendMessage("Nothing changed.");
|
||||
return;
|
||||
}
|
||||
|
||||
final World world;
|
||||
if (args.size() == 0) {
|
||||
world = p.getWorld();
|
||||
} else {
|
||||
world = Bukkit.getWorld(args.get(0));
|
||||
}
|
||||
|
||||
final StringBuilder gameRules = new StringBuilder();
|
||||
for (final String gameRule : world.getGameRules()) {
|
||||
if (gameRules.length() != 0) {
|
||||
gameRules.append(ChatColor.WHITE).append(", ");
|
||||
}
|
||||
gameRules.append(ChatColor.AQUA).append(gameRule).append(ChatColor.WHITE).append(": ");
|
||||
gameRules.append(ChatColor.GREEN).append(world.getGameRuleValue(gameRule));
|
||||
}
|
||||
sender.sendMessage("=== Gamerules for " + ChatColor.AQUA + world.getName() + ChatColor.WHITE + " ===");
|
||||
sender.sendMessage(gameRules.toString());
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -16,6 +15,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Returns a list of loaded generator plugins.
|
||||
@@ -37,7 +37,7 @@ public class GeneratorCommand extends MultiverseCommand {
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
Logging.info("PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
|
||||
this.plugin.log(Level.INFO, "PLEASE IGNORE the 'Plugin X does not contain any generators' message below!");
|
||||
Plugin[] plugins = this.plugin.getServer().getPluginManager().getPlugins();
|
||||
List<String> generators = new ArrayList<String>();
|
||||
for (Plugin p : plugins) {
|
||||
|
||||
@@ -122,16 +122,10 @@ public class InfoCommand extends MultiverseCommand {
|
||||
//message.add(new FancyMessage("Game Mode: ", StringUtils.capitalize(world.getGameMode().toString()), colors));
|
||||
Location spawn = world.getSpawnLocation();
|
||||
message.add(new FancyMessage("Spawn Location: ", plugin.getLocationManipulation().strCoords(spawn), colors));
|
||||
message.add(new FancyMessage("World Scale: ", String.valueOf(world.getScaling()), colors));
|
||||
message.add(new FancyMessage("World Seed: ", String.valueOf(world.getSeed()), colors));
|
||||
message.add(new FancyMessage("World Scale: ", world.getScaling() + "", colors));
|
||||
if (world.getPrice() > 0) {
|
||||
final String formattedAmount;
|
||||
if (world.getCurrency() <= 0 && plugin.getVaultHandler().getEconomy() != null) {
|
||||
formattedAmount = plugin.getVaultHandler().getEconomy().format(world.getPrice());
|
||||
} else {
|
||||
formattedAmount = this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency());
|
||||
}
|
||||
message.add(new FancyMessage("Price to enter this world: ", formattedAmount, colors));
|
||||
message.add(new FancyMessage("Price to enter this world: ",
|
||||
this.plugin.getBank().getFormattedAmount(p, world.getPrice(), world.getCurrency()), colors));
|
||||
} else {
|
||||
message.add(new FancyMessage("Price to enter this world: ", ChatColor.GREEN + "FREE!", colors));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.Permissions;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -66,7 +65,7 @@ public class ListCommand extends PaginatedCoreCommand<String> {
|
||||
}
|
||||
}
|
||||
for (String name : this.plugin.getMVWorldManager().getUnloadedWorlds()) {
|
||||
if (p == null || Permissions.ACCESS.hasPermission(p, name)) {
|
||||
if (p == null || this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + name, true)) {
|
||||
worldList.add(ChatColor.GRAY + name + " - UNLOADED");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,9 +85,6 @@ public class ModifyAddCommand extends MultiverseCommand {
|
||||
if (world.addToVariable(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA
|
||||
+ value + ChatColor.WHITE + " was " + ChatColor.GREEN + "added to " + ChatColor.GREEN + property);
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(value + " could not be added to " + property);
|
||||
}
|
||||
|
||||
@@ -80,9 +80,6 @@ public class ModifyClearCommand extends MultiverseCommand {
|
||||
sender.sendMessage(property + " was cleared. It contains 0 values now.");
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + property + ChatColor.WHITE + " was "
|
||||
+ ChatColor.GREEN + "CLEARED" + ChatColor.WHITE + ". It contains " + ChatColor.LIGHT_PURPLE + "0" + ChatColor.WHITE + " values now.");
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Error: " + ChatColor.GOLD + property
|
||||
+ ChatColor.WHITE + " was " + ChatColor.GOLD + "NOT" + ChatColor.WHITE + " cleared.");
|
||||
|
||||
@@ -85,9 +85,6 @@ public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
if (world.removeFromVariable(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success! " + ChatColor.AQUA + value + ChatColor.WHITE
|
||||
+ " was " + ChatColor.RED + "removed from " + ChatColor.GREEN + property);
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "There was an error removing " + ChatColor.GRAY
|
||||
+ value + ChatColor.WHITE + " from " + ChatColor.GOLD + property);
|
||||
|
||||
@@ -111,9 +111,6 @@ public class ModifySetCommand extends MultiverseCommand {
|
||||
if (world.setPropertyValue(property, value)) {
|
||||
sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property
|
||||
+ ChatColor.WHITE + " was set to " + ChatColor.GREEN + value);
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + world.getPropertyHelp(property));
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* States who is in what world.
|
||||
*/
|
||||
public class ScriptCommand extends MultiverseCommand {
|
||||
|
||||
public ScriptCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Runs a script.");
|
||||
this.setCommandUsage("/mv script" + ChatColor.GOLD + " {script} [target]");
|
||||
this.setArgRange(1, 2);
|
||||
this.addKey("mv script");
|
||||
this.addKey("mvscript");
|
||||
this.addCommandExample(String.format("/mv script %sscript.txt", ChatColor.GOLD));
|
||||
this.addCommandExample(String.format("/mv script %stest.txt %ssomeplayer", ChatColor.GOLD, ChatColor.GREEN));
|
||||
this.setPermission("multiverse.core.script", "Runs a script.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
File file = new File(plugin.getScriptAPI().getScriptFolder(), args.get(0));
|
||||
if (!file.exists()) {
|
||||
sender.sendMessage("That script file does not exist in the Multiverse-Core scripts directory!");
|
||||
return;
|
||||
}
|
||||
Player player = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
}
|
||||
String target = null;
|
||||
if (args.size() == 2) {
|
||||
target = args.get(1);
|
||||
}
|
||||
plugin.getScriptAPI().executeScript(file, target, player);
|
||||
sender.sendMessage(String.format("Script '%s%s%s' finished!", ChatColor.GOLD, file.getName(), ChatColor.WHITE));
|
||||
}
|
||||
}
|
||||
@@ -64,9 +64,6 @@ public class SetSpawnCommand extends MultiverseCommand {
|
||||
foundWorld.setAdjustSpawn(false);
|
||||
}
|
||||
sender.sendMessage("Spawn was set to: " + plugin.getLocationManipulation().strCoords(p.getLocation()));
|
||||
if (!plugin.saveWorldConfig()) {
|
||||
sender.sendMessage(ChatColor.RED + "There was an issue saving worlds.yml! Your changes will only be temporary!");
|
||||
}
|
||||
} 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).");
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Enables debug-information.
|
||||
*/
|
||||
public class SilentCommand extends MultiverseCommand {
|
||||
|
||||
public SilentCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Turn silent mode on/off?");
|
||||
this.setCommandUsage("/mv silent" + ChatColor.GOLD + " [true|false|on|off]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv silent");
|
||||
this.addKey("mvsilent");
|
||||
this.addCommandExample("/mv silent " + ChatColor.GOLD + "true");
|
||||
this.setPermission("multiverse.core.silent", "Reduces the amount of startup messages.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("on")) {
|
||||
args.set(0, "true");
|
||||
}
|
||||
plugin.getMVConfig().setSilentStart(Boolean.valueOf(args.get(0)));
|
||||
plugin.saveMVConfigs();
|
||||
}
|
||||
this.displaySilentMode(sender);
|
||||
}
|
||||
|
||||
private void displaySilentMode(CommandSender sender) {
|
||||
if (plugin.getMVConfig().getSilentStart()) {
|
||||
sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.GREEN + "ON");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Silent Start mode is " + ChatColor.RED + "OFF");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.event.MVVersionEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.webpaste.BitlyURLShortener;
|
||||
@@ -16,12 +15,14 @@ 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;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Dumps version info to the console.
|
||||
@@ -51,15 +52,9 @@ public class VersionCommand extends MultiverseCommand {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("[Multiverse-Core] Multiverse-Core Version: ").append(this.plugin.getDescription().getVersion()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Bukkit Version: ").append(this.plugin.getServer().getVersion()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Loaded Worlds: ").append(this.plugin.getMVWorldManager().getMVWorlds()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Loaded Worlds: ").append(this.plugin.getMVWorldManager().getMVWorlds().size()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Multiverse Plugins Loaded: ").append(this.plugin.getPluginCount()).append('\n');
|
||||
final boolean usingVault = plugin.getVaultHandler().getEconomy() != null;
|
||||
buffer.append("[Multiverse-Core] Using Vault: ").append(usingVault).append('\n');
|
||||
if (usingVault) {
|
||||
buffer.append("[Multiverse-Core] Economy being used: ").append(plugin.getVaultHandler().getEconomy().getName()).append('\n');
|
||||
} else {
|
||||
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
|
||||
}
|
||||
buffer.append("[Multiverse-Core] Economy being used: ").append(this.plugin.getBank().getEconUsed()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Permissions Plugin: ").append(this.plugin.getMVPerms().getType()).append('\n');
|
||||
buffer.append("[Multiverse-Core] Dumping Config Values: (version ")
|
||||
.append(this.plugin.getMVConfig().getVersion()).append(")").append('\n');
|
||||
@@ -81,7 +76,7 @@ public class VersionCommand extends MultiverseCommand {
|
||||
final String data = versionEvent.getVersionInfo();
|
||||
String[] lines = data.split("\n");
|
||||
for (String line : lines) {
|
||||
Logging.info(line);
|
||||
this.plugin.log(Level.INFO, line);
|
||||
}
|
||||
|
||||
this.plugin.getServer().getScheduler().scheduleAsyncDelayedTask(this.plugin, new Runnable() {
|
||||
@@ -98,7 +93,7 @@ public class VersionCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
sender.sendMessage("Version info dumped here: " + ChatColor.GREEN + pasteUrl);
|
||||
Logging.info("Version info dumped here: %s", pasteUrl);
|
||||
plugin.log(Level.INFO, "Version info dumped here: " + pasteUrl);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,8 +15,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -52,14 +50,6 @@ public class WhoCommand extends MultiverseCommand {
|
||||
showAll = false;
|
||||
}
|
||||
|
||||
final Player[] onlinePlayers = plugin.getServer().getOnlinePlayers();
|
||||
final Collection<Player> visiblePlayers = new HashSet<Player>(onlinePlayers.length);
|
||||
for (final Player player : onlinePlayers) {
|
||||
if (p == null || p.canSee(player)) {
|
||||
visiblePlayers.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("--all") || args.get(0).equalsIgnoreCase("-a")) {
|
||||
showAll = true;
|
||||
@@ -78,19 +68,18 @@ public class WhoCommand extends MultiverseCommand {
|
||||
|
||||
sender.sendMessage(String.format("%s--- Players in %s%s ---", ChatColor.AQUA,
|
||||
world.getColoredWorldString(), ChatColor.AQUA));
|
||||
sender.sendMessage(this.buildPlayerString(world, p, visiblePlayers));
|
||||
sender.sendMessage(buildPlayerString(world, p));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// multiworld mode
|
||||
sender.sendMessage(ChatColor.AQUA + "--- Worlds and their players --- "
|
||||
+ visiblePlayers.size() + "/" + plugin.getServer().getMaxPlayers());
|
||||
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, p, visiblePlayers)));
|
||||
sender.sendMessage(String.format("%s%s - %s", world.getColoredWorldString(), ChatColor.WHITE, buildPlayerString(world, p)));
|
||||
shownOne = true;
|
||||
}
|
||||
}
|
||||
@@ -101,18 +90,18 @@ public class WhoCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
private static String buildPlayerString(MultiverseWorld world, Player viewer, final Collection<Player> visiblePlayers) {
|
||||
// Retrieve the players in this world
|
||||
private static String buildPlayerString(MultiverseWorld world, Player viewer) {
|
||||
List<Player> players = world.getCBWorld().getPlayers();
|
||||
StringBuilder playerBuilder = new StringBuilder();
|
||||
for (Player player : players) {
|
||||
// If the viewer is the console or the viewier is allowed to see the player, show them.
|
||||
// Make sure we're also ONLY showing online players.
|
||||
// Since we already checked visible players, we'll just make sure who we're about to show is in that.
|
||||
if (visiblePlayers.contains(player))
|
||||
playerBuilder.append(player.getDisplayName()).append(", ");
|
||||
if (players.size() == 0) {
|
||||
return "No players found.";
|
||||
} else {
|
||||
StringBuilder playerBuilder = new StringBuilder();
|
||||
for (Player player : players) {
|
||||
if ((viewer == null) || viewer.canSee(player))
|
||||
playerBuilder.append(player.getDisplayName()).append(", ");
|
||||
}
|
||||
String bString = playerBuilder.toString();
|
||||
return bString.substring(0, bString.length() - 2);
|
||||
}
|
||||
String bString = playerBuilder.toString();
|
||||
return (bString.length() == 0) ? "No players found." : bString.substring(0, bString.length() - 2);
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,6 @@ public class SubSpawnSettings extends SerializationConfig {
|
||||
@Property
|
||||
private boolean spawn;
|
||||
@Property
|
||||
private int spawnrate;
|
||||
@Property
|
||||
private List<String> exceptions;
|
||||
|
||||
public SubSpawnSettings() {
|
||||
@@ -36,7 +34,6 @@ public class SubSpawnSettings extends SerializationConfig {
|
||||
public void setDefaults() {
|
||||
spawn = true;
|
||||
exceptions = new ArrayList<String>();
|
||||
spawnrate = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,23 +51,9 @@ public class SubSpawnSettings extends SerializationConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The exceptions
|
||||
* @return the exceptions
|
||||
*/
|
||||
public List<String> getExceptions() {
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rate The new spawn rate
|
||||
*/
|
||||
public void setSpawnRate(int rate) {
|
||||
this.spawnrate = rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The spawn rate
|
||||
*/
|
||||
public int getSpawnRate() {
|
||||
return this.spawnrate;
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,8 @@ package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.utils.Permissions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -136,15 +134,7 @@ public class AnchorDestination implements MVDestination {
|
||||
*/
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
return Permissions.ACCESS.getName(this.location.getWorld().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasRequiredPermission(Permissible permissible) {
|
||||
return Permissions.ACCESS.hasPermission(permissible, this.location.getWorld().getName());
|
||||
return "multiverse.access." + this.location.getWorld().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,14 +7,10 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.utils.Permissions;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -25,7 +21,6 @@ public class BedDestination implements MVDestination {
|
||||
|
||||
private boolean isValid;
|
||||
private Location knownBedLoc;
|
||||
private MultiverseCore plugin;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -51,10 +46,7 @@ public class BedDestination implements MVDestination {
|
||||
@Override
|
||||
public Location getLocation(Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
this.knownBedLoc = this.plugin.getBlockSafety().getSafeBedSpawn(((Player) entity).getBedSpawnLocation());
|
||||
if (this.knownBedLoc == null) {
|
||||
((Player) entity).sendMessage("Your bed was " + ChatColor.RED + "invalid or blocked" + ChatColor.RESET + ". Sorry.");
|
||||
}
|
||||
this.knownBedLoc = ((Player) entity).getBedSpawnLocation();
|
||||
return this.knownBedLoc;
|
||||
}
|
||||
return null;
|
||||
@@ -73,7 +65,7 @@ public class BedDestination implements MVDestination {
|
||||
*/
|
||||
@Override
|
||||
public void setDestination(JavaPlugin plugin, String destination) {
|
||||
this.plugin = (MultiverseCore) plugin;
|
||||
// Not needed.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,22 +98,11 @@ public class BedDestination implements MVDestination {
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
if (knownBedLoc != null) {
|
||||
return Permissions.ACCESS.getName(knownBedLoc.getWorld().getName());
|
||||
return "multiverse.access." + knownBedLoc.getWorld().getName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasRequiredPermission(Permissible permissible) {
|
||||
if (knownBedLoc != null) {
|
||||
Permissions.ACCESS.hasPermission(permissible, knownBedLoc.getWorld().getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -9,10 +9,8 @@ package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.utils.Permissions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -207,15 +205,7 @@ public class CannonDestination implements MVDestination {
|
||||
*/
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
return Permissions.ACCESS.getName(this.location.getWorld().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasRequiredPermission(Permissible permissible) {
|
||||
return Permissions.ACCESS.hasPermission(permissible, this.location.getWorld().getName());
|
||||
return "multiverse.access." + this.location.getWorld().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,10 +9,8 @@ package com.onarandombox.MultiverseCore.destination;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVDestination;
|
||||
import com.onarandombox.MultiverseCore.utils.Permissions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -210,15 +208,7 @@ public class ExactDestination implements MVDestination {
|
||||
*/
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
return Permissions.ACCESS.getName(this.location.getWorld().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasRequiredPermission(Permissible permissible) {
|
||||
return Permissions.ACCESS.hasPermission(permissible, this.location.getWorld().getName());
|
||||
return "multiverse.access." + this.location.getWorld().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,10 +11,8 @@ 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.Permissions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -151,15 +149,9 @@ public class WorldDestination implements MVDestination {
|
||||
*/
|
||||
@Override
|
||||
public String getRequiredPermission() {
|
||||
return Permissions.ACCESS.getName(this.world.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean hasRequiredPermission(Permissible permissible) {
|
||||
return Permissions.ACCESS.hasPermission(permissible, this.world.getName());
|
||||
// TODO: Potenitally replace spaces wiht tabs for friendlier yaml.
|
||||
// this.world.getName().replace(" ","_");
|
||||
return "multiverse.access." + this.world.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
/**
|
||||
* A wrapper for the {@link AsyncPlayerChatEvent}.
|
||||
*/
|
||||
public class AsyncChatEvent implements ChatEvent {
|
||||
private final AsyncPlayerChatEvent event;
|
||||
|
||||
public AsyncChatEvent(AsyncPlayerChatEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return event.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return event.getFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFormat(String s) {
|
||||
event.setFormat(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return event.getPlayer();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* A wrapper for the two chat-events in Bukkit.
|
||||
*/
|
||||
public interface ChatEvent {
|
||||
/**
|
||||
* @return Whether this event is cancelled.
|
||||
*/
|
||||
boolean isCancelled();
|
||||
|
||||
/**
|
||||
* @return The format.
|
||||
*/
|
||||
String getFormat();
|
||||
|
||||
/**
|
||||
* Sets the format.
|
||||
* @param s The new format.
|
||||
*/
|
||||
void setFormat(String s);
|
||||
|
||||
/**
|
||||
* @return The player.
|
||||
*/
|
||||
Player getPlayer();
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
/**
|
||||
* Multiverse's {@link org.bukkit.event.Listener} for players.
|
||||
*/
|
||||
public class MVAsyncPlayerChatListener extends MVChatListener {
|
||||
public MVAsyncPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
|
||||
super(plugin, playerListener);
|
||||
plugin.log(Level.FINE, "Created AsyncPlayerChatEvent listener.");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when a player wants to chat.
|
||||
* @param event The Event that was fired.
|
||||
*/
|
||||
@EventHandler
|
||||
public void playerChat(AsyncPlayerChatEvent event) {
|
||||
this.playerChat(new AsyncChatEvent(event));
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* Multiverse's {@link org.bukkit.event.Listener} for players.
|
||||
*/
|
||||
public abstract class MVChatListener implements Listener {
|
||||
private final MultiverseCore plugin;
|
||||
private final MVWorldManager worldManager;
|
||||
private final MVPlayerListener playerListener;
|
||||
|
||||
public MVChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
|
||||
this.plugin = plugin;
|
||||
this.worldManager = plugin.getMVWorldManager();
|
||||
this.playerListener = playerListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* This handles a {@link ChatEvent}.
|
||||
* @param event The {@link ChatEvent}.
|
||||
*/
|
||||
public void playerChat(ChatEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
// Check whether the Server is set to prefix the chat with the World name.
|
||||
// If not we do nothing, if so we need to check if the World has an Alias.
|
||||
if (plugin.getMVConfig().getPrefixChat()) {
|
||||
String world = playerListener.getPlayerWorld().get(event.getPlayer().getName());
|
||||
if (world == null) {
|
||||
world = event.getPlayer().getWorld().getName();
|
||||
playerListener.getPlayerWorld().put(event.getPlayer().getName(), world);
|
||||
}
|
||||
String prefix = "";
|
||||
// If we're not a MV world, don't do anything
|
||||
if (!this.worldManager.isMVWorld(world)) {
|
||||
return;
|
||||
}
|
||||
MultiverseWorld mvworld = this.worldManager.getMVWorld(world);
|
||||
if (mvworld.isHidden()) {
|
||||
return;
|
||||
}
|
||||
prefix = mvworld.getColoredWorldString();
|
||||
String format = event.getFormat();
|
||||
event.setFormat("[" + prefix + "]" + format);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,13 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
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.EntityType;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Squid;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
@@ -21,12 +26,14 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Multiverse's Entity {@link Listener}.
|
||||
*/
|
||||
public class MVEntityListener implements Listener {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
private MVWorldManager worldManager;
|
||||
|
||||
@@ -80,8 +87,7 @@ public class MVEntityListener implements Listener {
|
||||
public void creatureSpawn(CreatureSpawnEvent event) {
|
||||
// Check to see if the Creature is spawned by a plugin, we don't want to prevent this behaviour.
|
||||
// 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
|
||||
|| event.getSpawnReason() == SpawnReason.BREEDING) {
|
||||
if (event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -94,6 +100,8 @@ public class MVEntityListener implements Listener {
|
||||
return;
|
||||
|
||||
EntityType type = event.getEntityType();
|
||||
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
|
||||
|
||||
/**
|
||||
* Handle people with non-standard animals: ie a patched craftbukkit.
|
||||
*/
|
||||
@@ -102,8 +110,43 @@ public class MVEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
MultiverseWorld mvworld = this.worldManager.getMVWorld(world.getName());
|
||||
event.setCancelled(this.plugin.getMVWorldManager().getTheWorldPurger().shouldWeKillThisCreature(mvworld, event.getEntity()));
|
||||
/**
|
||||
* Animal Handling
|
||||
*/
|
||||
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.isCancelled() && (event.getEntity() instanceof Monster || event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime)) {
|
||||
event.setCancelled(shouldWeKillThisCreature(mvworld.getMonsterList(), mvworld.canMonstersSpawn(), type.getName().toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
} else if (creatureList.isEmpty()) {
|
||||
// 2. There are no exceptions and animals are NOT allowed. Kill it.
|
||||
return true;
|
||||
} else if (creatureList.contains(creature.toUpperCase()) && allowCreatureSpawning) {
|
||||
// 3. There ARE exceptions and animals ARE allowed. Kill it.
|
||||
return true;
|
||||
} else if (!creatureList.contains(creature.toUpperCase()) && allowCreatureSpawning) {
|
||||
// 4. There ARE exceptions and animals ARE NOT allowed. SAVE it.
|
||||
return false;
|
||||
} else if (creatureList.contains(creature.toUpperCase()) && !allowCreatureSpawning) {
|
||||
// 5. No animals are allowed to be spawned, BUT this one can stay...
|
||||
return false;
|
||||
} else if (!creatureList.contains(creature.toUpperCase()) && !allowCreatureSpawning) {
|
||||
// 6. Animals are NOT allowed to spawn, and this creature is not in the save list... KILL IT
|
||||
return true;
|
||||
} else {
|
||||
// This code should NEVER execute. I just left the verbose conditions in right now.
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.MapInitializeEvent;
|
||||
import org.bukkit.map.MapView;
|
||||
|
||||
/**
|
||||
* A listener for bukkit map events.
|
||||
*/
|
||||
public class MVMapListener implements Listener {
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
|
||||
public MVMapListener(final MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void mapInitialize(final MapInitializeEvent event) {
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
if ((player.getItemInHand().getType() == Material.MAP
|
||||
|| player.getItemInHand().getType() == Material.EMPTY_MAP)
|
||||
&& player.getItemInHand().getDurability() == event.getMap().getId()) {
|
||||
final Location playerLoc = player.getLocation();
|
||||
final MapView map = event.getMap();
|
||||
map.setCenterX(playerLoc.getBlockX());
|
||||
map.setCenterZ(playerLoc.getBlockZ());
|
||||
map.setWorld(playerLoc.getWorld());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
|
||||
* Multiverse 2 is licensed under the BSD License. *
|
||||
* For more information please check the README.md file included *
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
/**
|
||||
* Multiverse's {@link org.bukkit.event.Listener} for players.
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // this exists only for downwards compatibility
|
||||
public class MVPlayerChatListener extends MVChatListener {
|
||||
public MVPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
|
||||
super(plugin, playerListener);
|
||||
plugin.log(Level.FINE, "Registered PlayerChatEvent listener.");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when a player wants to chat.
|
||||
* @param event The Event that was fired.
|
||||
*/
|
||||
@EventHandler
|
||||
public void playerChat(PlayerChatEvent event) {
|
||||
this.playerChat(new NormalChatEvent(event));
|
||||
}
|
||||
}
|
||||
@@ -7,14 +7,11 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
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.Permissions;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -24,37 +21,55 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Multiverse's {@link Listener} for players.
|
||||
*/
|
||||
public class MVPlayerListener implements Listener {
|
||||
private final MultiverseCore plugin;
|
||||
private final MVWorldManager worldManager;
|
||||
private final PermissionTools pt;
|
||||
private MultiverseCore plugin;
|
||||
private MVWorldManager worldManager;
|
||||
private PermissionTools pt;
|
||||
|
||||
private final Map<String, String> playerWorld = new ConcurrentHashMap<String, String>();
|
||||
|
||||
public MVPlayerListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
worldManager = plugin.getMVWorldManager();
|
||||
pt = new PermissionTools(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the playerWorld-map
|
||||
* This method is called when a player wants to chat.
|
||||
* @param event The Event that was fired.
|
||||
*/
|
||||
public Map<String, String> getPlayerWorld() {
|
||||
return playerWorld;
|
||||
@EventHandler
|
||||
public void playerChat(PlayerChatEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
// Check whether the Server is set to prefix the chat with the World name.
|
||||
// If not we do nothing, if so we need to check if the World has an Alias.
|
||||
if (plugin.getMVConfig().getPrefixChat()) {
|
||||
String world = event.getPlayer().getWorld().getName();
|
||||
String prefix = "";
|
||||
// If we're not a MV world, don't do anything
|
||||
if (!this.worldManager.isMVWorld(world)) {
|
||||
return;
|
||||
}
|
||||
MultiverseWorld mvworld = this.worldManager.getMVWorld(world);
|
||||
if (mvworld.isHidden()) {
|
||||
return;
|
||||
}
|
||||
prefix = mvworld.getColoredWorldString();
|
||||
String format = event.getFormat();
|
||||
event.setFormat("[" + prefix + "]" + format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,14 +136,13 @@ public class MVPlayerListener implements Listener {
|
||||
} else {
|
||||
this.plugin.log(Level.FINER, "Player joined AGAIN!");
|
||||
if (this.plugin.getMVConfig().getEnforceAccess() // check this only if we're enforcing access!
|
||||
&& !Permissions.ACCESS.hasPermission(p, p.getWorld().getName())) {
|
||||
&& !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.handleGameModeAndFlight(event.getPlayer(), event.getPlayer().getWorld());
|
||||
playerWorld.put(p.getName(), p.getWorld().getName());
|
||||
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,8 +152,7 @@ public class MVPlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void playerChangedWorld(PlayerChangedWorldEvent event) {
|
||||
// Permissions now determine whether or not to handle a gamemode.
|
||||
this.handleGameModeAndFlight(event.getPlayer(), event.getPlayer().getWorld());
|
||||
playerWorld.put(event.getPlayer().getName(), event.getPlayer().getWorld().getName());
|
||||
this.handleGameMode(event.getPlayer(), event.getPlayer().getWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,38 +208,20 @@ public class MVPlayerListener implements Listener {
|
||||
+ "' don't have the FUNDS required to enter it.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if player is allowed to enter the world if we're enforcing permissions
|
||||
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
|
||||
if (event.isCancelled() && teleporter != null) {
|
||||
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
|
||||
+ "' was DENIED ACCESS to '" + toWorld.getAlias()
|
||||
+ "' because '" + teleporter.getName() + "' don't have: "
|
||||
+ Permissions.ACCESS.getName(event.getTo().getWorld().getName()));
|
||||
return;
|
||||
+ "' because '" + teleporter.getName()
|
||||
+ "' don't have: multiverse.access." + event.getTo().getWorld().getName());
|
||||
} else {
|
||||
this.stateSuccess(teleportee.getName(), toWorld.getAlias());
|
||||
}
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
|
||||
+ "' was allowed to go to '" + toWorld.getAlias() + "' because enforceaccess is off.");
|
||||
}
|
||||
|
||||
// Does a limit actually exist?
|
||||
if (toWorld.getPlayerLimit() > -1) {
|
||||
// Are there equal or more people on the world than the limit?
|
||||
if (toWorld.getCBWorld().getPlayers().size() >= toWorld.getPlayerLimit()) {
|
||||
// Ouch the world is full, lets see if the player can bypass that limitation
|
||||
if (!pt.playerCanBypassPlayerLimit(toWorld, teleporter, teleportee)) {
|
||||
Logging.fine("Player '%s' was DENIED ACCESS to '%s' because the world is full and '%s' doesn't have: %s.%s",
|
||||
teleportee.getName(), toWorld.getAlias(), teleporter.getName(),
|
||||
Permissions.BYPASS_PLAYERLIMIT.getName(), event.getTo().getWorld().getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// By this point anything cancelling the event has returned on the method, meaning the teleport is a success \o/
|
||||
this.stateSuccess(teleportee.getName(), toWorld.getAlias());
|
||||
}
|
||||
|
||||
private void stateSuccess(String playerName, String worldName) {
|
||||
@@ -290,27 +285,21 @@ public class MVPlayerListener implements Listener {
|
||||
if (plugin.getMVConfig().getEnforceAccess()) {
|
||||
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
|
||||
if (event.isCancelled()) {
|
||||
//
|
||||
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName()
|
||||
+ "' was DENIED ACCESS to '" + event.getTo().getWorld().getName()
|
||||
+ "' because they don't have: "
|
||||
+ Permissions.ACCESS.getName(event.getTo().getWorld().getName()));
|
||||
+ "' because they don't have: multiverse.access." + event.getTo().getWorld().getName());
|
||||
}
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName()
|
||||
+ "' was allowed to go to '" + event.getTo().getWorld().getName()
|
||||
+ "' because enforceaccess is off.");
|
||||
}
|
||||
if (!plugin.getMVConfig().isUsingDefaultPortalSearch()) {
|
||||
event.getPortalTravelAgent().setSearchRadius(plugin.getMVConfig().getPortalSearchRadius());
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
@@ -318,13 +307,13 @@ public class MVPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
// FOLLOWING 2 Methods and Private class handle Per Player GameModes.
|
||||
private void handleGameModeAndFlight(Player player, World world) {
|
||||
private void handleGameMode(Player player, World world) {
|
||||
|
||||
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
|
||||
if (mvWorld != null) {
|
||||
this.handleGameModeAndFlight(player, mvWorld);
|
||||
this.handleGameMode(player, mvWorld);
|
||||
} else {
|
||||
this.plugin.log(Level.FINER, "Not handling gamemode and flight for world '" + world.getName()
|
||||
this.plugin.log(Level.FINER, "Not handling gamemode for world '" + world.getName()
|
||||
+ "' not managed by Multiverse.");
|
||||
}
|
||||
}
|
||||
@@ -334,41 +323,30 @@ public class MVPlayerListener implements Listener {
|
||||
* @param player The {@link Player}.
|
||||
* @param world The world the player is in.
|
||||
*/
|
||||
public void handleGameModeAndFlight(final Player player, final MultiverseWorld world) {
|
||||
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.
|
||||
if (!this.pt.playerCanIgnoreGameModeRestriction(world, player)) {
|
||||
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()) {
|
||||
Logging.fine("Handling gamemode for player: %s, Changing to %s", player.getName(), world.getGameMode().toString());
|
||||
Logging.finest("From World: %s", player.getWorld());
|
||||
Logging.finest("To World: %s", world);
|
||||
MultiverseCore.staticLog(Level.FINE, "Handling gamemode for player: "
|
||||
+ player.getName() + ", Changing to " + world.getGameMode().toString());
|
||||
MultiverseCore.staticLog(Level.FINEST, "From World: " + player.getWorld());
|
||||
MultiverseCore.staticLog(Level.FINEST, "To World: " + world);
|
||||
player.setGameMode(world.getGameMode());
|
||||
} else {
|
||||
Logging.fine("The gamemode was NOT changed for player '%s' because he is now in world '%s' instead of world '%s'",
|
||||
player.getName(), player.getWorld().getName(), world.getName());
|
||||
MultiverseCore.staticLog(Level.FINE, "The gamemode was NOT changed for player '"
|
||||
+ player.getName() + "' because he is now in world '"
|
||||
+ player.getWorld().getName() + "' instead of world '"
|
||||
+ world.getName() +"'");
|
||||
}
|
||||
}
|
||||
}, 1L);
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Player: " + player.getName() + " is IMMUNE to gamemode changes!");
|
||||
}
|
||||
// TODO need a override permission for this
|
||||
if (player.getAllowFlight() && !world.getAllowFlight() && player.getGameMode() != GameMode.CREATIVE) {
|
||||
if (!this.pt.playerCanIgnoreAllowFlightRestriction(world, player)) {
|
||||
player.setAllowFlight(false);
|
||||
if (player.isFlying()) {
|
||||
player.setFlying(false);
|
||||
}
|
||||
}
|
||||
} else if (world.getAllowFlight()) {
|
||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||
player.setAllowFlight(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,6 @@ public class MVPluginListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void pluginEnable(PluginEnableEvent event) {
|
||||
if (plugin.getVaultHandler().getEconomy() != null) {
|
||||
// Don't hook 2 economy plugins.
|
||||
return;
|
||||
}
|
||||
// Let AllPay handle all econ plugin loadings, only go for econ plugins we support
|
||||
if (Arrays.asList(AllPay.getValidEconPlugins()).contains(event.getPlugin().getDescription().getName())) {
|
||||
this.plugin.setBank(this.plugin.getBanker().loadEconPlugin());
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
/**
|
||||
* A wrapper for the {@link PlayerChatEvent}.
|
||||
* @deprecated This is deprecated like the {@link PlayerChatEvent}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class NormalChatEvent implements ChatEvent {
|
||||
private final PlayerChatEvent event;
|
||||
|
||||
public NormalChatEvent(PlayerChatEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return event.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormat() {
|
||||
return event.getFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFormat(String s) {
|
||||
event.setFormat(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return event.getPlayer();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -17,6 +16,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -50,10 +50,10 @@ public class AnchorManager {
|
||||
//world:x,y,z:pitch:yaw
|
||||
Location anchorLocation = plugin.getLocationManipulation().stringToLocation(anchorsSection.getString(key, ""));
|
||||
if (anchorLocation != null) {
|
||||
Logging.config("Loading anchor: '%s'...", key);
|
||||
MultiverseCore.staticLog(Level.INFO, "Loading anchor: '" + key + "'...");
|
||||
this.anchors.put(key, anchorLocation);
|
||||
} else {
|
||||
Logging.warning("The location for anchor '%s' is INVALID.", key);
|
||||
MultiverseCore.staticLog(Level.WARNING, "The location for anchor '" + key + "' is INVALID.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public class AnchorManager {
|
||||
if (ancLoc == null) {
|
||||
continue;
|
||||
}
|
||||
if (Permissions.ACCESS.hasPermission(p, ancLoc.getWorld().getName())) {
|
||||
if (p.hasPermission("multiverse.access." + ancLoc.getWorld().getName())) {
|
||||
myAnchors.add(anchor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,15 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Used to determine block/location-related facts.
|
||||
*
|
||||
@@ -73,28 +75,28 @@ public class BlockSafety {
|
||||
|
||||
if (this.isSolidBlock(world.getBlockAt(actual).getType())
|
||||
|| this.isSolidBlock(upOne.getBlock().getType())) {
|
||||
Logging.finest("Error Here (Actual)? (%s)[%s]", actual.getBlock().getType(),
|
||||
this.isSolidBlock(actual.getBlock().getType()));
|
||||
Logging.finest("Error Here (upOne)? (%s)[%s]", upOne.getBlock().getType(),
|
||||
this.isSolidBlock(upOne.getBlock().getType()));
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here (Actual)? ("
|
||||
+ actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here (upOne)? ("
|
||||
+ upOne.getBlock().getType() + ")[" + this.isSolidBlock(upOne.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
|
||||
Logging.finest("Error Here (downOne)? (%s)[%s]", downOne.getBlock().getType(),
|
||||
this.isSolidBlock(downOne.getBlock().getType()));
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here (downOne)? ("
|
||||
+ downOne.getBlock().getType() + ")[" + this.isSolidBlock(downOne.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (downOne.getBlock().getType() == Material.FIRE) {
|
||||
Logging.finest("There's fire below! (%s)[%s]", actual.getBlock().getType(),
|
||||
this.isSolidBlock(actual.getBlock().getType()));
|
||||
MultiverseCore.staticLog(Level.FINER, "There's fire below! ("
|
||||
+ actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isBlockAboveAir(actual)) {
|
||||
Logging.finest("Is block above air [%s]", isBlockAboveAir(actual));
|
||||
Logging.finest("Has 2 blocks of water below [%s]", this.hasTwoBlocksofWaterBelow(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;
|
||||
|
||||
@@ -24,9 +24,7 @@ import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* The Multiverse debug-logger.
|
||||
* @deprecated Deprecated in favor of new Logging lib. See {@link com.dumptruckman.minecraft.util.Logging}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DebugLog extends Logger {
|
||||
private FileHandler fh;
|
||||
private Logger standardLog = null;
|
||||
@@ -81,11 +79,11 @@ public class DebugLog extends Logger {
|
||||
* @param msg the message.
|
||||
*/
|
||||
@Override
|
||||
public void log(final Level level, final String msg) {
|
||||
public void log(Level level, String msg) {
|
||||
if (MultiverseCoreConfiguration.isSet() && MultiverseCoreConfiguration.getInstance().getGlobalDebug() > 0) {
|
||||
// only redirect to standardLog if it's lower than INFO so we don't log that twice!
|
||||
if ((level.intValue() < Level.INFO.intValue()) && (standardLog != null)) {
|
||||
standardLog.log(Level.INFO, prefix + msg);
|
||||
standardLog.log(level, prefix + msg);
|
||||
}
|
||||
|
||||
super.log(level, prefix + msg);
|
||||
|
||||
@@ -8,13 +8,6 @@
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* File-utilities.
|
||||
@@ -44,79 +37,4 @@ public class FileUtils {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to delete the contents of a folder, without deleting the folder itself.
|
||||
*
|
||||
* @param file The folder whose contents to delete.
|
||||
* @return true if the contents were successfully deleted
|
||||
*/
|
||||
public static boolean deleteFolderContents(File file) {
|
||||
if (file.exists()) {
|
||||
boolean ret = true;
|
||||
// If the file exists, and it has more than one file in it.
|
||||
if (file.isDirectory()) {
|
||||
for (File f : file.listFiles()) {
|
||||
ret = ret && deleteFolder(f);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final int COPY_BLOCK_SIZE = 1024;
|
||||
|
||||
/**
|
||||
* Helper method to copy the world-folder.
|
||||
* @param source Source-File
|
||||
* @param target Target-File
|
||||
* @param log A logger that logs the operation
|
||||
*
|
||||
* @return if it had success
|
||||
*/
|
||||
public static boolean copyFolder(File source, File target, Logger log) {
|
||||
InputStream in = null;
|
||||
OutputStream out = null;
|
||||
try {
|
||||
if (source.isDirectory()) {
|
||||
|
||||
if (!target.exists())
|
||||
target.mkdir();
|
||||
|
||||
String[] children = source.list();
|
||||
// for (int i=0; i<children.length; i++) {
|
||||
for (String child : children) {
|
||||
copyFolder(new File(source, child), new File(target, child), log);
|
||||
}
|
||||
} else {
|
||||
in = new FileInputStream(source);
|
||||
out = new FileOutputStream(target);
|
||||
|
||||
byte[] buf = new byte[COPY_BLOCK_SIZE];
|
||||
int len;
|
||||
while ((len = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (FileNotFoundException e) {
|
||||
log.warning("Exception while copying file: " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
log.warning("Exception while copying file: " + e.getMessage());
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException ignore) { }
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,17 @@ public class MVPermissions implements PermissionsInterface {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 canIgnoreGameModeRestriction(Player p, MultiverseWorld w) {
|
||||
return p.hasPermission("mv.bypass.gamemode." + w.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Player can teleport to the Destination world from there current world.
|
||||
*
|
||||
@@ -65,10 +76,6 @@ public class MVPermissions implements PermissionsInterface {
|
||||
* @return Whether the {@link CommandSender} can travel to the specified {@link Location}.
|
||||
*/
|
||||
public boolean canTravelFromLocation(CommandSender sender, Location location) {
|
||||
// Now The Bed destination can return null now.
|
||||
if (location == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
@@ -92,7 +99,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
this.plugin.log(Level.FINEST, "EnforceAccess is OFF. Player was allowed in " + w.getAlias());
|
||||
return true;
|
||||
}
|
||||
return Permissions.ACCESS.hasPermission(p, w.getName());
|
||||
return this.hasPermission(p, "multiverse.access." + w.getName(), false);
|
||||
}
|
||||
|
||||
private boolean canEnterLocation(Player p, Location l) {
|
||||
@@ -103,7 +110,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
if (!this.plugin.getMVWorldManager().isMVWorld(worldName)) {
|
||||
return false;
|
||||
}
|
||||
return Permissions.ACCESS.hasPermission(p, worldName);
|
||||
return this.hasPermission(p, "multiverse.access." + worldName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +137,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
if (!canEnterLocation(p, d.getLocation(p))) {
|
||||
return false;
|
||||
}
|
||||
return d.hasRequiredPermission(p);
|
||||
return this.hasPermission(p, d.getRequiredPermission(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,14 +173,14 @@ public class MVPermissions implements PermissionsInterface {
|
||||
ChatColor.DARK_AQUA, ChatColor.WHITE));
|
||||
cango = false;
|
||||
}
|
||||
if (!Permissions.ACCESS.hasPermission(p, worldName)) {
|
||||
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, Permissions.ACCESS.getName(worldName), ChatColor.WHITE,
|
||||
ChatColor.GREEN, "multiverse.access." + worldName, ChatColor.WHITE,
|
||||
ChatColor.DARK_AQUA, d.getName(), ChatColor.WHITE));
|
||||
cango = false;
|
||||
}
|
||||
if (d.hasRequiredPermission(p)) {
|
||||
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,
|
||||
|
||||
@@ -140,43 +140,20 @@ public class PermissionTools {
|
||||
return true;
|
||||
}
|
||||
// If the player does not have to pay, return now.
|
||||
if (Permissions.COST_EXEMPT.hasPermission(teleporter, toWorld.getName())) {
|
||||
if (this.plugin.getMVPerms().hasPermission(teleporter, toWorld.getExemptPermission().getName(), true)) {
|
||||
return true;
|
||||
}
|
||||
final boolean usingVault;
|
||||
final String formattedAmount;
|
||||
if (toWorld.getCurrency() <= 0 && plugin.getVaultHandler().getEconomy() != null) {
|
||||
usingVault = true;
|
||||
formattedAmount = plugin.getVaultHandler().getEconomy().format(toWorld.getPrice());
|
||||
} else {
|
||||
usingVault = false;
|
||||
formattedAmount = this.plugin.getBank().getFormattedAmount(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency());
|
||||
}
|
||||
String errString = "You need " + formattedAmount + " to send " + teleportee + " to " + toWorld.getColoredWorldString();
|
||||
GenericBank bank = plugin.getBank();
|
||||
String errString = "You need " + bank.getFormattedAmount(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency())
|
||||
+ " to send " + teleportee + " to " + toWorld.getColoredWorldString();
|
||||
if (teleportee.equals(teleporter)) {
|
||||
errString = "You need " + formattedAmount + " to enter " + toWorld.getColoredWorldString();
|
||||
errString = "You need " + bank.getFormattedAmount(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency())
|
||||
+ " to enter " + toWorld.getColoredWorldString();
|
||||
}
|
||||
if (usingVault) {
|
||||
if (!plugin.getVaultHandler().getEconomy().has(teleporterPlayer.getName(), toWorld.getPrice())) {
|
||||
return false;
|
||||
} else if (pay) {
|
||||
if (toWorld.getPrice() < 0D) {
|
||||
plugin.getVaultHandler().getEconomy().depositPlayer(teleporterPlayer.getName(), toWorld.getPrice() * -1D);
|
||||
} else {
|
||||
plugin.getVaultHandler().getEconomy().withdrawPlayer(teleporterPlayer.getName(), toWorld.getPrice());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GenericBank bank = plugin.getBank();
|
||||
if (!bank.hasEnough(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency(), errString)) {
|
||||
return false;
|
||||
} else if (pay) {
|
||||
if (toWorld.getPrice() < 0D) {
|
||||
bank.give(teleporterPlayer, toWorld.getPrice() * -1D, toWorld.getCurrency());
|
||||
} else {
|
||||
bank.take(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency());
|
||||
}
|
||||
}
|
||||
if (!bank.hasEnough(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency(), errString)) {
|
||||
return false;
|
||||
} else if (pay) {
|
||||
bank.give(teleporterPlayer, toWorld.getPrice(), toWorld.getCurrency());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -258,31 +235,6 @@ public class PermissionTools {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a player can bypass the player limit.
|
||||
*
|
||||
* @param toWorld The world travelling to.
|
||||
* @param teleporter The player that initiated the teleport.
|
||||
* @param teleportee The player travelling.
|
||||
* @return True if they can bypass the player limit.
|
||||
*/
|
||||
public boolean playerCanBypassPlayerLimit(MultiverseWorld toWorld, CommandSender teleporter, Player teleportee) {
|
||||
if (teleporter == null) {
|
||||
teleporter = teleportee;
|
||||
}
|
||||
|
||||
if (!(teleporter instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Permissions.BYPASS_PLAYERLIMIT.hasPermission(teleportee, toWorld.getName())) {
|
||||
return true;
|
||||
} else {
|
||||
teleporter.sendMessage("The world " + toWorld.getColoredWorldString() + " is full");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a player should bypass game mode restrictions.
|
||||
*
|
||||
@@ -292,24 +244,7 @@ public class PermissionTools {
|
||||
*/
|
||||
public boolean playerCanIgnoreGameModeRestriction(MultiverseWorld toWorld, Player teleportee) {
|
||||
if (toWorld != null) {
|
||||
return Permissions.BYPASS_GAMEMODE.hasPermission(teleportee, toWorld.getName());
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Permissions.BYPASS_ALLOWFLY.hasPermission(teleportee, toWorld.getName());
|
||||
return this.plugin.getMVPerms().canIgnoreGameModeRestriction(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.
|
||||
|
||||
@@ -1,182 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.pluginbase.permission.BukkitPerm;
|
||||
import com.dumptruckman.minecraft.pluginbase.permission.BukkitPermFactory;
|
||||
import com.dumptruckman.minecraft.pluginbase.permission.PermDefault;
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
|
||||
public class Permissions {
|
||||
|
||||
// ============ Multiverse Bypass Permissions ============
|
||||
|
||||
private static final BukkitPerm MV = BukkitPermFactory.newBukkitPerm(Core.class, "mv.*")
|
||||
.def(PermDefault.FALSE).build();
|
||||
|
||||
private static final BukkitPerm BYPASS_ALL = BukkitPermFactory.newBukkitPerm(Core.class, "mv.bypass.*")
|
||||
.def(PermDefault.FALSE).parent(MV).build();
|
||||
|
||||
private static final BukkitPerm BYPASS_GAMEMODE_ALL = BukkitPermFactory.newBukkitPerm(Core.class,
|
||||
"mv.bypass.gamemode.*").desc("Allows a player to ignore gamemode changes for all worlds.")
|
||||
.def(PermDefault.FALSE).parent(BYPASS_ALL).build();
|
||||
|
||||
private static final BukkitPerm BYPASS_PLAYERLIMIT_ALL = BukkitPermFactory.newBukkitPerm(Core.class,
|
||||
"mv.bypass.playerlimit.*").desc("Allows a player to ignore the player limit for all worlds.")
|
||||
.def(PermDefault.FALSE).parent(BYPASS_ALL).build();
|
||||
|
||||
private static final BukkitPerm BYPASS_ALLOWFLY_ALL = BukkitPermFactory.newBukkitPerm(Core.class,
|
||||
"mv.bypass.allowfly.*").desc("Allows a player to ignore the flight restrictions for all worlds.")
|
||||
.def(PermDefault.FALSE).parent(BYPASS_ALL).build();
|
||||
|
||||
/** Used for bypassing the gamemode of specific worlds. */
|
||||
public static final BukkitPerm BYPASS_GAMEMODE = BukkitPermFactory.newBukkitPerm(Core.class,
|
||||
"mv.bypass.gamemode").desc("Allows a player to ignore gamemode changes for a specific world.")
|
||||
.specificOnly().def(PermDefault.FALSE).parent(BYPASS_GAMEMODE_ALL).build();
|
||||
|
||||
/** Used for bypassing the player limit of specific worlds. */
|
||||
public static final BukkitPerm BYPASS_PLAYERLIMIT = BukkitPermFactory.newBukkitPerm(Core.class,
|
||||
"mv.bypass.playerlimit").desc("Allows a player to ignore the player limit for a specific world.")
|
||||
.specificOnly().def(PermDefault.FALSE).parent(BYPASS_PLAYERLIMIT_ALL).build();
|
||||
|
||||
/** Used for bypassing the allow fly setting of specific worlds. */
|
||||
public static final BukkitPerm BYPASS_ALLOWFLY = BukkitPermFactory.newBukkitPerm(Core.class,
|
||||
"mv.bypass.allowfly").desc("Allows a player to ignore the flight restrictions for a specific world.")
|
||||
.specificOnly().def(PermDefault.FALSE).parent(BYPASS_ALLOWFLY_ALL).build();
|
||||
|
||||
|
||||
// ============ Multiverse World Permissions ============
|
||||
|
||||
private static final BukkitPerm ACCESS_ALL = BukkitPermFactory.newBukkitPerm(Core.class, "access.*")
|
||||
.desc("Allows a player to access all worlds.")
|
||||
.usePluginName().addToAll().build();
|
||||
|
||||
private static final BukkitPerm COST_EXEMPT_ALL = BukkitPermFactory.newBukkitPerm(Core.class, "exempt.*")
|
||||
.desc("Allows a player to bypass the costs for worlds and MV portals.")
|
||||
.usePluginName().addToAll().build();
|
||||
|
||||
public static final BukkitPerm ACCESS = BukkitPermFactory.newBukkitPerm(Core.class, "access")
|
||||
.desc("Allows a player to access a specific world.")
|
||||
.usePluginName().specificOnly().parent(ACCESS_ALL).build();
|
||||
|
||||
public static final BukkitPerm COST_EXEMPT = BukkitPermFactory.newBukkitPerm(Core.class, "exempt")
|
||||
.desc("Allows a player to bypass the costs for a specific world and MV portals in that world.")
|
||||
.usePluginName().specificOnly().parent(COST_EXEMPT_ALL).build();
|
||||
|
||||
|
||||
// ============ Multiverse Teleport Permissions ============
|
||||
|
||||
private static final BukkitPerm TELEPORT_ALL = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.*")
|
||||
.desc("Allows the player to use all forms of teleportation.")
|
||||
.usePluginName().addToAll().build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_SELF_ALL = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.*")
|
||||
.desc("Allows the player to use all forms of self teleportation.")
|
||||
.usePluginName().parent(TELEPORT_ALL).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_OTHER_ALL = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.*")
|
||||
.desc("Allows the player to use all forms of teleportation on other players.")
|
||||
.usePluginName().parent(TELEPORT_ALL).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_SELF_WORLD = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.w")
|
||||
.desc("Allows the player to teleport self to any world.")
|
||||
.usePluginName().parent(TELEPORT_SELF_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_SELF_WORLD = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.w")
|
||||
.desc("Allows the player to teleport self to a specific world.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_SELF_WORLD).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_SELF_ANCHOR = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.a")
|
||||
.desc("Allows the player to teleport self to any anchor.")
|
||||
.usePluginName().parent(TELEPORT_SELF_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_SELF_ANCHOR = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.a")
|
||||
.desc("Allows the player to teleport self to a specific anchor.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_SELF_ANCHOR).build();
|
||||
|
||||
public static final BukkitPerm TP_SELF_EXACT = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.e")
|
||||
.desc("Allows the player to teleport self to an exact location.")
|
||||
.usePluginName().parent(TELEPORT_SELF_ALL).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_SELF_PLAYER = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.pl")
|
||||
.desc("Allows the player to teleport self to any player.")
|
||||
.usePluginName().parent(TELEPORT_SELF_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_SELF_PLAYER = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.pl")
|
||||
.desc("Allows the player to teleport self to a specific player.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_SELF_PLAYER).build();
|
||||
|
||||
public static final BukkitPerm TP_SELF_CANNON = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.ca")
|
||||
.desc("Allows the player to teleport self to cannon.")
|
||||
.usePluginName().parent(TELEPORT_SELF_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_SELF_BED = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.b")
|
||||
.desc("Allows the player to teleport self to their bed.")
|
||||
.usePluginName().parent(TELEPORT_SELF_ALL).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_SELF_PORTAL = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.p")
|
||||
.desc("Allows the player to teleport self to any MV portal.")
|
||||
.usePluginName().parent(TELEPORT_SELF_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_SELF_PORTAL = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.p")
|
||||
.desc("Allows the player to teleport self to a specific MV portal.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_SELF_PORTAL).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_SELF_OPENWARP = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.ow")
|
||||
.desc("Allows the player to teleport self to any OpenWarp destination.")
|
||||
.usePluginName().parent(TELEPORT_SELF_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_SELF_OPENWARP = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.self.ow")
|
||||
.desc("Allows the player to teleport self to a specific OpenWarp destination.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_SELF_OPENWARP).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_OTHER_WORLD = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.w")
|
||||
.desc("Allows the player to teleport other to any world.")
|
||||
.usePluginName().parent(TELEPORT_OTHER_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_OTHER_WORLD = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.w")
|
||||
.desc("Allows the player to teleport other to a specific world.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_OTHER_WORLD).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_OTHER_ANCHOR = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.a")
|
||||
.desc("Allows the player to teleport other to any anchor.")
|
||||
.usePluginName().parent(TELEPORT_OTHER_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_OTHER_ANCHOR = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.a")
|
||||
.desc("Allows the player to teleport other to a specific anchor.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_OTHER_ANCHOR).build();
|
||||
|
||||
public static final BukkitPerm TP_OTHER_EXACT = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.e")
|
||||
.desc("Allows the player to teleport other to an exact location.")
|
||||
.usePluginName().parent(TELEPORT_OTHER_ALL).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_OTHER_PLAYER = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.pl")
|
||||
.desc("Allows the player to teleport other to any player.")
|
||||
.usePluginName().parent(TELEPORT_OTHER_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_OTHER_PLAYER = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.pl")
|
||||
.desc("Allows the player to teleport other to a specific player.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_OTHER_PLAYER).build();
|
||||
|
||||
public static final BukkitPerm TP_OTHER_CANNON = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.ca")
|
||||
.desc("Allows the player to teleport other to cannon.")
|
||||
.usePluginName().parent(TELEPORT_OTHER_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_OTHER_BED = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.b")
|
||||
.desc("Allows the player to teleport other to their bed.")
|
||||
.usePluginName().parent(TELEPORT_OTHER_ALL).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_OTHER_PORTAL = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.p")
|
||||
.desc("Allows the player to teleport other to any MV portal.")
|
||||
.usePluginName().parent(TELEPORT_OTHER_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_OTHER_PORTAL = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.p")
|
||||
.desc("Allows the player to teleport other to a specific MV portal.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_OTHER_PORTAL).build();
|
||||
|
||||
private static final BukkitPerm TELEPORT_OTHER_OPENWARP = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.ow")
|
||||
.desc("Allows the player to teleport other to any OpenWarp destination.")
|
||||
.usePluginName().parent(TELEPORT_OTHER_ALL).build();
|
||||
|
||||
public static final BukkitPerm TP_OTHER_OPENWARP = BukkitPermFactory.newBukkitPerm(Core.class, "teleport.other.ow")
|
||||
.desc("Allows the player to teleport other to a specific OpenWarp destination.")
|
||||
.usePluginName().specificOnly().parent(TELEPORT_OTHER_OPENWARP).build();
|
||||
}
|
||||
@@ -7,38 +7,23 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
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.block.BlockFace;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.material.Bed;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* The default-implementation of {@link BlockSafety}.
|
||||
*/
|
||||
public class SimpleBlockSafety implements BlockSafety {
|
||||
private final Core plugin;
|
||||
private static final Set<BlockFace> AROUND_BLOCK = EnumSet.noneOf(BlockFace.class);
|
||||
|
||||
static {
|
||||
AROUND_BLOCK.add(BlockFace.NORTH);
|
||||
AROUND_BLOCK.add(BlockFace.NORTH_EAST);
|
||||
AROUND_BLOCK.add(BlockFace.EAST);
|
||||
AROUND_BLOCK.add(BlockFace.SOUTH_EAST);
|
||||
AROUND_BLOCK.add(BlockFace.SOUTH);
|
||||
AROUND_BLOCK.add(BlockFace.SOUTH_WEST);
|
||||
AROUND_BLOCK.add(BlockFace.WEST);
|
||||
AROUND_BLOCK.add(BlockFace.NORTH_WEST);
|
||||
}
|
||||
|
||||
public SimpleBlockSafety(Core plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -82,88 +67,33 @@ public class SimpleBlockSafety implements BlockSafety {
|
||||
|
||||
if (isSolidBlock(world.getBlockAt(actual).getType())
|
||||
|| isSolidBlock(upOne.getBlock().getType())) {
|
||||
Logging.finer("Error Here (Actual)? (%s)[%s]", actual.getBlock().getType(),
|
||||
isSolidBlock(actual.getBlock().getType()));
|
||||
Logging.finer("Error Here (upOne)? (%s)[%s]", upOne.getBlock().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) {
|
||||
Logging.finer("Error Here (downOne)? (%s)[%s]", downOne.getBlock().getType(), isSolidBlock(downOne.getBlock().getType()));
|
||||
MultiverseCore.staticLog(Level.FINER, "Error Here (downOne)? ("
|
||||
+ downOne.getBlock().getType() + ")[" + isSolidBlock(downOne.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (downOne.getBlock().getType() == Material.FIRE) {
|
||||
Logging.finer("There's fire below! (%s)[%s]", actual.getBlock().getType(), isSolidBlock(actual.getBlock().getType()));
|
||||
MultiverseCore.staticLog(Level.FINER, "There's fire below! ("
|
||||
+ actual.getBlock().getType() + ")[" + isSolidBlock(actual.getBlock().getType()) + "]");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isBlockAboveAir(actual)) {
|
||||
Logging.finer("Is block above air [%s]", isBlockAboveAir(actual));
|
||||
Logging.finer("Has 2 blocks of water below [%s]", this.hasTwoBlocksofWaterBelow(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 getSafeBedSpawn(Location l) {
|
||||
// The passed location, may be null (if the bed is invalid)
|
||||
if (l == null) {
|
||||
return null;
|
||||
}
|
||||
final Location trySpawn = this.getSafeSpawnAroundABlock(l);
|
||||
if (trySpawn != null) {
|
||||
return trySpawn;
|
||||
}
|
||||
Location otherBlock = this.findOtherBedPiece(l);
|
||||
if (otherBlock == null) {
|
||||
return null;
|
||||
}
|
||||
// Now we have 2 locations, check around each, if the type is bed, skip it.
|
||||
return this.getSafeSpawnAroundABlock(otherBlock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a safe spawn around a location. (N,S,E,W,NE,NW,SE,SW)
|
||||
* @param l Location to check around
|
||||
* @return A safe location, or none if it wasn't found.
|
||||
*/
|
||||
private Location getSafeSpawnAroundABlock(Location l) {
|
||||
Iterator<BlockFace> checkblock = AROUND_BLOCK.iterator();
|
||||
while (checkblock.hasNext()) {
|
||||
final BlockFace face = checkblock.next();
|
||||
if (this.playerCanSpawnHereSafely(l.getBlock().getRelative(face).getLocation())) {
|
||||
// Don't forget to center the player.
|
||||
return l.getBlock().getRelative(face).getLocation().add(.5, 0, .5);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the other bed block.
|
||||
* @param checkLoc The location to check for the other piece at
|
||||
* @return The location of the other bed piece, or null if it was a jacked up bed.
|
||||
*/
|
||||
private Location findOtherBedPiece(Location checkLoc) {
|
||||
if (checkLoc.getBlock().getType() != Material.BED_BLOCK) {
|
||||
return null;
|
||||
}
|
||||
// Construct a bed object at this location
|
||||
final Bed b = new Bed(Material.BED_BLOCK, checkLoc.getBlock().getData());
|
||||
if (b.isHeadOfBed()) {
|
||||
return checkLoc.getBlock().getRelative(b.getFacing().getOppositeFace()).getLocation();
|
||||
}
|
||||
// We shouldn't ever be looking at the foot, but here's the code for it.
|
||||
return checkLoc.getBlock().getRelative(b.getFacing()).getLocation();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -7,26 +7,23 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
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.Golem;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Squid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Utility class that removes animals from worlds that don't belong there.
|
||||
@@ -65,16 +62,6 @@ public class SimpleWorldPurger implements WorldPurger {
|
||||
purgeWorld(world, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldWeKillThisCreature(MultiverseWorld world, Entity e) {
|
||||
ArrayList<String> allMobs = new ArrayList<String>(world.getAnimalList());
|
||||
allMobs.addAll(world.getMonsterList());
|
||||
return this.shouldWeKillThisCreature(e, allMobs, !world.canAnimalsSpawn(), !world.canMonstersSpawn());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -88,97 +75,61 @@ public class SimpleWorldPurger implements WorldPurger {
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
int projectilesKilled = 0;
|
||||
int entitiesKilled = 0;
|
||||
boolean specifiedAll = thingsToKill.contains("ALL");
|
||||
boolean specifiedAnimals = thingsToKill.contains("ANIMALS") || specifiedAll;
|
||||
boolean specifiedMonsters = thingsToKill.contains("MONSTERS") || specifiedAll;
|
||||
List<Entity> worldEntities = world.getEntities();
|
||||
List<LivingEntity> livingEntities = new ArrayList<LivingEntity>(worldEntities.size());
|
||||
List<Projectile> projectiles = new ArrayList<Projectile>(worldEntities.size());
|
||||
for (final Entity e : worldEntities) {
|
||||
if (e instanceof Projectile) {
|
||||
final Projectile p = (Projectile) e;
|
||||
if (p.getShooter() != null) {
|
||||
projectiles.add((Projectile) e);
|
||||
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;
|
||||
}
|
||||
} else if (e instanceof LivingEntity) {
|
||||
livingEntities.add((LivingEntity) e);
|
||||
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 (final LivingEntity e : livingEntities) {
|
||||
if (killDecision(e, thingsToKill, negateAnimals, negateMonsters, specifiedAnimals, specifiedMonsters)) {
|
||||
final Iterator<Projectile> it = projectiles.iterator();
|
||||
while (it.hasNext()) {
|
||||
final Projectile p = it.next();
|
||||
if (p.getShooter().equals(e)) {
|
||||
p.remove();
|
||||
it.remove();
|
||||
projectilesKilled++;
|
||||
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() + "' along with " + projectilesKilled + " projectiles that belonged to them.");
|
||||
sender.sendMessage(entitiesKilled + " entities purged from the world '" + world.getName() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean killDecision(Entity e, List<String> thingsToKill, boolean negateAnimals,
|
||||
boolean negateMonsters, boolean specifiedAnimals, boolean specifiedMonsters) {
|
||||
boolean negate = false;
|
||||
boolean specified = false;
|
||||
if (e instanceof Golem || e instanceof Squid || e instanceof Animals) {
|
||||
// it's an animal
|
||||
if (specifiedAnimals && !negateAnimals) {
|
||||
Logging.finest("Removing an entity because I was told to remove all animals in world %s: %s", e.getWorld().getName(), e);
|
||||
return true;
|
||||
}
|
||||
if (specifiedAnimals)
|
||||
specified = true;
|
||||
negate = negateAnimals;
|
||||
} else if (e instanceof Monster || e instanceof Ghast || e instanceof Slime) {
|
||||
// it's a monster
|
||||
if (specifiedMonsters && !negateMonsters) {
|
||||
Logging.finest("Removing an entity because I was told to remove all monsters in world %s: %s", e.getWorld().getName(), e);
|
||||
return true;
|
||||
}
|
||||
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) {
|
||||
Logging.finest("Removing an entity because it WAS specified and we are NOT negating in world %s: %s", e.getWorld().getName(), e);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!specified && negate) {
|
||||
Logging.finest("Removing an entity because it was NOT specified and we ARE negating in world %s: %s", e.getWorld().getName(), e);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldWeKillThisCreature(Entity e, List<String> thingsToKill, boolean negateAnimals, boolean negateMonsters) {
|
||||
boolean specifiedAll = thingsToKill.contains("ALL");
|
||||
boolean specifiedAnimals = thingsToKill.contains("ANIMALS") || specifiedAll;
|
||||
boolean specifiedMonsters = thingsToKill.contains("MONSTERS") || specifiedAll;
|
||||
return this.killDecision(e, thingsToKill, negateAnimals, negateMonsters, specifiedAnimals, specifiedMonsters);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -89,7 +87,7 @@ public class UpdateChecker {
|
||||
int compare = v1.compareTo(v2);
|
||||
|
||||
if (compare > 0) {
|
||||
Logging.info("[%s] - Update Available (%s)", this.name, version);
|
||||
log.info("[" + this.name + "]" + " - Update Available (" + version + ")");
|
||||
}
|
||||
|
||||
rd.close();
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
/**
|
||||
* A class we use to interface with Vault when it is present.
|
||||
*/
|
||||
public class VaultHandler implements Listener {
|
||||
|
||||
private Economy economy;
|
||||
|
||||
public VaultHandler(final Plugin plugin) {
|
||||
Bukkit.getPluginManager().registerEvents(new VaultListener(), plugin);
|
||||
setupVaultEconomy();
|
||||
}
|
||||
|
||||
private boolean setupVaultEconomy() {
|
||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
|
||||
final RegisteredServiceProvider<Economy> economyProvider =
|
||||
Bukkit.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
Logging.fine("Vault economy enabled.");
|
||||
economy = economyProvider.getProvider();
|
||||
} else {
|
||||
Logging.finer("Vault economy not detected.");
|
||||
economy = null;
|
||||
}
|
||||
} else {
|
||||
Logging.finer("Vault was not found.");
|
||||
economy = null;
|
||||
}
|
||||
|
||||
return (economy != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Listens for Vault plugin events.
|
||||
*/
|
||||
private class VaultListener implements Listener {
|
||||
@EventHandler
|
||||
private void vaultEnabled(PluginEnableEvent event) {
|
||||
if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) {
|
||||
setupVaultEconomy();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void vaultDisabled(PluginDisableEvent event) {
|
||||
if (event.getPlugin() != null && event.getPlugin().getName().equals("Vault")) {
|
||||
Logging.fine("Vault economy disabled");
|
||||
setupVaultEconomy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Vault economy system if Vault is present and has an economy system enabled.
|
||||
*
|
||||
* @return The vault economy system or null if not configured.
|
||||
*/
|
||||
public Economy getEconomy() {
|
||||
return economy;
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,14 @@
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import com.onarandombox.MultiverseCore.MVWorld;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.WorldProperties;
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
|
||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
@@ -27,6 +24,8 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
@@ -37,29 +36,26 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Public facing API to add/remove Multiverse worlds.
|
||||
*/
|
||||
public class WorldManager implements MVWorldManager {
|
||||
private final MultiverseCore plugin;
|
||||
private final WorldPurger worldPurger;
|
||||
private final Map<String, MultiverseWorld> worlds;
|
||||
private Map<String, WorldProperties> worldsFromTheConfig;
|
||||
private MultiverseCore plugin;
|
||||
private WorldPurger worldPurger;
|
||||
private Map<String, MVWorld> worldsFromTheConfig;
|
||||
private Map<String, MultiverseWorld> worlds;
|
||||
private FileConfiguration configWorlds = null;
|
||||
private Map<String, String> defaultGens;
|
||||
private String firstSpawn;
|
||||
|
||||
public WorldManager(MultiverseCore core) {
|
||||
this.plugin = core;
|
||||
this.worldsFromTheConfig = new HashMap<String, WorldProperties>();
|
||||
this.worlds = new ConcurrentHashMap<String, MultiverseWorld>();
|
||||
this.worldsFromTheConfig = new HashMap<String, MVWorld>();
|
||||
this.worlds = new HashMap<String, MultiverseWorld>();
|
||||
this.worldPurger = new SimpleWorldPurger(plugin);
|
||||
}
|
||||
|
||||
@@ -88,85 +84,6 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean cloneWorld(String oldName, String newName, String generator) {
|
||||
// Make sure we don't already know about the new world.
|
||||
if (this.isMVWorld(newName)) {
|
||||
return false;
|
||||
}
|
||||
// Make sure the old world is actually a world!
|
||||
if (this.getUnloadedWorlds().contains(oldName) || !this.isMVWorld(oldName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final File oldWorldFile = new File(this.plugin.getServer().getWorldContainer(), oldName);
|
||||
final File newWorldFile = new File(this.plugin.getServer().getWorldContainer(), newName);
|
||||
|
||||
// Make sure the new world doesn't exist outside of multiverse.
|
||||
if (newWorldFile.exists()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unloadWorld(oldName);
|
||||
|
||||
removePlayersFromWorld(oldName);
|
||||
|
||||
Logging.config("Copying data for world '%s'", oldName);
|
||||
try {
|
||||
Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileUtils.copyFolder(oldWorldFile, newWorldFile, Logger.getLogger("Minecraft"));
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
try {
|
||||
t.join();
|
||||
} catch (InterruptedException e) {
|
||||
// do nothing
|
||||
}
|
||||
File uidFile = new File(newWorldFile, "uid.dat");
|
||||
uidFile.delete();
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
Logging.fine("Kind of copied stuff");
|
||||
|
||||
WorldCreator worldCreator = new WorldCreator(newName);
|
||||
Logging.fine("Started to copy settings");
|
||||
worldCreator.copy(this.getMVWorld(oldName).getCBWorld());
|
||||
Logging.fine("Copied lots of settings");
|
||||
|
||||
boolean useSpawnAdjust = this.getMVWorld(oldName).getAdjustSpawn();
|
||||
Logging.fine("Copied more settings");
|
||||
|
||||
Environment environment = worldCreator.environment();
|
||||
Logging.fine("Copied most settings");
|
||||
if (newWorldFile.exists()) {
|
||||
Logging.fine("Succeeded at copying stuff");
|
||||
if (this.addWorld(newName, environment, null, null, null, generator, useSpawnAdjust)) {
|
||||
// getMVWorld() doesn't actually return an MVWorld
|
||||
Logging.fine("Succeeded at importing stuff");
|
||||
MVWorld newWorld = (MVWorld) this.getMVWorld(newName);
|
||||
MVWorld oldWorld = (MVWorld) this.getMVWorld(oldName);
|
||||
newWorld.copyValues(oldWorld);
|
||||
try {
|
||||
// don't keep the alias the same -- that would be useless
|
||||
newWorld.setPropertyValue("alias", newName);
|
||||
} catch (PropertyDoesNotExistException e) {
|
||||
// this should never happen
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -206,10 +123,8 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
|
||||
// Important: doLoad() needs the MVWorld-object in worldsFromTheConfig
|
||||
if (!worldsFromTheConfig.containsKey(name)) {
|
||||
WorldProperties props = new WorldProperties(useSpawnAdjust, env);
|
||||
worldsFromTheConfig.put(name, props);
|
||||
}
|
||||
if (!worldsFromTheConfig.containsKey(name))
|
||||
worldsFromTheConfig.put(name, new MVWorld(useSpawnAdjust));
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Loading World & Settings - '").append(name).append("'");
|
||||
@@ -221,9 +136,9 @@ public class WorldManager implements MVWorldManager {
|
||||
if (generator != null) {
|
||||
builder.append(" & generator: ").append(generator);
|
||||
}
|
||||
Logging.info(builder.toString());
|
||||
this.plugin.log(Level.INFO, builder.toString());
|
||||
|
||||
if (!doLoad(c, true)) {
|
||||
if (!doLoad(c)) {
|
||||
this.plugin.log(Level.SEVERE, "Failed to Create/Load the world '" + name + "'");
|
||||
return false;
|
||||
}
|
||||
@@ -262,12 +177,12 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
if (this.worldsFromTheConfig.containsKey(name)) {
|
||||
this.worldsFromTheConfig.remove(name);
|
||||
Logging.info("World '%s' was removed from config.yml", name);
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was removed from config.yml");
|
||||
|
||||
this.saveWorldsConfig();
|
||||
return true;
|
||||
} else {
|
||||
Logging.info("World '%s' was already removed from config.yml", name);
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was already removed from config.yml");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -309,22 +224,22 @@ public class WorldManager implements MVWorldManager {
|
||||
@Override
|
||||
public boolean unloadWorld(String name) {
|
||||
if (this.worlds.containsKey(name)) {
|
||||
this.worldsFromTheConfig.get(name).cacheVirtualProperties();
|
||||
if (this.unloadWorldFromBukkit(name, true)) {
|
||||
this.worlds.remove(name);
|
||||
Logging.info("World '%s' was unloaded from memory.", name);
|
||||
this.plugin.log(Level.INFO, "World '" + name + "' was unloaded from memory.");
|
||||
|
||||
this.worldsFromTheConfig.get(name).tearDown();
|
||||
|
||||
return true;
|
||||
} else {
|
||||
Logging.warning("World '%s' could not be unloaded. Is it a default world?", name);
|
||||
this.plugin.log(Level.WARNING, "World '" + name + "' could not be unloaded. Is it a default world?");
|
||||
}
|
||||
} else if (this.plugin.getServer().getWorld(name) != null) {
|
||||
Logging.warning("Hmm Multiverse does not know about this world but it's loaded in memory.");
|
||||
Logging.warning("To let Multiverse know about it, use:");
|
||||
Logging.warning("/mv import %s %s", name, this.plugin.getServer().getWorld(name).getEnvironment().toString());
|
||||
} else if (this.worldsFromTheConfig.containsKey(name)) {
|
||||
return true; // it's already unloaded
|
||||
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 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 {
|
||||
Logging.info("Multiverse does not know about '%s' and it's not loaded by Bukkit.", name);
|
||||
this.plugin.log(Level.INFO, "Multiverse does not know about " + name + " and it's not loaded by Bukkit.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -354,51 +269,39 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
|
||||
private boolean doLoad(String name) {
|
||||
return doLoad(name, false, null);
|
||||
}
|
||||
|
||||
private boolean doLoad(String name, boolean ignoreExists, WorldType type) {
|
||||
if (!worldsFromTheConfig.containsKey(name))
|
||||
throw new IllegalArgumentException("That world doesn't exist!");
|
||||
|
||||
WorldProperties world = worldsFromTheConfig.get(name);
|
||||
MVWorld world = worldsFromTheConfig.get(name);
|
||||
WorldCreator creator = WorldCreator.name(name);
|
||||
|
||||
creator.environment(world.getEnvironment()).seed(world.getSeed());
|
||||
if (type != null) {
|
||||
creator.type(type);
|
||||
}
|
||||
if ((world.getGenerator() != null) && (!world.getGenerator().equals("null")))
|
||||
creator.generator(world.getGenerator());
|
||||
|
||||
return doLoad(creator, ignoreExists);
|
||||
return doLoad(creator);
|
||||
}
|
||||
|
||||
private boolean doLoad(WorldCreator creator, boolean ignoreExists) {
|
||||
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!");
|
||||
|
||||
if (!ignoreExists && !new File(this.plugin.getServer().getWorldContainer(), worldName).exists()) {
|
||||
this.plugin.log(Level.WARNING, "WorldManager: Can't load this world because the folder was deleted/moved: " + worldName);
|
||||
this.plugin.log(Level.WARNING, "Use '/mv remove' to remove it from the config!");
|
||||
return false;
|
||||
MVWorld mvworld = worldsFromTheConfig.get(worldName);
|
||||
World cbworld = Bukkit.getWorld(worldName);
|
||||
if (cbworld == null) {
|
||||
try {
|
||||
cbworld = creator.createWorld();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
brokenWorld(worldName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
WorldProperties mvworld = worldsFromTheConfig.get(worldName);
|
||||
World cbworld;
|
||||
try {
|
||||
cbworld = creator.createWorld();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
brokenWorld(worldName);
|
||||
return false;
|
||||
}
|
||||
MVWorld world = new MVWorld(plugin, cbworld, mvworld);
|
||||
this.worldPurger.purgeWorld(world);
|
||||
this.worlds.put(worldName, world);
|
||||
mvworld.init(cbworld, plugin);
|
||||
this.worldPurger.purgeWorld(mvworld);
|
||||
this.worlds.put(worldName, mvworld);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -406,7 +309,7 @@ public class WorldManager implements MVWorldManager {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteWorld(String name, boolean removeFromConfig, boolean deleteWorldFolder) {
|
||||
public boolean deleteWorld(String name, boolean removeFromConfig) {
|
||||
World world = this.plugin.getServer().getWorld(name);
|
||||
if (world == null) {
|
||||
// We can only delete loaded worlds
|
||||
@@ -434,33 +337,25 @@ public class WorldManager implements MVWorldManager {
|
||||
try {
|
||||
File worldFile = world.getWorldFolder();
|
||||
plugin.log(Level.FINER, "deleteWorld(): worldFile: " + worldFile.getAbsolutePath());
|
||||
if (deleteWorldFolder ? FileUtils.deleteFolder(worldFile) : FileUtils.deleteFolderContents(worldFile)) {
|
||||
Logging.info("World '%s' was DELETED.", name);
|
||||
return true;
|
||||
boolean deletedWorld = FileUtils.deleteFolder(worldFile);
|
||||
if (deletedWorld) {
|
||||
this.plugin.log(Level.INFO, "World " + name + " was DELETED.");
|
||||
} else {
|
||||
Logging.severe("World '%s' was NOT deleted.", name);
|
||||
Logging.severe("Are you sure the folder %s exists?", name);
|
||||
Logging.severe("Please check your file permissions on '%s'", name);
|
||||
return false;
|
||||
this.plugin.log(Level.SEVERE, "World " + name + " was NOT deleted.");
|
||||
this.plugin.log(Level.SEVERE, "Are you sure the folder " + name + " exists?");
|
||||
this.plugin.log(Level.SEVERE, "Please check your file permissions on " + name);
|
||||
}
|
||||
return deletedWorld;
|
||||
} catch (Throwable e) {
|
||||
Logging.severe("Hrm, something didn't go as planned. Here's an exception for ya.");
|
||||
Logging.severe("You can go politely explain your situation in #multiverse on esper.net");
|
||||
Logging.severe("But from here, it looks like your folder is oddly named.");
|
||||
Logging.severe("This world has been removed from Multiverse-Core so your best bet is to go delete the folder by hand. Sorry.");
|
||||
Logging.severe(e.getMessage());
|
||||
this.plugin.log(Level.SEVERE, "Hrm, something didn't go as planned. Here's an exception for ya.");
|
||||
this.plugin.log(Level.SEVERE, "You can go politely explain your situation in #multiverse on esper.net");
|
||||
this.plugin.log(Level.SEVERE, "But from here, it looks like your folder is oddly named.");
|
||||
this.plugin.log(Level.SEVERE, "This world has been removed from Multiverse-Core so your best bet is to go delete the folder by hand. Sorry.");
|
||||
this.plugin.log(Level.SEVERE, e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteWorld(String name, boolean removeFromConfig) {
|
||||
return this.deleteWorld(name, removeFromConfig, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -511,12 +406,8 @@ public class WorldManager implements MVWorldManager {
|
||||
*/
|
||||
@Override
|
||||
public MultiverseWorld getMVWorld(String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
MultiverseWorld world = this.worlds.get(name);
|
||||
if (world != null) {
|
||||
return world;
|
||||
if (this.worlds.containsKey(name)) {
|
||||
return this.worlds.get(name);
|
||||
}
|
||||
return this.getMVWorldByAlias(name);
|
||||
}
|
||||
@@ -551,7 +442,7 @@ public class WorldManager implements MVWorldManager {
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean isMVWorld(final String name) {
|
||||
public boolean isMVWorld(String name) {
|
||||
return (this.worlds.containsKey(name) || isMVWorldAlias(name));
|
||||
}
|
||||
|
||||
@@ -569,7 +460,7 @@ public class WorldManager implements MVWorldManager {
|
||||
* @param alias The alias of the world to check.
|
||||
* @return True if the world exists, false if not.
|
||||
*/
|
||||
private boolean isMVWorldAlias(final String alias) {
|
||||
private boolean isMVWorldAlias(String alias) {
|
||||
for (MultiverseWorld w : this.worlds.values()) {
|
||||
if (w.getAlias().equalsIgnoreCase(alias)) {
|
||||
return true;
|
||||
@@ -612,16 +503,35 @@ public class WorldManager implements MVWorldManager {
|
||||
// Basic Counter to count how many Worlds we are loading.
|
||||
int count = 0;
|
||||
this.ensureConfigIsPrepared();
|
||||
this.ensureSecondNamespaceIsPrepared();
|
||||
|
||||
// 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()) {
|
||||
// Remove this world from the master list
|
||||
if (allAccess != null) {
|
||||
allAccess.getChildren().remove(w.getAccessPermission().getName());
|
||||
}
|
||||
if (allExempt != null) {
|
||||
allExempt.getChildren().remove(w.getAccessPermission().getName());
|
||||
}
|
||||
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.bypass.gamemode." + w.getName());
|
||||
}
|
||||
// Recalc the all permission
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allAccess);
|
||||
this.plugin.getServer().getPluginManager().recalculatePermissionDefaults(allExempt);
|
||||
this.worlds.clear();
|
||||
}
|
||||
|
||||
for (Map.Entry<String, WorldProperties> entry : worldsFromTheConfig.entrySet()) {
|
||||
if (worlds.containsKey(entry.getKey())) {
|
||||
for (Map.Entry<String, MVWorld> entry : worldsFromTheConfig.entrySet()) {
|
||||
if (worlds.containsKey(entry.getKey()))
|
||||
continue;
|
||||
}
|
||||
if (!entry.getValue().getAutoLoad())
|
||||
continue;
|
||||
|
||||
@@ -630,10 +540,18 @@ public class WorldManager implements MVWorldManager {
|
||||
}
|
||||
|
||||
// Simple Output to the Console to show how many Worlds were loaded.
|
||||
Logging.config("%s - World(s) loaded.", count);
|
||||
this.plugin.log(Level.INFO, count + " - World(s) loaded.");
|
||||
this.saveWorldsConfig();
|
||||
}
|
||||
|
||||
private void ensureSecondNamespaceIsPrepared() {
|
||||
Permission special = this.plugin.getServer().getPluginManager().getPermission("mv.bypass.gamemode.*");
|
||||
if (special == null) {
|
||||
special = new Permission("mv.bypass.gamemode.*", PermissionDefault.FALSE);
|
||||
this.plugin.getServer().getPluginManager().addPermission(special);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @deprecated This is deprecated!
|
||||
@@ -670,23 +588,26 @@ public class WorldManager implements MVWorldManager {
|
||||
// load world-objects
|
||||
Stack<String> worldKeys = new Stack<String>();
|
||||
worldKeys.addAll(this.configWorlds.getConfigurationSection("worlds").getKeys(false));
|
||||
Map<String, WorldProperties> newWorldsFromTheConfig = new HashMap<String, WorldProperties>();
|
||||
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 WorldProperties)) {
|
||||
if ((obj != null) && (obj instanceof MVWorld)) {
|
||||
String worldName = key.replaceAll(String.valueOf(SEPARATOR), ".");
|
||||
WorldProperties props = (WorldProperties) obj;
|
||||
if (this.worldsFromTheConfig.containsKey(worldName)) {
|
||||
// Object-Recycling :D
|
||||
// TODO Why is is checking worldsFromTheConfig and then getting from worlds? So confused... (DTM)
|
||||
MVWorld mvWorld = (MVWorld) this.worlds.get(worldName);
|
||||
if (mvWorld != null) {
|
||||
mvWorld.copyValues((WorldProperties) obj);
|
||||
}
|
||||
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);
|
||||
}
|
||||
newWorldsFromTheConfig.put(worldName, props);
|
||||
} else if (this.configWorlds.isConfigurationSection(path)) {
|
||||
ConfigurationSection section = this.configWorlds.getConfigurationSection(path);
|
||||
Set<String> subkeys = section.getKeys(false);
|
||||
@@ -708,7 +629,7 @@ public class WorldManager implements MVWorldManager {
|
||||
try {
|
||||
this.configWorlds.options().pathSeparator(SEPARATOR);
|
||||
this.configWorlds.set("worlds", null);
|
||||
for (Map.Entry<String, WorldProperties> entry : worldsFromTheConfig.entrySet()) {
|
||||
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"));
|
||||
@@ -737,47 +658,6 @@ public class WorldManager implements MVWorldManager {
|
||||
return allNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean regenWorld(String name, boolean useNewSeed, boolean randomSeed, String seed) {
|
||||
MultiverseWorld world = this.getMVWorld(name);
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
List<Player> ps = world.getCBWorld().getPlayers();
|
||||
|
||||
if (useNewSeed) {
|
||||
long theSeed;
|
||||
|
||||
if (randomSeed) {
|
||||
theSeed = new Random().nextLong();
|
||||
} else {
|
||||
try {
|
||||
theSeed = Long.parseLong(seed);
|
||||
} catch (NumberFormatException e) {
|
||||
theSeed = seed.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
world.setSeed(theSeed);
|
||||
}
|
||||
WorldType type = world.getWorldType();
|
||||
|
||||
if (this.deleteWorld(name, false, false)) {
|
||||
this.doLoad(name, true, type);
|
||||
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter();
|
||||
Location newSpawn = world.getSpawnLocation();
|
||||
// Send all players that were in the old world, BACK to it!
|
||||
for (Player p : ps) {
|
||||
teleporter.safelyTeleport(null, p, newSpawn, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link FileConfiguration} that this {@link WorldManager} is using.
|
||||
* @return The {@link FileConfiguration} that this {@link WorldManager} is using.
|
||||
|
||||
@@ -202,33 +202,3 @@ commands:
|
||||
description: Regenerates a world Multiverse already knows about.
|
||||
usage: |
|
||||
/<command> {WORLD}
|
||||
mvscript:
|
||||
description: Runs a script from the Multiverse scripts directory.
|
||||
usage: |
|
||||
/<command> {script} [target]
|
||||
mvclone:
|
||||
description: World clone command
|
||||
usage: |
|
||||
/<command> <world> <environment>
|
||||
/<command> creative grieftastic -- Creates a world called 'grieftastic' exactly identical to the world 'creative'.
|
||||
mvsilent:
|
||||
description: Reduces startup messages
|
||||
usage: |
|
||||
/<command> [true|false]
|
||||
|
||||
mvgamerule:
|
||||
description: Sets a gamerule.
|
||||
usage: |
|
||||
/<command> {RULE} {VALUE} [WORLD]
|
||||
mvrule:
|
||||
description: Sets a gamerule.
|
||||
usage: |
|
||||
/<command> {RULE} {VALUE} [WORLD]
|
||||
mvgamerules:
|
||||
description: Lists the gamerules.
|
||||
usage: |
|
||||
/<command> [WORLD]
|
||||
mvrules:
|
||||
description: Lists the gamerules.
|
||||
usage: |
|
||||
/<command> [WORLD]
|
||||
@@ -1,156 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
||||
public class TestEntitySpawnRules {
|
||||
TestInstanceCreator creator;
|
||||
MultiverseCore core;
|
||||
MVEntityListener listener;
|
||||
|
||||
MultiverseWorld mvWorld;
|
||||
World cbworld;
|
||||
|
||||
Sheep sheep;
|
||||
Zombie zombie;
|
||||
|
||||
CreatureSpawnEvent sheepEvent;
|
||||
CreatureSpawnEvent zombieEvent;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertTrue(creator.setUp());
|
||||
core = creator.getCore();
|
||||
listener = core.getEntityListener();
|
||||
|
||||
mvWorld = mock(MultiverseWorld.class);
|
||||
cbworld = mock(World.class);
|
||||
when(mvWorld.getCBWorld()).thenReturn(cbworld);
|
||||
|
||||
MVWorldManager worldman = mock(MVWorldManager.class);
|
||||
when(worldman.isMVWorld(anyString())).thenReturn(true);
|
||||
when(worldman.getMVWorld(anyString())).thenReturn(mvWorld);
|
||||
Field worldmanfield = MVEntityListener.class.getDeclaredField("worldManager");
|
||||
worldmanfield.setAccessible(true);
|
||||
worldmanfield.set(listener, worldman);
|
||||
|
||||
core.getMVConfig().setGlobalDebug(3);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
}
|
||||
|
||||
private static CreatureSpawnEvent mockSpawnEvent(LivingEntity e, SpawnReason reason) {
|
||||
CreatureSpawnEvent event = mock(CreatureSpawnEvent.class);
|
||||
when(event.getEntity()).thenReturn(e);
|
||||
EntityType type = e.getType();
|
||||
when(event.getEntityType()).thenReturn(type);
|
||||
when(event.getSpawnReason()).thenReturn(reason);
|
||||
return event;
|
||||
}
|
||||
|
||||
private void spawnAll(SpawnReason reason) {
|
||||
sheepEvent = mockSpawnEvent(sheep, reason);
|
||||
zombieEvent = mockSpawnEvent(zombie, reason);
|
||||
listener.creatureSpawn(sheepEvent);
|
||||
listener.creatureSpawn(zombieEvent);
|
||||
}
|
||||
|
||||
private void spawnAllNatural() {
|
||||
spawnAll(SpawnReason.NATURAL);
|
||||
}
|
||||
|
||||
private void adjustSettings(boolean animalSpawn, boolean monsterSpawn,
|
||||
List<String> animalExceptions, List<String> monsterExceptions) {
|
||||
when(this.mvWorld.canAnimalsSpawn()).thenReturn(animalSpawn);
|
||||
when(this.mvWorld.canMonstersSpawn()).thenReturn(monsterSpawn);
|
||||
when(this.mvWorld.getAnimalList()).thenReturn(animalExceptions);
|
||||
when(this.mvWorld.getMonsterList()).thenReturn(monsterExceptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
// test 1: no spawning at all allowed
|
||||
adjustSettings(false, false, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
|
||||
createAnimals();
|
||||
spawnAllNatural();
|
||||
verify(sheepEvent).setCancelled(true);
|
||||
verify(zombieEvent).setCancelled(true);
|
||||
|
||||
// test 2: only monsters
|
||||
adjustSettings(false, true, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
|
||||
createAnimals();
|
||||
spawnAllNatural();
|
||||
verify(sheepEvent).setCancelled(true);
|
||||
verify(zombieEvent).setCancelled(false);
|
||||
|
||||
// test 3: all spawning allowed
|
||||
adjustSettings(true, true, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
|
||||
createAnimals();
|
||||
spawnAllNatural();
|
||||
verify(sheepEvent).setCancelled(false);
|
||||
verify(zombieEvent).setCancelled(false);
|
||||
|
||||
// test 4: no spawning with zombie exception
|
||||
adjustSettings(false, false, Collections.EMPTY_LIST, Arrays.asList("ZOMBIE"));
|
||||
createAnimals();
|
||||
spawnAllNatural();
|
||||
verify(sheepEvent).setCancelled(true);
|
||||
verify(zombieEvent).setCancelled(false);
|
||||
|
||||
// test 5: all spawning with sheep exception
|
||||
adjustSettings(true, true, Arrays.asList("SHEEP"), Collections.EMPTY_LIST);
|
||||
createAnimals();
|
||||
spawnAllNatural();
|
||||
verify(sheepEvent).setCancelled(true);
|
||||
verify(zombieEvent).setCancelled(false);
|
||||
|
||||
// test 6: eggs
|
||||
adjustSettings(false, false, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
|
||||
createAnimals();
|
||||
spawnAll(SpawnReason.SPAWNER_EGG);
|
||||
verify(sheepEvent, never()).setCancelled(anyBoolean());
|
||||
verify(zombieEvent, never()).setCancelled(anyBoolean());
|
||||
}
|
||||
|
||||
private void createAnimals() {
|
||||
sheep = mock(Sheep.class);
|
||||
when(sheep.getType()).thenReturn(EntityType.SHEEP);
|
||||
when(sheep.getWorld()).thenReturn(this.cbworld);
|
||||
zombie = mock(Zombie.class);
|
||||
when(zombie.getType()).thenReturn(EntityType.ZOMBIE);
|
||||
when(zombie.getWorld()).thenReturn(this.cbworld);
|
||||
|
||||
when(cbworld.getEntities()).thenReturn(Arrays.asList((Entity) sheep, (Entity) zombie));
|
||||
}
|
||||
}
|
||||
+12
-9
@@ -5,11 +5,17 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
package com.onarandombox.MultiverseCore.test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -22,12 +28,9 @@ import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.Core;
|
||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
||||
+7
-6
@@ -1,7 +1,8 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
package com.onarandombox.MultiverseCore.test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -14,9 +15,9 @@ import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.onarandombox.MultiverseCore.test;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.internal.verification.VerificationModeFactory;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
||||
public class TestWorldCreation {
|
||||
|
||||
private TestInstanceCreator creator;
|
||||
private MultiverseCore core;
|
||||
private CommandSender mockCommandSender;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.creator = new TestInstanceCreator();
|
||||
assertTrue(this.creator.setUp());
|
||||
this.core = this.creator.getCore();
|
||||
this.mockCommandSender = this.creator.getCommandSender();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void test() {
|
||||
// Initialize a fake command
|
||||
Command mockCommand = mock(Command.class);
|
||||
when(mockCommand.getName()).thenReturn("mv");
|
||||
|
||||
// Try to create a world that exists
|
||||
String[] normalArgs = new String[] { "create", "world", "normal" };
|
||||
core.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
||||
verify(mockCommandSender).sendMessage(ChatColor.RED + "A Folder/World already exists with this name!");
|
||||
verify(mockCommandSender).sendMessage(ChatColor.RED + "If you are confident it is a world you can import with /mvimport");
|
||||
|
||||
// Try to create a world that is new
|
||||
String[] newArgs = new String[] { "create", "world2", "normal" };
|
||||
core.onCommand(mockCommandSender, mockCommand, "", newArgs);
|
||||
verify(mockCommandSender).sendMessage("Starting creation of world 'world2'...");
|
||||
|
||||
String[] dottedWorld = new String[] { "create", "fish.world", "normal" };
|
||||
core.onCommand(mockCommandSender, mockCommand, "", dottedWorld);
|
||||
verify(mockCommandSender).sendMessage("Starting creation of world 'fish.world'...");
|
||||
verify(mockCommandSender, VerificationModeFactory.times(2)).sendMessage("Complete!");
|
||||
|
||||
// Grab the Config
|
||||
Field worldConfigField = null;
|
||||
ConfigurationSection worldsSection = null;
|
||||
try {
|
||||
worldConfigField = WorldManager.class.getDeclaredField("configWorlds");
|
||||
worldConfigField.setAccessible(true);
|
||||
Configuration rootConfig = (Configuration) worldConfigField.get(this.core.getMVWorldManager());
|
||||
worldsSection = rootConfig.getConfigurationSection("worlds");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Verify that the world was added to the configs
|
||||
// TODO: Expand this.
|
||||
assertNotNull(worldsSection);
|
||||
assertEquals(2, worldsSection.getKeys(false).size());
|
||||
assertTrue(worldsSection.getKeys(false).contains("world2"));
|
||||
assertTrue(worldsSection.getKeys(false).contains("fish.world"));
|
||||
}
|
||||
}
|
||||
+30
-32
@@ -5,20 +5,19 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
package com.onarandombox.MultiverseCore.test;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.configuration.SpawnLocation;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVAsyncPlayerChatListener;
|
||||
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.File;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -28,7 +27,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
@@ -45,16 +44,17 @@ import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.*;
|
||||
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.configuration.SpawnLocation;
|
||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ PluginManager.class, MultiverseCore.class, Permission.class, Bukkit.class,
|
||||
WeatherChangeEvent.class, ThunderChangeEvent.class, AsyncPlayerChatEvent.class,
|
||||
WeatherChangeEvent.class, ThunderChangeEvent.class, PlayerChatEvent.class,
|
||||
PlayerJoinEvent.class, PlayerRespawnEvent.class, EntityRegainHealthEvent.class,
|
||||
FoodLevelChangeEvent.class, WorldManager.class, PluginDescriptionFile.class })
|
||||
public class TestWorldProperties {
|
||||
@@ -68,7 +68,7 @@ public class TestWorldProperties {
|
||||
private ThunderChangeEvent thunderChangeOffEvent;
|
||||
private ThunderChangeEvent thunderChangeOnEvent;
|
||||
private Player mockPlayer;
|
||||
private AsyncPlayerChatEvent playerChatEvent;
|
||||
private PlayerChatEvent playerChatEvent;
|
||||
private Player mockNewPlayer;
|
||||
private PlayerJoinEvent playerNewJoinEvent;
|
||||
private PlayerJoinEvent playerJoinEvent;
|
||||
@@ -167,10 +167,10 @@ public class TestWorldProperties {
|
||||
|
||||
// call player chat event
|
||||
core.getMVConfig().setPrefixChat(true);
|
||||
((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
|
||||
core.getPlayerListener().playerChat(playerChatEvent);
|
||||
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||
core.getMVConfig().setPrefixChat(false);
|
||||
((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
|
||||
core.getPlayerListener().playerChat(playerChatEvent);
|
||||
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
||||
|
||||
// call player join events
|
||||
@@ -261,15 +261,15 @@ public class TestWorldProperties {
|
||||
|
||||
// call player chat event
|
||||
core.getMVConfig().setPrefixChat(true);
|
||||
((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
|
||||
core.getPlayerListener().playerChat(playerChatEvent);
|
||||
// never because it's hidden!
|
||||
verify(playerChatEvent, never()).setFormat(
|
||||
"[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||
mvWorld.setHidden(false);
|
||||
((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
|
||||
core.getPlayerListener().playerChat(playerChatEvent);
|
||||
verify(playerChatEvent).setFormat("[" + mvWorld.getColoredWorldString() + "]" + "format");
|
||||
core.getMVConfig().setPrefixChat(false);
|
||||
((MVAsyncPlayerChatListener) core.getChatListener()).playerChat(playerChatEvent);
|
||||
core.getPlayerListener().playerChat(playerChatEvent);
|
||||
verify(playerChatEvent, times(1)).setFormat(anyString()); // only ONE TIME (not the 2nd time!)
|
||||
mvWorld.setHidden(true); // reset hidden-state
|
||||
|
||||
@@ -298,7 +298,7 @@ public class TestWorldProperties {
|
||||
assertTrue(core.saveMVConfigs());
|
||||
// change a value here
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(core.getDataFolder(), "worlds.yml"));
|
||||
WorldProperties worldObj = (WorldProperties) config.get("worlds.world");
|
||||
MVWorld worldObj = (MVWorld) config.get("worlds.world");
|
||||
assertTrue(worldObj.setColor("GREEN"));
|
||||
config.set("worlds.world", worldObj);
|
||||
config.save(new File(core.getDataFolder(), "worlds.yml"));
|
||||
@@ -331,22 +331,20 @@ public class TestWorldProperties {
|
||||
}
|
||||
|
||||
public void createEvents(MultiverseWorld mvWorld) {
|
||||
final World world = mvWorld.getCBWorld();
|
||||
//// Weather events
|
||||
// weather change
|
||||
weatherChangeOffEvent = new WeatherChangeEvent(world, false);
|
||||
weatherChangeOnEvent = new WeatherChangeEvent(world, true);
|
||||
weatherChangeOffEvent = new WeatherChangeEvent(mvWorld.getCBWorld(), false);
|
||||
weatherChangeOnEvent = new WeatherChangeEvent(mvWorld.getCBWorld(), true);
|
||||
// thunder change
|
||||
thunderChangeOffEvent = new ThunderChangeEvent(world, false);
|
||||
thunderChangeOnEvent = new ThunderChangeEvent(world, true);
|
||||
thunderChangeOffEvent = new ThunderChangeEvent(mvWorld.getCBWorld(), false);
|
||||
thunderChangeOnEvent = new ThunderChangeEvent(mvWorld.getCBWorld(), true);
|
||||
//// Player events
|
||||
// player chat
|
||||
mockPlayer = mock(Player.class);
|
||||
when(mockPlayer.getWorld()).thenReturn(world);
|
||||
when(mockPlayer.getWorld()).thenReturn(mvWorld.getCBWorld());
|
||||
when(mockPlayer.hasPlayedBefore()).thenReturn(true);
|
||||
when(mockPlayer.hasPermission("multiverse.access.world")).thenReturn(true);
|
||||
when(mockPlayer.getName()).thenReturn("MultiverseMan");
|
||||
playerChatEvent = PowerMockito.mock(AsyncPlayerChatEvent.class);
|
||||
playerChatEvent = PowerMockito.mock(PlayerChatEvent.class);
|
||||
when(playerChatEvent.getPlayer()).thenReturn(mockPlayer);
|
||||
when(playerChatEvent.getFormat()).thenReturn("format");
|
||||
// player join
|
||||
@@ -368,7 +366,7 @@ public class TestWorldProperties {
|
||||
// entity regain health
|
||||
entityRegainHealthEvent = PowerMockito.mock(EntityRegainHealthEvent.class);
|
||||
when(entityRegainHealthEvent.getRegainReason()).thenReturn(RegainReason.REGEN);
|
||||
when(mockHumanEntity.getLocation()).thenReturn(new Location(world, 0, 0, 0));
|
||||
when(mockHumanEntity.getLocation()).thenReturn(new Location(mvWorld.getCBWorld(), 0, 0, 0));
|
||||
when(entityRegainHealthEvent.getEntity()).thenReturn(mockHumanEntity);
|
||||
// entity food level change event
|
||||
entityFoodLevelChangeEvent = PowerMockito.mock(FoodLevelChangeEvent.class);
|
||||
+10
-11
@@ -1,8 +1,10 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
package com.onarandombox.MultiverseCore.test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -16,10 +18,10 @@ import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.*;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.api.WorldPurger;
|
||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class })
|
||||
@@ -111,13 +113,10 @@ public class TestWorldPurger {
|
||||
}
|
||||
|
||||
private void createAnimals() {
|
||||
World world = mvWorld.getCBWorld();
|
||||
sheep = mock(Sheep.class);
|
||||
when(sheep.getType()).thenReturn(EntityType.SHEEP);
|
||||
when(sheep.getWorld()).thenReturn(world);
|
||||
zombie = mock(Zombie.class);
|
||||
when(zombie.getType()).thenReturn(EntityType.ZOMBIE);
|
||||
when(zombie.getWorld()).thenReturn(world);
|
||||
when(cbworld.getEntities()).thenReturn(Arrays.asList((Entity) sheep, (Entity) zombie));
|
||||
}
|
||||
}
|
||||
+5
-37
@@ -5,18 +5,15 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore;
|
||||
package com.onarandombox.MultiverseCore.test;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.exceptions.PropertyDoesNotExistException;
|
||||
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldCreatorMatcher;
|
||||
import com.onarandombox.MultiverseCore.test.utils.TestInstanceCreator;
|
||||
import com.onarandombox.MultiverseCore.test.utils.WorldCreatorMatcher;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
@@ -171,35 +168,6 @@ public class TestWorldStuff {
|
||||
verify(mockServer).createWorld(Matchers.argThat(matcher));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWorldCreateInvalidGenerator() {
|
||||
// Pull a core instance from the server.
|
||||
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
||||
|
||||
// Make sure Core is not null
|
||||
assertNotNull(plugin);
|
||||
|
||||
// Make sure Core is enabled
|
||||
assertTrue(plugin.isEnabled());
|
||||
|
||||
// Initialize a fake command
|
||||
Command mockCommand = mock(Command.class);
|
||||
when(mockCommand.getName()).thenReturn("mv");
|
||||
|
||||
// Ensure that there are no worlds imported. This is a fresh setup.
|
||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||
|
||||
// Create the world
|
||||
String[] normalArgs = new String[]{ "create", "newworld", "normal", "-g", "BogusGen"};
|
||||
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
||||
|
||||
// This command should halt, not creating any worlds
|
||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||
|
||||
// Verify
|
||||
verify(mockCommandSender).sendMessage("Invalid generator! 'BogusGen'. " + ChatColor.RED + "Aborting world creation.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWorld() {
|
||||
// Pull a core instance from the server.
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
package com.onarandombox.MultiverseCore.test.utils;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
+10
-22
@@ -5,7 +5,16 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
package com.onarandombox.MultiverseCore.test.utils;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.Location;
|
||||
@@ -17,20 +26,9 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class MockWorldFactory {
|
||||
|
||||
private static final Map<String, World> createdWorlds = new HashMap<String, World>();
|
||||
private static final Map<UUID, World> worldUIDS = new HashMap<UUID, World>();
|
||||
|
||||
private static final Map<World, Boolean> pvpStates = new WeakHashMap<World, Boolean>();
|
||||
private static final Map<World, Boolean> keepSpawnInMemoryStates = new WeakHashMap<World, Boolean>();
|
||||
@@ -41,8 +39,6 @@ public class MockWorldFactory {
|
||||
|
||||
private static void registerWorld(World world) {
|
||||
createdWorlds.put(world.getName(), world);
|
||||
worldUIDS.put(world.getUID(), world);
|
||||
new File(TestInstanceCreator.worldsDirectory, world.getName()).mkdir();
|
||||
}
|
||||
|
||||
private static World basics(String world, World.Environment env, WorldType type) {
|
||||
@@ -135,7 +131,6 @@ public class MockWorldFactory {
|
||||
return mockBlock;
|
||||
}
|
||||
});
|
||||
when(mockWorld.getUID()).thenReturn(UUID.randomUUID());
|
||||
return mockWorld;
|
||||
}
|
||||
|
||||
@@ -207,10 +202,6 @@ public class MockWorldFactory {
|
||||
return createdWorlds.get(name);
|
||||
}
|
||||
|
||||
public static World getWorld(UUID worldUID) {
|
||||
return worldUIDS.get(worldUID);
|
||||
}
|
||||
|
||||
public static List<World> getWorlds() {
|
||||
// we have to invert the order!
|
||||
ArrayList<World> myList = new ArrayList<World>(createdWorlds.values());
|
||||
@@ -222,9 +213,6 @@ public class MockWorldFactory {
|
||||
}
|
||||
|
||||
public static void clearWorlds() {
|
||||
for (String name : createdWorlds.keySet())
|
||||
new File(TestInstanceCreator.worldsDirectory, name).delete();
|
||||
createdWorlds.clear();
|
||||
worldUIDS.clear();
|
||||
}
|
||||
}
|
||||
+3
-31
@@ -5,14 +5,15 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
package com.onarandombox.MultiverseCore.test.utils;
|
||||
|
||||
import buscript.Buscript;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVEntityListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVPlayerListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||
import com.onarandombox.MultiverseCore.utils.FileUtils;
|
||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||
import junit.framework.Assert;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -36,7 +37,6 @@ import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -60,12 +60,6 @@ public class TestInstanceCreator {
|
||||
MockGateway.MOCK_STANDARD_METHODS = false;
|
||||
|
||||
core = PowerMockito.spy(new MultiverseCore());
|
||||
PowerMockito.doAnswer(new Answer<Void>() {
|
||||
@Override
|
||||
public Void answer(InvocationOnMock invocation) throws Throwable {
|
||||
return null; // don't run metrics in tests
|
||||
}
|
||||
}).when(core, "setupMetrics");
|
||||
|
||||
// Let's let all MV files go to bin/test
|
||||
doReturn(pluginDirectory).when(core).getDataFolder();
|
||||
@@ -86,8 +80,6 @@ public class TestInstanceCreator {
|
||||
when(mockPluginManager.getPlugins()).thenReturn(plugins);
|
||||
when(mockPluginManager.getPlugin("Multiverse-Core")).thenReturn(core);
|
||||
when(mockPluginManager.getPermission(anyString())).thenReturn(null);
|
||||
// Tell Buscript Vault is not available.
|
||||
when(mockPluginManager.getPermission("Vault")).thenReturn(null);
|
||||
|
||||
// Make some fake folders to fool the fake MV into thinking these worlds exist
|
||||
File worldNormalFile = new File(core.getServerFolder(), "world");
|
||||
@@ -121,19 +113,6 @@ public class TestInstanceCreator {
|
||||
}
|
||||
});
|
||||
|
||||
when(mockServer.getWorld(any(UUID.class))).thenAnswer(new Answer<World>() {
|
||||
@Override
|
||||
public World answer(InvocationOnMock invocation) throws Throwable {
|
||||
UUID arg;
|
||||
try {
|
||||
arg = (UUID) invocation.getArguments()[0];
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return MockWorldFactory.getWorld(arg);
|
||||
}
|
||||
});
|
||||
|
||||
when(mockServer.getWorlds()).thenAnswer(new Answer<List<World>>() {
|
||||
@Override
|
||||
public List<World> answer(InvocationOnMock invocation) throws Throwable {
|
||||
@@ -199,13 +178,6 @@ public class TestInstanceCreator {
|
||||
serverfield.setAccessible(true);
|
||||
serverfield.set(core, mockServer);
|
||||
|
||||
// Set buscript
|
||||
Buscript buscript = PowerMockito.spy(new Buscript(core));
|
||||
Field buscriptfield = MultiverseCore.class.getDeclaredField("buscript");
|
||||
buscriptfield.setAccessible(true);
|
||||
buscriptfield.set(core, buscript);
|
||||
when(buscript.getPlugin()).thenReturn(core);
|
||||
|
||||
// Set worldManager
|
||||
WorldManager wm = PowerMockito.spy(new WorldManager(core));
|
||||
Field worldmanagerfield = MultiverseCore.class.getDeclaredField("worldManager");
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
package com.onarandombox.MultiverseCore.test.utils;
|
||||
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Handler;
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* with this project. *
|
||||
******************************************************************************/
|
||||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
package com.onarandombox.MultiverseCore.test.utils;
|
||||
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
Reference in new issue
Block a user