mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-02 13:31:47 +01:00
Added team kick and leave commands. Need full testing.
This commit is contained in:
parent
f6ca7f7866
commit
9ce1dbf592
@ -14,6 +14,7 @@ general:
|
||||
unlimited: "Unlimited"
|
||||
success: "&aSuccess!"
|
||||
errors:
|
||||
command-cancelled: "&cCommand cancelled"
|
||||
no-permission: "&cYou don't have permission to execute this command."
|
||||
use-in-game: "&cThis command is only available in game."
|
||||
no-team: "&cYou do not have a team!"
|
||||
@ -21,6 +22,7 @@ general:
|
||||
already-have-island: "&cYou already have an island!"
|
||||
no-safe-location: "&cNo safe location found on island!"
|
||||
not-leader: "&cYou are not the leader of your island!"
|
||||
not-in-team: "&cThat player is not in your team!"
|
||||
offline-player: "&cThat player is offline or doesn't exist."
|
||||
unknown-player: "&cUnknown player!"
|
||||
general: "&cThat command is not ready yet - contact admin"
|
||||
@ -98,9 +100,13 @@ commands:
|
||||
description: "cancel the pending invite to join your island"
|
||||
leave:
|
||||
description: "leave your island"
|
||||
type-again: "&cEnter the leave command again to confirm"
|
||||
left-your-island: "&c[player] left your island"
|
||||
kick:
|
||||
description: "remove a member from your island"
|
||||
parameters: "<player>"
|
||||
type-again: "&cEnter the kick command again to confirm"
|
||||
leader-kicked: "&cThe leader kicked you from the island!"
|
||||
promote:
|
||||
description: "promote a player on your island to another rank"
|
||||
parameters: "<player>"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,76 @@
|
||||
package us.tastybento.bskyblock.commands.island.teams;
|
||||
|
||||
public class IslandTeamKickCommand {
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import us.tastybento.bskyblock.Constants;
|
||||
import us.tastybento.bskyblock.api.commands.User;
|
||||
|
||||
public class IslandTeamKickCommand extends AbstractIslandTeamCommand {
|
||||
|
||||
Set<UUID> kickSet;
|
||||
|
||||
public IslandTeamKickCommand(IslandTeamCommand islandTeamCommand) {
|
||||
super(islandTeamCommand, "kick");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
this.setPermission(Constants.PERMPREFIX + "island.team");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setParameters("commands.island.team.kick.parameters");
|
||||
this.setDescription("commands.island.team.kick.description");
|
||||
kickSet = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, List<String> args) {
|
||||
if (!getPlayers().inTeam(user.getUniqueId())) {
|
||||
user.sendMessage("general.errors.no-team");
|
||||
return true;
|
||||
}
|
||||
if (!getIslands().getTeamLeader(user.getUniqueId()).equals(user.getUniqueId())) {
|
||||
user.sendMessage("general.errors.not-leader");
|
||||
return true;
|
||||
}
|
||||
// If args are not right, show help
|
||||
if (args.size() != 1) {
|
||||
this.getSubCommand("help").get().execute(user, new ArrayList<>());
|
||||
return true;
|
||||
}
|
||||
// Get target
|
||||
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||
if (targetUUID == null) {
|
||||
user.sendMessage("general.errors.unknown-player");
|
||||
return true;
|
||||
}
|
||||
if (!getIslands().getMembers(user.getUniqueId()).contains(targetUUID)) {
|
||||
user.sendMessage("general.errors.not-in-team");
|
||||
return true;
|
||||
}
|
||||
if (!getSettings().isKickConfirmation() || kickSet.contains(targetUUID)) {
|
||||
kickSet.remove(targetUUID);
|
||||
User.getInstance(targetUUID).sendMessage("commands.island.team.kick.leader-kicked");
|
||||
getIslands().removePlayer(targetUUID);
|
||||
user.sendMessage("general.success");
|
||||
} else {
|
||||
user.sendMessage("commands.island.team.kick.type-again");
|
||||
kickSet.add(targetUUID);
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
kickSet.remove(targetUUID);
|
||||
user.sendMessage("general.errors.command-cancelled");
|
||||
}}.runTaskLater(getPlugin(), getSettings().getKickWait());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,11 +1,18 @@
|
||||
package us.tastybento.bskyblock.commands.island.teams;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
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");
|
||||
@ -16,13 +23,35 @@ public class IslandTeamLeaveCommand extends AbstractIslandTeamCommand {
|
||||
this.setPermission(Constants.PERMPREFIX + "island.team");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setDescription("commands.island.team.leave.description");
|
||||
|
||||
leaveSet = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, List<String> args) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
if (!getPlayers().inTeam(user.getUniqueId())) {
|
||||
user.sendMessage("general.errors.no-team");
|
||||
return true;
|
||||
}
|
||||
if (!getSettings().isKickConfirmation() || leaveSet.contains(user.getUniqueId())) {
|
||||
leaveSet.remove(user.getUniqueId());
|
||||
UUID leaderUUID = getIslands().getTeamLeader(user.getUniqueId());
|
||||
if (leaderUUID != null) {
|
||||
User.getInstance(leaderUUID).sendMessage("commands.island.team.leave.left-your-island", "[player]", user.getName());
|
||||
}
|
||||
getIslands().removePlayer(user.getUniqueId());
|
||||
user.sendMessage("general.success");
|
||||
} else {
|
||||
user.sendMessage("commands.island.team.leave.type-again");
|
||||
leaveSet.add(user.getUniqueId());
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
leaveSet.remove(user.getUniqueId());
|
||||
user.sendMessage("general.errors.command-cancelled");
|
||||
}}.runTaskLater(getPlugin(), getSettings().getKickWait());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -39,7 +39,12 @@ public class IslandTeamSetownerCommand extends AbstractIslandTeamCommand {
|
||||
if (!(inTeam && teamLeaderUUID.equals(playerUUID))) {
|
||||
return true;
|
||||
}
|
||||
getPlugin().getLogger().info("DEBUG: arg[0] = " + args.get(0));
|
||||
// If args are not right, show help
|
||||
if (args.size() != 1) {
|
||||
this.getSubCommand("help").get().execute(user, new ArrayList<>());
|
||||
return true;
|
||||
}
|
||||
//getPlugin().getLogger().info("DEBUG: arg[0] = " + args.get(0));
|
||||
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||
if (targetUUID == null) {
|
||||
user.sendMessage("general.errors.unknown-player");
|
||||
|
@ -236,7 +236,7 @@ public class PlayersManager{
|
||||
* @param playerUUID
|
||||
* @return true if player in a team
|
||||
*/
|
||||
public boolean inTeam(final UUID playerUUID) {
|
||||
public boolean inTeam(UUID playerUUID) {
|
||||
addPlayer(playerUUID);
|
||||
return plugin.getIslands().getMembers(playerUUID).size() > 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user