mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-18 07:07:40 +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
@ -23,7 +23,6 @@ general:
|
||||
not-leader: "You are not the leader of your island!"
|
||||
offline-player: "That player is offline or doesn't exist."
|
||||
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"
|
||||
|
||||
commands:
|
||||
@ -34,34 +33,83 @@ commands:
|
||||
end: "&7================================="
|
||||
about: "display this help page"
|
||||
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:
|
||||
about: "display info about %bsb_plugin_name%"
|
||||
go: "teleport you to your island"
|
||||
go-homes: "teleport you to the specified home"
|
||||
spawn: "teleport you to the spawn"
|
||||
create: "create an island"
|
||||
info: "display info about your island"
|
||||
reset: "restart your island and remove the old one"
|
||||
sethome: "set your teleport point for /island"
|
||||
name: "set a name for your island"
|
||||
resetname: "reset your island name"
|
||||
about:
|
||||
usage: "display info about %bsb_plugin_name%"
|
||||
go:
|
||||
usage: "teleport you to your island"
|
||||
spawn:
|
||||
usage: "teleport you to the spawn"
|
||||
create:
|
||||
usage: "create an island"
|
||||
unable-create-island: "Your island could not be generated, please contact an administrator."
|
||||
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:
|
||||
info: "display detailed info about your team"
|
||||
invite: "invite a player to join your island"
|
||||
uninvite: "cancel the pending invite to join your island"
|
||||
leave: "leave your island"
|
||||
kick: "remove a member from your island"
|
||||
accept: "accept an invitation"
|
||||
reject: "reject an invitation"
|
||||
promote: "promote a player on your island to another rank"
|
||||
expel: "expel a visitor from your island"
|
||||
ban: "ban a player from your island"
|
||||
unban: "unban a player from your island"
|
||||
banlist: "list banned players"
|
||||
lock: "lock/unlock your island so visitors cannot enter it"
|
||||
settings: "display island settings"
|
||||
language: "select language"
|
||||
usage: "manage your team"
|
||||
info:
|
||||
usage: "display detailed info about your team"
|
||||
invite:
|
||||
usage: "invite a player to join your island"
|
||||
errors:
|
||||
island-is-full: "Your island is full, you can't invite anyone else."
|
||||
none-invited-you: "No one invited you :c."
|
||||
you-already-are-in-team: "You are already on a team!"
|
||||
invalid-invite: "That invite is no longer valid, sorry."
|
||||
you-can-invite: "You can invite [number] more players."
|
||||
accept:
|
||||
usage: "accept an invitation"
|
||||
you-joined-island: "You have joined an island! Use /[label] team info to see the other members."
|
||||
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:
|
||||
flags:
|
||||
|
@ -9,7 +9,7 @@ import java.util.Optional;
|
||||
* @author ben
|
||||
*
|
||||
*/
|
||||
public interface BSBCommand {
|
||||
public interface BSCommand {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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 args
|
||||
* @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
|
||||
*
|
||||
*/
|
||||
public abstract class CompositeCommand extends Command implements PluginIdentifiableCommand, BSBCommand {
|
||||
public abstract class CompositeCommand extends Command implements PluginIdentifiableCommand, BSCommand {
|
||||
|
||||
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.IslandSethomeCommand;
|
||||
import us.tastybento.bskyblock.commands.island.IslandResetnameCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandInviteAcceptCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandInviteRejectCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandLeaveCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamInviteAcceptCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamInviteRejectCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamLeaveCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamInviteCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamPromoteCommand;
|
||||
import us.tastybento.bskyblock.commands.island.teams.IslandTeamUninviteCommand;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
|
||||
public class IslandCommand extends CompositeCommand {
|
||||
@ -45,13 +44,6 @@ public class IslandCommand extends CompositeCommand {
|
||||
new IslandResetnameCommand(this);
|
||||
// Team commands
|
||||
new IslandTeamCommand(this);
|
||||
new IslandTeamInviteCommand(this);
|
||||
new IslandInviteAcceptCommand(this);
|
||||
new IslandInviteRejectCommand(this);
|
||||
new IslandLeaveCommand(this);
|
||||
new IslandTeamPromoteCommand(this);
|
||||
new IslandTeamUninviteCommand(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@ public class IslandAboutCommand extends CompositeCommand {
|
||||
*/
|
||||
public IslandAboutCommand(CompositeCommand islandCommand) {
|
||||
super(islandCommand, "about", "ab");
|
||||
this.setUsage("island.about.usage");
|
||||
this.setUsage("commands.island.about.usage");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,7 +23,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
||||
super(islandCommand, "create", "auto");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.create");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setUsage("island.create.usage");
|
||||
this.setUsage("commands.island.create.usage");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -56,7 +56,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
||||
.build();
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Could not create island for player.");
|
||||
user.sendMessage("general.errors.general");
|
||||
user.sendMessage("commands.island.create.unable-create-island");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class IslandGoCommand extends CompositeCommand {
|
||||
super(islandCommand, "go", "home", "h");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.home");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setUsage("island.go.usage");
|
||||
this.setUsage("commands.island.go.usage");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -17,11 +17,11 @@ public class IslandResetCommand extends CompositeCommand {
|
||||
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
public IslandResetCommand(CompositeCommand command) {
|
||||
super(command, "reset", "restart");
|
||||
public IslandResetCommand(CompositeCommand islandCommand) {
|
||||
super(islandCommand, "reset", "restart");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.create");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setUsage("island.reset.usage");
|
||||
this.setUsage("commands.island.reset.usage");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -31,10 +31,11 @@ public class IslandResetCommand extends CompositeCommand {
|
||||
return true;
|
||||
}
|
||||
if (!getIslands().isOwner(user.getUniqueId())) {
|
||||
user.sendMessage("general.errors.not-leader");
|
||||
return false;
|
||||
}
|
||||
if (plugin.getPlayers().inTeam(user.getUniqueId())) {
|
||||
user.sendMessage("island.reset.MustRemovePlayers");
|
||||
user.sendMessage("commands.island.reset.must-remove-members");
|
||||
return true;
|
||||
}
|
||||
Player player = user.getPlayer();
|
||||
@ -58,7 +59,7 @@ public class IslandResetCommand extends CompositeCommand {
|
||||
.build();
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe("Could not create island for player.");
|
||||
user.sendMessage("general.errors.general");
|
||||
user.sendMessage("commands.island.create.unable-create-island");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
|
@ -18,11 +18,11 @@ import us.tastybento.bskyblock.config.Settings;
|
||||
*/
|
||||
public class IslandResetnameCommand extends CompositeCommand {
|
||||
|
||||
public IslandResetnameCommand(CompositeCommand command) {
|
||||
super(command, "resetname");
|
||||
public IslandResetnameCommand(CompositeCommand islandCommand) {
|
||||
super(islandCommand, "resetname");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.name");
|
||||
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();
|
||||
|
||||
if (!getIslands().hasIsland(playerUUID)) {
|
||||
user.sendMessage(ChatColor.RED + "general.errors.no-island");
|
||||
user.sendMessage("general.errors.no-island");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!getIslands().isOwner(playerUUID)) {
|
||||
user.sendMessage(ChatColor.RED + "general.errors.not-leader");
|
||||
user.sendMessage("general.errors.not-leader");
|
||||
return true;
|
||||
}
|
||||
// Resets the island name
|
||||
|
@ -10,11 +10,11 @@ import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
public class IslandSethomeCommand extends CompositeCommand {
|
||||
|
||||
public IslandSethomeCommand(CompositeCommand command) {
|
||||
super(command, "sethome");
|
||||
public IslandSethomeCommand(CompositeCommand islandCommand) {
|
||||
super(islandCommand, "sethome");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.sethome");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setUsage("island.sethome.usage");
|
||||
this.setUsage("commands.island.sethome.usage");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -26,13 +26,13 @@ public class IslandSethomeCommand extends CompositeCommand {
|
||||
return true;
|
||||
}
|
||||
if (!plugin.getIslands().playerIsOnIsland(user.getPlayer())) {
|
||||
user.sendMessage("sethome.error.NotOnIsland");
|
||||
user.sendMessage("commands.island.sethome.must-be-on-your-island");
|
||||
return true;
|
||||
}
|
||||
if (args.isEmpty()) {
|
||||
// island sethome
|
||||
plugin.getPlayers().setHomeLocation(playerUUID, user.getLocation());
|
||||
user.sendMessage("sethome.homeSet");
|
||||
user.sendMessage("commands.island.sethome.home-set");
|
||||
} else {
|
||||
// Dynamic home sizes with permissions
|
||||
int maxHomes = Util.getPermValue(user.getPlayer(), Settings.PERMPREFIX + "island.maxhomes", Settings.maxHomes);
|
||||
@ -42,13 +42,13 @@ public class IslandSethomeCommand extends CompositeCommand {
|
||||
try {
|
||||
number = Integer.valueOf(args.get(0));
|
||||
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 {
|
||||
plugin.getPlayers().setHomeLocation(playerUUID, user.getLocation(), number);
|
||||
user.sendMessage("sethome.homeSet");
|
||||
user.sendMessage("commands.island.sethome.home-set");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
user.sendMessage("sethome.error.NumHomes", "[max]", String.valueOf(maxHomes));
|
||||
user.sendMessage("commands.island.sethome.num-homes", "[max]", String.valueOf(maxHomes));
|
||||
}
|
||||
} else {
|
||||
user.sendMessage("general.errors.no-permission");
|
||||
|
@ -20,11 +20,11 @@ import us.tastybento.bskyblock.config.Settings;
|
||||
*/
|
||||
public class IslandSetnameCommand extends CompositeCommand {
|
||||
|
||||
public IslandSetnameCommand(CompositeCommand command) {
|
||||
super(command, "setname");
|
||||
public IslandSetnameCommand(CompositeCommand islandCommand) {
|
||||
super(islandCommand, "setname");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.name");
|
||||
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
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
|
||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||
@ -23,8 +22,15 @@ public class IslandTeamCommand extends AbstractIslandTeamCommand {
|
||||
super(islandCommand, "team");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||
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
|
||||
@ -67,20 +73,9 @@ public class IslandTeamCommand extends AbstractIslandTeamCommand {
|
||||
}
|
||||
|
||||
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 {
|
||||
user.sendMessage(ChatColor.RED + "invite.error.YourIslandIsFull");
|
||||
}
|
||||
}
|
||||
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));
|
||||
user.sendMessage("commands.island.team.invite.errors.island-is-full");
|
||||
}
|
||||
}
|
||||
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.database.objects.Island;
|
||||
|
||||
public class IslandInviteAcceptCommand extends AbstractIslandTeamCommand {
|
||||
public class IslandTeamInviteAcceptCommand extends AbstractIslandTeamCommand {
|
||||
|
||||
public IslandInviteAcceptCommand(CompositeCommand islandCommand) {
|
||||
super(islandCommand, "accept");
|
||||
public IslandTeamInviteAcceptCommand(IslandTeamInviteCommand islandTeamInviteCommand) {
|
||||
super(islandTeamInviteCommand, "accept");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setUsage("island.invite.accept.usage");
|
||||
this.setUsage("commands.island.team.invite.accept.usage");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -34,18 +34,18 @@ public class IslandInviteAcceptCommand extends AbstractIslandTeamCommand {
|
||||
return true;
|
||||
// Check if player has been invited
|
||||
if (!inviteList.containsKey(playerUUID)) {
|
||||
user.sendMessage("invite.error.NoOneInvitedYou");
|
||||
user.sendMessage("commands.island.team.invite.errors.none-invited-you");
|
||||
return true;
|
||||
}
|
||||
// Check if player is already in a team
|
||||
if (getPlayers().inTeam(playerUUID)) {
|
||||
user.sendMessage("invite.error.YouAreAlreadyOnATeam");
|
||||
user.sendMessage("commands.island.team.invite.errors.you-already-are-in-team");
|
||||
return true;
|
||||
}
|
||||
// Get the team leader
|
||||
UUID prospectiveTeamLeaderUUID = inviteList.get(playerUUID);
|
||||
if (!getIslands().hasIsland(prospectiveTeamLeaderUUID)) {
|
||||
user.sendMessage("invite.error.InvalidInvite");
|
||||
user.sendMessage("commands.island.team.invite.errors.invalid-invite");
|
||||
inviteList.remove(playerUUID);
|
||||
return true;
|
||||
}
|
||||
@ -92,10 +92,10 @@ public class IslandInviteAcceptCommand extends AbstractIslandTeamCommand {
|
||||
// Put player back into normal mode
|
||||
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));
|
||||
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);
|
||||
if (DEBUG)
|
@ -21,11 +21,17 @@ import us.tastybento.bskyblock.util.Util;
|
||||
|
||||
public class IslandTeamInviteCommand extends AbstractIslandTeamCommand {
|
||||
|
||||
public IslandTeamInviteCommand(CompositeCommand islandTeamCommand) {
|
||||
public IslandTeamInviteCommand(IslandTeamCommand islandTeamCommand) {
|
||||
super(islandTeamCommand, "invite");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||
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
|
||||
@ -37,7 +43,7 @@ public class IslandTeamInviteCommand extends AbstractIslandTeamCommand {
|
||||
if (getPlayers().inTeam(playerUUID)) {
|
||||
user.sendMessage("general.errors.not-leader");
|
||||
}
|
||||
user.sendMessage("invite.error.YouMustHaveIslandToInvite");
|
||||
user.sendMessage("general.errors.no-island");
|
||||
}
|
||||
if (args.isEmpty() || args.size() > 1) {
|
||||
// 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.config.Settings;
|
||||
|
||||
public class IslandInviteRejectCommand extends AbstractIslandTeamCommand {
|
||||
public class IslandTeamInviteRejectCommand extends AbstractIslandTeamCommand {
|
||||
|
||||
public IslandInviteRejectCommand(IslandCommand islandCommand) {
|
||||
super(islandCommand, "reject");
|
||||
public IslandTeamInviteRejectCommand(IslandTeamInviteCommand islandTeamInviteCommand) {
|
||||
super(islandTeamInviteCommand, "reject");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setUsage("island.invite.reject.usage");
|
||||
this.setUsage("commands.island.team.invite.reject.usage");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -36,17 +36,13 @@ public class IslandInviteRejectCommand extends AbstractIslandTeamCommand {
|
||||
|
||||
// Remove this player from the global invite list
|
||||
inviteList.remove(user.getUniqueId());
|
||||
user.sendMessage("reject.youHaveRejectedInvitation");
|
||||
// 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.sendMessage("commands.island.team.invite.reject.you-rejected-invite");
|
||||
|
||||
User inviter = User.getInstance(inviteList.get(playerUUID));
|
||||
inviter.sendMessage("commands.island.team.invite.reject.name-rejected-your-invite", "[name]", user.getName());
|
||||
} else {
|
||||
// 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;
|
||||
}
|
@ -2,17 +2,16 @@ package us.tastybento.bskyblock.commands.island.teams;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||
import us.tastybento.bskyblock.api.commands.User;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
|
||||
public class IslandLeaveCommand extends AbstractIslandTeamCommand {
|
||||
public class IslandTeamLeaveCommand extends AbstractIslandTeamCommand {
|
||||
|
||||
public IslandLeaveCommand(CompositeCommand islandCommand) {
|
||||
super(islandCommand, "leave");
|
||||
public IslandTeamLeaveCommand(IslandTeamCommand islandTeamCommand) {
|
||||
super(islandTeamCommand, "leave");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import us.tastybento.bskyblock.api.commands.User;
|
||||
import us.tastybento.bskyblock.config.Settings;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
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 IslandTeamPromoteCommand(CompositeCommand islandCommand) {
|
||||
super(islandCommand, "promote", "makeleader");
|
||||
public IslandTeamPromoteCommand(IslandTeamCommand islandTeamCommand) {
|
||||
super(islandTeamCommand, "promote");
|
||||
this.setPermission(Settings.PERMPREFIX + "island.team");
|
||||
this.setOnlyPlayer(true);
|
||||
this.setUsage("island.team.promote.usage");
|
||||
@ -29,117 +18,12 @@ public class IslandTeamPromoteCommand extends AbstractIslandTeamCommand {
|
||||
|
||||
@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("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;
|
||||
}
|
||||
|
||||
@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));
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -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