Program: 41964
Project: 41964
Buggy source:
private org.bukkit.entity.Entity createEntity(IWorld world,Entity e,com.worldcretornica.plotme_core.api.Vector loc,int originX,int originY,int originZ){
  try {
    @SuppressWarnings("String_Node_Str") EntityType entitytype=EntityType.fromName(e.getId());
    org.bukkit.entity.Entity ent=null;
    if (entitytype != null && e.getPos() != null && e.getPos().size() == 3) {
      List<Double> positions=e.getPos();
      double x=positions.get(0) - originX;
      double y=positions.get(1) - originY;
      double z=positions.get(2) - originZ;
      Byte dir=e.getDir();
      byte onground=e.getOnGround();
      byte canpickuploot=e.getCanPickupLoot();
      byte color=e.getColor();
      byte customnamevisible=e.getCustomNameVisible();
      byte persistencerequired=e.getPersistenceRequired();
      byte sheared=e.getSheared();
      byte skeletontype=e.getSkeletonType();
      byte isbaby=e.getIsBaby();
      byte itemrotation=e.getItemRotation();
      byte agelocked=e.getAgeLocked();
      byte invisible=e.getInvisible();
      byte nobaseplate=e.getNoBasePlate();
      byte nogravity=e.getNoGravity();
      byte showarms=e.getShowArms();
      byte small=e.getSmall();
      byte elder=e.getElder();
      byte chestedhorse=e.getChestedHorse();
      byte tame=e.getTame();
      byte facing=e.getFacing();
      Entity riding=e.getRiding();
      float falldistance=e.getFallDistance();
      float healf=e.getHealF();
      int age=e.getAge();
      int hurtbytimestamp=e.getHurtByTimestamp();
      int rabbittype=e.getRabbitType();
      int temper=e.getTemper();
      int type=e.getType();
      int variant=e.getVariant();
      Item item=e.getItem();
      Leash leash=e.getLeash();
      Pose pose=e.getPose();
      short air=e.getAir();
      short fire=e.getFire();
      String motive=e.getMotive();
      String customname=e.getCustomName();
      String owneruuid=e.getOwnerUUID();
      List<Double> motion=e.getMotion();
      List<Attribute> attributes=e.getAttributes();
      Item itemheld=e.getItemHeld();
      Item feetarmor=e.getFeetArmor();
      Item legarmor=e.getLegArmor();
      Item chestarmor=e.getChestArmor();
      Item headarmor=e.getHeadArmor();
      List<Item> items=e.getItems();
      Location etloc=new Location(((BukkitWorld)world).getWorld(),x + loc.getBlockX(),y + loc.getBlockY(),z + loc.getBlockZ());
      if (entitytype == EntityType.ITEM_FRAME) {
        etloc.setX(Math.floor(etloc.getX()));
        etloc.setY(Math.floor(etloc.getY()));
        etloc.setZ(Math.floor(etloc.getZ()));
        ent=world.spawnEntity(etloc,EntityType.ITEM_FRAME);
      }
 else       if (entitytype == EntityType.PAINTING) {
        etloc.setX(Math.floor(etloc.getX()));
        etloc.setY(Math.floor(etloc.getY()));
        etloc.setZ(Math.floor(etloc.getZ()));
        ent=world.spawnEntity(etloc,EntityType.PAINTING);
        Painting painting=(Painting)ent;
        BlockFace bf=BlockFace.SOUTH;
switch (facing) {
case 0:
          bf=BlockFace.SOUTH;
        break;
case 1:
      bf=BlockFace.WEST;
    break;
case 2:
  bf=BlockFace.NORTH;
break;
case 3:
bf=BlockFace.EAST;
break;
}
painting.setArt(Art.getByName(motive),true);
painting.setFacingDirection(bf,true);
}
 else if (entitytype == EntityType.LEASH_HITCH) {
return null;
}
 else if (entitytype == EntityType.DROPPED_ITEM) {
if (item == null) {
return null;
}
 else {
@SuppressWarnings("String_Node_Str") ItemStack is=new ItemStack(item.getId(),item.getCount());
ItemTag itemtag=item.getTag();
if (itemtag != null) {
setTag(is,itemtag);
}
ent=((BukkitWorld)world).getWorld().dropItem(etloc,is);
}
}
 else {
ent=world.spawnEntity(etloc,entitytype);
}
if (riding != null) {
ent.setPassenger(createEntity(world,riding,loc,originX,originY,originZ));
}
ent.setFallDistance(falldistance);
ent.setFireTicks(fire);
ent.setTicksLived(age);
if (motion != null && motion.size() == 3) {
Vector velocity=new Vector(motion.get(0),motion.get(1),motion.get(2));
ent.setVelocity(velocity);
}
if (ent instanceof InventoryHolder) {
InventoryHolder ih=(InventoryHolder)ent;
Set<ItemStack> newitems=new HashSet<>();
if (items != null && !items.isEmpty()) {
for (Item newitem : items) {
ItemStack is=getItemStack(newitem);
ItemTag itemtag=newitem.getTag();
if (itemtag != null) {
setTag(is,itemtag);
}
newitems.add(is);
}
}
ih.getInventory().setContents(newitems.toArray(new ItemStack[newitems.size()]));
}
if (ent instanceof ItemFrame) {
ItemFrame itemframe=(ItemFrame)ent;
itemframe.setRotation(Rotation.values()[itemrotation]);
ItemStack is=getItemStack(item);
ItemTag itemtag=item.getTag();
if (itemtag != null) {
setTag(is,itemtag);
}
itemframe.setItem(is);
}
if (ent instanceof LivingEntity) {
LivingEntity livingentity=(LivingEntity)ent;
livingentity.setCanPickupItems(canpickuploot != 0);
if (customname != null) {
livingentity.setCustomName(customname);
}
livingentity.setCustomNameVisible(customnamevisible != 0);
livingentity.setRemainingAir(air);
livingentity.setRemoveWhenFarAway(persistencerequired == 0);
if (leash != null) {
org.bukkit.entity.Entity leashentity=getLeash(world,leash,loc,originX,originY,originZ);
if (leashentity != null) {
livingentity.setLeashHolder(leashentity);
}
}
livingentity.setNoDamageTicks(hurtbytimestamp);
if (livingentity.getMaxHealth() < healf) {
livingentity.setMaxHealth(healf);
}
livingentity.setHealth(healf);
EntityEquipment entityequipment=livingentity.getEquipment();
if (itemheld != null) {
entityequipment.setItemInHand(getItemStack(itemheld));
}
if (feetarmor != null) {
entityequipment.setBoots(getItemStack(feetarmor));
}
if (legarmor != null) {
entityequipment.setLeggings(getItemStack(legarmor));
}
if (chestarmor != null) {
entityequipment.setChestplate(getItemStack(chestarmor));
}
if (headarmor != null) {
entityequipment.setHelmet(getItemStack(headarmor));
}
if (livingentity instanceof Ageable) {
Ageable ageable=(Ageable)livingentity;
ageable.setAge(age);
ageable.setAgeLock(agelocked != 0);
if (isbaby != 0) {
ageable.setBaby();
}
 else {
ageable.setAdult();
}
}
if (livingentity instanceof Tameable) {
Tameable tameable=(Tameable)livingentity;
if (owneruuid != null) {
tameable.setOwner(Bukkit.getOfflinePlayer(UUID.fromString(owneruuid)));
}
tameable.setTamed(tame != 0);
}
if (livingentity instanceof Skeleton) {
Skeleton skeleton=(Skeleton)livingentity;
SkeletonType st;
if (skeletontype == 0) {
st=SkeletonType.NORMAL;
}
 else {
st=SkeletonType.WITHER;
}
skeleton.setSkeletonType(st);
}
 else if (livingentity instanceof Rabbit) {
Rabbit rabbit=(Rabbit)livingentity;
switch (rabbittype) {
case 0:
rabbit.setRabbitType(Rabbit.Type.BROWN);
break;
case 1:
rabbit.setRabbitType(Rabbit.Type.WHITE);
break;
case 2:
rabbit.setRabbitType(Rabbit.Type.BLACK);
break;
case 3:
rabbit.setRabbitType(Rabbit.Type.BLACK_AND_WHITE);
break;
case 4:
rabbit.setRabbitType(Rabbit.Type.GOLD);
break;
case 5:
rabbit.setRabbitType(Rabbit.Type.SALT_AND_PEPPER);
break;
case 99:
rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY);
break;
}
}
 else if (livingentity instanceof ArmorStand) {
ArmorStand armorstand=(ArmorStand)livingentity;
armorstand.setArms(showarms != 0);
armorstand.setBasePlate(nobaseplate == 0);
armorstand.setVisible(invisible == 0);
armorstand.setGravity(nogravity == 0);
armorstand.setSmall(small != 0);
if (pose != null) {
List<Float> body=pose.getBody();
List<Float> head=pose.getHead();
List<Float> leftarm=pose.getLeftArm();
List<Float> rightarm=pose.getRightArm();
List<Float> leftleg=pose.getLeftLeg();
List<Float> rightleg=pose.getRightLeg();
if (body != null && body.size() == 3) {
armorstand.setBodyPose(new EulerAngle(body.get(0),body.get(1),body.get(2)));
}
if (head != null && head.size() == 3) {
armorstand.setHeadPose(new EulerAngle(head.get(0),head.get(1),head.get(2)));
}
if (leftarm != null && leftarm.size() == 3) {
armorstand.setLeftArmPose(new EulerAngle(leftarm.get(0),leftarm.get(1),leftarm.get(2)));
}
if (rightarm != null && rightarm.size() == 3) {
armorstand.setRightArmPose(new EulerAngle(rightarm.get(0),rightarm.get(1),rightarm.get(2)));
}
if (leftleg != null && leftleg.size() == 3) {
armorstand.setLeftLegPose(new EulerAngle(leftleg.get(0),leftleg.get(1),leftleg.get(2)));
}
if (rightleg != null && rightleg.size() == 3) {
armorstand.setRightLegPose(new EulerAngle(rightleg.get(0),rightleg.get(1),rightleg.get(2)));
}
}
}
 else if (livingentity instanceof Guardian) {
Guardian guardian=(Guardian)livingentity;
guardian.setElder(elder != 0);
}
 else if (livingentity instanceof Sheep) {
Sheep sheep=(Sheep)livingentity;
sheep.setSheared(sheared != 0);
@SuppressWarnings("String_Node_Str") DyeColor dyecolor=DyeColor.getByWoolData(color);
if (dyecolor != null) {
sheep.setColor(dyecolor);
}
}
 else if (livingentity instanceof Horse) {
Horse horse=(Horse)livingentity;
if (attributes != null) {
for (Attribute attribute : attributes) {
if ("String_Node_Str".equalsIgnoreCase(attribute.getName())) {
horse.setJumpStrength(attribute.getBase());
}
}
}
horse.setCarryingChest(chestedhorse != 0);
horse.setDomestication(temper);
switch (variant) {
case 0:
horse.setVariant(Variant.HORSE);
break;
case 1:
horse.setVariant(Variant.DONKEY);
break;
case 2:
horse.setVariant(Variant.MULE);
break;
case 3:
horse.setVariant(Variant.UNDEAD_HORSE);
break;
case 4:
horse.setVariant(Variant.SKELETON_HORSE);
break;
}
if (type < 256) {
horse.setStyle(Style.NONE);
}
 else if (type < 512) {
horse.setStyle(Style.WHITE);
}
 else if (type < 768) {
horse.setStyle(Style.WHITEFIELD);
}
 else if (type < 1024) {
horse.setStyle(Style.WHITE_DOTS);
}
 else {
horse.setStyle(Style.BLACK_DOTS);
}
switch ((int)((double)type) % 256) {
case 0:
horse.setColor(Horse.Color.WHITE);
break;
case 1:
horse.setColor(Horse.Color.CREAMY);
break;
case 2:
horse.setColor(Horse.Color.CHESTNUT);
break;
case 3:
horse.setColor(Horse.Color.BROWN);
break;
case 4:
horse.setColor(Horse.Color.BLACK);
break;
case 5:
horse.setColor(Horse.Color.GRAY);
break;
case 6:
horse.setColor(Horse.Color.DARK_BROWN);
break;
}
}
}
}
if (ent == null) {
plugin.getLogger().info("String_Node_Str");
}
return ent;
}
 catch (IllegalArgumentException ex) {
plugin.getLogger().info("String_Node_Str");
ex.printStackTrace();
return null;
}
}

Fixed version (ground truth):
private org.bukkit.entity.Entity createEntity(IWorld world,Entity e,com.worldcretornica.plotme_core.api.Vector loc,int originX,int originY,int originZ){
  try {
    @SuppressWarnings("String_Node_Str") EntityType entitytype=EntityType.fromName(e.getId());
    org.bukkit.entity.Entity ent=null;
    if (entitytype != null && e.getPos() != null && e.getPos().size() == 3) {
      List<Double> positions=e.getPos();
      double x=positions.get(0) - originX;
      double y=positions.get(1) - originY;
      double z=positions.get(2) - originZ;
      Byte dir=e.getDir();
      byte onground=e.getOnGround();
      byte canpickuploot=e.getCanPickupLoot();
      byte color=e.getColor();
      byte customnamevisible=e.getCustomNameVisible();
      byte persistencerequired=e.getPersistenceRequired();
      byte sheared=e.getSheared();
      byte skeletontype=e.getSkeletonType();
      byte isbaby=e.getIsBaby();
      byte itemrotation=e.getItemRotation();
      byte agelocked=e.getAgeLocked();
      byte invisible=e.getInvisible();
      byte nobaseplate=e.getNoBasePlate();
      byte nogravity=e.getNoGravity();
      byte showarms=e.getShowArms();
      byte small=e.getSmall();
      byte elder=e.getElder();
      byte chestedhorse=e.getChestedHorse();
      byte tame=e.getTame();
      byte facing=e.getFacing();
      Entity riding=e.getRiding();
      float falldistance=e.getFallDistance();
      float healf=e.getHealF();
      int age=e.getAge();
      int hurtbytimestamp=e.getHurtByTimestamp();
      int rabbittype=e.getRabbitType();
      int temper=e.getTemper();
      int type=e.getType();
      int variant=e.getVariant();
      Item item=e.getItem();
      Leash leash=e.getLeash();
      Pose pose=e.getPose();
      short air=e.getAir();
      short fire=e.getFire();
      String motive=e.getMotive();
      String customname=e.getCustomName();
      String owneruuid=e.getOwnerUUID();
      List<Double> motion=e.getMotion();
      List<Attribute> attributes=e.getAttributes();
      Item itemheld=e.getItemHeld();
      Item feetarmor=e.getFeetArmor();
      Item legarmor=e.getLegArmor();
      Item chestarmor=e.getChestArmor();
      Item headarmor=e.getHeadArmor();
      List<Item> items=e.getItems();
      org.bukkit.Location etloc=new org.bukkit.Location(((BukkitWorld)world).getWorld(),x + loc.getBlockX(),y + loc.getBlockY(),z + loc.getBlockZ());
      if (entitytype == EntityType.ITEM_FRAME) {
        etloc.setX(Math.floor(etloc.getX()));
        etloc.setY(Math.floor(etloc.getY()));
        etloc.setZ(Math.floor(etloc.getZ()));
        ent=world.spawnEntity(etloc,EntityType.ITEM_FRAME);
      }
 else       if (entitytype == EntityType.PAINTING) {
        etloc.setX(Math.floor(etloc.getX()));
        etloc.setY(Math.floor(etloc.getY()));
        etloc.setZ(Math.floor(etloc.getZ()));
        ent=world.spawnEntity(etloc,EntityType.PAINTING);
        Painting painting=(Painting)ent;
        BlockFace bf=BlockFace.SOUTH;
switch (facing) {
case 0:
          bf=BlockFace.SOUTH;
        break;
case 1:
      bf=BlockFace.WEST;
    break;
case 2:
  bf=BlockFace.NORTH;
break;
case 3:
bf=BlockFace.EAST;
break;
}
painting.setArt(Art.getByName(motive),true);
painting.setFacingDirection(bf,true);
}
 else if (entitytype == EntityType.LEASH_HITCH) {
return null;
}
 else if (entitytype == EntityType.DROPPED_ITEM) {
if (item == null) {
return null;
}
 else {
@SuppressWarnings("String_Node_Str") ItemStack is=new ItemStack(item.getId(),item.getCount());
ItemTag itemtag=item.getTag();
if (itemtag != null) {
setTag(is,itemtag);
}
ent=((BukkitWorld)world).getWorld().dropItem(etloc,is);
}
}
 else {
ent=world.spawnEntity(etloc,entitytype);
}
if (riding != null) {
ent.setPassenger(createEntity(world,riding,loc,originX,originY,originZ));
}
ent.setFallDistance(falldistance);
ent.setFireTicks(fire);
ent.setTicksLived(age);
if (motion != null && motion.size() == 3) {
Vector velocity=new Vector(motion.get(0),motion.get(1),motion.get(2));
ent.setVelocity(velocity);
}
if (ent instanceof InventoryHolder) {
InventoryHolder ih=(InventoryHolder)ent;
Set<ItemStack> newitems=new HashSet<>();
if (items != null && !items.isEmpty()) {
for (Item newitem : items) {
ItemStack is=getItemStack(newitem);
ItemTag itemtag=newitem.getTag();
if (itemtag != null) {
setTag(is,itemtag);
}
newitems.add(is);
}
}
ih.getInventory().setContents(newitems.toArray(new ItemStack[newitems.size()]));
}
if (ent instanceof ItemFrame) {
ItemFrame itemframe=(ItemFrame)ent;
itemframe.setRotation(Rotation.values()[itemrotation]);
ItemStack is=getItemStack(item);
ItemTag itemtag=item.getTag();
if (itemtag != null) {
setTag(is,itemtag);
}
itemframe.setItem(is);
}
if (ent instanceof LivingEntity) {
LivingEntity livingentity=(LivingEntity)ent;
livingentity.setCanPickupItems(canpickuploot != 0);
if (customname != null) {
livingentity.setCustomName(customname);
}
livingentity.setCustomNameVisible(customnamevisible != 0);
livingentity.setRemainingAir(air);
livingentity.setRemoveWhenFarAway(persistencerequired == 0);
if (leash != null) {
org.bukkit.entity.Entity leashentity=getLeash(world,leash,loc,originX,originY,originZ);
if (leashentity != null) {
livingentity.setLeashHolder(leashentity);
}
}
livingentity.setNoDamageTicks(hurtbytimestamp);
if (livingentity.getMaxHealth() < healf) {
livingentity.setMaxHealth(healf);
}
livingentity.setHealth(healf);
EntityEquipment entityequipment=livingentity.getEquipment();
if (itemheld != null) {
entityequipment.setItemInHand(getItemStack(itemheld));
}
if (feetarmor != null) {
entityequipment.setBoots(getItemStack(feetarmor));
}
if (legarmor != null) {
entityequipment.setLeggings(getItemStack(legarmor));
}
if (chestarmor != null) {
entityequipment.setChestplate(getItemStack(chestarmor));
}
if (headarmor != null) {
entityequipment.setHelmet(getItemStack(headarmor));
}
if (livingentity instanceof Ageable) {
Ageable ageable=(Ageable)livingentity;
ageable.setAge(age);
ageable.setAgeLock(agelocked != 0);
if (isbaby != 0) {
ageable.setBaby();
}
 else {
ageable.setAdult();
}
}
if (livingentity instanceof Tameable) {
Tameable tameable=(Tameable)livingentity;
if (owneruuid != null) {
tameable.setOwner(Bukkit.getOfflinePlayer(UUID.fromString(owneruuid)));
}
tameable.setTamed(tame != 0);
}
if (livingentity instanceof Skeleton) {
Skeleton skeleton=(Skeleton)livingentity;
SkeletonType st;
if (skeletontype == 0) {
st=SkeletonType.NORMAL;
}
 else {
st=SkeletonType.WITHER;
}
skeleton.setSkeletonType(st);
}
 else if (livingentity instanceof Rabbit) {
Rabbit rabbit=(Rabbit)livingentity;
switch (rabbittype) {
case 0:
rabbit.setRabbitType(Rabbit.Type.BROWN);
break;
case 1:
rabbit.setRabbitType(Rabbit.Type.WHITE);
break;
case 2:
rabbit.setRabbitType(Rabbit.Type.BLACK);
break;
case 3:
rabbit.setRabbitType(Rabbit.Type.BLACK_AND_WHITE);
break;
case 4:
rabbit.setRabbitType(Rabbit.Type.GOLD);
break;
case 5:
rabbit.setRabbitType(Rabbit.Type.SALT_AND_PEPPER);
break;
case 99:
rabbit.setRabbitType(Rabbit.Type.THE_KILLER_BUNNY);
break;
}
}
 else if (livingentity instanceof ArmorStand) {
ArmorStand armorstand=(ArmorStand)livingentity;
armorstand.setArms(showarms != 0);
armorstand.setBasePlate(nobaseplate == 0);
armorstand.setVisible(invisible == 0);
armorstand.setGravity(nogravity == 0);
armorstand.setSmall(small != 0);
if (pose != null) {
List<Float> body=pose.getBody();
List<Float> head=pose.getHead();
List<Float> leftarm=pose.getLeftArm();
List<Float> rightarm=pose.getRightArm();
List<Float> leftleg=pose.getLeftLeg();
List<Float> rightleg=pose.getRightLeg();
if (body != null && body.size() == 3) {
armorstand.setBodyPose(new EulerAngle(body.get(0),body.get(1),body.get(2)));
}
if (head != null && head.size() == 3) {
armorstand.setHeadPose(new EulerAngle(head.get(0),head.get(1),head.get(2)));
}
if (leftarm != null && leftarm.size() == 3) {
armorstand.setLeftArmPose(new EulerAngle(leftarm.get(0),leftarm.get(1),leftarm.get(2)));
}
if (rightarm != null && rightarm.size() == 3) {
armorstand.setRightArmPose(new EulerAngle(rightarm.get(0),rightarm.get(1),rightarm.get(2)));
}
if (leftleg != null && leftleg.size() == 3) {
armorstand.setLeftLegPose(new EulerAngle(leftleg.get(0),leftleg.get(1),leftleg.get(2)));
}
if (rightleg != null && rightleg.size() == 3) {
armorstand.setRightLegPose(new EulerAngle(rightleg.get(0),rightleg.get(1),rightleg.get(2)));
}
}
}
 else if (livingentity instanceof Guardian) {
Guardian guardian=(Guardian)livingentity;
guardian.setElder(elder != 0);
}
 else if (livingentity instanceof Sheep) {
Sheep sheep=(Sheep)livingentity;
sheep.setSheared(sheared != 0);
@SuppressWarnings("String_Node_Str") DyeColor dyecolor=DyeColor.getByWoolData(color);
if (dyecolor != null) {
sheep.setColor(dyecolor);
}
}
 else if (livingentity instanceof Horse) {
Horse horse=(Horse)livingentity;
if (attributes != null) {
for (Attribute attribute : attributes) {
if ("String_Node_Str".equalsIgnoreCase(attribute.getName())) {
horse.setJumpStrength(attribute.getBase());
}
}
}
horse.setCarryingChest(chestedhorse != 0);
horse.setDomestication(temper);
switch (variant) {
case 0:
horse.setVariant(Variant.HORSE);
break;
case 1:
horse.setVariant(Variant.DONKEY);
break;
case 2:
horse.setVariant(Variant.MULE);
break;
case 3:
horse.setVariant(Variant.UNDEAD_HORSE);
break;
case 4:
horse.setVariant(Variant.SKELETON_HORSE);
break;
}
if (type < 256) {
horse.setStyle(Style.NONE);
}
 else if (type < 512) {
horse.setStyle(Style.WHITE);
}
 else if (type < 768) {
horse.setStyle(Style.WHITEFIELD);
}
 else if (type < 1024) {
horse.setStyle(Style.WHITE_DOTS);
}
 else {
horse.setStyle(Style.BLACK_DOTS);
}
switch ((int)((double)type) % 256) {
case 0:
horse.setColor(Horse.Color.WHITE);
break;
case 1:
horse.setColor(Horse.Color.CREAMY);
break;
case 2:
horse.setColor(Horse.Color.CHESTNUT);
break;
case 3:
horse.setColor(Horse.Color.BROWN);
break;
case 4:
horse.setColor(Horse.Color.BLACK);
break;
case 5:
horse.setColor(Horse.Color.GRAY);
break;
case 6:
horse.setColor(Horse.Color.DARK_BROWN);
break;
}
}
}
}
if (ent == null) {
plugin.getLogger().info("String_Node_Str");
}
return ent;
}
 catch (IllegalArgumentException ex) {
plugin.getLogger().info("String_Node_Str");
ex.printStackTrace();
return null;
}
}