mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-09-10 14:27:59 +02:00
Fixed some code smells
This commit is contained in:
parent
e4cedb58d0
commit
97b9543f15
@ -50,14 +50,11 @@ public class IslandCommand extends CompositeCommand {
|
||||
@Override
|
||||
public boolean execute(User user, List<String> args) {
|
||||
// If this player does not have an island, create one
|
||||
|
||||
if (!getPlugin().getIslands().hasIsland(user.getUniqueId())) {
|
||||
getSubCommand("create").ifPresent(createCmd -> createCmd.execute(user, new ArrayList<>()));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise, currently, just go home
|
||||
getSubCommand("go").ifPresent(goCmd -> goCmd.execute(user, new ArrayList<>()));
|
||||
else getSubCommand("go").ifPresent(goCmd -> goCmd.execute(user, new ArrayList<>()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -38,10 +38,10 @@ public class PanelListenerManager implements Listener {
|
||||
if (slot == event.getRawSlot()) {
|
||||
// Check that they left clicked on it
|
||||
// TODO: in the future, we may want to support right clicking
|
||||
panel.getItems().get(slot).getClickHandler().ifPresent(handler -> {
|
||||
panel.getItems().get(slot).getClickHandler().ifPresent(handler ->
|
||||
// Execute the handler's onClick method and optionally cancel the event if the handler returns true
|
||||
event.setCancelled(handler.onClick(user, ClickType.LEFT));
|
||||
});
|
||||
event.setCancelled(handler.onClick(user, ClickType.LEFT))
|
||||
);
|
||||
}
|
||||
}
|
||||
// If there is a listener, then run it.
|
||||
|
@ -40,14 +40,10 @@ public class FireListener extends AbstractFlagListener {
|
||||
public boolean checkFire(Cancellable e, Location l, Flag flag) {
|
||||
// Check world
|
||||
if (!inWorld(l)) {
|
||||
//Bukkit.getLogger().info("DEBUG: not in world");
|
||||
return false;
|
||||
}
|
||||
//Bukkit.getLogger().info("DEBUG: in world");
|
||||
// Check if the island exists and if fire is allowed
|
||||
boolean cancel = getIslands().getIslandAt(l).map(i -> {
|
||||
return !i.isAllowed(flag);
|
||||
}).orElse(!flag.isDefaultSetting());
|
||||
boolean cancel = getIslands().getIslandAt(l).map(i -> !i.isAllowed(flag)).orElse(!flag.isDefaultSetting());
|
||||
|
||||
e.setCancelled(cancel);
|
||||
return cancel;
|
||||
|
@ -46,15 +46,11 @@ public class MobSpawnListener extends AbstractFlagListener {
|
||||
Optional<Island> island = getIslands().getIslandAt(e.getLocation());
|
||||
// Cancel the event if these are true
|
||||
if ((e.getEntity() instanceof Monster || e.getEntity() instanceof Slime)) {
|
||||
boolean cancel = island.map(i -> {
|
||||
return !i.isAllowed(Flags.MOB_SPAWN);
|
||||
}).orElse(!Flags.MOB_SPAWN.isDefaultSetting());
|
||||
boolean cancel = island.map(i -> !i.isAllowed(Flags.MOB_SPAWN)).orElse(!Flags.MOB_SPAWN.isDefaultSetting());
|
||||
e.setCancelled(cancel);
|
||||
return cancel;
|
||||
} else if (e.getEntity() instanceof Animals) {
|
||||
boolean cancel = island.map(i -> {
|
||||
return !i.isAllowed(Flags.MONSTER_SPAWN);
|
||||
}).orElse(!Flags.MONSTER_SPAWN.isDefaultSetting());
|
||||
boolean cancel = island.map(i -> !i.isAllowed(Flags.MONSTER_SPAWN)).orElse(!Flags.MONSTER_SPAWN.isDefaultSetting());
|
||||
e.setCancelled(cancel);
|
||||
return cancel;
|
||||
}
|
||||
|
@ -60,7 +60,6 @@ public class PVPListener extends AbstractFlagListener {
|
||||
// Find out who fired the arrow
|
||||
Projectile p = (Projectile) damager;
|
||||
if (p.getShooter() instanceof Player) {
|
||||
;
|
||||
if (!setUser(User.getInstance((Player)p.getShooter())).checkIsland(event, damager.getLocation(), flag)) {
|
||||
damager.setFireTicks(0);
|
||||
damager.remove();
|
||||
|
@ -90,7 +90,7 @@ public class FlyingMobEvents implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void MobExplosion(EntityExplodeEvent e) {
|
||||
public void mobExplosion(EntityExplodeEvent e) {
|
||||
if (DEBUG) {
|
||||
plugin.getLogger().info(e.getEventName());
|
||||
}
|
||||
@ -118,7 +118,7 @@ public class FlyingMobEvents implements Listener {
|
||||
* Deal with pre-explosions
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void WitherExplode(ExplosionPrimeEvent e) {
|
||||
public void witherExplode(ExplosionPrimeEvent e) {
|
||||
if (DEBUG) {
|
||||
plugin.getLogger().info(e.getEventName());
|
||||
}
|
||||
@ -176,7 +176,7 @@ public class FlyingMobEvents implements Listener {
|
||||
* @param e - event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void WitherChangeBlocks(EntityChangeBlockEvent e) {
|
||||
public void witherChangeBlocks(EntityChangeBlockEvent e) {
|
||||
if (DEBUG) {
|
||||
plugin.getLogger().info(e.getEventName());
|
||||
}
|
||||
@ -203,7 +203,7 @@ public class FlyingMobEvents implements Listener {
|
||||
* Clean up the hashmap. It's probably not needed, but just in case.
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void MobDeath(EntityDeathEvent e) {
|
||||
public void mobDeath(EntityDeathEvent e) {
|
||||
mobSpawnInfo.remove(e.getEntity());
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ public class LocalesManager {
|
||||
|
||||
private BSkyBlock plugin;
|
||||
private HashMap<Locale, BSBLocale> languages = new HashMap<>();
|
||||
final static String LOCALE_FOLDER = "locales";
|
||||
private static final String LOCALE_FOLDER = "locales";
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
public LocalesManager(BSkyBlock plugin) {
|
||||
|
@ -53,7 +53,7 @@ public class Util {
|
||||
* - serialized location in format "world:x:y:z"
|
||||
* @return Location
|
||||
*/
|
||||
static public Location getLocationString(final String s) {
|
||||
public static Location getLocationString(final String s) {
|
||||
if (s == null || s.trim().equals("")) {
|
||||
return null;
|
||||
}
|
||||
@ -89,7 +89,7 @@ public class Util {
|
||||
* @param location - the location
|
||||
* @return String of location
|
||||
*/
|
||||
static public String getStringLocation(final Location location) {
|
||||
public static String getStringLocation(final Location location) {
|
||||
if (location == null || location.getWorld() == null) {
|
||||
return "";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user