Skip to content

Commit

Permalink
Fix code smells.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Mar 6, 2021
1 parent 8004e05 commit c042908
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public boolean canExecute(User user, String label, List<String> args) {

@Override
public boolean execute(User user, String label, List<String> args) {
boolean on = user.getMetaData(BorderShower.BORDER_STATE_META_DATA).map(md -> md.asBoolean()).orElse(addon.getSettings().isShowByDefault());
boolean on = user.getMetaData(BorderShower.BORDER_STATE_META_DATA).map(MetaDataValue::asBoolean).orElse(addon.getSettings().isShowByDefault());
if (on) {
user.sendMessage("border.toggle.border-off");
user.putMetaData(BorderShower.BORDER_STATE_META_DATA, new MetaDataValue(false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public interface BorderShower {
* Removes any cache
* @param user - user
*/
default public void clearUser(User user) {};
public default void clearUser(User user) {
// Do nothing
};


}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void onPlayerMove(PlayerMoveEvent e) {
public void onVehicleMove(VehicleMoveEvent e) {
// Remove head movement
if (!addon.getSettings().isUseWbapi() && !e.getFrom().toVector().equals(e.getTo().toVector())) {
e.getVehicle().getPassengers().stream().filter(en -> en instanceof Player).map(en -> (Player)en).forEach(p ->
e.getVehicle().getPassengers().stream().filter(Player.class::isInstance).map(Player.class::cast).forEach(p ->
addon.getIslands().getIslandAt(p.getLocation()).ifPresent(i -> barrier.showBorder(p, i)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector;

import world.bentobox.bentobox.api.metadata.MetaDataValue;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.util.Util;
Expand Down Expand Up @@ -108,7 +109,7 @@ private boolean outsideCheck(Player player, Location from, Location to) {
|| !addon.getSettings().isUseBarrierBlocks()
|| !addon.inGameWorld(player.getWorld())
|| !addon.getIslands().getIslandAt(to).filter(i -> addon.getIslands().locationIsOnIsland(player, i.getCenter())).isPresent()
|| !user.getMetaData(BorderShower.BORDER_STATE_META_DATA).map(md -> md.asBoolean()).orElse(addon.getSettings().isShowByDefault())) {
|| !user.getMetaData(BorderShower.BORDER_STATE_META_DATA).map(MetaDataValue::asBoolean).orElse(addon.getSettings().isShowByDefault())) {
return false;
}
return addon.getIslands().getIslandAt(to).filter(i -> !i.onIsland(to)).isPresent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void showBorder(Player player, Island island) {
|| !User.getInstance(player).getMetaData(BORDER_STATE_META_DATA).map(MetaDataValue::asBoolean).orElse(addon.getSettings().isShowByDefault())) {
return;
}
BorderAPI.getApi().setBorder(player, island.getProtectionRange() * 2, island.getProtectionCenter());
BorderAPI.getApi().setBorder(player, island.getProtectionRange() * 2D, island.getProtectionCenter());
}

@Override
Expand Down

0 comments on commit c042908

Please sign in to comment.