Cleanup and fixes

Actually registers 1.11 stuff now;
Stop bad habit of "catch (Exception ex)" in ReflectionUtils.class;
Add "Bow Shoot" pathfinder goal;
Dropped support for WorldGuard 6.1 and below. Please update to
WorldGuard 6.2.
This commit is contained in:
TheBukor 2016-12-02 17:08:01 -02:00
parent 5d75ab5dba
commit f784116a82
5 changed files with 107 additions and 103 deletions

View File

@ -1,6 +1,6 @@
name: SkStuff name: SkStuff
author: TheBukor author: TheBukor
description: A Skript addon which adds extra functionalities such as NBT and extended WorldEdit support. description: A Skript addon which adds extra functionalities such as NBT and extended WorldEdit support.
version: 1.6.3.8 version: 1.6.4
main: me.TheBukor.SkStuff.SkStuff main: me.TheBukor.SkStuff.SkStuff
softdepend: [Skript, WorldEdit, VanishNoPacket] softdepend: [Skript, WorldEdit, VanishNoPacket]

View File

@ -21,8 +21,10 @@ import org.mcstats.Metrics;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldguard.bukkit.WGBukkit; import com.sk89q.worldguard.bukkit.WGBukkit;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.DefaultFlag; import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import ch.njol.skript.Skript; import ch.njol.skript.Skript;
@ -94,6 +96,7 @@ import me.TheBukor.SkStuff.expressions.ExprWGMemberOwner;
import me.TheBukor.SkStuff.expressions.ExprWordsToUpperCase; import me.TheBukor.SkStuff.expressions.ExprWordsToUpperCase;
import me.TheBukor.SkStuff.util.NMSInterface; import me.TheBukor.SkStuff.util.NMSInterface;
import me.TheBukor.SkStuff.util.NMS_v1_10_R1; import me.TheBukor.SkStuff.util.NMS_v1_10_R1;
import me.TheBukor.SkStuff.util.NMS_v1_11_R1;
import me.TheBukor.SkStuff.util.NMS_v1_7_R4; import me.TheBukor.SkStuff.util.NMS_v1_7_R4;
import me.TheBukor.SkStuff.util.NMS_v1_8_R3; import me.TheBukor.SkStuff.util.NMS_v1_8_R3;
import me.TheBukor.SkStuff.util.NMS_v1_9_R1; import me.TheBukor.SkStuff.util.NMS_v1_9_R1;
@ -128,6 +131,8 @@ public class SkStuff extends JavaPlugin {
Skript.registerEffect(EffResourceSound.class, "play [raw] [([resource[ ]]pack)] sound %string% (for|to) %players% at %location% [[with] volume %-number%[[(,| and)] pitch %-number%]]", "play [raw] [([resource[ ]]pack)] sound %string% for %players% at %location% [[with] pitch %-number%[[(,| and)] volume %-number%]]"); Skript.registerEffect(EffResourceSound.class, "play [raw] [([resource[ ]]pack)] sound %string% (for|to) %players% at %location% [[with] volume %-number%[[(,| and)] pitch %-number%]]", "play [raw] [([resource[ ]]pack)] sound %string% for %players% at %location% [[with] pitch %-number%[[(,| and)] volume %-number%]]");
Skript.registerEvent("Elytra glide toggle", SimpleEvent.class, EntityToggleGlideEvent.class, "[entity] elytra (fl(y|ight)|glid(e|ing)) toggl(e|ing)", "[entity] toggle elytra (fl(y|ight)|glid(e|ing))"); Skript.registerEvent("Elytra glide toggle", SimpleEvent.class, EntityToggleGlideEvent.class, "[entity] elytra (fl(y|ight)|glid(e|ing)) toggl(e|ing)", "[entity] toggle elytra (fl(y|ight)|glid(e|ing))");
Skript.registerExpression(ExprGlideState.class, Boolean.class, ExpressionType.PROPERTY, "elytra (fl(y|ight)|glid(e|ing)) state of %livingentity%", "%livingentity%'s elytra (fl(y|ight)|glid(e|ing)) state"); Skript.registerExpression(ExprGlideState.class, Boolean.class, ExpressionType.PROPERTY, "elytra (fl(y|ight)|glid(e|ing)) state of %livingentity%", "%livingentity%'s elytra (fl(y|ight)|glid(e|ing)) state");
//Skript.registerExpression(ExprPlayerChargeTime.class, Float.class, ExpressionType.PROPERTY, "blah of %player%", "%player%'s blah");
//Increase exprAmount when I uncomment this
EventValues.registerEventValue(EntityToggleGlideEvent.class, Entity.class, new Getter<Entity, EntityToggleGlideEvent>() { EventValues.registerEventValue(EntityToggleGlideEvent.class, Entity.class, new Getter<Entity, EntityToggleGlideEvent>() {
@Override @Override
@Nullable @Nullable
@ -146,8 +151,8 @@ public class SkStuff extends JavaPlugin {
if (setupNMSVersion()) { if (setupNMSVersion()) {
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]) 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(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%]]]) 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%");
Skript.registerExpression(ExprNBTOf.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %~object%", "%~object%'s nbt[[ ]tag[s]]"); Skript.registerExpression(ExprNBTOf.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %~object%", "%~object%'s nbt[[ ]tag[s]]");
@ -221,7 +226,9 @@ public class SkStuff extends JavaPlugin {
effAmount += 13; effAmount += 13;
exprAmount += 8; exprAmount += 8;
typeAmount += 1; typeAmount += 1;
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) { //WorldGuard depends on WorldEdit final Plugin worldGuard = Bukkit.getPluginManager().getPlugin("WorldGuard");
if (worldGuard != null) { //WorldGuard depends on WorldEdit
getLogger().info("WorldGuard found! Registering WorldGuard stuff...");
Plugin umbaska = Bukkit.getPluginManager().getPlugin("Umbaska"); Plugin umbaska = Bukkit.getPluginManager().getPlugin("Umbaska");
Plugin skRambled = Bukkit.getPluginManager().getPlugin("SkRambled"); Plugin skRambled = Bukkit.getPluginManager().getPlugin("SkRambled");
boolean registerNewTypes = (umbaska == null && skRambled == null); boolean registerNewTypes = (umbaska == null && skRambled == null);
@ -234,7 +241,8 @@ public class SkStuff extends JavaPlugin {
@Override @Override
@Nullable @Nullable
public Flag<?> parse(String flag, ParseContext context) { public Flag<?> parse(String flag, ParseContext context) {
return DefaultFlag.fuzzyMatchFlag(flag); FlagRegistry flagRegistry = ((WorldGuardPlugin) worldGuard).getFlagRegistry();
return DefaultFlag.fuzzyMatchFlag(flagRegistry, flag);
} }
@Override @Override
@ -289,6 +297,10 @@ public class SkStuff extends JavaPlugin {
} }
Skript.registerExpression(ExprRegionsWithinLocation.class, ProtectedRegion.class, ExpressionType.SIMPLE, "[all] [the] regions (containing|within|inside) %location%"); Skript.registerExpression(ExprRegionsWithinLocation.class, ProtectedRegion.class, ExpressionType.SIMPLE, "[all] [the] regions (containing|within|inside) %location%");
exprAmount += 4; exprAmount += 4;
if (!Skript.classExists("com.sk89q.protection.flags.registry.FlagRegistry")) {
getLogger().warning("Detected old unsupported version of WorldGuard, please update to WorldGuard 6.2. Flags will not fully work with your current version!!");
}
} }
} }
if (Bukkit.getPluginManager().getPlugin("VanishNoPacket") != null) { if (Bukkit.getPluginManager().getPlugin("VanishNoPacket") != null) {
@ -318,7 +330,7 @@ public class SkStuff extends JavaPlugin {
getLogger().info("Everything ready! Loaded a total of " + condAmount + " conditions, " + effAmount + " effects, " + evtAmount + " events, " + exprAmount + " expressions and " + typeAmount + " types!"); getLogger().info("Everything ready! Loaded a total of " + condAmount + " conditions, " + effAmount + " effects, " + evtAmount + " events, " + exprAmount + " expressions and " + typeAmount + " types!");
} else { } else {
getLogger().info("Unable to find Skript or Skript isn't accepting registrations, disabling SkStuff..."); getLogger().info("Unable to find Skript or Skript isn't accepting registrations, disabling SkStuff...");
Bukkit.getPluginManager().disablePlugin(this);; Bukkit.getPluginManager().disablePlugin(this);
} }
} }
@ -339,6 +351,9 @@ public class SkStuff extends JavaPlugin {
} else if (version.equals("v1_10_R1.")) { } else if (version.equals("v1_10_R1.")) {
nmsMethods = new NMS_v1_10_R1(); nmsMethods = new NMS_v1_10_R1();
getLogger().info("It looks like you're running 1.10!"); getLogger().info("It looks like you're running 1.10!");
} else if (version.equals("v1_11_R1.")) {
nmsMethods = new NMS_v1_11_R1();
getLogger().info("It looks like you're running 1.11!");
} else { } else {
getLogger().warning("It looks like you're running an unsupported server version, some features will not be available :("); getLogger().warning("It looks like you're running an unsupported server version, some features will not be available :(");
} }

View File

@ -14,11 +14,14 @@ import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Spider; import org.bukkit.entity.Spider;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import ch.njol.skript.Skript;
import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean; import ch.njol.util.Kleenean;
import me.TheBukor.SkStuff.SkStuff; import me.TheBukor.SkStuff.SkStuff;
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_8_R3;
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_9_R1;
import me.TheBukor.SkStuff.util.ReflectionUtils; import me.TheBukor.SkStuff.util.ReflectionUtils;
public class EffRemovePathGoal extends Effect { public class EffRemovePathGoal extends Effect {
@ -60,165 +63,132 @@ public class EffRemovePathGoal extends Effect {
boolean resetGoalTarget = false; boolean resetGoalTarget = false;
if (mark == 0) { if (mark == 0) {
if (ent instanceof Rabbit) { if (ent instanceof Rabbit) {
Class<?> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget"); toRemove = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget");
toRemove = goalRabbitAvoid;
} else { } else {
Class<?> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget");
toRemove = goalAvoid;
} }
} else if (mark == 1) { } else if (mark == 1) {
Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor");
toRemove = goalBreakDoor;
} else if (mark == 2) { } else if (mark == 2) {
Class<?> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalBreed");
toRemove = goalBreed;
} else if (mark == 3) { } else if (mark == 3) {
Class<?> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalEatTile");
toRemove = goalEatGrass;
} else if (mark == 4) { } else if (mark == 4) {
Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun");
toRemove = goalFleeSun;
} else if (mark == 5) { } else if (mark == 5) {
Class<?> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalFloat");
toRemove = goalFloat;
} else if (mark == 6) { } else if (mark == 6) {
Class<?> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner");
toRemove = goalFollowOwner;
} else if (mark == 7) { } else if (mark == 7) {
Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent");
toRemove = goalFollowAdults;
} else if (mark == 8) { } else if (mark == 8) {
target = true; target = true;
Class<?> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget");
toRemove = goalReactAttack;
} else if (mark == 9) { } else if (mark == 9) {
Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock");
toRemove = goalJumpOnBlock;
} else if (mark == 10) { } else if (mark == 10) {
Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget");
toRemove = goalLeapTarget;
} else if (mark == 11) { } else if (mark == 11) {
Class<?> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer");
toRemove = goalLookEntities;
} else if (mark == 12) { } else if (mark == 12) {
if (ent instanceof Spider) { if (ent instanceof Spider) {
Class<?> goalSpiderMelee = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack"); toRemove = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack");
toRemove = goalSpiderMelee;
} else { } else {
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
toRemove = goalMeleeAttack;
} }
} else if (mark == 13) { } else if (mark == 13) {
if (ent instanceof Ghast) { if (ent instanceof Ghast) {
Class<?> goalGhastGotoTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalMoveTowardsTarget"); toRemove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalMoveTowardsTarget");
toRemove = goalGhastGotoTarget;
} else { } else {
Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget");
toRemove = goalGotoTarget;
} }
} else if (mark == 14) { } else if (mark == 14) {
target = true; target = true;
if (ent instanceof Spider) { if (ent instanceof Spider) {
Class<?> goalSpiderNearTarget = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget"); toRemove = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget");
toRemove = goalSpiderNearTarget;
} else { } else {
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
toRemove = goalNearTarget;
} }
} else if (mark == 15) { } else if (mark == 15) {
Class<?> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack");
toRemove = goalOcelotAttack;
} else if (mark == 16) { } else if (mark == 16) {
Class<?> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor");
toRemove = goalOpenDoors;
} else if (mark == 17) { } else if (mark == 17) {
if (ent instanceof Rabbit) { if (ent instanceof Rabbit) {
Class<?> goalRabbitPanic = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic"); toRemove = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic");
toRemove = goalRabbitPanic;
} else { } else {
Class<?> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalPanic");
toRemove = goalPanic;
} }
} else if (mark == 18) { } else if (mark == 18) {
Class<?> goalRandomLook = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround");
toRemove = goalRandomLook;
} else if (mark == 19) { } else if (mark == 19) {
Class<?> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll");
toRemove = goalWander;
} else if (mark == 20) { } else if (mark == 20) {
Class<?> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalSit");
toRemove = goalSit;
} else if (mark == 21) { } else if (mark == 21) {
Class<?> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalSwell");
toRemove = goalSwell;
} else if (mark == 22) { } else if (mark == 22) {
Class<?> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid"); toRemove = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid");
toRemove = goalSquid;
} else if (mark == 23) { } else if (mark == 23) {
resetGoalTarget = true; resetGoalTarget = true;
if (ent instanceof Blaze) { if (ent instanceof Blaze) {
Class<?> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball"); toRemove = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball");
toRemove = goalBlazeFireball;
} else if (ent instanceof Ghast) { } else if (ent instanceof Ghast) {
Class<?> goalGhastFireball = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget"); toRemove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget");
toRemove = goalGhastFireball;
} }
} else if (mark == 24) { } else if (mark == 24) {
Class<?> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock"); toRemove = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock");
toRemove = goalHideInBlock;
} else if (mark == 25) { } else if (mark == 25) {
Class<?> goalWakeSilverfish = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers"); toRemove = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers");
toRemove = goalWakeSilverfish;
} else if (mark == 26) { } else if (mark == 26) {
Class<?> goalPickBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock"); toRemove = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock");
toRemove = goalPickBlocks;
} else if (mark == 27) { } else if (mark == 27) {
Class<?> goalPlaceBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock"); toRemove = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock");
toRemove = goalPlaceBlocks;
} else if (mark == 28) { } else if (mark == 28) {
target = true; target = true;
Class<?> goalAttackLooker = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget"); toRemove = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget");
toRemove = goalAttackLooker;
} else if (mark == 29) { } else if (mark == 29) {
Class<?> goalGhastMoveTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget"); toRemove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget");
toRemove = goalGhastMoveTarget;
} else if (mark == 30) { } else if (mark == 30) {
Class<?> goalGhastIdleMove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove"); toRemove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove");
toRemove = goalGhastIdleMove;
} else if (mark == 31) { } else if (mark == 31) {
Class<?> goalTempt = ReflectionUtils.getNMSClass("PathfinderGoalTempt"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalTempt");
toRemove = goalTempt;
} else if (mark == 32) { } else if (mark == 32) {
target = true; target = true;
Class<?> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed"); toRemove = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed");
toRemove = goalTargetNonTamed;
} else if (mark == 33) { } else if (mark == 33) {
resetGoalTarget = true; resetGoalTarget = true;
Class<?> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack"); toRemove = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack");
toRemove = goalGuardianAttack;
} else if (mark == 34) { } else if (mark == 34) {
target = true; target = true;
Class<?> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger"); toRemove = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger");
toRemove = goalAnger;
} else if (mark == 35) { } else if (mark == 35) {
target = true; target = true;
Class<?> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther"); toRemove = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther");
toRemove = goalAngerOther;
} else if (mark == 36) { } else if (mark == 36) {
Class<?> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots"); toRemove = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots");
toRemove = goalEatCarrots;
} else if (mark == 37) { } else if (mark == 37) {
Class<?> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack"); toRemove = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack");
toRemove = goalRabbitAttack;
} else if (mark == 38) { } else if (mark == 38) {
Class<?> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump"); toRemove = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump");
toRemove = goalJump;
} else if (mark == 39) { } else if (mark == 39) {
Class<?> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection"); toRemove = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection");
toRemove = goalRandomDir;
} else if (mark == 40) { } else if (mark == 40) {
Class<?> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle"); toRemove = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle");
toRemove = goalSlimeWander; } else if (mark == 41) {
String version = ReflectionUtils.getVersion();
if (version.equals("v1_8_R3.")) {
toRemove = PathfinderGoalFollow_v1_8_R3.class;
} else if (version.equals("v1_9_R1.")) {
toRemove = PathfinderGoalFollow_v1_9_R1.class;
}
} else if (mark == 42) {
if (Skript.isRunningMinecraft(1, 9)) {
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalBowShoot");
} else {
Skript.warning("The pathfinder goal \"bow shoot\" is not present in 1.8!");
return;
}
} }
if (toRemove == null) if (toRemove == null)
return; return;

View File

@ -21,6 +21,7 @@ import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Rabbit; import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Silverfish; import org.bukkit.entity.Silverfish;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Slime; import org.bukkit.entity.Slime;
import org.bukkit.entity.Spider; import org.bukkit.entity.Spider;
import org.bukkit.entity.Squid; import org.bukkit.entity.Squid;
@ -31,6 +32,7 @@ import org.bukkit.inventory.ItemStack;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import ch.njol.skript.Skript;
import ch.njol.skript.entity.EntityData; import ch.njol.skript.entity.EntityData;
import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
@ -79,6 +81,9 @@ public class EffSetPathGoal extends Effect {
private Expression<Number> followedRadius; private Expression<Number> followedRadius;
private Expression<Number> followedSpeed; private Expression<Number> followedSpeed;
private Expression<String> followedName; private Expression<String> followedName;
private Expression<Number> bowShootMoveSpeed;
private Expression<Number> bowShootUnkParam;
private Expression<Number> bowShootFollowRange;
private Expression<LivingEntity> entities; private Expression<LivingEntity> entities;
private int mark; private int mark;
@ -147,6 +152,10 @@ public class EffSetPathGoal extends Effect {
followedRadius = (Expression<Number>) expr[32]; followedRadius = (Expression<Number>) expr[32];
followedSpeed = (Expression<Number>) expr[33]; followedSpeed = (Expression<Number>) expr[33];
followedName = (Expression<String>) expr[34]; followedName = (Expression<String>) expr[34];
} else if (mark == 42) {
bowShootMoveSpeed = (Expression<Number>) expr[35];
bowShootUnkParam = (Expression<Number>) expr[36];
bowShootFollowRange = (Expression<Number>) expr[37];
} }
entities = (Expression<LivingEntity>) expr[35]; entities = (Expression<LivingEntity>) expr[35];
return true; return true;
@ -525,6 +534,16 @@ public class EffSetPathGoal extends Effect {
newGoals.add(new PathfinderGoalFollow_v1_9_R1((net.minecraft.server.v1_9_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName)); newGoals.add(new PathfinderGoalFollow_v1_9_R1((net.minecraft.server.v1_9_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
} }
} }
} else if (mark == 42) {
if (!(ent instanceof Skeleton)) {
Skript.warning("The pathfinder goal \"Bow Shoot\" can only be applied to skeletons!");
return;
}
double moveSpd = (bowShootMoveSpeed == null ? 1.0D : avoidSpeed.getSingle(e).doubleValue());
double unkParam = (bowShootUnkParam == null ? 20 : avoidSpeedNear.getSingle(e).intValue());
double followRange = (bowShootFollowRange == null ? 15.0F : avoidSpeedNear.getSingle(e).floatValue());
Class<?> goalBowShoot = ReflectionUtils.getNMSClass("PathfinderGoalBowShoot");
newGoals.add(ReflectionUtils.getConstructor(goalBowShoot, nmsEnt.getClass(), double.class, int.class, float.class).newInstance(nmsEnt, moveSpd, unkParam, followRange));
} }
if (newGoals.size() == 0) if (newGoals.size() == 0)

View File

@ -40,7 +40,7 @@ public class ReflectionUtils {
f = clazz.getDeclaredField(field); f = clazz.getDeclaredField(field);
f.setAccessible(true); f.setAccessible(true);
obj = f.get(object); obj = f.get(object);
} catch (Exception ex) { } catch (IllegalAccessException | NoSuchFieldException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
return obj; return obj;
@ -52,7 +52,7 @@ public class ReflectionUtils {
f = clazz.getDeclaredField(field); f = clazz.getDeclaredField(field);
f.setAccessible(true); f.setAccessible(true);
f.set(object, toSet); f.set(object, toSet);
} catch (Exception ex) { } catch (IllegalAccessException | IllegalArgumentException | NoSuchFieldException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@ -62,7 +62,7 @@ public class ReflectionUtils {
try { try {
constr = clazz.getDeclaredConstructor(params); constr = clazz.getDeclaredConstructor(params);
constr.setAccessible(true); constr.setAccessible(true);
} catch (Exception ex) { } catch (NoSuchMethodException | SecurityException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
return constr; return constr;