Fixed a bug preventing wandering traders from granting XP

This commit is contained in:
nossr50 2019-07-05 05:51:41 -07:00
parent 02c1ce749c
commit 304a942f51
3 changed files with 34 additions and 8 deletions

View File

@ -1,3 +1,6 @@
Version 2.1.95
Fixed a bug preventing Wandering Traders from granting XP
Version 2.1.94
2 new devs have joined the mcMMO team (electronicboy, kashike), bringing the active dev team to 3 including myself! Strings relating to authors of mcMMO have been updated to reflect this
Fixed a bug where 2 people using Tree Feller could result in the tree being rejected for being too big

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.94</version>
<version>2.1.95-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>

View File

@ -40,17 +40,40 @@ public final class Misc {
private Misc() {};
/**
* Determines if an entity is an NPC but not a villager
* This method aims to establish compatibility between mcMMO and other plugins which create "NPCs"
*
* It does this by checking the following
* 1) The entity is not a Villager
* 2) The entity can be considered an NPC
*
* In this context, an NPC is a bit hard to define. Various plugins determine what an NPC is in different ways.
* @see Misc::isNPCIncludingVillagers
* @param entity target entity
* @return true if the entity is not a Villager and is not a "NPC"
*/
public static boolean isNPCEntityExcludingVillagers(Entity entity) {
return (entity == null
|| (entity.hasMetadata("NPC") && !(entity instanceof Villager))
|| (entity instanceof NPC && !(entity instanceof Villager))
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
return (!isVillager(entity)
&& isNPCIncludingVillagers(entity)); //Compatibility with some mod..
}
public static boolean isNPCIncludingVillagers(Player entity) {
public static boolean isNPCClassType(Entity entity) {
return entity instanceof NPC;
}
public static boolean hasNPCMetadataTag(Entity entity) {
return entity.hasMetadata("NPC");
}
public static boolean isVillager(Entity entity) {
return (entity instanceof AbstractVillager);
}
public static boolean isNPCIncludingVillagers(Entity entity) {
return (entity == null
|| (entity.hasMetadata("NPC"))
|| (entity instanceof NPC)
|| (hasNPCMetadataTag(entity))
|| (isNPCClassType(entity))
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
}