Skip to content

Commit

Permalink
Fixes issues with setting spawn point location for visitors.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Mar 24, 2021
1 parent 2e3889b commit 7eaebe5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;

import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.visit.VisitAddon;
Expand Down Expand Up @@ -83,26 +84,30 @@ public boolean canExecute(User user, String label, List<String> args)
user.sendMessage("general.errors.no-island");
return false;
}
else if (island.isAllowed(user, VisitAddon.VISIT_CONFIG_PERMISSION))
else if (!island.isAllowed(user, VisitAddon.VISIT_CONFIG_PERMISSION))
{
// No permission to edit.
Utils.sendMessage(user, user.getTranslation("general.errors.insufficient-rank",
TextVariables.RANK,
user.getTranslation(this.getPlugin().getRanksManager().
getRank(VisitAddon.VISIT_CONFIG_PERMISSION.getDefaultRank()))));
return false;
}
else if (user.getLocation() == null || World.Environment.NORMAL.equals(user.getWorld().getEnvironment()))
else if (user.getLocation() == null || !World.Environment.NORMAL.equals(user.getWorld().getEnvironment()))
{
// User must be in overworld.
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS, "not-in-overworld"));
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "not-in-overworld"));
return false;
}
else if (!island.getProtectionBoundingBox().contains(user.getLocation().toVector()))
{
// User must be in protected area.
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS, "not-in-protected-area"));
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "not-in-protected-area"));
}
else if (!this.getAddon().getIslands().isSafeLocation(user.getLocation()))
{
// Location must be safe.
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS, "not-safe-location"));
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "not-safe-location"));
return false;
}

Expand All @@ -128,6 +133,7 @@ public boolean execute(User user, String label, List<String> args)
{
// Utilize island spawn point location.
island.setSpawnPoint(World.Environment.NORMAL, user.getLocation());
Utils.sendMessage(user, user.getTranslation(Constants.CONVERSATIONS + "spawn-point-updated"));
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ commands:
# Player setLocation sub-command that allows to change spawn location for visitors.
# This command label will be required to write after gamemode player command label, f.e. /[label] visit setLocation
# /!\ In order to apply the changes made to this option, you must restart your server. Reloading BentoBox or the server won't work.
set-location: setLocation
set-location: setlocation setLocation
admin:
# Admin main sub-command to access the addon.
# This command label will be required to write after gamemode admin command label, f.e. /[label] visit
Expand Down
16 changes: 9 additions & 7 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ visit:
click-to-select: "&e Click &7 to select."
click-to-deselect: "&e Click &7 to deselect."
errors:
noone-is-online: '&r Noone from this island is online!'
not-enough-credits: '&r You do not have enough credits to visit this island. Necessary [number] credits.'
cannot-withdraw-credits: '&r Cannot withdraw [number] from your account! Operation is cancelled.'
cannot-deposit-credits: '&r Cannot deposit [number] into island owner account! Operation is cancelled.'
not-in-overworld: '&r You must be in overworld to change visitor spawn location! Operation is cancelled.'
not-in-protected-area: '&r You must be in your island protected area! Operation is cancelled.'
not-safe-location: '&r Cannot set this location, it is not safe for teleportation! Operation is cancelled.'
noone-is-online: '&r&c Noone from this island is online!'
not-enough-credits: '&r&c You do not have enough credits to visit this island. Necessary [number] credits.'
cannot-withdraw-credits: '&r&c Cannot withdraw [number] from your account! Operation is cancelled.'
cannot-deposit-credits: '&r&c Cannot deposit [number] into island owner account! Operation is cancelled.'
not-in-overworld: '&rv You must be in overworld to change visitor spawn location! Operation is cancelled.'
not-in-protected-area: '&r&c You must be in your island protected area! Operation is cancelled.'
not-safe-location: '&r&c Cannot set this location, it is not safe for teleportation! Operation is cancelled.'
conversations:
# List of strings that are valid for confirming input. (separated with ,)
confirm-string: "true, on, yes, confirm, y, valid, correct"
Expand Down Expand Up @@ -259,6 +259,8 @@ visit:
confirm-island-data-deletion: "&e Confirm that you want to delete all user data from the database for [gamemode]."
# Message that appears after successful user data removing.
user-data-removed: "&a Success, all user data for [gamemode] was removed!"
# Message that appears when user updates spawn point.
spawn-point-updated: "&a Success, spawn point is changed!"
# Protection flags that are used in current addon.
protection:
flags:
Expand Down

0 comments on commit 7eaebe5

Please sign in to comment.