diff --git a/.classpath b/.classpath
index 229d6b7..6edceba 100644
--- a/.classpath
+++ b/.classpath
@@ -1,13 +1,14 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugin.yml b/plugin.yml
index c5f377c..f97c1f9 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -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.5.1
-main: me.TheBukor.SkStuff.SkStuff
+name: SkStuff
+author: TheBukor
+description: A Skript addon which adds extra functionalities such as NBT and extended WorldEdit support.
+version: 1.6
+main: me.TheBukor.SkStuff.SkStuff
softdepend: [Skript, WorldEdit]
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/SkStuff.java b/src/me/TheBukor/SkStuff/SkStuff.java
index 4fda291..4a56458 100644
--- a/src/me/TheBukor/SkStuff/SkStuff.java
+++ b/src/me/TheBukor/SkStuff/SkStuff.java
@@ -1,219 +1,217 @@
-package me.TheBukor.SkStuff;
-
-import javax.annotation.Nullable;
-
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import com.sk89q.worldedit.EditSession;
-
-import ch.njol.skript.Skript;
-import ch.njol.skript.classes.ClassInfo;
-import ch.njol.skript.lang.ExpressionType;
-import ch.njol.skript.lang.util.SimpleEvent;
-import ch.njol.skript.registrations.Classes;
-import ch.njol.skript.registrations.EventValues;
-import ch.njol.skript.util.Getter;
-import me.TheBukor.SkStuff.conditions.CondSelectionContains;
-import me.TheBukor.SkStuff.effects.EffClearPathGoals;
-import me.TheBukor.SkStuff.effects.EffDrainLiquid;
-import me.TheBukor.SkStuff.effects.EffDrawLineWE;
-import me.TheBukor.SkStuff.effects.EffGZipFile;
-import me.TheBukor.SkStuff.effects.EffMakeCylinder;
-import me.TheBukor.SkStuff.effects.EffMakeJump;
-import me.TheBukor.SkStuff.effects.EffMakePyramid;
-import me.TheBukor.SkStuff.effects.EffMakeSphere;
-import me.TheBukor.SkStuff.effects.EffMakeWalls;
-import me.TheBukor.SkStuff.effects.EffNaturalize;
-import me.TheBukor.SkStuff.effects.EffPasteSchematic;
-import me.TheBukor.SkStuff.effects.EffRememberChanges;
-import me.TheBukor.SkStuff.effects.EffRemovePathGoal;
-import me.TheBukor.SkStuff.effects.EffReplaceBlocksWE;
-import me.TheBukor.SkStuff.effects.EffSetBlocksWE;
-import me.TheBukor.SkStuff.effects.EffSetPathGoal;
-import me.TheBukor.SkStuff.effects.EffShowEntityEffect;
-import me.TheBukor.SkStuff.effects.EffSimulateSnow;
-import me.TheBukor.SkStuff.effects.EffToggleVanish;
-import me.TheBukor.SkStuff.effects.EffUndoRedoSession;
-import me.TheBukor.SkStuff.events.EvtWorldEditChange;
-import me.TheBukor.SkStuff.events.WorldEditChangeHandler;
-import me.TheBukor.SkStuff.expressions.ExprChangedBlocksSession;
-import me.TheBukor.SkStuff.expressions.ExprClickedInventory;
-import me.TheBukor.SkStuff.expressions.ExprEditSessionLimit;
-import me.TheBukor.SkStuff.expressions.ExprEndermanBlocks;
-import me.TheBukor.SkStuff.expressions.ExprFileNBT;
-import me.TheBukor.SkStuff.expressions.ExprFireProof;
-import me.TheBukor.SkStuff.expressions.ExprItemNBT;
-import me.TheBukor.SkStuff.expressions.ExprNBTListContents;
-import me.TheBukor.SkStuff.expressions.ExprNBTListIndex;
-import me.TheBukor.SkStuff.expressions.ExprNBTOf;
-import me.TheBukor.SkStuff.expressions.ExprNewEditSession;
-import me.TheBukor.SkStuff.expressions.ExprNoClip;
-import me.TheBukor.SkStuff.expressions.ExprSchematicArea;
-import me.TheBukor.SkStuff.expressions.ExprSelectionArea;
-import me.TheBukor.SkStuff.expressions.ExprSelectionOfPlayer;
-import me.TheBukor.SkStuff.expressions.ExprSelectionPos;
-import me.TheBukor.SkStuff.expressions.ExprTagOf;
-import me.TheBukor.SkStuff.expressions.ExprTimespanToNumber;
-import me.TheBukor.SkStuff.expressions.ExprToLowerCase;
-import me.TheBukor.SkStuff.expressions.ExprToUpperCase;
-import me.TheBukor.SkStuff.expressions.ExprVanishState;
-import me.TheBukor.SkStuff.expressions.ExprWordsToUpperCase;
-import me.TheBukor.SkStuff.util.NMSInterface;
-import me.TheBukor.SkStuff.util.NMS_v1_7_R4;
-import me.TheBukor.SkStuff.util.NMS_v1_8_R1;
-import me.TheBukor.SkStuff.util.NMS_v1_8_R2;
-import me.TheBukor.SkStuff.util.NMS_v1_8_R3;
-import me.TheBukor.SkStuff.util.ReflectionUtils;
-
-public class SkStuff extends JavaPlugin {
- private int condAmount = 0;
- private int effAmount = 0;
- private int evtAmount = 0;
- private int exprAmount = 0;
- private int typeAmount = 0;
-
- public static SkStuff instance;
-
- private static NMSInterface nmsMethods;
-
- public void onEnable() {
- if (Bukkit.getPluginManager().getPlugin("Skript") != null && Skript.isAcceptRegistrations()) {
- Skript.registerAddon(this);
- getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!");
-
- getLogger().info("Registering general non version specific stuff...");
- Skript.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0¦firework[s] explo(de|sion)|1¦hurt|2¦[[iron] golem] (give|offer) (rose|poppy)|3¦[sheep] eat grass|4¦wolf shake) at %entity%");
- Skript.registerExpression(ExprToUpperCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] (cap[ital]s|upper[ ]case)", "convert %string% to [all] (cap[ital]s|upper[ ]case)", "capitalize [all] [char[acter]s (of|in)] %string%");
- Skript.registerExpression(ExprToLowerCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] lower[ ]case", "convert %string% to [all] lower[ ]case", "un[( |-)]capitalize [all] [char[acter]s (of|in)] %string%");
- Skript.registerExpression(ExprWordsToUpperCase.class, String.class, ExpressionType.SIMPLE, "(first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% [converted] to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "convert (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "capitalize (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])");
- Skript.registerExpression(ExprTimespanToNumber.class, Number.class, ExpressionType.SIMPLE, "%timespan% [converted] [in]to (0¦ticks|1¦sec[ond]s|2¦min[ute]s|3¦hours|4¦days)");
- Skript.registerExpression(ExprClickedInventory.class, Inventory.class, ExpressionType.SIMPLE, "[skstuff] clicked inventory");
- effAmount += 1;
- exprAmount += 5;
-
- if (setupNMSVersion()) {
- getLogger().info("Trying to register version specific stuff...");
- Skript.registerEffect(EffClearPathGoals.class, "(clear|delete) [all] pathfind[er] goals (of|from) %livingentity%");
- 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)) from %livingentity%");
- Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %entitydata%[, 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] %entitydata%[, 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 %entitydata%[, (radius|max[imum] distance) %-number%]|12¦melee attack %entitydata%[, [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] %entitydata%[, 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] %entitydata% (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)) to %livingentity%");
- Skript.registerEffect(EffMakeJump.class, "make %livingentities% jump", "force %livingentities% to jump");
- Skript.registerEffect(EffGZipFile.class, "create [a] gzip[ped] file [at] %string%");
- Skript.registerExpression(ExprNBTOf.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %~object%", "%~object%'s nbt[[ ]tag[s]]");
- Skript.registerExpression(ExprItemNBT.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
- Skript.registerExpression(ExprTagOf.class, Object.class, ExpressionType.PROPERTY, "[nbt[ ]]tag %string% of [[nbt] compound] %compound%");
- Skript.registerExpression(ExprFileNBT.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] from [file] %string%");
- Skript.registerExpression(ExprNBTListIndex.class, Object.class, ExpressionType.PROPERTY, "[nbt[ ]list] %nbtlist% index %number%");
- Skript.registerExpression(ExprNBTListContents.class, Object.class, ExpressionType.PROPERTY, "[all] contents (of|from) [nbt[ ]list] %nbtlist%", "[nbt[ ]list] %nbtlist% contents");
- Skript.registerExpression(ExprNoClip.class, Boolean.class, ExpressionType.PROPERTY, "no[( |-)]clip (state|mode) of %entities%", "%entities%'s no[( |-)]clip (state|mode)");
- Skript.registerExpression(ExprFireProof.class, Boolean.class, ExpressionType.PROPERTY, "fire[ ]proof (state|mode) of %entities%", "%entities%'s fire[ ]proof (state|mode)");
- Skript.registerExpression(ExprEndermanBlocks.class, ItemStack.class, ExpressionType.PROPERTY, "blocks that %entity% can (carry|hold|grab|steal)");
- nmsMethods.registerCompoundClassInfo();
- nmsMethods.registerNBTListClassInfo();
- effAmount += 5;
- exprAmount += 9;
- typeAmount += 2;
- }
- if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
- getLogger().info("WorldEdit found! Registering WorldEdit stuff...");
- Skript.registerCondition(CondSelectionContains.class, "[(world[ ]edit|we)] selection of %player% (contains|has) %location%", "%player%'s [(world[ ]edit|we)] selection (contains|has) %location%", "[(world[ ]edit|we)] selection of %player% does(n't| not) (contain|have) %location%", "%player%'s [(world[ ]edit|we)] selection does(n't| not) (contain|have) %location%");
- Skript.registerEffect(EffDrawLineWE.class, "(create|draw|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% [with] thick[ness] %double%");
- Skript.registerEffect(EffUndoRedoSession.class, "(0¦undo|1¦redo) (change|edit)s (of|from) [edit[ ]session] %editsession%");
- Skript.registerEffect(EffRememberChanges.class, "make %player% (remember|be able to undo) changes (of|from) [edit[ ]session] %editsession%");
- Skript.registerEffect(EffMakeSphere.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) (ellipsoid|sphere) [centered] at %location% [with] radius [of] %double%,[ ]%double%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
- Skript.registerEffect(EffSimulateSnow.class, "(simulate snow at|place snow over) %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%", "make %location% snowy (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
- Skript.registerEffect(EffMakePyramid.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) pyramid at %location% [with] radius [of] %integer% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
- Skript.registerEffect(EffDrainLiquid.class, "(drain|remove) [all] liquid[s] at %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
- Skript.registerEffect(EffNaturalize.class, "naturalize ([cuboid] region|[all] blocks) (from|between) %location% (to|and) %location% (using|with) [edit[ ]session] %editsession%");
- Skript.registerEffect(EffMakeWalls.class, "(create|make) wall[s] from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
- Skript.registerEffect(EffSetBlocksWE.class, "set [all] blocks (from|between) %location% (to|and) %location% to %itemstacks% (using|with) [edit[ ]session] %editsession%");
- Skript.registerEffect(EffMakeCylinder.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) cylinder at %location% [with] radius [of] %double%,[ ]%integer%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
- Skript.registerEffect(EffReplaceBlocksWE.class, "replace [all] %itemstacks% (from|between) %location% (to|and) %location% with %itemstacks% (using|with) [edit[ ]session] %editsession%");
- Skript.registerEffect(EffPasteSchematic.class, "paste schem[atic] %string% at %location% using [edit[ ]session] %editsession% (0¦|1¦(ignor(e|ing)|without|[with] no) air)");
- Skript.registerExpression(ExprEditSessionLimit.class, Integer.class, ExpressionType.PROPERTY, "[block] limit [change] of [edit[ ]session] %editsession%");
- Skript.registerExpression(ExprChangedBlocksSession.class, Integer.class, ExpressionType.PROPERTY, "number of [all] changed blocks (in|of) [edit[ ]session] %editsession%");
- Skript.registerExpression(ExprNewEditSession.class, EditSession.class, ExpressionType.PROPERTY, "[new] edit[ ]session in [world] %world% [with] [max[imum]] [block] limit [change] [of] %integer%");
- Skript.registerExpression(ExprSelectionOfPlayer.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection");
- Skript.registerExpression(ExprSelectionPos.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] po(s|int)[ ](0¦1|1¦2) of %player%", "%player%'s [(world[ ]edit|we)] po(s|int)[ ](0¦1|1¦2)");
- Skript.registerExpression(ExprSelectionArea.class, Integer.class, ExpressionType.SIMPLE, "(0¦volume|1¦(x( |-)size|width)|2¦(y( |-)size|height)|3¦(z( |-)size|length)|4¦area) of [(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection (0¦volume|1¦(x( |-)size|width)|2¦(y( |-)size|height)|3¦(z( |-)size|length)|4¦area)");
- Skript.registerExpression(ExprSchematicArea.class, Integer.class, ExpressionType.SIMPLE, "(0¦volume|1¦(x( |-)size|width)|2¦(y( |-)size|height)|3¦(z( |-)size|length)|4¦area) of schem[atic] [from] %string%");
- Classes.registerClass(new ClassInfo(EditSession.class, "editsession").name("Edit Session").user("edit ?sessions?"));
- try {
- Class.forName("com.sk89q.worldedit.extent.logging.AbstractLoggingExtent");
- new WorldEditChangeHandler();
- Skript.registerEvent("WorldEdit block change", SimpleEvent.class, EvtWorldEditChange.class, "world[ ]edit [block] (chang(e|ing)|edit[ing])");
- EventValues.registerEventValue(EvtWorldEditChange.class, Player.class, new Getter() {
- @Override
- @Nullable
- public Player get(EvtWorldEditChange e) {
- return EvtWorldEditChange.getPlayer();
- }
- }, 0);
- EventValues.registerEventValue(EvtWorldEditChange.class, Block.class, new Getter() {
- @Override
- @Nullable
- public Block get(EvtWorldEditChange e) {
- return EvtWorldEditChange.getBlock();
- }
- }, 0);
- evtAmount += 1;
- } catch (ClassNotFoundException ex) {
- Skript.error("Unable to register \"On WorldEdit block change\" event! You will need to upgrade to WorldEdit 6.0");
- return;
- }
- condAmount += 1;
- effAmount += 13;
- exprAmount += 7;
- typeAmount += 1;
- }
- if (Bukkit.getPluginManager().getPlugin("VanishNoPacket") != null) {
- getLogger().info("VanishNoPacket was found! Registering vanishing features...");
- Skript.registerEffect(EffToggleVanish.class, "toggle vanish (state|mode) of %player% (0¦|1¦(silently|quietly))", "toggle %player%'s vanish (state|mode) (0¦|1¦(silently|quietly))");
- Skript.registerExpression(ExprVanishState.class, Boolean.class, ExpressionType.PROPERTY, "vanish (state|mode) of %player%", "%player%'s vanish (state|mode)");
- effAmount += 1;
- exprAmount += 1;
- }
- 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);;
- }
- }
-
- private boolean setupNMSVersion() {
- String version = ReflectionUtils.getVersion();
- if (version.equals("v1_7_R4.")) {
- nmsMethods = new NMS_v1_7_R4();
- getLogger().info("It looks like you're running 1.7.10!");
- } else if (version.equals("v1_8_R1.")) {
- nmsMethods = new NMS_v1_8_R1();
- getLogger().info("It looks like you're running 1.8.0!");
- } else if (version.equals("v1_8_R2.")) {
- nmsMethods = new NMS_v1_8_R2();
- getLogger().info("It looks like you're running 1.8.3!");
- } else if (version.equals("v1_8_R3.")) {
- nmsMethods = new NMS_v1_8_R3();
- getLogger().info("It looks like you're either running 1.8.7, 1.8.8 or 1.8.9!");
- } else {
- getLogger().warning("It looks like you're running an unsupported server version, some features will not be available :(");
- }
- return nmsMethods != null;
- }
-
- public static SkStuff getInstance() {
- return instance;
- }
-
- public static NMSInterface getNMSMethods() {
- return nmsMethods;
- }
-
- public void onDisable() {
- getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully disabled.");
- }
+package me.TheBukor.SkStuff;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.block.Block;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.java.JavaPlugin;
+
+import com.sk89q.worldedit.EditSession;
+
+import ch.njol.skript.Skript;
+import ch.njol.skript.classes.ClassInfo;
+import ch.njol.skript.lang.ExpressionType;
+import ch.njol.skript.lang.util.SimpleEvent;
+import ch.njol.skript.registrations.Classes;
+import ch.njol.skript.registrations.EventValues;
+import ch.njol.skript.util.Getter;
+import me.TheBukor.SkStuff.conditions.CondSelectionContains;
+import me.TheBukor.SkStuff.effects.EffClearPathGoals;
+import me.TheBukor.SkStuff.effects.EffDrainLiquid;
+import me.TheBukor.SkStuff.effects.EffDrawLineWE;
+import me.TheBukor.SkStuff.effects.EffGZipFile;
+import me.TheBukor.SkStuff.effects.EffMakeCylinder;
+import me.TheBukor.SkStuff.effects.EffMakeJump;
+import me.TheBukor.SkStuff.effects.EffMakePyramid;
+import me.TheBukor.SkStuff.effects.EffMakeSphere;
+import me.TheBukor.SkStuff.effects.EffMakeWalls;
+import me.TheBukor.SkStuff.effects.EffNaturalize;
+import me.TheBukor.SkStuff.effects.EffPasteSchematic;
+import me.TheBukor.SkStuff.effects.EffRememberChanges;
+import me.TheBukor.SkStuff.effects.EffRemovePathGoal;
+import me.TheBukor.SkStuff.effects.EffReplaceBlocksWE;
+import me.TheBukor.SkStuff.effects.EffSetBlocksWE;
+import me.TheBukor.SkStuff.effects.EffSetPathGoal;
+import me.TheBukor.SkStuff.effects.EffShowEntityEffect;
+import me.TheBukor.SkStuff.effects.EffSimulateSnow;
+import me.TheBukor.SkStuff.effects.EffToggleVanish;
+import me.TheBukor.SkStuff.effects.EffUndoRedoSession;
+import me.TheBukor.SkStuff.events.EvtWorldEditChange;
+import me.TheBukor.SkStuff.events.WorldEditChangeHandler;
+import me.TheBukor.SkStuff.expressions.ExprChangedBlocksSession;
+import me.TheBukor.SkStuff.expressions.ExprClickedInventory;
+import me.TheBukor.SkStuff.expressions.ExprEditSessionLimit;
+import me.TheBukor.SkStuff.expressions.ExprEndermanBlocks;
+import me.TheBukor.SkStuff.expressions.ExprFileNBT;
+import me.TheBukor.SkStuff.expressions.ExprFireProof;
+import me.TheBukor.SkStuff.expressions.ExprItemNBT;
+import me.TheBukor.SkStuff.expressions.ExprNBTListContents;
+import me.TheBukor.SkStuff.expressions.ExprNBTListIndex;
+import me.TheBukor.SkStuff.expressions.ExprNBTOf;
+import me.TheBukor.SkStuff.expressions.ExprNewEditSession;
+import me.TheBukor.SkStuff.expressions.ExprNoClip;
+import me.TheBukor.SkStuff.expressions.ExprSchematicArea;
+import me.TheBukor.SkStuff.expressions.ExprSelectionArea;
+import me.TheBukor.SkStuff.expressions.ExprSelectionOfPlayer;
+import me.TheBukor.SkStuff.expressions.ExprSelectionPos;
+import me.TheBukor.SkStuff.expressions.ExprTagOf;
+import me.TheBukor.SkStuff.expressions.ExprTimespanToNumber;
+import me.TheBukor.SkStuff.expressions.ExprToLowerCase;
+import me.TheBukor.SkStuff.expressions.ExprToUpperCase;
+import me.TheBukor.SkStuff.expressions.ExprVanishState;
+import me.TheBukor.SkStuff.expressions.ExprWordsToUpperCase;
+import me.TheBukor.SkStuff.util.NMSInterface;
+import me.TheBukor.SkStuff.util.NMS_v1_7_R4;
+import me.TheBukor.SkStuff.util.NMS_v1_8_R1;
+import me.TheBukor.SkStuff.util.NMS_v1_8_R2;
+import me.TheBukor.SkStuff.util.NMS_v1_8_R3;
+import me.TheBukor.SkStuff.util.NMS_v1_9_R1;
+import me.TheBukor.SkStuff.util.ReflectionUtils;
+
+public class SkStuff extends JavaPlugin {
+ private int condAmount = 0;
+ private int effAmount = 0;
+ private int evtAmount = 0;
+ private int exprAmount = 0;
+ private int typeAmount = 0;
+
+ private static NMSInterface nmsMethods;
+
+ public void onEnable() {
+ if (Bukkit.getPluginManager().getPlugin("Skript") != null && Skript.isAcceptRegistrations()) {
+ Skript.registerAddon(this);
+ getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!");
+
+ getLogger().info("Registering general non version specific stuff...");
+ Skript.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0¦firework[s] explo(de|sion)|1¦hurt|2¦[[iron] golem] (give|offer) (rose|poppy)|3¦[sheep] eat grass|4¦wolf shake) at %entity%");
+ Skript.registerExpression(ExprToUpperCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] (cap[ital]s|upper[ ]case)", "convert %string% to [all] (cap[ital]s|upper[ ]case)", "capitalize [all] [char[acter]s (of|in)] %string%");
+ Skript.registerExpression(ExprToLowerCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] lower[ ]case", "convert %string% to [all] lower[ ]case", "un[( |-)]capitalize [all] [char[acter]s (of|in)] %string%");
+ Skript.registerExpression(ExprWordsToUpperCase.class, String.class, ExpressionType.SIMPLE, "(first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% [converted] to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "convert (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "capitalize (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])");
+ Skript.registerExpression(ExprTimespanToNumber.class, Number.class, ExpressionType.SIMPLE, "%timespan% [converted] [in]to (0¦ticks|1¦sec[ond]s|2¦min[ute]s|3¦hours|4¦days)");
+ Skript.registerExpression(ExprClickedInventory.class, Inventory.class, ExpressionType.SIMPLE, "[skstuff] clicked inventory");
+ effAmount += 1;
+ exprAmount += 5;
+
+ if (setupNMSVersion()) {
+ getLogger().info("Trying to register version specific stuff...");
+ Skript.registerEffect(EffClearPathGoals.class, "(clear|delete) [all] pathfind[er] goals (of|from) %livingentity%");
+ 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)) from %livingentity%");
+ Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %entitydata%[, 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] %entitydata%[, 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 %entitydata%[, (radius|max[imum] distance) %-number%]|12¦melee attack %entitydata%[, [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] %entitydata%[, 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] %entitydata% (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)) to %livingentity%");
+ 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]]");
+ Skript.registerExpression(ExprItemNBT.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
+ Skript.registerExpression(ExprTagOf.class, Object.class, ExpressionType.PROPERTY, "[nbt[ ]]tag %string% of [[nbt] compound] %compound%");
+ Skript.registerExpression(ExprFileNBT.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] from [file] %string%");
+ Skript.registerExpression(ExprNBTListIndex.class, Object.class, ExpressionType.PROPERTY, "[nbt[ ]list] %nbtlist% index %number%");
+ Skript.registerExpression(ExprNBTListContents.class, Object.class, ExpressionType.PROPERTY, "[all] contents (of|from) [nbt[ ]list] %nbtlist%", "[nbt[ ]list] %nbtlist% contents");
+ Skript.registerExpression(ExprNoClip.class, Boolean.class, ExpressionType.PROPERTY, "no[( |-)]clip (state|mode) of %entities%", "%entities%'s no[( |-)]clip (state|mode)");
+ Skript.registerExpression(ExprFireProof.class, Boolean.class, ExpressionType.PROPERTY, "fire[ ]proof (state|mode) of %entities%", "%entities%'s fire[ ]proof (state|mode)");
+ Skript.registerExpression(ExprEndermanBlocks.class, ItemStack.class, ExpressionType.PROPERTY, "blocks that %entity% can (carry|hold|grab|steal)");
+ nmsMethods.registerCompoundClassInfo();
+ nmsMethods.registerNBTListClassInfo();
+ effAmount += 5;
+ exprAmount += 9;
+ typeAmount += 2;
+ }
+ if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
+ getLogger().info("WorldEdit found! Registering WorldEdit stuff...");
+ Skript.registerCondition(CondSelectionContains.class, "[(world[ ]edit|we)] selection of %player% (contains|has) %location%", "%player%'s [(world[ ]edit|we)] selection (contains|has) %location%", "[(world[ ]edit|we)] selection of %player% does(n't| not) (contain|have) %location%", "%player%'s [(world[ ]edit|we)] selection does(n't| not) (contain|have) %location%");
+ Skript.registerEffect(EffDrawLineWE.class, "(create|draw|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% [with] thick[ness] %double%");
+ Skript.registerEffect(EffUndoRedoSession.class, "(0¦undo|1¦redo) (change|edit)s (of|from) [edit[ ]session] %editsession%");
+ Skript.registerEffect(EffRememberChanges.class, "make %player% (remember|be able to undo) changes (of|from) [edit[ ]session] %editsession%");
+ Skript.registerEffect(EffMakeSphere.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) (ellipsoid|sphere) [centered] at %location% [with] radius [of] %double%,[ ]%double%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
+ Skript.registerEffect(EffSimulateSnow.class, "(simulate snow at|place snow over) %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%", "make %location% snowy (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
+ Skript.registerEffect(EffMakePyramid.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) pyramid at %location% [with] radius [of] %integer% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
+ Skript.registerEffect(EffDrainLiquid.class, "(drain|remove) [all] liquid[s] at %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
+ Skript.registerEffect(EffNaturalize.class, "naturalize ([cuboid] region|[all] blocks) (from|between) %location% (to|and) %location% (using|with) [edit[ ]session] %editsession%");
+ Skript.registerEffect(EffMakeWalls.class, "(create|make) wall[s] from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
+ Skript.registerEffect(EffSetBlocksWE.class, "set [all] blocks (from|between) %location% (to|and) %location% to %itemstacks% (using|with) [edit[ ]session] %editsession%");
+ Skript.registerEffect(EffMakeCylinder.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) cylinder at %location% [with] radius [of] %double%,[ ]%integer%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
+ Skript.registerEffect(EffReplaceBlocksWE.class, "replace [all] %itemstacks% (from|between) %location% (to|and) %location% with %itemstacks% (using|with) [edit[ ]session] %editsession%");
+ Skript.registerEffect(EffPasteSchematic.class, "paste schem[atic] %string% at %location% using [edit[ ]session] %editsession% (0¦|1¦(ignor(e|ing)|without|[with] no) air)");
+ Skript.registerExpression(ExprEditSessionLimit.class, Integer.class, ExpressionType.PROPERTY, "[block] limit [change] of [edit[ ]session] %editsession%");
+ Skript.registerExpression(ExprChangedBlocksSession.class, Integer.class, ExpressionType.PROPERTY, "number of [all] changed blocks (in|of) [edit[ ]session] %editsession%");
+ Skript.registerExpression(ExprNewEditSession.class, EditSession.class, ExpressionType.PROPERTY, "[new] edit[ ]session in [world] %world% [with] [max[imum]] [block] limit [change] [of] %integer%");
+ Skript.registerExpression(ExprSelectionOfPlayer.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection");
+ Skript.registerExpression(ExprSelectionPos.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] po(s|int)[ ](0¦1|1¦2) of %player%", "%player%'s [(world[ ]edit|we)] po(s|int)[ ](0¦1|1¦2)");
+ Skript.registerExpression(ExprSelectionArea.class, Integer.class, ExpressionType.SIMPLE, "(0¦volume|1¦(x( |-)size|width)|2¦(y( |-)size|height)|3¦(z( |-)size|length)|4¦area) of [(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection (0¦volume|1¦(x( |-)size|width)|2¦(y( |-)size|height)|3¦(z( |-)size|length)|4¦area)");
+ Skript.registerExpression(ExprSchematicArea.class, Integer.class, ExpressionType.SIMPLE, "(0¦volume|1¦(x( |-)size|width)|2¦(y( |-)size|height)|3¦(z( |-)size|length)|4¦area) of schem[atic] [from] %string%");
+ Classes.registerClass(new ClassInfo(EditSession.class, "editsession").name("Edit Session").user("edit ?sessions?"));
+ try {
+ Class.forName("com.sk89q.worldedit.extent.logging.AbstractLoggingExtent");
+ new WorldEditChangeHandler();
+ Skript.registerEvent("WorldEdit block change", SimpleEvent.class, EvtWorldEditChange.class, "world[ ]edit [block] (chang(e|ing)|edit[ing])");
+ EventValues.registerEventValue(EvtWorldEditChange.class, Player.class, new Getter() {
+ @Override
+ @Nullable
+ public Player get(EvtWorldEditChange e) {
+ return EvtWorldEditChange.getPlayer();
+ }
+ }, 0);
+ EventValues.registerEventValue(EvtWorldEditChange.class, Block.class, new Getter() {
+ @Override
+ @Nullable
+ public Block get(EvtWorldEditChange e) {
+ return EvtWorldEditChange.getBlock();
+ }
+ }, 0);
+ evtAmount += 1;
+ } catch (ClassNotFoundException ex) {
+ Skript.error("Unable to register \"On WorldEdit block change\" event! You will need to upgrade to WorldEdit 6.0");
+ return;
+ }
+ condAmount += 1;
+ effAmount += 13;
+ exprAmount += 7;
+ typeAmount += 1;
+ }
+ if (Bukkit.getPluginManager().getPlugin("VanishNoPacket") != null) {
+ getLogger().info("VanishNoPacket was found! Registering vanishing features...");
+ Skript.registerEffect(EffToggleVanish.class, "toggle vanish (state|mode) of %player% (0¦|1¦(silently|quietly))", "toggle %player%'s vanish (state|mode) (0¦|1¦(silently|quietly))");
+ Skript.registerExpression(ExprVanishState.class, Boolean.class, ExpressionType.PROPERTY, "vanish (state|mode) of %player%", "%player%'s vanish (state|mode)");
+ effAmount += 1;
+ exprAmount += 1;
+ }
+ 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);;
+ }
+ }
+
+ private boolean setupNMSVersion() {
+ String version = ReflectionUtils.getVersion();
+ if (version.equals("v1_7_R4.")) {
+ nmsMethods = new NMS_v1_7_R4();
+ getLogger().info("It looks like you're running 1.7.10!");
+ } else if (version.equals("v1_8_R1.")) {
+ nmsMethods = new NMS_v1_8_R1();
+ getLogger().info("It looks like you're running 1.8.0!");
+ } else if (version.equals("v1_8_R2.")) {
+ nmsMethods = new NMS_v1_8_R2();
+ getLogger().info("It looks like you're running 1.8.3!");
+ } else if (version.equals("v1_8_R3.")) {
+ nmsMethods = new NMS_v1_8_R3();
+ getLogger().info("It looks like you're either running 1.8.7, 1.8.8 or 1.8.9!");
+ } else if (version.equals("v1_9_R1.")) {
+ nmsMethods = new NMS_v1_9_R1();
+ getLogger().info("It looks like you're running 1.9.0!");
+ } else {
+ getLogger().warning("It looks like you're running an unsupported server version, some features will not be available :(");
+ }
+ return nmsMethods != null;
+ }
+
+ public static NMSInterface getNMSMethods() {
+ return nmsMethods;
+ }
+
+ public void onDisable() {
+ getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully disabled.");
+ }
}
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/effects/EffClearPathGoals.java b/src/me/TheBukor/SkStuff/effects/EffClearPathGoals.java
index e6da1d0..01d5fed 100644
--- a/src/me/TheBukor/SkStuff/effects/EffClearPathGoals.java
+++ b/src/me/TheBukor/SkStuff/effects/EffClearPathGoals.java
@@ -1,54 +1,54 @@
-package me.TheBukor.SkStuff.effects;
-
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Event;
-
-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.util.ReflectionUtils;
-
-public class EffClearPathGoals extends Effect {
- private Expression entity;
-
- private Class> goalSelectorClass = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
- private Class> insentientEnt = ReflectionUtils.getNMSClass("EntityInsentient", false);
- private Class> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
- entity = (Expression) expr[0];
- return true;
- }
-
- @Override
- public String toString(@Nullable Event e, boolean debug) {
- return "clear all pathfinder goals from " + entity.toString(e, debug);
- }
-
- @Override
- protected void execute(Event e) {
- LivingEntity ent = entity.getSingle(e);
- if (ent instanceof Player || ent == null)
- return;
- Object obcEnt = craftLivEnt.cast(ent);
- try {
- Object nmsEnt = insentientEnt.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
- Object goalSelector = ReflectionUtils.getField("goalSelector", insentientEnt, nmsEnt);
- Object targetSelector = ReflectionUtils.getField("targetSelector", insentientEnt, nmsEnt);
- ((List>) ReflectionUtils.getField("b", goalSelectorClass, goalSelector)).clear();
- ((List>) ReflectionUtils.getField("c", goalSelectorClass, goalSelector)).clear();
- ((List>) ReflectionUtils.getField("b", goalSelectorClass, targetSelector)).clear();
- ((List>) ReflectionUtils.getField("c", goalSelectorClass, targetSelector)).clear();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
+package me.TheBukor.SkStuff.effects;
+
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+
+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.util.ReflectionUtils;
+
+public class EffClearPathGoals extends Effect {
+ private Expression entity;
+
+ private Class> goalSelectorClass = ReflectionUtils.getNMSClass("PathfinderGoalSelector");
+ private Class> insentientEnt = ReflectionUtils.getNMSClass("EntityInsentient");
+ private Class> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
+ entity = (Expression) expr[0];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean debug) {
+ return "clear all pathfinder goals from " + entity.toString(e, debug);
+ }
+
+ @Override
+ protected void execute(Event e) {
+ LivingEntity ent = entity.getSingle(e);
+ if (ent instanceof Player || ent == null)
+ return;
+ Object obcEnt = craftLivEnt.cast(ent);
+ try {
+ Object nmsEnt = insentientEnt.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
+ Object goalSelector = ReflectionUtils.getField("goalSelector", insentientEnt, nmsEnt);
+ Object targetSelector = ReflectionUtils.getField("targetSelector", insentientEnt, nmsEnt);
+ ((List>) ReflectionUtils.getField("b", goalSelectorClass, goalSelector)).clear();
+ ((List>) ReflectionUtils.getField("c", goalSelectorClass, goalSelector)).clear();
+ ((List>) ReflectionUtils.getField("b", goalSelectorClass, targetSelector)).clear();
+ ((List>) ReflectionUtils.getField("c", goalSelectorClass, targetSelector)).clear();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
}
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/effects/EffGZipFile.java b/src/me/TheBukor/SkStuff/effects/EffGZipFile.java
index 470177a..c3f993e 100644
--- a/src/me/TheBukor/SkStuff/effects/EffGZipFile.java
+++ b/src/me/TheBukor/SkStuff/effects/EffGZipFile.java
@@ -1,56 +1,49 @@
-package me.TheBukor.SkStuff.effects;
-
-import java.io.EOFException;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.zip.GZIPOutputStream;
-
-import javax.annotation.Nullable;
-
-import org.bukkit.event.Event;
-
-import ch.njol.skript.lang.Effect;
-import ch.njol.skript.lang.Expression;
-import ch.njol.skript.lang.SkriptParser.ParseResult;
-import ch.njol.util.Kleenean;
-
-public class EffGZipFile extends Effect {
- private Expression filePath;
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
- filePath = (Expression) expr[0];
- return true;
- }
-
- @Override
- public String toString(@Nullable Event e, boolean debug) {
- return "create GZipped file at " + filePath.toString(e, debug);
- }
-
- @Override
- protected void execute(Event e) {
- File newFile = new File(filePath.getSingle(e));
- /*
- if (!newFile.exists()) {
- try {
- newFile.createNewFile();
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
- */
- try {
- new GZIPOutputStream(new FileOutputStream(newFile)).close();
- } catch (FileNotFoundException ex) {
- ex.printStackTrace();
- } catch (IOException ex) {
- if (!(ex instanceof EOFException)) {
- ex.printStackTrace();
- }
- }
- }
-}
+package me.TheBukor.SkStuff.effects;
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.zip.GZIPOutputStream;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.event.Event;
+
+import ch.njol.skript.lang.Effect;
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.util.Kleenean;
+
+public class EffGZipFile extends Effect {
+ private Expression filePath;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
+ filePath = (Expression) expr[0];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean debug) {
+ return "create GZipped file at path " + filePath.toString(e, debug);
+ }
+
+ @Override
+ protected void execute(Event e) {
+ File newFile = new File(filePath.getSingle(e));
+ if (!newFile.exists()) {
+ try {
+ new GZIPOutputStream(new FileOutputStream(newFile)).close();
+ } catch (FileNotFoundException ex) {
+ ex.printStackTrace();
+ } catch (IOException ex) {
+ if (!(ex instanceof EOFException)) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+}
diff --git a/src/me/TheBukor/SkStuff/effects/EffMakeJump.java b/src/me/TheBukor/SkStuff/effects/EffMakeJump.java
index b00a464..ec67b2a 100644
--- a/src/me/TheBukor/SkStuff/effects/EffMakeJump.java
+++ b/src/me/TheBukor/SkStuff/effects/EffMakeJump.java
@@ -1,51 +1,51 @@
-package me.TheBukor.SkStuff.effects;
-
-import javax.annotation.Nullable;
-
-import org.bukkit.entity.ArmorStand;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Event;
-
-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.util.ReflectionUtils;
-
-public class EffMakeJump extends Effect {
- private Expression entities;
-
- private Class> entInsent = ReflectionUtils.getNMSClass("EntityInsentient", false);
- private Class> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
- entities = (Expression) expr[0];
- return true;
- }
-
- @Override
- public String toString(@Nullable Event e, boolean debug) {
- return "make " + entities.toString(e, debug) + " jump";
- }
-
- @Override
- 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 (Exception ex) {
- ex.printStackTrace();
- }
- }
- }
+package me.TheBukor.SkStuff.effects;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.entity.ArmorStand;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+
+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.util.ReflectionUtils;
+
+public class EffMakeJump extends Effect {
+ private Expression entities;
+
+ private Class> entInsent = ReflectionUtils.getNMSClass("EntityInsentient");
+ private Class> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
+ entities = (Expression) expr[0];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean debug) {
+ return "make " + entities.toString(e, debug) + " jump";
+ }
+
+ @Override
+ 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 (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/effects/EffRemovePathGoal.java b/src/me/TheBukor/SkStuff/effects/EffRemovePathGoal.java
index 6281532..060382f 100644
--- a/src/me/TheBukor/SkStuff/effects/EffRemovePathGoal.java
+++ b/src/me/TheBukor/SkStuff/effects/EffRemovePathGoal.java
@@ -1,256 +1,235 @@
-package me.TheBukor.SkStuff.effects;
-
-import java.util.Iterator;
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import org.bukkit.entity.Blaze;
-import org.bukkit.entity.Creature;
-import org.bukkit.entity.Ghast;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.Rabbit;
-import org.bukkit.entity.Spider;
-import org.bukkit.event.Event;
-
-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.util.ReflectionUtils;
-
-public class EffRemovePathGoal extends Effect {
- private Expression entity;
-
- private int mark;
-
- private Class> entInsent = ReflectionUtils.getNMSClass("EntityInsentient", false);
- private Class> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
- mark = result.mark;
- entity = (Expression) expr[0];
- return true;
- }
-
- @Override
- public String toString(@Nullable Event e, boolean debug) {
- return "remove pathfinder goal from " + entity.toString(e, debug);
- }
-
- @Override
- protected void execute(Event e) {
- LivingEntity ent = entity.getSingle(e);
- if (ent instanceof Player || ent == null)
- return;
- Object obcEnt = craftLivEnt.cast(ent);
- try {
- Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
- Object goalSelector = ReflectionUtils.getField("goalSelector", entInsent, nmsEnt);
- Object targetSelector = ReflectionUtils.getField("targetSelector", entInsent, nmsEnt);
- Object toRemove = null;
- boolean target = false;
- boolean resetGoalTarget = false;
- if (mark == 0) {
- if (ent instanceof Rabbit) {
- Class> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget", false);
- toRemove = goalRabbitAvoid;
- } else {
- Class> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget", false);
- toRemove = goalAvoid;
- }
- } else if (mark == 1) {
- Class> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor", false);
- toRemove = goalBreakDoor;
- } else if (mark == 2) {
- Class> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed", false);
- toRemove = goalBreed;
- } else if (mark == 3) {
- Class> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile", false);
- toRemove = goalEatGrass;
- } else if (mark == 4) {
- Class> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun", false);
- toRemove = goalFleeSun;
- } else if (mark == 5) {
- Class> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat", false);
- toRemove = goalFloat;
- } else if (mark == 6) {
- Class> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner", false);
- toRemove = goalFollowOwner;
- } else if (mark == 7) {
- Class> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent", false);
- toRemove = goalFollowAdults;
- } else if (mark == 8) {
- target = true;
- Class> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget", false);
- toRemove = goalReactAttack;
- } else if (mark == 9) {
- Class> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock", false);
- toRemove = goalJumpOnBlock;
- } else if (mark == 10) {
- Class> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget", false);
- toRemove = goalLeapTarget;
- } else if (mark == 11) {
- Class> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer", false);
- toRemove = goalLookEntities;
- } else if (mark == 12) {
- if (ent instanceof Spider) {
- Class> goalSpiderMelee = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack", false);
- toRemove = goalSpiderMelee;
- } else {
- Class> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack", false);
- toRemove = goalMeleeAttack;
- }
- } else if (mark == 13) {
- if (ent instanceof Ghast) {
- Class> goalGhastGotoTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalMoveTowardsTarget", false);
- toRemove = goalGhastGotoTarget;
- } else {
- Class> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget", false);
- toRemove = goalGotoTarget;
- }
- } else if (mark == 14) {
- target = true;
- if (ent instanceof Spider) {
- Class> goalSpiderNearTarget = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget", false);
- toRemove = goalSpiderNearTarget;
- } else {
- Class> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget", false);
- toRemove = goalNearTarget;
- }
- } else if (mark == 15) {
- Class> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack", false);
- toRemove = goalOcelotAttack;
- } else if (mark == 16) {
- Class> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor", false);
- toRemove = goalOpenDoors;
- } else if (mark == 17) {
- if (ent instanceof Rabbit) {
- Class> goalRabbitPanic = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic", false);
- toRemove = goalRabbitPanic;
- } else {
- Class> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic", false);
- toRemove = goalPanic;
- }
- } else if (mark == 18) {
- Class> goalRandomLook = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround", false);
- toRemove = goalRandomLook;
- } else if (mark == 19) {
- Class> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll", false);
- toRemove = goalWander;
- } else if (mark == 20) {
- Class> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit", false);
- toRemove = goalSit;
- } else if (mark == 21) {
- Class> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell", false);
- toRemove = goalSwell;
- } else if (mark == 22) {
- Class> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid", false);
- toRemove = goalSquid;
- } else if (mark == 23) {
- resetGoalTarget = true;
- if (ent instanceof Blaze) {
- Class> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball", false);
- toRemove = goalBlazeFireball;
- } else if (ent instanceof Ghast) {
- Class> goalGhastFireball = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget", false);
- toRemove = goalGhastFireball;
- }
- } else if (mark == 24) {
- Class> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock", false);
- toRemove = goalHideInBlock;
- } else if (mark == 25) {
- Class> goalWakeSilverfish = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers", false);
- toRemove = goalWakeSilverfish;
- } else if (mark == 26) {
- Class> goalPickBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock", false);
- toRemove = goalPickBlocks;
- } else if (mark == 27) {
- Class> goalPlaceBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock", false);
- toRemove = goalPlaceBlocks;
- } else if (mark == 28) {
- target = true;
- Class> goalAttackLooker = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget", false);
- toRemove = goalAttackLooker;
- } else if (mark == 29) {
- Class> goalGhastMoveTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget", false);
- toRemove = goalGhastMoveTarget;
- } else if (mark == 30) {
- Class> goalGhastIdleMove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove", false);
- toRemove = goalGhastIdleMove;
- } else if (mark == 31) {
- Class> goalTempt = ReflectionUtils.getNMSClass("PathfinderGoalTempt", false);
- toRemove = goalTempt;
- } else if (mark == 32) {
- target = true;
- Class> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed", false);
- toRemove = goalTargetNonTamed;
- } else if (mark == 33) {
- resetGoalTarget = true;
- Class> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack", false);
- toRemove = goalGuardianAttack;
- } else if (mark == 34) {
- target = true;
- Class> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger", false);
- toRemove = goalAnger;
- } else if (mark == 35) {
- target = true;
- Class> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther", false);
- toRemove = goalAngerOther;
- } else if (mark == 36) {
- Class> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots", false);
- toRemove = goalEatCarrots;
- } else if (mark == 37) {
- Class> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack", false);
- toRemove = goalRabbitAttack;
- } else if (mark == 38) {
- Class> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump", false);
- toRemove = goalJump;
- } else if (mark == 39) {
- Class> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection", false);
- toRemove = goalRandomDir;
- } else if (mark == 40) {
- Class> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle", false);
- toRemove = goalSlimeWander;
- }
- if (toRemove == null)
- return;
-
- /* "Hey, why are you setting the entity's target to null?!"
- *
- * For some goals (Blaze/Ghast fireball and Guardian attack), if you remove the goal while the entity is attacking, it will not stop attacking imediatelly, it will keep attacking its target.
- * So there's a "bug" with this behavior, as soon as the entity's target resets (null, A.K.A ) the server crashes. Because we messed with the entity's "attack target" goal, the game
- * still thinks it needs to get the target's location for some reason, and since the target is null... It throws an unhandled NPE (it never happens in Vanilla behavior), crashing the server.
- * So I'm just setting the target to null before removing the goal, so it stops attacking properly, and also prevents the said crash.
- */
-
- if (resetGoalTarget) {
- ((Creature) entity.getSingle(e)).setTarget(null);
- }
-
- Class> goalSelectorClass = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
- if (target) { //Target Selector
- Iterator> targets = ((List>) ReflectionUtils.getField("b", goalSelectorClass, targetSelector)).iterator();
- while (targets.hasNext()) {
- Object o = targets.next();
- if (ReflectionUtils.getField("a", o.getClass(), o).getClass() == toRemove) {
- targets.remove();
- }
- }
- } else { //Goal Selector
- Iterator> goals = ((List>) ReflectionUtils.getField("b", goalSelectorClass, goalSelector)).iterator();
- while (goals.hasNext()) {
- Object o = goals.next();
- if (ReflectionUtils.getField("a", o.getClass(), o).getClass() == toRemove) {
- goals.remove();
- }
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
+package me.TheBukor.SkStuff.effects;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.entity.Blaze;
+import org.bukkit.entity.Creature;
+import org.bukkit.entity.Ghast;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Rabbit;
+import org.bukkit.entity.Spider;
+import org.bukkit.event.Event;
+
+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.util.ReflectionUtils;
+
+public class EffRemovePathGoal extends Effect {
+ private Expression entity;
+
+ private int mark;
+
+ private Class> entInsent = ReflectionUtils.getNMSClass("EntityInsentient");
+ private Class> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
+ mark = result.mark;
+ entity = (Expression) expr[0];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean debug) {
+ return "remove pathfinder goal from " + entity.toString(e, debug);
+ }
+
+ @Override
+ protected void execute(Event e) {
+ LivingEntity ent = entity.getSingle(e);
+ if (ent instanceof Player || ent == null)
+ return;
+ Object obcEnt = craftLivEnt.cast(ent);
+ try {
+ Object nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
+ Class> toRemove = null;
+ boolean target = false;
+ boolean resetGoalTarget = false;
+ if (mark == 0) {
+ if (ent instanceof Rabbit) {
+ Class> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget");
+ toRemove = goalRabbitAvoid;
+ } else {
+ Class> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget");
+ toRemove = goalAvoid;
+ }
+ } else if (mark == 1) {
+ Class> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor");
+ toRemove = goalBreakDoor;
+ } else if (mark == 2) {
+ Class> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed");
+ toRemove = goalBreed;
+ } else if (mark == 3) {
+ Class> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile");
+ toRemove = goalEatGrass;
+ } else if (mark == 4) {
+ Class> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun");
+ toRemove = goalFleeSun;
+ } else if (mark == 5) {
+ Class> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat");
+ toRemove = goalFloat;
+ } else if (mark == 6) {
+ Class> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner");
+ toRemove = goalFollowOwner;
+ } else if (mark == 7) {
+ Class> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent");
+ toRemove = goalFollowAdults;
+ } else if (mark == 8) {
+ target = true;
+ Class> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget");
+ toRemove = goalReactAttack;
+ } else if (mark == 9) {
+ Class> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock");
+ toRemove = goalJumpOnBlock;
+ } else if (mark == 10) {
+ Class> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget");
+ toRemove = goalLeapTarget;
+ } else if (mark == 11) {
+ Class> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer");
+ toRemove = goalLookEntities;
+ } else if (mark == 12) {
+ if (ent instanceof Spider) {
+ Class> goalSpiderMelee = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack");
+ toRemove = goalSpiderMelee;
+ } else {
+ Class> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
+ toRemove = goalMeleeAttack;
+ }
+ } else if (mark == 13) {
+ if (ent instanceof Ghast) {
+ Class> goalGhastGotoTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalMoveTowardsTarget");
+ toRemove = goalGhastGotoTarget;
+ } else {
+ Class> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget");
+ toRemove = goalGotoTarget;
+ }
+ } else if (mark == 14) {
+ target = true;
+ if (ent instanceof Spider) {
+ Class> goalSpiderNearTarget = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget");
+ toRemove = goalSpiderNearTarget;
+ } else {
+ Class> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
+ toRemove = goalNearTarget;
+ }
+ } else if (mark == 15) {
+ Class> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack");
+ toRemove = goalOcelotAttack;
+ } else if (mark == 16) {
+ Class> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor");
+ toRemove = goalOpenDoors;
+ } else if (mark == 17) {
+ if (ent instanceof Rabbit) {
+ Class> goalRabbitPanic = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic");
+ toRemove = goalRabbitPanic;
+ } else {
+ Class> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic");
+ toRemove = goalPanic;
+ }
+ } else if (mark == 18) {
+ Class> goalRandomLook = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround");
+ toRemove = goalRandomLook;
+ } else if (mark == 19) {
+ Class> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll");
+ toRemove = goalWander;
+ } else if (mark == 20) {
+ Class> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit");
+ toRemove = goalSit;
+ } else if (mark == 21) {
+ Class> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell");
+ toRemove = goalSwell;
+ } else if (mark == 22) {
+ Class> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid");
+ toRemove = goalSquid;
+ } else if (mark == 23) {
+ resetGoalTarget = true;
+ if (ent instanceof Blaze) {
+ Class> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball");
+ toRemove = goalBlazeFireball;
+ } else if (ent instanceof Ghast) {
+ Class> goalGhastFireball = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget");
+ toRemove = goalGhastFireball;
+ }
+ } else if (mark == 24) {
+ Class> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock");
+ toRemove = goalHideInBlock;
+ } else if (mark == 25) {
+ Class> goalWakeSilverfish = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers");
+ toRemove = goalWakeSilverfish;
+ } else if (mark == 26) {
+ Class> goalPickBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock");
+ toRemove = goalPickBlocks;
+ } else if (mark == 27) {
+ Class> goalPlaceBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock");
+ toRemove = goalPlaceBlocks;
+ } else if (mark == 28) {
+ target = true;
+ Class> goalAttackLooker = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget");
+ toRemove = goalAttackLooker;
+ } else if (mark == 29) {
+ Class> goalGhastMoveTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget");
+ toRemove = goalGhastMoveTarget;
+ } else if (mark == 30) {
+ Class> goalGhastIdleMove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove");
+ toRemove = goalGhastIdleMove;
+ } else if (mark == 31) {
+ Class> goalTempt = ReflectionUtils.getNMSClass("PathfinderGoalTempt");
+ toRemove = goalTempt;
+ } else if (mark == 32) {
+ target = true;
+ Class> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed");
+ toRemove = goalTargetNonTamed;
+ } else if (mark == 33) {
+ resetGoalTarget = true;
+ Class> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack");
+ toRemove = goalGuardianAttack;
+ } else if (mark == 34) {
+ target = true;
+ Class> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger");
+ toRemove = goalAnger;
+ } else if (mark == 35) {
+ target = true;
+ Class> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther");
+ toRemove = goalAngerOther;
+ } else if (mark == 36) {
+ Class> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots");
+ toRemove = goalEatCarrots;
+ } else if (mark == 37) {
+ Class> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack");
+ toRemove = goalRabbitAttack;
+ } else if (mark == 38) {
+ Class> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump");
+ toRemove = goalJump;
+ } else if (mark == 39) {
+ Class> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection");
+ toRemove = goalRandomDir;
+ } else if (mark == 40) {
+ Class> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle");
+ toRemove = goalSlimeWander;
+ }
+ if (toRemove == null)
+ return;
+
+ /* "Hey, why are you setting the entity's target to null?!"
+ *
+ * For some goals (Blaze/Ghast fireball and Guardian attack), if you remove the goal while the entity is attacking, it will not stop attacking imediatelly, it will keep attacking its target.
+ * So there's a "bug" with this behavior, as soon as the entity's target resets (null, A.K.A ) the server crashes. Because we messed with the entity's "attack target" goal, the game
+ * still thinks it needs to get the target's location for some reason, and since the target is null... It throws an unhandled NPE (it never happens in Vanilla behavior), crashing the server.
+ * So I'm just setting the target to null before removing the goal, so it stops attacking properly, and also prevents the said crash.
+ */
+
+ if (resetGoalTarget) {
+ ((Creature) entity.getSingle(e)).setTarget(null);
+ }
+
+ SkStuff.getNMSMethods().removePathfinderGoal(nmsEnt, toRemove, target);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
}
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java b/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java
index a4b2a4e..a072d15 100644
--- a/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java
+++ b/src/me/TheBukor/SkStuff/effects/EffSetPathGoal.java
@@ -1,602 +1,625 @@
-package me.TheBukor.SkStuff.effects;
-
-import java.lang.reflect.Constructor;
-
-import javax.annotation.Nullable;
-
-import org.bukkit.Material;
-import org.bukkit.entity.Animals;
-import org.bukkit.entity.Blaze;
-import org.bukkit.entity.Creeper;
-import org.bukkit.entity.Enderman;
-import org.bukkit.entity.Ghast;
-import org.bukkit.entity.Guardian;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Ocelot;
-import org.bukkit.entity.PigZombie;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.Rabbit;
-import org.bukkit.entity.Silverfish;
-import org.bukkit.entity.Slime;
-import org.bukkit.entity.Spider;
-import org.bukkit.entity.Squid;
-import org.bukkit.entity.Tameable;
-import org.bukkit.event.Event;
-import org.bukkit.inventory.ItemStack;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-
-import ch.njol.skript.entity.EntityData;
-import ch.njol.skript.lang.Effect;
-import ch.njol.skript.lang.Expression;
-import ch.njol.skript.lang.SkriptParser.ParseResult;
-import ch.njol.skript.util.Timespan;
-import ch.njol.util.Kleenean;
-import me.TheBukor.SkStuff.util.ReflectionUtils;
-
-public class EffSetPathGoal extends Effect {
- private Expression goalPriority;
- private Expression> typeToAvoid;
- private Expression avoidRadius;
- private Expression avoidSpeed;
- private Expression avoidSpeedNear;
- private Expression breedSpeed;
- private Expression fleeSunSpeed;
- private Expression followOwnerSpeed;
- private Expression followMinDist;
- private Expression followMaxDist;
- private Expression followAdultsSpeed;
- private Expression> typesToFightBack;
- private Expression callForHelp;
- private Expression jumpOnBlockSpeed;
- private Expression leapHeight;
- private Expression> lookType;
- private Expression lookRadius;
- private Expression> meleeTarget;
- private Expression meleeSpeed;
- private Expression meleeMemorize;
- private Expression moveTargetSpeed;
- private Expression moveTargetRadius;
- private Expression> nearTarget;
- private Expression checkSight;
- private Expression panicSpeed;
- private Expression randomWalkSpeed;
- private Expression randomWalkInterval;
- private Expression temptItem;
- private Expression temptSpeed;
- private Expression temptScared;
- private Expression> nonTamedTarget;
- private Expression entity;
-
- private int mark;
-
- private Class> craftItemClass = ReflectionUtils.getOBCClass("inventory.CraftItemStack");
- private Class> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
- private Class> entAnimal = ReflectionUtils.getNMSClass("EntityAnimal", false);
- private Class> entCreature = ReflectionUtils.getNMSClass("EntityCreature", false);
- private Class> entInsent = ReflectionUtils.getNMSClass("EntityInsentient", false);
- private Class> entTameable = ReflectionUtils.getNMSClass("EntityTameableAnimal", false);
- private Class> nmsItemClass = ReflectionUtils.getNMSClass("Item", false);
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
- goalPriority = (Expression) expr[0];
- mark = result.mark;
- if (mark == 0) {
- typeToAvoid = (Expression>) expr[1];
- avoidRadius = (Expression) expr[2];
- avoidSpeed = (Expression) expr[3];
- avoidSpeedNear = (Expression) expr[4];
- } else if (mark == 2) {
- breedSpeed = (Expression) expr[5];
- } else if (mark == 4) {
- fleeSunSpeed = (Expression) expr[6];
- } else if (mark == 6) {
- followOwnerSpeed = (Expression) expr[7];
- followMinDist = (Expression) expr[8];
- followMaxDist = (Expression) expr[9];
- } else if (mark == 7) {
- followAdultsSpeed = (Expression) expr[10];
- } else if (mark == 8) {
- typesToFightBack = (Expression>) expr[11];
- callForHelp = (Expression) expr[12];
- } else if (mark == 9) {
- jumpOnBlockSpeed = (Expression) expr[13];
- } else if (mark == 10) {
- leapHeight = (Expression) expr[14];
- } else if (mark == 11) {
- lookType = (Expression>) expr[15];
- lookRadius = (Expression) expr[16];
- } else if (mark == 12) {
- meleeTarget = (Expression>) expr[17];
- meleeSpeed = (Expression) expr[18];
- meleeMemorize = (Expression) expr[19];
- } else if (mark == 13) {
- moveTargetSpeed = (Expression) expr[20];
- moveTargetRadius = (Expression) expr[21];
- } else if (mark == 14) {
- nearTarget = (Expression>) expr[22];
- checkSight = (Expression) expr[23];
- } else if (mark == 17) {
- panicSpeed = (Expression) expr[24];
- } else if (mark == 19) {
- randomWalkSpeed = (Expression) expr[25];
- randomWalkInterval = (Expression) expr[26];
- } else if (mark == 31) {
- temptItem = (Expression) expr[27];
- temptSpeed = (Expression) expr[28];
- temptScared = (Expression) expr[29];
- } else if (mark == 32) {
- nonTamedTarget = (Expression>) expr[30];
- }
- entity = (Expression) expr[31];
- return true;
- }
-
- @Override
- public String toString(@Nullable Event e, boolean debug) {
- return "add pathfinder goal to" + entity.toString(e, debug);
- }
-
- @SuppressWarnings("deprecation")
- @Override
- protected void execute(Event e) {
- int priority = 0;
- if (goalPriority != null) {
- priority = goalPriority.getSingle(e).intValue();
- } else {
- priority = 4;
- }
- if (priority < 0) {
- priority = 0;
- } else if (priority > 9) {
- priority = 9;
- }
- LivingEntity ent = entity.getSingle(e);
- if (ent == null ||ent instanceof Player)
- return;
- Object obcEnt = craftLivEnt.cast(ent);
- try {
- Object nmsEnt = null;
- boolean target = false;
- Object newGoal = null;
- nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
- Object goals = ReflectionUtils.getField("goalSelector", entInsent, nmsEnt);
- Object targets = ReflectionUtils.getField("targetSelector", entInsent, nmsEnt);
- if (mark == 0) {
- float radius = 6.0F;
- double spd = 1.0D;
- double nearSpd = 1.2D;
- if (avoidRadius != null)
- radius = avoidRadius.getSingle(e).floatValue();
- if (avoidSpeed != null)
- spd = avoidSpeed.getSingle(e).doubleValue();
- if (avoidSpeedNear != null)
- nearSpd = avoidSpeedNear.getSingle(e).doubleValue();
- EntityData> entityData;
- String exprInput = typeToAvoid.toString(e, false);
- if (exprInput.startsWith("the ")) {
- exprInput = exprInput.substring(4);
- }
- entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
- if (!LivingEntity.class.isAssignableFrom(entityData.getType())) {
- return;
- }
- String className = entityData.getType().getSimpleName();
- if (className.equals("HumanEntity"))
- className = "Human";
- else if (className.equals("LivingEntity"))
- className = "Living";
- className = "Entity" + className;
- Class> nmsClass = ReflectionUtils.getNMSClass(className, false);
- if (nmsClass == null)
- return;
- if (ent instanceof Rabbit) {
- Class> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget", false);
- newGoal = goalRabbitAvoid.getDeclaredConstructor(nmsEnt.getClass(), Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, nearSpd);
- } else {
- Class> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget", false);
- newGoal = goalAvoid.getConstructor(entCreature, Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, nearSpd);
- }
- } else if (mark == 1) {
- Class> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor", false);
- newGoal = goalBreakDoor.getConstructor(entInsent).newInstance(nmsEnt);
- } else if (mark == 2) {
- Class> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed", false);
- double spd = 1.0D;
- if (breedSpeed != null)
- spd = breedSpeed.getSingle(e).doubleValue();
- if (!(ent instanceof Animals))
- return;
- newGoal = goalBreed.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
- } else if (mark == 3) {
- Class> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile", false);
- newGoal = goalEatGrass.getConstructor(entInsent).newInstance(nmsEnt);
- } else if (mark == 4) {
- Class> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun", false);
- double spd = 1.0D;
- if (fleeSunSpeed != null)
- spd = fleeSunSpeed.getSingle(e).doubleValue();
- newGoal = goalFleeSun.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
- } else if (mark == 5) {
- Class> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat", false);
- newGoal = goalFloat.getConstructor(entInsent).newInstance(nmsEnt);
- } else if (mark == 6) {
- Class> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner", false);
- double spd = 1.0D;
- if (followOwnerSpeed != null)
- spd = followOwnerSpeed.getSingle(e).doubleValue();
- float minDist = 3.0F;
- if (followMinDist != null)
- minDist = followMinDist.getSingle(e).floatValue();
- float maxDist = 10.0F;
- if (followMaxDist != null)
- maxDist = followMaxDist.getSingle(e).floatValue();
- if (!(ent instanceof Tameable))
- return;
- newGoal = goalFollowOwner.getConstructor(entTameable, double.class, float.class, float.class).newInstance(nmsEnt, spd, maxDist, minDist);
- } else if (mark == 7) {
- Class> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent", false);
- double spd = 1.0D;
- if (followAdultsSpeed != null)
- spd = followAdultsSpeed.getSingle(e).doubleValue();
- if (!(ent instanceof Animals))
- return;
- newGoal = goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
- } else if (mark == 8) {
- target = true;
- boolean callHelp = false;
- Class> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget", false);
- EntityData> entityData;
- String exprInput = typesToFightBack.toString(e, false);
- if (exprInput.startsWith("the ")) {
- exprInput = exprInput.substring(4);
- }
- entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
- if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
- return;
- String className = entityData.getType().getSimpleName();
- if (className.equals("HumanEntity"))
- className = "Human";
- else if (className.equals("LivingEntity"))
- className = "Living";
- className = "Entity" + className;
- Class>[] nmsClass = new Class>[] { ReflectionUtils.getNMSClass(className, false) };
- if (nmsClass[0] == null)
- return;
- if (callForHelp != null)
- callHelp = callForHelp.getSingle(e);
- newGoal = goalReactAttack.getConstructor(entCreature, boolean.class, Class[].class).newInstance(nmsEnt, callHelp, nmsClass);
- } else if (mark == 9) {
- Class> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock", false);
- double spd = 1.0D;
- if (jumpOnBlockSpeed != null)
- spd = jumpOnBlockSpeed.getSingle(e).doubleValue();
- if (!(ent instanceof Ocelot))
- return;
- newGoal = goalJumpOnBlock.getConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
- } else if (mark == 10) {
- Class> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget", false);
- float height = 0.4F;
- if (leapHeight != null)
- height = leapHeight.getSingle(e).floatValue();
- newGoal = goalLeapTarget.getConstructor(entInsent, float.class).newInstance(nmsEnt, height);
- } else if (mark == 11) {
- Class> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer", false);
- EntityData> entityData;
- String exprInput = lookType.toString(e, false);
- if (exprInput.startsWith("the ")) {
- exprInput = exprInput.substring(4);
- }
- entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
- if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
- return;
- String className = entityData.getType().getSimpleName();
- if (className.equals("HumanEntity"))
- className = "Human";
- else if (className.equals("LivingEntity"))
- className = "Living";
- className = "Entity" + className;
- Class> nmsClass = ReflectionUtils.getNMSClass(className, false);
- if (nmsClass == null)
- return;
- float radius = 1.0F;
- if (lookRadius != null)
- radius = lookRadius.getSingle(e).floatValue();
- newGoal = goalLookEntities.getConstructor(entInsent, Class.class, float.class).newInstance(nmsEnt, nmsClass, radius);
- } else if (mark == 12) {
- EntityData> entityData;
- String exprInput = meleeTarget.toString(e, false);
- if (exprInput.startsWith("the ")) {
- exprInput = exprInput.substring(4);
- }
- entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
- if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
- return;
- String className = entityData.getType().getSimpleName();
- if (className.equals("HumanEntity"))
- className = "Human";
- else if (className.equals("LivingEntity"))
- className = "Living";
- className = "Entity" + className;
- Class> nmsClass = ReflectionUtils.getNMSClass(className, false);
- if (nmsClass == null)
- return;
- if (ent instanceof Spider) {
- Class> goalSpiderMelee = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack", false);
- Constructor> constr = goalSpiderMelee.getDeclaredConstructor(nmsEnt.getClass(), Class.class);
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt, nmsClass);
- } else {
- Class> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack", false);
- double spd = 1.0D;
- if (meleeSpeed != null)
- spd = meleeSpeed.getSingle(e).doubleValue();
- boolean memorize = false;
- if (meleeMemorize != null)
- memorize = meleeMemorize.getSingle(e);
- newGoal = goalMeleeAttack.getConstructor(entCreature, Class.class, double.class, boolean.class).newInstance(nmsEnt, nmsClass, spd, memorize);
- }
- } else if (mark == 13) {
- Class> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget", false);
- double spd = 1.0D;
- if (moveTargetSpeed != null)
- spd = moveTargetSpeed.getSingle(e).doubleValue();
- float radius = 32.0F;
- if (moveTargetRadius != null)
- radius = moveTargetRadius.getSingle(e).floatValue();
- newGoal = goalGotoTarget.getConstructor(entCreature, double.class, float.class).newInstance(nmsEnt, spd, radius);
- } else if (mark == 14) {
- target = true;
- boolean checkView = false;
- EntityData> entityData;
- String exprInput = nearTarget.toString(e, false);
- if (exprInput.startsWith("the ")) {
- exprInput = exprInput.substring(4);
- }
- entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
- if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
- return;
- String className = entityData.getType().getSimpleName();
- if (className.equals("HumanEntity"))
- className = "Human";
- else if (className.equals("LivingEntity"))
- className = "Living";
- className = "Entity" + className;
- Class> nmsClass = ReflectionUtils.getNMSClass(className, false);
- if (nmsClass == null)
- return;
- if (ent instanceof Spider) {
- Class> goalSpiderNearTarget = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget", false);
- Constructor> constr = goalSpiderNearTarget.getDeclaredConstructor(nmsEnt.getClass(), Class.class);
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt, nmsClass);
- } else {
- if (checkSight != null)
- checkView = checkSight.getSingle(e);
- Class> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget", false);
- newGoal = goalNearTarget.getConstructor(entCreature, Class.class, boolean.class).newInstance(nmsEnt, nmsClass, checkView);
- }
- } else if (mark == 15) {
- Class> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack", false);
- newGoal = goalOcelotAttack.getConstructor(entInsent).newInstance(nmsEnt);
- } else if (mark == 16) {
- Class> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor", false);
- newGoal = goalOpenDoors.getConstructor(entInsent, boolean.class).newInstance(nmsEnt, false);
- } else if (mark == 17) {
- double spd = 1.0D;
- if (panicSpeed != null)
- spd = panicSpeed.getSingle(e).doubleValue();
- if (ent instanceof Rabbit) {
- Class> goalRabbitPanic = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic", false);
- newGoal = goalRabbitPanic.getDeclaredConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
- } else {
- Class> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic", false);
-
- newGoal = goalPanic.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
- }
- } else if (mark == 18) {
- Class> goalRandomLook = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround", false);
- newGoal = goalRandomLook.getConstructor(entInsent).newInstance(nmsEnt);
- } else if (mark == 19) {
- Class> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll", false);
- double spd = 1.0D;
- if (randomWalkSpeed != null)
- spd = randomWalkSpeed.getSingle(e).doubleValue();
- int interval = 120;
- if (randomWalkInterval != null)
- interval = randomWalkInterval.getSingle(e).getTicks();
- newGoal = goalWander.getConstructor(entCreature, double.class, int.class).newInstance(nmsEnt, spd, interval);
- } else if (mark == 20) {
- Class> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit", false);
- if (!(ent instanceof Tameable))
- return;
- newGoal = goalSit.getConstructor(entTameable).newInstance(nmsEnt);
- } else if (mark == 21) {
- Class> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell", false);
- if (!(ent instanceof Creeper))
- return;
- newGoal = goalSwell.getConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
- } else if (mark == 22) {
- Class> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid", false);
- if (!(ent instanceof Squid))
- return;
- Constructor> constr = goalSquid.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 23) {
- if (ent instanceof Blaze) {
- Class> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball", false);
- Constructor> constr = goalBlazeFireball.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (ent instanceof Ghast) {
- Class> goalGhastFireball = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget", false);
- Constructor> constr = goalGhastFireball.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- }
- } else if (mark == 24) {
- Class> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock", false);
- if (!(ent instanceof Silverfish))
- return;
- Constructor> constr = goalHideInBlock.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 25) {
- Class> goalWakeSilverfish = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers", false);
- if (!(ent instanceof Silverfish))
- return;
- Constructor> constr = goalWakeSilverfish.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 26) {
- Class> goalPickBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock", false);
- if (!(ent instanceof Enderman))
- return;
- Constructor> constr = goalPickBlocks.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 27) {
- Class> goalPlaceBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock", false);
- if (!(ent instanceof Enderman))
- return;
- Constructor> constr = goalPlaceBlocks.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 28) {
- target = true;
- Class> goalAttackLooker = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget", false);
- if (!(ent instanceof Enderman))
- return;
- Constructor> constr = goalAttackLooker.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 29) {
- Class> goalGhastMoveTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget", false);
- if (!(ent instanceof Ghast))
- return;
- Constructor> constr = goalGhastMoveTarget.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 30) {
- Class> goalGhastIdleMove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove", false);
- if (!(ent instanceof Ghast))
- return;
- Constructor> constr = goalGhastIdleMove.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 31) {
- Class> goalTempt = ReflectionUtils.getNMSClass("PathfinderGoalTempt", false);
- ItemStack itemStack = temptItem.getSingle(e);
- if (itemStack.getType() == Material.AIR || itemStack == null)
- return;
- Object nmsItemStack = craftItemClass.getMethod("asNMSCopy", ItemStack.class).invoke(itemStack, itemStack);
- Object nmsItem = nmsItemStack.getClass().getMethod("getItem").invoke(nmsItemStack);
- double spd = 1.0D;
- if (temptSpeed != null)
- spd = temptSpeed.getSingle(e).doubleValue();
- boolean scared = false;
- if (temptScared != null)
- scared = temptScared.getSingle(e);
- newGoal = goalTempt.getConstructor(entCreature, double.class, nmsItemClass, boolean.class).newInstance(nmsEnt, spd, nmsItem, scared);
- } else if (mark == 32) {
- target = true;
- Class> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed", false);
- if (!(ent instanceof Tameable))
- return;
- EntityData> entityData;
- String exprInput = nonTamedTarget.toString(e, false);
- if (exprInput.startsWith("the ")) {
- exprInput = exprInput.substring(4);
- }
- entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
- if (!LivingEntity.class.isAssignableFrom(entityData.getType())) {
- return;
- }
- String className = entityData.getType().getSimpleName();
- if (className.equals("HumanEntity"))
- className = "Human";
- else if (className.equals("LivingEntity"))
- className = "Living";
- className = "Entity" + className;
- Class> nmsClass = ReflectionUtils.getNMSClass(className, false);
- if (nmsClass == null)
- return;
- newGoal = goalTargetNonTamed.getConstructor(entTameable, Class.class, boolean.class, Predicate.class).newInstance(nmsEnt, nmsClass, false, Predicates.alwaysTrue());
- } else if (mark == 33) {
- if (!(ent instanceof Guardian))
- return;
- Class> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack", false);
- Constructor> constr = goalGuardianAttack.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 34) {
- if (!(ent instanceof PigZombie))
- return;
- target = true;
- Class> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger", false);
- Constructor> constr = goalAnger.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 35) {
- if (!(ent instanceof PigZombie))
- return;
- target = true;
- Class> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther", false);
- Constructor> constr = goalAngerOther.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 36) {
- if (!(ent instanceof Rabbit))
- return;
- Class> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots", false);
- Constructor> constr = goalEatCarrots.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 37) {
- if (!(ent instanceof Rabbit))
- return;
- Class> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack", false);
- Constructor> constr = goalRabbitAttack.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 38) {
- if (!(ent instanceof Slime))
- return;
- Class> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump", false);
- Constructor> constr = goalJump.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 39) {
- if (!(ent instanceof Slime))
- return;
- Class> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection", false);
- Constructor> constr = goalRandomDir.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- } else if (mark == 40) {
- if (!(ent instanceof Slime))
- return;
- Class> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle", false);
- Constructor> constr = goalSlimeWander.getDeclaredConstructor(nmsEnt.getClass());
- constr.setAccessible(true);
- newGoal = constr.newInstance(nmsEnt);
- }
- if (newGoal == null)
- return;
- Class> goal = ReflectionUtils.getNMSClass("PathfinderGoal", false);
- Class> goalSelector = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
- if (target) { //Target Selector
- newGoal = goalSelector.getMethod("a", int.class, goal).invoke(targets, priority, newGoal);
- } else { //Goal Selector
- newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
-
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
+package me.TheBukor.SkStuff.effects;
+
+import java.lang.reflect.Constructor;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Material;
+import org.bukkit.entity.Animals;
+import org.bukkit.entity.Blaze;
+import org.bukkit.entity.Creeper;
+import org.bukkit.entity.Enderman;
+import org.bukkit.entity.Ghast;
+import org.bukkit.entity.Guardian;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Ocelot;
+import org.bukkit.entity.PigZombie;
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Rabbit;
+import org.bukkit.entity.Silverfish;
+import org.bukkit.entity.Slime;
+import org.bukkit.entity.Spider;
+import org.bukkit.entity.Squid;
+import org.bukkit.entity.Tameable;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.ItemStack;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
+import ch.njol.skript.entity.EntityData;
+import ch.njol.skript.lang.Effect;
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.localization.Language;
+import ch.njol.skript.util.Timespan;
+import ch.njol.util.Kleenean;
+import me.TheBukor.SkStuff.SkStuff;
+import me.TheBukor.SkStuff.util.ReflectionUtils;
+
+public class EffSetPathGoal extends Effect {
+ private Expression goalPriority;
+ private Expression> typeToAvoid;
+ private Expression avoidRadius;
+ private Expression avoidSpeed;
+ private Expression avoidSpeedNear;
+ private Expression breedSpeed;
+ private Expression fleeSunSpeed;
+ private Expression followOwnerSpeed;
+ private Expression followMinDist;
+ private Expression followMaxDist;
+ private Expression followAdultsSpeed;
+ private Expression> typesToFightBack;
+ private Expression callForHelp;
+ private Expression jumpOnBlockSpeed;
+ private Expression leapHeight;
+ private Expression> lookType;
+ private Expression lookRadius;
+ private Expression> meleeTarget;
+ private Expression meleeSpeed;
+ private Expression meleeMemorize;
+ private Expression moveTargetSpeed;
+ private Expression moveTargetRadius;
+ private Expression> nearTarget;
+ private Expression checkSight;
+ private Expression panicSpeed;
+ private Expression randomWalkSpeed;
+ private Expression randomWalkInterval;
+ private Expression temptItem;
+ private Expression temptSpeed;
+ private Expression temptScared;
+ private Expression> nonTamedTarget;
+ private Expression entity;
+
+ private int mark;
+
+ private Class> craftItemClass = ReflectionUtils.getOBCClass("inventory.CraftItemStack");
+ private Class> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
+ private Class> entAnimal = ReflectionUtils.getNMSClass("EntityAnimal");
+ private Class> entCreature = ReflectionUtils.getNMSClass("EntityCreature");
+ private Class> entInsent = ReflectionUtils.getNMSClass("EntityInsentient");
+ private Class> entTameable = ReflectionUtils.getNMSClass("EntityTameableAnimal");
+ private Class> nmsItemClass = ReflectionUtils.getNMSClass("Item");
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
+ goalPriority = (Expression) expr[0];
+ mark = result.mark;
+ if (mark == 0) {
+ typeToAvoid = (Expression>) expr[1];
+ avoidRadius = (Expression) expr[2];
+ avoidSpeed = (Expression) expr[3];
+ avoidSpeedNear = (Expression) expr[4];
+ } else if (mark == 2) {
+ breedSpeed = (Expression) expr[5];
+ } else if (mark == 4) {
+ fleeSunSpeed = (Expression) expr[6];
+ } else if (mark == 6) {
+ followOwnerSpeed = (Expression) expr[7];
+ followMinDist = (Expression) expr[8];
+ followMaxDist = (Expression) expr[9];
+ } else if (mark == 7) {
+ followAdultsSpeed = (Expression) expr[10];
+ } else if (mark == 8) {
+ typesToFightBack = (Expression>) expr[11];
+ callForHelp = (Expression) expr[12];
+ } else if (mark == 9) {
+ jumpOnBlockSpeed = (Expression) expr[13];
+ } else if (mark == 10) {
+ leapHeight = (Expression) expr[14];
+ } else if (mark == 11) {
+ lookType = (Expression>) expr[15];
+ lookRadius = (Expression) expr[16];
+ } else if (mark == 12) {
+ meleeTarget = (Expression>) expr[17];
+ meleeSpeed = (Expression) expr[18];
+ meleeMemorize = (Expression) expr[19];
+ } else if (mark == 13) {
+ moveTargetSpeed = (Expression) expr[20];
+ moveTargetRadius = (Expression) expr[21];
+ } else if (mark == 14) {
+ nearTarget = (Expression>) expr[22];
+ checkSight = (Expression) expr[23];
+ } else if (mark == 17) {
+ panicSpeed = (Expression) expr[24];
+ } else if (mark == 19) {
+ randomWalkSpeed = (Expression) expr[25];
+ randomWalkInterval = (Expression) expr[26];
+ } else if (mark == 31) {
+ temptItem = (Expression) expr[27];
+ temptSpeed = (Expression) expr[28];
+ temptScared = (Expression) expr[29];
+ } else if (mark == 32) {
+ nonTamedTarget = (Expression>) expr[30];
+ }
+ entity = (Expression) expr[31];
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean debug) {
+ return "add pathfinder goal to" + entity.toString(e, debug);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void execute(Event e) {
+ int priority = 0;
+ if (goalPriority != null) {
+ priority = goalPriority.getSingle(e).intValue();
+ } else {
+ priority = 4;
+ }
+ if (priority < 0) {
+ priority = 0;
+ } else if (priority > 9) {
+ priority = 9;
+ }
+ LivingEntity ent = entity.getSingle(e);
+ if (ent == null ||ent instanceof Player)
+ return;
+ Object obcEnt = craftLivEnt.cast(ent);
+ try {
+ Object nmsEnt = null;
+ boolean target = false;
+ Object newGoal = null;
+ nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
+ if (mark == 0) {
+ boolean wasLocal = Language.setUseLocal(false);
+ float radius = 6.0F;
+ double spd = 1.0D;
+ double nearSpd = 1.2D;
+ if (avoidRadius != null)
+ radius = avoidRadius.getSingle(e).floatValue();
+ if (avoidSpeed != null)
+ spd = avoidSpeed.getSingle(e).doubleValue();
+ if (avoidSpeedNear != null)
+ nearSpd = avoidSpeedNear.getSingle(e).doubleValue();
+ EntityData> entityData;
+ String exprInput = typeToAvoid.toString(e, false);
+ if (exprInput.startsWith("the ")) {
+ exprInput = exprInput.substring(4);
+ }
+ try {
+ entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
+ } finally {
+ Language.setUseLocal(wasLocal);
+ }
+ if (!LivingEntity.class.isAssignableFrom(entityData.getType())) {
+ return;
+ }
+ String className = entityData.getType().getSimpleName();
+ if (className.equals("HumanEntity"))
+ className = "Human";
+ else if (className.equals("LivingEntity"))
+ className = "Living";
+ className = "Entity" + className;
+ Class> nmsClass = ReflectionUtils.getNMSClass(className);
+ if (nmsClass == null)
+ return;
+ if (ent instanceof Rabbit) {
+ Class> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget");
+ newGoal = goalRabbitAvoid.getDeclaredConstructor(nmsEnt.getClass(), Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, nearSpd);
+ } else {
+ Class> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget");
+ newGoal = goalAvoid.getConstructor(entCreature, Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd, nearSpd);
+ }
+ } else if (mark == 1) {
+ Class> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor");
+ newGoal = goalBreakDoor.getConstructor(entInsent).newInstance(nmsEnt);
+ } else if (mark == 2) {
+ Class> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed");
+ double spd = 1.0D;
+ if (breedSpeed != null)
+ spd = breedSpeed.getSingle(e).doubleValue();
+ if (!(ent instanceof Animals))
+ return;
+ newGoal = goalBreed.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
+ } else if (mark == 3) {
+ Class> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile");
+ newGoal = goalEatGrass.getConstructor(entInsent).newInstance(nmsEnt);
+ } else if (mark == 4) {
+ Class> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun");
+ double spd = 1.0D;
+ if (fleeSunSpeed != null)
+ spd = fleeSunSpeed.getSingle(e).doubleValue();
+ newGoal = goalFleeSun.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
+ } else if (mark == 5) {
+ Class> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat");
+ newGoal = goalFloat.getConstructor(entInsent).newInstance(nmsEnt);
+ } else if (mark == 6) {
+ Class> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner");
+ double spd = 1.0D;
+ if (followOwnerSpeed != null)
+ spd = followOwnerSpeed.getSingle(e).doubleValue();
+ float minDist = 3.0F;
+ if (followMinDist != null)
+ minDist = followMinDist.getSingle(e).floatValue();
+ float maxDist = 10.0F;
+ if (followMaxDist != null)
+ maxDist = followMaxDist.getSingle(e).floatValue();
+ if (!(ent instanceof Tameable))
+ return;
+ newGoal = goalFollowOwner.getConstructor(entTameable, double.class, float.class, float.class).newInstance(nmsEnt, spd, maxDist, minDist);
+ } else if (mark == 7) {
+ Class> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent");
+ double spd = 1.0D;
+ if (followAdultsSpeed != null)
+ spd = followAdultsSpeed.getSingle(e).doubleValue();
+ if (!(ent instanceof Animals))
+ return;
+ newGoal = goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
+ } else if (mark == 8) {
+ boolean wasLocal = Language.setUseLocal(false);
+ target = true;
+ boolean callHelp = false;
+ Class> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget");
+ EntityData> entityData;
+ String exprInput = typesToFightBack.toString(e, false);
+ if (exprInput.startsWith("the ")) {
+ exprInput = exprInput.substring(4);
+ }
+ try {
+ entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
+ } finally {
+ Language.setUseLocal(wasLocal);
+ }
+ if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
+ return;
+ String className = entityData.getType().getSimpleName();
+ if (className.equals("HumanEntity"))
+ className = "Human";
+ else if (className.equals("LivingEntity"))
+ className = "Living";
+ className = "Entity" + className;
+ Class>[] nmsClass = new Class>[] { ReflectionUtils.getNMSClass(className) };
+ if (nmsClass[0] == null)
+ return;
+ if (callForHelp != null)
+ callHelp = callForHelp.getSingle(e);
+ newGoal = goalReactAttack.getConstructor(entCreature, boolean.class, Class[].class).newInstance(nmsEnt, callHelp, nmsClass);
+ } else if (mark == 9) {
+ Class> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock");
+ double spd = 1.0D;
+ if (jumpOnBlockSpeed != null)
+ spd = jumpOnBlockSpeed.getSingle(e).doubleValue();
+ if (!(ent instanceof Ocelot))
+ return;
+ newGoal = goalJumpOnBlock.getConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
+ } else if (mark == 10) {
+ Class> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget");
+ float height = 0.4F;
+ if (leapHeight != null)
+ height = leapHeight.getSingle(e).floatValue();
+ newGoal = goalLeapTarget.getConstructor(entInsent, float.class).newInstance(nmsEnt, height);
+ } else if (mark == 11) {
+ boolean wasLocal = Language.setUseLocal(false);
+ Class> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer");
+ EntityData> entityData;
+ String exprInput = lookType.toString(e, false);
+ if (exprInput.startsWith("the ")) {
+ exprInput = exprInput.substring(4);
+ }
+ try {
+ entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
+ } finally {
+ Language.setUseLocal(wasLocal);
+ }
+ if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
+ return;
+ String className = entityData.getType().getSimpleName();
+ if (className.equals("HumanEntity"))
+ className = "Human";
+ else if (className.equals("LivingEntity"))
+ className = "Living";
+ className = "Entity" + className;
+ Class> nmsClass = ReflectionUtils.getNMSClass(className);
+ if (nmsClass == null)
+ return;
+ float radius = 1.0F;
+ if (lookRadius != null)
+ radius = lookRadius.getSingle(e).floatValue();
+ newGoal = goalLookEntities.getConstructor(entInsent, Class.class, float.class).newInstance(nmsEnt, nmsClass, radius);
+ } else if (mark == 12) {
+ boolean wasLocal = Language.setUseLocal(false);
+ EntityData> entityData;
+ String exprInput = meleeTarget.toString(e, false);
+ if (exprInput.startsWith("the ")) {
+ exprInput = exprInput.substring(4);
+ }
+ try {
+ entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
+ } finally {
+ Language.setUseLocal(wasLocal);
+ }
+ if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
+ return;
+ String className = entityData.getType().getSimpleName();
+ if (className.equals("HumanEntity"))
+ className = "Human";
+ else if (className.equals("LivingEntity"))
+ className = "Living";
+ className = "Entity" + className;
+ Class> nmsClass = ReflectionUtils.getNMSClass(className);
+ if (nmsClass == null)
+ return;
+ if (ent instanceof Spider) {
+ Class> goalSpiderMelee = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack");
+ Constructor> constr = goalSpiderMelee.getDeclaredConstructor(nmsEnt.getClass(), Class.class);
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt, nmsClass);
+ } else {
+ Class> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
+ double spd = 1.0D;
+ if (meleeSpeed != null)
+ spd = meleeSpeed.getSingle(e).doubleValue();
+ boolean memorize = false;
+ if (meleeMemorize != null)
+ memorize = meleeMemorize.getSingle(e);
+ newGoal = goalMeleeAttack.getConstructor(entCreature, Class.class, double.class, boolean.class).newInstance(nmsEnt, nmsClass, spd, memorize);
+ }
+ } else if (mark == 13) {
+ Class> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget");
+ double spd = 1.0D;
+ if (moveTargetSpeed != null)
+ spd = moveTargetSpeed.getSingle(e).doubleValue();
+ float radius = 32.0F;
+ if (moveTargetRadius != null)
+ radius = moveTargetRadius.getSingle(e).floatValue();
+ newGoal = goalGotoTarget.getConstructor(entCreature, double.class, float.class).newInstance(nmsEnt, spd, radius);
+ } else if (mark == 14) {
+ boolean wasLocal = Language.setUseLocal(false);
+ target = true;
+ boolean checkView = false;
+ EntityData> entityData;
+ String exprInput = nearTarget.toString(e, false);
+ if (exprInput.startsWith("the ")) {
+ exprInput = exprInput.substring(4);
+ }
+ try {
+ entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
+ } finally {
+ Language.setUseLocal(wasLocal);
+ }
+ if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
+ return;
+ String className = entityData.getType().getSimpleName();
+ if (className.equals("HumanEntity"))
+ className = "Human";
+ else if (className.equals("LivingEntity"))
+ className = "Living";
+ className = "Entity" + className;
+ Class> nmsClass = ReflectionUtils.getNMSClass(className);
+ if (nmsClass == null)
+ return;
+ if (ent instanceof Spider) {
+ Class> goalSpiderNearTarget = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget");
+ Constructor> constr = goalSpiderNearTarget.getDeclaredConstructor(nmsEnt.getClass(), Class.class);
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt, nmsClass);
+ } else {
+ if (checkSight != null)
+ checkView = checkSight.getSingle(e);
+ Class> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
+ newGoal = goalNearTarget.getConstructor(entCreature, Class.class, boolean.class).newInstance(nmsEnt, nmsClass, checkView);
+ }
+ } else if (mark == 15) {
+ Class> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack");
+ newGoal = goalOcelotAttack.getConstructor(entInsent).newInstance(nmsEnt);
+ } else if (mark == 16) {
+ Class> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor");
+ newGoal = goalOpenDoors.getConstructor(entInsent, boolean.class).newInstance(nmsEnt, false);
+ } else if (mark == 17) {
+ double spd = 1.0D;
+ if (panicSpeed != null)
+ spd = panicSpeed.getSingle(e).doubleValue();
+ if (ent instanceof Rabbit) {
+ Class> goalRabbitPanic = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitPanic");
+ newGoal = goalRabbitPanic.getDeclaredConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
+ } else {
+ Class> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic");
+
+ newGoal = goalPanic.getConstructor(entCreature, double.class).newInstance(nmsEnt, spd);
+ }
+ } else if (mark == 18) {
+ Class> goalRandomLook = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround");
+ newGoal = goalRandomLook.getConstructor(entInsent).newInstance(nmsEnt);
+ } else if (mark == 19) {
+ Class> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll");
+ double spd = 1.0D;
+ if (randomWalkSpeed != null)
+ spd = randomWalkSpeed.getSingle(e).doubleValue();
+ int interval = 120;
+ if (randomWalkInterval != null)
+ interval = randomWalkInterval.getSingle(e).getTicks();
+ newGoal = goalWander.getConstructor(entCreature, double.class, int.class).newInstance(nmsEnt, spd, interval);
+ } else if (mark == 20) {
+ Class> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit");
+ if (!(ent instanceof Tameable))
+ return;
+ newGoal = goalSit.getConstructor(entTameable).newInstance(nmsEnt);
+ } else if (mark == 21) {
+ Class> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell");
+ if (!(ent instanceof Creeper))
+ return;
+ newGoal = goalSwell.getConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
+ } else if (mark == 22) {
+ Class> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid");
+ if (!(ent instanceof Squid))
+ return;
+ Constructor> constr = goalSquid.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 23) {
+ if (ent instanceof Blaze) {
+ Class> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball");
+ Constructor> constr = goalBlazeFireball.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (ent instanceof Ghast) {
+ Class> goalGhastFireball = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget");
+ Constructor> constr = goalGhastFireball.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ }
+ } else if (mark == 24) {
+ Class> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock");
+ if (!(ent instanceof Silverfish))
+ return;
+ Constructor> constr = goalHideInBlock.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 25) {
+ Class> goalWakeSilverfish = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers");
+ if (!(ent instanceof Silverfish))
+ return;
+ Constructor> constr = goalWakeSilverfish.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 26) {
+ Class> goalPickBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock");
+ if (!(ent instanceof Enderman))
+ return;
+ Constructor> constr = goalPickBlocks.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 27) {
+ Class> goalPlaceBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock");
+ if (!(ent instanceof Enderman))
+ return;
+ Constructor> constr = goalPlaceBlocks.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 28) {
+ target = true;
+ Class> goalAttackLooker = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget");
+ if (!(ent instanceof Enderman))
+ return;
+ Constructor> constr = goalAttackLooker.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 29) {
+ Class> goalGhastMoveTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget");
+ if (!(ent instanceof Ghast))
+ return;
+ Constructor> constr = goalGhastMoveTarget.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 30) {
+ Class> goalGhastIdleMove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove");
+ if (!(ent instanceof Ghast))
+ return;
+ Constructor> constr = goalGhastIdleMove.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 31) {
+ Class> goalTempt = ReflectionUtils.getNMSClass("PathfinderGoalTempt");
+ ItemStack itemStack = temptItem.getSingle(e);
+ if (itemStack.getType() == Material.AIR || itemStack == null)
+ return;
+ Object nmsItemStack = craftItemClass.getMethod("asNMSCopy", ItemStack.class).invoke(itemStack, itemStack);
+ Object nmsItem = nmsItemStack.getClass().getMethod("getItem").invoke(nmsItemStack);
+ double spd = 1.0D;
+ if (temptSpeed != null)
+ spd = temptSpeed.getSingle(e).doubleValue();
+ boolean scared = false;
+ if (temptScared != null)
+ scared = temptScared.getSingle(e);
+ newGoal = goalTempt.getConstructor(entCreature, double.class, nmsItemClass, boolean.class).newInstance(nmsEnt, spd, nmsItem, scared);
+ } else if (mark == 32) {
+ boolean wasLocal = Language.setUseLocal(false);
+ target = true;
+ Class> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed");
+ if (!(ent instanceof Tameable))
+ return;
+ EntityData> entityData;
+ String exprInput = nonTamedTarget.toString(e, false);
+ if (exprInput.startsWith("the ")) {
+ exprInput = exprInput.substring(4);
+ }
+ try {
+ entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
+ } finally {
+ Language.setUseLocal(wasLocal);
+ }
+ if (!LivingEntity.class.isAssignableFrom(entityData.getType())) {
+ return;
+ }
+ String className = entityData.getType().getSimpleName();
+ if (className.equals("HumanEntity"))
+ className = "Human";
+ else if (className.equals("LivingEntity"))
+ className = "Living";
+ className = "Entity" + className;
+ Class> nmsClass = ReflectionUtils.getNMSClass(className);
+ if (nmsClass == null)
+ return;
+ newGoal = goalTargetNonTamed.getConstructor(entTameable, Class.class, boolean.class, Predicate.class).newInstance(nmsEnt, nmsClass, false, Predicates.alwaysTrue());
+ } else if (mark == 33) {
+ if (!(ent instanceof Guardian))
+ return;
+ Class> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack");
+ Constructor> constr = goalGuardianAttack.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 34) {
+ if (!(ent instanceof PigZombie))
+ return;
+ target = true;
+ Class> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger");
+ Constructor> constr = goalAnger.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 35) {
+ if (!(ent instanceof PigZombie))
+ return;
+ target = true;
+ Class> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther");
+ Constructor> constr = goalAngerOther.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 36) {
+ if (!(ent instanceof Rabbit))
+ return;
+ Class> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots");
+ Constructor> constr = goalEatCarrots.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 37) {
+ if (!(ent instanceof Rabbit))
+ return;
+ Class> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack");
+ Constructor> constr = goalRabbitAttack.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 38) {
+ if (!(ent instanceof Slime))
+ return;
+ Class> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump");
+ Constructor> constr = goalJump.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 39) {
+ if (!(ent instanceof Slime))
+ return;
+ Class> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection");
+ Constructor> constr = goalRandomDir.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ } else if (mark == 40) {
+ if (!(ent instanceof Slime))
+ return;
+ Class> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle");
+ Constructor> constr = goalSlimeWander.getDeclaredConstructor(nmsEnt.getClass());
+ constr.setAccessible(true);
+ newGoal = constr.newInstance(nmsEnt);
+ }
+ if (newGoal == null)
+ return;
+ SkStuff.getNMSMethods().addPathfinderGoal(nmsEnt, priority, newGoal, target);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
}
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/expressions/ExprEndermanBlocks.java b/src/me/TheBukor/SkStuff/expressions/ExprEndermanBlocks.java
index c4668d8..2031a3c 100644
--- a/src/me/TheBukor/SkStuff/expressions/ExprEndermanBlocks.java
+++ b/src/me/TheBukor/SkStuff/expressions/ExprEndermanBlocks.java
@@ -1,163 +1,163 @@
-package me.TheBukor.SkStuff.expressions;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-import javax.annotation.Nullable;
-
-import org.bukkit.Material;
-import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
-import org.bukkit.entity.Enderman;
-import org.bukkit.entity.Entity;
-import org.bukkit.event.Event;
-import org.bukkit.inventory.ItemStack;
-
-import ch.njol.skript.classes.Changer.ChangeMode;
-import ch.njol.skript.lang.Expression;
-import ch.njol.skript.lang.SkriptParser.ParseResult;
-import ch.njol.skript.lang.util.SimpleExpression;
-import ch.njol.util.Kleenean;
-import ch.njol.util.coll.CollectionUtils;
-import me.TheBukor.SkStuff.util.ReflectionUtils;
-
-public class ExprEndermanBlocks extends SimpleExpression {
- private Expression entity;
-
- private Class> nmsBlockClass = ReflectionUtils.getNMSClass("Block", false);
- private Class> endermanClass = ReflectionUtils.getNMSClass("EntityEnderman", false);
- private Class> nmsIBlockData = ReflectionUtils.getNMSClass("IBlockData", false);
- private Class> nmsItemClass = ReflectionUtils.getNMSClass("ItemStack", false);
- private Class> craftEntClass = ReflectionUtils.getOBCClass("entity.CraftEntity");
- private Class> craftItemClass = ReflectionUtils.getOBCClass("inventory.CraftItemStack");
-
- @Override
- public Class extends ItemStack> getReturnType() {
- return ItemStack.class;
- }
-
- @Override
- public boolean isSingle() {
- return false;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean init(Expression>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
- entity = (Expression) expr[0];
- return true;
- }
-
- @Override
- public String toString(@Nullable Event e, boolean debug) {
- return "blocks that " + entity.toString(e, debug) + " can carry";
- }
-
- @SuppressWarnings("unchecked")
- @Override
- @Nullable
- protected ItemStack[] get(Event e) {
- Entity ent = entity.getSingle(e);
- if (ent == null || !(ent instanceof Enderman))
- return null;
- Object nmsEnt = null;
- try {
- nmsEnt = craftEntClass.cast(ent).getClass().getMethod("getHandle").invoke(ent);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- Set