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,29 +183,55 @@ public class ConfigManager {
myKey = myKey.split("-")[0]; myKey = myKey.split("-")[0];
} }
CMIMaterial material = CMIMaterial.get(myKey + (subType)); CMIMaterial material = null;
if (material == null) switch (actionType) {
material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase()); 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) { if (material == null)
// try integer method material = CMIMaterial.get(myKey.replace(" ", "_").toUpperCase());
Integer matId = null;
try { if (material == null) {
matId = Integer.valueOf(myKey); // try integer method
} catch (NumberFormatException e) { Integer matId = null;
} try {
if (matId != null) { matId = Integer.valueOf(myKey);
material = CMIMaterial.get(matId); } catch (NumberFormatException e) {
if (material != null) { }
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " is using ID: " + myKey + "!"); if (matId != null) {
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!"); material = CMIMaterial.get(matId);
if (material != null) {
Jobs.getPluginLogger().warning("Job " + jobName + " " + actionType.getName() + " is using ID: " + myKey + "!");
Jobs.getPluginLogger().warning("Please use the Material name instead: " + material.toString() + "!");
}
} }
} }
} break;
default:
break;
if (actionType == ActionType.EXPLORE) }
material = null;
c: if (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) { } else if (actionType == ActionType.KILL || actionType == ActionType.TAME || actionType == ActionType.BREED || actionType == ActionType.MILK) {
// check entities // check entities
EntityType entity = EntityType.fromName(myKey); EntityType entity = EntityType.fromName(myKey.toUpperCase());
if (entity == null) { if (entity == null) {
try { try {
entity = EntityType.valueOf(myKey.toUpperCase()); entity = EntityType.valueOf(myKey.toUpperCase());
@ -278,42 +304,44 @@ public class ConfigManager {
Jobs.getGCManager().setBreederFinder(true); Jobs.getGCManager().setBreederFinder(true);
} }
switch (myKey.toLowerCase()) { if (entity == null) {
case "skeletonwither": switch (myKey.toLowerCase()) {
type = "SkeletonWither"; case "skeletonwither":
id = 51; type = CMIEntityType.WITHER_SKELETON.getOneWordName();
meta = "1"; id = 51;
break; meta = "1";
case "skeletonstray": break;
type = "SkeletonStray"; case "skeletonstray":
id = 51; type = CMIEntityType.STRAY.getOneWordName();
meta = "2"; id = 51;
break; meta = "2";
case "zombievillager": break;
type = "ZombieVillager"; case "zombievillager":
id = 54; type = CMIEntityType.ZOMBIE_VILLAGER.getOneWordName();
meta = "1"; id = 54;
break; meta = "1";
case "zombiehusk": break;
type = "ZombieHusk"; case "zombiehusk":
id = 54; type = CMIEntityType.HUSK.getOneWordName();
meta = "2"; id = 54;
break; meta = "2";
case "horseskeleton": break;
type = "HorseSkeleton"; case "horseskeleton":
id = 100; type = CMIEntityType.SKELETON_HORSE.getOneWordName();
meta = "1"; id = 100;
break; meta = "1";
case "horsezombie": break;
type = "HorseZombie"; case "horsezombie":
id = 100; type = CMIEntityType.ZOMBIE_HORSE.getOneWordName();
meta = "2"; id = 100;
break; meta = "2";
case "guardianelder": break;
type = "GuardianElder"; case "guardianelder":
id = 68; type = CMIEntityType.ELDER_GUARDIAN.getOneWordName();
meta = "1"; id = 68;
break; meta = "1";
break;
}
} }
} else if (actionType == ActionType.ENCHANT) { } else if (actionType == ActionType.ENCHANT) {
@ -1029,42 +1057,45 @@ public class ConfigManager {
Jobs.getGCManager().setBreederFinder(true); Jobs.getGCManager().setBreederFinder(true);
} }
switch (key.toLowerCase()) { // Pre 1.13 checks for custom names
case "skeletonwither": if (entity == null) {
type = CMIEntityType.WITHER_SKELETON.getOneWordName(); switch (key.toLowerCase()) {
id = 51; case "skeletonwither":
meta = "1"; type = CMIEntityType.WITHER_SKELETON.getOneWordName();
break; id = 51;
case "skeletonstray": meta = "1";
type = CMIEntityType.STRAY.getOneWordName(); break;
id = 51; case "skeletonstray":
meta = "2"; type = CMIEntityType.STRAY.getOneWordName();
break; id = 51;
case "zombievillager": meta = "2";
type = CMIEntityType.ZOMBIE_VILLAGER.getOneWordName(); break;
id = 54; case "zombievillager":
meta = "1"; type = CMIEntityType.ZOMBIE_VILLAGER.getOneWordName();
break; id = 54;
case "zombiehusk": meta = "1";
type = CMIEntityType.HUSK.getOneWordName(); break;
id = 54; case "zombiehusk":
meta = "2"; type = CMIEntityType.HUSK.getOneWordName();
break; id = 54;
case "horseskeleton": meta = "2";
type = CMIEntityType.SKELETON_HORSE.getOneWordName(); break;
id = 100; case "horseskeleton":
meta = "1"; type = CMIEntityType.SKELETON_HORSE.getOneWordName();
break; id = 100;
case "horsezombie": meta = "1";
type = CMIEntityType.ZOMBIE_HORSE.getOneWordName(); break;
id = 100; case "horsezombie":
meta = "2"; type = CMIEntityType.ZOMBIE_HORSE.getOneWordName();
break; id = 100;
case "guardianelder": meta = "2";
type = CMIEntityType.ELDER_GUARDIAN.getOneWordName(); break;
id = 68; case "guardianelder":
meta = "1"; type = CMIEntityType.ELDER_GUARDIAN.getOneWordName();
break; id = 68;
meta = "1";
break;
}
} }
} else if (actionType == ActionType.ENCHANT) { } else if (actionType == ActionType.ENCHANT) {

View File

@ -1079,7 +1079,7 @@ public class JobsPaymentListener implements Listener {
double damage = lVictim.getMetadata(entityDamageByPlayer).get(0).asDouble(); double damage = lVictim.getMetadata(entityDamageByPlayer).get(0).asDouble();
double perc = (damage * 100D) / lVictim.getMaxHealth(); double perc = (damage * 100D) / lVictim.getMaxHealth();
if (perc < Jobs.getGCManager().MonsterDamagePercentage) if (perc < Jobs.getGCManager().MonsterDamagePercentage)
return; return;
} }
Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), e.getDamager(), lVictim); Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), e.getDamager(), lVictim);

View File

@ -20,22 +20,6 @@ public class v1_13 implements NMS {
@Override @Override
public String getRealType(Entity entity) { 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(); return entity.getType().name();
} }