Fixed npe in restricted blocks

This commit is contained in:
Fabrizio La Rosa 2020-07-21 21:14:45 +02:00
parent a67808188f
commit 5b4601198f

View File

@ -246,24 +246,28 @@ public class Block implements Listener {
IslandWorld world = worldManager.getIslandWorld(block.getWorld()); IslandWorld world = worldManager.getIslandWorld(block.getWorld());
if(!player.hasPermission("fabledskyblock.bypass.netherplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.Nether)){ if(!player.hasPermission("fabledskyblock.bypass.netherplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.Nether)){
for(String s : Objects.requireNonNull(configLoad.getConfigurationSection("Island.Restrict.NetherBlocks")).getKeys(false)){ if(configLoad.getConfigurationSection("Island.Restrict.NetherBlocks") != null) {
if(s.equalsIgnoreCase(block.getType().toString())){ for(String s : configLoad.getConfigurationSection("Island.Restrict.NetherBlocks").getKeys(false)){
if(configLoad.getBoolean("Island.Restrict.NetherBlocks." + s, false)){ if(s.equalsIgnoreCase(block.getType().toString())){
plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) if(configLoad.getBoolean("Island.Restrict.NetherBlocks." + s, false)){
.getFileConfiguration().getString("Island.Unlock.NetherBlocksPlace.Message"))); plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
event.setCancelled(true); .getFileConfiguration().getString("Island.Unlock.NetherBlocksPlace.Message")));
event.setCancelled(true);
}
} }
} }
} }
} }
if(!player.hasPermission("fabledskyblock.bypass.endplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.End)){ if(!player.hasPermission("fabledskyblock.bypass.endplace") && !islandManager.isIslandWorldUnlocked(island, IslandWorld.End)){
for(String s : Objects.requireNonNull(configLoad.getConfigurationSection("Island.Restrict.EndBlocks")).getKeys(false)){ if(configLoad.getConfigurationSection("Island.Restrict.EndBlocks") != null) {
if(s.equalsIgnoreCase(block.getType().toString())){ for(String s : configLoad.getConfigurationSection("Island.Restrict.EndBlocks").getKeys(false)){
if(configLoad.getBoolean("Island.Restrict.EndBlocks." + s)){ if(s.equalsIgnoreCase(block.getType().toString())){
plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml")) if(configLoad.getBoolean("Island.Restrict.EndBlocks." + s)){
.getFileConfiguration().getString("Island.Unlock.EndBlocksPlace.Message"))); plugin.getMessageManager().sendMessage(player, Objects.requireNonNull(plugin.getFileManager().getConfig(new File(plugin.getDataFolder(), "language.yml"))
event.setCancelled(true); .getFileConfiguration().getString("Island.Unlock.EndBlocksPlace.Message")));
event.setCancelled(true);
}
} }
} }
} }