diff --git a/pom.xml b/pom.xml index 3b49aff..241f0fe 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - addon-acidisland + us.tastybento addon-acidisland 0.0.1-SNAPSHOT jar diff --git a/src/main/java/bskyblock/addon/acidisland/AISettings.java b/src/main/java/bskyblock/addon/acidisland/AISettings.java index 9e56182..dd450fb 100644 --- a/src/main/java/bskyblock/addon/acidisland/AISettings.java +++ b/src/main/java/bskyblock/addon/acidisland/AISettings.java @@ -172,5 +172,17 @@ public class AISettings implements WorldSettings { return false; } + @Override + public int getMaxTeamSize() { + // TODO Auto-generated method stub + return 3; + } + + @Override + public int getMaxHomes() { + // TODO Auto-generated method stub + return 1; + } + } diff --git a/src/main/java/bskyblock/addon/acidisland/AcidIsland.java b/src/main/java/bskyblock/addon/acidisland/AcidIsland.java index 59c2d76..06935c6 100644 --- a/src/main/java/bskyblock/addon/acidisland/AcidIsland.java +++ b/src/main/java/bskyblock/addon/acidisland/AcidIsland.java @@ -3,8 +3,11 @@ package bskyblock.addon.acidisland; import org.bukkit.World; import org.bukkit.plugin.PluginManager; +import bskyblock.addon.acidisland.commands.AcidCommand; +import bskyblock.addon.acidisland.commands.AiCommand; import bskyblock.addon.acidisland.listeners.AcidEffect; import bskyblock.addon.acidisland.listeners.IslandBuilder; +import bskyblock.addon.acidisland.world.AcidIslandWorld; import us.tastybento.bskyblock.api.addons.Addon; /** @@ -25,7 +28,6 @@ public class AcidIsland extends Addon { aiw = new AcidIslandWorld(this); // TODO Register settings //getBSkyBlock().getSettings().register(settings); - } @Override @@ -36,6 +38,9 @@ public class AcidIsland extends Addon { manager.registerEvents(new AcidEffect(this), this.getBSkyBlock()); // New Islands manager.registerEvents(new IslandBuilder(this), this.getBSkyBlock()); + // Register commands + new AcidCommand(this); + new AiCommand(this); } @@ -54,6 +59,10 @@ public class AcidIsland extends Addon { return aiw; } + /** + * Convenience method to obtain the AcidIsland overworld + * @return + */ public World getIslandWorld() { return aiw.getOverWorld(); } diff --git a/src/main/java/bskyblock/addon/acidisland/commands/AcidCommand.java b/src/main/java/bskyblock/addon/acidisland/commands/AcidCommand.java new file mode 100755 index 0000000..19b45d5 --- /dev/null +++ b/src/main/java/bskyblock/addon/acidisland/commands/AcidCommand.java @@ -0,0 +1,61 @@ +package bskyblock.addon.acidisland.commands; + +import java.util.List; + +import bskyblock.addon.acidisland.AcidIsland; +import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.user.User; +import us.tastybento.bskyblock.commands.admin.AdminGetRankCommand; +import us.tastybento.bskyblock.commands.admin.AdminInfoCommand; +import us.tastybento.bskyblock.commands.admin.AdminReloadCommand; +import us.tastybento.bskyblock.commands.admin.AdminSchemCommand; +import us.tastybento.bskyblock.commands.admin.AdminSetRankCommand; +import us.tastybento.bskyblock.commands.admin.AdminTeleportCommand; +import us.tastybento.bskyblock.commands.admin.AdminVersionCommand; +import us.tastybento.bskyblock.commands.admin.teams.AdminTeamAddCommand; +import us.tastybento.bskyblock.commands.admin.teams.AdminTeamDisbandCommand; +import us.tastybento.bskyblock.commands.admin.teams.AdminTeamKickCommand; +import us.tastybento.bskyblock.commands.admin.teams.AdminTeamMakeLeaderCommand; + +public class AcidCommand extends CompositeCommand { + + public AcidCommand(AcidIsland addon) { + super("acid"); + setWorld(addon.getIslandWorld()); + new AdminVersionCommand(this); + new AdminReloadCommand(this); + new AdminTeleportCommand(this, "tp"); + new AdminTeleportCommand(this, "tpnether"); + new AdminTeleportCommand(this, "tpend"); + new AdminGetRankCommand(this); + new AdminSetRankCommand(this); + new AdminInfoCommand(this); + // Team commands + new AdminTeamAddCommand(this); + new AdminTeamKickCommand(this); + new AdminTeamDisbandCommand(this); + new AdminTeamMakeLeaderCommand(this); + // Schems + new AdminSchemCommand(this); + } + + @Override + public void setup() { + setPermissionPrefix("acidisland"); + setPermission("acidisland.admin.*"); + setOnlyPlayer(false); + setParameters("commands.admin.help.parameters"); + setDescription("commands.admin.help.description"); + } + + @Override + public boolean execute(User user, List args) { + if (!args.isEmpty()) { + user.sendMessage("general.errors.unknown-command", "[label]", "acid"); + return false; + } + // By default run the attached help command, if it exists (it should) + return showHelp(this, user); + } + +} diff --git a/src/main/java/bskyblock/addon/acidisland/commands/AiCommand.java b/src/main/java/bskyblock/addon/acidisland/commands/AiCommand.java new file mode 100755 index 0000000..179fc69 --- /dev/null +++ b/src/main/java/bskyblock/addon/acidisland/commands/AiCommand.java @@ -0,0 +1,92 @@ +package bskyblock.addon.acidisland.commands; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import bskyblock.addon.acidisland.AcidIsland; +import us.tastybento.bskyblock.Constants; +import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.user.User; +import us.tastybento.bskyblock.commands.island.IslandAboutCommand; +import us.tastybento.bskyblock.commands.island.IslandBanCommand; +import us.tastybento.bskyblock.commands.island.IslandBanlistCommand; +import us.tastybento.bskyblock.commands.island.IslandCreateCommand; +import us.tastybento.bskyblock.commands.island.IslandGoCommand; +import us.tastybento.bskyblock.commands.island.IslandLanguageCommand; +import us.tastybento.bskyblock.commands.island.IslandResetCommand; +import us.tastybento.bskyblock.commands.island.IslandResetnameCommand; +import us.tastybento.bskyblock.commands.island.IslandSethomeCommand; +import us.tastybento.bskyblock.commands.island.IslandSetnameCommand; +import us.tastybento.bskyblock.commands.island.IslandSettingsCommand; +import us.tastybento.bskyblock.commands.island.IslandUnbanCommand; +import us.tastybento.bskyblock.commands.island.teams.IslandTeamCommand; +import us.tastybento.bskyblock.util.Util; + +public class AiCommand extends CompositeCommand { + + AcidIsland addon; + + public AiCommand(AcidIsland addon) { + super("ai"); + // Set up world + setWorld(addon.getIslandWorld()); + // Set up subcommands + new IslandAboutCommand(this); + new IslandCreateCommand(this); + new IslandGoCommand(this); + new IslandResetCommand(this); + new IslandSetnameCommand(this); + new IslandResetnameCommand(this); + new IslandSethomeCommand(this); + new IslandSettingsCommand(this); + new IslandLanguageCommand(this); + new IslandBanCommand(this); + new IslandUnbanCommand(this); + new IslandBanlistCommand(this); + // Team commands + 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("acidisland"); + setPermission("island"); + } + + /* (non-Javadoc) + * @see us.tastybento.bskyblock.api.commands.CommandArgument#execute(org.bukkit.command.CommandSender, java.lang.String[]) + */ + @Override + public boolean execute(User user, List args) { + if (user == null) { + return false; + } + if (args.isEmpty()) { + // If in world, go + if (getPlugin().getIslands().hasIsland(getWorld(), user.getUniqueId())) { + return getSubCommand("go").map(goCmd -> goCmd.execute(user, new ArrayList<>())).orElse(false); + } + // No islands currently + return getSubCommand("create").map(createCmd -> createCmd.execute(user, new ArrayList<>())).orElse(false); + } + user.sendMessage("general.errors.unknown-command", "[label]", Constants.ISLANDCOMMAND); + return false; + + } + + @Override + public Optional> tabComplete(User user, String alias, List args) { + List options = getPlugin().getIWM().getOverWorldNames().stream().collect(Collectors.toList()); + String lastArg = !args.isEmpty() ? args.get(args.size()-1) : ""; + return Optional.of(Util.tabLimit(options, lastArg)); + } + +} diff --git a/src/main/java/bskyblock/addon/acidisland/AcidIslandWorld.java b/src/main/java/bskyblock/addon/acidisland/world/AcidIslandWorld.java similarity index 97% rename from src/main/java/bskyblock/addon/acidisland/AcidIslandWorld.java rename to src/main/java/bskyblock/addon/acidisland/world/AcidIslandWorld.java index d1de3c5..5959f8b 100644 --- a/src/main/java/bskyblock/addon/acidisland/AcidIslandWorld.java +++ b/src/main/java/bskyblock/addon/acidisland/world/AcidIslandWorld.java @@ -1,13 +1,14 @@ /** * */ -package bskyblock.addon.acidisland; +package bskyblock.addon.acidisland.world; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.WorldCreator; import org.bukkit.WorldType; +import bskyblock.addon.acidisland.AcidIsland; import us.tastybento.bskyblock.util.Util; /** diff --git a/src/main/java/bskyblock/addon/acidisland/ChunkGeneratorWorld.java b/src/main/java/bskyblock/addon/acidisland/world/ChunkGeneratorWorld.java similarity index 98% rename from src/main/java/bskyblock/addon/acidisland/ChunkGeneratorWorld.java rename to src/main/java/bskyblock/addon/acidisland/world/ChunkGeneratorWorld.java index 8ac1e10..4f76fd9 100644 --- a/src/main/java/bskyblock/addon/acidisland/ChunkGeneratorWorld.java +++ b/src/main/java/bskyblock/addon/acidisland/world/ChunkGeneratorWorld.java @@ -1,4 +1,4 @@ -package bskyblock.addon.acidisland; +package bskyblock.addon.acidisland.world; import java.util.Arrays; import java.util.List; @@ -11,6 +11,8 @@ import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import org.bukkit.util.noise.PerlinOctaveGenerator; +import bskyblock.addon.acidisland.AcidIsland; + /** * Generates the AcidIsland world * @author tastybento