mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-10 02:19:30 +01:00
Prevent NPE possibility.
This commit is contained in:
parent
29fa03976c
commit
690ea2f99e
@ -1,11 +1,13 @@
|
||||
package world.bentobox.bentobox.api.commands.island;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.commands.ConfirmableCommand;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
@ -51,29 +53,30 @@ public class IslandSethomeCommand extends ConfirmableCommand {
|
||||
@Override
|
||||
public boolean execute(User user, String label, List<String> args) {
|
||||
String number = String.join(" ", args);
|
||||
WorldSettings ws = Objects.requireNonNull(getIWM().getWorldSettings(user.getWorld()));
|
||||
// Check if the player is in the Nether
|
||||
if (getIWM().isNether(user.getWorld())) {
|
||||
// Check if he is (not) allowed to set his home here
|
||||
if (!getIWM().getWorldSettings(user.getWorld()).isAllowSetHomeInNether()) {
|
||||
if (!ws.isAllowSetHomeInNether()) {
|
||||
user.sendMessage("commands.island.sethome.nether.not-allowed");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if a confirmation is required
|
||||
if (getIWM().getWorldSettings(user.getWorld()).isRequireConfirmationToSetHomeInNether()) {
|
||||
if (ws.isRequireConfirmationToSetHomeInNether()) {
|
||||
askConfirmation(user, user.getTranslation("commands.island.sethome.nether.confirmation"), () -> doSetHome(user, number));
|
||||
} else {
|
||||
doSetHome(user, number);
|
||||
}
|
||||
} else if (getIWM().isEnd(user.getWorld())) { // Check if the player is in the End
|
||||
// Check if he is (not) allowed to set his home here
|
||||
if (!getIWM().getWorldSettings(user.getWorld()).isAllowSetHomeInTheEnd()) {
|
||||
if (!ws.isAllowSetHomeInTheEnd()) {
|
||||
user.sendMessage("commands.island.sethome.the-end.not-allowed");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if a confirmation is required
|
||||
if (getIWM().getWorldSettings(user.getWorld()).isRequireConfirmationToSetHomeInTheEnd()) {
|
||||
if (ws.isRequireConfirmationToSetHomeInTheEnd()) {
|
||||
askConfirmation(user, user.getTranslation("commands.island.sethome.the-end.confirmation"), () -> doSetHome(user, number));
|
||||
} else {
|
||||
doSetHome(user, number);
|
||||
|
Loading…
Reference in New Issue
Block a user