Fixed NPE when chest is not on an island (ASkyBlock and uSkyBlock)

This commit is contained in:
Eric 2017-04-17 18:29:15 +02:00
parent bc222b6b37
commit d34e5f809f
2 changed files with 15 additions and 6 deletions

View File

@ -178,7 +178,8 @@ public class ChestProtectListener implements Listener {
} }
} }
} }
} catch (Exception ignored) { } catch (Exception ex) {
plugin.debug(ex);
} }
} }
} }
@ -192,13 +193,17 @@ public class ChestProtectListener implements Listener {
if (plugin.hasUSkyBlock() && config.enable_uskyblock_integration) { if (plugin.hasUSkyBlock() && config.enable_uskyblock_integration) {
IslandInfo islandInfo = plugin.getUSkyBlock().getIslandInfo(b.getLocation()); IslandInfo islandInfo = plugin.getUSkyBlock().getIslandInfo(b.getLocation());
if (islandInfo != null) {
externalPluginsAllowed &= islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName()); externalPluginsAllowed &= islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName());
} }
}
if (plugin.hasASkyBlock() && config.enable_askyblock_integration) { if (plugin.hasASkyBlock() && config.enable_askyblock_integration) {
Island island = ASkyBlockAPI.getInstance().getIslandAt(b.getLocation()); Island island = ASkyBlockAPI.getInstance().getIslandAt(b.getLocation());
if (island != null) {
externalPluginsAllowed &= island.getMembers().contains(p.getUniqueId()) || island.getOwner().equals(p.getUniqueId()); externalPluginsAllowed &= island.getMembers().contains(p.getUniqueId()) || island.getOwner().equals(p.getUniqueId());
} }
}
if (plugin.hasIslandWorld() && config.enable_islandworld_integration && IslandWorldApi.isInitialized()) { if (plugin.hasIslandWorld() && config.enable_islandworld_integration && IslandWorldApi.isInitialized()) {
if (b.getWorld().getName().equals(IslandWorldApi.getIslandWorld().getName())) { if (b.getWorld().getName().equals(IslandWorldApi.getIslandWorld().getName())) {
@ -211,7 +216,7 @@ public class ChestProtectListener implements Listener {
if (b.getRelative(BlockFace.UP).getType() == Material.AIR) { if (b.getRelative(BlockFace.UP).getType() == Material.AIR) {
shopUtils.removeShop(shop, true); shopUtils.removeShop(shop, true);
Shop newShop = new Shop(shop.getID(), ShopChest.getInstance(), shop.getVendor(), shop.getProduct(), shop.getLocation(), shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType()); Shop newShop = new Shop(shop.getID(), plugin, shop.getVendor(), shop.getProduct(), shop.getLocation(), shop.getBuyPrice(), shop.getSellPrice(), shop.getShopType());
newShop.create(true); newShop.create(true);
shopUtils.addShop(newShop, true); shopUtils.addShop(newShop, true);
plugin.debug(String.format("%s extended %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID())); plugin.debug(String.format("%s extended %s's shop (#%d)", p.getName(), shop.getVendor().getName(), shop.getID()));

View File

@ -168,19 +168,23 @@ public class ShopInteractListener implements Listener {
for (Location loc : chestLocations) { for (Location loc : chestLocations) {
if (loc != null) { if (loc != null) {
IslandInfo islandInfo = plugin.getUSkyBlock().getIslandInfo(loc); IslandInfo islandInfo = plugin.getUSkyBlock().getIslandInfo(loc);
if (islandInfo != null) {
externalPluginsAllowed &= islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName()); externalPluginsAllowed &= islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName());
} }
} }
} }
}
if (plugin.hasASkyBlock() && config.enable_askyblock_integration) { if (plugin.hasASkyBlock() && config.enable_askyblock_integration) {
for (Location loc : chestLocations) { for (Location loc : chestLocations) {
if (loc != null) { if (loc != null) {
Island island = ASkyBlockAPI.getInstance().getIslandAt(loc); Island island = ASkyBlockAPI.getInstance().getIslandAt(loc);
if (island != null) {
externalPluginsAllowed &= island.getMembers().contains(p.getUniqueId()) || island.getOwner().equals(p.getUniqueId()); externalPluginsAllowed &= island.getMembers().contains(p.getUniqueId()) || island.getOwner().equals(p.getUniqueId());
} }
} }
} }
}
if (plugin.hasIslandWorld() && config.enable_islandworld_integration && IslandWorldApi.isInitialized()) { if (plugin.hasIslandWorld() && config.enable_islandworld_integration && IslandWorldApi.isInitialized()) {
for (Location loc : chestLocations) { for (Location loc : chestLocations) {