Small change to clarify /island use outside of island worlds

This commit is contained in:
tastybento 2018-05-25 15:11:17 -07:00
parent 6a18cc4ccc
commit 682d34849a
4 changed files with 26 additions and 0 deletions

View File

@ -130,6 +130,7 @@ commands:
teleported: "&aTeleported you to home &e#[number]."
help:
description: "The main island command"
pick-world: "&cSpecify world from [worlds]"
spawn:
description: "teleport you to the spawn"
create:

View File

@ -21,6 +21,7 @@ import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.Settings;
import us.tastybento.bskyblock.api.events.command.CommandEvent;
import us.tastybento.bskyblock.api.user.User;
import us.tastybento.bskyblock.managers.IslandWorldManager;
import us.tastybento.bskyblock.managers.IslandsManager;
import us.tastybento.bskyblock.managers.PlayersManager;
import us.tastybento.bskyblock.util.Util;
@ -263,6 +264,13 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
return plugin;
}
/**
* Get the island worlds manager
* @return island worlds manager
*/
public IslandWorldManager getIWM() {
return plugin.getIWM();
}
/**
* @return Settings object
*/

View File

@ -69,6 +69,11 @@ public class IslandCommand extends CompositeCommand {
return false;
}
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 (getPlugin().getIslands().hasIsland(user.getWorld(), user.getUniqueId())) {
return getSubCommand("go").map(goCmd -> goCmd.execute(user, new ArrayList<>())).orElse(false);

View File

@ -396,5 +396,17 @@ public class IslandWorldManager {
World w = Util.getWorld(world);
return (worldSettings.containsKey(w) && !worldSettings.get(w).isDragonSpawn()) ? false : true;
}
/**
* @return a comma separated string of friendly world names
*/
public String getFriendlyNames() {
StringBuilder r = new StringBuilder();
worlds.values().forEach(n -> r.append(n).append(", "));
if (r.length() > 0) {
r.setLength(r.length() - 2);
}
return r.toString();
}
}