mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-03 14:57:43 +01:00
Merge branch 'master' into development
This commit is contained in:
commit
ce8b042919
@ -1 +1 @@
|
||||
Subproject commit b6b450e8b67af96aee856469b2061cccbcfac87e
|
||||
Subproject commit 5f40678ac750210a3121921af0c4e58e6516bfdb
|
17
pom.xml
17
pom.xml
@ -126,7 +126,15 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.iCo6</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
<version>6.0</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.iConomy</groupId>
|
||||
<artifactId>iConomy</artifactId>
|
||||
@ -150,6 +158,13 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.ashtheking.currency</groupId>
|
||||
<artifactId>MultiCurrency</artifactId>
|
||||
<version>0.09</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- End of Economy Dependencies -->
|
||||
|
||||
<!-- Start of Permissions Dependencies -->
|
||||
|
@ -90,7 +90,7 @@ public class MVPermissions implements PermissionsInterface {
|
||||
if (!this.plugin.isMVWorld(worldName)) {
|
||||
return false;
|
||||
}
|
||||
if(!canEnterLocation(p, d.getLocation(p))) {
|
||||
if (!canEnterLocation(p, d.getLocation(p))) {
|
||||
return false;
|
||||
}
|
||||
return this.hasPermission(p, d.getRequiredPermission(), false);
|
||||
@ -105,31 +105,31 @@ public class MVPermissions implements PermissionsInterface {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// NO one can access a null permission (mainly used for destinations):w
|
||||
if(node == null) {
|
||||
if (node == null) {
|
||||
return false;
|
||||
}
|
||||
// Everyone can access an empty permission
|
||||
// Currently used for the PlayerDestination
|
||||
if(node.equals("")) {
|
||||
if (node.equals("")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
this.plugin.log(Level.FINEST, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]");
|
||||
boolean opFallback = this.plugin.getConfig().getBoolean("opfallback", true);
|
||||
if (this.permissions != null && this.permissions.has(player, node)) {
|
||||
// If Permissions is enabled we check against them.
|
||||
// this.plugin.log(Level.WARNING, "Allowed by P3/P2 ");
|
||||
this.plugin.log(Level.FINEST, "Allowed by Permissions or something that looked like it.");
|
||||
return true;
|
||||
} else if (sender.hasPermission(node)) {
|
||||
// If Now check the bukkit permissions
|
||||
// this.plugin.log(Level.WARNING, "Allowed by BukkitPerms");
|
||||
this.plugin.log(Level.FINEST, "Allowed by the built in Permissions.");
|
||||
return true;
|
||||
} else if (player.isOp() && opFallback) {
|
||||
// If Player is Op we always let them use it if they have the fallback enabled!
|
||||
// this.plugin.log(Level.WARNING, "Allowed by OP");
|
||||
this.plugin.log(Level.FINEST, "Allowed by OP (opfallback was on).");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -138,19 +138,22 @@ public class MVPermissions implements PermissionsInterface {
|
||||
// This allows us to act as a default permission guidance
|
||||
|
||||
// If they have the op fallback disabled, NO commands will work without a permissions plugin.
|
||||
if (!isOpRequired && opFallback) {
|
||||
this.plugin.log(Level.FINEST, "Allowed because opfallback was set to true.");
|
||||
}
|
||||
return !isOpRequired && opFallback;
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
String opsfallback = "";
|
||||
if(this.plugin.getConfig().getBoolean("opfallback", true)) {
|
||||
opsfallback = " WITH OPs.txt fallback";
|
||||
if (this.plugin.getConfig().getBoolean("opfallback", true)) {
|
||||
opsfallback = " WITH OPs.txt fallback";
|
||||
}
|
||||
if (this.permissions != null) {
|
||||
return "Permissions " + this.plugin.getServer().getPluginManager().getPlugin("Permissions").getDescription().getVersion() + opsfallback;
|
||||
}
|
||||
|
||||
|
||||
return "Bukkit Permissions" + opsfallback;
|
||||
}
|
||||
|
||||
|
@ -9,15 +9,17 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
|
||||
import com.onarandombox.utils.BlockSafety;
|
||||
import com.onarandombox.utils.LocationManipulation;
|
||||
|
||||
public class MVTeleport {
|
||||
|
||||
MultiverseCore plugin;
|
||||
|
||||
BlockSafety bs = new BlockSafety();
|
||||
BlockSafety bs;
|
||||
|
||||
public MVTeleport(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
this.bs = new BlockSafety(this.plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,17 +49,23 @@ public class MVTeleport {
|
||||
if (safe != null) {
|
||||
safe.setX(safe.getBlockX() + .5);
|
||||
safe.setZ(safe.getBlockZ() + .5);
|
||||
this.plugin.log(Level.FINE, "Hey! I found one: " + LocationManipulation.strCoordsRaw(safe));
|
||||
} else {
|
||||
this.plugin.log(Level.FINE, "Uh oh! No safe place found!");
|
||||
}
|
||||
return safe;
|
||||
}
|
||||
|
||||
private Location checkAboveAndBelowLocation(Location l, int tolerance, int radius) {
|
||||
|
||||
// Tolerance must be an even number:
|
||||
if (tolerance % 2 != 0) {
|
||||
tolerance += 1;
|
||||
}
|
||||
// We want half of it, so we can go up and down
|
||||
tolerance /= 2;
|
||||
this.plugin.log(Level.FINER, "Given Location of: " + LocationManipulation.strCoordsRaw(l));
|
||||
this.plugin.log(Level.FINER, "Checking +-" + tolerance + " with a radius of " + radius);
|
||||
|
||||
// For now this will just do a straight up block.
|
||||
Location locToCheck = l.clone();
|
||||
@ -176,40 +184,43 @@ public class MVTeleport {
|
||||
public boolean safelyTeleport(Entity e, Location l) {
|
||||
if (this.bs.playerCanSpawnHereSafely(l)) {
|
||||
e.teleport(l);
|
||||
//this.plugin.log(Level.WARNING, "The first location you gave me was safe.");
|
||||
plugin.log(Level.FINE, "The first location you gave me was safe.");
|
||||
return true;
|
||||
}
|
||||
if(e instanceof Minecart) {
|
||||
Minecart m = (Minecart)e;
|
||||
if(!this.bs.canSpawnCartSafely(m)) {
|
||||
if (e instanceof Minecart) {
|
||||
Minecart m = (Minecart) e;
|
||||
if (!this.bs.canSpawnCartSafely(m)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(e instanceof Vehicle) {
|
||||
Vehicle v = (Vehicle)e;
|
||||
if(!this.bs.canSpawnVehicleSafely(v)) {
|
||||
else if (e instanceof Vehicle) {
|
||||
Vehicle v = (Vehicle) e;
|
||||
if (!this.bs.canSpawnVehicleSafely(v)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Location safeLocation = this.getSafeLocation(l);
|
||||
if (safeLocation != null) {
|
||||
// Add offset to account for a vehicle on dry land!
|
||||
if (!this.bs.isEntitiyOnTrack(e, safeLocation)) {
|
||||
if (e instanceof Minecart && !this.bs.isEntitiyOnTrack(e, safeLocation)) {
|
||||
safeLocation.setY(safeLocation.getBlockY() + .5);
|
||||
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
|
||||
}
|
||||
e.teleport(safeLocation);
|
||||
//this.plugin.log(Level.WARNING, "Had to look for a bit, but I found a safe place for ya!");
|
||||
this.plugin.log(Level.FINE, "Had to look for a bit, but I found a safe place for ya!");
|
||||
return true;
|
||||
}
|
||||
if (e instanceof Player) {
|
||||
Player p = (Player) e;
|
||||
p.sendMessage("No safe locations found!");
|
||||
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||
}
|
||||
else if (e.getPassenger() instanceof Player) {
|
||||
Player p = (Player) e.getPassenger();
|
||||
p.sendMessage("No safe locations found!");
|
||||
this.plugin.log(Level.FINER, "No safe location found for " + p.getName());
|
||||
}
|
||||
this.plugin.log(Level.WARNING, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
|
||||
this.plugin.log(Level.FINE, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class MVWorld {
|
||||
this.canSave = true;
|
||||
saveConfig();
|
||||
|
||||
this.permission = new Permission("multiverse.access." + this.getName(), "Allows access to " + this.getName(), PermissionDefault.TRUE);
|
||||
this.permission = new Permission("multiverse.access." + this.getName(), "Allows access to " + this.getName(), PermissionDefault.OP);
|
||||
this.exempt = new Permission("multiverse.exempt." + this.getName(), "A player who has this does not pay to enter this world, or use any MV portals in it " + this.getName(), PermissionDefault.OP);
|
||||
try {
|
||||
this.plugin.getServer().getPluginManager().addPermission(this.permission);
|
||||
|
@ -36,6 +36,7 @@ import com.fernferret.allpay.GenericBank;
|
||||
import com.onarandombox.MultiverseCore.commands.ConfirmCommand;
|
||||
import com.onarandombox.MultiverseCore.commands.CoordCommand;
|
||||
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.HelpCommand;
|
||||
@ -106,6 +107,8 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
|
||||
public UpdateChecker updateCheck;
|
||||
|
||||
public static int GlobalDebug = 0;
|
||||
|
||||
// HashMap to contain all the Worlds which this Plugin will manage.
|
||||
private HashMap<String, MVWorld> worlds = new HashMap<String, MVWorld>();
|
||||
|
||||
@ -268,6 +271,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
|
||||
// Misc Commands
|
||||
this.commandHandler.registerCommand(new EnvironmentCommand(this));
|
||||
this.commandHandler.registerCommand(new DebugCommand(this));
|
||||
this.commandHandler.registerCommand(new SleepCommand(this));
|
||||
this.commandHandler.registerCommand(new SpoutCommand(this));
|
||||
|
||||
@ -471,9 +475,9 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
* @return True if success, false if failure.
|
||||
*/
|
||||
public Boolean deleteWorld(String name) {
|
||||
|
||||
|
||||
if (this.getServer().getWorld(name) != null) {
|
||||
if(!unloadWorld(name, false)) {
|
||||
if (!unloadWorld(name, false)) {
|
||||
// If the world was loaded, and we couldn't unload it, return false. DON"T DELTEE
|
||||
return false;
|
||||
}
|
||||
@ -626,8 +630,20 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
* @param msg
|
||||
*/
|
||||
public void log(Level level, String msg) {
|
||||
log.log(level, this.tag + " " + msg);
|
||||
debugLog.log(level, this.tag + " " + msg);
|
||||
// We're using Config as debug
|
||||
if (level == Level.FINE && GlobalDebug >= 1) {
|
||||
this.debugLog(Level.INFO, msg);
|
||||
return;
|
||||
} else if (level == Level.FINER && GlobalDebug >= 2) {
|
||||
this.debugLog(Level.INFO, msg);
|
||||
return;
|
||||
} else if (level == Level.FINEST && GlobalDebug >= 3) {
|
||||
this.debugLog(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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -637,10 +653,8 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin {
|
||||
* @param msg
|
||||
*/
|
||||
public void debugLog(Level level, String msg) {
|
||||
if (this.debug) {
|
||||
log.log(level, "[Debug] " + msg);
|
||||
}
|
||||
debugLog.log(level, "[Debug] " + msg);
|
||||
log.log(level, "[MVCore-Debug] " + msg);
|
||||
debugLog.log(level, "[MVCore-Debug] " + msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class DebugCommand extends MultiverseCommand {
|
||||
|
||||
public DebugCommand(MultiverseCore plugin) {
|
||||
super(plugin);
|
||||
this.setName("Turn Debug on/off?");
|
||||
this.setCommandUsage("/mv who" + ChatColor.GOLD + " [1|2|3|off]");
|
||||
this.setArgRange(0, 1);
|
||||
this.addKey("mv debug");
|
||||
this.addKey("mv d");
|
||||
this.addKey("mvdebug");
|
||||
this.setPermission("multiverse.core.debug", "Spams the console a bunch.", PermissionDefault.OP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(CommandSender sender, List<String> args) {
|
||||
if (args.size() == 1) {
|
||||
if (args.get(0).equalsIgnoreCase("off")) {
|
||||
MultiverseCore.GlobalDebug = 0;
|
||||
} else {
|
||||
try {
|
||||
int debugLevel = Integer.parseInt(args.get(0));
|
||||
if(debugLevel > 3 || debugLevel < 0) {
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
MultiverseCore.GlobalDebug = debugLevel;
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Error" + ChatColor.WHITE + " setting debug level. Please use a number 0-3 " + ChatColor.AQUA + "(3 being many many messages!)");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
this.displayDebugMode(sender);
|
||||
}
|
||||
|
||||
private void displayDebugMode(CommandSender sender) {
|
||||
if (MultiverseCore.GlobalDebug == 0) {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
||||
} else {
|
||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + MultiverseCore.GlobalDebug);
|
||||
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED");
|
||||
}
|
||||
}
|
||||
}
|
@ -73,7 +73,11 @@ public class InfoCommand extends MultiverseCommand {
|
||||
}
|
||||
|
||||
if (this.plugin.isMVWorld(worldName)) {
|
||||
showPage(pageNum, sender, this.buildEntireCommand(this.plugin.getMVWorld(worldName)));
|
||||
Player p = null;
|
||||
if(sender instanceof Player) {
|
||||
p = (Player) sender;
|
||||
}
|
||||
showPage(pageNum, sender, this.buildEntireCommand(this.plugin.getMVWorld(worldName), p));
|
||||
} else if (this.plugin.getServer().getWorld(worldName) != null) {
|
||||
sender.sendMessage("That world exists, but multiverse does not know about it!");
|
||||
sender.sendMessage("You can import it with" + ChatColor.AQUA + "/mv import " + ChatColor.GREEN + worldName + ChatColor.LIGHT_PURPLE + "{ENV}");
|
||||
@ -81,7 +85,7 @@ public class InfoCommand extends MultiverseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private List<List<FancyText>> buildEntireCommand(MVWorld world) {
|
||||
private List<List<FancyText>> buildEntireCommand(MVWorld world, Player p) {
|
||||
List<FancyText> message = new ArrayList<FancyText>();
|
||||
List<List<FancyText>> worldInfo = new ArrayList<List<FancyText>>();
|
||||
// Page 1
|
||||
@ -94,7 +98,7 @@ public class InfoCommand extends MultiverseCommand {
|
||||
message.add(new FancyMessage("Spawn Location: ", "(" + spawn.getBlockX() + ", " + spawn.getBlockY() + ", " + spawn.getBlockZ() + ")", colors));
|
||||
message.add(new FancyMessage("World Scale: ", world.getScaling().toString(), colors));
|
||||
if (world.getPrice() > 0) {
|
||||
message.add(new FancyMessage("Price to enter this world: ", this.plugin.getBank().getFormattedAmount(world.getPrice(), world.getCurrency()), 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));
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.onarandombox.MultiverseCore.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -72,7 +73,17 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
teleporter = (Player) sender;
|
||||
teleportee = (Player) sender;
|
||||
}
|
||||
// Special case for cannons:
|
||||
if (destinationName.matches("(?i)cannon-[\\d]+(\\.[\\d]+)?")) {
|
||||
String[] cannonSpeed = destinationName.split("-");
|
||||
try {
|
||||
double speed = Double.parseDouble(cannonSpeed[1]);
|
||||
destinationName = "ca:" + teleportee.getWorld().getName() + ":" + teleportee.getLocation().getX() + "," + teleportee.getLocation().getY() + "," + teleportee.getLocation().getZ() + ":" + teleportee.getLocation().getPitch() + ":" + teleportee.getLocation().getYaw() + ":" + speed;
|
||||
} catch (Exception e) {
|
||||
destinationName = "i:invalid";
|
||||
}
|
||||
|
||||
}
|
||||
DestinationFactory df = this.plugin.getDestinationFactory();// .parseDestination(worldName, (MultiverseCore) this.plugin);
|
||||
MVDestination d = df.getDestination(destinationName);
|
||||
if (d != null && d instanceof InvalidDestination) {
|
||||
@ -101,6 +112,8 @@ public class TeleportCommand extends MultiverseCommand {
|
||||
return;
|
||||
}
|
||||
if (!this.playerTeleporter.safelyTeleport(teleportee, l)) {
|
||||
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName() + " to " + l);
|
||||
this.plugin.log(Level.FINE, "Queueing Command");
|
||||
Class<?> paramTypes[] = { Player.class, Location.class };
|
||||
List<Object> items = new ArrayList<Object>();
|
||||
items.add(teleportee);
|
||||
|
@ -1,47 +0,0 @@
|
||||
package com.onarandombox.MultiverseCore.listeners;
|
||||
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
//import org.bukkit.event.block.BlockRightClickEvent;
|
||||
|
||||
public class MVBlockListener extends BlockListener {
|
||||
|
||||
MultiverseCore plugin;
|
||||
|
||||
public MVBlockListener(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
// public void onBlockRightClicked(BlockRightClickEvent event){
|
||||
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int id = event.getChangedTypeId();
|
||||
|
||||
if (id == 90) { // && config.getBoolean("portalanywhere", false)
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void onBlockPlaced(BlockPlaceEvent event) {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -129,7 +129,7 @@ public class MVPlayerListener extends PlayerListener {
|
||||
return;
|
||||
}
|
||||
GenericBank bank = plugin.getBank();
|
||||
if (!bank.hasEnough(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency(), "You need " + bank.getFormattedAmount(toWorld.getPrice(), toWorld.getCurrency()) + " to enter " + toWorld.getColoredWorldString())) {
|
||||
if (!bank.hasEnough(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency(), "You need " + bank.getFormattedAmount(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency()) + " to enter " + toWorld.getColoredWorldString())) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
bank.pay(event.getPlayer(), toWorld.getPrice(), toWorld.getCurrency());
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -7,7 +9,15 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
public class BlockSafety {
|
||||
private MultiverseCore plugin;
|
||||
|
||||
public BlockSafety(MultiverseCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks whether the block at the given coordinates are above air or not.
|
||||
*
|
||||
@ -45,18 +55,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()) + "]");
|
||||
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()) + "]");
|
||||
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()) + "]");
|
||||
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) + "]");
|
||||
return this.hasTwoBlocksofWaterBelow(actual);
|
||||
}
|
||||
return true;
|
||||
@ -122,6 +139,12 @@ public class BlockSafety {
|
||||
return false;
|
||||
case SIGN_POST:
|
||||
return false;
|
||||
case WOODEN_DOOR:
|
||||
return false;
|
||||
case STATIONARY_WATER:
|
||||
return false;
|
||||
case WATER:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -145,41 +168,43 @@ public class BlockSafety {
|
||||
System.out.print("Location Down: " + downOne.getBlock().getType());
|
||||
System.out.print(" " + downOne);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks recursively below location L for 2 blocks of water
|
||||
*
|
||||
* @param l
|
||||
* @return
|
||||
*/
|
||||
public boolean hasTwoBlocksofWaterBelow(Location l) {
|
||||
if(l.getBlockY() < 0) {
|
||||
if (l.getBlockY() < 0) {
|
||||
return false;
|
||||
}
|
||||
Location oneBelow = l.clone();
|
||||
oneBelow.subtract(0, 1, 0);
|
||||
if(oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER) {
|
||||
if (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER) {
|
||||
Location twoBelow = oneBelow.clone();
|
||||
twoBelow.subtract(0, 1, 0);
|
||||
return (oneBelow.getBlock().getType() == Material.WATER || oneBelow.getBlock().getType() == Material.STATIONARY_WATER);
|
||||
}
|
||||
if(oneBelow.getBlock().getType() != Material.AIR) {
|
||||
if (oneBelow.getBlock().getType() != Material.AIR) {
|
||||
return false;
|
||||
}
|
||||
return hasTwoBlocksofWaterBelow(oneBelow);
|
||||
}
|
||||
|
||||
|
||||
public boolean canSpawnCartSafely(Minecart cart) {
|
||||
|
||||
if(this.isBlockAboveAir(cart.getLocation())) {
|
||||
|
||||
if (this.isBlockAboveAir(cart.getLocation())) {
|
||||
return true;
|
||||
}
|
||||
if(this.isEntitiyOnTrack(cart, LocationManipulation.getNextBlock(cart))) {
|
||||
return true;
|
||||
if (this.isEntitiyOnTrack(cart, LocationManipulation.getNextBlock(cart))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean canSpawnVehicleSafely(Vehicle vehicle) {
|
||||
if(this.isBlockAboveAir(vehicle.getLocation())) {
|
||||
if (this.isBlockAboveAir(vehicle.getLocation())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -30,7 +30,7 @@ public class LocationManipulation {
|
||||
* @param location
|
||||
* @return
|
||||
*/
|
||||
public String locationToString(Location location) {
|
||||
public static String locationToString(Location location) {
|
||||
StringBuilder l = new StringBuilder();
|
||||
l.append(location.getBlockX() + ":");
|
||||
l.append(location.getBlockY() + ":");
|
||||
@ -78,6 +78,19 @@ public class LocationManipulation {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String strCoordsRaw(Location l) {
|
||||
String result = "";
|
||||
DecimalFormat df = new DecimalFormat();
|
||||
df.setMinimumFractionDigits(0);
|
||||
df.setMaximumFractionDigits(2);
|
||||
result += "X: " + df.format(l.getX()) + " ";
|
||||
result += "Y: " + df.format(l.getY()) + " ";
|
||||
result += "Z: " + df.format(l.getZ()) + " ";
|
||||
result += "P: " + df.format(l.getPitch()) + " ";
|
||||
result += "Y: " + df.format(l.getYaw()) + " ";
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the NESW Direction a Location is facing.
|
||||
*
|
||||
|
5
src/main/java/com/onarandombox/utils/MVLevel.java
Normal file
5
src/main/java/com/onarandombox/utils/MVLevel.java
Normal file
@ -0,0 +1,5 @@
|
||||
package com.onarandombox.utils;
|
||||
|
||||
public class MVLevel {
|
||||
|
||||
}
|
@ -180,5 +180,9 @@ commands:
|
||||
/<command>
|
||||
mvhelp:
|
||||
description: Prints out version invo.
|
||||
usage: |
|
||||
/<command>
|
||||
mvdebug:
|
||||
description: Turns on debugging.
|
||||
usage: |
|
||||
/<command>
|
Loading…
Reference in New Issue
Block a user