diff --git a/.classpath b/.classpath index fd37ca7..67339e1 100644 --- a/.classpath +++ b/.classpath @@ -9,11 +9,11 @@ - + diff --git a/bin/.gitignore b/bin/.gitignore index 4060509..24cb195 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1 +1,2 @@ /me/ +/org/ diff --git a/src/me/TheBukor/SkStuff/SkStuff.java b/src/me/TheBukor/SkStuff/SkStuff.java index cbea301..77cf293 100644 --- a/src/me/TheBukor/SkStuff/SkStuff.java +++ b/src/me/TheBukor/SkStuff/SkStuff.java @@ -152,6 +152,7 @@ public class SkStuff extends JavaPlugin { getLogger().info("Trying to register version specific stuff..."); 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%"); + // 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(EffMakeJump.class, "make %livingentities% jump", "force %livingentities% to jump"); Skript.registerEffect(EffGZipFile.class, "create [a] gzip[ped] file [at] [path] %string%"); diff --git a/src/me/TheBukor/SkStuff/effects/EffClearPathGoals.java b/src/me/TheBukor/SkStuff/effects/EffClearPathGoals.java index 68eafd5..8b4f529 100644 --- a/src/me/TheBukor/SkStuff/effects/EffClearPathGoals.java +++ b/src/me/TheBukor/SkStuff/effects/EffClearPathGoals.java @@ -32,9 +32,9 @@ public class EffClearPathGoals extends Effect { protected void execute(Event e) { LivingEntity[] ents = entities.getAll(e); for (LivingEntity ent : ents) { - if (ent instanceof Player || ent instanceof ArmorStand || ent == null) - continue; - SkStuff.getNMSMethods().clearPathfinderGoals(ent); + if (!(ent instanceof Player || ent instanceof ArmorStand || ent == null)) { + SkStuff.getNMSMethods().clearPathfinderGoals(ent); + } } } } \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/effects/EffMakeJump.java b/src/me/TheBukor/SkStuff/effects/EffMakeJump.java index b4def6e..a0ef7f4 100644 --- a/src/me/TheBukor/SkStuff/effects/EffMakeJump.java +++ b/src/me/TheBukor/SkStuff/effects/EffMakeJump.java @@ -38,15 +38,15 @@ public class EffMakeJump extends Effect { protected void execute(Event e) { LivingEntity[] ents = entities.getAll(e); for (Entity ent : ents) { - if (ent == null || ent instanceof Player || ent instanceof ArmorStand) - continue; - Object obcEnt = craftLivEnt.cast(ent); - try { - Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt)); - Object controllerJump = nmsEnt.getClass().getMethod("getControllerJump").invoke(nmsEnt); - controllerJump.getClass().getMethod("a").invoke(controllerJump); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) { - ex.printStackTrace(); + if (!(ent == null || ent instanceof Player || ent instanceof ArmorStand)) { + Object obcEnt = craftLivEnt.cast(ent); + try { + Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt)); + Object controllerJump = nmsEnt.getClass().getMethod("getControllerJump").invoke(nmsEnt); + controllerJump.getClass().getMethod("a").invoke(controllerJump); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) { + ex.printStackTrace(); + } } } } diff --git a/src/me/TheBukor/SkStuff/effects/EffRemovePathGoal.java b/src/me/TheBukor/SkStuff/effects/EffRemovePathGoal.java index f833b49..1e444bc 100644 --- a/src/me/TheBukor/SkStuff/effects/EffRemovePathGoal.java +++ b/src/me/TheBukor/SkStuff/effects/EffRemovePathGoal.java @@ -49,8 +49,9 @@ public class EffRemovePathGoal extends Effect { protected void execute(Event e) { LivingEntity[] ents = entities.getAll(e); for (LivingEntity ent : ents) { - if (ent instanceof Player || ent instanceof ArmorStand || ent == null) + if (ent instanceof Player || ent instanceof ArmorStand || ent == null) { return; + } Object obcEnt = craftLivEnt.cast(ent); Object nmsEnt = null; try { diff --git a/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java b/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java index d6760ff..021533d 100644 --- a/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java +++ b/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java @@ -157,7 +157,7 @@ public class EffSetPathGoal extends Effect { bowShootUnkParam = (Expression) expr[36]; bowShootFollowRange = (Expression) expr[37]; } - entities = (Expression) expr[35]; + entities = (Expression) expr[38]; return true; } @@ -169,7 +169,7 @@ public class EffSetPathGoal extends Effect { @SuppressWarnings("deprecation") @Override protected void execute(Event e) { - LivingEntity[] ents = entities.getAll(e); + LivingEntity[] ents = entities.getAll(e); for (LivingEntity ent : ents) { if (ent == null || ent instanceof Player || ent instanceof ArmorStand) return; diff --git a/src/me/TheBukor/SkStuff/expressions/ExprLastLocation.java b/src/me/TheBukor/SkStuff/expressions/ExprLastLocation.java index 155389e..adb4320 100644 --- a/src/me/TheBukor/SkStuff/expressions/ExprLastLocation.java +++ b/src/me/TheBukor/SkStuff/expressions/ExprLastLocation.java @@ -41,6 +41,9 @@ public class ExprLastLocation extends SimpleExpression { @Nullable protected Location[] get(Event 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) }; } } \ No newline at end of file diff --git a/src/me/TheBukor/SkStuff/expressions/ExprMCIdOf.java b/src/me/TheBukor/SkStuff/expressions/ExprMCIdOf.java index e4e70b1..b048a9d 100644 --- a/src/me/TheBukor/SkStuff/expressions/ExprMCIdOf.java +++ b/src/me/TheBukor/SkStuff/expressions/ExprMCIdOf.java @@ -42,6 +42,9 @@ public class ExprMCIdOf extends SimpleExpression { @Nullable protected String[] get(Event e) { ItemType type = itemType.getSingle(e); + if (type == null) { + return null; + } ItemStack item = new ItemStack(type.getTypes().get(0).getId()); return new String[] { SkStuff.getNMSMethods().getMCId(item) }; } diff --git a/src/me/TheBukor/SkStuff/expressions/ExprMCIdToItem.java b/src/me/TheBukor/SkStuff/expressions/ExprMCIdToItem.java index 23fe158..b043c89 100644 --- a/src/me/TheBukor/SkStuff/expressions/ExprMCIdToItem.java +++ b/src/me/TheBukor/SkStuff/expressions/ExprMCIdToItem.java @@ -40,6 +40,9 @@ public class ExprMCIdToItem extends SimpleExpression { @Nullable protected ItemStack[] get(Event e) { String id = mcId.getSingle(e); + if (id == null) { + return null; + } return new ItemStack[] { SkStuff.getNMSMethods().getItemFromMcId(id) }; } diff --git a/src/me/TheBukor/SkStuff/expressions/ExprStepLength.java b/src/me/TheBukor/SkStuff/expressions/ExprStepLength.java index 6f63035..890bce6 100644 --- a/src/me/TheBukor/SkStuff/expressions/ExprStepLength.java +++ b/src/me/TheBukor/SkStuff/expressions/ExprStepLength.java @@ -42,16 +42,18 @@ public class ExprStepLength extends SimpleExpression { @Nullable protected Number[] get(Event e) { Entity ent = entity.getSingle(e); - if (ent == null) + if (ent == null) { return null; + } return new Number[] { SkStuff.getNMSMethods().getEntityStepLength(ent) }; } @Override public void change(Event e, @Nullable Object[] delta, ChangeMode mode) { Entity ent = entity.getSingle(e); - if (ent == null) + if (ent == null) { return; + } if (mode == ChangeMode.ADD) { float toAdd = ((Number) delta[0]).floatValue(); float currentLength = SkStuff.getNMSMethods().getEntityStepLength(ent);