Skip to content

Commit

Permalink
Fixes skygrid go command not unknown players.
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Aug 29, 2019
1 parent 4ca43cd commit f73b94d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/world/bentobox/skygrid/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ public boolean isEndIslands() {

@Override
public boolean isNetherIslands() {
return false;
return true;
}

@Override
Expand Down
25 changes: 18 additions & 7 deletions src/main/java/world/bentobox/skygrid/commands/GoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
import org.apache.commons.lang.math.NumberUtils;

import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.commands.DelayedTeleportCommand;
import world.bentobox.bentobox.api.commands.island.CustomIslandMultiHomeHelp;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags;

/**
* @author tastybento
*/
public class GoCommand extends CompositeCommand {
public class GoCommand extends DelayedTeleportCommand {

public GoCommand(CompositeCommand islandCommand) {
super(islandCommand, "go");
Expand All @@ -28,23 +29,33 @@ public void setup() {
}

@Override
public boolean execute(User user, String label, List<String> args) {
public boolean canExecute(User user, String label, List<String> args) {
// Check if the island is reserved
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
if (island == null) {
user.sendMessage("general.errors.no-island");
return false;
}
if ((getIWM().inWorld(user.getWorld()) && Flags.PREVENT_TELEPORT_WHEN_FALLING.isSetForWorld(user.getWorld()))
&& user.getPlayer().getFallDistance() > 0) {
// We're sending the "hint" to the player to tell them they cannot teleport while falling.
user.sendMessage(Flags.PREVENT_TELEPORT_WHEN_FALLING.getHintReference());
return true;
return false;
}
return true;
}

@Override
public boolean execute(User user, String label, List<String> args) {
if (!args.isEmpty() && NumberUtils.isDigits(args.get(0))) {
int homeValue = Integer.parseInt(args.get(0));
int maxHomes = user.getPermissionValue(getPermissionPrefix() + "skygrid.maxhomes", getIWM().getMaxHomes(getWorld()));
if (homeValue > 1 && homeValue <= maxHomes) {
getIslands().homeTeleport(getWorld(), user.getPlayer(), homeValue);
user.sendMessage("commands.skygrid.go.tip", TextVariables.LABEL, getTopLabel());
this.delayCommand(user, () -> getIslands().homeTeleport(getWorld(), user.getPlayer(), homeValue));
return true;
}
}
getIslands().homeTeleport(getWorld(), user.getPlayer());
this.delayCommand(user, () -> getIslands().homeTeleport(getWorld(), user.getPlayer()));
return true;
}

Expand Down

0 comments on commit f73b94d

Please sign in to comment.