mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-14 03:11:26 +01:00
NPE protections
This commit is contained in:
parent
f37226b115
commit
db464d5c04
@ -109,7 +109,7 @@ public class BlueprintPaster {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.clipboard = clipboard;
|
this.clipboard = clipboard;
|
||||||
// Calculate location for pasting
|
// Calculate location for pasting
|
||||||
this.blueprint = clipboard.getBlueprint();
|
this.blueprint = Objects.requireNonNull(clipboard.getBlueprint(), "Clipboard cannot have a null Blueprint");
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.island = null;
|
this.island = null;
|
||||||
|
|
||||||
@ -416,9 +416,11 @@ public class BlueprintPaster {
|
|||||||
if (island != null && !lines.isEmpty() && lines.get(0).equalsIgnoreCase(TextVariables.START_TEXT)) {
|
if (island != null && !lines.isEmpty() && lines.get(0).equalsIgnoreCase(TextVariables.START_TEXT)) {
|
||||||
// Get the addon that is operating in this world
|
// Get the addon that is operating in this world
|
||||||
String addonName = plugin.getIWM().getAddon(island.getWorld()).map(addon -> addon.getDescription().getName().toLowerCase(Locale.ENGLISH)).orElse("");
|
String addonName = plugin.getIWM().getAddon(island.getWorld()).map(addon -> addon.getDescription().getName().toLowerCase(Locale.ENGLISH)).orElse("");
|
||||||
for (int i = 0; i < 4; i++) {
|
if (island.getOwner() != null) {
|
||||||
s.setLine(i, Util.translateColorCodes(plugin.getLocalesManager().getOrDefault(User.getInstance(island.getOwner()),
|
for (int i = 0; i < 4; i++) {
|
||||||
addonName + ".sign.line" + i,"").replace(TextVariables.NAME, name)));
|
s.setLine(i, Util.translateColorCodes(plugin.getLocalesManager().getOrDefault(User.getInstance(island.getOwner()),
|
||||||
|
addonName + ".sign.line" + i,"").replace(TextVariables.NAME, name)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Just paste
|
// Just paste
|
||||||
|
@ -16,7 +16,6 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -43,7 +42,6 @@ import world.bentobox.bentobox.database.objects.adapters.FlagSerializer;
|
|||||||
import world.bentobox.bentobox.database.objects.adapters.FlagSerializer3;
|
import world.bentobox.bentobox.database.objects.adapters.FlagSerializer3;
|
||||||
import world.bentobox.bentobox.database.objects.adapters.LogEntryListAdapter;
|
import world.bentobox.bentobox.database.objects.adapters.LogEntryListAdapter;
|
||||||
import world.bentobox.bentobox.lists.Flags;
|
import world.bentobox.bentobox.lists.Flags;
|
||||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
|
||||||
import world.bentobox.bentobox.managers.RanksManager;
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
import world.bentobox.bentobox.util.Pair;
|
import world.bentobox.bentobox.util.Pair;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
@ -1216,11 +1214,9 @@ public class Island implements DataObject, MetaDataAble {
|
|||||||
* @return {@code true} if this island has its nether island generated, {@code false} otherwise.
|
* @return {@code true} if this island has its nether island generated, {@code false} otherwise.
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public boolean hasNetherIsland(){
|
public boolean hasNetherIsland() {
|
||||||
IslandWorldManager iwm = BentoBox.getInstance().getIWM();
|
World nether = BentoBox.getInstance().getIWM().getNetherWorld(getWorld());
|
||||||
return iwm.isNetherGenerate(getWorld()) && iwm.isNetherIslands(getWorld()) &&
|
return nether != null && !getCenter().toVector().toLocation(nether).getBlock().getType().isAir();
|
||||||
iwm.getNetherWorld(getWorld()) != null &&
|
|
||||||
!getCenter().toVector().toLocation(iwm.getNetherWorld(getWorld())).getBlock().getType().equals(Material.AIR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1228,11 +1224,9 @@ public class Island implements DataObject, MetaDataAble {
|
|||||||
* @return {@code true} if this island has its end island generated, {@code false} otherwise.
|
* @return {@code true} if this island has its end island generated, {@code false} otherwise.
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public boolean hasEndIsland(){
|
public boolean hasEndIsland() {
|
||||||
IslandWorldManager iwm = BentoBox.getInstance().getIWM();
|
World end = BentoBox.getInstance().getIWM().getEndWorld(getWorld());
|
||||||
return iwm.isEndGenerate(getWorld()) && iwm.isEndIslands(getWorld()) &&
|
return end != null && !getCenter().toVector().toLocation(end).getBlock().getType().isAir();
|
||||||
iwm.getEndWorld(getWorld()) != null &&
|
|
||||||
!getCenter().toVector().toLocation(iwm.getEndWorld(getWorld())).getBlock().getType().equals(Material.AIR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user