Code smells cleanup

Removed unnecessary cast in Island.
Combined if statement
Removed unnecessary {}
This commit is contained in:
Tastybento 2018-02-10 13:56:44 -08:00
parent 84e3ae3e8b
commit c76c854ed3
4 changed files with 10 additions and 20 deletions

View File

@ -316,8 +316,8 @@ public class Island implements DataObject {
*/ */
public int getTileEntityCount(Material material, World world) { public int getTileEntityCount(Material material, World world) {
int result = 0; int result = 0;
for (int x = (int) (getMinProtectedX() /16); x <= (getMinProtectedX() + getProtectionRange() - 1)/16; x++) { for (int x = getMinProtectedX() /16; x <= (getMinProtectedX() + getProtectionRange() - 1)/16; x++) {
for (int z = (int) (getMinProtectedZ() /16); z <= (getMinProtectedZ() + getProtectionRange() - 1)/16; z++) { for (int z = getMinProtectedZ() /16; z <= (getMinProtectedZ() + getProtectionRange() - 1)/16; z++) {
for (BlockState holder : world.getChunkAt(x, z).getTileEntities()) { for (BlockState holder : world.getChunkAt(x, z).getTileEntities()) {
//plugin.getLogger().info("DEBUG: tile entity: " + holder.getType()); //plugin.getLogger().info("DEBUG: tile entity: " + holder.getType());
if (onIsland(holder.getLocation())) { if (onIsland(holder.getLocation())) {

View File

@ -40,20 +40,14 @@ public class BucketListener extends AbstractFlagListener {
@EventHandler(priority = EventPriority.LOW) @EventHandler(priority = EventPriority.LOW)
public void onBucketFill(final PlayerBucketFillEvent e) { public void onBucketFill(final PlayerBucketFillEvent e) {
// Check filling of various liquids // Check filling of various liquids
if (e.getItemStack().getType().equals(Material.LAVA_BUCKET)) { if (e.getItemStack().getType().equals(Material.LAVA_BUCKET) && (!checkIsland(e, e.getBlockClicked().getLocation(), Flags.COLLECT_LAVA))) {
if (!checkIsland(e, e.getBlockClicked().getLocation(), Flags.COLLECT_LAVA)) { return;
return;
}
} }
if (e.getItemStack().getType().equals(Material.WATER_BUCKET)) { if (e.getItemStack().getType().equals(Material.WATER_BUCKET) && (!checkIsland(e, e.getBlockClicked().getLocation(), Flags.COLLECT_WATER))) {
if (!checkIsland(e, e.getBlockClicked().getLocation(), Flags.COLLECT_WATER)) { return;
return;
}
} }
if (e.getItemStack().getType().equals(Material.MILK_BUCKET)) { if (e.getItemStack().getType().equals(Material.MILK_BUCKET) && (!checkIsland(e, e.getBlockClicked().getLocation(), Flags.MILKING))) {
if (!checkIsland(e, e.getBlockClicked().getLocation(), Flags.MILKING)) { return;
return;
}
} }
// Check general bucket use // Check general bucket use
checkIsland(e, e.getBlockClicked().getLocation(), Flags.BUCKET); checkIsland(e, e.getBlockClicked().getLocation(), Flags.BUCKET);

View File

@ -170,9 +170,7 @@ public class HurtingListener extends AbstractFlagListener {
UUID uuid = ((Player)projectile.getShooter()).getUniqueId(); UUID uuid = ((Player)projectile.getShooter()).getUniqueId();
// Store it and remove it when the effect is gone // Store it and remove it when the effect is gone
thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid); thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid);
getPlugin().getServer().getScheduler().runTaskLater(getPlugin(), () -> { getPlugin().getServer().getScheduler().runTaskLater(getPlugin(), () -> thrownPotions.remove(e.getAreaEffectCloud().getEntityId()), e.getAreaEffectCloud().getDuration());
thrownPotions.remove(e.getAreaEffectCloud().getEntityId());
}, e.getAreaEffectCloud().getDuration());
} }
} }

View File

@ -132,9 +132,7 @@ public class PVPListener extends AbstractFlagListener {
UUID uuid = ((Player)projectile.getShooter()).getUniqueId(); UUID uuid = ((Player)projectile.getShooter()).getUniqueId();
// Store it and remove it when the effect is gone // Store it and remove it when the effect is gone
thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid); thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid);
getPlugin().getServer().getScheduler().runTaskLater(getPlugin(), () -> { getPlugin().getServer().getScheduler().runTaskLater(getPlugin(), () -> thrownPotions.remove(e.getAreaEffectCloud().getEntityId()), e.getAreaEffectCloud().getDuration());
thrownPotions.remove(e.getAreaEffectCloud().getEntityId());
}, e.getAreaEffectCloud().getDuration());
} }
} }