1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-01 23:13:48 +01:00

Lets allow custom names for MythicMobs

This commit is contained in:
Zrips 2020-01-03 17:12:29 +02:00
parent ca8ea40f7f
commit 8c4ae9dcf5
2 changed files with 28 additions and 4 deletions

View File

@ -25,6 +25,7 @@ public class NameTranslatorManager {
public HashMap<CMIMaterial, NameList> ListOfNames = new HashMap<>(); public HashMap<CMIMaterial, NameList> ListOfNames = new HashMap<>();
public ArrayList<NameList> ListOfEntities = new ArrayList<>(); public ArrayList<NameList> ListOfEntities = new ArrayList<>();
public HashMap<String, NameList> ListOfEnchants = new HashMap<>(); public HashMap<String, NameList> ListOfEnchants = new HashMap<>();
public HashMap<String, NameList> ListOfMMEntities = new HashMap<>();
public ArrayList<NameList> ListOfColors = new ArrayList<>(); public ArrayList<NameList> ListOfColors = new ArrayList<>();
public String Translate(String materialName, JobInfo info) { public String Translate(String materialName, JobInfo info) {
@ -95,6 +96,9 @@ public class NameTranslatorManager {
} }
break; break;
case MMKILL: case MMKILL:
NameList got = ListOfMMEntities.get(materialName.toLowerCase());
if (got != null && got.getName() != null)
return got.getName();
if (Jobs.getMythicManager() == null) if (Jobs.getMythicManager() == null)
return materialName; return materialName;
return Jobs.getMythicManager().getDisplayName(materialName); return Jobs.getMythicManager().getDisplayName(materialName);
@ -145,6 +149,19 @@ public class NameTranslatorManager {
} else } else
Jobs.consoleMsg("&c[Jobs] The EntityList section not found in " + ItemFile.fileName + " file."); Jobs.consoleMsg("&c[Jobs] The EntityList section not found in " + ItemFile.fileName + " file.");
if (ItemFile.getConfig().isConfigurationSection("MythicEntityList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("MythicEntityList");
Set<String> keys = section.getKeys(false);
ListOfMMEntities.clear();
for (String one : keys) {
String Name = ItemFile.getConfig().getString("MythicEntityList." + one);
ListOfMMEntities.put(one.toLowerCase(), new NameList(null, null, Name, Name));
}
if (ListOfMMEntities.size() > 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + ListOfMMEntities.size() + " custom MythicMobs names!");
} else
Jobs.consoleMsg("&c[Jobs] The MythicEntityList section not found in " + ItemFile.fileName + " file.");
if (ItemFile.getConfig().isConfigurationSection("EnchantList")) { if (ItemFile.getConfig().isConfigurationSection("EnchantList")) {
ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("EnchantList"); ConfigurationSection section = ItemFile.getConfig().getConfigurationSection("EnchantList");
Set<String> keys = section.getKeys(false); Set<String> keys = section.getKeys(false);
@ -384,6 +401,13 @@ public class NameTranslatorManager {
c.get("ColorList." + cn.getId() + "-" + cn.toString(), name); c.get("ColorList." + cn.getId() + "-" + cn.toString(), name);
}*/ }*/
if (!c.getC().isConfigurationSection("MythicEntityList")) {
c.get("MythicEntityList.AngrySludge", "Angry Sludge");
c.get("MythicEntityList.SkeletalKnight", "Skeletal Knight");
} else {
c.set("MythicEntityList", c.getC().get("MythicEntityList"));
}
c.save(); c.save();
} }
readFile(); readFile();

View File

@ -76,7 +76,7 @@ public class ExploreChunk {
public String serializeNames() { public String serializeNames() {
String s = ""; String s = "";
if (playerIds == null) if (playerIds == null)
return ""; return null;
for (Integer one : this.playerIds) { for (Integer one : this.playerIds) {
if (!s.isEmpty()) if (!s.isEmpty())
s += ";"; s += ";";
@ -86,7 +86,7 @@ public class ExploreChunk {
} }
public void deserializeNames(String names) { public void deserializeNames(String names) {
if (names.isEmpty()) { if (names == null || names.isEmpty()) {
this.full = true; this.full = true;
playerIds = null; playerIds = null;
return; return;