Missed last commit for 1.6, whoopsies! This commit is from 1.6.1.

Some cleanup on SetPathfinderGoal effect, and also testing support for
multiple entities.
This commit is contained in:
TheBukor 2016-03-06 02:50:34 -03:00
parent b0aa11475e
commit f046b64367
15 changed files with 409 additions and 544 deletions

View File

@ -2,13 +2,13 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/Server - Survival - 1.8/plugins/Skript.jar"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/Server - Survival - 1.8/plugins/WorldEdit.jar"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/workspace/Spigot 1.8, 1.8.3/1.8.7.jar"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/workspace/Spigot 1.8, 1.8.3/VanishNoPacket.jar"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/workspace/Spigot 1.8, 1.8.3/1.7.10.jar"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/workspace/Spigot 1.8, 1.8.3/1.8.3.jar"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/workspace/Spigot 1.8, 1.8.3/1.8.jar"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/workspace/Spigot 1.8, 1.8.3/1.9.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.7.10.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.8.3.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.8.8.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.8.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/Skript.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/1.9.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/VanishNoPacket.jar"/>
<classpathentry kind="lib" path="C:/Users/DELL/AppData/Roaming/.minecraft/workspace/eclipse/Build Path/WorldEdit.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

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

View File

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

View File

@ -1,7 +1,5 @@
package me.TheBukor.SkStuff.effects;
import java.util.List;
import javax.annotation.Nullable;
import org.bukkit.entity.LivingEntity;
@ -12,43 +10,30 @@ 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;
import me.TheBukor.SkStuff.SkStuff;
public class EffClearPathGoals extends Effect {
private Expression<LivingEntity> entity;
private Class<?> goalSelectorClass = ReflectionUtils.getNMSClass("PathfinderGoalSelector");
private Class<?> insentientEnt = ReflectionUtils.getNMSClass("EntityInsentient");
private Class<?> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
private Expression<LivingEntity> entities;
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
entity = (Expression<LivingEntity>) expr[0];
entities = (Expression<LivingEntity>) expr[0];
return true;
}
@Override
public String toString(@Nullable Event e, boolean debug) {
return "clear all pathfinder goals from " + entity.toString(e, debug);
return "clear all pathfinder goals from " + entities.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();
LivingEntity[] ents = entities.getAll(e);
for (LivingEntity ent : ents) {
if (ent instanceof Player || ent == null)
continue;
SkStuff.getNMSMethods().clearPathfinderGoals(ent);
}
}
}

View File

@ -1,5 +1,7 @@
package me.TheBukor.SkStuff.effects;
import java.lang.reflect.InvocationTargetException;
import javax.annotation.Nullable;
import org.bukkit.entity.ArmorStand;
@ -43,7 +45,7 @@ public class EffMakeJump extends Effect {
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) {
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
ex.printStackTrace();
}
}

View File

@ -1,5 +1,7 @@
package me.TheBukor.SkStuff.effects;
import java.lang.reflect.InvocationTargetException;
import javax.annotation.Nullable;
import org.bukkit.entity.Blaze;
@ -19,7 +21,7 @@ import me.TheBukor.SkStuff.SkStuff;
import me.TheBukor.SkStuff.util.ReflectionUtils;
public class EffRemovePathGoal extends Effect {
private Expression<LivingEntity> entity;
private Expression<LivingEntity> entities;
private int mark;
@ -30,23 +32,28 @@ public class EffRemovePathGoal extends Effect {
@Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
mark = result.mark;
entity = (Expression<LivingEntity>) expr[0];
entities = (Expression<LivingEntity>) expr[0];
return true;
}
@Override
public String toString(@Nullable Event e, boolean debug) {
return "remove pathfinder goal from " + entity.toString(e, debug);
return "remove pathfinder goal from " + entities.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));
LivingEntity[] ents = entities.getAll(e);
for (LivingEntity ent : ents) {
if (ent instanceof Player || ent == null)
return;
Object obcEnt = craftLivEnt.cast(ent);
Object nmsEnt = null;
try {
nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
ex.printStackTrace();
}
Class<?> toRemove = null;
boolean target = false;
boolean resetGoalTarget = false;
@ -114,8 +121,8 @@ public class EffRemovePathGoal extends Effect {
Class<?> goalSpiderNearTarget = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget");
toRemove = goalSpiderNearTarget;
} else {
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
toRemove = goalNearTarget;
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
toRemove = goalNearTarget;
}
} else if (mark == 15) {
Class<?> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack");
@ -224,12 +231,10 @@ public class EffRemovePathGoal extends Effect {
*/
if (resetGoalTarget) {
((Creature) entity.getSingle(e)).setTarget(null);
((Creature) ent).setTarget(null);
}
SkStuff.getNMSMethods().removePathfinderGoal(nmsEnt, toRemove, target);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View File

@ -1,6 +1,9 @@
package me.TheBukor.SkStuff.effects;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
@ -31,7 +34,6 @@ 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;
@ -39,7 +41,7 @@ import me.TheBukor.SkStuff.util.ReflectionUtils;
public class EffSetPathGoal extends Effect {
private Expression<Integer> goalPriority;
private Expression<EntityData<?>> typeToAvoid;
private Expression<? extends EntityData<?>> typeToAvoid;
private Expression<Number> avoidRadius;
private Expression<Number> avoidSpeed;
private Expression<Number> avoidSpeedNear;
@ -49,18 +51,18 @@ public class EffSetPathGoal extends Effect {
private Expression<Number> followMinDist;
private Expression<Number> followMaxDist;
private Expression<Number> followAdultsSpeed;
private Expression<EntityData<?>> typesToFightBack;
private Expression<? extends EntityData<?>> typesToFightBack;
private Expression<Boolean> callForHelp;
private Expression<Number> jumpOnBlockSpeed;
private Expression<Number> leapHeight;
private Expression<EntityData<?>> lookType;
private Expression<? extends EntityData<?>> lookType;
private Expression<Number> lookRadius;
private Expression<EntityData<?>> meleeTarget;
private Expression<? extends EntityData<?>> meleeTarget;
private Expression<Number> meleeSpeed;
private Expression<Boolean> meleeMemorize;
private Expression<Number> moveTargetSpeed;
private Expression<Number> moveTargetRadius;
private Expression<EntityData<?>> nearTarget;
private Expression<? extends EntityData<?>> nearTarget;
private Expression<Boolean> checkSight;
private Expression<Number> panicSpeed;
private Expression<Number> randomWalkSpeed;
@ -68,8 +70,8 @@ public class EffSetPathGoal extends Effect {
private Expression<ItemStack> temptItem;
private Expression<Number> temptSpeed;
private Expression<Boolean> temptScared;
private Expression<EntityData<?>> nonTamedTarget;
private Expression<LivingEntity> entity;
private Expression<? extends EntityData<?>> nonTamedTarget;
private Expression<LivingEntity> entities;
private int mark;
@ -133,493 +135,306 @@ public class EffSetPathGoal extends Effect {
} else if (mark == 32) {
nonTamedTarget = (Expression<EntityData<?>>) expr[30];
}
entity = (Expression<LivingEntity>) expr[31];
entities = (Expression<LivingEntity>) expr[31];
return true;
}
@Override
public String toString(@Nullable Event e, boolean debug) {
return "add pathfinder goal to" + entity.toString(e, debug);
return "add pathfinder goal to" + entities.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 {
LivingEntity[] ents = entities.getAll(e);
for (LivingEntity ent : ents) {
if (ent == null || ent instanceof Player)
return;
int priority = (goalPriority == null ? 4 : goalPriority.getSingle(e).intValue());
if (priority < 0)
priority = 0;
else if (priority > 9)
priority = 9;
Object obcEnt = craftLivEnt.cast(ent);
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 {
nmsEnt = entInsent.cast(obcEnt.getClass().getMethod("getHandle").invoke(obcEnt));
if (mark == 0) {
float radius = (avoidRadius == null ? 6.0F : avoidRadius.getSingle(e).floatValue());
double spd = (avoidSpeed == null ? 1.0D : avoidSpeed.getSingle(e).doubleValue());
double nearSpd = (avoidSpeedNear == null ? 1.2D : avoidSpeedNear.getSingle(e).doubleValue());
EntityData<?>[] types = typeToAvoid.getAll(e);
if (ent instanceof Rabbit) {
Class<?> goalRabbitAvoid = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalRabbitAvoidTarget");
for (EntityData<?> entData : types) {
if (LivingEntity.class.isAssignableFrom(entData.getType()))
newGoal = goalRabbitAvoid.getDeclaredConstructor(nmsEnt.getClass(), Class.class, float.class, double.class, double.class).newInstance(nmsEnt, entData.getType(), radius, spd, nearSpd);
}
} else {
Class<?> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget");
for (EntityData<?> entData : types) {
if (LivingEntity.class.isAssignableFrom(entData.getType()))
newGoal = goalAvoid.getConstructor(entCreature, Class.class, float.class, double.class, double.class).newInstance(nmsEnt, entData.getType(), radius, spd, nearSpd);
}
}
} else if (mark == 1) {
Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor");
newGoal = goalBreakDoor.getConstructor(entInsent).newInstance(nmsEnt);
} else if (mark == 2) {
if (!(ent instanceof Animals))
return;
double spd = (breedSpeed == null ? 1.0D : breedSpeed.getSingle(e).doubleValue());
Class<?> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed");
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) {
double spd = (fleeSunSpeed == null ? 1.0D : fleeSunSpeed.getSingle(e).doubleValue());
Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun");
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) {
if (!(ent instanceof Tameable))
return;
double spd = (followOwnerSpeed == null ? 1.0D : followOwnerSpeed.getSingle(e).doubleValue());
float minDist = (followMinDist == null ? 3.0F : followMinDist.getSingle(e).floatValue());
float maxDist = (followMaxDist == null ? 10.0F : followMaxDist.getSingle(e).floatValue());
Class<?> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner");
newGoal = goalFollowOwner.getConstructor(entTameable, double.class, float.class, float.class).newInstance(nmsEnt, spd, maxDist, minDist);
} else if (mark == 7) {
if (!(ent instanceof Animals))
return;
double spd = (followAdultsSpeed == null ? 1.0D : followAdultsSpeed.getSingle(e).doubleValue());
Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent");
newGoal = goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
} else if (mark == 8) {
target = true;
boolean callHelp = (callForHelp == null ? false : callForHelp.getSingle(e));
EntityData<?>[] types = typesToFightBack.getAll(e);
List<Class<?>> typesClasses = new ArrayList<Class<?>>();
for (EntityData<?> entData : types) {
if (LivingEntity.class.isAssignableFrom(entData.getType()))
typesClasses.add(entData.getType());
}
Class<?>[] finalTypes = Arrays.copyOf(typesClasses.toArray(), typesClasses.size(), Class[].class);
Class<?> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget");
newGoal = goalReactAttack.getConstructor(entCreature, boolean.class, Class[].class).newInstance(nmsEnt, callHelp, finalTypes);
} else if (mark == 9) {
if (!(ent instanceof Ocelot))
return;
double spd = (jumpOnBlockSpeed == null ? 1.0D : jumpOnBlockSpeed.getSingle(e).doubleValue());
Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock");
newGoal = goalJumpOnBlock.getConstructor(nmsEnt.getClass(), double.class).newInstance(nmsEnt, spd);
} else if (mark == 10) {
float height = (leapHeight == null ? 0.4F : leapHeight.getSingle(e).floatValue());
Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget");
newGoal = goalLeapTarget.getConstructor(entInsent, float.class).newInstance(nmsEnt, height);
} else if (mark == 11) {
float radius = (lookRadius == null ? 1.0F : lookRadius.getSingle(e).floatValue());
EntityData<?>[] types = lookType.getAll(e);
Class<?> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer");
for (EntityData<?> entData : types) {
if (LivingEntity.class.isAssignableFrom(entData.getType()))
newGoal = goalLookEntities.getConstructor(entInsent, Class.class, float.class).newInstance(nmsEnt, entData.getType(), radius);
}
} else if (mark == 12) {
EntityData<?>[] types = meleeTarget.getAll(e);
if (ent instanceof Spider) {
Class<?> goalSpiderMelee = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderMeleeAttack");
for (EntityData<?> entData : types) {
if (LivingEntity.class.isAssignableFrom(entData.getType()))
newGoal = ReflectionUtils.getConstructor(goalSpiderMelee, nmsEnt.getClass(), Class.class).newInstance(nmsEnt, entData.getType());
}
} else {
double spd = (meleeSpeed == null ? 1.0D : meleeSpeed.getSingle(e).doubleValue());
boolean memorize = (meleeMemorize == null ? false : meleeMemorize.getSingle(e));
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
for (EntityData<?> entData : types) {
if (LivingEntity.class.isAssignableFrom(entData.getType()))
newGoal = goalMeleeAttack.getConstructor(entCreature, Class.class, double.class, boolean.class).newInstance(nmsEnt, entData.getType(), spd, memorize);
}
}
} else if (mark == 13) {
double spd = (moveTargetSpeed == null ? 1.0D : moveTargetSpeed.getSingle(e).doubleValue());
float radius = (moveTargetRadius == null ? 32.0F : moveTargetRadius.getSingle(e).floatValue());
Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget");
newGoal = goalGotoTarget.getConstructor(entCreature, double.class, float.class).newInstance(nmsEnt, spd, radius);
} else if (mark == 14) {
target = true;
EntityData<?>[] types = nearTarget.getAll(e);
if (ent instanceof Spider) {
Class<?> goalSpiderNearTarget = ReflectionUtils.getNMSClass("EntitySpider$PathfinderGoalSpiderNearestAttackableTarget");
for (EntityData<?> entData : types) {
if (LivingEntity.class.isAssignableFrom(entData.getType()))
newGoal = ReflectionUtils.getConstructor(goalSpiderNearTarget, nmsEnt.getClass(), Class.class).newInstance(nmsEnt, entData.getType());
}
} else {
boolean checkView = (checkSight == null ? true : checkSight.getSingle(e));
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget");
for (EntityData<?> entData : types) {
if (LivingEntity.class.isAssignableFrom(entData.getType()))
newGoal = goalNearTarget.getConstructor(entCreature, Class.class, boolean.class).newInstance(nmsEnt, entData.getType(), 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 = (panicSpeed == null ? 1.25D : 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) {
double spd = (randomWalkSpeed == null ? 1.0D : randomWalkSpeed.getSingle(e).doubleValue());
int interval = (randomWalkInterval == null ? 120 : randomWalkInterval.getSingle(e).getTicks());
Class<?> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll");
newGoal = goalWander.getConstructor(entCreature, double.class, int.class).newInstance(nmsEnt, spd, interval);
} else if (mark == 20) {
if (!(ent instanceof Tameable))
return;
Class<?> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit");
newGoal = goalSit.getConstructor(entTameable).newInstance(nmsEnt);
} else if (mark == 21) {
if (!(ent instanceof Creeper))
return;
Class<?> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell");
newGoal = goalSwell.getConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 22) {
if (!(ent instanceof Squid))
return;
Class<?> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid");
newGoal = ReflectionUtils.getConstructor(goalSquid, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 23) {
if (ent instanceof Blaze) {
Class<?> goalBlazeFireball = ReflectionUtils.getNMSClass("EntityBlaze$PathfinderGoalBlazeFireball");
newGoal = ReflectionUtils.getConstructor(goalBlazeFireball, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (ent instanceof Ghast) {
Class<?> goalGhastFireball = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastAttackTarget");
newGoal = ReflectionUtils.getConstructor(goalGhastFireball, nmsEnt.getClass()).newInstance(nmsEnt);
}
} else if (mark == 24) {
if (!(ent instanceof Silverfish))
return;
Class<?> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlock");
newGoal = ReflectionUtils.getConstructor(goalHideInBlock, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 25) {
if (!(ent instanceof Silverfish))
return;
Class<?> goalWakeSilverfish = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishWakeOthers");
newGoal = ReflectionUtils.getConstructor(goalWakeSilverfish, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 26) {
if (!(ent instanceof Enderman))
return;
Class<?> goalPickBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPickupBlock");
newGoal = ReflectionUtils.getConstructor(goalPickBlocks, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 27) {
if (!(ent instanceof Enderman))
return;
Class<?> goalPlaceBlocks = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalEndermanPlaceBlock");
newGoal = ReflectionUtils.getConstructor(goalPlaceBlocks, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 28) {
if (!(ent instanceof Enderman))
return;
target = true;
Class<?> goalAttackLooker = ReflectionUtils.getNMSClass("EntityEnderman$PathfinderGoalPlayerWhoLookedAtTarget");
newGoal = ReflectionUtils.getConstructor(goalAttackLooker, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 29) {
if (!(ent instanceof Ghast))
return;
Class<?> goalGhastMoveTarget = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastMoveTowardsTarget");
newGoal = ReflectionUtils.getConstructor(goalGhastMoveTarget, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 30) {
if (!(ent instanceof Ghast))
return;
Class<?> goalGhastIdleMove = ReflectionUtils.getNMSClass("EntityGhast$PathfinderGoalGhastIdleMove");
newGoal = ReflectionUtils.getConstructor(goalGhastIdleMove, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 31) {
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 = (temptSpeed == null ? 1.0D : temptSpeed.getSingle(e).doubleValue());
boolean scared = (temptScared == null ? false : temptScared.getSingle(e));
Class<?> goalTempt = ReflectionUtils.getNMSClass("PathfinderGoalTempt");
newGoal = goalTempt.getConstructor(entCreature, double.class, nmsItemClass, boolean.class).newInstance(nmsEnt, spd, nmsItem, scared);
} else if (mark == 32) {
if (!(ent instanceof Tameable))
return;
target = true;
EntityData<?>[] types = nonTamedTarget.getAll(e);
Class<?> goalTargetNonTamed = ReflectionUtils.getNMSClass("PathfinderGoalRandomTargetNonTamed");
for (EntityData<?> entData : types) {
if (LivingEntity.class.isAssignableFrom(entData.getType()))
newGoal = goalTargetNonTamed.getConstructor(entTameable, Class.class, boolean.class, Predicate.class).newInstance(nmsEnt, entData.getType(), false, Predicates.alwaysTrue());
}
} else if (mark == 33) {
if (!(ent instanceof Guardian))
return;
Class<?> goalGuardianAttack = ReflectionUtils.getNMSClass("EntityGuardian$PathfinderGoalGuardianAttack");
newGoal = ReflectionUtils.getConstructor(goalGuardianAttack, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 34) {
if (!(ent instanceof PigZombie))
return;
target = true;
Class<?> goalAnger = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAnger");
newGoal = ReflectionUtils.getConstructor(goalAnger, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 35) {
if (!(ent instanceof PigZombie))
return;
target = true;
Class<?> goalAngerOther = ReflectionUtils.getNMSClass("EntityPigZombie$PathfinderGoalAngerOther");
newGoal = ReflectionUtils.getConstructor(goalAngerOther, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 36) {
if (!(ent instanceof Rabbit))
return;
Class<?> goalEatCarrots = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalEatCarrots");
newGoal = ReflectionUtils.getConstructor(goalEatCarrots, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 37) {
if (!(ent instanceof Rabbit))
return;
Class<?> goalRabbitAttack = ReflectionUtils.getNMSClass("EntityRabbit$PathfinderGoalKillerRabbitMeleeAttack");
newGoal = ReflectionUtils.getConstructor(goalRabbitAttack, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 38) {
if (!(ent instanceof Slime))
return;
Class<?> goalJump = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomJump");
newGoal = ReflectionUtils.getConstructor(goalJump, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 39) {
if (!(ent instanceof Slime))
return;
Class<?> goalRandomDir = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeRandomDirection");
newGoal = ReflectionUtils.getConstructor(goalRandomDir, nmsEnt.getClass()).newInstance(nmsEnt);
} else if (mark == 40) {
if (!(ent instanceof Slime))
return;
Class<?> goalSlimeWander = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle");
newGoal = ReflectionUtils.getConstructor(goalSlimeWander, nmsEnt.getClass()).newInstance(nmsEnt);
}
try {
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
} finally {
Language.setUseLocal(wasLocal);
}
if (!LivingEntity.class.isAssignableFrom(entityData.getType())) {
if (newGoal == null)
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);
SkStuff.getNMSMethods().addPathfinderGoal(nmsEnt, priority, newGoal, target);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException ex) {
ex.printStackTrace();
}
if (newGoal == null)
return;
SkStuff.getNMSMethods().addPathfinderGoal(nmsEnt, priority, newGoal, target);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}

View File

@ -61,6 +61,13 @@ public class ExprFileNBT extends SimpleExpression<Object> {
if (!file.exists())
return;
Object fileNBT = SkStuff.getNMSMethods().getFileNBT(file);
if (fileNBT == null) {
try {
fileNBT = nbtClass.newInstance();
} catch (InstantiationException | IllegalAccessException ex) {
ex.printStackTrace();
}
}
if (mode == ChangeMode.ADD) {
Object parsedNBT = null;
parsedNBT = SkStuff.getNMSMethods().parseRawNBT((String) delta[0]);
@ -79,7 +86,7 @@ public class ExprFileNBT extends SimpleExpression<Object> {
@Nullable
public Class<?>[] acceptChange(ChangeMode mode) {
if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE) {
return CollectionUtils.array(String[].class);
return CollectionUtils.array(String.class);
}
return null;
}

View File

@ -26,6 +26,8 @@ public interface NMSInterface {
public Object getIndex(Object nbtList, int index);
public void clearPathfinderGoals(Entity entity);
public void removePathfinderGoal(Object entity, Class<?> goalClass, boolean isTargetSelector);
public void addPathfinderGoal(Object entity, int priority, Object goal, boolean isTargetSelector);

View File

@ -166,6 +166,11 @@ public class NMS_v1_7_R4 implements NMSInterface {
return null;
}
@Override
public void clearPathfinderGoals(Entity entity) {
Bukkit.getLogger().warning("Sorry, Pathfinder Goal are only supported in 1.8 and above");
}
@Override
public void removePathfinderGoal(Object entity, Class<?> goalClass, boolean isTargetSelector) {
Bukkit.getLogger().warning("Sorry, Pathfinder Goals are only supported in 1.8 and above");

View File

@ -148,6 +148,15 @@ public class NMS_v1_8_R1 implements NMSInterface {
return null;
}
@Override
public void clearPathfinderGoals(Entity entity) {
EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle();
((List<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((List<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((List<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
((List<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
}
@Override
public void removePathfinderGoal(Object entity, Class<?> goalClass, boolean isTargetSelector) {
if (entity instanceof EntityInsentient) {

View File

@ -154,6 +154,15 @@ public class NMS_v1_8_R2 implements NMSInterface {
return null;
}
@Override
public void clearPathfinderGoals(Entity entity) {
EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle();
((List<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((List<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((List<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
((List<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
}
@Override
public void removePathfinderGoal(Object entity, Class<?> goalClass, boolean isTargetSelector) {
if (entity instanceof EntityInsentient) {

View File

@ -154,6 +154,15 @@ public class NMS_v1_8_R3 implements NMSInterface {
return null;
}
@Override
public void clearPathfinderGoals(Entity entity) {
EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle();
((List<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((List<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((List<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
((List<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
}
@Override
public void removePathfinderGoal(Object entity, Class<?> goalClass, boolean isTargetSelector) {
if (entity instanceof EntityInsentient) {

View File

@ -10,10 +10,12 @@ import java.io.NotSerializableException;
import java.io.OutputStream;
import java.io.StreamCorruptedException;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
@ -155,6 +157,15 @@ public class NMS_v1_9_R1 implements NMSInterface {
return null;
}
@Override
public void clearPathfinderGoals(Entity entity) {
EntityInsentient nmsEnt = (EntityInsentient) ((CraftEntity) entity).getHandle();
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((LinkedHashSet<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.goalSelector)).clear();
((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
((LinkedHashSet<?>) ReflectionUtils.getField("c", PathfinderGoalSelector.class, nmsEnt.targetSelector)).clear();
}
@Override
public void removePathfinderGoal(Object entity, Class<?> goalClass, boolean isTargetSelector) {
if (entity instanceof EntityInsentient) {
@ -205,7 +216,9 @@ public class NMS_v1_9_R1 implements NMSInterface {
@Override
public void change(NBTTagCompound[] NBT, @Nullable Object[] delta, ChangeMode mode) {
Bukkit.broadcastMessage("Changing a compound");
if (mode == ChangeMode.SET) {
Bukkit.broadcastMessage("is setting");
if (delta[0] instanceof NBTTagCompound) {
NBT[0] = (NBTTagCompound) delta[0];
} else {
@ -214,6 +227,7 @@ public class NMS_v1_9_R1 implements NMSInterface {
NBT[0] = parsedNBT;
}
} else if (mode == ChangeMode.ADD) {
Bukkit.broadcastMessage("is adding");
if (delta[0] instanceof String) {
NBTTagCompound parsedNBT = null;
parsedNBT = parseRawNBT((String) delta[0]);
@ -222,6 +236,7 @@ public class NMS_v1_9_R1 implements NMSInterface {
addToCompound(NBT[0], delta[0]);
}
} else if (mode == ChangeMode.REMOVE) {
Bukkit.broadcastMessage("is removing");
if (delta[0] instanceof NBTTagCompound)
return;
for (Object s : delta) {
@ -308,13 +323,14 @@ public class NMS_v1_9_R1 implements NMSInterface {
@Nullable
public Class<?>[] acceptChange(ChangeMode mode) {
if (mode == ChangeMode.ADD || mode == ChangeMode.SET || mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
return CollectionUtils.array(Float[].class, Double[].class, String[].class, NBTTagCompound[].class, Integer[].class, NBTTagList[].class);
return CollectionUtils.array(Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, String.class, NBTTagCompound.class, NBTTagList.class);
}
return null;
}
@Override
public void change(NBTTagList[] nbtList, @Nullable Object[] delta, ChangeMode mode) {
Bukkit.broadcastMessage("Changing a NBTList");
int typeId = 0;
if (delta instanceof Byte[]) {
typeId = 1;
@ -335,9 +351,11 @@ public class NMS_v1_9_R1 implements NMSInterface {
} else if (delta instanceof NBTTagCompound[]) {
typeId = 10;
} else {
Bukkit.broadcastMessage("No compatible class: " + delta.getClass() + "\nStopping...");
return;
}
if (mode == ChangeMode.SET) {
Bukkit.broadcastMessage("is setting");
if (typeId == 9)
nbtList[0] = (NBTTagList) delta[0];
} else if (mode == ChangeMode.ADD) {
@ -350,6 +368,7 @@ public class NMS_v1_9_R1 implements NMSInterface {
addToList(nbtList, delta[0]);
}
} else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
Bukkit.broadcastMessage("Is deleting/resetting");
nbtList[0] = new NBTTagList();
}
}

View File

@ -57,7 +57,7 @@ public class ReflectionUtils {
}
}
public static Constructor<?> getConstructor(String constructor, Class<?> clazz, Object object, Class<?> ... params) {
public static Constructor<?> getConstructor(Class<?> clazz, Class<?> ... params) {
Constructor<?> constr = null;
try {
constr = clazz.getDeclaredConstructor(params);