mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-28 03:57:39 +01:00
Fixed return values for execute.
This commit is contained in:
parent
af5c7e472e
commit
eefcd48c7c
@ -37,12 +37,11 @@ public class IslandTeamInviteCommand extends AbstractIslandTeamCommand {
|
||||
public boolean execute(User user, List<String> args) {
|
||||
UUID playerUUID = user.getUniqueId();
|
||||
// Player issuing the command must have an island
|
||||
if (!getPlayers().hasIsland(playerUUID)) {
|
||||
// If the player is in a team, they are not the leader
|
||||
if (getPlayers().inTeam(playerUUID)) {
|
||||
user.sendMessage("general.errors.not-leader");
|
||||
}
|
||||
user.sendMessage("general.errors.no-island");
|
||||
boolean inTeam = getPlugin().getPlayers().inTeam(playerUUID);
|
||||
UUID teamLeaderUUID = getPlugin().getIslands().getTeamLeader(playerUUID);
|
||||
if (!(inTeam && teamLeaderUUID.equals(playerUUID))) {
|
||||
user.sendMessage("general.errors.not-leader");
|
||||
return false;
|
||||
}
|
||||
if (args.isEmpty() || args.size() > 1) {
|
||||
// Invite label with no name, i.e., /island invite - tells the player who has invited them so far
|
||||
@ -58,29 +57,29 @@ public class IslandTeamInviteCommand extends AbstractIslandTeamCommand {
|
||||
UUID invitedPlayerUUID = getPlayers().getUUID(args.get(0));
|
||||
if (invitedPlayerUUID == null) {
|
||||
user.sendMessage("general.errors.offline-player");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
User invitedPlayer = User.getInstance(invitedPlayerUUID);
|
||||
if (!invitedPlayer.isOnline()) {
|
||||
user.sendMessage("general.errors.offline-player");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
// Player cannot invite themselves
|
||||
if (playerUUID.equals(invitedPlayerUUID)) {
|
||||
user.sendMessage("commands.island.team.invite.cannot-invite-self");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
// Check if this player can be invited to this island, or
|
||||
// whether they are still on cooldown
|
||||
long time = getPlayers().getInviteCoolDownTime(invitedPlayerUUID, getIslands().getIslandLocation(playerUUID));
|
||||
if (time > 0 && !user.isOp()) {
|
||||
user.sendMessage("commands.island.team.invite.cooldown", "[time]", String.valueOf(time));
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
// Player cannot invite someone already on a team
|
||||
if (getPlayers().inTeam(invitedPlayerUUID)) {
|
||||
user.sendMessage("commands.island.team.invite.already-on-team");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
Set<UUID> teamMembers = getMembers(user);
|
||||
// Check if player has space on their team
|
||||
@ -131,11 +130,12 @@ public class IslandTeamInviteCommand extends AbstractIslandTeamCommand {
|
||||
if (getPlayers().hasIsland(invitedPlayer.getUniqueId())) {
|
||||
invitedPlayer.sendMessage("commands.island.team.invite.you-will-lose-your-island");
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
user.sendMessage("commands.island.team.invite.errors.island-is-full");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +34,7 @@ public class IslandTeamInviteRejectCommand extends AbstractIslandTeamCommand {
|
||||
.involvedPlayer(playerUUID)
|
||||
.build();
|
||||
getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return true;
|
||||
if (event.isCancelled()) return false;
|
||||
|
||||
// Remove this player from the global invite list
|
||||
inviteList.remove(user.getUniqueId());
|
||||
@ -45,6 +45,7 @@ public class IslandTeamInviteRejectCommand extends AbstractIslandTeamCommand {
|
||||
} else {
|
||||
// Someone typed /island reject and had not been invited
|
||||
user.sendMessage("commands.island.team.invite.errors.none-invited-you");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ import us.tastybento.bskyblock.Constants;
|
||||
import us.tastybento.bskyblock.api.commands.User;
|
||||
|
||||
public class IslandTeamLeaveCommand extends AbstractIslandTeamCommand {
|
||||
|
||||
|
||||
Set<UUID> leaveSet;
|
||||
|
||||
public IslandTeamLeaveCommand(IslandTeamCommand islandTeamCommand) {
|
||||
super(islandTeamCommand, "leave");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
this.setPermission(Constants.PERMPREFIX + "island.team");
|
||||
@ -30,7 +30,7 @@ public class IslandTeamLeaveCommand extends AbstractIslandTeamCommand {
|
||||
public boolean execute(User user, List<String> args) {
|
||||
if (!getPlayers().inTeam(user.getUniqueId())) {
|
||||
user.sendMessage("general.errors.no-team");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (!getSettings().isKickConfirmation() || leaveSet.contains(user.getUniqueId())) {
|
||||
leaveSet.remove(user.getUniqueId());
|
||||
@ -40,6 +40,7 @@ public class IslandTeamLeaveCommand extends AbstractIslandTeamCommand {
|
||||
}
|
||||
getIslands().removePlayer(user.getUniqueId());
|
||||
user.sendMessage("general.success");
|
||||
return true;
|
||||
} else {
|
||||
user.sendMessage("commands.island.team.leave.type-again");
|
||||
leaveSet.add(user.getUniqueId());
|
||||
@ -50,8 +51,8 @@ public class IslandTeamLeaveCommand extends AbstractIslandTeamCommand {
|
||||
leaveSet.remove(user.getUniqueId());
|
||||
user.sendMessage("general.errors.command-cancelled");
|
||||
}}.runTaskLater(getPlugin(), getSettings().getKickWait());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -37,7 +37,8 @@ public class IslandTeamSetownerCommand extends AbstractIslandTeamCommand {
|
||||
boolean inTeam = getPlugin().getPlayers().inTeam(playerUUID);
|
||||
UUID teamLeaderUUID = getPlugin().getIslands().getTeamLeader(playerUUID);
|
||||
if (!(inTeam && teamLeaderUUID.equals(playerUUID))) {
|
||||
return true;
|
||||
user.sendMessage("general.errors.not-leader");
|
||||
return false;
|
||||
}
|
||||
// If args are not right, show help
|
||||
if (args.size() != 1) {
|
||||
@ -47,23 +48,23 @@ public class IslandTeamSetownerCommand extends AbstractIslandTeamCommand {
|
||||
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||
if (targetUUID == null) {
|
||||
user.sendMessage("general.errors.unknown-player");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (!getPlayers().inTeam(playerUUID)) {
|
||||
user.sendMessage("general.errors.no-team");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (!teamLeaderUUID.equals(playerUUID)) {
|
||||
user.sendMessage("general.errors.not-leader");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (targetUUID.equals(playerUUID)) {
|
||||
user.sendMessage("commands.island.team.setowner.errors.cant-transfer-to-yourself");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
if (!getPlugin().getIslands().getMembers(playerUUID).contains(targetUUID)) {
|
||||
user.sendMessage("commands.island.team.setowner.errors.target-is-not-member");
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
// Fire event so add-ons can run commands, etc.
|
||||
IslandBaseEvent event = TeamEvent.builder()
|
||||
@ -73,7 +74,7 @@ public class IslandTeamSetownerCommand extends AbstractIslandTeamCommand {
|
||||
.involvedPlayer(targetUUID)
|
||||
.build();
|
||||
getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return true;
|
||||
if (event.isCancelled()) return false;
|
||||
|
||||
// target is the new leader
|
||||
getIslands().getIsland(playerUUID).setOwner(targetUUID);
|
||||
|
Loading…
Reference in New Issue
Block a user