Fixes EffSetPathGoal not working correctly.

Also fixes some unhandled exceptions and a loop that was breaking when
it wasn't supposed to.
This commit is contained in:
TheBukor 2016-12-14 14:14:34 -02:00
parent f784116a82
commit 6bdfc3196e
11 changed files with 33 additions and 19 deletions

View File

@ -9,11 +9,11 @@
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/Skript.jar"/> <classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/Skript.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/VanishNoPacket.jar"/> <classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/VanishNoPacket.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/WorldEdit.jar"/> <classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/WorldEdit.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/WorldGuard.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/ProtocolLib.jar"/> <classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/ProtocolLib.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.9.4.jar"/> <classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.9.4.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.9.jar"/> <classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.9.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.10.jar"/> <classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.10.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.11.jar"/> <classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.11.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/WorldGuard1.11.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

1
bin/.gitignore vendored
View File

@ -1 +1,2 @@
/me/ /me/
/org/

View File

@ -152,6 +152,7 @@ public class SkStuff extends JavaPlugin {
getLogger().info("Trying to register version specific stuff..."); getLogger().info("Trying to register version specific stuff...");
Skript.registerEffect(EffClearPathGoals.class, "(clear|delete) [all] pathfind[er] goals (of|from) %livingentities%"); Skript.registerEffect(EffClearPathGoals.class, "(clear|delete) [all] pathfind[er] goals (of|from) %livingentities%");
Skript.registerEffect(EffRemovePathGoal.class, "remove pathfind[er] goal (0¦(avoid|run away from) entit(y|ies)|1¦break door[s]|2¦breed|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))|5¦float (in[side]|on) water|6¦follow (owner|tamer)|7¦follow (adult|parent)[s]|8¦(fight back|react to|target) (damager|attacker)|9¦o(c|z)elot jump on blocks|10¦leap at target|11¦look at entit(y|ies)|12¦melee attack entit(y|ies)|13¦move to[wards] target|14¦target nearest entity|15¦o(c|z)elot attack [chicken[s]]|16¦open door[s]|17¦(panic|flee)|18¦look around randomly|19¦(walk around randomly|wander)|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦(wake other silverfish[es]|[silverfish] call (help|reinforcement|other [hidden] silverfish[es]))|26¦[enderm(a|e)n] pick[[ ]up] block[s]|27¦[enderm(a|e)n] place block[s]|28¦[enderman] attack player (staring|looking) [at eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) [a[n]] item|32¦target [random] entity (if|when) (not tamed|untamed)|33¦guardian attack [entity]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow [entity]|42¦bow shoot) from %livingentities%"); Skript.registerEffect(EffRemovePathGoal.class, "remove pathfind[er] goal (0¦(avoid|run away from) entit(y|ies)|1¦break door[s]|2¦breed|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))|5¦float (in[side]|on) water|6¦follow (owner|tamer)|7¦follow (adult|parent)[s]|8¦(fight back|react to|target) (damager|attacker)|9¦o(c|z)elot jump on blocks|10¦leap at target|11¦look at entit(y|ies)|12¦melee attack entit(y|ies)|13¦move to[wards] target|14¦target nearest entity|15¦o(c|z)elot attack [chicken[s]]|16¦open door[s]|17¦(panic|flee)|18¦look around randomly|19¦(walk around randomly|wander)|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦(wake other silverfish[es]|[silverfish] call (help|reinforcement|other [hidden] silverfish[es]))|26¦[enderm(a|e)n] pick[[ ]up] block[s]|27¦[enderm(a|e)n] place block[s]|28¦[enderman] attack player (staring|looking) [at eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) [a[n]] item|32¦target [random] entity (if|when) (not tamed|untamed)|33¦guardian attack [entity]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow [entity]|42¦bow shoot) from %livingentities%");
// Note to self: whenever adding a new pathfinder goal, increase the expression index for 'entities' in EffSetPathGoal
Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %*entitydatas%[, radius %-number%[, speed %-number%[, speed (if|when) (close|near) %-number%]]]|1¦break door[s]|2¦breed[,[move[ment]] speed %-number%]|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))[, [move[ment]] speed %-number%]|5¦(float (in[side]|on) water|swim)|6¦follow (owner|tamer)[, speed %-number%[, min[imum] distance %-number%[, max[imum] distance %-number%]]]|7¦follow (adult|parent)[s][, [move[ment]] speed %-number%]|8¦(fight back|react to|target) (damager|attacker) [[of] type] %*entitydatas%[, call ([for] help|reinforcement) %-boolean%]|9¦o(c|z)elot jump on blocks[, [move[ment]] speed %-number%]|10¦leap at target[, [leap] height %-number%]|11¦look at %*entitydatas%[, (radius|max[imum] distance) %-number%]|12¦melee attack %*entitydatas%[, [move[ment]] speed %-number%[, (memorize|do('nt| not) forget) target [for [a] long[er] time] %-boolean%]]|13¦move to[wards] target[, [move[ment]] speed %-number%[, (radius|max[imum] distance) %-number%]]|14¦target nearest [entity [of] type] %*entitydatas%[, check sight %-boolean%]|15¦o(c|z)elot attack|16¦open door[s]|17¦(panic|flee)[, [move[ment]] speed %-number%]|18¦look around randomly|19¦(walk around randomly|wander)[, [move[ment]] speed %-number%[, min[imum] [of] %-timespan% between mov(e[ment][s]|ing)]]|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim around|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦((call|summon|wake) [other] [hidden] silverfish[es])|26¦[enderman] pick[[ ]up] block[s]|27¦[enderman] place block[s]|28¦[enderman] attack player (staring|looking) at [their] eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) %-itemstack%[, [move[ment]] speed %number%[, scared of player movement %-boolean%]]|32¦target [random] %*entitydatas% (if|when) (not |un)tamed|33¦guardian attack [entities]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow %*entitydatas%[, radius %-number%[, speed %-number%[, [custom[ ]]name[d] %-string%]]]|42¦bow shoot[, [move[ment]] speed %-number%[, unk[nown] param[eter] %-number%[, follow range %-number%]]])) to %livingentities%"); Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %*entitydatas%[, radius %-number%[, speed %-number%[, speed (if|when) (close|near) %-number%]]]|1¦break door[s]|2¦breed[,[move[ment]] speed %-number%]|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))[, [move[ment]] speed %-number%]|5¦(float (in[side]|on) water|swim)|6¦follow (owner|tamer)[, speed %-number%[, min[imum] distance %-number%[, max[imum] distance %-number%]]]|7¦follow (adult|parent)[s][, [move[ment]] speed %-number%]|8¦(fight back|react to|target) (damager|attacker) [[of] type] %*entitydatas%[, call ([for] help|reinforcement) %-boolean%]|9¦o(c|z)elot jump on blocks[, [move[ment]] speed %-number%]|10¦leap at target[, [leap] height %-number%]|11¦look at %*entitydatas%[, (radius|max[imum] distance) %-number%]|12¦melee attack %*entitydatas%[, [move[ment]] speed %-number%[, (memorize|do('nt| not) forget) target [for [a] long[er] time] %-boolean%]]|13¦move to[wards] target[, [move[ment]] speed %-number%[, (radius|max[imum] distance) %-number%]]|14¦target nearest [entity [of] type] %*entitydatas%[, check sight %-boolean%]|15¦o(c|z)elot attack|16¦open door[s]|17¦(panic|flee)[, [move[ment]] speed %-number%]|18¦look around randomly|19¦(walk around randomly|wander)[, [move[ment]] speed %-number%[, min[imum] [of] %-timespan% between mov(e[ment][s]|ing)]]|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim around|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦((call|summon|wake) [other] [hidden] silverfish[es])|26¦[enderman] pick[[ ]up] block[s]|27¦[enderman] place block[s]|28¦[enderman] attack player (staring|looking) at [their] eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) %-itemstack%[, [move[ment]] speed %number%[, scared of player movement %-boolean%]]|32¦target [random] %*entitydatas% (if|when) (not |un)tamed|33¦guardian attack [entities]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow %*entitydatas%[, radius %-number%[, speed %-number%[, [custom[ ]]name[d] %-string%]]]|42¦bow shoot[, [move[ment]] speed %-number%[, unk[nown] param[eter] %-number%[, follow range %-number%]]])) to %livingentities%");
Skript.registerEffect(EffMakeJump.class, "make %livingentities% jump", "force %livingentities% to jump"); Skript.registerEffect(EffMakeJump.class, "make %livingentities% jump", "force %livingentities% to jump");
Skript.registerEffect(EffGZipFile.class, "create [a] gzip[ped] file [at] [path] %string%"); Skript.registerEffect(EffGZipFile.class, "create [a] gzip[ped] file [at] [path] %string%");

View File

@ -32,9 +32,9 @@ public class EffClearPathGoals extends Effect {
protected void execute(Event e) { protected void execute(Event e) {
LivingEntity[] ents = entities.getAll(e); LivingEntity[] ents = entities.getAll(e);
for (LivingEntity ent : ents) { for (LivingEntity ent : ents) {
if (ent instanceof Player || ent instanceof ArmorStand || ent == null) if (!(ent instanceof Player || ent instanceof ArmorStand || ent == null)) {
continue; SkStuff.getNMSMethods().clearPathfinderGoals(ent);
SkStuff.getNMSMethods().clearPathfinderGoals(ent); }
} }
} }
} }

View File

@ -38,15 +38,15 @@ public class EffMakeJump extends Effect {
protected void execute(Event e) { protected void execute(Event e) {
LivingEntity[] ents = entities.getAll(e); LivingEntity[] ents = entities.getAll(e);
for (Entity ent : ents) { for (Entity ent : ents) {
if (ent == null || ent instanceof Player || ent instanceof ArmorStand) if (!(ent == null || ent instanceof Player || ent instanceof ArmorStand)) {
continue; Object obcEnt = craftLivEnt.cast(ent);
Object obcEnt = craftLivEnt.cast(ent); try {
try { Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt)); Object controllerJump = nmsEnt.getClass().getMethod("getControllerJump").invoke(nmsEnt);
Object controllerJump = nmsEnt.getClass().getMethod("getControllerJump").invoke(nmsEnt); controllerJump.getClass().getMethod("a").invoke(controllerJump);
controllerJump.getClass().getMethod("a").invoke(controllerJump); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) { ex.printStackTrace();
ex.printStackTrace(); }
} }
} }
} }

View File

@ -49,8 +49,9 @@ public class EffRemovePathGoal extends Effect {
protected void execute(Event e) { protected void execute(Event e) {
LivingEntity[] ents = entities.getAll(e); LivingEntity[] ents = entities.getAll(e);
for (LivingEntity ent : ents) { for (LivingEntity ent : ents) {
if (ent instanceof Player || ent instanceof ArmorStand || ent == null) if (ent instanceof Player || ent instanceof ArmorStand || ent == null) {
return; return;
}
Object obcEnt = craftLivEnt.cast(ent); Object obcEnt = craftLivEnt.cast(ent);
Object nmsEnt = null; Object nmsEnt = null;
try { try {

View File

@ -157,7 +157,7 @@ public class EffSetPathGoal extends Effect {
bowShootUnkParam = (Expression<Number>) expr[36]; bowShootUnkParam = (Expression<Number>) expr[36];
bowShootFollowRange = (Expression<Number>) expr[37]; bowShootFollowRange = (Expression<Number>) expr[37];
} }
entities = (Expression<LivingEntity>) expr[35]; entities = (Expression<LivingEntity>) expr[38];
return true; return true;
} }
@ -169,7 +169,7 @@ public class EffSetPathGoal extends Effect {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
protected void execute(Event e) { protected void execute(Event e) {
LivingEntity[] ents = entities.getAll(e); LivingEntity[] ents = entities.getAll(e);
for (LivingEntity ent : ents) { for (LivingEntity ent : ents) {
if (ent == null || ent instanceof Player || ent instanceof ArmorStand) if (ent == null || ent instanceof Player || ent instanceof ArmorStand)
return; return;

View File

@ -41,6 +41,9 @@ public class ExprLastLocation extends SimpleExpression<Location> {
@Nullable @Nullable
protected Location[] get(Event e) { protected Location[] get(Event e) {
Entity ent = entity.getSingle(e); Entity ent = entity.getSingle(e);
return new Location[] { SkStuff.getNMSMethods().getLastLocation(ent) }; if (ent == null) {
return null;
}
return new Location[] { SkStuff.getNMSMethods().getLastLocation(ent) };
} }
} }

View File

@ -42,6 +42,9 @@ public class ExprMCIdOf extends SimpleExpression<String> {
@Nullable @Nullable
protected String[] get(Event e) { protected String[] get(Event e) {
ItemType type = itemType.getSingle(e); ItemType type = itemType.getSingle(e);
if (type == null) {
return null;
}
ItemStack item = new ItemStack(type.getTypes().get(0).getId()); ItemStack item = new ItemStack(type.getTypes().get(0).getId());
return new String[] { SkStuff.getNMSMethods().getMCId(item) }; return new String[] { SkStuff.getNMSMethods().getMCId(item) };
} }

View File

@ -40,6 +40,9 @@ public class ExprMCIdToItem extends SimpleExpression<ItemStack> {
@Nullable @Nullable
protected ItemStack[] get(Event e) { protected ItemStack[] get(Event e) {
String id = mcId.getSingle(e); String id = mcId.getSingle(e);
if (id == null) {
return null;
}
return new ItemStack[] { SkStuff.getNMSMethods().getItemFromMcId(id) }; return new ItemStack[] { SkStuff.getNMSMethods().getItemFromMcId(id) };
} }

View File

@ -42,16 +42,18 @@ public class ExprStepLength extends SimpleExpression<Number> {
@Nullable @Nullable
protected Number[] get(Event e) { protected Number[] get(Event e) {
Entity ent = entity.getSingle(e); Entity ent = entity.getSingle(e);
if (ent == null) if (ent == null) {
return null; return null;
}
return new Number[] { SkStuff.getNMSMethods().getEntityStepLength(ent) }; return new Number[] { SkStuff.getNMSMethods().getEntityStepLength(ent) };
} }
@Override @Override
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) { public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
Entity ent = entity.getSingle(e); Entity ent = entity.getSingle(e);
if (ent == null) if (ent == null) {
return; return;
}
if (mode == ChangeMode.ADD) { if (mode == ChangeMode.ADD) {
float toAdd = ((Number) delta[0]).floatValue(); float toAdd = ((Number) delta[0]).floatValue();
float currentLength = SkStuff.getNMSMethods().getEntityStepLength(ent); float currentLength = SkStuff.getNMSMethods().getEntityStepLength(ent);