mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-21 08:37:50 +01:00
Updated en_US with all the commands and made some minor changes to the CommandsAPI
Renamed BSBCommand to BSCommand Renamed some commands Put invites commands in team Splited makeleader from promote -> setowner
This commit is contained in:
parent
5a5aff32c0
commit
8144f80cfb
locales
src/main/java/us/tastybento/bskyblock
@ -23,7 +23,6 @@ general:
|
|||||||
not-leader: "You are not the leader of your island!"
|
not-leader: "You are not the leader of your island!"
|
||||||
offline-player: "That player is offline or doesn't exist."
|
offline-player: "That player is offline or doesn't exist."
|
||||||
unknown-player: "Unknown player!"
|
unknown-player: "Unknown player!"
|
||||||
unable-create-island: "Your island could not be generated, please contact an administrator."
|
|
||||||
general: "That command is not ready yet - contact admin"
|
general: "That command is not ready yet - contact admin"
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
@ -34,34 +33,83 @@ commands:
|
|||||||
end: "&7================================="
|
end: "&7================================="
|
||||||
about: "display this help page"
|
about: "display this help page"
|
||||||
admin:
|
admin:
|
||||||
version: "display %bsb_plugin_name% and addons versions"
|
version:
|
||||||
|
usage: "display %bsb_plugin_name% and addons versions"
|
||||||
|
setrange:
|
||||||
|
range-updated: "Island range updated to [number]"
|
||||||
island:
|
island:
|
||||||
about: "display info about %bsb_plugin_name%"
|
about:
|
||||||
go: "teleport you to your island"
|
usage: "display info about %bsb_plugin_name%"
|
||||||
go-homes: "teleport you to the specified home"
|
go:
|
||||||
spawn: "teleport you to the spawn"
|
usage: "teleport you to your island"
|
||||||
create: "create an island"
|
spawn:
|
||||||
info: "display info about your island"
|
usage: "teleport you to the spawn"
|
||||||
reset: "restart your island and remove the old one"
|
create:
|
||||||
sethome: "set your teleport point for /island"
|
usage: "create an island"
|
||||||
name: "set a name for your island"
|
unable-create-island: "Your island could not be generated, please contact an administrator."
|
||||||
resetname: "reset your island name"
|
info:
|
||||||
|
usage: "display info about your island"
|
||||||
|
reset:
|
||||||
|
usage: "restart your island and remove the old one"
|
||||||
|
must-remove-members: "You must remove all members from your island before you can restart it (/island kick <player>)."
|
||||||
|
sethome:
|
||||||
|
usage: "set your teleport point for /island"
|
||||||
|
must-be-on-your-island: "You must be on your island to set home!"
|
||||||
|
num-homes: "Homes can be 1 to [max]."
|
||||||
|
home-set: "Your island home has been set to your current location."
|
||||||
|
setname:
|
||||||
|
usage: "set a name for your island"
|
||||||
|
name-too-short: "Too short. Minimum size is [length] characters."
|
||||||
|
name-too-long: "Too long. Maximum size is [length] characters."
|
||||||
|
resetname:
|
||||||
|
usage: "reset your island name"
|
||||||
team:
|
team:
|
||||||
info: "display detailed info about your team"
|
usage: "manage your team"
|
||||||
invite: "invite a player to join your island"
|
info:
|
||||||
uninvite: "cancel the pending invite to join your island"
|
usage: "display detailed info about your team"
|
||||||
leave: "leave your island"
|
invite:
|
||||||
kick: "remove a member from your island"
|
usage: "invite a player to join your island"
|
||||||
accept: "accept an invitation"
|
errors:
|
||||||
reject: "reject an invitation"
|
island-is-full: "Your island is full, you can't invite anyone else."
|
||||||
promote: "promote a player on your island to another rank"
|
none-invited-you: "No one invited you :c."
|
||||||
expel: "expel a visitor from your island"
|
you-already-are-in-team: "You are already on a team!"
|
||||||
ban: "ban a player from your island"
|
invalid-invite: "That invite is no longer valid, sorry."
|
||||||
unban: "unban a player from your island"
|
you-can-invite: "You can invite [number] more players."
|
||||||
banlist: "list banned players"
|
accept:
|
||||||
lock: "lock/unlock your island so visitors cannot enter it"
|
usage: "accept an invitation"
|
||||||
settings: "display island settings"
|
you-joined-island: "You have joined an island! Use /[label] team info to see the other members."
|
||||||
language: "select language"
|
name-joined-your-island: "[name] has joined your island!"
|
||||||
|
reject:
|
||||||
|
usage: "reject an invitation"
|
||||||
|
you-rejected-invite: "You have rejected the invitation to join an island."
|
||||||
|
name-rejected-your-invite: "[name] has rejected your island invite!"
|
||||||
|
cancel:
|
||||||
|
usage: "cancel the pending invite to join your island"
|
||||||
|
leave:
|
||||||
|
usage: "leave your island"
|
||||||
|
kick:
|
||||||
|
usage: "remove a member from your island"
|
||||||
|
promote:
|
||||||
|
usage: "promote a player on your island to another rank"
|
||||||
|
setowner:
|
||||||
|
usage: "transfer your island ownership to a member"
|
||||||
|
errors:
|
||||||
|
cant-transfer-to-yourself: "You can't transfer ownership to yourself! Well, in facts, you could have been able to do so... But we don't want you to do so. 'Cause it's bad."
|
||||||
|
target-is-not-member: "That player is not part of your island team!"
|
||||||
|
name-is-the-owner: "[name] is now the island owner!"
|
||||||
|
you-are-the-owner: "You are now the island owner!"
|
||||||
|
ban:
|
||||||
|
usage: "ban a player from your island"
|
||||||
|
unban:
|
||||||
|
usage: "unban a player from your island"
|
||||||
|
banlist:
|
||||||
|
usage: "list banned players"
|
||||||
|
lock:
|
||||||
|
usage: "lock/unlock your island so visitors cannot enter it"
|
||||||
|
settings:
|
||||||
|
usage: "display island settings"
|
||||||
|
language:
|
||||||
|
usage: "select language"
|
||||||
|
|
||||||
protection:
|
protection:
|
||||||
flags:
|
flags:
|
||||||
|
@ -9,7 +9,7 @@ import java.util.Optional;
|
|||||||
* @author ben
|
* @author ben
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface BSBCommand {
|
public interface BSCommand {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Anything that needs to be set up for this command.
|
* Anything that needs to be set up for this command.
|
||||||
@ -28,7 +28,7 @@ public interface BSBCommand {
|
|||||||
/**
|
/**
|
||||||
* Tab Completer for CompositeCommands. Note that any registered sub-commands will be automatically
|
* Tab Completer for CompositeCommands. Note that any registered sub-commands will be automatically
|
||||||
* added to the list must not be manually added. Use this to add tab-complete for things like names.
|
* added to the list must not be manually added. Use this to add tab-complete for things like names.
|
||||||
* @param sender
|
* @param user
|
||||||
* @param alias
|
* @param alias
|
||||||
* @param args
|
* @param args
|
||||||
* @return List of strings that could be used to complete this command.
|
* @return List of strings that could be used to complete this command.
|
@ -27,7 +27,7 @@ import us.tastybento.bskyblock.util.Util;
|
|||||||
* @author ben, poslovich
|
* @author ben, poslovich
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class CompositeCommand extends Command implements PluginIdentifiableCommand, BSBCommand {
|
public abstract class CompositeCommand extends Command implements PluginIdentifiableCommand, BSCommand {
|
||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
/**
|
/**
|
||||||
|
@ -11,13 +11,12 @@ import us.tastybento.bskyblock.commands.island.IslandResetCommand;
|
|||||||
import us.tastybento.bskyblock.commands.island.IslandSetnameCommand;
|
import us.tastybento.bskyblock.commands.island.IslandSetnameCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.IslandSethomeCommand;
|
import us.tastybento.bskyblock.commands.island.IslandSethomeCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.IslandResetnameCommand;
|
import us.tastybento.bskyblock.commands.island.IslandResetnameCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.teams.IslandInviteAcceptCommand;
|
import us.tastybento.bskyblock.commands.island.teams.IslandTeamInviteAcceptCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.teams.IslandInviteRejectCommand;
|
import us.tastybento.bskyblock.commands.island.teams.IslandTeamInviteRejectCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.teams.IslandLeaveCommand;
|
import us.tastybento.bskyblock.commands.island.teams.IslandTeamLeaveCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamCommand;
|
import us.tastybento.bskyblock.commands.island.teams.IslandTeamCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamInviteCommand;
|
import us.tastybento.bskyblock.commands.island.teams.IslandTeamInviteCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamPromoteCommand;
|
import us.tastybento.bskyblock.commands.island.teams.IslandTeamPromoteCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamUninviteCommand;
|
|
||||||
import us.tastybento.bskyblock.config.Settings;
|
import us.tastybento.bskyblock.config.Settings;
|
||||||
|
|
||||||
public class IslandCommand extends CompositeCommand {
|
public class IslandCommand extends CompositeCommand {
|
||||||
@ -45,13 +44,6 @@ public class IslandCommand extends CompositeCommand {
|
|||||||
new IslandResetnameCommand(this);
|
new IslandResetnameCommand(this);
|
||||||
// Team commands
|
// Team commands
|
||||||
new IslandTeamCommand(this);
|
new IslandTeamCommand(this);
|
||||||
new IslandTeamInviteCommand(this);
|
|
||||||
new IslandInviteAcceptCommand(this);
|
|
||||||
new IslandInviteRejectCommand(this);
|
|
||||||
new IslandLeaveCommand(this);
|
|
||||||
new IslandTeamPromoteCommand(this);
|
|
||||||
new IslandTeamUninviteCommand(this);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,7 @@ public class IslandAboutCommand extends CompositeCommand {
|
|||||||
*/
|
*/
|
||||||
public IslandAboutCommand(CompositeCommand islandCommand) {
|
public IslandAboutCommand(CompositeCommand islandCommand) {
|
||||||
super(islandCommand, "about", "ab");
|
super(islandCommand, "about", "ab");
|
||||||
this.setUsage("island.about.usage");
|
this.setUsage("commands.island.about.usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,7 +23,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
|||||||
super(islandCommand, "create", "auto");
|
super(islandCommand, "create", "auto");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.create");
|
this.setPermission(Settings.PERMPREFIX + "island.create");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.create.usage");
|
this.setUsage("commands.island.create.usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -56,7 +56,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
|||||||
.build();
|
.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
plugin.getLogger().severe("Could not create island for player.");
|
plugin.getLogger().severe("Could not create island for player.");
|
||||||
user.sendMessage("general.errors.general");
|
user.sendMessage("commands.island.create.unable-create-island");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ public class IslandGoCommand extends CompositeCommand {
|
|||||||
super(islandCommand, "go", "home", "h");
|
super(islandCommand, "go", "home", "h");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.home");
|
this.setPermission(Settings.PERMPREFIX + "island.home");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.go.usage");
|
this.setUsage("commands.island.go.usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -17,11 +17,11 @@ public class IslandResetCommand extends CompositeCommand {
|
|||||||
|
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
|
|
||||||
public IslandResetCommand(CompositeCommand command) {
|
public IslandResetCommand(CompositeCommand islandCommand) {
|
||||||
super(command, "reset", "restart");
|
super(islandCommand, "reset", "restart");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.create");
|
this.setPermission(Settings.PERMPREFIX + "island.create");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.reset.usage");
|
this.setUsage("commands.island.reset.usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -31,10 +31,11 @@ public class IslandResetCommand extends CompositeCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!getIslands().isOwner(user.getUniqueId())) {
|
if (!getIslands().isOwner(user.getUniqueId())) {
|
||||||
|
user.sendMessage("general.errors.not-leader");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plugin.getPlayers().inTeam(user.getUniqueId())) {
|
if (plugin.getPlayers().inTeam(user.getUniqueId())) {
|
||||||
user.sendMessage("island.reset.MustRemovePlayers");
|
user.sendMessage("commands.island.reset.must-remove-members");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
@ -58,7 +59,7 @@ public class IslandResetCommand extends CompositeCommand {
|
|||||||
.build();
|
.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
plugin.getLogger().severe("Could not create island for player.");
|
plugin.getLogger().severe("Could not create island for player.");
|
||||||
user.sendMessage("general.errors.general");
|
user.sendMessage("commands.island.create.unable-create-island");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,11 +18,11 @@ import us.tastybento.bskyblock.config.Settings;
|
|||||||
*/
|
*/
|
||||||
public class IslandResetnameCommand extends CompositeCommand {
|
public class IslandResetnameCommand extends CompositeCommand {
|
||||||
|
|
||||||
public IslandResetnameCommand(CompositeCommand command) {
|
public IslandResetnameCommand(CompositeCommand islandCommand) {
|
||||||
super(command, "resetname");
|
super(islandCommand, "resetname");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.name");
|
this.setPermission(Settings.PERMPREFIX + "island.name");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.invite.accept.usage");
|
this.setUsage("commands.island.resetname.usage");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,12 +34,12 @@ public class IslandResetnameCommand extends CompositeCommand {
|
|||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
|
|
||||||
if (!getIslands().hasIsland(playerUUID)) {
|
if (!getIslands().hasIsland(playerUUID)) {
|
||||||
user.sendMessage(ChatColor.RED + "general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getIslands().isOwner(playerUUID)) {
|
if (!getIslands().isOwner(playerUUID)) {
|
||||||
user.sendMessage(ChatColor.RED + "general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Resets the island name
|
// Resets the island name
|
||||||
|
@ -10,11 +10,11 @@ import us.tastybento.bskyblock.util.Util;
|
|||||||
|
|
||||||
public class IslandSethomeCommand extends CompositeCommand {
|
public class IslandSethomeCommand extends CompositeCommand {
|
||||||
|
|
||||||
public IslandSethomeCommand(CompositeCommand command) {
|
public IslandSethomeCommand(CompositeCommand islandCommand) {
|
||||||
super(command, "sethome");
|
super(islandCommand, "sethome");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.sethome");
|
this.setPermission(Settings.PERMPREFIX + "island.sethome");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.sethome.usage");
|
this.setUsage("commands.island.sethome.usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -26,13 +26,13 @@ public class IslandSethomeCommand extends CompositeCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!plugin.getIslands().playerIsOnIsland(user.getPlayer())) {
|
if (!plugin.getIslands().playerIsOnIsland(user.getPlayer())) {
|
||||||
user.sendMessage("sethome.error.NotOnIsland");
|
user.sendMessage("commands.island.sethome.must-be-on-your-island");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
// island sethome
|
// island sethome
|
||||||
plugin.getPlayers().setHomeLocation(playerUUID, user.getLocation());
|
plugin.getPlayers().setHomeLocation(playerUUID, user.getLocation());
|
||||||
user.sendMessage("sethome.homeSet");
|
user.sendMessage("commands.island.sethome.home-set");
|
||||||
} else {
|
} else {
|
||||||
// Dynamic home sizes with permissions
|
// Dynamic home sizes with permissions
|
||||||
int maxHomes = Util.getPermValue(user.getPlayer(), Settings.PERMPREFIX + "island.maxhomes", Settings.maxHomes);
|
int maxHomes = Util.getPermValue(user.getPlayer(), Settings.PERMPREFIX + "island.maxhomes", Settings.maxHomes);
|
||||||
@ -42,13 +42,13 @@ public class IslandSethomeCommand extends CompositeCommand {
|
|||||||
try {
|
try {
|
||||||
number = Integer.valueOf(args.get(0));
|
number = Integer.valueOf(args.get(0));
|
||||||
if (number < 1 || number > maxHomes) {
|
if (number < 1 || number > maxHomes) {
|
||||||
user.sendMessage("sethome.error.NumHomes", "[max]", String.valueOf(maxHomes));
|
user.sendMessage("commands.island.sethome.num-homes", "[max]", String.valueOf(maxHomes));
|
||||||
} else {
|
} else {
|
||||||
plugin.getPlayers().setHomeLocation(playerUUID, user.getLocation(), number);
|
plugin.getPlayers().setHomeLocation(playerUUID, user.getLocation(), number);
|
||||||
user.sendMessage("sethome.homeSet");
|
user.sendMessage("commands.island.sethome.home-set");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
user.sendMessage("sethome.error.NumHomes", "[max]", String.valueOf(maxHomes));
|
user.sendMessage("commands.island.sethome.num-homes", "[max]", String.valueOf(maxHomes));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
user.sendMessage("general.errors.no-permission");
|
user.sendMessage("general.errors.no-permission");
|
||||||
|
@ -20,11 +20,11 @@ import us.tastybento.bskyblock.config.Settings;
|
|||||||
*/
|
*/
|
||||||
public class IslandSetnameCommand extends CompositeCommand {
|
public class IslandSetnameCommand extends CompositeCommand {
|
||||||
|
|
||||||
public IslandSetnameCommand(CompositeCommand command) {
|
public IslandSetnameCommand(CompositeCommand islandCommand) {
|
||||||
super(command, "setname");
|
super(islandCommand, "setname");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.name");
|
this.setPermission(Settings.PERMPREFIX + "island.name");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.setname.usage");
|
this.setUsage("commands.island.setname.usage");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,11 +56,11 @@ public class IslandSetnameCommand extends CompositeCommand {
|
|||||||
|
|
||||||
// Check if the name isn't too short or too long
|
// Check if the name isn't too short or too long
|
||||||
if (name.length() < Settings.nameMinLength) {
|
if (name.length() < Settings.nameMinLength) {
|
||||||
user.sendMessage("general.errors.too-short", "[length]", String.valueOf(Settings.nameMinLength));
|
user.sendMessage("commands.island.setname.too-short", "[length]", String.valueOf(Settings.nameMinLength));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (name.length() > Settings.nameMaxLength) {
|
if (name.length() > Settings.nameMaxLength) {
|
||||||
user.sendMessage("general.errors.too-long", "[length]", String.valueOf(Settings.nameMaxLength));
|
user.sendMessage("commands.island.setname.too-long", "[length]", String.valueOf(Settings.nameMaxLength));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
@ -23,8 +22,15 @@ public class IslandTeamCommand extends AbstractIslandTeamCommand {
|
|||||||
super(islandCommand, "team");
|
super(islandCommand, "team");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.team.usage");
|
this.setUsage("commands.island.team.usage");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
new IslandTeamInviteCommand(this);
|
||||||
|
new IslandTeamLeaveCommand(this);
|
||||||
|
new IslandTeamPromoteCommand(this);
|
||||||
|
new IslandTeamSetownerCommand(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -67,20 +73,9 @@ public class IslandTeamCommand extends AbstractIslandTeamCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (teamMembers.size() < maxSize) {
|
if (teamMembers.size() < maxSize) {
|
||||||
user.sendMessage("invite.youCanInvite", "[number]", String.valueOf(maxSize - teamMembers.size()));
|
user.sendMessage("commands.island.team.invite.you-can-invite", "[number]", String.valueOf(maxSize - teamMembers.size()));
|
||||||
} else {
|
} else {
|
||||||
user.sendMessage(ChatColor.RED + "invite.error.YourIslandIsFull");
|
user.sendMessage("commands.island.team.invite.errors.island-is-full");
|
||||||
}
|
|
||||||
}
|
|
||||||
user.sendMessage("team.listingMembers");
|
|
||||||
// Display members in the list
|
|
||||||
for (UUID m : teamMembers) {
|
|
||||||
if (DEBUG)
|
|
||||||
plugin.getLogger().info("DEBUG: member " + m);
|
|
||||||
if (teamLeaderUUID.equals(m)) {
|
|
||||||
user.sendMessage("team.leader", "[name]", getPlayers().getName(m));
|
|
||||||
} else {
|
|
||||||
user.sendMessage("team.member", "[name]", getPlayers().getName(m));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package us.tastybento.bskyblock.commands.island.teams;
|
||||||
|
|
||||||
|
public class IslandTeamInfoCommand {
|
||||||
|
}
|
@ -15,13 +15,13 @@ import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason;
|
|||||||
import us.tastybento.bskyblock.config.Settings;
|
import us.tastybento.bskyblock.config.Settings;
|
||||||
import us.tastybento.bskyblock.database.objects.Island;
|
import us.tastybento.bskyblock.database.objects.Island;
|
||||||
|
|
||||||
public class IslandInviteAcceptCommand extends AbstractIslandTeamCommand {
|
public class IslandTeamInviteAcceptCommand extends AbstractIslandTeamCommand {
|
||||||
|
|
||||||
public IslandInviteAcceptCommand(CompositeCommand islandCommand) {
|
public IslandTeamInviteAcceptCommand(IslandTeamInviteCommand islandTeamInviteCommand) {
|
||||||
super(islandCommand, "accept");
|
super(islandTeamInviteCommand, "accept");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.invite.accept.usage");
|
this.setUsage("commands.island.team.invite.accept.usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,18 +34,18 @@ public class IslandInviteAcceptCommand extends AbstractIslandTeamCommand {
|
|||||||
return true;
|
return true;
|
||||||
// Check if player has been invited
|
// Check if player has been invited
|
||||||
if (!inviteList.containsKey(playerUUID)) {
|
if (!inviteList.containsKey(playerUUID)) {
|
||||||
user.sendMessage("invite.error.NoOneInvitedYou");
|
user.sendMessage("commands.island.team.invite.errors.none-invited-you");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check if player is already in a team
|
// Check if player is already in a team
|
||||||
if (getPlayers().inTeam(playerUUID)) {
|
if (getPlayers().inTeam(playerUUID)) {
|
||||||
user.sendMessage("invite.error.YouAreAlreadyOnATeam");
|
user.sendMessage("commands.island.team.invite.errors.you-already-are-in-team");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Get the team leader
|
// Get the team leader
|
||||||
UUID prospectiveTeamLeaderUUID = inviteList.get(playerUUID);
|
UUID prospectiveTeamLeaderUUID = inviteList.get(playerUUID);
|
||||||
if (!getIslands().hasIsland(prospectiveTeamLeaderUUID)) {
|
if (!getIslands().hasIsland(prospectiveTeamLeaderUUID)) {
|
||||||
user.sendMessage("invite.error.InvalidInvite");
|
user.sendMessage("commands.island.team.invite.errors.invalid-invite");
|
||||||
inviteList.remove(playerUUID);
|
inviteList.remove(playerUUID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -92,10 +92,10 @@ public class IslandInviteAcceptCommand extends AbstractIslandTeamCommand {
|
|||||||
// Put player back into normal mode
|
// Put player back into normal mode
|
||||||
user.setGameMode(GameMode.SURVIVAL);
|
user.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
user.sendMessage("invite.youHaveJoinedAnIsland", "[label]", Settings.ISLANDCOMMAND);
|
user.sendMessage("commands.island.team.invite.accept.you-joined-island", "[label]", Settings.ISLANDCOMMAND);
|
||||||
User inviter = User.getInstance(inviteList.get(playerUUID));
|
User inviter = User.getInstance(inviteList.get(playerUUID));
|
||||||
if (inviter != null) {
|
if (inviter != null) {
|
||||||
inviter.sendMessage("invite.hasJoinedYourIsland", "[name]", user.getName());
|
inviter.sendMessage("commands.island.team.invite.accept.name-joined-your-island", "[name]", user.getName());
|
||||||
}
|
}
|
||||||
getIslands().save(false);
|
getIslands().save(false);
|
||||||
if (DEBUG)
|
if (DEBUG)
|
@ -21,11 +21,17 @@ import us.tastybento.bskyblock.util.Util;
|
|||||||
|
|
||||||
public class IslandTeamInviteCommand extends AbstractIslandTeamCommand {
|
public class IslandTeamInviteCommand extends AbstractIslandTeamCommand {
|
||||||
|
|
||||||
public IslandTeamInviteCommand(CompositeCommand islandTeamCommand) {
|
public IslandTeamInviteCommand(IslandTeamCommand islandTeamCommand) {
|
||||||
super(islandTeamCommand, "invite");
|
super(islandTeamCommand, "invite");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.team.invite");
|
this.setUsage("commands.island.team.invite.usage");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
new IslandTeamInviteAcceptCommand(this);
|
||||||
|
new IslandTeamInviteRejectCommand(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,7 +43,7 @@ public class IslandTeamInviteCommand extends AbstractIslandTeamCommand {
|
|||||||
if (getPlayers().inTeam(playerUUID)) {
|
if (getPlayers().inTeam(playerUUID)) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
}
|
}
|
||||||
user.sendMessage("invite.error.YouMustHaveIslandToInvite");
|
user.sendMessage("general.errors.no-island");
|
||||||
}
|
}
|
||||||
if (args.isEmpty() || args.size() > 1) {
|
if (args.isEmpty() || args.size() > 1) {
|
||||||
// Invite label with no name, i.e., /island invite - tells the player who has invited them so far
|
// Invite label with no name, i.e., /island invite - tells the player who has invited them so far
|
||||||
|
@ -10,13 +10,13 @@ import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason;
|
|||||||
import us.tastybento.bskyblock.commands.IslandCommand;
|
import us.tastybento.bskyblock.commands.IslandCommand;
|
||||||
import us.tastybento.bskyblock.config.Settings;
|
import us.tastybento.bskyblock.config.Settings;
|
||||||
|
|
||||||
public class IslandInviteRejectCommand extends AbstractIslandTeamCommand {
|
public class IslandTeamInviteRejectCommand extends AbstractIslandTeamCommand {
|
||||||
|
|
||||||
public IslandInviteRejectCommand(IslandCommand islandCommand) {
|
public IslandTeamInviteRejectCommand(IslandTeamInviteCommand islandTeamInviteCommand) {
|
||||||
super(islandCommand, "reject");
|
super(islandTeamInviteCommand, "reject");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.invite.reject.usage");
|
this.setUsage("commands.island.team.invite.reject.usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,17 +36,13 @@ public class IslandInviteRejectCommand extends AbstractIslandTeamCommand {
|
|||||||
|
|
||||||
// Remove this player from the global invite list
|
// Remove this player from the global invite list
|
||||||
inviteList.remove(user.getUniqueId());
|
inviteList.remove(user.getUniqueId());
|
||||||
user.sendMessage("reject.youHaveRejectedInvitation");
|
user.sendMessage("commands.island.team.invite.reject.you-rejected-invite");
|
||||||
// If the leader is online tell them directly
|
|
||||||
// about the rejection
|
|
||||||
User inviter = User.getInstance(inviteList.get(playerUUID));
|
|
||||||
if (inviter != null) {
|
|
||||||
inviter.sendMessage("reject.nameHasRejectedInvite", "[name]", user.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
User inviter = User.getInstance(inviteList.get(playerUUID));
|
||||||
|
inviter.sendMessage("commands.island.team.invite.reject.name-rejected-your-invite", "[name]", user.getName());
|
||||||
} else {
|
} else {
|
||||||
// Someone typed /island reject and had not been invited
|
// Someone typed /island reject and had not been invited
|
||||||
user.sendMessage("reject.youHaveNotBeenInvited");
|
user.sendMessage("commands.island.team.invite.errors.none-invited-you");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
@ -2,17 +2,16 @@ package us.tastybento.bskyblock.commands.island.teams;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
|
||||||
import us.tastybento.bskyblock.api.commands.User;
|
import us.tastybento.bskyblock.api.commands.User;
|
||||||
import us.tastybento.bskyblock.config.Settings;
|
import us.tastybento.bskyblock.config.Settings;
|
||||||
|
|
||||||
public class IslandLeaveCommand extends AbstractIslandTeamCommand {
|
public class IslandTeamLeaveCommand extends AbstractIslandTeamCommand {
|
||||||
|
|
||||||
public IslandLeaveCommand(CompositeCommand islandCommand) {
|
public IslandTeamLeaveCommand(IslandTeamCommand islandTeamCommand) {
|
||||||
super(islandCommand, "leave");
|
super(islandTeamCommand, "leave");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.leave.usage");
|
this.setUsage("command.island.team.leave.usage");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,27 +1,16 @@
|
|||||||
package us.tastybento.bskyblock.commands.island.teams;
|
package us.tastybento.bskyblock.commands.island.teams;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import us.tastybento.bskyblock.api.commands.User;
|
||||||
|
import us.tastybento.bskyblock.config.Settings;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
|
||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
|
||||||
import us.tastybento.bskyblock.api.commands.User;
|
|
||||||
import us.tastybento.bskyblock.api.events.IslandBaseEvent;
|
|
||||||
import us.tastybento.bskyblock.api.events.team.TeamEvent;
|
|
||||||
import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason;
|
|
||||||
import us.tastybento.bskyblock.config.Settings;
|
|
||||||
import us.tastybento.bskyblock.database.objects.Island;
|
|
||||||
import us.tastybento.bskyblock.util.Util;
|
|
||||||
|
|
||||||
public class IslandTeamPromoteCommand extends AbstractIslandTeamCommand {
|
public class IslandTeamPromoteCommand extends AbstractIslandTeamCommand {
|
||||||
|
|
||||||
public IslandTeamPromoteCommand(CompositeCommand islandCommand) {
|
public IslandTeamPromoteCommand(IslandTeamCommand islandTeamCommand) {
|
||||||
super(islandCommand, "promote", "makeleader");
|
super(islandTeamCommand, "promote");
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||||
this.setOnlyPlayer(true);
|
this.setOnlyPlayer(true);
|
||||||
this.setUsage("island.team.promote.usage");
|
this.setUsage("island.team.promote.usage");
|
||||||
@ -29,117 +18,12 @@ public class IslandTeamPromoteCommand extends AbstractIslandTeamCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
|
||||||
// Can use if in a team
|
|
||||||
boolean inTeam = plugin.getPlayers().inTeam(playerUUID);
|
|
||||||
UUID teamLeaderUUID = plugin.getIslands().getTeamLeader(playerUUID);
|
|
||||||
if (!(inTeam && teamLeaderUUID.equals(playerUUID))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
plugin.getLogger().info("DEBUG: arg[0] = " + args.get(0));
|
|
||||||
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
|
||||||
if (targetUUID == null) {
|
|
||||||
user.sendMessage("general.errors.unknown-player");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!getPlayers().inTeam(playerUUID)) {
|
|
||||||
user.sendMessage("makeleader.errorYouMustBeInTeam");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!teamLeaderUUID.equals(playerUUID)) {
|
|
||||||
user.sendMessage("makeleader.errorNotYourIsland");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (targetUUID.equals(playerUUID)) {
|
|
||||||
user.sendMessage("makeleader.errorGeneralError");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!plugin.getIslands().getMembers(playerUUID).contains(targetUUID)) {
|
|
||||||
user.sendMessage("makeleader.errorThatPlayerIsNotInTeam");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Fire event so add-ons can run commands, etc.
|
|
||||||
IslandBaseEvent event = TeamEvent.builder()
|
|
||||||
.island(getIslands()
|
|
||||||
.getIsland(playerUUID))
|
|
||||||
.reason(TeamReason.MAKELEADER)
|
|
||||||
.involvedPlayer(targetUUID)
|
|
||||||
.build();
|
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (event.isCancelled()) return true;
|
|
||||||
|
|
||||||
// target is the new leader
|
|
||||||
getIslands().getIsland(playerUUID).setOwner(targetUUID);
|
|
||||||
user.sendMessage("makeleader.nameIsNowTheOwner", "[name]", getPlayers().getName(targetUUID));
|
|
||||||
|
|
||||||
// Check if online
|
|
||||||
User target = User.getInstance(targetUUID);
|
|
||||||
if (target == null) {
|
|
||||||
// TODO offline messaging
|
|
||||||
//plugin.getMessages().setMessage(targetPlayer, "makeleader.youAreNowTheOwner"));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Online
|
|
||||||
target.sendMessage("makeleader.youAreNowTheOwner");
|
|
||||||
// Check if new leader has a lower range permission than the island size
|
|
||||||
boolean hasARangePerm = false;
|
|
||||||
int range = Settings.islandProtectionRange;
|
|
||||||
// Check for zero protection range
|
|
||||||
Island islandByOwner = getIslands().getIsland(targetUUID);
|
|
||||||
if (islandByOwner.getProtectionRange() == 0) {
|
|
||||||
plugin.getLogger().warning("Player " + user.getName() + "'s island had a protection range of 0. Setting to default " + range);
|
|
||||||
islandByOwner.setProtectionRange(range);
|
|
||||||
}
|
|
||||||
for (PermissionAttachmentInfo perms : target.getEffectivePermissions()) {
|
|
||||||
if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.range.")) {
|
|
||||||
if (perms.getPermission().contains(Settings.PERMPREFIX + "island.range.*")) {
|
|
||||||
// Ignore
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.range.");
|
|
||||||
if (spl.length > 1) {
|
|
||||||
if (!NumberUtils.isDigits(spl[1])) {
|
|
||||||
plugin.getLogger().severe("Player " + user.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
hasARangePerm = true;
|
|
||||||
range = Math.max(range, Integer.valueOf(spl[1]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Only set the island range if the player has a perm to override the default
|
|
||||||
if (hasARangePerm) {
|
|
||||||
// Do some sanity checking
|
|
||||||
if (range % 2 != 0) {
|
|
||||||
range--;
|
|
||||||
}
|
|
||||||
// Get island range
|
|
||||||
|
|
||||||
// Range can go up or down
|
|
||||||
if (range != islandByOwner.getProtectionRange()) {
|
|
||||||
user.sendMessage("admin.SetRangeUpdated", "[number]", String.valueOf(range));
|
|
||||||
target.sendMessage("admin.SetRangeUpdated", "[number]", String.valueOf(range));
|
|
||||||
plugin.getLogger().info(
|
|
||||||
"Makeleader: Island protection range changed from " + islandByOwner.getProtectionRange() + " to "
|
|
||||||
+ range + " for " + user.getName() + " due to permission.");
|
|
||||||
}
|
|
||||||
islandByOwner.setProtectionRange(range);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getIslands().save(true);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<List<String>> tabComplete(final User user, final String alias, final LinkedList<String> args) {
|
public Optional<List<String>> tabComplete(final User user, final String alias, final LinkedList<String> args) {
|
||||||
List<String> options = new ArrayList<>();
|
return null;
|
||||||
String lastArg = (!args.isEmpty() ? args.getLast() : "");
|
|
||||||
for (UUID member : plugin.getIslands().getMembers(user.getUniqueId())) {
|
|
||||||
options.add(plugin.getServer().getOfflinePlayer(member).getName());
|
|
||||||
}
|
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package us.tastybento.bskyblock.commands.island.teams;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
|
import us.tastybento.bskyblock.api.commands.User;
|
||||||
|
import us.tastybento.bskyblock.api.events.IslandBaseEvent;
|
||||||
|
import us.tastybento.bskyblock.api.events.team.TeamEvent;
|
||||||
|
import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason;
|
||||||
|
import us.tastybento.bskyblock.config.Settings;
|
||||||
|
import us.tastybento.bskyblock.database.objects.Island;
|
||||||
|
import us.tastybento.bskyblock.util.Util;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class IslandTeamSetownerCommand extends AbstractIslandTeamCommand {
|
||||||
|
|
||||||
|
public IslandTeamSetownerCommand(IslandTeamCommand islandTeamCommand) {
|
||||||
|
super(islandTeamCommand, "setleader");
|
||||||
|
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||||
|
this.setOnlyPlayer(true);
|
||||||
|
this.setUsage("commands.island.team.setowner.usage");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(User user, List<String> args) {
|
||||||
|
UUID playerUUID = user.getUniqueId();
|
||||||
|
// Can use if in a team
|
||||||
|
boolean inTeam = plugin.getPlayers().inTeam(playerUUID);
|
||||||
|
UUID teamLeaderUUID = plugin.getIslands().getTeamLeader(playerUUID);
|
||||||
|
if (!(inTeam && teamLeaderUUID.equals(playerUUID))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
plugin.getLogger().info("DEBUG: arg[0] = " + args.get(0));
|
||||||
|
UUID targetUUID = getPlayers().getUUID(args.get(0));
|
||||||
|
if (targetUUID == null) {
|
||||||
|
user.sendMessage("general.errors.unknown-player");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!getPlayers().inTeam(playerUUID)) {
|
||||||
|
user.sendMessage("general.errors.no-team");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!teamLeaderUUID.equals(playerUUID)) {
|
||||||
|
user.sendMessage("general.errors.not-leader");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (targetUUID.equals(playerUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.setowner.errors.cant-transfer-to-yourself");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!plugin.getIslands().getMembers(playerUUID).contains(targetUUID)) {
|
||||||
|
user.sendMessage("commands.island.team.setowner.errors.target-is-not-member");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Fire event so add-ons can run commands, etc.
|
||||||
|
IslandBaseEvent event = TeamEvent.builder()
|
||||||
|
.island(getIslands()
|
||||||
|
.getIsland(playerUUID))
|
||||||
|
.reason(TeamReason.MAKELEADER)
|
||||||
|
.involvedPlayer(targetUUID)
|
||||||
|
.build();
|
||||||
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) return true;
|
||||||
|
|
||||||
|
// target is the new leader
|
||||||
|
getIslands().getIsland(playerUUID).setOwner(targetUUID);
|
||||||
|
user.sendMessage("commands.island.team.setowner.name-is-the-owner", "[name]", getPlayers().getName(targetUUID));
|
||||||
|
|
||||||
|
// Check if online
|
||||||
|
User target = User.getInstance(targetUUID);
|
||||||
|
target.sendMessage("commands.island.team.setowner.you-are-the-owner");
|
||||||
|
if (target.isOnline()) {
|
||||||
|
// Check if new leader has a lower range permission than the island size
|
||||||
|
boolean hasARangePerm = false;
|
||||||
|
int range = Settings.islandProtectionRange;
|
||||||
|
// Check for zero protection range
|
||||||
|
Island islandByOwner = getIslands().getIsland(targetUUID);
|
||||||
|
if (islandByOwner.getProtectionRange() == 0) {
|
||||||
|
plugin.getLogger().warning("Player " + user.getName() + "'s island had a protection range of 0. Setting to default " + range);
|
||||||
|
islandByOwner.setProtectionRange(range);
|
||||||
|
}
|
||||||
|
for (PermissionAttachmentInfo perms : target.getEffectivePermissions()) {
|
||||||
|
if (perms.getPermission().startsWith(Settings.PERMPREFIX + "island.range.")) {
|
||||||
|
if (perms.getPermission().contains(Settings.PERMPREFIX + "island.range.*")) {
|
||||||
|
// Ignore
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
String[] spl = perms.getPermission().split(Settings.PERMPREFIX + "island.range.");
|
||||||
|
if (spl.length > 1) {
|
||||||
|
if (!NumberUtils.isDigits(spl[1])) {
|
||||||
|
plugin.getLogger().severe("Player " + user.getName() + " has permission: " + perms.getPermission() + " <-- the last part MUST be a number! Ignoring...");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
hasARangePerm = true;
|
||||||
|
range = Math.max(range, Integer.valueOf(spl[1]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Only set the island range if the player has a perm to override the default
|
||||||
|
if (hasARangePerm) {
|
||||||
|
// Do some sanity checking
|
||||||
|
if (range % 2 != 0) {
|
||||||
|
range--;
|
||||||
|
}
|
||||||
|
// Get island range
|
||||||
|
|
||||||
|
// Range can go up or down
|
||||||
|
if (range != islandByOwner.getProtectionRange()) {
|
||||||
|
user.sendMessage("commands.admin.setrange.range-updated", "[number]", String.valueOf(range));
|
||||||
|
target.sendMessage("commands.admin.setrange.range-updated", "[number]", String.valueOf(range));
|
||||||
|
plugin.getLogger().info(
|
||||||
|
"Makeleader: Island protection range changed from " + islandByOwner.getProtectionRange() + " to "
|
||||||
|
+ range + " for " + user.getName() + " due to permission.");
|
||||||
|
}
|
||||||
|
islandByOwner.setProtectionRange(range);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getIslands().save(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<String>> tabComplete(final User user, final String alias, final LinkedList<String> args) {
|
||||||
|
List<String> options = new ArrayList<>();
|
||||||
|
String lastArg = (!args.isEmpty() ? args.getLast() : "");
|
||||||
|
for (UUID member : plugin.getIslands().getMembers(user.getUniqueId())) {
|
||||||
|
options.add(plugin.getServer().getOfflinePlayer(member).getName());
|
||||||
|
}
|
||||||
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,70 +0,0 @@
|
|||||||
package us.tastybento.bskyblock.commands.island.teams;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
|
||||||
import us.tastybento.bskyblock.api.commands.User;
|
|
||||||
import us.tastybento.bskyblock.api.events.IslandBaseEvent;
|
|
||||||
import us.tastybento.bskyblock.api.events.team.TeamEvent;
|
|
||||||
import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason;
|
|
||||||
import us.tastybento.bskyblock.config.Settings;
|
|
||||||
import us.tastybento.bskyblock.util.Util;
|
|
||||||
|
|
||||||
public class IslandTeamUninviteCommand extends AbstractIslandTeamCommand {
|
|
||||||
|
|
||||||
public IslandTeamUninviteCommand(CompositeCommand islandCommand) {
|
|
||||||
super(islandCommand, "uninvite");
|
|
||||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
|
||||||
this.setOnlyPlayer(true);
|
|
||||||
this.setUsage("island.team.uninvite.usage");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean execute(User user, List<String> args) {
|
|
||||||
UUID playerUUID = user.getUniqueId();
|
|
||||||
// Can only use if you have an invite out there
|
|
||||||
if(!inviteList.inverse().containsKey(playerUUID)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire event so add-ons can run commands, etc.
|
|
||||||
IslandBaseEvent event = TeamEvent.builder()
|
|
||||||
.island(getIslands()
|
|
||||||
.getIsland(playerUUID))
|
|
||||||
.reason(TeamReason.UNINVITE)
|
|
||||||
.involvedPlayer(playerUUID)
|
|
||||||
.build();
|
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (event.isCancelled()) return true;
|
|
||||||
// Perform uninvite
|
|
||||||
if (inviteList.inverse().containsKey(playerUUID)) {
|
|
||||||
User invitee = User.getInstance(inviteList.inverse().get(playerUUID));
|
|
||||||
if (invitee != null) {
|
|
||||||
inviteList.inverse().remove(playerUUID);
|
|
||||||
invitee.sendMessage("invite.nameHasUninvitedYou", "[name]", user.getName());
|
|
||||||
user.sendMessage("general.success");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
user.sendMessage("help.island.invite");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: FIX THIS
|
|
||||||
@Override
|
|
||||||
public Optional<List<String>> tabComplete(final User user, final String alias, final LinkedList<String> args) {
|
|
||||||
List<String> options = new ArrayList<>();
|
|
||||||
String lastArg = (!args.isEmpty() ? args.getLast() : "");
|
|
||||||
if (inviteList.inverse().containsKey(user.getUniqueId())) {
|
|
||||||
User invitee = User.getInstance(inviteList.inverse().get(user.getUniqueId()));
|
|
||||||
if (invitee != null) {
|
|
||||||
options.add(invitee.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user