mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 19:55:17 +01:00
Redid API for multiworld.
Now AcidIsland uses its own command instead of island. Added a world element to commands so they can operate only in specific worlds.
This commit is contained in:
parent
6d17d48bde
commit
007a9af025
@ -98,10 +98,8 @@ public class BSkyBlock extends JavaPlugin {
|
|||||||
// Load Notifier
|
// Load Notifier
|
||||||
notifier = new Notifier();
|
notifier = new Notifier();
|
||||||
|
|
||||||
// Set up commands
|
// Set up command manager
|
||||||
commandsManager = new CommandsManager();
|
commandsManager = new CommandsManager();
|
||||||
new IslandCommand();
|
|
||||||
new AdminCommand();
|
|
||||||
|
|
||||||
// These items have to be loaded when the server has done 1 tick.
|
// These items have to be loaded when the server has done 1 tick.
|
||||||
// Note Worlds are not loaded this early, so any Locations or World reference will be null
|
// Note Worlds are not loaded this early, so any Locations or World reference will be null
|
||||||
@ -110,6 +108,11 @@ public class BSkyBlock extends JavaPlugin {
|
|||||||
// Create the world if it does not exist
|
// Create the world if it does not exist
|
||||||
islandWorldManager = new IslandWorldManager(instance);
|
islandWorldManager = new IslandWorldManager(instance);
|
||||||
|
|
||||||
|
// Set up commands
|
||||||
|
new IslandCommand();
|
||||||
|
new AdminCommand();
|
||||||
|
|
||||||
|
|
||||||
getServer().getScheduler().runTask(instance, () -> {
|
getServer().getScheduler().runTask(instance, () -> {
|
||||||
|
|
||||||
// Load Flags
|
// Load Flags
|
||||||
|
@ -477,6 +477,7 @@ public class Settings implements ISettings<Settings>, WorldSettings {
|
|||||||
/**
|
/**
|
||||||
* @return the maxHomes
|
* @return the maxHomes
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getMaxHomes() {
|
public int getMaxHomes() {
|
||||||
return maxHomes;
|
return maxHomes;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public interface BSBCommand {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Anything that needs to be set up for this command.
|
* Anything that needs to be set up for this command.
|
||||||
* This is where you register subcommands and other settings
|
* Do not register subcommands in this section. Put them after the super in the constructor
|
||||||
*/
|
*/
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
|
@ -73,6 +73,12 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
|||||||
* The prefix to be used in this command
|
* The prefix to be used in this command
|
||||||
*/
|
*/
|
||||||
private String permissionPrefix = "";
|
private String permissionPrefix = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The world that this command operates in. This is an overworld and will cover any associated nether or end
|
||||||
|
* If the world value does not exist, then the command is general across worlds
|
||||||
|
*/
|
||||||
|
private World world;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used only for testing....
|
* Used only for testing....
|
||||||
@ -142,8 +148,10 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
|||||||
if (!getSubCommand("help").isPresent() && !label.equals("help")) {
|
if (!getSubCommand("help").isPresent() && !label.equals("help")) {
|
||||||
new DefaultHelpCommand(this);
|
new DefaultHelpCommand(this);
|
||||||
}
|
}
|
||||||
// Set permission prefix
|
// Inherit permission prefix
|
||||||
this.permissionPrefix = parent.getPermissionPrefix();
|
this.permissionPrefix = parent.getPermissionPrefix();
|
||||||
|
// Inherit world
|
||||||
|
this.world = parent.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -482,5 +490,19 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
|
|||||||
public void setPermissionPrefix(String permissionPrefix) {
|
public void setPermissionPrefix(String permissionPrefix) {
|
||||||
this.permissionPrefix = permissionPrefix + ".";
|
this.permissionPrefix = permissionPrefix + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the world
|
||||||
|
*/
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param world the world to set
|
||||||
|
*/
|
||||||
|
public void setWorld(World world) {
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -115,5 +115,10 @@ public interface WorldSettings {
|
|||||||
* @return the max team size for this world
|
* @return the max team size for this world
|
||||||
*/
|
*/
|
||||||
public int getMaxTeamSize();
|
public int getMaxTeamSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the max homes
|
||||||
|
*/
|
||||||
|
public int getMaxHomes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,7 @@ public class AdminCommand extends CompositeCommand {
|
|||||||
|
|
||||||
public AdminCommand() {
|
public AdminCommand() {
|
||||||
super(Constants.ADMINCOMMAND, "bsb");
|
super(Constants.ADMINCOMMAND, "bsb");
|
||||||
}
|
setWorld(getPlugin().getIWM().getIslandWorld());
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setup() {
|
|
||||||
setPermissionPrefix("bskyblock");
|
|
||||||
setPermission("admin.*");
|
|
||||||
setOnlyPlayer(false);
|
|
||||||
setParameters("commands.admin.help.parameters");
|
|
||||||
setDescription("commands.admin.help.description");
|
|
||||||
new AdminVersionCommand(this);
|
new AdminVersionCommand(this);
|
||||||
new AdminReloadCommand(this);
|
new AdminReloadCommand(this);
|
||||||
new AdminTeleportCommand(this, "tp");
|
new AdminTeleportCommand(this, "tp");
|
||||||
@ -47,6 +39,15 @@ public class AdminCommand extends CompositeCommand {
|
|||||||
new AdminSchemCommand(this);
|
new AdminSchemCommand(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
setPermissionPrefix("bskyblock");
|
||||||
|
setPermission("admin.*");
|
||||||
|
setOnlyPlayer(false);
|
||||||
|
setParameters("commands.admin.help.parameters");
|
||||||
|
setDescription("commands.admin.help.description");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
if (!args.isEmpty()) {
|
if (!args.isEmpty()) {
|
||||||
|
@ -5,8 +5,6 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.Constants;
|
import us.tastybento.bskyblock.Constants;
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
@ -23,25 +21,13 @@ import us.tastybento.bskyblock.commands.island.IslandSetnameCommand;
|
|||||||
import us.tastybento.bskyblock.commands.island.IslandSettingsCommand;
|
import us.tastybento.bskyblock.commands.island.IslandSettingsCommand;
|
||||||
import us.tastybento.bskyblock.commands.island.IslandUnbanCommand;
|
import us.tastybento.bskyblock.commands.island.IslandUnbanCommand;
|
||||||
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.util.Util;
|
import us.tastybento.bskyblock.util.Util;
|
||||||
|
|
||||||
public class IslandCommand extends CompositeCommand {
|
public class IslandCommand extends CompositeCommand {
|
||||||
|
|
||||||
public IslandCommand() {
|
public IslandCommand() {
|
||||||
super(Constants.ISLANDCOMMAND, "is");
|
super(Constants.ISLANDCOMMAND, "is");
|
||||||
}
|
setWorld(getPlugin().getIWM().getIslandWorld());
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see us.tastybento.bskyblock.api.commands.CompositeCommand#setup()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setup() {
|
|
||||||
setDescription("commands.island.help.description");
|
|
||||||
setOnlyPlayer(true);
|
|
||||||
// Permission
|
|
||||||
setPermissionPrefix("bskyblock");
|
|
||||||
setPermission("island");
|
|
||||||
// Set up subcommands
|
// Set up subcommands
|
||||||
new IslandAboutCommand(this);
|
new IslandAboutCommand(this);
|
||||||
new IslandCreateCommand(this);
|
new IslandCreateCommand(this);
|
||||||
@ -57,7 +43,18 @@ public class IslandCommand extends CompositeCommand {
|
|||||||
new IslandBanlistCommand(this);
|
new IslandBanlistCommand(this);
|
||||||
// Team commands
|
// Team commands
|
||||||
new IslandTeamCommand(this);
|
new IslandTeamCommand(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see us.tastybento.bskyblock.api.commands.CompositeCommand#setup()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
setDescription("commands.island.help.description");
|
||||||
|
setOnlyPlayer(true);
|
||||||
|
// Permission
|
||||||
|
setPermissionPrefix("bskyblock");
|
||||||
|
setPermission("island");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -67,30 +64,15 @@ public class IslandCommand extends CompositeCommand {
|
|||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
// Check if not in world. If multiple worlds, then tell user to pick one
|
|
||||||
if (!getIWM().inWorld(user.getLocation()) && getIWM().getOverWorlds().size() > 1) {
|
|
||||||
user.sendMessage("commands.island.help.pick-world", "[worlds]", getIWM().getFriendlyNames());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// If in world, go
|
// If in world, go
|
||||||
if (getPlugin().getIslands().hasIsland(user.getWorld(), user.getUniqueId())) {
|
if (getPlugin().getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
return getSubCommand("go").map(goCmd -> goCmd.execute(user, new ArrayList<>())).orElse(false);
|
return getSubCommand("go").map(goCmd -> goCmd.execute(user, new ArrayList<>())).orElse(false);
|
||||||
}
|
}
|
||||||
// No islands currently
|
// No islands currently
|
||||||
return getSubCommand("create").map(createCmd -> createCmd.execute(user, new ArrayList<>())).orElse(false);
|
return getSubCommand("create").map(createCmd -> createCmd.execute(user, new ArrayList<>())).orElse(false);
|
||||||
} else if (args.size() == 1) {
|
}
|
||||||
// Argument should be a world
|
|
||||||
if (getPlugin().getIWM().isOverWorld(args.get(0))) {
|
|
||||||
World world = getPlugin().getIWM().getWorld(args.get(0));
|
|
||||||
if (getPlugin().getIslands().hasIsland(world, user.getUniqueId())) {
|
|
||||||
return getSubCommand("go").map(goCmd -> goCmd.execute(user, args)).orElse(false);
|
|
||||||
}
|
|
||||||
// No islands currently
|
|
||||||
return getSubCommand("create").map(createCmd -> createCmd.execute(user, args)).orElse(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
user.sendMessage("general.errors.unknown-command", "[label]", Constants.ISLANDCOMMAND);
|
user.sendMessage("general.errors.unknown-command", "[label]", Constants.ISLANDCOMMAND);
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -102,5 +84,5 @@ public class IslandCommand extends CompositeCommand {
|
|||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import java.util.UUID;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
@ -43,9 +42,6 @@ public class AdminGetRankCommand extends CompositeCommand {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
// TODO: fix world
|
|
||||||
World world = getPlugin().getIWM().getIslandWorld();
|
|
||||||
|
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
// Show help
|
// Show help
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
@ -57,14 +53,14 @@ public class AdminGetRankCommand extends CompositeCommand {
|
|||||||
user.sendMessage("general.errors.unknown-player");
|
user.sendMessage("general.errors.unknown-player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getPlugin().getIslands().hasIsland(world, targetUUID)) {
|
if (!getPlugin().getIslands().hasIsland(getWorld(), targetUUID)) {
|
||||||
user.sendMessage("general.errors.player-has-no-island");
|
user.sendMessage("general.errors.player-has-no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Get rank
|
// Get rank
|
||||||
RanksManager rm = getPlugin().getRanksManager();
|
RanksManager rm = getPlugin().getRanksManager();
|
||||||
User target = User.getInstance(targetUUID);
|
User target = User.getInstance(targetUUID);
|
||||||
Island island = getPlugin().getIslands().getIsland(world, targetUUID);
|
Island island = getPlugin().getIslands().getIsland(getWorld(), targetUUID);
|
||||||
int currentRank = island.getRank(target);
|
int currentRank = island.getRank(target);
|
||||||
user.sendMessage("commands.admin.getrank.rank-is", "[rank]", user.getTranslation(rm.getRank(currentRank)));
|
user.sendMessage("commands.admin.getrank.rank-is", "[rank]", user.getTranslation(rm.getRank(currentRank)));
|
||||||
return true;
|
return true;
|
||||||
|
@ -3,8 +3,6 @@ package us.tastybento.bskyblock.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
|
|
||||||
@ -24,9 +22,6 @@ public class AdminInfoCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
// TODO: fix world
|
|
||||||
World world = getPlugin().getIWM().getIslandWorld();
|
|
||||||
|
|
||||||
if (args.size() > 1 || (args.isEmpty() && !user.isPlayer())) {
|
if (args.size() > 1 || (args.isEmpty() && !user.isPlayer())) {
|
||||||
// Show help
|
// Show help
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
@ -46,12 +41,12 @@ public class AdminInfoCommand extends CompositeCommand {
|
|||||||
user.sendMessage("general.errors.unknown-player");
|
user.sendMessage("general.errors.unknown-player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().hasIsland(world, targetUUID)) {
|
if (!getIslands().hasIsland(getWorld(), targetUUID)) {
|
||||||
user.sendMessage("general.errors.player-has-no-island");
|
user.sendMessage("general.errors.player-has-no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Show info for this player
|
// Show info for this player
|
||||||
getIslands().getIsland(world, targetUUID).showInfo(getPlugin(), user);
|
getIslands().getIsland(getWorld(), targetUUID).showInfo(getPlugin(), user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
import us.tastybento.bskyblock.database.objects.Island;
|
import us.tastybento.bskyblock.database.objects.Island;
|
||||||
@ -27,9 +25,6 @@ public class AdminRegisterCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
// TODO: fix world
|
|
||||||
World world = getPlugin().getIWM().getIslandWorld();
|
|
||||||
|
|
||||||
// If args are not right, show help
|
// If args are not right, show help
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
@ -41,11 +36,11 @@ public class AdminRegisterCommand extends CompositeCommand {
|
|||||||
user.sendMessage("general.errors.unknown-player");
|
user.sendMessage("general.errors.unknown-player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getIslands().hasIsland(world, targetUUID)) {
|
if (getIslands().hasIsland(getWorld(), targetUUID)) {
|
||||||
user.sendMessage("general.errors.player-has-island");
|
user.sendMessage("general.errors.player-has-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getIslands().inTeam(world, targetUUID)) {
|
if (getIslands().inTeam(getWorld(), targetUUID)) {
|
||||||
user.sendMessage("commands.admin.register.cannot-register-team-player");
|
user.sendMessage("commands.admin.register.cannot-register-team-player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ import java.util.Optional;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
import us.tastybento.bskyblock.database.objects.Island;
|
import us.tastybento.bskyblock.database.objects.Island;
|
||||||
@ -41,9 +39,6 @@ public class AdminSetRankCommand extends CompositeCommand {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
// TODO: fix world
|
|
||||||
World world = getPlugin().getIWM().getIslandWorld();
|
|
||||||
|
|
||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
// Show help
|
// Show help
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
@ -55,7 +50,7 @@ public class AdminSetRankCommand extends CompositeCommand {
|
|||||||
user.sendMessage("general.errors.unknown-player");
|
user.sendMessage("general.errors.unknown-player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getPlugin().getIslands().hasIsland(world, targetUUID)) {
|
if (!getPlugin().getIslands().hasIsland(getWorld(), targetUUID)) {
|
||||||
user.sendMessage("general.errors.player-has-no-island");
|
user.sendMessage("general.errors.player-has-no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -70,7 +65,7 @@ public class AdminSetRankCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
User target = User.getInstance(targetUUID);
|
User target = User.getInstance(targetUUID);
|
||||||
|
|
||||||
Island island = getPlugin().getIslands().getIsland(world, targetUUID);
|
Island island = getPlugin().getIslands().getIsland(getWorld(), targetUUID);
|
||||||
int currentRank = island.getRank(target);
|
int currentRank = island.getRank(target);
|
||||||
island.setRank(target, rankValue);
|
island.setRank(target, rankValue);
|
||||||
user.sendMessage("commands.admin.setrank.rank-set", "[from]", user.getTranslation(rm.getRank(currentRank)), "[to]", user.getTranslation(rm.getRank(rankValue)));
|
user.sendMessage("commands.admin.setrank.rank-set", "[from]", user.getTranslation(rm.getRank(currentRank)), "[to]", user.getTranslation(rm.getRank(rankValue)));
|
||||||
|
@ -6,7 +6,6 @@ import java.util.Optional;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
@ -30,9 +29,6 @@ public class AdminTeleportCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
// TODO: fix world
|
|
||||||
World world = getPlugin().getIWM().getIslandWorld();
|
|
||||||
|
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
this.showHelp(this, user);
|
this.showHelp(this, user);
|
||||||
return true;
|
return true;
|
||||||
@ -44,12 +40,12 @@ public class AdminTeleportCommand extends CompositeCommand {
|
|||||||
user.sendMessage("general.errors.unknown-player");
|
user.sendMessage("general.errors.unknown-player");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (getIslands().hasIsland(world, targetUUID) || getIslands().inTeam(world, targetUUID)) {
|
if (getIslands().hasIsland(getWorld(), targetUUID) || getIslands().inTeam(getWorld(), targetUUID)) {
|
||||||
Location warpSpot = getIslands().getIslandLocation(world, targetUUID).toVector().toLocation(getPlugin().getIWM().getIslandWorld());
|
Location warpSpot = getIslands().getIslandLocation(getWorld(), targetUUID).toVector().toLocation(getPlugin().getIWM().getIslandWorld());
|
||||||
if (getLabel().equals("tpnether")) {
|
if (getLabel().equals("tpnether")) {
|
||||||
warpSpot = getIslands().getIslandLocation(world, targetUUID).toVector().toLocation(getPlugin().getIWM().getNetherWorld());
|
warpSpot = getIslands().getIslandLocation(getWorld(), targetUUID).toVector().toLocation(getPlugin().getIWM().getNetherWorld());
|
||||||
} else if (getLabel().equals("tpend")) {
|
} else if (getLabel().equals("tpend")) {
|
||||||
warpSpot = getIslands().getIslandLocation(world, targetUUID).toVector().toLocation(getPlugin().getIWM().getEndWorld());
|
warpSpot = getIslands().getIslandLocation(getWorld(), targetUUID).toVector().toLocation(getPlugin().getIWM().getEndWorld());
|
||||||
}
|
}
|
||||||
// Other wise, go to a safe spot
|
// Other wise, go to a safe spot
|
||||||
String failureMessage = user.getTranslation("commands.admin.tp.manual", "[location]", warpSpot.getBlockX() + " " + warpSpot.getBlockY() + " "
|
String failureMessage = user.getTranslation("commands.admin.tp.manual", "[location]", warpSpot.getBlockX() + " " + warpSpot.getBlockY() + " "
|
||||||
|
@ -3,8 +3,6 @@ package us.tastybento.bskyblock.commands.admin;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
import us.tastybento.bskyblock.util.Util;
|
import us.tastybento.bskyblock.util.Util;
|
||||||
@ -24,9 +22,6 @@ public class AdminUnregisterCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
// TODO: fix world
|
|
||||||
World world = getPlugin().getIWM().getIslandWorld();
|
|
||||||
|
|
||||||
// If args are not right, show help
|
// If args are not right, show help
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
showHelp(this, user);
|
showHelp(this, user);
|
||||||
@ -38,17 +33,17 @@ public class AdminUnregisterCommand extends CompositeCommand {
|
|||||||
user.sendMessage("general.errors.unknown-player");
|
user.sendMessage("general.errors.unknown-player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().hasIsland(world, targetUUID)) {
|
if (!getIslands().hasIsland(getWorld(), targetUUID)) {
|
||||||
user.sendMessage("general.errors.player-has-no-island");
|
user.sendMessage("general.errors.player-has-no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getIslands().inTeam(world, targetUUID)) {
|
if (getIslands().inTeam(getWorld(), targetUUID)) {
|
||||||
user.sendMessage("commands.admin.unregister.cannot-unregister-team-player");
|
user.sendMessage("commands.admin.unregister.cannot-unregister-team-player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Unregister island
|
// Unregister island
|
||||||
user.sendMessage("commands.admin.unregister.unregistered-island", "[xyz]", Util.xyz(getIslands().getIsland(world, targetUUID).getCenter().toVector()));
|
user.sendMessage("commands.admin.unregister.unregistered-island", "[xyz]", Util.xyz(getIslands().getIsland(getWorld(), targetUUID).getCenter().toVector()));
|
||||||
getIslands().removePlayer(world, targetUUID);
|
getIslands().removePlayer(getWorld(), targetUUID);
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("general.success");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class CustomIslandMultiHomeHelp extends CompositeCommand {
|
|||||||
private void showPrettyHelp(User user, String usage, String params, String desc) {
|
private void showPrettyHelp(User user, String usage, String params, String desc) {
|
||||||
// Player. Check perms
|
// Player. Check perms
|
||||||
if (user.hasPermission(getPermission())) {
|
if (user.hasPermission(getPermission())) {
|
||||||
int maxHomes = Util.getPermValue(user.getPlayer(), "island.maxhomes", getSettings().getMaxHomes());
|
int maxHomes = Util.getPermValue(user.getPlayer(), getPermissionPrefix() + "island.maxhomes", getIWM().getMaxHomes(getWorld()));
|
||||||
if (maxHomes > 1) {
|
if (maxHomes > 1) {
|
||||||
params = getParameters().isEmpty() ? "" : user.getTranslation(getParameters());
|
params = getParameters().isEmpty() ? "" : user.getTranslation(getParameters());
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,11 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island
|
||||||
if (!getIslands().hasIsland(user.getWorld(), playerUUID)) {
|
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().isOwner(user.getWorld(), playerUUID)) {
|
if (!getIslands().isOwner(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -56,11 +56,11 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
user.sendMessage("commands.island.ban.cannot-ban-yourself");
|
user.sendMessage("commands.island.ban.cannot-ban-yourself");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getIslands().getMembers(user.getWorld(), user.getUniqueId()).contains(targetUUID)) {
|
if (getIslands().getMembers(getWorld(), user.getUniqueId()).contains(targetUUID)) {
|
||||||
user.sendMessage("commands.island.ban.cannot-ban-member");
|
user.sendMessage("commands.island.ban.cannot-ban-member");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getIslands().getIsland(user.getWorld(), playerUUID).isBanned(targetUUID)) {
|
if (getIslands().getIsland(getWorld(), playerUUID).isBanned(targetUUID)) {
|
||||||
user.sendMessage("commands.island.ban.player-already-banned");
|
user.sendMessage("commands.island.ban.player-already-banned");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -75,13 +75,13 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean ban(User user, User targetUser) {
|
private boolean ban(User user, User targetUser) {
|
||||||
Island island = getIslands().getIsland(user.getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
if (island.addToBanList(targetUser.getUniqueId())) {
|
if (island.addToBanList(targetUser.getUniqueId())) {
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("general.success");
|
||||||
targetUser.sendMessage("commands.island.ban.owner-banned-you", "[owner]", user.getName());
|
targetUser.sendMessage("commands.island.ban.owner-banned-you", "[owner]", user.getName());
|
||||||
// If the player is online, has an island and on the banned island, move them home immediately
|
// If the player is online, has an island and on the banned island, move them home immediately
|
||||||
if (targetUser.isOnline() && getIslands().hasIsland(user.getWorld(), targetUser.getUniqueId()) && island.onIsland(targetUser.getLocation())) {
|
if (targetUser.isOnline() && getIslands().hasIsland(getWorld(), targetUser.getUniqueId()) && island.onIsland(targetUser.getLocation())) {
|
||||||
getIslands().homeTeleport(user.getWorld(), targetUser.getPlayer());
|
getIslands().homeTeleport(getWorld(), targetUser.getPlayer());
|
||||||
island.getWorld().playSound(targetUser.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
island.getWorld().playSound(targetUser.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -96,7 +96,7 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
// Don't show every player on the server. Require at least the first letter
|
// Don't show every player on the server. Require at least the first letter
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
Island island = getIslands().getIsland(user.getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
List<String> options = Bukkit.getOnlinePlayers().stream()
|
List<String> options = Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(p -> !p.getUniqueId().equals(user.getUniqueId()))
|
.filter(p -> !p.getUniqueId().equals(user.getUniqueId()))
|
||||||
.filter(p -> !island.isBanned(p.getUniqueId()))
|
.filter(p -> !island.isBanned(p.getUniqueId()))
|
||||||
|
@ -29,11 +29,11 @@ public class IslandBanlistCommand extends CompositeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island
|
||||||
if (!getIslands().hasIsland(user.getWorld(), user.getUniqueId())) {
|
if (!getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Island island = getIslands().getIsland(user.getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
// Show all the players banned on the island
|
// Show all the players banned on the island
|
||||||
if (island.getBanned().isEmpty()) {
|
if (island.getBanned().isEmpty()) {
|
||||||
user.sendMessage("commands.island.banlist.noone");
|
user.sendMessage("commands.island.banlist.noone");
|
||||||
|
@ -5,14 +5,10 @@ package us.tastybento.bskyblock.commands.island;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.events.island.IslandEvent.Reason;
|
import us.tastybento.bskyblock.api.events.island.IslandEvent.Reason;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
import us.tastybento.bskyblock.commands.IslandCommand;
|
|
||||||
import us.tastybento.bskyblock.managers.island.NewIsland;
|
import us.tastybento.bskyblock.managers.island.NewIsland;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,8 +18,12 @@ import us.tastybento.bskyblock.managers.island.NewIsland;
|
|||||||
*/
|
*/
|
||||||
public class IslandCreateCommand extends CompositeCommand {
|
public class IslandCreateCommand extends CompositeCommand {
|
||||||
|
|
||||||
public IslandCreateCommand(IslandCommand islandCommand) {
|
/**
|
||||||
super(islandCommand, "create", "auto");
|
* Command to create an island
|
||||||
|
* @param islandCommand
|
||||||
|
*/
|
||||||
|
public IslandCreateCommand(CompositeCommand islandCommand) {
|
||||||
|
super(islandCommand, "create");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -38,35 +38,11 @@ public class IslandCreateCommand extends CompositeCommand {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
World world = null;
|
if (getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
if (args.size() == 1 && getPlugin().getIWM().isOverWorld(args.get(0))) {
|
|
||||||
world = getPlugin().getIWM().getWorld(args.get(0));
|
|
||||||
}
|
|
||||||
if (world == null) {
|
|
||||||
// See which worlds are available
|
|
||||||
Set<String> worldNames = getPlugin().getIWM().getFreeOverWorldNames(user);
|
|
||||||
if (!worldNames.isEmpty()) {
|
|
||||||
// Make a list of worlds
|
|
||||||
StringBuilder worlds = new StringBuilder();
|
|
||||||
// Filter out ones that player already has
|
|
||||||
worldNames.forEach(w -> {
|
|
||||||
worlds.append(w);
|
|
||||||
worlds.append(", ");
|
|
||||||
});
|
|
||||||
if (worlds.length() > 2) {
|
|
||||||
worlds.setLength(worlds.length() - 2);
|
|
||||||
}
|
|
||||||
user.sendMessage("commands.island.create.pick-world", "[worlds]", worlds.toString());
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
world = getPlugin().getIWM().getIslandWorld();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (getIslands().hasIsland(world, user.getUniqueId())) {
|
|
||||||
user.sendMessage("general.errors.already-have-island");
|
user.sendMessage("general.errors.already-have-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getIslands().inTeam(world, user.getUniqueId())) {
|
if (getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.already-have-island");
|
user.sendMessage("general.errors.already-have-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -74,7 +50,7 @@ public class IslandCreateCommand extends CompositeCommand {
|
|||||||
try {
|
try {
|
||||||
NewIsland.builder()
|
NewIsland.builder()
|
||||||
.player(user)
|
.player(user)
|
||||||
.world(world)
|
.world(getWorld())
|
||||||
.reason(Reason.CREATE)
|
.reason(Reason.CREATE)
|
||||||
.build();
|
.build();
|
||||||
return true;
|
return true;
|
||||||
|
@ -7,11 +7,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
import us.tastybento.bskyblock.commands.IslandCommand;
|
|
||||||
import us.tastybento.bskyblock.util.Util;
|
import us.tastybento.bskyblock.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,8 +17,9 @@ import us.tastybento.bskyblock.util.Util;
|
|||||||
*/
|
*/
|
||||||
public class IslandGoCommand extends CompositeCommand {
|
public class IslandGoCommand extends CompositeCommand {
|
||||||
|
|
||||||
public IslandGoCommand(IslandCommand islandCommand) {
|
public IslandGoCommand(CompositeCommand islandCommand) {
|
||||||
super(islandCommand, "go", "home", "h");
|
super(islandCommand, "go", "home", "h");
|
||||||
|
new CustomIslandMultiHomeHelp(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -30,8 +29,7 @@ public class IslandGoCommand extends CompositeCommand {
|
|||||||
public void setup() {
|
public void setup() {
|
||||||
setPermission("island.home");
|
setPermission("island.home");
|
||||||
setOnlyPlayer(true);
|
setOnlyPlayer(true);
|
||||||
setDescription("commands.island.go.description");
|
setDescription("commands.island.go.description");
|
||||||
new CustomIslandMultiHomeHelp(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
@ -39,24 +37,8 @@ public class IslandGoCommand extends CompositeCommand {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
World world = user.getWorld();
|
|
||||||
if (!args.isEmpty() && !NumberUtils.isDigits(args.get(0))) {
|
if (!getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
// World?
|
|
||||||
if (getPlugin().getIWM().isOverWorld(args.get(0))) {
|
|
||||||
world = getPlugin().getIWM().getWorld(args.get(0));
|
|
||||||
} else {
|
|
||||||
// Make a list of worlds
|
|
||||||
StringBuilder worlds = new StringBuilder();
|
|
||||||
getPlugin().getIWM().getOverWorldNames().forEach(w -> {
|
|
||||||
worlds.append(w);
|
|
||||||
worlds.append(", ");
|
|
||||||
});
|
|
||||||
worlds.setLength(worlds.length() - 2);
|
|
||||||
user.sendMessage("commands.island.create.pick-world", "[worlds]", worlds.toString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!getIslands().hasIsland(world, user.getUniqueId())) {
|
|
||||||
user.sendMessage(ChatColor.RED + "general.errors.no-island");
|
user.sendMessage(ChatColor.RED + "general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -64,11 +46,11 @@ public class IslandGoCommand extends CompositeCommand {
|
|||||||
int homeValue = Integer.valueOf(args.get(0));
|
int homeValue = Integer.valueOf(args.get(0));
|
||||||
int maxHomes = Util.getPermValue(user.getPlayer(), "island.maxhomes", getSettings().getMaxHomes());
|
int maxHomes = Util.getPermValue(user.getPlayer(), "island.maxhomes", getSettings().getMaxHomes());
|
||||||
if (homeValue > 1 && homeValue <= maxHomes) {
|
if (homeValue > 1 && homeValue <= maxHomes) {
|
||||||
getIslands().homeTeleport(world, user.getPlayer(), homeValue);
|
getIslands().homeTeleport(getWorld(), user.getPlayer(), homeValue);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getIslands().homeTeleport(world, user.getPlayer());
|
getIslands().homeTeleport(getWorld(), user.getPlayer());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
import us.tastybento.bskyblock.commands.IslandCommand;
|
|
||||||
import us.tastybento.bskyblock.panels.LanguagePanel;
|
import us.tastybento.bskyblock.panels.LanguagePanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,7 +11,7 @@ import us.tastybento.bskyblock.panels.LanguagePanel;
|
|||||||
*/
|
*/
|
||||||
public class IslandLanguageCommand extends CompositeCommand {
|
public class IslandLanguageCommand extends CompositeCommand {
|
||||||
|
|
||||||
public IslandLanguageCommand(IslandCommand islandCommand) {
|
public IslandLanguageCommand(CompositeCommand islandCommand) {
|
||||||
super(islandCommand, "language", "lang");
|
super(islandCommand, "language", "lang");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,15 +43,15 @@ public class IslandResetCommand extends CompositeCommand {
|
|||||||
user.sendMessage("general.errors.you-must-wait", SECONDS_PLACEHOLDER, String.valueOf(onRestartWaitTime(user)));
|
user.sendMessage("general.errors.you-must-wait", SECONDS_PLACEHOLDER, String.valueOf(onRestartWaitTime(user)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().hasIsland(user.getWorld(), user.getUniqueId())) {
|
if (!getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().isOwner(user.getWorld(), user.getUniqueId())) {
|
if (!getIslands().isOwner(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getIslands().inTeam(user.getWorld(), user.getUniqueId())) {
|
if (getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("commands.island.reset.must-remove-members");
|
user.sendMessage("commands.island.reset.must-remove-members");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -105,9 +105,9 @@ public class IslandResetCommand extends CompositeCommand {
|
|||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
player.setGameMode(GameMode.SPECTATOR);
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
// Get the player's old island
|
// Get the player's old island
|
||||||
Island oldIsland = getIslands().getIsland(user.getWorld(), player.getUniqueId());
|
Island oldIsland = getIslands().getIsland(getWorld(), player.getUniqueId());
|
||||||
// Remove them from this island (it still exists and will be deleted later)
|
// Remove them from this island (it still exists and will be deleted later)
|
||||||
getIslands().removePlayer(user.getWorld(), player.getUniqueId());
|
getIslands().removePlayer(getWorld(), player.getUniqueId());
|
||||||
// Create new island and then delete the old one
|
// Create new island and then delete the old one
|
||||||
try {
|
try {
|
||||||
NewIsland.builder()
|
NewIsland.builder()
|
||||||
|
@ -34,17 +34,17 @@ public class IslandResetnameCommand extends CompositeCommand {
|
|||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
|
|
||||||
if (!getIslands().hasIsland(user.getWorld(), playerUUID)) {
|
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getIslands().isOwner(user.getWorld(), playerUUID)) {
|
if (!getIslands().isOwner(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Resets the island name
|
// Resets the island name
|
||||||
getIslands().getIsland(user.getWorld(), playerUUID).setName(null);
|
getIslands().getIsland(getWorld(), playerUUID).setName(null);
|
||||||
|
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("general.success");
|
||||||
return true;
|
return true;
|
||||||
|
@ -11,6 +11,7 @@ public class IslandSethomeCommand extends CompositeCommand {
|
|||||||
|
|
||||||
public IslandSethomeCommand(CompositeCommand islandCommand) {
|
public IslandSethomeCommand(CompositeCommand islandCommand) {
|
||||||
super(islandCommand, "sethome");
|
super(islandCommand, "sethome");
|
||||||
|
new CustomIslandMultiHomeHelp(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -18,18 +19,17 @@ public class IslandSethomeCommand extends CompositeCommand {
|
|||||||
setPermission("island.sethome");
|
setPermission("island.sethome");
|
||||||
setOnlyPlayer(true);
|
setOnlyPlayer(true);
|
||||||
setDescription("commands.island.sethome.description");
|
setDescription("commands.island.sethome.description");
|
||||||
new CustomIslandMultiHomeHelp(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Check island
|
// Check island
|
||||||
if (getPlugin().getIslands().getIsland(user.getWorld(), user.getUniqueId()) == null) {
|
if (getPlugin().getIslands().getIsland(getWorld(), user.getUniqueId()) == null) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getPlugin().getIslands().userIsOnIsland(user.getWorld(), user)) {
|
if (!getPlugin().getIslands().userIsOnIsland(getWorld(), user)) {
|
||||||
user.sendMessage("commands.island.sethome.must-be-on-your-island");
|
user.sendMessage("commands.island.sethome.must-be-on-your-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ public class IslandSetnameCommand extends CompositeCommand {
|
|||||||
Player player = user.getPlayer();
|
Player player = user.getPlayer();
|
||||||
UUID playerUUID = player.getUniqueId();
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
|
||||||
if (!getIslands().hasIsland(user.getWorld(), playerUUID)) {
|
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getIslands().isOwner(user.getWorld(), playerUUID)) {
|
if (!getIslands().isOwner(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -69,9 +69,9 @@ public class IslandSetnameCommand extends CompositeCommand {
|
|||||||
|
|
||||||
// Set the name
|
// Set the name
|
||||||
if (!player.hasPermission("island.name.format")) {
|
if (!player.hasPermission("island.name.format")) {
|
||||||
getIslands().getIsland(user.getWorld(), player.getUniqueId()).setName(ChatColor.translateAlternateColorCodes('&', name));
|
getIslands().getIsland(getWorld(), player.getUniqueId()).setName(ChatColor.translateAlternateColorCodes('&', name));
|
||||||
} else {
|
} else {
|
||||||
getIslands().getIsland(user.getWorld(), playerUUID).setName(name);
|
getIslands().getIsland(getWorld(), playerUUID).setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("general.success");
|
||||||
|
@ -4,7 +4,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
import us.tastybento.bskyblock.api.commands.CompositeCommand;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
import us.tastybento.bskyblock.commands.IslandCommand;
|
|
||||||
import us.tastybento.bskyblock.panels.SettingsPanel;
|
import us.tastybento.bskyblock.panels.SettingsPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,7 +11,7 @@ import us.tastybento.bskyblock.panels.SettingsPanel;
|
|||||||
*/
|
*/
|
||||||
public class IslandSettingsCommand extends CompositeCommand {
|
public class IslandSettingsCommand extends CompositeCommand {
|
||||||
|
|
||||||
public IslandSettingsCommand(IslandCommand islandCommand) {
|
public IslandSettingsCommand(CompositeCommand islandCommand) {
|
||||||
super(islandCommand, "settings", "flags");
|
super(islandCommand, "settings", "flags");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,11 +33,11 @@ public class IslandUnbanCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island
|
||||||
if (!getIslands().hasIsland(user.getWorld(), playerUUID)) {
|
if (!getIslands().hasIsland(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().isOwner(user.getWorld(), playerUUID)) {
|
if (!getIslands().isOwner(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ public class IslandUnbanCommand extends CompositeCommand {
|
|||||||
user.sendMessage("commands.island.unban.cannot-unban-yourself");
|
user.sendMessage("commands.island.unban.cannot-unban-yourself");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().getIsland(user.getWorld(), playerUUID).isBanned(targetUUID)) {
|
if (!getIslands().getIsland(getWorld(), playerUUID).isBanned(targetUUID)) {
|
||||||
user.sendMessage("commands.island.unban.player-not-banned");
|
user.sendMessage("commands.island.unban.player-not-banned");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ public class IslandUnbanCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean unban(User user, User targetUser) {
|
private boolean unban(User user, User targetUser) {
|
||||||
if (getIslands().getIsland(user.getWorld(), user.getUniqueId()).removeFromBanList(targetUser.getUniqueId())) {
|
if (getIslands().getIsland(getWorld(), user.getUniqueId()).removeFromBanList(targetUser.getUniqueId())) {
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("general.success");
|
||||||
targetUser.sendMessage("commands.island.unban.you-are-unbanned", "[owner]", user.getName());
|
targetUser.sendMessage("commands.island.unban.you-are-unbanned", "[owner]", user.getName());
|
||||||
return true;
|
return true;
|
||||||
@ -73,7 +73,7 @@ public class IslandUnbanCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
Island island = getIslands().getIsland(user.getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
List<String> options = island.getBanned().stream().map(getPlayers()::getName).collect(Collectors.toList());
|
List<String> options = island.getBanned().stream().map(getPlayers()::getName).collect(Collectors.toList());
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
@ -15,6 +15,14 @@ public class IslandTeamCommand extends CompositeCommand {
|
|||||||
|
|
||||||
public IslandTeamCommand(CompositeCommand parent) {
|
public IslandTeamCommand(CompositeCommand parent) {
|
||||||
super(parent, "team");
|
super(parent, "team");
|
||||||
|
// Register commands
|
||||||
|
inviteCommand = new IslandTeamInviteCommand(this);
|
||||||
|
new IslandTeamLeaveCommand(this);
|
||||||
|
new IslandTeamSetownerCommand(this);
|
||||||
|
new IslandTeamKickCommand(this);
|
||||||
|
new IslandTeamInviteAcceptCommand(this);
|
||||||
|
new IslandTeamInviteRejectCommand(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -22,19 +30,12 @@ public class IslandTeamCommand extends CompositeCommand {
|
|||||||
setPermission("island.team");
|
setPermission("island.team");
|
||||||
setOnlyPlayer(true);
|
setOnlyPlayer(true);
|
||||||
setDescription("commands.island.team.description");
|
setDescription("commands.island.team.description");
|
||||||
|
|
||||||
inviteCommand = new IslandTeamInviteCommand(this);
|
|
||||||
new IslandTeamLeaveCommand(this);
|
|
||||||
new IslandTeamSetownerCommand(this);
|
|
||||||
new IslandTeamKickCommand(this);
|
|
||||||
new IslandTeamInviteAcceptCommand(this);
|
|
||||||
new IslandTeamInviteRejectCommand(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island
|
||||||
UUID teamLeaderUUID = getTeamLeader(user.getWorld(), user);
|
UUID teamLeaderUUID = getTeamLeader(getWorld(), user);
|
||||||
if (teamLeaderUUID == null) {
|
if (teamLeaderUUID == null) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
@ -46,7 +47,7 @@ public class IslandTeamCommand extends CompositeCommand {
|
|||||||
// Cancelled
|
// Cancelled
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Set<UUID> teamMembers = getMembers(user.getWorld(), user);
|
Set<UUID> teamMembers = getMembers(getWorld(), user);
|
||||||
if (teamLeaderUUID.equals(playerUUID)) {
|
if (teamLeaderUUID.equals(playerUUID)) {
|
||||||
int maxSize = inviteCommand.getMaxTeamSize(user);
|
int maxSize = inviteCommand.getMaxTeamSize(user);
|
||||||
if (teamMembers.size() < maxSize) {
|
if (teamMembers.size() < maxSize) {
|
||||||
@ -56,7 +57,7 @@ public class IslandTeamCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Show members of island
|
// Show members of island
|
||||||
getIslands().getIsland(user.getWorld(), playerUUID).showMembers(getPlugin(), user);
|
getIslands().getIsland(getWorld(), playerUUID).showMembers(getPlugin(), user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ public class IslandTeamCommand extends CompositeCommand {
|
|||||||
private boolean fireEvent(User user) {
|
private boolean fireEvent(User user) {
|
||||||
IslandBaseEvent event = TeamEvent.builder()
|
IslandBaseEvent event = TeamEvent.builder()
|
||||||
.island(getIslands()
|
.island(getIslands()
|
||||||
.getIsland(user.getWorld(), user.getUniqueId()))
|
.getIsland(getWorld(), user.getUniqueId()))
|
||||||
.reason(TeamEvent.Reason.INFO)
|
.reason(TeamEvent.Reason.INFO)
|
||||||
.involvedPlayer(user.getUniqueId())
|
.involvedPlayer(user.getUniqueId())
|
||||||
.build();
|
.build();
|
||||||
|
@ -39,13 +39,13 @@ public class IslandTeamInviteAcceptCommand extends CompositeCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Check if player is already in a team
|
// Check if player is already in a team
|
||||||
if (getIslands().inTeam(user.getWorld(), playerUUID)) {
|
if (getIslands().inTeam(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("commands.island.team.invite.errors.you-already-are-in-team");
|
user.sendMessage("commands.island.team.invite.errors.you-already-are-in-team");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Get the team leader
|
// Get the team leader
|
||||||
UUID prospectiveTeamLeaderUUID = itc.getInviteCommand().getInviteList().get(playerUUID);
|
UUID prospectiveTeamLeaderUUID = itc.getInviteCommand().getInviteList().get(playerUUID);
|
||||||
if (!getIslands().hasIsland(user.getWorld(), prospectiveTeamLeaderUUID)) {
|
if (!getIslands().hasIsland(getWorld(), prospectiveTeamLeaderUUID)) {
|
||||||
user.sendMessage("commands.island.team.invite.errors.invalid-invite");
|
user.sendMessage("commands.island.team.invite.errors.invalid-invite");
|
||||||
itc.getInviteCommand().getInviteList().remove(playerUUID);
|
itc.getInviteCommand().getInviteList().remove(playerUUID);
|
||||||
return false;
|
return false;
|
||||||
@ -53,7 +53,7 @@ public class IslandTeamInviteAcceptCommand extends CompositeCommand {
|
|||||||
// Fire event so add-ons can run commands, etc.
|
// Fire event so add-ons can run commands, etc.
|
||||||
IslandBaseEvent event = TeamEvent.builder()
|
IslandBaseEvent event = TeamEvent.builder()
|
||||||
.island(getIslands()
|
.island(getIslands()
|
||||||
.getIsland(user.getWorld(), prospectiveTeamLeaderUUID))
|
.getIsland(getWorld(), prospectiveTeamLeaderUUID))
|
||||||
.reason(TeamEvent.Reason.JOIN)
|
.reason(TeamEvent.Reason.JOIN)
|
||||||
.involvedPlayer(playerUUID)
|
.involvedPlayer(playerUUID)
|
||||||
.build();
|
.build();
|
||||||
@ -66,17 +66,17 @@ public class IslandTeamInviteAcceptCommand extends CompositeCommand {
|
|||||||
// Put player into Spectator mode
|
// Put player into Spectator mode
|
||||||
user.setGameMode(GameMode.SPECTATOR);
|
user.setGameMode(GameMode.SPECTATOR);
|
||||||
// Get the player's island - may be null if the player has no island
|
// Get the player's island - may be null if the player has no island
|
||||||
Island island = getIslands().getIsland(user.getWorld(), playerUUID);
|
Island island = getIslands().getIsland(getWorld(), playerUUID);
|
||||||
// Get the team's island
|
// Get the team's island
|
||||||
Island teamIsland = getIslands().getIsland(user.getWorld(), prospectiveTeamLeaderUUID);
|
Island teamIsland = getIslands().getIsland(getWorld(), prospectiveTeamLeaderUUID);
|
||||||
// Clear the player's inventory
|
// Clear the player's inventory
|
||||||
user.getInventory().clear();
|
user.getInventory().clear();
|
||||||
// Move player to team's island
|
// Move player to team's island
|
||||||
User prospectiveTeamLeader = User.getInstance(prospectiveTeamLeaderUUID);
|
User prospectiveTeamLeader = User.getInstance(prospectiveTeamLeaderUUID);
|
||||||
Location newHome = getIslands().getSafeHomeLocation(user.getWorld(), prospectiveTeamLeader, 1);
|
Location newHome = getIslands().getSafeHomeLocation(getWorld(), prospectiveTeamLeader, 1);
|
||||||
user.teleport(newHome);
|
user.teleport(newHome);
|
||||||
// Remove player as owner of the old island
|
// Remove player as owner of the old island
|
||||||
getIslands().removePlayer(user.getWorld(), playerUUID);
|
getIslands().removePlayer(getWorld(), playerUUID);
|
||||||
// Add the player as a team member of the new island
|
// Add the player as a team member of the new island
|
||||||
getIslands().setJoinTeam(teamIsland, playerUUID);
|
getIslands().setJoinTeam(teamIsland, playerUUID);
|
||||||
// Set the player's home
|
// Set the player's home
|
||||||
|
@ -38,11 +38,11 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
|||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Player issuing the command must have an island
|
// Player issuing the command must have an island
|
||||||
if (!getIslands().hasIsland(user.getWorld(), user.getUniqueId())) {
|
if (!getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-island");
|
user.sendMessage("general.errors.no-island");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
UUID teamLeaderUUID = getTeamLeader(user.getWorld(), user);
|
UUID teamLeaderUUID = getTeamLeader(getWorld(), user);
|
||||||
if (!(teamLeaderUUID.equals(playerUUID))) {
|
if (!(teamLeaderUUID.equals(playerUUID))) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return false;
|
return false;
|
||||||
@ -76,13 +76,13 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
// Check if this player can be invited to this island, or
|
// Check if this player can be invited to this island, or
|
||||||
// whether they are still on cooldown
|
// whether they are still on cooldown
|
||||||
long time = getPlayers().getInviteCoolDownTime(invitedPlayerUUID, getIslands().getIslandLocation(user.getWorld(), playerUUID));
|
long time = getPlayers().getInviteCoolDownTime(invitedPlayerUUID, getIslands().getIslandLocation(getWorld(), playerUUID));
|
||||||
if (time > 0 && !user.isOp()) {
|
if (time > 0 && !user.isOp()) {
|
||||||
user.sendMessage("commands.island.team.invite.cooldown", "[time]", String.valueOf(time));
|
user.sendMessage("commands.island.team.invite.cooldown", "[time]", String.valueOf(time));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Player cannot invite someone already on a team
|
// Player cannot invite someone already on a team
|
||||||
if (getIslands().inTeam(user.getWorld(), invitedPlayerUUID)) {
|
if (getIslands().inTeam(getWorld(), invitedPlayerUUID)) {
|
||||||
user.sendMessage("commands.island.team.invite.already-on-team");
|
user.sendMessage("commands.island.team.invite.already-on-team");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean invite(User user, User invitedPlayer) {
|
private boolean invite(User user, User invitedPlayer) {
|
||||||
Set<UUID> teamMembers = getMembers(user.getWorld(), user);
|
Set<UUID> teamMembers = getMembers(getWorld(), user);
|
||||||
// Check if player has space on their team
|
// Check if player has space on their team
|
||||||
int maxSize = getMaxTeamSize(user);
|
int maxSize = getMaxTeamSize(user);
|
||||||
if (teamMembers.size() < maxSize) {
|
if (teamMembers.size() < maxSize) {
|
||||||
@ -103,7 +103,7 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
// Fire event so add-ons can run commands, etc.
|
// Fire event so add-ons can run commands, etc.
|
||||||
IslandBaseEvent event = TeamEvent.builder()
|
IslandBaseEvent event = TeamEvent.builder()
|
||||||
.island(getIslands().getIsland(user.getWorld(), user.getUniqueId()))
|
.island(getIslands().getIsland(getWorld(), user.getUniqueId()))
|
||||||
.reason(TeamEvent.Reason.INVITE)
|
.reason(TeamEvent.Reason.INVITE)
|
||||||
.involvedPlayer(invitedPlayer.getUniqueId())
|
.involvedPlayer(invitedPlayer.getUniqueId())
|
||||||
.build();
|
.build();
|
||||||
@ -118,7 +118,7 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
|||||||
// Send message to online player
|
// Send message to online player
|
||||||
invitedPlayer.sendMessage("commands.island.team.invite.name-has-invited-you", NAME_PLACEHOLDER, user.getName());
|
invitedPlayer.sendMessage("commands.island.team.invite.name-has-invited-you", NAME_PLACEHOLDER, user.getName());
|
||||||
invitedPlayer.sendMessage("commands.island.team.invite.to-accept-or-reject", "[label]", getLabel());
|
invitedPlayer.sendMessage("commands.island.team.invite.to-accept-or-reject", "[label]", getLabel());
|
||||||
if (getIslands().hasIsland(user.getWorld(), invitedPlayer.getUniqueId())) {
|
if (getIslands().hasIsland(getWorld(), invitedPlayer.getUniqueId())) {
|
||||||
invitedPlayer.sendMessage("commands.island.team.invite.you-will-lose-your-island");
|
invitedPlayer.sendMessage("commands.island.team.invite.you-will-lose-your-island");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -154,7 +154,7 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
|||||||
* @return max team size
|
* @return max team size
|
||||||
*/
|
*/
|
||||||
public int getMaxTeamSize(User user) {
|
public int getMaxTeamSize(User user) {
|
||||||
return Util.getPermValue(user.getPlayer(), getPermissionPrefix() + "team.maxsize.", getIWM().getMaxTeamSize(user.getWorld()));
|
return Util.getPermValue(user.getPlayer(), getPermissionPrefix() + "team.maxsize.", getIWM().getMaxTeamSize(getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class IslandTeamInviteRejectCommand extends CompositeCommand {
|
|||||||
// Fire event so add-ons can run commands, etc.
|
// Fire event so add-ons can run commands, etc.
|
||||||
IslandBaseEvent event = TeamEvent.builder()
|
IslandBaseEvent event = TeamEvent.builder()
|
||||||
.island(getIslands()
|
.island(getIslands()
|
||||||
.getIsland(user.getWorld(), itc.getInviteCommand().getInviteList().get(playerUUID)))
|
.getIsland(getWorld(), itc.getInviteCommand().getInviteList().get(playerUUID)))
|
||||||
.reason(TeamEvent.Reason.REJECT)
|
.reason(TeamEvent.Reason.REJECT)
|
||||||
.involvedPlayer(playerUUID)
|
.involvedPlayer(playerUUID)
|
||||||
.build();
|
.build();
|
||||||
|
@ -29,11 +29,11 @@ public class IslandTeamKickCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
if (!getIslands().inTeam(user.getWorld(), user.getUniqueId())) {
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-team");
|
user.sendMessage("general.errors.no-team");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getTeamLeader(user.getWorld(), user).equals(user.getUniqueId())) {
|
if (!getTeamLeader(getWorld(), user).equals(user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -52,14 +52,14 @@ public class IslandTeamKickCommand extends CompositeCommand {
|
|||||||
user.sendMessage("commands.island.kick.cannot-kick");
|
user.sendMessage("commands.island.kick.cannot-kick");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().getMembers(user.getWorld(), user.getUniqueId()).contains(targetUUID)) {
|
if (!getIslands().getMembers(getWorld(), user.getUniqueId()).contains(targetUUID)) {
|
||||||
user.sendMessage("general.errors.not-in-team");
|
user.sendMessage("general.errors.not-in-team");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getSettings().isKickConfirmation() || kickSet.contains(targetUUID)) {
|
if (!getSettings().isKickConfirmation() || kickSet.contains(targetUUID)) {
|
||||||
kickSet.remove(targetUUID);
|
kickSet.remove(targetUUID);
|
||||||
User.getInstance(targetUUID).sendMessage("commands.island.team.kick.leader-kicked");
|
User.getInstance(targetUUID).sendMessage("commands.island.team.kick.leader-kicked");
|
||||||
getIslands().removePlayer(user.getWorld(), targetUUID);
|
getIslands().removePlayer(getWorld(), targetUUID);
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("general.success");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,21 +28,21 @@ public class IslandTeamLeaveCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
if (!getIslands().inTeam(user.getWorld(), user.getUniqueId())) {
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-team");
|
user.sendMessage("general.errors.no-team");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getIslands().hasIsland(user.getWorld(), user.getUniqueId())) {
|
if (getIslands().hasIsland(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("commands.island.team.leave.cannot-leave");
|
user.sendMessage("commands.island.team.leave.cannot-leave");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getSettings().isLeaveConfirmation() || leaveSet.contains(user.getUniqueId())) {
|
if (!getSettings().isLeaveConfirmation() || leaveSet.contains(user.getUniqueId())) {
|
||||||
leaveSet.remove(user.getUniqueId());
|
leaveSet.remove(user.getUniqueId());
|
||||||
UUID leaderUUID = getIslands().getTeamLeader(user.getWorld(), user.getUniqueId());
|
UUID leaderUUID = getIslands().getTeamLeader(getWorld(), user.getUniqueId());
|
||||||
if (leaderUUID != null) {
|
if (leaderUUID != null) {
|
||||||
User.getInstance(leaderUUID).sendMessage("commands.island.team.leave.left-your-island", "[player]", user.getName());
|
User.getInstance(leaderUUID).sendMessage("commands.island.team.leave.left-your-island", "[player]", user.getName());
|
||||||
}
|
}
|
||||||
getIslands().removePlayer(user.getWorld(), user.getUniqueId());
|
getIslands().removePlayer(getWorld(), user.getUniqueId());
|
||||||
user.sendMessage("general.success");
|
user.sendMessage("general.success");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,11 +26,11 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
if (!getIslands().inTeam(user.getWorld(), user.getUniqueId())) {
|
if (!getIslands().inTeam(getWorld(), user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.no-team");
|
user.sendMessage("general.errors.no-team");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!getTeamLeader(user.getWorld(), user).equals(user.getUniqueId())) {
|
if (!getTeamLeader(getWorld(), user).equals(user.getUniqueId())) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
|||||||
user.sendMessage("general.errors.unknown-player");
|
user.sendMessage("general.errors.unknown-player");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!inTeam(user.getWorld(), target) || !getTeamLeader(user.getWorld(), user).equals(getTeamLeader(user.getWorld(), target))) {
|
if (!inTeam(getWorld(), target) || !getTeamLeader(getWorld(), user).equals(getTeamLeader(getWorld(), target))) {
|
||||||
user.sendMessage("general.errors.not-in-team");
|
user.sendMessage("general.errors.not-in-team");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -54,11 +54,11 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean change(User user, User target) {
|
private boolean change(User user, User target) {
|
||||||
int currentRank = getIslands().getIsland(user.getWorld(), user.getUniqueId()).getRank(target);
|
int currentRank = getIslands().getIsland(getWorld(), user.getUniqueId()).getRank(target);
|
||||||
if (this.getLabel().equals("promote")) {
|
if (this.getLabel().equals("promote")) {
|
||||||
int nextRank = getPlugin().getRanksManager().getRankUpValue(currentRank);
|
int nextRank = getPlugin().getRanksManager().getRankUpValue(currentRank);
|
||||||
if (nextRank > currentRank) {
|
if (nextRank > currentRank) {
|
||||||
getIslands().getIsland(user.getWorld(), user.getUniqueId()).setRank(target, nextRank);
|
getIslands().getIsland(getWorld(), user.getUniqueId()).setRank(target, nextRank);
|
||||||
String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(nextRank));
|
String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(nextRank));
|
||||||
user.sendMessage("commands.island.team.promote.success", "[name]", target.getName(), "[rank]", rankName);
|
user.sendMessage("commands.island.team.promote.success", "[name]", target.getName(), "[rank]", rankName);
|
||||||
return true;
|
return true;
|
||||||
@ -70,7 +70,7 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
|||||||
// Demote
|
// Demote
|
||||||
int prevRank = getPlugin().getRanksManager().getRankDownValue(currentRank);
|
int prevRank = getPlugin().getRanksManager().getRankDownValue(currentRank);
|
||||||
if (prevRank < currentRank) {
|
if (prevRank < currentRank) {
|
||||||
getIslands().getIsland(user.getWorld(), user.getUniqueId()).setRank(target, prevRank);
|
getIslands().getIsland(getWorld(), user.getUniqueId()).setRank(target, prevRank);
|
||||||
String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(prevRank));
|
String rankName = user.getTranslation(getPlugin().getRanksManager().getRank(prevRank));
|
||||||
user.sendMessage("commands.island.team.demote.success", "[name]", target.getName(), "[rank]", rankName);
|
user.sendMessage("commands.island.team.demote.success", "[name]", target.getName(), "[rank]", rankName);
|
||||||
return true;
|
return true;
|
||||||
|
@ -29,8 +29,8 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
|||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
UUID playerUUID = user.getUniqueId();
|
UUID playerUUID = user.getUniqueId();
|
||||||
// Can use if in a team
|
// Can use if in a team
|
||||||
boolean inTeam = getPlugin().getIslands().inTeam(user.getWorld(), playerUUID);
|
boolean inTeam = getPlugin().getIslands().inTeam(getWorld(), playerUUID);
|
||||||
UUID teamLeaderUUID = getTeamLeader(user.getWorld(), user);
|
UUID teamLeaderUUID = getTeamLeader(getWorld(), user);
|
||||||
if (!(inTeam && teamLeaderUUID.equals(playerUUID))) {
|
if (!(inTeam && teamLeaderUUID.equals(playerUUID))) {
|
||||||
user.sendMessage("general.errors.not-leader");
|
user.sendMessage("general.errors.not-leader");
|
||||||
return false;
|
return false;
|
||||||
@ -45,7 +45,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
|||||||
user.sendMessage("general.errors.unknown-player");
|
user.sendMessage("general.errors.unknown-player");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().inTeam(user.getWorld(), playerUUID)) {
|
if (!getIslands().inTeam(getWorld(), playerUUID)) {
|
||||||
user.sendMessage("general.errors.no-team");
|
user.sendMessage("general.errors.no-team");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -53,14 +53,14 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
|||||||
user.sendMessage("commands.island.team.setowner.errors.cant-transfer-to-yourself");
|
user.sendMessage("commands.island.team.setowner.errors.cant-transfer-to-yourself");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getPlugin().getIslands().getMembers(user.getWorld(), playerUUID).contains(targetUUID)) {
|
if (!getPlugin().getIslands().getMembers(getWorld(), playerUUID).contains(targetUUID)) {
|
||||||
user.sendMessage("commands.island.team.setowner.errors.target-is-not-member");
|
user.sendMessage("commands.island.team.setowner.errors.target-is-not-member");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Fire event so add-ons can run commands, etc.
|
// Fire event so add-ons can run commands, etc.
|
||||||
IslandBaseEvent event = TeamEvent.builder()
|
IslandBaseEvent event = TeamEvent.builder()
|
||||||
.island(getIslands()
|
.island(getIslands()
|
||||||
.getIsland(user.getWorld(), playerUUID))
|
.getIsland(getWorld(), playerUUID))
|
||||||
.reason(TeamEvent.Reason.MAKELEADER)
|
.reason(TeamEvent.Reason.MAKELEADER)
|
||||||
.involvedPlayer(targetUUID)
|
.involvedPlayer(targetUUID)
|
||||||
.build();
|
.build();
|
||||||
@ -68,7 +68,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
|||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
getIslands().makeLeader(user.getWorld(), user, targetUUID);
|
getIslands().makeLeader(getWorld(), user, targetUUID);
|
||||||
getIslands().save(true);
|
getIslands().save(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
|||||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
List<String> options = new ArrayList<>();
|
List<String> options = new ArrayList<>();
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
for (UUID member : getPlugin().getIslands().getMembers(user.getWorld(), user.getUniqueId())) {
|
for (UUID member : getPlugin().getIslands().getMembers(getWorld(), user.getUniqueId())) {
|
||||||
options.add(getPlugin().getServer().getOfflinePlayer(member).getName());
|
options.add(getPlugin().getServer().getOfflinePlayer(member).getName());
|
||||||
}
|
}
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
@ -427,5 +427,14 @@ public class IslandWorldManager {
|
|||||||
public int getMaxTeamSize(World world) {
|
public int getMaxTeamSize(World world) {
|
||||||
return worldSettings.get(Util.getWorld(world)).getMaxTeamSize();
|
return worldSettings.get(Util.getWorld(world)).getMaxTeamSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get max homes for world
|
||||||
|
* @param world
|
||||||
|
* @return max homes
|
||||||
|
*/
|
||||||
|
public int getMaxHomes(World world) {
|
||||||
|
return worldSettings.get(Util.getWorld(world)).getMaxHomes();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import org.powermock.reflect.Whitebox;
|
|||||||
import us.tastybento.bskyblock.BSkyBlock;
|
import us.tastybento.bskyblock.BSkyBlock;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
import us.tastybento.bskyblock.managers.CommandsManager;
|
import us.tastybento.bskyblock.managers.CommandsManager;
|
||||||
|
import us.tastybento.bskyblock.managers.IslandWorldManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
@ -61,6 +62,10 @@ public class AdminCommandTest {
|
|||||||
plugin = mock(BSkyBlock.class);
|
plugin = mock(BSkyBlock.class);
|
||||||
Whitebox.setInternalState(BSkyBlock.class, "instance", plugin);
|
Whitebox.setInternalState(BSkyBlock.class, "instance", plugin);
|
||||||
|
|
||||||
|
IslandWorldManager iwm = mock(IslandWorldManager.class);
|
||||||
|
when(iwm.getIslandWorld()).thenReturn(world);
|
||||||
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user