Small changes to BlockSafety for MVPortals, Remove hard spout dependency for real this time. Thanks @lithium3141

This commit is contained in:
Eric Stokes 2011-08-22 19:53:00 -06:00
parent 8d09c19988
commit e556261e84
6 changed files with 48 additions and 27 deletions

View File

@ -22,7 +22,7 @@ public class MVTeleport {
public MVTeleport(MultiverseCore plugin) {
this.plugin = plugin;
this.bs = new BlockSafety(this.plugin);
this.bs = new BlockSafety();
}
/**

View File

@ -86,7 +86,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
// Setup our Map for our Commands using the CommandHandler.
private CommandHandler commandHandler;
private final String tag = "[Multiverse-Core]";
private final static String tag = "[Multiverse-Core]";
// Multiverse Permissions Handler
private MVPermissions ph;
@ -117,7 +117,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
protected MVConfigMigrator migrator = new MVCoreConfigMigrator(this);
protected int pluginCount;
private DestinationFactory destFactory;
private SpoutManager spoutManager;
private SpoutInterface spoutInterface = null;
@Override
public void onLoad() {
@ -340,7 +340,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
* @param env Environment Type
*/
public boolean addWorld(String name, Environment env, String seedString, String generator) {
this.debugLog(Level.CONFIG, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
staticLog(Level.FINE, "Adding world with: " + name + ", " + env.toString() + ", " + seedString + ", " + generator);
Long seed = null;
if (seedString != null && seedString.length() > 0) {
try {
@ -625,19 +625,22 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
* @param msg
*/
public void log(Level level, String msg) {
// We're using Config as debug
staticLog(level, msg);
}
public static void staticLog(Level level, String msg) {
if (level == Level.FINE && GlobalDebug >= 1) {
this.debugLog(Level.INFO, msg);
staticDebugLog(Level.INFO, msg);
return;
} else if (level == Level.FINER && GlobalDebug >= 2) {
this.debugLog(Level.INFO, msg);
staticDebugLog(Level.INFO, msg);
return;
} else if (level == Level.FINEST && GlobalDebug >= 3) {
this.debugLog(Level.INFO, msg);
staticDebugLog(Level.INFO, msg);
return;
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
log.log(level, this.tag + " " + msg);
debugLog.log(level, this.tag + " " + msg);
log.log(level, tag + " " + msg);
debugLog.log(level, tag + " " + msg);
}
}
@ -647,7 +650,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
* @param level
* @param msg
*/
public void debugLog(Level level, String msg) {
public static void staticDebugLog(Level level, String msg) {
log.log(level, "[MVCore-Debug] " + msg);
debugLog.log(level, "[MVCore-Debug] " + msg);
}
@ -828,12 +831,13 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
}
}
public void setSpout(SpoutManager spoutManager) {
this.spoutManager = spoutManager;
public void setSpout() {
this.spoutInterface = new SpoutInterface();
this.commandHandler.registerCommand(new SpoutCommand(this));
}
public SpoutManager getSpout() {
return this.spoutManager;
public SpoutInterface getSpout() {
return this.spoutInterface;
}
}

View File

@ -0,0 +1,14 @@
package com.onarandombox.MultiverseCore;
import org.getspout.spoutapi.SpoutManager;
public class SpoutInterface {
private SpoutManager spoutManager;
public SpoutInterface() {
this.spoutManager = SpoutManager.getInstance();
}
public SpoutManager getManager() {
return this.spoutManager;
}
}

View File

@ -37,7 +37,6 @@ public class SpoutCommand extends MultiverseCommand {
}
SpoutPlayer p = (SpoutPlayer) sender;
if (!p.isSpoutCraftEnabled()) {
sender.sendMessage(ChatColor.RED + p.getName() + "You need to be using the Spoutcraft client to run this command!");
return;
}

View File

@ -43,7 +43,7 @@ public class MVPluginListener extends ServerListener {
}
}
if (event.getPlugin().getDescription().getName().equals("Spout")) {
this.plugin.setSpout(SpoutManager.getInstance());
this.plugin.setSpout();
this.plugin.log(Level.INFO, "Spout integration enabled.");
}
}

View File

@ -12,10 +12,9 @@ import org.bukkit.entity.Vehicle;
import com.onarandombox.MultiverseCore.MultiverseCore;
public class BlockSafety {
private MultiverseCore plugin;
public BlockSafety(MultiverseCore plugin) {
this.plugin = plugin;
public BlockSafety() {
// TODO Auto-generated constructor stub
}
/**
@ -37,6 +36,11 @@ public class BlockSafety {
Location l = new Location(world, x, y, z);
return !playerCanSpawnHereSafely(l);
}
public boolean playerCanSpawnHereSafely(World world, double x, double y, double z) {
Location l = new Location(world, x, y, z);
return playerCanSpawnHereSafely(l);
}
/**
* This function checks whether the block at the coordinates given is safe or not by checking for Laval/Fire/Air etc. This also ensures there is enough space for a player to spawn!
@ -55,25 +59,25 @@ public class BlockSafety {
downOne.setY(downOne.getY() - 1);
if (this.isSolidBlock(actual.getBlock().getType()) || this.isSolidBlock(upOne.getBlock().getType())) {
this.plugin.log(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
this.plugin.log(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
return false;
}
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
this.plugin.log(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
this.plugin.log(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
MultiverseCore.staticLog(Level.FINER, "Error Here? (" + actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
return false;
}
if (downOne.getBlock().getType() == Material.FIRE) {
this.plugin.log(Level.FINER, "There's fire below! (" + 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)) {
this.plugin.log(Level.FINER, "Is block above air [" + isBlockAboveAir(actual) + "]");
this.plugin.log(Level.FINER, "Has 2 blocks of water below [" + 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;