Implemented human-readable monster-name

master
Alexander B 4 years ago
parent b3bf1eba55
commit c062482e1f

@ -57,4 +57,21 @@ public class Main extends JavaPlugin {
public static String serialiseLocation(Location loc){ public static String serialiseLocation(Location loc){
return loc.getWorld().getName()+";"+loc.getBlockX()+";"+loc.getBlockY()+";"+loc.getBlockZ(); 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;
}
} }

@ -128,7 +128,13 @@ public class OnBlockBreak implements Listener {
BlockStateMeta bsm = (BlockStateMeta)item.getItemMeta(); BlockStateMeta bsm = (BlockStateMeta)item.getItemMeta();
bsm.setBlockState(cs); 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); item.setItemMeta(bsm);
e.getBlock().setType(Material.AIR); e.getBlock().setType(Material.AIR);

Loading…
Cancel
Save