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
author: TheBukor
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
softdepend: [Skript, WorldEdit, VanishNoPacket]

View File

@ -21,8 +21,10 @@ import org.mcstats.Metrics;
import com.sk89q.worldedit.EditSession;
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.Flag;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
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.util.NMSInterface;
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_8_R3;
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.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(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>() {
@Override
@Nullable
@ -146,8 +151,8 @@ public class SkStuff extends JavaPlugin {
if (setupNMSVersion()) {
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]) 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(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%]]]|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%");
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;
exprAmount += 8;
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 skRambled = Bukkit.getPluginManager().getPlugin("SkRambled");
boolean registerNewTypes = (umbaska == null && skRambled == null);
@ -234,7 +241,8 @@ public class SkStuff extends JavaPlugin {
@Override
@Nullable
public Flag<?> parse(String flag, ParseContext context) {
return DefaultFlag.fuzzyMatchFlag(flag);
FlagRegistry flagRegistry = ((WorldGuardPlugin) worldGuard).getFlagRegistry();
return DefaultFlag.fuzzyMatchFlag(flagRegistry, flag);
}
@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%");
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) {
@ -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!");
} else {
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.")) {
nmsMethods = new NMS_v1_10_R1();
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 {
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.event.Event;
import ch.njol.skript.Skript;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
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;
public class EffRemovePathGoal extends Effect {
@ -60,165 +63,132 @@ public class EffRemovePathGoal extends Effect {
boolean resetGoalTarget = false;
if (mark == 0) {
if (ent instanceof Rabbit) {
Class<?> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget");
toRemove = goalRabbitAvoid;
toRemove = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget");
} else {
Class<?> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget");
toRemove = goalAvoid;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget");
}
} else if (mark == 1) {
Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor");
toRemove = goalBreakDoor;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor");
} else if (mark == 2) {
Class<?> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed");
toRemove = goalBreed;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalBreed");
} else if (mark == 3) {
Class<?> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile");
toRemove = goalEatGrass;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalEatTile");
} else if (mark == 4) {
Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun");
toRemove = goalFleeSun;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun");
} else if (mark == 5) {
Class<?> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat");
toRemove = goalFloat;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalFloat");
} else if (mark == 6) {
Class<?> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner");
toRemove = goalFollowOwner;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner");
} else if (mark == 7) {
Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent");
toRemove = goalFollowAdults;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent");
} else if (mark == 8) {
target = true;
Class<?> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget");
toRemove = goalReactAttack;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget");
} else if (mark == 9) {
Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock");
toRemove = goalJumpOnBlock;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock");
} else if (mark == 10) {
Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget");
toRemove = goalLeapTarget;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget");
} else if (mark == 11) {
Class<?> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer");
toRemove = goalLookEntities;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer");
} else if (mark == 12) {
if (ent instanceof Spider) {
Class<?> goalSpiderMelee = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack");
toRemove = goalSpiderMelee;
toRemove = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack");
} else {
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
toRemove = goalMeleeAttack;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
}
} else if (mark == 13) {
if (ent instanceof Ghast) {
Class<?> goalGhastGotoTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalMoveTowardsTarget");
toRemove = goalGhastGotoTarget;
toRemove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalMoveTowardsTarget");
} else {
Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget");
toRemove = goalGotoTarget;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget");
}
} else if (mark == 14) {
target = true;
if (ent instanceof Spider) {
Class<?> goalSpiderNearTarget = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget");
toRemove = goalSpiderNearTarget;
toRemove = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget");
} else {
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
toRemove = goalNearTarget;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
}
} else if (mark == 15) {
Class<?> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack");
toRemove = goalOcelotAttack;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack");
} else if (mark == 16) {
Class<?> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor");
toRemove = goalOpenDoors;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor");
} else if (mark == 17) {
if (ent instanceof Rabbit) {
Class<?> goalRabbitPanic = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic");
toRemove = goalRabbitPanic;
toRemove = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic");
} else {
Class<?> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic");
toRemove = goalPanic;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalPanic");
}
} else if (mark == 18) {
Class<?> goalRandomLook = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround");
toRemove = goalRandomLook;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround");
} else if (mark == 19) {
Class<?> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll");
toRemove = goalWander;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll");
} else if (mark == 20) {
Class<?> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit");
toRemove = goalSit;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalSit");
} else if (mark == 21) {
Class<?> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell");
toRemove = goalSwell;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalSwell");
} else if (mark == 22) {
Class<?> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid");
toRemove = goalSquid;
toRemove = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid");
} else if (mark == 23) {
resetGoalTarget = true;
if (ent instanceof Blaze) {
Class<?> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball");
toRemove = goalBlazeFireball;
toRemove = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball");
} else if (ent instanceof Ghast) {
Class<?> goalGhastFireball = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget");
toRemove = goalGhastFireball;
toRemove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget");
}
} else if (mark == 24) {
Class<?> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock");
toRemove = goalHideInBlock;
toRemove = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock");
} else if (mark == 25) {
Class<?> goalWakeSilverfish = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers");
toRemove = goalWakeSilverfish;
toRemove = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers");
} else if (mark == 26) {
Class<?> goalPickBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock");
toRemove = goalPickBlocks;
toRemove = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock");
} else if (mark == 27) {
Class<?> goalPlaceBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock");
toRemove = goalPlaceBlocks;
toRemove = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock");
} else if (mark == 28) {
target = true;
Class<?> goalAttackLooker = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget");
toRemove = goalAttackLooker;
toRemove = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget");
} else if (mark == 29) {
Class<?> goalGhastMoveTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget");
toRemove = goalGhastMoveTarget;
toRemove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget");
} else if (mark == 30) {
Class<?> goalGhastIdleMove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove");
toRemove = goalGhastIdleMove;
toRemove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove");
} else if (mark == 31) {
Class<?> goalTempt = ReflectionUtils.getNMSClass("PathfinderGoalTempt");
toRemove = goalTempt;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalTempt");
} else if (mark == 32) {
target = true;
Class<?> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed");
toRemove = goalTargetNonTamed;
toRemove = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed");
} else if (mark == 33) {
resetGoalTarget = true;
Class<?> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack");
toRemove = goalGuardianAttack;
toRemove = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack");
} else if (mark == 34) {
target = true;
Class<?> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger");
toRemove = goalAnger;
toRemove = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger");
} else if (mark == 35) {
target = true;
Class<?> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther");
toRemove = goalAngerOther;
toRemove = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther");
} else if (mark == 36) {
Class<?> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots");
toRemove = goalEatCarrots;
toRemove = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots");
} else if (mark == 37) {
Class<?> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack");
toRemove = goalRabbitAttack;
toRemove = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack");
} else if (mark == 38) {
Class<?> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump");
toRemove = goalJump;
toRemove = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump");
} else if (mark == 39) {
Class<?> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection");
toRemove = goalRandomDir;
toRemove = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection");
} else if (mark == 40) {
Class<?> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle");
toRemove = goalSlimeWander;
toRemove = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle");
} 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)
return;

View File

@ -21,6 +21,7 @@ import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Player;
import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Silverfish;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Slime;
import org.bukkit.entity.Spider;
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.Predicates;
import ch.njol.skript.Skript;
import ch.njol.skript.entity.EntityData;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
@ -79,6 +81,9 @@ public class EffSetPathGoal extends Effect {
private Expression<Number> followedRadius;
private Expression<Number> followedSpeed;
private Expression<String> followedName;
private Expression<Number> bowShootMoveSpeed;
private Expression<Number> bowShootUnkParam;
private Expression<Number> bowShootFollowRange;
private Expression<LivingEntity> entities;
private int mark;
@ -147,6 +152,10 @@ public class EffSetPathGoal extends Effect {
followedRadius = (Expression<Number>) expr[32];
followedSpeed = (Expression<Number>) expr[33];
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];
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));
}
}
} 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)

View File

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