1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +01:00

Correct entity type check for 1.13+

This commit is contained in:
Zrips 2018-10-14 17:17:24 +03:00
parent aa84bde32d
commit 081edff7cb
3 changed files with 123 additions and 108 deletions

View File

@ -183,7 +183,31 @@ public class ConfigManager {
myKey = myKey.split("-")[0];
}
CMIMaterial material = CMIMaterial.get(myKey + (subType));
CMIMaterial material = null;
switch (actionType) {
case KILL:
case MILK:
case MMKILL:
case BREED:
case SHEAR:
case EXPLORE:
case CUSTOMKILL:
break;
case TNTBREAK:
case VTRADE:
case SMELT:
case REPAIR:
case PLACE:
case EAT:
case FISH:
case ENCHANT:
case DYE:
case DRINK:
case CRAFT:
case BREW:
case BREAK:
material = CMIMaterial.get(myKey + (subType));
if (material == null)
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase());
@ -203,9 +227,11 @@ public class ConfigManager {
}
}
}
break;
default:
break;
if (actionType == ActionType.EXPLORE)
material = null;
}
c: if (material != null) {
@ -261,7 +287,7 @@ public class ConfigManager {
} else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) {
// check entities
EntityType entity = EntityType.fromName(myKey);
EntityType entity = EntityType.fromName(myKey.toUpperCase());
if (entity == null) {
try {
entity = EntityType.valueOf(myKey.toUpperCase());
@ -278,43 +304,45 @@ public class ConfigManager {
Jobs.getGCManager().setBreederFinder(true);
}
if (entity == null) {
switch (myKey.toLowerCase()) {
case "skeletonwither":
type = "SkeletonWither";
type = CMIEntityType.WITHER_SKELETON.getOneWordName();
id = 51;
meta = "1";
break;
case "skeletonstray":
type = "SkeletonStray";
type = CMIEntityType.STRAY.getOneWordName();
id = 51;
meta = "2";
break;
case "zombievillager":
type = "ZombieVillager";
type = CMIEntityType.ZOMBIE_VILLAGER.getOneWordName();
id = 54;
meta = "1";
break;
case "zombiehusk":
type = "ZombieHusk";
type = CMIEntityType.HUSK.getOneWordName();
id = 54;
meta = "2";
break;
case "horseskeleton":
type = "HorseSkeleton";
type = CMIEntityType.SKELETON_HORSE.getOneWordName();
id = 100;
meta = "1";
break;
case "horsezombie":
type = "HorseZombie";
type = CMIEntityType.ZOMBIE_HORSE.getOneWordName();
id = 100;
meta = "2";
break;
case "guardianelder":
type = "GuardianElder";
type = CMIEntityType.ELDER_GUARDIAN.getOneWordName();
id = 68;
meta = "1";
break;
}
}
} else if (actionType == ActionType.ENCHANT) {
Enchantment enchant = Enchantment.getByName(myKey);
@ -1029,6 +1057,8 @@ public class ConfigManager {
Jobs.getGCManager().setBreederFinder(true);
}
// Pre 1.13 checks for custom names
if (entity == null) {
switch (key.toLowerCase()) {
case "skeletonwither":
type = CMIEntityType.WITHER_SKELETON.getOneWordName();
@ -1066,6 +1096,7 @@ public class ConfigManager {
meta = "1";
break;
}
}
} else if (actionType == ActionType.ENCHANT) {
Enchantment enchant = Enchantment.getByName(myKey);

View File

@ -20,22 +20,6 @@ public class v1_13 implements NMS {
@Override
public String getRealType(Entity entity) {
switch (entity.getType().name()) {
case "WITHER_SKELETON":
return "skeletonwither";
case "STRAY":
return "SkeletonStray";
case "ZOMBIE_VILLAGER":
return "ZombieVillager";
case "HUSK":
return "ZombieHusk";
case "SKELETON_HORSE":
return "HorseSkeleton";
case "ZOMBIE_HORSE":
return "HorseZombie";
case "ELDER_GUARDIAN":
return "GuardianElder";
}
return entity.getType().name();
}