Upgraded gradle file and fixed a nullpointer

This commit is contained in:
Sekwah 2019-08-12 09:40:06 +01:00
parent c8efcbb801
commit f5deb96d2e
3 changed files with 13 additions and 8 deletions

View File

@ -16,7 +16,7 @@ tasks.withType(JavaCompile) {
}
String getPluginData(String tag) {
File file = new File("src/main/resources/plugin.yml")
File file = file("src/main/resources/plugin.yml")
String version = "notfound"
file.readLines("UTF-8").each {String line ->
line = line.trim()

View File

@ -74,11 +74,13 @@ public class Portal {
ConfigurationSection portalConfigSection = portalData.getConfig().getConfigurationSection(portal.toString());
String[] blockTypesString = portalConfigSection.getString("triggerblock").split(",");
String blockTypesRaw = portalConfigSection.getString("triggerblock");
String[] blockTypesString = blockTypesRaw != null ? blockTypesRaw.split(",") : null;
HashSet<Material> blockTypes = getMaterialSet(blockTypesString);
if(blockTypes.size() == 0) {
if(blockTypes.isEmpty()) {
blockTypes.add(Material.NETHER_PORTAL);
}
@ -132,12 +134,15 @@ public class Portal {
public static HashSet<Material> getMaterialSet(String[] blockTypesString) {
HashSet<Material> blockTypes = new HashSet<>();
for(String blockType : blockTypesString) {
Material material = Material.getMaterial(blockType);
if(material != null) {
blockTypes.add(material);
if (blockTypesString != null) {
for(String blockType : blockTypesString) {
Material material = Material.getMaterial(blockType);
if(material != null) {
blockTypes.add(material);
}
}
}
return blockTypes;
}

View File

@ -1,6 +1,6 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.2.0
version: 0.2.1
author: sekwah41
description: An advanced portals plugin for bukkit.
api-version: 1.13