mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-22 09:08:03 +01:00
Teams functions are working now.
Added kick command. Cleaned up command permissions and allowed/no allowed logic. Added permissions to plugin.yml.
This commit is contained in:
parent
adb16eb36b
commit
f109c956bb
@ -24,6 +24,7 @@ general:
|
||||
help:
|
||||
header: "&7=========== BSKYBLOCK ==========="
|
||||
syntax: " &7/&b[label] &c[command] &a[args] &7: &e[info]"
|
||||
syntax-alias-separator: "/"
|
||||
end: "&7================================="
|
||||
island:
|
||||
about: "display info about %bsb_plugin_name%"
|
||||
@ -229,7 +230,7 @@ challenges:
|
||||
erroryouaremissing: "You are missing"
|
||||
expReward: "Exp reward"
|
||||
firstTimeRewards: "First time reward(s)"
|
||||
guititle: "ASkyBlock Challenges"
|
||||
guititle: "BSkyBlock Challenges"
|
||||
help1: "Use /c <name> to view information about a challenge."
|
||||
help2: "Use /c complete <name> to attempt to complete that challenge."
|
||||
incomplete: "Incomplete"
|
||||
@ -452,12 +453,16 @@ islandguardsettings:
|
||||
withergriefing: "Wither griefing"
|
||||
workbench: "Visitor workbench use"
|
||||
kick:
|
||||
errorNoTeam: "You do not have a team!"
|
||||
errorNotPartOfTeam: "That player is not part of your island team!"
|
||||
errorOnlyLeaderCan: "Only the leader can kick people off the island!"
|
||||
errorPlayerNotInTeam: "That player is not in your team!"
|
||||
nameRemoved: "[name] has been removed from the island."
|
||||
nameRemovedYou: "[name] has removed you from their island!"
|
||||
canceled: "Kick canceled"
|
||||
error:
|
||||
noTeam: "You do not have a team!"
|
||||
notPartOfTeam: "That player is not part of your island team!"
|
||||
onlyLeaderCan: "Only the leader can kick people off the island!"
|
||||
playerNotInTeam: "That player is not in your team!"
|
||||
youCannotKickYourself: "You cannot kick yourself!"
|
||||
nameRemoved: "[name] removed from the island."
|
||||
nameRemovedYou: "[name] removed you from their island!"
|
||||
warning: "Are you sure you want to kick the player? Type the command again to confirm."
|
||||
lavaTip: "Tip: If obsidian was not intended, it can be scooped back up again with a bucket."
|
||||
leave:
|
||||
canceled: "Leave canceled"
|
||||
@ -554,7 +559,7 @@ settingsReset:
|
||||
done: "Done."
|
||||
inprogress: "Protection settings being reset, please wait..."
|
||||
sign:
|
||||
line1: "&1[A Skyblock]"
|
||||
line1: "&1[BSkyblock]"
|
||||
line2: "[player]"
|
||||
line3: "Do not fall!"
|
||||
line4: "Beware!"
|
||||
|
132
plugin.yml
132
plugin.yml
@ -24,4 +24,134 @@ commands:
|
||||
description: Game challenges
|
||||
aliases: [c, challenge, bschallenge, challenges]
|
||||
usage: |
|
||||
/challenge
|
||||
/challenge
|
||||
permissions:
|
||||
bskyblock.*:
|
||||
default: false
|
||||
children:
|
||||
bskyblock.island.*:
|
||||
children:
|
||||
bskyblock.island.home:
|
||||
description: Allow teleporting to player island
|
||||
default: true
|
||||
bskyblock.island.create:
|
||||
description: Let the player use the /island command
|
||||
default: true
|
||||
bskyblock.island.info:
|
||||
description: Let the player check their island level
|
||||
default: true
|
||||
bskyblock.island.sethome:
|
||||
description: Let the player set their island teleport point
|
||||
default: true
|
||||
bskyblock.island.controlpanel:
|
||||
description: Allows usage of the island GUI
|
||||
default: true
|
||||
bskyblock.island.lock:
|
||||
description: Allows island locking
|
||||
default: false
|
||||
bskyblock.island.expel:
|
||||
description: Allows expelling of visitors
|
||||
default: true
|
||||
bskyblock.island.ban:
|
||||
description: Allows banning of visitors
|
||||
default: false
|
||||
bskyblock.island.settings:
|
||||
description: Player can see server settings
|
||||
default: true
|
||||
bskyblock.island.lang:
|
||||
description: Player can select a language
|
||||
default: true
|
||||
bskyblock.island.name:
|
||||
description: Player can set the name of their island
|
||||
default: false
|
||||
bskyblock.island.spawn:
|
||||
description: Player can use the island spawn command if spawn exists
|
||||
default: true
|
||||
bskyblock.island.reset:
|
||||
description: Player can use the island reset or restart command
|
||||
default: true
|
||||
bskyblock.team:
|
||||
description: Let a player use team commands
|
||||
default: true
|
||||
bskyblock.mod.*:
|
||||
children:
|
||||
bskyblock.mod.info:
|
||||
description: Let a moderator see info on a player
|
||||
default: op
|
||||
bskyblock.mod.resethome:
|
||||
description: Allows setting or reseting of a player's home position
|
||||
default: op
|
||||
bskyblock.mod.clearreset:
|
||||
description: Allow clearing of island reset limit
|
||||
default: false
|
||||
bskyblock.mod.tp:
|
||||
description: Allows teleport to an island
|
||||
default: op
|
||||
bskyblock.mod.bypassprotect:
|
||||
description: Allow moderator to bypass island protection
|
||||
default: op
|
||||
bskyblock.mod.bypassexpel:
|
||||
description: Allow moderator to bypass island expulsion
|
||||
default: op
|
||||
bskyblock.mod.topbreeders:
|
||||
description: Lists most populated islands current loaded
|
||||
default: op
|
||||
bskyblock.mod.lock:
|
||||
description: Locks or unlocks an island
|
||||
default: op
|
||||
bskyblock.mod.bypasslock:
|
||||
description: Bypasses an island lock
|
||||
default: op
|
||||
bskyblock.mod.team:
|
||||
description: Enables modification of teams via kick and add commands
|
||||
default: false
|
||||
bskyblock.mod.name:
|
||||
description: Enables naming of player's islands
|
||||
default: false
|
||||
bskyblock.mod.resetname:
|
||||
description: Enables reset of player's island names
|
||||
default: false
|
||||
bskyblock.admin.*:
|
||||
children:
|
||||
bskyblock.admin.clearresetall:
|
||||
description: Allow clearing of island reset limit of all players
|
||||
default: op
|
||||
bskyblock.admin.reload:
|
||||
description: Reload the config.yml
|
||||
default: op
|
||||
bskyblock.admin.delete:
|
||||
description: Let a player completely remove a player (including island)
|
||||
default: op
|
||||
bskyblock.admin.deleteisland:
|
||||
description: Let a player completely remove the island the player is on
|
||||
default: op
|
||||
bskyblock.admin.register:
|
||||
description: Let a player register the nearest island to another player.
|
||||
default: op
|
||||
bskyblock.admin.unregister:
|
||||
description: Removes a player from an island without deleting the island blocks.
|
||||
default: op
|
||||
bskyblock.admin.purge:
|
||||
description: Let a player purge old islands.
|
||||
default: op
|
||||
bskyblock.admin.setspawn:
|
||||
description: Allows use of spawn tools
|
||||
default: op
|
||||
bskyblock.admin.setrange:
|
||||
description: Allows setting of island protection range
|
||||
default: op
|
||||
bskyblock.admin.topbreeders:
|
||||
description: Lists most populated islands current loaded
|
||||
default: op
|
||||
bskyblock.admin.reserve:
|
||||
description: Reserves an empty spot for a player's next island
|
||||
default: op
|
||||
bskyblock.admin.settingsreset:
|
||||
description: Resets all the islands to default protection settings
|
||||
default: op
|
||||
bskyblock.admin.noban:
|
||||
description: Player cannot be banned from an island
|
||||
default: op
|
||||
bskyblock.admin.setlanguage:
|
||||
description: Resets all player languages and sets the default language
|
||||
default: op
|
@ -10,11 +10,11 @@ import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
@ -45,6 +45,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
// The time a player has to wait until they can reset their island again
|
||||
private HashMap<UUID, Long> resetWaitTime = new HashMap<>();
|
||||
protected Set<UUID> leavingPlayers = new HashSet<>();
|
||||
protected Set<UUID> kickingPlayers = new HashSet<>();
|
||||
|
||||
public IslandCommand(BSkyBlock plugin) {
|
||||
super(plugin, Settings.ISLANDCOMMAND, new String[]{"is"}, true);
|
||||
@ -137,6 +138,9 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.home")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
if (!getIslands().hasIsland(playerUUID)) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-island"));
|
||||
}
|
||||
@ -168,6 +172,9 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.spawn")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
|
||||
@ -192,10 +199,15 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.create")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
if (getIslands().hasIsland(playerUUID)) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.already-have-island"));
|
||||
}
|
||||
|
||||
if (inTeam) {
|
||||
new CanUseResp(false);
|
||||
}
|
||||
return new CanUseResp(true);
|
||||
}
|
||||
|
||||
@ -220,6 +232,9 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.info")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
|
||||
@ -244,6 +259,9 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.cp")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
|
||||
@ -268,10 +286,18 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.reset")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
if (getIslands().hasIsland(playerUUID)) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-island"));
|
||||
}
|
||||
|
||||
if (!getIslands().isOwner(playerUUID)) {
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
if (inTeam) {
|
||||
return new CanUseResp(getLocale(sender).get("island.reset.MustRemovePlayers"));
|
||||
}
|
||||
return new CanUseResp(true);
|
||||
}
|
||||
|
||||
@ -308,6 +334,9 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.sethome")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
return new CanUseResp(false);
|
||||
}
|
||||
|
||||
@ -431,15 +460,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
|
||||
if (!inTeam) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-team"));
|
||||
}
|
||||
|
||||
return new CanUseResp(true);
|
||||
return new CanUseResp(inTeam);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -504,7 +528,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
// Player issuing the command must have an island
|
||||
@ -527,19 +551,22 @@ public class IslandCommand extends AbstractCommand {
|
||||
OfflinePlayer inviter = plugin.getServer().getOfflinePlayer(inviteList.get(playerUUID));
|
||||
Util.sendMessage(player, getLocale(sender).get("invite.nameHasInvitedYou").replace("[name]", inviter.getName()));
|
||||
} else {
|
||||
Util.sendMessage(player, getLocale(sender).get("island.help.Invite"));
|
||||
Util.sendMessage(player, getLocale(sender).get("help.island.invite"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
// Only online players can be invited
|
||||
@SuppressWarnings("deprecation")
|
||||
Player invitedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||
UUID invitedPlayerUUID = getPlayers().getUUID(args[0]);
|
||||
if (invitedPlayerUUID == null) {
|
||||
Util.sendMessage(player, getLocale(sender).get("general.errors.offline-player"));
|
||||
return;
|
||||
}
|
||||
Player invitedPlayer = plugin.getServer().getPlayer(invitedPlayerUUID);
|
||||
if (invitedPlayer == null) {
|
||||
Util.sendMessage(player, getLocale(sender).get("general.errors.offline-player"));
|
||||
return;
|
||||
}
|
||||
UUID invitedPlayerUUID = invitedPlayer.getUniqueId();
|
||||
// Player cannot invite themselves
|
||||
if (playerUUID.equals(invitedPlayerUUID)) {
|
||||
Util.sendMessage(player, getLocale(sender).get("invite.error.YouCannotInviteYourself"));
|
||||
@ -615,7 +642,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("island.help.invite")};
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.invite")};
|
||||
}
|
||||
});
|
||||
|
||||
@ -624,11 +651,11 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
|
||||
return new CanUseResp(true);
|
||||
// Can only use if you have an invite out there
|
||||
return new CanUseResp(inviteList.inverse().containsKey(playerUUID));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -642,7 +669,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
Util.sendMessage(player, getLocale(sender).get("general.success"));
|
||||
}
|
||||
} else {
|
||||
Util.sendMessage(player, getLocale(sender).get("island.help.invite"));
|
||||
Util.sendMessage(player, getLocale(sender).get("help.island.invite"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,7 +680,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.uninvite")};
|
||||
return new String[]{"", getLocale(sender).get("help.island.uninvite")};
|
||||
}
|
||||
});
|
||||
|
||||
@ -662,11 +689,11 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.join")) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
|
||||
return new CanUseResp(true);
|
||||
// Can only leave if you are not the leader
|
||||
return new CanUseResp(inTeam && !teamLeaderUUID.equals(playerUUID));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -681,13 +708,13 @@ public class IslandCommand extends AbstractCommand {
|
||||
// Check for confirmation
|
||||
if (Settings.leaveConfirmation && !leavingPlayers.contains(playerUUID)) {
|
||||
leavingPlayers.add(playerUUID);
|
||||
Util.sendMessage(player, getLocale(sender).get("leave.Warning"));
|
||||
Util.sendMessage(player, getLocale(sender).get("leave.warning"));
|
||||
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||
// If the player is still on the list, remove them and cancel the leave
|
||||
if (leavingPlayers.contains(playerUUID)) {
|
||||
leavingPlayers.remove(playerUUID);
|
||||
Util.sendMessage(player, getLocale(sender).get("leave.Canceled"));
|
||||
Util.sendMessage(player, getLocale(sender).get("leave.canceled"));
|
||||
}
|
||||
}, Settings.leaveConfirmWait * 20L);
|
||||
|
||||
@ -744,21 +771,75 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
|
||||
return new CanUseResp(true);
|
||||
return new CanUseResp(inTeam && teamLeaderUUID.equals(playerUUID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (args.length != 1) {
|
||||
Util.sendMessage(player, ChatColor.RED + getShortDescription(sender));
|
||||
return;
|
||||
}
|
||||
// Only team members can be kicked
|
||||
UUID targetPlayerUUID = getPlayers().getUUID(args[0]);
|
||||
if (targetPlayerUUID == null || !getIslands().getMembers(playerUUID).contains(targetPlayerUUID)) {
|
||||
Util.sendMessage(player, getLocale(sender).get("kick.error.notPartOfTeam"));
|
||||
return;
|
||||
}
|
||||
// Player cannot kick themselves
|
||||
if (playerUUID.equals(targetPlayerUUID)) {
|
||||
Util.sendMessage(player, getLocale(sender).get("kick.error.youCannotKickYourself"));
|
||||
return;
|
||||
}
|
||||
// Check for confirmation
|
||||
if (Settings.confirmKick && !kickingPlayers.contains(playerUUID)) {
|
||||
kickingPlayers.add(playerUUID);
|
||||
Util.sendMessage(player, getLocale(sender).get("kick.warning"));
|
||||
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||
// If the player is still on the list, remove them and cancel the leave
|
||||
if (kickingPlayers.contains(playerUUID)) {
|
||||
kickingPlayers.remove(playerUUID);
|
||||
Util.sendMessage(player, getLocale(sender).get("kick.canceled"));
|
||||
}
|
||||
}, Settings.confirmKickWait * 20L);
|
||||
|
||||
return;
|
||||
}
|
||||
// Remove from confirmation list
|
||||
kickingPlayers.remove(playerUUID);
|
||||
// Remove from team
|
||||
if (!getIslands().setLeaveTeam(targetPlayerUUID)) {
|
||||
// If this is canceled, fail silently
|
||||
return;
|
||||
}
|
||||
// Log the location that this player left so they
|
||||
// cannot join again before the cool down ends
|
||||
getPlayers().startInviteCoolDownTimer(targetPlayerUUID, getIslands().getIslandLocation(teamLeaderUUID));
|
||||
// Tell the player they kicked okay
|
||||
Util.sendMessage(player, getLocale(sender).get("kick.nameRemoved").replace("[name]", getPlayers().getName(targetPlayerUUID)));
|
||||
// Tell the target if they are online
|
||||
if (plugin.getServer().getPlayer(targetPlayerUUID) != null) {
|
||||
Player target = plugin.getServer().getPlayer(targetPlayerUUID);
|
||||
Util.sendMessage(target, getLocale(targetPlayerUUID).get("kick.nameRemovedYou").replace("[name]", player.getName()));
|
||||
} else {
|
||||
// TODO: Leave them an offline message
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return null;
|
||||
Set<String> result = new HashSet<>();
|
||||
for (UUID members : getIslands().getMembers(teamLeaderUUID)) {
|
||||
if (!members.equals(teamLeaderUUID)) {
|
||||
result.add(getPlayers().getName(members));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -772,11 +853,11 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.join")) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
|
||||
return new CanUseResp(true);
|
||||
return new CanUseResp(inviteList.containsKey(player.getUniqueId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -806,32 +887,31 @@ public class IslandCommand extends AbstractCommand {
|
||||
inviteList.remove(playerUUID);
|
||||
// Put player into Spectator mode
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
// Add the player to the team
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: adding " + playerUUID + " to team " + prospectiveTeamLeaderUUID);
|
||||
Island island = getIslands().getIsland(prospectiveTeamLeaderUUID);
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: team members = " + island.getMembers().toString());
|
||||
if (!getIslands().setJoinTeam(playerUUID, prospectiveTeamLeaderUUID)) {
|
||||
// Not allowed (blocked by another listener)
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO implement this
|
||||
//getPlayers().resetPlayer(player);
|
||||
|
||||
// Get the player's island - may be null if the player has no island
|
||||
Island island = getIslands().getIsland(playerUUID);
|
||||
// Get the team's island
|
||||
Island teamIsland = getIslands().getIsland(prospectiveTeamLeaderUUID);
|
||||
// Clear the player's inventory
|
||||
player.getInventory().clear();
|
||||
// Move player to team's island
|
||||
Location newHome = getIslands().getSafeHomeLocation(prospectiveTeamLeaderUUID, 1);
|
||||
player.teleport(newHome);
|
||||
// Remove player as owner of the old island
|
||||
getIslands().removePlayer(playerUUID);
|
||||
// Add the player as a team member of the new island
|
||||
getIslands().setJoinTeam(teamIsland, playerUUID);
|
||||
// Set the player's home
|
||||
getPlayers().setHomeLocation(playerUUID, player.getLocation());
|
||||
// Delete the old island
|
||||
getIslands().deleteIsland(island, true);
|
||||
// Set the cooldown
|
||||
setResetWaitTime(player);
|
||||
|
||||
// Reset deaths
|
||||
if (Settings.teamJoinDeathReset) {
|
||||
getPlayers().setDeaths(playerUUID, 0);
|
||||
}
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: Setting home. team leader's home is " + getPlayers().getHomeLocation(prospectiveTeamLeaderUUID));
|
||||
// Set the player's home
|
||||
getPlayers().setHomeLocation(playerUUID, getPlayers().getHomeLocation(prospectiveTeamLeaderUUID));
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: teleporting player to new island");
|
||||
getIslands().homeTeleport(player);
|
||||
// Put player back into normal mode
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
// Fire event so add-ons can run commands, etc.
|
||||
plugin.getServer().getPluginManager().callEvent(new PlayerAcceptInviteEvent(player));
|
||||
@ -862,11 +942,11 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.join")) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
|
||||
return new CanUseResp(true);
|
||||
// Can use if invited
|
||||
return new CanUseResp(inviteList.containsKey(player.getUniqueId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -904,11 +984,11 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team.create")) {
|
||||
if (!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "team")) {
|
||||
return new CanUseResp(getLocale(sender).get("general.errors.no-permission"));
|
||||
}
|
||||
|
||||
return new CanUseResp(true);
|
||||
// Can use if in a team
|
||||
return new CanUseResp(inTeam && teamLeaderUUID.equals(playerUUID));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -269,24 +269,7 @@ public class IslandsManager {
|
||||
//getWarpSignsListener().removeWarp(player);
|
||||
final Island island = getIsland(player);
|
||||
if (island != null) {
|
||||
// Set the owner of the island to no one.
|
||||
island.setOwner(null);
|
||||
island.setLocked(false);
|
||||
if (removeBlocks) {
|
||||
// Remove players from island
|
||||
removePlayersFromIsland(island, player);
|
||||
// Remove island from the cache
|
||||
deleteIslandFromCache(island);
|
||||
// Remove the island from the database
|
||||
try {
|
||||
handler.deleteObject(island);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Remove blocks from world
|
||||
new DeleteIslandBlocks(plugin, island);
|
||||
}
|
||||
//getServer().getPluginManager().callEvent(new IslandDeleteEvent(player, island.getCenter()));
|
||||
deleteIsland(island, removeBlocks);
|
||||
} else {
|
||||
plugin.getLogger().severe("Could not delete player: " + player.toString() + " island!");
|
||||
//plugin.getServer().getPluginManager().callEvent(new IslandDeleteEvent(player, null));
|
||||
@ -329,55 +312,14 @@ public class IslandsManager {
|
||||
* @param teamLeader
|
||||
* @return true if successful, false if not
|
||||
*/
|
||||
public boolean setJoinTeam(UUID playerUUID, UUID teamLeader) {
|
||||
Island teamIsland = islandsByUUID.get(teamLeader);
|
||||
if (teamIsland == null) {
|
||||
// Something odd here, team leader does not have an island!
|
||||
plugin.getLogger().severe("Team leader does not have an island!");
|
||||
return false;
|
||||
}
|
||||
if (DEBUG) {
|
||||
plugin.getLogger().info("DEBUG: new team member list 0:");
|
||||
plugin.getLogger().info(teamIsland.getMembers().toString());
|
||||
}
|
||||
if (teamIsland.getMembers().contains(playerUUID)) {
|
||||
// Player already on island
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: Fire a join team event. If canceled, return false
|
||||
// Find out if the player had an old island
|
||||
if (islandsByUUID.containsKey(playerUUID)) {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: player is a member of an old island");
|
||||
Island oldIsland = islandsByUUID.get(playerUUID);
|
||||
oldIsland.removeMember(playerUUID);
|
||||
if (oldIsland.getOwner() != null && oldIsland.getOwner().equals(playerUUID)) {
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: player's old island was theirs - deleting from grid");
|
||||
// Delete old island
|
||||
oldIsland.setOwner(null);
|
||||
oldIsland.setLocked(false);
|
||||
islandsByLocation.remove(oldIsland.getCenter());
|
||||
new DeleteIslandBlocks(plugin, oldIsland);
|
||||
try {
|
||||
handler.deleteObject(oldIsland);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DEBUG) {
|
||||
plugin.getLogger().info("DEBUG: new team member list 1:");
|
||||
plugin.getLogger().info(teamIsland.getMembers().toString());
|
||||
}
|
||||
public boolean setJoinTeam(Island teamIsland, UUID playerUUID) {
|
||||
// Add player to new island
|
||||
if (DEBUG)
|
||||
plugin.getLogger().info("DEBUG: Adding player to new island");
|
||||
teamIsland.addMember(playerUUID);
|
||||
islandsByUUID.put(playerUUID, teamIsland);
|
||||
if (DEBUG) {
|
||||
plugin.getLogger().info("DEBUG: new team member list 2:");
|
||||
plugin.getLogger().info("DEBUG: new team member list:");
|
||||
plugin.getLogger().info(teamIsland.getMembers().toString());
|
||||
}
|
||||
// Save the database
|
||||
@ -1110,13 +1052,13 @@ public class IslandsManager {
|
||||
* @param island to remove players from
|
||||
* @param uuid
|
||||
*/
|
||||
public void removePlayersFromIsland(final Island island, UUID uuid) {
|
||||
public void removePlayersFromIsland(final Island island) {
|
||||
// Teleport players away
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (island.inIslandSpace(player.getLocation().getBlockX(), player.getLocation().getBlockZ())) {
|
||||
//plugin.getLogger().info("DEBUG: in island space");
|
||||
// Teleport island players to their island home
|
||||
if (!player.getUniqueId().equals(uuid) && (plugin.getPlayers().hasIsland(player.getUniqueId()) || plugin.getPlayers().inTeam(player.getUniqueId()))) {
|
||||
if (plugin.getPlayers().hasIsland(player.getUniqueId()) || plugin.getPlayers().inTeam(player.getUniqueId())) {
|
||||
//plugin.getLogger().info("DEBUG: home teleport");
|
||||
homeTeleport(player);
|
||||
} else {
|
||||
@ -1379,4 +1321,33 @@ public class IslandsManager {
|
||||
public void metrics_setCreatedCount(int count){
|
||||
this.metrics_createdcount = count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes island. If island is null, it does nothing
|
||||
* @param island
|
||||
* @param removeBlocks - if the island blocks should be removed or not
|
||||
*/
|
||||
public void deleteIsland(Island island, boolean removeBlocks) {
|
||||
if (island == null)
|
||||
return;
|
||||
// Set the owner of the island to no one.
|
||||
island.setOwner(null);
|
||||
island.setLocked(false);
|
||||
if (removeBlocks) {
|
||||
// Remove players from island
|
||||
removePlayersFromIsland(island);
|
||||
// Remove island from the cache
|
||||
deleteIslandFromCache(island);
|
||||
// Remove the island from the database
|
||||
try {
|
||||
handler.deleteObject(island);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Remove blocks from world
|
||||
new DeleteIslandBlocks(plugin, island);
|
||||
}
|
||||
//getServer().getPluginManager().callEvent(new IslandDeleteEvent(player, island.getCenter()));
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user