mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-04 14:31:21 +01:00
Added team coop, uncoop, trust and untrust commands.
This commit is contained in:
parent
82c35f9aa9
commit
c1a6a233a9
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>world.bentobox</groupId>
|
<groupId>world.bentobox</groupId>
|
||||||
<artifactId>bentobox</artifactId>
|
<artifactId>bentobox</artifactId>
|
||||||
<version>FC-0.92</version>
|
<version>FC-0.95</version>
|
||||||
|
|
||||||
<name>BentoBox</name>
|
<name>BentoBox</name>
|
||||||
<description>BentoBox is an expandable Minecraft Spigot plugin for island-type games like ASkyBlock or AcidIsland.</description>
|
<description>BentoBox is an expandable Minecraft Spigot plugin for island-type games like ASkyBlock or AcidIsland.</description>
|
||||||
|
@ -38,8 +38,8 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island or be in a team
|
||||||
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId()) && !getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ public class IslandUnbanCommand extends CompositeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island or be in a team
|
||||||
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId()) && !getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,13 @@ public class IslandTeamCommand extends CompositeCommand {
|
|||||||
new IslandTeamKickCommand(this);
|
new IslandTeamKickCommand(this);
|
||||||
new IslandTeamInviteAcceptCommand(this);
|
new IslandTeamInviteAcceptCommand(this);
|
||||||
new IslandTeamInviteRejectCommand(this);
|
new IslandTeamInviteRejectCommand(this);
|
||||||
|
new IslandTeamCoopCommand(this);
|
||||||
|
new IslandTeamUncoopCommand(this);
|
||||||
|
new IslandTeamTrustCommand(this);
|
||||||
|
new IslandTeamUntrustCommand(this);
|
||||||
|
new IslandTeamPromoteCommand(this, "promote");
|
||||||
|
new IslandTeamPromoteCommand(this, "demote");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,106 @@
|
|||||||
|
package world.bentobox.bentobox.api.commands.island.team;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command to coop another player
|
||||||
|
* @author tastybento
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class IslandTeamCoopCommand extends CompositeCommand {
|
||||||
|
|
||||||
|
public IslandTeamCoopCommand(CompositeCommand parentCommand) {
|
||||||
|
super(parentCommand, "coop");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
setPermission("island.team.coop");
|
||||||
|
setOnlyPlayer(true);
|
||||||
|
setParametersHelp("commands.island.team.coop.parameters");
|
||||||
|
setDescription("commands.island.team.coop.description");
|
||||||
|
setConfigurableRankCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
|
if (args.size() != 1) {
|
||||||
|
// Show help
|
||||||
|
showHelp(this, user);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Player issuing the command must have an island or be in a team
|
||||||
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId()) && !getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
|
user.sendMessage("general.errors.no-island");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check rank to use command
|
||||||
|
if (getIslands().getIsland(getWorld(), user).getRank(user) < getPlugin().getSettings().getRankCommand(getUsage())) {
|
||||||
|
user.sendMessage("general.errors.no-permission");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Get target player
|
||||||
|
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||||
|
if (targetUUID == null) {
|
||||||
|
user.sendMessage("general.errors.unknown-player");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getSettings().getInviteWait() > 0 && checkCooldown(user, targetUUID)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return coopCmd(user, targetUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean coopCmd(User user, UUID targetUUID) {
|
||||||
|
// Player cannot coop themselves
|
||||||
|
if (user.getUniqueId().equals(targetUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.coop.cannot-coop-yourself");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getIslands().getMembers(getWorld(), user.getUniqueId()).contains(targetUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.coop.already-has-rank");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
User target = User.getInstance(targetUUID);
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
|
island.setRank(target, RanksManager.COOP_RANK);
|
||||||
|
user.sendMessage("general.success");
|
||||||
|
target.sendMessage("commands.island.team.coop.you-are-a-coop-member", TextVariables.NAME, user.getName());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Should not happen
|
||||||
|
user.sendMessage("general.errors.general");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
// Don't show every player on the server. Require at least the first letter
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
List<String> options = Bukkit.getOnlinePlayers().stream()
|
||||||
|
.filter(p -> !p.getUniqueId().equals(user.getUniqueId()))
|
||||||
|
.filter(p -> !island.getMemberSet().contains(p.getUniqueId()))
|
||||||
|
.filter(p -> user.getPlayer().canSee(p))
|
||||||
|
.map(Player::getName).collect(Collectors.toList());
|
||||||
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
}
|
||||||
|
}
|
@ -38,7 +38,7 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
|||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, String label, List<String> args) {
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island or be in a team
|
||||||
if (!getIslands().inTeam(getWorld(), user.getUniqueId()) && !getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId()) && !getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
|
@ -0,0 +1,111 @@
|
|||||||
|
package world.bentobox.bentobox.api.commands.island.team;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command to trust another player
|
||||||
|
* @author tastybento
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class IslandTeamTrustCommand extends CompositeCommand {
|
||||||
|
|
||||||
|
public IslandTeamTrustCommand(CompositeCommand parentCommand) {
|
||||||
|
super(parentCommand, "trust");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
setPermission("island.team.trust");
|
||||||
|
setOnlyPlayer(true);
|
||||||
|
setParametersHelp("commands.island.team.trust.parameters");
|
||||||
|
setDescription("commands.island.team.trust.description");
|
||||||
|
setConfigurableRankCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
|
if (args.size() != 1) {
|
||||||
|
// Show help
|
||||||
|
showHelp(this, user);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Player issuing the command must have an island or be in a team
|
||||||
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId()) && !getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
|
user.sendMessage("general.errors.no-island");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check rank to use command
|
||||||
|
if (getIslands().getIsland(getWorld(), user).getRank(user) < getPlugin().getSettings().getRankCommand(getUsage())) {
|
||||||
|
user.sendMessage("general.errors.no-permission");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Get target player
|
||||||
|
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||||
|
if (targetUUID == null) {
|
||||||
|
user.sendMessage("general.errors.unknown-player");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getSettings().getInviteWait() > 0 && checkCooldown(user, targetUUID)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return trustCmd(user, targetUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean trustCmd(User user, UUID targetUUID) {
|
||||||
|
// Player cannot trust themselves
|
||||||
|
if (user.getUniqueId().equals(targetUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.trust.trust-in-yourself");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getIslands().getMembers(getWorld(), user.getUniqueId()).contains(targetUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.trust.members-trusted");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
User target = User.getInstance(targetUUID);
|
||||||
|
int rank = getIslands().getIsland(getWorld(), user).getRank(target);
|
||||||
|
if (rank >= RanksManager.TRUSTED_RANK) {
|
||||||
|
user.sendMessage("commands.island.team.trust.player-already-trusted");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
|
island.setRank(target, RanksManager.TRUSTED_RANK);
|
||||||
|
user.sendMessage("general.success");
|
||||||
|
target.sendMessage("commands.island.team.trust.you-are-trusted", TextVariables.NAME, user.getName());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Should not happen
|
||||||
|
user.sendMessage("general.errors.general");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
// Don't show every player on the server. Require at least the first letter
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
List<String> options = Bukkit.getOnlinePlayers().stream()
|
||||||
|
.filter(p -> !p.getUniqueId().equals(user.getUniqueId()))
|
||||||
|
.filter(p -> !island.getMemberSet().contains(p.getUniqueId()))
|
||||||
|
.filter(p -> user.getPlayer().canSee(p))
|
||||||
|
.map(Player::getName).collect(Collectors.toList());
|
||||||
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
package world.bentobox.bentobox.api.commands.island.team;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command to uncoop a player
|
||||||
|
* @author tastybento
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class IslandTeamUncoopCommand extends CompositeCommand {
|
||||||
|
|
||||||
|
public IslandTeamUncoopCommand(CompositeCommand parentCommand) {
|
||||||
|
super(parentCommand, "uncoop");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
setPermission("island.team.coop");
|
||||||
|
setOnlyPlayer(true);
|
||||||
|
setParametersHelp("commands.island.team.uncoop.parameters");
|
||||||
|
setDescription("commands.island.team.uncoop.description");
|
||||||
|
setConfigurableRankCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
|
if (args.size() != 1) {
|
||||||
|
// Show help
|
||||||
|
showHelp(this, user);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Player issuing the command must have an island or be in a team
|
||||||
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId()) && !getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
|
user.sendMessage("general.errors.no-island");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check rank to use command
|
||||||
|
if (getIslands().getIsland(getWorld(), user).getRank(user) < getPlugin().getSettings().getRankCommand(getUsage())) {
|
||||||
|
user.sendMessage("general.errors.no-permission");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Get target player
|
||||||
|
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||||
|
if (targetUUID == null) {
|
||||||
|
user.sendMessage("general.errors.unknown-player");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Uncoop
|
||||||
|
return unCoopCmd(user, targetUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean unCoopCmd(User user, UUID targetUUID) {
|
||||||
|
// Player cannot uncoop themselves
|
||||||
|
if (user.getUniqueId().equals(targetUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.coop.cannot-uncoop-yourself");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getIslands().getMembers(getWorld(), user.getUniqueId()).contains(targetUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.coop.cannot-uncoop-member");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
User target = User.getInstance(targetUUID);
|
||||||
|
int rank = getIslands().getIsland(getWorld(), user).getRank(target);
|
||||||
|
if (rank != RanksManager.COOP_RANK) {
|
||||||
|
user.sendMessage("commands.island.team.uncoop.player-not-coop");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
|
island.removeMember(targetUUID);
|
||||||
|
user.sendMessage("general.success");
|
||||||
|
target.sendMessage("commands.island.team.coop.you-are-no-longer-a-coop-member", TextVariables.NAME, user.getName());
|
||||||
|
// Set cooldown
|
||||||
|
if (getSettings().getInviteWait() > 0 && getParent() != null) {
|
||||||
|
getParent().getSubCommand("coop").ifPresent(subCommand ->
|
||||||
|
subCommand.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteWait() * 60));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Should not happen
|
||||||
|
user.sendMessage("general.errors.general");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
// Don't show every player on the server. Require at least the first letter
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
List<String> options = island.getMemberSet().stream()
|
||||||
|
.filter(uuid -> island.getRank(User.getInstance(uuid)) == RanksManager.COOP_RANK)
|
||||||
|
.map(Bukkit::getOfflinePlayer)
|
||||||
|
.map(OfflinePlayer::getName).collect(Collectors.toList());
|
||||||
|
|
||||||
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
package world.bentobox.bentobox.api.commands.island.team;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
|
import world.bentobox.bentobox.api.user.User;
|
||||||
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command to untrust a player
|
||||||
|
* @author tastybento
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class IslandTeamUntrustCommand extends CompositeCommand {
|
||||||
|
|
||||||
|
public IslandTeamUntrustCommand(CompositeCommand parentCommand) {
|
||||||
|
super(parentCommand, "untrust");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
setPermission("island.team.coop");
|
||||||
|
setOnlyPlayer(true);
|
||||||
|
setParametersHelp("commands.island.team.untrust.parameters");
|
||||||
|
setDescription("commands.island.team.untrust.description");
|
||||||
|
setConfigurableRankCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(User user, String label, List<String> args) {
|
||||||
|
if (args.size() != 1) {
|
||||||
|
// Show help
|
||||||
|
showHelp(this, user);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Player issuing the command must have an island or be in a team
|
||||||
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId()) && !getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
|
user.sendMessage("general.errors.no-island");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Check rank to use command
|
||||||
|
if (getIslands().getIsland(getWorld(), user).getRank(user) < getPlugin().getSettings().getRankCommand(getUsage())) {
|
||||||
|
user.sendMessage("general.errors.no-permission");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Get target player
|
||||||
|
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||||
|
if (targetUUID == null) {
|
||||||
|
user.sendMessage("general.errors.unknown-player");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// untrust
|
||||||
|
return unTrustCmd(user, targetUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean unTrustCmd(User user, UUID targetUUID) {
|
||||||
|
// Player cannot untrust themselves
|
||||||
|
if (user.getUniqueId().equals(targetUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.untrust.cannot-untrust-yourself");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getIslands().getMembers(getWorld(), user.getUniqueId()).contains(targetUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.untrust.cannot-untrust-member");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
User target = User.getInstance(targetUUID);
|
||||||
|
int rank = getIslands().getIsland(getWorld(), user).getRank(target);
|
||||||
|
if (rank != RanksManager.TRUSTED_RANK) {
|
||||||
|
user.sendMessage("commands.island.team.untrust.player-not-trusted");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
|
island.removeMember(targetUUID);
|
||||||
|
user.sendMessage("general.success");
|
||||||
|
target.sendMessage("commands.island.team.untrust.you-are-no-longer-trusted", TextVariables.NAME, user.getName());
|
||||||
|
// Set cooldown
|
||||||
|
if (getSettings().getInviteWait() > 0 && getParent() != null) {
|
||||||
|
getParent().getSubCommand("trust").ifPresent(subCommand ->
|
||||||
|
subCommand.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteWait() * 60));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Should not happen
|
||||||
|
user.sendMessage("general.errors.general");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
|
if (args.isEmpty()) {
|
||||||
|
// Don't show every player on the server. Require at least the first letter
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
List<String> options = island.getMemberSet().stream()
|
||||||
|
.filter(uuid -> island.getRank(User.getInstance(uuid)) == RanksManager.TRUSTED_RANK)
|
||||||
|
.map(Bukkit::getOfflinePlayer)
|
||||||
|
.map(OfflinePlayer::getName).collect(Collectors.toList());
|
||||||
|
|
||||||
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
}
|
||||||
|
}
|
@ -403,8 +403,8 @@ public class Island implements DataObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a player from the team member map. Do not call this directly.
|
* Removes a player from the team member map. Generally, you should
|
||||||
* Use {@link world.bentobox.bentobox.managers.IslandsManager#removePlayer(World, UUID)}
|
* use {@link world.bentobox.bentobox.managers.IslandsManager#removePlayer(World, UUID)}
|
||||||
* @param playerUUID - uuid of player
|
* @param playerUUID - uuid of player
|
||||||
*/
|
*/
|
||||||
public void removeMember(UUID playerUUID) {
|
public void removeMember(UUID playerUUID) {
|
||||||
@ -636,20 +636,16 @@ public class Island implements DataObject {
|
|||||||
* @param world - world to check
|
* @param world - world to check
|
||||||
*/
|
*/
|
||||||
public void showMembers(BentoBox plugin, User user, World world) {
|
public void showMembers(BentoBox plugin, User user, World world) {
|
||||||
if (plugin.getIslands().inTeam(world, user.getUniqueId())) {
|
user.sendMessage("commands.admin.info.team-members-title");
|
||||||
user.sendMessage("commands.admin.info.team-members-title");
|
members.forEach((u, i) -> {
|
||||||
members.forEach((u, i) -> {
|
if (owner.equals(u)) {
|
||||||
if (owner.equals(u)) {
|
user.sendMessage("commands.admin.info.team-owner-format", TextVariables.NAME, plugin.getPlayers().getName(u)
|
||||||
user.sendMessage("commands.admin.info.team-owner-format", TextVariables.NAME, plugin.getPlayers().getName(u)
|
, "[rank]", user.getTranslation(plugin.getRanksManager().getRank(i)));
|
||||||
, "[rank]", user.getTranslation(plugin.getRanksManager().getRank(i)));
|
} else if (i > RanksManager.VISITOR_RANK){
|
||||||
} else if (i > RanksManager.VISITOR_RANK){
|
user.sendMessage("commands.admin.info.team-member-format", TextVariables.NAME, plugin.getPlayers().getName(u)
|
||||||
user.sendMessage("commands.admin.info.team-member-format", TextVariables.NAME, plugin.getPlayers().getName(u)
|
, "[rank]", user.getTranslation(plugin.getRanksManager().getRank(i)));
|
||||||
, "[rank]", user.getTranslation(plugin.getRanksManager().getRank(i)));
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package world.bentobox.bentobox.listeners.flags;
|
package world.bentobox.bentobox.listeners.flags.clicklisteners;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package world.bentobox.bentobox.listeners.flags;
|
package world.bentobox.bentobox.listeners.flags.clicklisteners;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -94,11 +94,11 @@ public class CommandRankClickListener implements ClickHandler {
|
|||||||
pib.description(d);
|
pib.description(d);
|
||||||
plugin.getRanksManager().getRanks().forEach((reference, score) -> {
|
plugin.getRanksManager().getRanks().forEach((reference, score) -> {
|
||||||
if (score >= RanksManager.MEMBER_RANK && score < plugin.getSettings().getRankCommand(c)) {
|
if (score >= RanksManager.MEMBER_RANK && score < plugin.getSettings().getRankCommand(c)) {
|
||||||
pib.description(user.getTranslation("protection.panel.flag-item.blocked_rank") + user.getTranslation(reference));
|
pib.description(user.getTranslation("protection.panel.flag-item.blocked-rank") + user.getTranslation(reference));
|
||||||
} else if (score <= RanksManager.OWNER_RANK && score > plugin.getSettings().getRankCommand(c)) {
|
} else if (score <= RanksManager.OWNER_RANK && score > plugin.getSettings().getRankCommand(c)) {
|
||||||
pib.description(user.getTranslation("protection.panel.flag-item.allowed_rank") + user.getTranslation(reference));
|
pib.description(user.getTranslation("protection.panel.flag-item.allowed-rank") + user.getTranslation(reference));
|
||||||
} else if (score == plugin.getSettings().getRankCommand(c)) {
|
} else if (score == plugin.getSettings().getRankCommand(c)) {
|
||||||
pib.description(user.getTranslation("protection.panel.flag-item.minimal_rank") + user.getTranslation(reference));
|
pib.description(user.getTranslation("protection.panel.flag-item.minimal-rank") + user.getTranslation(reference));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return pib.build();
|
return pib.build();
|
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package world.bentobox.bentobox.listeners.flags;
|
package world.bentobox.bentobox.listeners.flags.clicklisteners;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
@ -16,7 +16,6 @@ import world.bentobox.bentobox.listeners.flags.BreedingListener;
|
|||||||
import world.bentobox.bentobox.listeners.flags.BucketListener;
|
import world.bentobox.bentobox.listeners.flags.BucketListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.ChestDamageListener;
|
import world.bentobox.bentobox.listeners.flags.ChestDamageListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.CleanSuperFlatListener;
|
import world.bentobox.bentobox.listeners.flags.CleanSuperFlatListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.CommandRankClickListener;
|
|
||||||
import world.bentobox.bentobox.listeners.flags.CreeperListener;
|
import world.bentobox.bentobox.listeners.flags.CreeperListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.EggListener;
|
import world.bentobox.bentobox.listeners.flags.EggListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.EnderChestListener;
|
import world.bentobox.bentobox.listeners.flags.EnderChestListener;
|
||||||
@ -24,7 +23,6 @@ import world.bentobox.bentobox.listeners.flags.EndermanListener;
|
|||||||
import world.bentobox.bentobox.listeners.flags.EnterExitListener;
|
import world.bentobox.bentobox.listeners.flags.EnterExitListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.EntityInteractListener;
|
import world.bentobox.bentobox.listeners.flags.EntityInteractListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.FireListener;
|
import world.bentobox.bentobox.listeners.flags.FireListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.GeoLimitClickListener;
|
|
||||||
import world.bentobox.bentobox.listeners.flags.GeoLimitMobsListener;
|
import world.bentobox.bentobox.listeners.flags.GeoLimitMobsListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.HurtingListener;
|
import world.bentobox.bentobox.listeners.flags.HurtingListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.InventoryListener;
|
import world.bentobox.bentobox.listeners.flags.InventoryListener;
|
||||||
@ -45,6 +43,8 @@ import world.bentobox.bentobox.listeners.flags.RemoveMobsListener;
|
|||||||
import world.bentobox.bentobox.listeners.flags.ShearingListener;
|
import world.bentobox.bentobox.listeners.flags.ShearingListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.TNTListener;
|
import world.bentobox.bentobox.listeners.flags.TNTListener;
|
||||||
import world.bentobox.bentobox.listeners.flags.TeleportationListener;
|
import world.bentobox.bentobox.listeners.flags.TeleportationListener;
|
||||||
|
import world.bentobox.bentobox.listeners.flags.clicklisteners.CommandRankClickListener;
|
||||||
|
import world.bentobox.bentobox.listeners.flags.clicklisteners.GeoLimitClickListener;
|
||||||
import world.bentobox.bentobox.managers.RanksManager;
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
|
||||||
public class Flags {
|
public class Flags {
|
||||||
|
@ -226,12 +226,39 @@ commands:
|
|||||||
description: "manage your team"
|
description: "manage your team"
|
||||||
info:
|
info:
|
||||||
description: "display detailed info about your team"
|
description: "display detailed info about your team"
|
||||||
|
coop:
|
||||||
|
description: "make a player coop rank on your island"
|
||||||
|
paramters: "<player>"
|
||||||
|
cannot-coop-yourself: "&cYou cannot coop yourself!"
|
||||||
|
already-has-rank: "&cPlayer already has a rank!"
|
||||||
|
you-are-a-coop-member: "&2You were cooped by [name]"
|
||||||
|
uncoop:
|
||||||
|
description: "remove a coop rank from player"
|
||||||
|
paramters: "<player>"
|
||||||
|
cannot-uncoop-yourself: "&cYou cannot uncoop yourself!"
|
||||||
|
cannot-uncoop-member: "&cYou cannot uncoop a team member!"
|
||||||
|
player-not-cooped: "&cPlayer is not cooped!"
|
||||||
|
you-are-no-longer-a-coop-member: "&cYou are no longer a coop member of [name]'s island"
|
||||||
|
trust:
|
||||||
|
description: "give a player trusted rank on your island"
|
||||||
|
paramters: "<player>"
|
||||||
|
trust-in-yourself: "&cTrust in yourself!"
|
||||||
|
members-trusted: "&cMembers are already trusted"
|
||||||
|
player-already-trusted: "&cPlayer is already trusted!"
|
||||||
|
you-are-trusted: "&2You are trusted by [name]!"
|
||||||
|
untrust:
|
||||||
|
description: "remove trusted player rank from player"
|
||||||
|
paramters: "<player>"
|
||||||
|
cannot-untrust-yourself: "&cYou cannot untrust yourself!"
|
||||||
|
cannot-untrust-member: "&cYou cannot untrust a team member!"
|
||||||
|
player-not-trusted: "&cPlayer is not trusted!"
|
||||||
|
you-are-no-longer-trusted: "&cYou are no longer trusted by [name]!"
|
||||||
invite:
|
invite:
|
||||||
description: "invite a player to join your island"
|
description: "invite a player to join your island"
|
||||||
invitation-sent: "Invitation sent to [name]"
|
invitation-sent: "Invitation sent to [name]"
|
||||||
removing-invite: "Removing invite"
|
removing-invite: "Removing invite"
|
||||||
name-has-invited-you: "[name] has invited you to join their island."
|
name-has-invited-you: "[name] has invited you to join their island."
|
||||||
to-accept-or-reject: "Do /island team accept to accept, or /island team reject to reject"
|
to-accept-or-reject: "Do /[label] team accept to accept, or /[label] team reject to reject"
|
||||||
you-will-lose-your-island: "&cWARNING! You will lose your island if you accept!"
|
you-will-lose-your-island: "&cWARNING! You will lose your island if you accept!"
|
||||||
errors:
|
errors:
|
||||||
cannot-invite-self: "&cYou cannot invite yourself!"
|
cannot-invite-self: "&cYou cannot invite yourself!"
|
||||||
|
@ -151,6 +151,7 @@ public class IslandBanCommandTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoIsland() {
|
public void testNoIsland() {
|
||||||
|
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
||||||
IslandBanCommand ibc = new IslandBanCommand(ic);
|
IslandBanCommand ibc = new IslandBanCommand(ic);
|
||||||
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
|
assertFalse(ibc.execute(user, ibc.getLabel(), Collections.singletonList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.errors.no-island");
|
Mockito.verify(user).sendMessage("general.errors.no-island");
|
||||||
|
@ -145,6 +145,7 @@ public class IslandUnbanCommandTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoIsland() {
|
public void testNoIsland() {
|
||||||
|
when(im.inTeam(Mockito.any(), Mockito.eq(uuid))).thenReturn(false);
|
||||||
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
|
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
|
||||||
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
|
assertFalse(iubc.execute(user, iubc.getLabel(), Collections.singletonList("bill")));
|
||||||
Mockito.verify(user).sendMessage("general.errors.no-island");
|
Mockito.verify(user).sendMessage("general.errors.no-island");
|
||||||
|
Loading…
Reference in New Issue
Block a user