mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-30 13:07:46 +01:00
Code smells ; minor code format issues
This commit is contained in:
parent
f8da453a29
commit
f10c2da7d3
@ -14,7 +14,7 @@ public class AdminVersionCommand extends CompositeCommand {
|
||||
@Override
|
||||
public void setup() {
|
||||
// Permission
|
||||
setPermission(getPermissionPrefix() + "admin.version");
|
||||
setPermission("admin.version");
|
||||
setDescription("commands.admin.version.description");
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,6 @@ public class AdminRangeDisplayCommand extends CompositeCommand {
|
||||
}
|
||||
|
||||
private void drawZone(Player player, Particle particle, Location center, int range) {
|
||||
|
||||
// Get player Y coordinate
|
||||
int playerY = player.getLocation().getBlockY() + 1;
|
||||
|
||||
@ -108,10 +107,10 @@ public class AdminRangeDisplayCommand extends CompositeCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnParticle(Player player, Particle particle, int i, int j, int k) {
|
||||
// Check if this particle is beyond the viewing distance of the sever
|
||||
if (player.getLocation().toVector().distanceSquared(new Vector(i,j,k)) < (Bukkit.getServer().getViewDistance()*256*Bukkit.getServer().getViewDistance())) {
|
||||
player.spawnParticle(particle, i, j, k, 1);
|
||||
private void spawnParticle(Player player, Particle particle, int x, int y, int z) {
|
||||
// Check if this particle is beyond the viewing distance of the server
|
||||
if (player.getLocation().toVector().distanceSquared(new Vector(x,y,z)) < (Bukkit.getServer().getViewDistance()*256*Bukkit.getServer().getViewDistance())) {
|
||||
player.spawnParticle(particle, x, y, z, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,70 +44,6 @@ import us.tastybento.bskyblock.util.teleport.SafeTeleportBuilder;
|
||||
*/
|
||||
public class IslandsManager {
|
||||
|
||||
/**
|
||||
* Checks if this location is safe for a player to teleport to. Used by
|
||||
* warps and boat exits Unsafe is any liquid or air and also if there's no
|
||||
* space
|
||||
*
|
||||
* @param l
|
||||
* - Location to be checked
|
||||
* @return true if safe, otherwise false
|
||||
*/
|
||||
public boolean isSafeLocation(Location l) {
|
||||
if (l == null) {
|
||||
return false;
|
||||
}
|
||||
Block ground = l.getBlock().getRelative(BlockFace.DOWN);
|
||||
Block space1 = l.getBlock();
|
||||
Block space2 = l.getBlock().getRelative(BlockFace.UP);
|
||||
|
||||
// Ground must be solid
|
||||
if (!ground.getType().isSolid()) {
|
||||
return false;
|
||||
}
|
||||
// Cannot be submerged
|
||||
if (space1.isLiquid() && space2.isLiquid()) {
|
||||
return false;
|
||||
}
|
||||
// Check if water is safe in this world
|
||||
if (space1.isLiquid() && plugin.getIWM().isWaterNotSafe(l.getWorld())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Portals are not "safe"
|
||||
if (space1.getType() == Material.PORTAL || ground.getType() == Material.PORTAL || space2.getType() == Material.PORTAL
|
||||
|| space1.getType() == Material.ENDER_PORTAL || ground.getType() == Material.ENDER_PORTAL || space2.getType() == Material.ENDER_PORTAL) {
|
||||
return false;
|
||||
}
|
||||
if (ground.getType().equals(Material.STATIONARY_LAVA) || ground.getType().equals(Material.LAVA)
|
||||
|| space1.getType().equals(Material.STATIONARY_LAVA) || space1.getType().equals(Material.LAVA)
|
||||
|| space2.getType().equals(Material.STATIONARY_LAVA) || space2.getType().equals(Material.LAVA)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MaterialData md = ground.getState().getData();
|
||||
if (md instanceof SimpleAttachableMaterialData) {
|
||||
if (md instanceof TrapDoor) {
|
||||
TrapDoor trapDoor = (TrapDoor) md;
|
||||
if (trapDoor.isOpen()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (ground.getType().equals(Material.CACTUS) || ground.getType().equals(Material.BOAT) || ground.getType().toString().contains("FENCE")
|
||||
|| ground.getType().equals(Material.SIGN_POST) || ground.getType().equals(Material.WALL_SIGN)) {
|
||||
return false;
|
||||
}
|
||||
// Check that the space is not solid
|
||||
// The isSolid function is not fully accurate (yet) so we have to
|
||||
// check
|
||||
// a few other items
|
||||
// isSolid thinks that PLATEs and SIGNS are solid, but they are not
|
||||
return (!space1.getType().isSolid() || space1.getType().equals(Material.SIGN_POST) || space1.getType().equals(Material.WALL_SIGN)) && (!space2.getType().isSolid() || space2.getType().equals(Material.SIGN_POST) || space2.getType().equals(Material.WALL_SIGN));
|
||||
}
|
||||
|
||||
private BSkyBlock plugin;
|
||||
|
||||
/**
|
||||
@ -221,6 +157,70 @@ public class IslandsManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this location is safe for a player to teleport to. Used by
|
||||
* warps and boat exits Unsafe is any liquid or air and also if there's no
|
||||
* space
|
||||
*
|
||||
* @param l
|
||||
* - Location to be checked
|
||||
* @return true if safe, otherwise false
|
||||
*/
|
||||
public boolean isSafeLocation(Location l) {
|
||||
if (l == null) {
|
||||
return false;
|
||||
}
|
||||
Block ground = l.getBlock().getRelative(BlockFace.DOWN);
|
||||
Block space1 = l.getBlock();
|
||||
Block space2 = l.getBlock().getRelative(BlockFace.UP);
|
||||
|
||||
// Ground must be solid
|
||||
if (!ground.getType().isSolid()) {
|
||||
return false;
|
||||
}
|
||||
// Cannot be submerged
|
||||
if (space1.isLiquid() && space2.isLiquid()) {
|
||||
return false;
|
||||
}
|
||||
// Check if water is safe in this world
|
||||
if (space1.isLiquid() && plugin.getIWM().isWaterNotSafe(l.getWorld())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Portals are not "safe"
|
||||
if (space1.getType() == Material.PORTAL || ground.getType() == Material.PORTAL || space2.getType() == Material.PORTAL
|
||||
|| space1.getType() == Material.ENDER_PORTAL || ground.getType() == Material.ENDER_PORTAL || space2.getType() == Material.ENDER_PORTAL) {
|
||||
return false;
|
||||
}
|
||||
if (ground.getType().equals(Material.STATIONARY_LAVA) || ground.getType().equals(Material.LAVA)
|
||||
|| space1.getType().equals(Material.STATIONARY_LAVA) || space1.getType().equals(Material.LAVA)
|
||||
|| space2.getType().equals(Material.STATIONARY_LAVA) || space2.getType().equals(Material.LAVA)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MaterialData md = ground.getState().getData();
|
||||
if (md instanceof SimpleAttachableMaterialData) {
|
||||
if (md instanceof TrapDoor) {
|
||||
TrapDoor trapDoor = (TrapDoor) md;
|
||||
if (trapDoor.isOpen()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (ground.getType().equals(Material.CACTUS) || ground.getType().equals(Material.BOAT) || ground.getType().toString().contains("FENCE")
|
||||
|| ground.getType().equals(Material.SIGN_POST) || ground.getType().equals(Material.WALL_SIGN)) {
|
||||
return false;
|
||||
}
|
||||
// Check that the space is not solid
|
||||
// The isSolid function is not fully accurate (yet) so we have to
|
||||
// check
|
||||
// a few other items
|
||||
// isSolid thinks that PLATEs and SIGNS are solid, but they are not
|
||||
return (!space1.getType().isSolid() || space1.getType().equals(Material.SIGN_POST) || space1.getType().equals(Material.WALL_SIGN)) && (!space2.getType().isSolid() || space2.getType().equals(Material.SIGN_POST) || space2.getType().equals(Material.WALL_SIGN));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an island with no owner at location
|
||||
* @param location - the location - location
|
||||
@ -804,7 +804,6 @@ public class IslandsManager {
|
||||
island.setProtectionRange(range);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,7 +161,6 @@ public class PanelItemBuilderTest {
|
||||
|
||||
@Override
|
||||
public boolean onClick(Panel panel, User user, ClickType click, int slot) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user