mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-30 22:53:39 +01:00
Changed island team kick to use confirm API
Fix for: https://github.com/BentoBoxWorld/bentobox/issues/214
This commit is contained in:
parent
bad870d3da
commit
53f28eb68d
@ -1,19 +1,13 @@
|
||||
package world.bentobox.bentobox.api.commands.island.team;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
|
||||
public class IslandTeamKickCommand extends CompositeCommand {
|
||||
|
||||
Set<UUID> kickSet;
|
||||
|
||||
public IslandTeamKickCommand(CompositeCommand islandTeamCommand) {
|
||||
super(islandTeamCommand, "kick");
|
||||
}
|
||||
@ -24,7 +18,6 @@ public class IslandTeamKickCommand extends CompositeCommand {
|
||||
setOnlyPlayer(true);
|
||||
setParameters("commands.island.team.kick.parameters");
|
||||
setDescription("commands.island.team.kick.description");
|
||||
kickSet = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -56,8 +49,16 @@ public class IslandTeamKickCommand extends CompositeCommand {
|
||||
user.sendMessage("general.errors.not-in-team");
|
||||
return false;
|
||||
}
|
||||
if (!getSettings().isKickConfirmation() || kickSet.contains(targetUUID)) {
|
||||
kickSet.remove(targetUUID);
|
||||
if (!getSettings().isKickConfirmation()) {
|
||||
kick(user, targetUUID);
|
||||
return true;
|
||||
} else {
|
||||
this.askConfirmation(user, () -> kick(user, targetUUID));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void kick(User user, UUID targetUUID) {
|
||||
User.getInstance(targetUUID).sendMessage("commands.island.team.kick.leader-kicked");
|
||||
getIslands().removePlayer(getWorld(), targetUUID);
|
||||
// Remove money inventory etc.
|
||||
@ -71,21 +72,6 @@ public class IslandTeamKickCommand extends CompositeCommand {
|
||||
// TODO: needs Vault
|
||||
}
|
||||
user.sendMessage("general.success");
|
||||
return true;
|
||||
} else {
|
||||
user.sendMessage("commands.island.team.kick.type-again");
|
||||
kickSet.add(targetUUID);
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (kickSet.contains(targetUUID)) {
|
||||
kickSet.remove(targetUUID);
|
||||
user.sendMessage("general.errors.command-cancelled");
|
||||
}
|
||||
}}.runTaskLater(getPlugin(), getSettings().getKickWait() * 20);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,7 +232,7 @@ public class IslandTeamKickCommandTest {
|
||||
IslandTeamKickCommand itl = new IslandTeamKickCommand(ic);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
// Confirmation required
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("commands.island.team.kick.type-again"));
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("general.confirm"), Mockito.eq("[seconds]"), Mockito.eq("0"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user