Permalink
Browse files

Re-add get|set_mob_target()

  • Loading branch information...
PseudoKnight committed Aug 11, 2018
1 parent 421fe5e commit 1a6b478b64a928db37bf42a43275fafa8da2285a
@@ -15,9 +15,9 @@
import com.laytonsmith.core.exceptions.CRE.CREBadEntityException;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@@ -291,10 +291,10 @@ public void setRemoveWhenFarAway(boolean remove) {
@Override
public MCLivingEntity getTarget(Target t) {
if(!(le instanceof Creature)) {
throw new CREBadEntityException("This type of mob does not have a target API", t);
if(!(le instanceof Mob)) {
throw new CREBadEntityException("This type of entity does not have a target API", t);
}
LivingEntity target = ((Creature) le).getTarget();
LivingEntity target = ((Mob) le).getTarget();
if(target == null) {
return null;
}
@@ -303,13 +303,13 @@ public MCLivingEntity getTarget(Target t) {
@Override
public void setTarget(MCLivingEntity target, Target t) {
if(!(le instanceof Creature)) {
throw new CREBadEntityException("This type of mob does not have a target API", t);
if(!(le instanceof Mob)) {
throw new CREBadEntityException("This type of entity not have a target API", t);
}
if(target == null) {
((Creature) le).setTarget(null);
((Mob) le).setTarget(null);
} else {
((Creature) le).setTarget(((BukkitMCLivingEntity) target).asLivingEntity());
((Mob) le).setTarget(((BukkitMCLivingEntity) target).asLivingEntity());
}
}
@@ -747,12 +747,11 @@ public CHVersion since() {
}
}
//@api
@api
public static class get_mob_target extends EntityManagement.EntityGetterFunction {
@Override
public Construct exec(Target t, Environment environment,
Construct... args) throws ConfigRuntimeException {
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
MCLivingEntity le = Static.getLivingEntity(args[0], t);
if(le.getTarget(t) == null) {
return CNull.NULL;
@@ -769,7 +768,7 @@ public String getName() {
@Override
public String docs() {
return "entityID {entityID} Gets the mob's target if it has one, and returns the target's entityID."
+ " If there is no target, null is returned instead.";
+ " If there is no target, null is returned instead. Not all mobs will have a returnable target.";
}
@Override
@@ -778,7 +777,7 @@ public CHVersion since() {
}
}
//@api
@api
public static class set_mob_target extends EntityManagement.EntitySetterFunction {
@Override
@@ -804,8 +803,8 @@ public String getName() {
@Override
public String docs() {
return "void {entityID, entityID} The first ID is the entity who is targetting, the second is the target."
+ " It can also be set to null to clear the current target.";
return "void {entityID, entityID} The first ID is the entity that is targeting, the second is the target."
+ " It can also be set to null to clear the current target. Not all mobs can have their target set.";
}
@Override

0 comments on commit 1a6b478

Please sign in to comment.