diff --git a/eu/railduction/ruakij/spawnerDrops/Main.java b/eu/railduction/ruakij/spawnerDrops/Main.java index 5ce0b87..da270a8 100644 --- a/eu/railduction/ruakij/spawnerDrops/Main.java +++ b/eu/railduction/ruakij/spawnerDrops/Main.java @@ -57,4 +57,21 @@ public class Main extends JavaPlugin { public static String serialiseLocation(Location loc){ return loc.getWorld().getName()+";"+loc.getBlockX()+";"+loc.getBlockY()+";"+loc.getBlockZ(); } + + public static String stringHumanReadable(String str){ + + str = str.replace("_", " "); + String[] strData = str.split(" "); + str = ""; + for (int i = 0; i < strData.length; i++) { + String tmpStr = strData[i].substring(0, 1).toUpperCase(); + strData[i] = tmpStr + strData[i].substring(1).toLowerCase(); + + str += strData[i]; + if(i < strData.length-1) + str += " "; + } + + return str; + } } diff --git a/eu/railduction/ruakij/spawnerDrops/listener/OnBlockBreak.java b/eu/railduction/ruakij/spawnerDrops/listener/OnBlockBreak.java index 2bc5ccc..e44bf6c 100644 --- a/eu/railduction/ruakij/spawnerDrops/listener/OnBlockBreak.java +++ b/eu/railduction/ruakij/spawnerDrops/listener/OnBlockBreak.java @@ -128,7 +128,13 @@ public class OnBlockBreak implements Listener { BlockStateMeta bsm = (BlockStateMeta)item.getItemMeta(); bsm.setBlockState(cs); - bsm.setDisplayName(dropConfig.getString("item.name").replace("{mob-type}", cs.getSpawnedType().name())); + + String item_name_conf = dropConfig.getString("item.name"); + if(item_name_conf != null && item_name_conf != ""){ + String mobTypeName = Main.stringHumanReadable(cs.getSpawnedType().name()); + bsm.setDisplayName(dropConfig.getString("item.name").replace("{mob-type}", mobTypeName)); + } + item.setItemMeta(bsm); e.getBlock().setType(Material.AIR);