mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-24 08:12:23 +01:00
Fixed some code smells
This commit is contained in:
parent
a27f54a6f7
commit
5ef74bd0f4
@ -67,7 +67,7 @@ public class AdminRegisterCommand extends ConfirmableCommand {
|
||||
return false;
|
||||
}
|
||||
// Check if island is spawn
|
||||
if (island.map(i -> i.isSpawn()).orElse(false)) {
|
||||
if (island.map(Island::isSpawn).orElse(false)) {
|
||||
askConfirmation(user, user.getTranslation("commands.admin.register.island-is-spawn"), () -> register(user, targetUUID, island, closestIsland));
|
||||
return false;
|
||||
}
|
||||
|
@ -30,6 +30,12 @@ public class IslandTeamCommand extends CompositeCommand {
|
||||
*/
|
||||
private Map<UUID, Invite> inviteMap;
|
||||
|
||||
/**
|
||||
* Contains the text variable for units.
|
||||
* @since 1.9.0
|
||||
*/
|
||||
private final String UNIT = "[unit]";
|
||||
|
||||
private IslandTeamInviteCommand inviteCommand;
|
||||
|
||||
public IslandTeamCommand(CompositeCommand parent) {
|
||||
@ -137,15 +143,15 @@ public class IslandTeamCommand extends CompositeCommand {
|
||||
if (duration.toMinutes() < 60L) {
|
||||
lastSeen = user.getTranslation(reference,
|
||||
TextVariables.NUMBER, String.valueOf(duration.toMinutes()),
|
||||
"[unit]", user.getTranslation("commands.island.team.info.last-seen.minutes"));
|
||||
UNIT, user.getTranslation("commands.island.team.info.last-seen.minutes"));
|
||||
} else if (duration.toHours() < 24L) {
|
||||
lastSeen = user.getTranslation(reference,
|
||||
TextVariables.NUMBER, String.valueOf(duration.toHours()),
|
||||
"[unit]", user.getTranslation("commands.island.team.info.last-seen.hours"));
|
||||
UNIT, user.getTranslation("commands.island.team.info.last-seen.hours"));
|
||||
} else {
|
||||
lastSeen = user.getTranslation(reference,
|
||||
TextVariables.NUMBER, String.valueOf(duration.toDays()),
|
||||
"[unit]", user.getTranslation("commands.island.team.info.last-seen.days"));
|
||||
UNIT, user.getTranslation("commands.island.team.info.last-seen.days"));
|
||||
}
|
||||
|
||||
user.sendMessage("commands.island.team.info.member-layout.offline",
|
||||
|
@ -111,35 +111,6 @@ public class IslandTeamTrustCommand extends CompositeCommand {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||
if (island != null) {
|
||||
if (getPlugin().getSettings().isInviteConfirmation()) {
|
||||
if (itc.isInvited(targetUUID) && itc.getInviter(targetUUID).equals(user.getUniqueId()) && itc.getInvite(targetUUID).getType().equals(Type.TRUST)) {
|
||||
// Prevent spam
|
||||
user.sendMessage("commands.island.team.invite.errors.you-have-already-invited");
|
||||
return false;
|
||||
}
|
||||
// Put the invited player (key) onto the list with inviter (value)
|
||||
// If someone else has invited a player, then this invite will overwrite the previous invite!
|
||||
itc.addInvite(Type.TRUST, user.getUniqueId(), target.getUniqueId());
|
||||
user.sendMessage("commands.island.team.invite.invitation-sent", TextVariables.NAME, target.getName());
|
||||
// Send message to online player
|
||||
target.sendMessage("commands.island.team.trust.name-has-invited-you", TextVariables.NAME, user.getName());
|
||||
target.sendMessage("commands.island.team.invite.to-accept-or-reject", TextVariables.LABEL, getTopLabel());
|
||||
} else {
|
||||
island.setRank(target, RanksManager.TRUSTED_RANK);
|
||||
user.sendMessage("commands.island.team.trust.success", TextVariables.NAME, target.getName());
|
||||
target.sendMessage("commands.island.team.trust.you-are-trusted", TextVariables.NAME, user.getName());
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// Should not happen
|
||||
user.sendMessage("general.errors.general");
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||
if (args.isEmpty()) {
|
||||
|
@ -159,8 +159,8 @@ public class BlueprintPaster {
|
||||
// Tell the owner we're pasting blocks and how much time it might take
|
||||
owner.ifPresent(user -> {
|
||||
// Estimated time:
|
||||
double total = blocks.size() + attached.size() + entities.size();
|
||||
BigDecimal time = new BigDecimal(total / (pasteSpeed * 20.0D)).setScale(1, RoundingMode.UP);
|
||||
double total = (double) blocks.size() + attached.size() + entities.size();
|
||||
BigDecimal time = BigDecimal.valueOf(total / (pasteSpeed * 20.0D)).setScale(1, RoundingMode.UP);
|
||||
user.sendMessage("commands.island.create.pasting.estimated-time", TextVariables.NUMBER, String.valueOf(time.doubleValue()));
|
||||
// We're pasting blocks!
|
||||
user.sendMessage("commands.island.create.pasting.blocks", TextVariables.NUMBER, String.valueOf(blocks.size() + attached.size()));
|
||||
|
@ -299,28 +299,28 @@ public class IslandWorldManager {
|
||||
* @return the endGenerate
|
||||
*/
|
||||
public boolean isEndGenerate(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isEndGenerate() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isEndGenerate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the endIslands
|
||||
*/
|
||||
public boolean isEndIslands(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isEndIslands() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isEndIslands();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the netherGenerate
|
||||
*/
|
||||
public boolean isNetherGenerate(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isNetherGenerate() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isNetherGenerate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the netherIslands
|
||||
*/
|
||||
public boolean isNetherIslands(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isNetherIslands() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isNetherIslands();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -511,21 +511,21 @@ public class IslandWorldManager {
|
||||
* @return the onJoinResetMoney
|
||||
*/
|
||||
public boolean isOnJoinResetMoney(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnJoinResetMoney() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnJoinResetMoney();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the onJoinResetInventory
|
||||
*/
|
||||
public boolean isOnJoinResetInventory(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnJoinResetInventory() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnJoinResetInventory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the onJoinResetEnderChest
|
||||
*/
|
||||
public boolean isOnJoinResetEnderChest(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnJoinResetEnderChest() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnJoinResetEnderChest();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -535,7 +535,7 @@ public class IslandWorldManager {
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public boolean isOnJoinResetHealth(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnJoinResetHealth() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnJoinResetHealth();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -545,7 +545,7 @@ public class IslandWorldManager {
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public boolean isOnJoinResetHunger(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnJoinResetHunger() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnJoinResetHunger();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -555,7 +555,7 @@ public class IslandWorldManager {
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public boolean isOnJoinResetXP(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnJoinResetXP() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnJoinResetXP();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -574,21 +574,21 @@ public class IslandWorldManager {
|
||||
* @return the onLeaveResetMoney
|
||||
*/
|
||||
public boolean isOnLeaveResetMoney(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnLeaveResetMoney() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnLeaveResetMoney();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the onLeaveResetInventory
|
||||
*/
|
||||
public boolean isOnLeaveResetInventory(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnLeaveResetInventory() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnLeaveResetInventory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the onLeaveResetEnderChest
|
||||
*/
|
||||
public boolean isOnLeaveResetEnderChest(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnLeaveResetEnderChest() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnLeaveResetEnderChest();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -598,7 +598,7 @@ public class IslandWorldManager {
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public boolean isOnLeaveResetHealth(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnLeaveResetHealth() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnLeaveResetHealth();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -608,7 +608,7 @@ public class IslandWorldManager {
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public boolean isOnLeaveResetHunger(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnLeaveResetHunger() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnLeaveResetHunger();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -618,7 +618,7 @@ public class IslandWorldManager {
|
||||
* @since 1.8.0
|
||||
*/
|
||||
public boolean isOnLeaveResetXP(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isOnLeaveResetXP() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isOnLeaveResetXP();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -684,7 +684,7 @@ public class IslandWorldManager {
|
||||
}
|
||||
|
||||
public boolean isUseOwnGenerator(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isUseOwnGenerator() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isUseOwnGenerator();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -709,7 +709,7 @@ public class IslandWorldManager {
|
||||
* @return true if water is not safe, e.g.for home locations
|
||||
*/
|
||||
public boolean isWaterNotSafe(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isWaterUnsafe() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isWaterUnsafe();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -753,7 +753,7 @@ public class IslandWorldManager {
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean isTeamJoinDeathReset(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isTeamJoinDeathReset() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isTeamJoinDeathReset();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -764,7 +764,7 @@ public class IslandWorldManager {
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public boolean isDeathsResetOnNewIsland(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isDeathsResetOnNewIsland() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isDeathsResetOnNewIsland();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -789,14 +789,14 @@ public class IslandWorldManager {
|
||||
* @return whether leavers should lose a reset or not
|
||||
*/
|
||||
public boolean isLeaversLoseReset(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isLeaversLoseReset() : false;
|
||||
return gameModes.containsKey(world) && gameModes.get(world).getWorldSettings().isLeaversLoseReset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether players keep their inventory if they are kicked. Overrides leave inventory clearing
|
||||
*/
|
||||
public boolean isKickedKeepInventory(@NonNull World world) {
|
||||
return gameModes.containsKey(world) ? gameModes.get(world).getWorldSettings().isKickedKeepInventory() : true;
|
||||
return !gameModes.containsKey(world) || gameModes.get(world).getWorldSettings().isKickedKeepInventory();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user