mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-08 03:49:43 +01:00
Fix code smells.
This commit is contained in:
parent
1f341f4929
commit
af25bba60c
@ -20,6 +20,9 @@ import world.bentobox.bentobox.database.objects.Island;
|
|||||||
*/
|
*/
|
||||||
public class IslandExpelCommand extends CompositeCommand {
|
public class IslandExpelCommand extends CompositeCommand {
|
||||||
|
|
||||||
|
private static final String CANNOT_EXPEL = "commands.island.expel.cannot-expel";
|
||||||
|
private static final String SUCCESS = "general.success";
|
||||||
|
|
||||||
private @Nullable User target;
|
private @Nullable User target;
|
||||||
|
|
||||||
public IslandExpelCommand(CompositeCommand islandCommand) {
|
public IslandExpelCommand(CompositeCommand islandCommand) {
|
||||||
@ -82,7 +85,7 @@ public class IslandExpelCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
// Cannot ban ops
|
// Cannot ban ops
|
||||||
if (target.isOp() || target.hasPermission("admin.noexpel")) {
|
if (target.isOp() || target.hasPermission("admin.noexpel")) {
|
||||||
user.sendMessage("commands.island.expel.cannot-expel");
|
user.sendMessage(CANNOT_EXPEL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -101,7 +104,7 @@ public class IslandExpelCommand extends CompositeCommand {
|
|||||||
.reason(IslandEvent.Reason.EXPEL)
|
.reason(IslandEvent.Reason.EXPEL)
|
||||||
.build();
|
.build();
|
||||||
if (expelEvent.isCancelled()) {
|
if (expelEvent.isCancelled()) {
|
||||||
user.sendMessage("commands.island.expel.cannot-expel");
|
user.sendMessage(CANNOT_EXPEL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,28 +112,28 @@ public class IslandExpelCommand extends CompositeCommand {
|
|||||||
island.getWorld().playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
island.getWorld().playSound(target.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
||||||
if (getIslands().hasIsland(getWorld(), target)) {
|
if (getIslands().hasIsland(getWorld(), target)) {
|
||||||
// Success
|
// Success
|
||||||
user.sendMessage("general.success");
|
user.sendMessage(SUCCESS);
|
||||||
// Teleport home
|
// Teleport home
|
||||||
getIslands().homeTeleport(getWorld(), target.getPlayer());
|
getIslands().homeTeleport(getWorld(), target.getPlayer());
|
||||||
return true;
|
return true;
|
||||||
} else if (getIslands().getSpawn(getWorld()).isPresent()){
|
} else if (getIslands().getSpawn(getWorld()).isPresent()){
|
||||||
// Success
|
// Success
|
||||||
user.sendMessage("general.success");
|
user.sendMessage(SUCCESS);
|
||||||
getIslands().spawnTeleport(getWorld(), user.getPlayer());
|
getIslands().spawnTeleport(getWorld(), user.getPlayer());
|
||||||
return true;
|
return true;
|
||||||
} else if (getIWM().getAddon(getWorld())
|
} else if (getIWM().getAddon(getWorld())
|
||||||
.map(gm -> gm.getPlayerCommand()
|
.map(gm -> gm.getPlayerCommand()
|
||||||
.map(pc -> pc.getSubCommand("create").isPresent())
|
.map(pc -> pc.getSubCommand("create").isPresent())
|
||||||
.orElse(false))
|
.orElse(false))
|
||||||
.orElse(false)) {
|
.orElse(false)
|
||||||
if (target.performCommand(this.getTopLabel() + " create")) {
|
&& target.performCommand(this.getTopLabel() + " create")) {
|
||||||
getAddon().logWarning("Expel: " + target.getName() + " had no island, so one was created");
|
getAddon().logWarning("Expel: " + target.getName() + " had no island, so one was created");
|
||||||
user.sendMessage("general.success");
|
user.sendMessage(SUCCESS);
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getAddon().logError("Expel: " + target.getName() + " had no island, and one could not be created");
|
getAddon().logError("Expel: " + target.getName() + " had no island, and one could not be created");
|
||||||
user.sendMessage("commands.island.expel.cannot-expel");
|
user.sendMessage(CANNOT_EXPEL);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user