Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a4e87b13d2 |
No files matched your search
@@ -215,7 +215,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<version>3.1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
@@ -264,19 +264,13 @@
|
||||
<plugin>
|
||||
<groupId>se.eris</groupId>
|
||||
<artifactId>notnull-instrumenter-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>0.6.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>instrument</goal>
|
||||
<goal>tests-instrument</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<notNull>
|
||||
<param>org.jetbrains.annotations.NotNull</param>
|
||||
<param>javax.validation.constraints.NotNull</param>
|
||||
</notNull>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
@@ -325,7 +319,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>1.8</version>
|
||||
<version>1.7</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
@@ -359,21 +353,21 @@
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-module-junit4</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<version>2.0.0</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-easymock</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<version>2.0.0</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.powermock</groupId>
|
||||
<artifactId>powermock-api-mockito2</artifactId>
|
||||
<version>2.0.9</version>
|
||||
<version>2.0.0</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -88,7 +88,6 @@ import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWorldInitListener;
|
||||
import com.onarandombox.MultiverseCore.listeners.MVWorldListener;
|
||||
import com.onarandombox.MultiverseCore.utils.AnchorManager;
|
||||
import com.onarandombox.MultiverseCore.utils.CompatibilityLayer;
|
||||
import com.onarandombox.MultiverseCore.utils.MVEconomist;
|
||||
import com.onarandombox.MultiverseCore.utils.MVMessaging;
|
||||
import com.onarandombox.MultiverseCore.utils.MVPermissions;
|
||||
@@ -129,9 +128,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
private static final int PROTOCOL = 24;
|
||||
// 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 static final Map<String, String> teleportQueue = new HashMap<String, String>();
|
||||
|
||||
private AnchorManager anchorManager = new AnchorManager(this);
|
||||
private final AnchorManager anchorManager = new AnchorManager(this);
|
||||
// TODO please let's make this non-static
|
||||
private volatile MultiverseCoreConfiguration config;
|
||||
|
||||
@@ -255,8 +254,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
// Setup our SafeTTeleporter
|
||||
this.safeTTeleporter = new SimpleSafeTTeleporter(this);
|
||||
this.unsafeCallWrapper = new UnsafeCallWrapper(this);
|
||||
// Setup our CompatibilityLayer
|
||||
CompatibilityLayer.init();
|
||||
}
|
||||
|
||||
|
||||
@@ -356,16 +353,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||
* Initializes the buscript javascript library.
|
||||
*/
|
||||
private void initializeBuscript() {
|
||||
buscript = null;
|
||||
|
||||
if (this.getMVConfig().getEnableBuscript()) {
|
||||
try {
|
||||
buscript = new Buscript(this);
|
||||
// Add global variable "multiverse" to javascript environment
|
||||
buscript.setScriptVariable("multiverse", this);
|
||||
} catch (NullPointerException e) {
|
||||
Logging.warning("Buscript failed to load! The script command will be disabled!");
|
||||
}
|
||||
try {
|
||||
buscript = new Buscript(this);
|
||||
// Add global variable "multiverse" to javascript environment
|
||||
buscript.setScriptVariable("multiverse", this);
|
||||
} catch (NullPointerException e) {
|
||||
buscript = null;
|
||||
Logging.warning("Buscript failed to load! The script command will be disabled!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,8 +56,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
@Property
|
||||
private volatile boolean displaypermerrors;
|
||||
@Property
|
||||
private volatile boolean enablebuscript;
|
||||
@Property
|
||||
private volatile int globaldebug;
|
||||
@Property
|
||||
private volatile boolean silentstart;
|
||||
@@ -101,7 +99,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
teleportintercept = true;
|
||||
firstspawnoverride = true;
|
||||
displaypermerrors = true;
|
||||
enablebuscript = true;
|
||||
globaldebug = 0;
|
||||
messagecooldown = 5000;
|
||||
teleportcooldown = 1000;
|
||||
@@ -216,22 +213,6 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
return this.displaypermerrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean getEnableBuscript() {
|
||||
return this.enablebuscript;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void setEnableBuscript(boolean enableBuscript) {
|
||||
this.enablebuscript = enableBuscript;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@@ -86,18 +86,6 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
*/
|
||||
boolean getDisplayPermErrors();
|
||||
|
||||
/**
|
||||
* Sets enableBuscript.
|
||||
* @param enableBuscript The new value.
|
||||
*/
|
||||
void setEnableBuscript(boolean enableBuscript);
|
||||
|
||||
/**
|
||||
* Gets enableBuscript.
|
||||
* @return enableBuscript.
|
||||
*/
|
||||
boolean getEnableBuscript();
|
||||
|
||||
/**
|
||||
* Sets firstSpawnOverride.
|
||||
* @param firstSpawnOverride The new value.
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
* Creates a clone of a world.
|
||||
*/
|
||||
public class CloneCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public CloneCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.Map;
|
||||
* Allows you to set Global MV Variables.
|
||||
*/
|
||||
public class ConfigCommand extends MultiverseCommand {
|
||||
|
||||
public ConfigCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Configuration");
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
* Returns detailed information on the Players where abouts.
|
||||
*/
|
||||
public class CoordCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public CoordCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
* Creates a new world and loads it.
|
||||
*/
|
||||
public class CreateCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public CreateCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.List;
|
||||
* Returns detailed information about a world.
|
||||
*/
|
||||
public class InfoCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public InfoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
@@ -115,7 +115,6 @@ public class InfoCommand extends MultiverseCommand {
|
||||
FancyColorScheme colors = new FancyColorScheme(ChatColor.AQUA, ChatColor.AQUA, ChatColor.GOLD, ChatColor.WHITE);
|
||||
message.add(new FancyHeader("General Info", colors));
|
||||
message.add(new FancyMessage("World Name: ", world.getName(), colors));
|
||||
message.add(new FancyMessage("World UID: ", world.getCBWorld().getUID().toString(), colors));
|
||||
message.add(new FancyMessage("World Alias: ", world.getColoredWorldString(), colors));
|
||||
message.add(new FancyMessage("Game Mode: ", world.getGameMode().toString(), colors));
|
||||
message.add(new FancyMessage("Difficulty: ", world.getDifficulty().toString(), colors));
|
||||
@@ -152,7 +151,6 @@ public class InfoCommand extends MultiverseCommand {
|
||||
message = new ArrayList<FancyText>();
|
||||
message.add(new FancyHeader("More World Settings", colors));
|
||||
message.add(new FancyMessage("World Type: ", world.getWorldType().toString(), colors));
|
||||
message.add(new FancyMessage("Generator: ", world.getGenerator(), colors));
|
||||
message.add(new FancyMessage("Structures: ", world.getCBWorld().canGenerateStructures() + "", colors));
|
||||
message.add(new FancyMessage("Weather: ", world.isWeatherEnabled() + "", colors));
|
||||
message.add(new FancyMessage("Players will get hungry: ", world.getHunger() + "", colors));
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
* Used to modify various aspects of worlds.
|
||||
*/
|
||||
public class ModifyAddCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public ModifyAddCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
* Removes all values from a world-property.
|
||||
*/
|
||||
public class ModifyClearCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public ModifyClearCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.List;
|
||||
* Removes values from a world-property.
|
||||
*/
|
||||
public class ModifyRemoveCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public ModifyRemoveCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
* Used to set world-properties.
|
||||
*/
|
||||
public class ModifySetCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public ModifySetCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
* Removes a type of mob from a world.
|
||||
*/
|
||||
public class PurgeCommand extends MultiverseCommand {
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public PurgeCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.logging.Level;
|
||||
* Used to teleport players.
|
||||
*/
|
||||
public class TeleportCommand extends MultiverseCommand {
|
||||
private SafeTTeleporter playerTeleporter;
|
||||
private final SafeTTeleporter playerTeleporter;
|
||||
|
||||
public TeleportCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -64,7 +64,6 @@ public class VersionCommand extends MultiverseCommand {
|
||||
+ "[Multiverse-Core] teleportintercept: " + plugin.getMVConfig().getTeleportIntercept() + '\n'
|
||||
+ "[Multiverse-Core] firstspawnoverride: " + plugin.getMVConfig().getFirstSpawnOverride() + '\n'
|
||||
+ "[Multiverse-Core] displaypermerrors: " + plugin.getMVConfig().getDisplayPermErrors() + '\n'
|
||||
+ "[Multiverse-Core] enablebuscript: " + plugin.getMVConfig().getEnableBuscript() + '\n'
|
||||
+ "[Multiverse-Core] globaldebug: " + plugin.getMVConfig().getGlobalDebug() + '\n'
|
||||
+ "[Multiverse-Core] silentstart: " + plugin.getMVConfig().getSilentStart() + '\n'
|
||||
+ "[Multiverse-Core] messagecooldown: " + plugin.getMessaging().getCooldown() + '\n'
|
||||
|
||||
@@ -23,8 +23,7 @@ import java.util.List;
|
||||
* States who is in what world.
|
||||
*/
|
||||
public class WhoCommand extends MultiverseCommand {
|
||||
|
||||
private MVWorldManager worldManager;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public WhoCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.enums;
|
||||
|
||||
public enum RespawnType {
|
||||
BED,
|
||||
ANCHOR,
|
||||
OTHER
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
* Called when the Multiverse-config should be reloaded.
|
||||
*/
|
||||
public class MVConfigReloadEvent extends Event {
|
||||
private List<String> configsLoaded;
|
||||
private final List<String> configsLoaded;
|
||||
|
||||
public MVConfigReloadEvent(List<String> configsLoaded) {
|
||||
this.configsLoaded = configsLoaded;
|
||||
|
||||
@@ -17,8 +17,8 @@ import org.bukkit.event.HandlerList;
|
||||
* This event is thrown when a portal is touched.
|
||||
*/
|
||||
public class MVPlayerTouchedPortalEvent extends Event implements Cancellable {
|
||||
private Player p;
|
||||
private Location l;
|
||||
private final Player p;
|
||||
private final Location l;
|
||||
private boolean isCancelled;
|
||||
private boolean canUse = true;
|
||||
|
||||
|
||||
@@ -16,10 +16,9 @@ import org.bukkit.event.HandlerList;
|
||||
* Called when a player is respawning.
|
||||
*/
|
||||
public class MVRespawnEvent extends Event {
|
||||
private Player player;
|
||||
private final Player player;
|
||||
private final String respawnMethod;
|
||||
private Location location;
|
||||
private String respawnMethod;
|
||||
|
||||
|
||||
public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) {
|
||||
this.player = p;
|
||||
|
||||
@@ -21,10 +21,10 @@ import org.bukkit.event.HandlerList;
|
||||
* Event that gets called when a player use the /mvtp command.
|
||||
*/
|
||||
public class MVTeleportEvent extends Event implements Cancellable {
|
||||
private Player teleportee;
|
||||
private CommandSender teleporter;
|
||||
private MVDestination dest;
|
||||
private boolean useSafeTeleport;
|
||||
private final Player teleportee;
|
||||
private final CommandSender teleporter;
|
||||
private final MVDestination dest;
|
||||
private final boolean useSafeTeleport;
|
||||
private boolean isCancelled;
|
||||
|
||||
public MVTeleportEvent(MVDestination dest, Player teleportee, CommandSender teleporter, boolean safeTeleport) {
|
||||
|
||||
@@ -24,11 +24,11 @@ import org.bukkit.event.HandlerList;
|
||||
* @param <T> The type of the property that was set.
|
||||
*/
|
||||
public class MVWorldPropertyChangeEvent<T> extends Event implements Cancellable {
|
||||
private MultiverseWorld world;
|
||||
private CommandSender changer;
|
||||
private boolean isCancelled = false;
|
||||
private String name;
|
||||
private final MultiverseWorld world;
|
||||
private final CommandSender changer;
|
||||
private final String name;
|
||||
private T value;
|
||||
private boolean isCancelled = false;
|
||||
|
||||
public MVWorldPropertyChangeEvent(MultiverseWorld world, CommandSender changer, String name, T value) {
|
||||
this.world = world;
|
||||
|
||||
@@ -28,8 +28,8 @@ import java.util.logging.Level;
|
||||
* Multiverse's Entity {@link Listener}.
|
||||
*/
|
||||
public class MVEntityListener implements Listener {
|
||||
private MultiverseCore plugin;
|
||||
private MVWorldManager worldManager;
|
||||
private final MultiverseCore plugin;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public MVEntityListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -15,9 +15,7 @@ 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.enums.RespawnType;
|
||||
import com.onarandombox.MultiverseCore.event.MVRespawnEvent;
|
||||
import com.onarandombox.MultiverseCore.utils.CompatibilityLayer;
|
||||
import com.onarandombox.MultiverseCore.utils.PermissionTools;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -64,33 +62,32 @@ public class MVPlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void playerRespawn(PlayerRespawnEvent event) {
|
||||
MultiverseWorld mvWorld = this.worldManager.getMVWorld(event.getPlayer().getWorld().getName());
|
||||
World world = event.getPlayer().getWorld();
|
||||
MultiverseWorld mvWorld = this.worldManager.getMVWorld(world.getName());
|
||||
// If it's not a World MV manages we stop.
|
||||
if (mvWorld == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RespawnType respawnType = RespawnType.OTHER;
|
||||
if (event.isBedSpawn()) {
|
||||
respawnType = RespawnType.BED;
|
||||
}
|
||||
if (CompatibilityLayer.isAnchorSpawn(event)) {
|
||||
respawnType = RespawnType.ANCHOR;
|
||||
}
|
||||
|
||||
if (mvWorld.getBedRespawn() && (respawnType == RespawnType.BED || respawnType == RespawnType.ANCHOR)) {
|
||||
Logging.fine("Spawning %s at their %s", event.getPlayer().getName(), respawnType);
|
||||
if (mvWorld.getBedRespawn() && event.isBedSpawn()) {
|
||||
Logging.fine("Spawning " + event.getPlayer().getName() + " at their bed");
|
||||
return;
|
||||
}
|
||||
|
||||
World respawnWorld = mvWorld.getRespawnToWorld();
|
||||
if (respawnWorld.equals(event.getRespawnLocation().getWorld())) {
|
||||
Logging.fine("Player already respawning at RespawnWorld '%s'. No action needed.", respawnWorld.getName());
|
||||
return;
|
||||
// Get the instance of the World the player should respawn at.
|
||||
MultiverseWorld respawnWorld = null;
|
||||
if (this.worldManager.isMVWorld(mvWorld.getRespawnToWorld())) {
|
||||
respawnWorld = this.worldManager.getMVWorld(mvWorld.getRespawnToWorld());
|
||||
}
|
||||
|
||||
// World to be set to the appropriate respawn world defined.
|
||||
Location respawnLocation = getMostAccurateRespawnLocation(respawnWorld);
|
||||
// If it's null then it either means the World doesn't exist or the value is blank, so we don't handle it.
|
||||
// NOW: We'll always handle it to get more accurate spawns
|
||||
if (respawnWorld != null) {
|
||||
world = respawnWorld.getCBWorld();
|
||||
}
|
||||
// World has been set to the appropriate world
|
||||
Location respawnLocation = getMostAccurateRespawnLocation(world);
|
||||
|
||||
MVRespawnEvent respawnEvent = new MVRespawnEvent(respawnLocation, event.getPlayer(), "compatability");
|
||||
this.plugin.getServer().getPluginManager().callEvent(respawnEvent);
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.logging.Level;
|
||||
*/
|
||||
public class MVPortalListener implements Listener {
|
||||
|
||||
private MultiverseCore plugin;
|
||||
private final MultiverseCore plugin;
|
||||
|
||||
public MVPortalListener(MultiverseCore core) {
|
||||
this.plugin = core;
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
* Multiverse's Weather {@link Listener}.
|
||||
*/
|
||||
public class MVWeatherListener implements Listener {
|
||||
private MultiverseCore plugin;
|
||||
private final MultiverseCore plugin;
|
||||
|
||||
public MVWeatherListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.bukkit.event.world.WorldInitEvent;
|
||||
|
||||
public class MVWorldInitListener implements Listener {
|
||||
|
||||
MultiverseCore plugin;
|
||||
private final MultiverseCore plugin;
|
||||
|
||||
public MVWorldInitListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -20,8 +20,8 @@ import org.bukkit.event.world.WorldUnloadEvent;
|
||||
* Multiverse's World {@link Listener}.
|
||||
*/
|
||||
public class MVWorldListener implements Listener {
|
||||
private MultiverseCore plugin;
|
||||
private MVWorldManager worldManager;
|
||||
private final MultiverseCore plugin;
|
||||
private final MVWorldManager worldManager;
|
||||
|
||||
public MVWorldListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.dumptruckman.minecraft.util.Logging;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* A utility class to enable version specific minecraft features.
|
||||
*/
|
||||
public class CompatibilityLayer {
|
||||
|
||||
private static Method checkAnchorSpawn;
|
||||
|
||||
/**
|
||||
* Initialise the reflection methods.
|
||||
*/
|
||||
public static void init() {
|
||||
try {
|
||||
checkAnchorSpawn = PlayerRespawnEvent.class.getDeclaredMethod("isAnchorSpawn");
|
||||
} catch (NoSuchMethodException e) {
|
||||
Logging.fine("%s does not support respawn anchors.", Bukkit.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the respawn point is of respawn anchor type.
|
||||
* Introduced in minecraft 1.16
|
||||
*
|
||||
* @param event A player respawn event.
|
||||
* @return If the respawn location is an anchor point.
|
||||
*/
|
||||
public static boolean isAnchorSpawn(PlayerRespawnEvent event) {
|
||||
if (checkAnchorSpawn == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return (boolean) checkAnchorSpawn.invoke(event);
|
||||
} catch (Exception e) {
|
||||
Logging.warning("Error checking for: %s", checkAnchorSpawn);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -40,15 +40,6 @@ public class SimpleLocationManipulation implements LocationManipulation {
|
||||
orientationInts.put("w", 90);
|
||||
orientationInts.put("nw", 135);
|
||||
|
||||
orientationInts.put("north", 180);
|
||||
orientationInts.put("northeast", 225);
|
||||
orientationInts.put("east", 270);
|
||||
orientationInts.put("southeast", 315);
|
||||
orientationInts.put("south", 0);
|
||||
orientationInts.put("southwest", 45);
|
||||
orientationInts.put("west", 90);
|
||||
orientationInts.put("northwest", 135);
|
||||
|
||||
// "freeze" the map:
|
||||
ORIENTATION_INTS = Collections.unmodifiableMap(orientationInts);
|
||||
// END CHECKSTYLE-SUPPRESSION: MagicNumberCheck
|
||||
|
||||
@@ -200,11 +200,11 @@ public class TestWorldProperties {
|
||||
verify(mockNewPlayer).teleport(worldManager.getFirstSpawnWorld().getSpawnLocation());
|
||||
|
||||
// call player respawn events
|
||||
// core.getPlayerListener().playerRespawn(playerRespawnBed);
|
||||
// // bedrespawn is on so nothing should happen
|
||||
// verify(playerRespawnBed, never()).setRespawnLocation(any(Location.class));
|
||||
// core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||
// verify(playerRespawnNormal).setRespawnLocation(mvWorld.getSpawnLocation());
|
||||
core.getPlayerListener().playerRespawn(playerRespawnBed);
|
||||
// bedrespawn is on so nothing should happen
|
||||
verify(playerRespawnBed, never()).setRespawnLocation(any(Location.class));
|
||||
core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||
verify(playerRespawnNormal).setRespawnLocation(mvWorld.getSpawnLocation());
|
||||
|
||||
// call entity regain health event
|
||||
core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
|
||||
@@ -300,11 +300,11 @@ public class TestWorldProperties {
|
||||
verify(mockNewPlayer).teleport(new SpawnLocation(1, 1, 1));
|
||||
|
||||
// call player respawn events
|
||||
// core.getPlayerListener().playerRespawn(playerRespawnBed);
|
||||
// // bedrespawn is off so something should happen (and we've set respawn to nether...)
|
||||
// verify(playerRespawnBed).setRespawnLocation(netherWorld.getSpawnLocation());
|
||||
// core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||
// verify(playerRespawnNormal).setRespawnLocation(netherWorld.getSpawnLocation());
|
||||
core.getPlayerListener().playerRespawn(playerRespawnBed);
|
||||
// bedrespawn is off so something should happen (and we've set respawn to nether...)
|
||||
verify(playerRespawnBed).setRespawnLocation(netherWorld.getSpawnLocation());
|
||||
core.getPlayerListener().playerRespawn(playerRespawnNormal);
|
||||
verify(playerRespawnNormal).setRespawnLocation(netherWorld.getSpawnLocation());
|
||||
|
||||
// call entity regain health event
|
||||
core.getEntityListener().entityRegainHealth(entityRegainHealthEvent);
|
||||
|
||||
@@ -214,18 +214,11 @@ public class TestInstanceCreator {
|
||||
serverfield.set(core, mockServer);
|
||||
|
||||
// Set buscript
|
||||
Buscript buscript;
|
||||
Buscript buscript = PowerMockito.spy(new Buscript(core));
|
||||
Field buscriptfield = MultiverseCore.class.getDeclaredField("buscript");
|
||||
buscriptfield.setAccessible(true);
|
||||
|
||||
try {
|
||||
buscript = PowerMockito.spy(new Buscript(core));
|
||||
when(buscript.getPlugin()).thenReturn(core);
|
||||
} catch (NullPointerException e) {
|
||||
buscript = null;
|
||||
}
|
||||
|
||||
buscriptfield.set(core, buscript);
|
||||
when(buscript.getPlugin()).thenReturn(core);
|
||||
|
||||
// Set worldManager
|
||||
WorldManager wm = PowerMockito.spy(new WorldManager(core));
|
||||
|
||||
Reference in new issue
Block a user