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) {
int result = 0;
for (int x = (int) (getMinProtectedX() /16); x <= (getMinProtectedX() + getProtectionRange() - 1)/16; x++) {
for (int z = (int) (getMinProtectedZ() /16); z <= (getMinProtectedZ() + getProtectionRange() - 1)/16; z++) {
for (int x = getMinProtectedX() /16; x <= (getMinProtectedX() + getProtectionRange() - 1)/16; x++) {
for (int z = getMinProtectedZ() /16; z <= (getMinProtectedZ() + getProtectionRange() - 1)/16; z++) {
for (BlockState holder : world.getChunkAt(x, z).getTileEntities()) {
//plugin.getLogger().info("DEBUG: tile entity: " + holder.getType());
if (onIsland(holder.getLocation())) {

View File

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

View File

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