mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-29 12:37:37 +01:00
Fixed some code smells
This commit is contained in:
parent
3d7ef58323
commit
4897d8ef77
@ -315,10 +315,9 @@ public class Island implements DataObject {
|
||||
}
|
||||
} else if (material.toString().endsWith("BANNER") && holder.getType().toString().endsWith("BANNER")) {
|
||||
result++;
|
||||
} else if (material.equals(Material.WALL_SIGN) || material.equals(Material.SIGN_POST)) {
|
||||
if (holder.getType().equals(Material.WALL_SIGN) || holder.getType().equals(Material.SIGN_POST)) {
|
||||
result++;
|
||||
}
|
||||
} else if ((material.equals(Material.WALL_SIGN) || material.equals(Material.SIGN_POST))
|
||||
&& (holder.getType().equals(Material.WALL_SIGN) || holder.getType().equals(Material.SIGN_POST))) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,14 +111,12 @@ public class NetherPopulator extends BlockPopulator {
|
||||
} else if (b.getType().equals(Material.DIRT)) {
|
||||
world.generateTree(source.getBlock(x, y + 1, z).getLocation(), TreeType.BROWN_MUSHROOM);
|
||||
b.setType(Material.SOUL_SAND);
|
||||
} else if (b.getType().equals(Material.SOUL_SAND) && b.getRelative(BlockFace.UP).getType().equals(Material.AIR)) {
|
||||
if (random.nextInt(9) == 1) {
|
||||
b.getRelative(BlockFace.UP).setType(Material.NETHER_WARTS);
|
||||
}
|
||||
} else if (b.getType().equals(Material.SOUL_SAND) && b.getRelative(BlockFace.UP).getType().equals(Material.AIR)
|
||||
&& random.nextInt(9) == 1) {
|
||||
b.getRelative(BlockFace.UP).setType(Material.NETHER_WARTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -378,14 +378,11 @@ public class Clipboard {
|
||||
try (ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(targetFile.getAbsolutePath() + ".schem"))) {
|
||||
zipOutputStream.putNextEntry(new ZipEntry(targetFile.getName()));
|
||||
try (FileInputStream inputStream = new FileInputStream(targetFile)) {
|
||||
|
||||
final byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while((length = inputStream.read(buffer)) >= 0) {
|
||||
zipOutputStream.write(buffer, 0, length);
|
||||
}
|
||||
inputStream.close();
|
||||
zipOutputStream.close();
|
||||
try {
|
||||
Files.delete(targetFile.toPath());
|
||||
} catch (Exception e) {
|
||||
|
@ -134,15 +134,14 @@ public abstract class AbstractFlagListener implements Listener {
|
||||
|
||||
// Protection flag
|
||||
// If the user is not set already, try to get it from the event
|
||||
if (user == null) {
|
||||
// Set the user associated with this event
|
||||
if (!createEventUser(e)) {
|
||||
// The user is not set, and the event does not hold a getPlayer, so return false
|
||||
// TODO: is this the correct handling here?
|
||||
plugin.logError("Check island had no associated user! " + e.getEventName());
|
||||
return false;
|
||||
}
|
||||
// Set the user associated with this event
|
||||
// The user is not set, and the event does not hold a getPlayer, so return false
|
||||
// TODO: is this the correct handling here?
|
||||
if (user == null && !createEventUser(e)) {
|
||||
plugin.logError("Check island had no associated user! " + e.getEventName());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the plugin is set in User (required for testing)
|
||||
User.setPlugin(plugin);
|
||||
|
||||
|
@ -128,13 +128,10 @@ public class BreakBlocksListener extends AbstractFlagListener {
|
||||
} else if (e.getDamager() instanceof Projectile) {
|
||||
// Find out who fired the arrow
|
||||
Projectile p = (Projectile) e.getDamager();
|
||||
if (p.getShooter() instanceof Player) {
|
||||
if (!setUser(User.getInstance((Player)p.getShooter())).checkIsland(e, e.getEntity().getLocation(), Flags.BREAK_BLOCKS)) {
|
||||
e.getEntity().setFireTicks(0);
|
||||
e.getDamager().remove();
|
||||
}
|
||||
if (p.getShooter() instanceof Player && !setUser(User.getInstance((Player)p.getShooter())).checkIsland(e, e.getEntity().getLocation(), Flags.BREAK_BLOCKS)) {
|
||||
e.getEntity().setFireTicks(0);
|
||||
e.getDamager().remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class BreedingListener extends AbstractFlagListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
|
||||
public void onPlayerInteract(final PlayerInteractAtEntityEvent e) {
|
||||
if (e.getRightClicked() != null && e.getRightClicked() instanceof Animals) {
|
||||
if (e.getRightClicked() instanceof Animals) {
|
||||
ItemStack inHand = e.getPlayer().getInventory().getItemInMainHand();
|
||||
if (e.getHand().equals(EquipmentSlot.OFF_HAND)) {
|
||||
inHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
|
@ -118,7 +118,7 @@ public class HurtingListener extends AbstractFlagListener {
|
||||
public void onSplashPotionSplash(final PotionSplashEvent e) {
|
||||
// Try to get the shooter
|
||||
Projectile projectile = e.getEntity();
|
||||
if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) {
|
||||
if (projectile.getShooter() instanceof Player) {
|
||||
Player attacker = (Player)projectile.getShooter();
|
||||
// Run through all the affected entities
|
||||
for (LivingEntity entity: e.getAffectedEntities()) {
|
||||
@ -162,7 +162,7 @@ public class HurtingListener extends AbstractFlagListener {
|
||||
public void onLingeringPotionSplash(final LingeringPotionSplashEvent e) {
|
||||
// Try to get the shooter
|
||||
Projectile projectile = e.getEntity();
|
||||
if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) {
|
||||
if (projectile.getShooter() instanceof Player) {
|
||||
UUID uuid = ((Player)projectile.getShooter()).getUniqueId();
|
||||
// Store it and remove it when the effect is gone
|
||||
thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid);
|
||||
|
@ -69,7 +69,7 @@ public class PVPListener extends AbstractFlagListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onFishing(PlayerFishEvent e) {
|
||||
if (e.getCaught() != null && e.getCaught() instanceof Player) {
|
||||
if (e.getCaught() instanceof Player) {
|
||||
Flag flag = Flags.PVP_OVERWORLD;
|
||||
if (e.getCaught().getWorld().equals(getPlugin().getIWM().getNetherWorld())) {
|
||||
flag = Flags.PVP_NETHER;
|
||||
@ -98,7 +98,7 @@ public class PVPListener extends AbstractFlagListener {
|
||||
|
||||
// Try to get the thrower
|
||||
Projectile projectile = e.getEntity();
|
||||
if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) {
|
||||
if (projectile.getShooter() instanceof Player) {
|
||||
Player attacker = (Player)projectile.getShooter();
|
||||
// Run through all the affected entities
|
||||
for (LivingEntity entity: e.getAffectedEntities()) {
|
||||
@ -122,7 +122,7 @@ public class PVPListener extends AbstractFlagListener {
|
||||
public void onLingeringPotionSplash(final LingeringPotionSplashEvent e) {
|
||||
// Try to get the shooter
|
||||
Projectile projectile = e.getEntity();
|
||||
if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) {
|
||||
if (projectile.getShooter() instanceof Player) {
|
||||
UUID uuid = ((Player) projectile.getShooter()).getUniqueId();
|
||||
// Store it and remove it when the effect is gone
|
||||
thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid);
|
||||
|
@ -142,12 +142,10 @@ public class FlyingMobEvents implements Listener {
|
||||
if (e.getEntityType() != EntityType.WITHER || !plugin.getIWM().inWorld(e.getEntity().getLocation()) ) {
|
||||
return;
|
||||
}
|
||||
if (mobSpawnInfo.containsKey(e.getEntity())) {
|
||||
if (mobSpawnInfo.containsKey(e.getEntity()) && !mobSpawnInfo.get(e.getEntity()).inIslandSpace(e.getEntity().getLocation())) {
|
||||
// We know about this wither
|
||||
if (!mobSpawnInfo.get(e.getEntity()).inIslandSpace(e.getEntity().getLocation())) {
|
||||
// Cancel the block changes
|
||||
e.setCancelled(true);
|
||||
}
|
||||
// Cancel the block changes
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,11 +378,9 @@ public class IslandsManager {
|
||||
} else {
|
||||
// try team leader's home
|
||||
Location tlh = plugin.getPlayers().getHomeLocation(world, plugin.getIslands().getTeamLeader(world, user.getUniqueId()));
|
||||
if (tlh != null) {
|
||||
if (isSafeLocation(tlh)) {
|
||||
plugin.getPlayers().setHomeLocation(user, tlh, number);
|
||||
return tlh;
|
||||
}
|
||||
if (tlh != null && isSafeLocation(tlh)) {
|
||||
plugin.getPlayers().setHomeLocation(user, tlh, number);
|
||||
return tlh;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user