Fix Citizens mob signs with latest builds; resolves #1071

This commit is contained in:
Daniel Saukel 2022-01-08 22:54:48 +01:00
parent 961906d4d6
commit b838414c0b
2 changed files with 6 additions and 14 deletions

View File

@ -17,6 +17,7 @@
package de.erethon.dungeonsxl.mob;
import de.erethon.caliburn.mob.ExMob;
import de.erethon.caliburn.mob.VanillaMob;
import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.dungeon.GameRule;
import de.erethon.dungeonsxl.api.event.mob.DungeonMobDeathEvent;
@ -45,9 +46,9 @@ public class DMob implements DungeonMob {
public DMob(LivingEntity entity, GameWorld gameWorld, ExMob type, String trigger) {
this.entity = entity;
this.type = type;
this.type = type != null ? type : VanillaMob.get(entity.getType());
if (!getDrops(gameWorld.getDungeon().getRules().getState(GameRule.MOB_ITEM_DROPS))) {
if (this.type != VanillaMob.PLAYER && !getDrops(gameWorld.getDungeon().getRules().getState(GameRule.MOB_ITEM_DROPS))) {
entity.getEquipment().setHelmetDropChance(0);
entity.getEquipment().setChestplateDropChance(0);
entity.getEquipment().setLeggingsDropChance(0);

View File

@ -16,8 +16,6 @@
*/
package de.erethon.dungeonsxl.mob;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.UUID;
import net.citizensnpcs.Settings.Setting;
@ -31,6 +29,8 @@ import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.trait.MobType;
import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.api.util.MemoryDataKey;
import net.citizensnpcs.npc.CitizensNPC;
import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.trait.ArmorStandTrait;
import net.citizensnpcs.trait.LookClose;
import net.citizensnpcs.trait.MountTrait;
@ -50,16 +50,7 @@ public class DNPCRegistry implements NPCRegistry {
@Override
public NPC createNPC(EntityType type, UUID uuid, int id, String name) {
NPC npc = null;
try {
Method method = CitizensAPI.getNPCRegistry().getClass().getDeclaredMethod("getByType", EntityType.class, UUID.class, int.class, String.class);
method.setAccessible(true);
npc = (NPC) method.invoke(CitizensAPI.getNPCRegistry(), type, uuid, id, name);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) {
throw new IllegalStateException("Could not create NPC: " + exception.getClass().getSimpleName());
}
NPC npc = new CitizensNPC(uuid, id, name, EntityControllers.createForType(type), this);
if (npc == null) {
throw new IllegalStateException("Could not create NPC: npc is null");
}