mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-10-02 16:47:38 +02:00
Fixed code smells
This commit is contained in:
parent
76d4edd19f
commit
457b296372
@ -97,17 +97,15 @@ public class IslandBanCommand extends CompositeCommand {
|
||||
.build();
|
||||
|
||||
// Event is not cancelled
|
||||
if (!banEvent.isCancelled()) {
|
||||
if (island.ban(issuer.getUniqueId(), target.getUniqueId())) {
|
||||
issuer.sendMessage("general.success");
|
||||
target.sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, issuer.getName());
|
||||
// If the player is online, has an island and on the banned island, move them home immediately
|
||||
if (target.isOnline() && getIslands().hasIsland(getWorld(), target.getUniqueId()) && island.onIsland(target.getLocation())) {
|
||||
getIslands().homeTeleport(getWorld(), target.getPlayer());
|
||||
island.getWorld().playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
||||
}
|
||||
return true;
|
||||
if (!banEvent.isCancelled() && island.ban(issuer.getUniqueId(), target.getUniqueId())) {
|
||||
issuer.sendMessage("general.success");
|
||||
target.sendMessage("commands.island.ban.owner-banned-you", TextVariables.NAME, issuer.getName());
|
||||
// If the player is online, has an island and on the banned island, move them home immediately
|
||||
if (target.isOnline() && getIslands().hasIsland(getWorld(), target.getUniqueId()) && island.onIsland(target.getLocation())) {
|
||||
getIslands().homeTeleport(getWorld(), target.getPlayer());
|
||||
island.getWorld().playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
issuer.sendMessage("commands.island.ban.cannot-ban-more-players");
|
||||
|
@ -67,26 +67,26 @@ public class IslandUnbanCommand extends CompositeCommand {
|
||||
}
|
||||
|
||||
private boolean unban(User issuer, User target) {
|
||||
Island island = getIslands().getIsland(getWorld(), issuer.getUniqueId());
|
||||
|
||||
// Run the event
|
||||
IslandBaseEvent unbanEvent = IslandEvent.builder()
|
||||
.island(getIslands().getIsland(getWorld(), issuer.getUniqueId()))
|
||||
.island(island)
|
||||
.involvedPlayer(target.getUniqueId())
|
||||
.admin(false)
|
||||
.reason(IslandEvent.Reason.UNBAN)
|
||||
.build();
|
||||
|
||||
// Event is not cancelled
|
||||
if (!unbanEvent.isCancelled()) {
|
||||
if (getIslands().getIsland(getWorld(), issuer.getUniqueId()).unban(issuer.getUniqueId(), target.getUniqueId())) {
|
||||
issuer.sendMessage("general.success");
|
||||
target.sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, issuer.getName());
|
||||
// Set cooldown
|
||||
if (getSettings().getBanCooldown() > 0 && getParent() != null) {
|
||||
getParent().getSubCommand("ban").ifPresent(subCommand ->
|
||||
subCommand.setCooldown(issuer.getUniqueId(), target.getUniqueId(), getSettings().getBanCooldown() * 60));
|
||||
}
|
||||
return true;
|
||||
if (!unbanEvent.isCancelled() && island.unban(issuer.getUniqueId(), target.getUniqueId())) {
|
||||
issuer.sendMessage("general.success");
|
||||
target.sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, issuer.getName());
|
||||
// Set cooldown
|
||||
if (getSettings().getBanCooldown() > 0 && getParent() != null) {
|
||||
getParent().getSubCommand("ban").ifPresent(subCommand ->
|
||||
subCommand.setCooldown(issuer.getUniqueId(), target.getUniqueId(), getSettings().getBanCooldown() * 60));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// Unbanning was blocked, maybe due to an event cancellation. Fail silently.
|
||||
return false;
|
||||
|
@ -133,15 +133,12 @@ public class Island implements DataObject {
|
||||
* @param issuer UUID of the issuer, may be null.
|
||||
* Whenever possible, one should be provided.
|
||||
* @param target UUID of the target, must be provided.
|
||||
* @return {@code true} if the target is successfully banned, {@code false} otherwise.
|
||||
* @return {@code true}
|
||||
*/
|
||||
public boolean ban(@Nullable UUID issuer, @NonNull UUID target) {
|
||||
if (target != null) {
|
||||
setRank(target, RanksManager.BANNED_RANK);
|
||||
log(new LogEntry.Builder("BAN").data("player", target).data("issuer", issuer).build());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
setRank(target, RanksManager.BANNED_RANK);
|
||||
log(new LogEntry.Builder("BAN").data("player", target).data("issuer", issuer).build());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -98,11 +98,8 @@ public class JoinLeaveListener implements Listener {
|
||||
&& Bukkit.getOfflinePlayer(uuid).getLastPlayed() < timestamp)
|
||||
.toArray());
|
||||
|
||||
if (!candidates.isEmpty()) {
|
||||
if (!plugin.getSettings().isAutoOwnershipTransferIgnoreRanks()) {
|
||||
// Ranks are not ignored, our candidates can only have the highest rank
|
||||
|
||||
}
|
||||
if (!candidates.isEmpty() && !plugin.getSettings().isAutoOwnershipTransferIgnoreRanks()) {
|
||||
// Ranks are not ignored, our candidates can only have the highest rank
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -43,9 +43,6 @@ public class FlagsManager {
|
||||
* @return true if successfully registered, false if not, e.g., because one with the same ID already exists
|
||||
*/
|
||||
public boolean registerFlag(@NonNull Flag flag) {
|
||||
if (flag == null) {
|
||||
return false;
|
||||
}
|
||||
// Check in case the flag id or icon already exists
|
||||
for (Flag fl : flags) {
|
||||
if (fl.getID().equals(flag.getID()) || fl.getIcon().equals(flag.getIcon())) {
|
||||
|
Loading…
Reference in New Issue
Block a user