Closer and closer to a release!
Few changes to pathfinder goals, new "proper" clicked inventory expression, let Skript debug "toString()" if needed.
This commit is contained in:
@@ -29,8 +29,8 @@ public class EffClearPathGoals extends Effect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "clear all pathfind goals of " + entity.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "clear all pathfinder goals from " + entity.toString(e, debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,8 +29,8 @@ public class EffDrainLiquid extends Effect {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "drain liquids at " + location.toString(e, false) + " in a radius of " + radius.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "drain liquids at " + location.toString(e, debug) + " in a radius of " + radius.toString(e, debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,8 +41,8 @@ public class EffDrawLineWE extends Effect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "draw a line from " + location1.toString(e, false) + " to " + location2.toString(e, false) + " using an edit session with " + blockList.toString(e, false) + " and thickness " + thickness.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "draw a line from " + location1.toString(e, debug) + " to " + location2.toString(e, debug) + " using an edit session with " + blockList.toString(e, debug) + " and thickness " + thickness.toString(e, debug);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -43,8 +43,8 @@ public class EffMakeCylinder extends Effect {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "create a cylinder at " + location.toString(e, false) + " with a radius of " + radius1.toString(e, false) + " " + height.toString(e, false) + " " + radius2.toString(e, false) + " using an edit session with " + blockList.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "create a cylinder at " + location.toString(e, debug) + " with a radius of " + radius1.toString(e, debug) + " " + height.toString(e, debug) + " " + radius2.toString(e, debug) + " using an edit session with " + blockList.toString(e, debug);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -27,15 +28,15 @@ public class EffMakeJump extends Effect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "make " + entities.toString(e, false) + " jump";
|
||||
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 instanceof Player || ent == null)
|
||||
if (ent == null || ent instanceof Player || ent instanceof ArmorStand)
|
||||
continue;
|
||||
Object obcEnt = craftLivEnt.cast(ent);
|
||||
try {
|
||||
|
||||
@@ -39,8 +39,8 @@ public class EffMakePyramid extends Effect {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "create a pyramid at " + location.toString(e, false) + " with a radius of " + radius.toString(e, false) + " using an edit session with " + blockList.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "create a pyramid at " + location.toString(e, debug) + " with a radius of " + radius.toString(e, debug) + " using an edit session with " + blockList.toString(e, debug);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -43,8 +43,8 @@ public class EffMakeSphere extends Effect {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "create a sphere centered at " + location.toString(e, false) + " with a radius of " + radius1.toString(e, false) + " " + radius2.toString(e, false) + " " + radius3.toString(e, false) + " using an edit session with " + blockList.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "create a sphere centered at " + location.toString(e, debug) + " with a radius of " + radius1.toString(e, debug) + " " + radius2.toString(e, debug) + " " + radius3.toString(e, debug) + " using an edit session with " + blockList.toString(e, debug);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -38,8 +38,8 @@ public class EffMakeWalls extends Effect {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "make walls from " + location1.toString(e, false) + " to " + location2.toString(e, false) + " using an edit session with " + blockList.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "make walls from " + location1.toString(e, debug) + " to " + location2.toString(e, debug) + " using an edit session with " + blockList.toString(e, debug);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -30,8 +30,8 @@ public class EffNaturalize extends Effect {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "naturalize all blocks from " + location1.toString(e, false) + " to " + location2.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "naturalize all blocks from " + location1.toString(e, debug) + " to " + location2.toString(e, debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package me.TheBukor.SkStuff.effects;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldedit.data.DataException;
|
||||
import com.sk89q.worldedit.schematic.SchematicFormat;
|
||||
|
||||
import ch.njol.skript.lang.Effect;
|
||||
import ch.njol.skript.lang.Expression;
|
||||
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||
import ch.njol.util.Kleenean;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class EffPasteSchematic extends Effect {
|
||||
private Expression<String> schematic;
|
||||
private Expression<Location> location;
|
||||
private Expression<EditSession> editSession;
|
||||
|
||||
private int mark;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
|
||||
mark = result.mark;
|
||||
schematic = (Expression<String>) expr[0];
|
||||
location = (Expression<Location>) expr[1];
|
||||
editSession = (Expression<EditSession>) expr[2];
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "paste schematic " + schematic.toString(e, debug) + " at " + location.toString(e, debug) + " using edit session" + (mark == 1 ? " ignoring air" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(Event e) {
|
||||
String schem = schematic.getSingle(e);
|
||||
Location loc = location.getSingle(e);
|
||||
EditSession session = editSession.getSingle(e);
|
||||
Vector origin = BukkitUtil.toVector(loc);
|
||||
boolean noAir = false;
|
||||
if (mark == 1)
|
||||
noAir = true;
|
||||
File schemFile = new File((schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
|
||||
if (!schemFile.exists() || session == null)
|
||||
return;
|
||||
try {
|
||||
SchematicFormat.getFormat(schemFile).load(schemFile).paste(session, origin, noAir);
|
||||
} catch (MaxChangedBlocksException | DataException | IOException ex) {
|
||||
if (ex instanceof MaxChangedBlocksException)
|
||||
return;
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,8 @@ public class EffRememberChanges extends Effect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "make " + player.toString(e, false) + " remember changes from edit session";
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "make " + player.toString(e, debug) + " remember changes from edit session";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,8 +6,11 @@ import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Blaze;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import ch.njol.skript.lang.Effect;
|
||||
@@ -21,33 +24,8 @@ public class EffRemovePathGoal extends Effect {
|
||||
|
||||
private int mark;
|
||||
|
||||
private Class<?> goalSelectorClass = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
|
||||
private Class<?> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget", false);
|
||||
private Class<?> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed", false);
|
||||
private Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor", false);
|
||||
private Class<?> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile", false);
|
||||
private Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun", false);
|
||||
private Class<?> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat", false);
|
||||
private Class<?> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner", false);
|
||||
private Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent", false);
|
||||
private Class<?> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget", false);
|
||||
private Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock", false);
|
||||
private Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget", false);
|
||||
private Class<?> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer", false);
|
||||
private Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack", false);
|
||||
private Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget", false);
|
||||
private Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget", false);
|
||||
private Class<?> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack", false);
|
||||
private Class<?> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor", false);
|
||||
private Class<?> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic", false);
|
||||
private Class<?> goalRandomLook = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround", false);
|
||||
private Class<?> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll", false);
|
||||
private Class<?> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit", false);
|
||||
private Class<?> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell", false);
|
||||
|
||||
private Class<?> entBlaze = ReflectionUtils.getNMSClass("EntityBlaze", false);
|
||||
private Class<?> entInsent = ReflectionUtils.getNMSClass("EntityInsentient", false);
|
||||
private Class<?> entSquid = ReflectionUtils.getNMSClass("EntitySquid", false);
|
||||
private Class<?> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -59,11 +37,10 @@ public class EffRemovePathGoal extends Effect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "remove pathfind goal of " + entity.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "remove pathfinder goal from " + entity.toString(e, debug);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unused" })
|
||||
@Override
|
||||
protected void execute(Event e) {
|
||||
LivingEntity ent = entity.getSingle(e);
|
||||
@@ -75,79 +52,146 @@ public class EffRemovePathGoal extends Effect {
|
||||
Object goalSelector = ReflectionUtils.getField("goalSelector", entInsent, nmsEnt);
|
||||
Object targetSelector = ReflectionUtils.getField("targetSelector", entInsent, nmsEnt);
|
||||
Object toRemove = null;
|
||||
boolean target = false;
|
||||
if (mark == 0) {
|
||||
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) {
|
||||
toRemove = goalMeleeAttack;
|
||||
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) {
|
||||
toRemove = goalGotoTarget;
|
||||
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) {
|
||||
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<?>[] classes = entSquid.getDeclaredClasses();
|
||||
for (Class<?> c : classes) {
|
||||
Bukkit.broadcastMessage("\u00A79loop-class: \u00A7b" + c);
|
||||
if (c.getSimpleName().equals("PathfinderGoalSquid")) {
|
||||
toRemove = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Class<?> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid", false);
|
||||
toRemove = goalSquid;
|
||||
} else if (mark == 23) {
|
||||
Class<?>[] classes = entBlaze.getDeclaredClasses();
|
||||
for (Class<?> c : classes) {
|
||||
Bukkit.broadcastMessage("\u00A79loop-class: \u00A7b" + c);
|
||||
if (c.getSimpleName().equals("PathfinderGoalBlazeFireball")) {
|
||||
toRemove = c;
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (toRemove == null)
|
||||
return;
|
||||
Iterator<?> goals = ((List<?>) ReflectionUtils.getField("b", goalSelectorClass, goalSelector)).iterator();
|
||||
Iterator<?> goalPriorities = ((List<?>) ReflectionUtils.getField("c", goalSelectorClass, goalSelector)).iterator();
|
||||
while (goals.hasNext()) {
|
||||
Object o = goals.next();
|
||||
goalPriorities.next();
|
||||
if (ReflectionUtils.getField("a", o.getClass(), o).getClass() == toRemove) {
|
||||
goals.remove();
|
||||
goalPriorities.remove();
|
||||
Class<?> goalSelectorClass = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
|
||||
if (target) {
|
||||
Iterator<?> targets = ((List<?>) ReflectionUtils.getField("b", goalSelectorClass, targetSelector)).iterator();
|
||||
while (targets.hasNext()) {
|
||||
Object o = targets.next();
|
||||
Bukkit.broadcastMessage("Class: \u00A7a" + ReflectionUtils.getField("a", o.getClass(), o).getClass().getSimpleName());
|
||||
if (ReflectionUtils.getField("a", o.getClass(), o).getClass() == toRemove) {
|
||||
Bukkit.broadcastMessage("\u00A72Is same class");
|
||||
targets.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Iterator<?> goals = ((List<?>) ReflectionUtils.getField("b", goalSelectorClass, goalSelector)).iterator();
|
||||
while (goals.hasNext()) {
|
||||
Object o = goals.next();
|
||||
Bukkit.broadcastMessage("Class: \u00A7a" + ReflectionUtils.getField("a", o.getClass(), o).getClass().getSimpleName());
|
||||
if (ReflectionUtils.getField("a", o.getClass(), o).getClass() == toRemove) {
|
||||
Bukkit.broadcastMessage("\u00A72Is same class");
|
||||
goals.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
@@ -43,8 +43,8 @@ public class EffReplaceBlocksWE extends Effect {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "replace all " + blockList1.toString(e, false) + " from " + location1.toString(e, false) + " to " + location2.toString(e, false) + " with " + blockList1.toString(e, false) + " using an edit session";
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "replace all " + blockList1.toString(e, debug) + " from " + location1.toString(e, debug) + " to " + location2.toString(e, debug) + " with " + blockList1.toString(e, debug) + " using an edit session";
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "deprecation" })
|
||||
|
||||
@@ -38,8 +38,8 @@ public class EffSetBlocksWE extends Effect {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "set all blocks from " + location1.toString(e, false) + " to " + location2.toString(e, false) + " to " + blockList.toString(e, false) + " using an edit session";
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "set all blocks from " + location1.toString(e, debug) + " to " + location2.toString(e, debug) + " to " + blockList.toString(e, debug) + " using an edit session";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package me.TheBukor.SkStuff.effects;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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.LivingEntity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Silverfish;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.entity.Squid;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.Event;
|
||||
@@ -48,31 +54,6 @@ public class EffSetPathGoal extends Effect {
|
||||
|
||||
private int mark;
|
||||
|
||||
private Class<?> goal = ReflectionUtils.getNMSClass("PathfinderGoal", false);
|
||||
private Class<?> goalSelector = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
|
||||
private Class<?> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget", false);
|
||||
private Class<?> goalBreed = ReflectionUtils.getNMSClass("PathfinderGoalBreed", false);
|
||||
private Class<?> goalBreakDoor = ReflectionUtils.getNMSClass("PathfinderGoalBreakDoor", false);
|
||||
private Class<?> goalEatGrass = ReflectionUtils.getNMSClass("PathfinderGoalEatTile", false);
|
||||
private Class<?> goalFleeSun = ReflectionUtils.getNMSClass("PathfinderGoalFleeSun", false);
|
||||
private Class<?> goalFloat = ReflectionUtils.getNMSClass("PathfinderGoalFloat", false);
|
||||
private Class<?> goalFollowOwner = ReflectionUtils.getNMSClass("PathfinderGoalFollowOwner", false);
|
||||
private Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent", false);
|
||||
private Class<?> goalReactAttack = ReflectionUtils.getNMSClass("PathfinderGoalHurtByTarget", false);
|
||||
private Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock", false);
|
||||
private Class<?> goalLeapTarget = ReflectionUtils.getNMSClass("PathfinderGoalLeapAtTarget", false);
|
||||
private Class<?> goalLookEntities = ReflectionUtils.getNMSClass("PathfinderGoalLookAtPlayer", false);
|
||||
private Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack", false);
|
||||
private Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget", false);
|
||||
private Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget", false);
|
||||
private Class<?> goalOcelotAttack = ReflectionUtils.getNMSClass("PathfinderGoalOcelotAttack", false);
|
||||
private Class<?> goalOpenDoors = ReflectionUtils.getNMSClass("PathfinderGoalOpenDoor", false);
|
||||
private Class<?> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic", false);
|
||||
private Class<?> goalRandomLook = ReflectionUtils.getNMSClass("PathfinderGoalRandomLookaround", false);
|
||||
private Class<?> goalWander = ReflectionUtils.getNMSClass("PathfinderGoalRandomStroll", false);
|
||||
private Class<?> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit", false);
|
||||
private Class<?> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell", false);
|
||||
|
||||
private Class<?> craftLivEnt = ReflectionUtils.getOBCClass("entity.CraftLivingEntity");
|
||||
private Class<?> entAnimal = ReflectionUtils.getNMSClass("EntityAnimal", false);
|
||||
private Class<?> entCreature = ReflectionUtils.getNMSClass("EntityCreature", false);
|
||||
@@ -125,8 +106,8 @@ public class EffSetPathGoal extends Effect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "add pathfinder goal to ent";
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "add pathfinder goal to entity";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -136,26 +117,26 @@ public class EffSetPathGoal extends Effect {
|
||||
if (goalPriority != null) {
|
||||
priority = goalPriority.getSingle(e).intValue();
|
||||
} else {
|
||||
priority = 1;
|
||||
priority = 4;
|
||||
}
|
||||
if (priority < 0) {
|
||||
if (priority < 1) {
|
||||
priority = 1;
|
||||
} else if (priority > 9) {
|
||||
priority = 9;
|
||||
}
|
||||
LivingEntity ent = entity.getSingle(e);
|
||||
if (ent instanceof Player || ent == null)
|
||||
if (ent == null ||ent instanceof Player)
|
||||
return;
|
||||
Object obcEnt = craftLivEnt.cast(ent);
|
||||
Object nmsEnt = null;
|
||||
Class<?> clazz = null;
|
||||
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) {
|
||||
Class<?> goalAvoid = ReflectionUtils.getNMSClass("PathfinderGoalAvoidTarget", false);
|
||||
float radius = avoidRadius.getSingle(e).floatValue();
|
||||
double spd1 = avoidSpeed1.getSingle(e).doubleValue();
|
||||
double spd2 = avoidSpeed2.getSingle(e).doubleValue();
|
||||
@@ -165,6 +146,9 @@ public class EffSetPathGoal extends Effect {
|
||||
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";
|
||||
@@ -174,43 +158,47 @@ public class EffSetPathGoal extends Effect {
|
||||
return;
|
||||
newGoal = goalAvoid.getConstructor(entCreature, Class.class, float.class, double.class, double.class).newInstance(nmsEnt, nmsClass, radius, spd1, spd2);
|
||||
} 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 = breedSpeed.getSingle(e).doubleValue();
|
||||
if (!(ent instanceof Animals)) {
|
||||
Bukkit.broadcastMessage("\u00A7c" + ent.getType().toString() + " is not an animal - \u00A7e[DEBUG MESSAGE]");
|
||||
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 = 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 = followOwnerSpeed.getSingle(e).doubleValue();
|
||||
if (!(ent instanceof Tameable)) {
|
||||
Bukkit.broadcastMessage("\u00A7c" + ent.getType().toString() + " is not a tameable animal - \u00A7e[DEBUG MESSAGE]");
|
||||
if (!(ent instanceof Tameable))
|
||||
return;
|
||||
}
|
||||
newGoal = goalFollowOwner.getConstructor(entTameable, double.class, float.class, float.class).newInstance(nmsEnt, spd, 20.0F, 5.0F);
|
||||
} else if (mark == 7) {
|
||||
Class<?> goalFollowAdults = ReflectionUtils.getNMSClass("PathfinderGoalFollowParent", false);
|
||||
double spd = followAdultsSpeed.getSingle(e).doubleValue();
|
||||
if (!(ent instanceof Animals)) {
|
||||
Bukkit.broadcastMessage("\u00A7c" + ent.getType().toString() + " is not an animal - \u00A7e[DEBUG MESSAGE]");
|
||||
if (!(ent instanceof Animals))
|
||||
return;
|
||||
}
|
||||
newGoal = goalFollowAdults.getConstructor(entAnimal, double.class).newInstance(nmsEnt, spd);
|
||||
} else if (mark == 8) {
|
||||
target = true;
|
||||
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";
|
||||
@@ -220,20 +208,25 @@ public class EffSetPathGoal extends Effect {
|
||||
return;
|
||||
newGoal = goalReactAttack.getConstructor(entCreature, boolean.class, Class[].class).newInstance(nmsEnt, false, nmsClass[0]);
|
||||
} else if (mark == 9) {
|
||||
Class<?> goalJumpOnBlock = ReflectionUtils.getNMSClass("PathfinderGoalJumpOnBlock", false);
|
||||
double 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 = 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";
|
||||
@@ -250,16 +243,41 @@ public class EffSetPathGoal extends Effect {
|
||||
exprInput = exprInput.substring(4);
|
||||
}
|
||||
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
||||
String className = entityData.getType().getSimpleName();
|
||||
if (className.equals("HumanEntity"))
|
||||
className = "Human";
|
||||
className = "Entity" + className;
|
||||
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
||||
if (nmsClass == null)
|
||||
if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
|
||||
return;
|
||||
double spd = meleeSpeed.getSingle(e).doubleValue();
|
||||
newGoal = goalMeleeAttack.getConstructor(entCreature, Class.class, double.class, boolean.class).newInstance(nmsEnt, nmsClass, spd, false);
|
||||
if (ent instanceof Spider) {
|
||||
Class<?>[] classes = nmsEnt.getClass().getDeclaredClasses();
|
||||
Class<?> clazz = null;
|
||||
for (Class<?> c : classes) {
|
||||
Bukkit.broadcastMessage("Class name: \u00A7e" + c.getName());
|
||||
if (c.getName().equals("PathfinderGoalSpiderMeleeAttack"))
|
||||
clazz = c;
|
||||
}
|
||||
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
|
||||
Constructor<?> constr = null;
|
||||
for (Constructor<?> constructor : constructors) {
|
||||
Bukkit.broadcastMessage("Constructor name: \u00A7a" + constructor.getName());
|
||||
if (constructor.getName().equals("PathfinderGoalSpiderMeleeAttack"))
|
||||
constr = constructor;
|
||||
}
|
||||
if (constr == null)
|
||||
return;
|
||||
constr.setAccessible(true);
|
||||
newGoal = constr.newInstance(nmsEnt, entityData);
|
||||
} else {
|
||||
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack", false);
|
||||
String className = entityData.getType().getSimpleName();
|
||||
if (className.equals("HumanEntity"))
|
||||
className = "Human";
|
||||
className = "Entity" + className;
|
||||
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
||||
if (nmsClass == null)
|
||||
return;
|
||||
double spd = meleeSpeed.getSingle(e).doubleValue();
|
||||
newGoal = goalMeleeAttack.getConstructor(entCreature, Class.class, double.class, boolean.class).newInstance(nmsEnt, nmsClass, spd, false);
|
||||
}
|
||||
} else if (mark == 13) {
|
||||
Class<?> goalGotoTarget = ReflectionUtils.getNMSClass("PathfinderGoalMoveTowardsTarget", false);
|
||||
double spd = moveTargetSpeed.getSingle(e).doubleValue();
|
||||
float radius = moveTargetRadius.getSingle(e).floatValue();
|
||||
newGoal = goalGotoTarget.getConstructor(entCreature, double.class, float.class).newInstance(nmsEnt, spd, radius);
|
||||
@@ -271,100 +289,147 @@ public class EffSetPathGoal extends Effect {
|
||||
exprInput = exprInput.substring(4);
|
||||
}
|
||||
entityData = EntityData.parseWithoutIndefiniteArticle(exprInput);
|
||||
String className = entityData.getType().getSimpleName();
|
||||
if (className.equals("HumanEntity"))
|
||||
className = "Human";
|
||||
className = "Entity" + className;
|
||||
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
||||
if (nmsClass == null)
|
||||
if (!LivingEntity.class.isAssignableFrom(entityData.getType()))
|
||||
return;
|
||||
newGoal = goalNearTarget.getConstructor(entCreature, Class.class, boolean.class).newInstance(nmsEnt, nmsClass, false);
|
||||
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, entityData);
|
||||
} else {
|
||||
Class<?> goalNearTarget = ReflectionUtils.getNMSClass("PathfinderGoalNearestAttackableTarget", false);
|
||||
String className = entityData.getType().getSimpleName();
|
||||
if (className.equals("HumanEntity"))
|
||||
className = "Human";
|
||||
className = "Entity" + className;
|
||||
Class<?> nmsClass = ReflectionUtils.getNMSClass(className, false);
|
||||
if (nmsClass == null)
|
||||
return;
|
||||
newGoal = goalNearTarget.getConstructor(entCreature, Class.class, boolean.class).newInstance(nmsEnt, nmsClass, false);
|
||||
}
|
||||
} 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) {
|
||||
Class<?> goalPanic = ReflectionUtils.getNMSClass("PathfinderGoalPanic", false);
|
||||
double spd = panicSpeed.getSingle(e).doubleValue();
|
||||
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 = randomWalkSpeed.getSingle(e).doubleValue();
|
||||
int interval = randomWalkInterval.getSingle(e).getTicks();
|
||||
newGoal = goalWander.getConstructor(entCreature, double.class, int.class).newInstance(nmsEnt, spd, interval);
|
||||
} else if (mark == 20) {
|
||||
if (!(ent instanceof Tameable)) {
|
||||
Bukkit.broadcastMessage("\u00A7c" + ent.getType().toString() + " is not a tameable animal - \u00A7e[DEBUG MESSAGE]");
|
||||
Class<?> goalSit = ReflectionUtils.getNMSClass("PathfinderGoalSit", false);
|
||||
if (!(ent instanceof Tameable))
|
||||
return;
|
||||
}
|
||||
newGoal = goalSit.getConstructor(entTameable).newInstance(nmsEnt);
|
||||
} else if (mark == 21) {
|
||||
if (!(ent instanceof Creeper)) {
|
||||
Bukkit.broadcastMessage("\u00A7c" + ent.getType().toString() + " is not a creeper - \u00A7e[DEBUG MESSAGE]");
|
||||
Class<?> goalSwell = ReflectionUtils.getNMSClass("PathfinderGoalSwell", false);
|
||||
if (!(ent instanceof Creeper))
|
||||
return;
|
||||
}
|
||||
newGoal = goalSwell.getConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
||||
} else if (mark == 22) {
|
||||
if (!(ent instanceof Squid)) {
|
||||
Bukkit.broadcastMessage("\u00A7c" + ent.getType().toString() + " is not a squid - \u00A7e[DEBUG MESSAGE]");
|
||||
Class<?> goalSquid = ReflectionUtils.getNMSClass("EntitySquid$PathfinderGoalSquid", false);
|
||||
if (!(ent instanceof Squid))
|
||||
return;
|
||||
}
|
||||
Class<?>[] classes = nmsEnt.getClass().getDeclaredClasses();
|
||||
for (Class<?> c : classes) {
|
||||
Bukkit.broadcastMessage("\u00A79loop-class: \u00A7b" + c);
|
||||
if (c.getSimpleName().equals("PathfinderGoalSquid")) {
|
||||
clazz = c;
|
||||
clazz.getConstructor(nmsEnt.getClass()).setAccessible(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (clazz == null)
|
||||
return;
|
||||
newGoal = clazz.getConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
||||
clazz.getConstructor(nmsEnt.getClass()).setAccessible(false);
|
||||
Constructor<?> constr = goalSquid.getDeclaredConstructor(nmsEnt.getClass());
|
||||
constr.setAccessible(true);
|
||||
newGoal = constr.newInstance(nmsEnt);
|
||||
} else if (mark == 23) {
|
||||
if (!(ent instanceof Blaze)) {
|
||||
Bukkit.broadcastMessage("\u00A7c" + ent.getType().toString() + " is not a blaze - \u00A7e[DEBUG MESSAGE]");
|
||||
return;
|
||||
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);
|
||||
}
|
||||
Class<?>[] classes = nmsEnt.getClass().getDeclaredClasses();
|
||||
for (Class<?> c : classes) {
|
||||
Bukkit.broadcastMessage("\u00A79loop-class: \u00A7b" + c);
|
||||
if (c.getSimpleName().equals("PathfinderGoalBlazeFireball")) {
|
||||
clazz = c;
|
||||
clazz.getConstructor(nmsEnt.getClass()).setAccessible(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (clazz == null)
|
||||
return;
|
||||
newGoal = clazz.getConstructor(nmsEnt.getClass()).newInstance(nmsEnt);
|
||||
clazz.getConstructor(nmsEnt.getClass()).setAccessible(false);
|
||||
} else if (mark == 24) {
|
||||
Class<?> goalHideInBlock = ReflectionUtils.getNMSClass("EntitySilverfish$PathfinderGoalSilverfishHideInBlocks", 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) {
|
||||
// TODO: Add more goal/target selectors
|
||||
|
||||
/* Classes that have their own pathfinder goals:
|
||||
* Enderman, 3 goals, place blocks, pickup blocks and player who looked (?).
|
||||
* Ghast, 3 goals, all copy of existing ones, but adapted to a flying ghast.
|
||||
* Rabbit, 3 goals, 2 adapted copies, 1 new (eat carrot crops)
|
||||
* Silverfish, 2 goals, hide in block and wake other silverfish blocks.
|
||||
* Slime, 4 goals, random jump, go to near player, go in random direction and idle.
|
||||
* Spider, 2 goals, adapted copies of melee and nearest attackable.
|
||||
* ZPigMan, 2 goals, anger and anger other (adapted HurtByTarget to work with Anger tag)
|
||||
*/
|
||||
|
||||
/* Goals to add:
|
||||
* Tempt - Mob follows you with a certain item in hand (e.g cow follows wheat)
|
||||
* AttackNonTamed - Used by ocelots, to attack chickens (maybe for wolves to attack sheep to?)
|
||||
*/
|
||||
}
|
||||
if (newGoal == null)
|
||||
return;
|
||||
Class<?> goal = ReflectionUtils.getNMSClass("PathfinderGoal", false);
|
||||
Class<?> goalSelector = ReflectionUtils.getNMSClass("PathfinderGoalSelector", false);
|
||||
if (target) {
|
||||
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(targets, priority, newGoal);
|
||||
} else {
|
||||
newGoal = goalSelector.getMethod("a", int.class, goal).invoke(goals, priority, newGoal);
|
||||
|
||||
}
|
||||
} catch (Exception ex1) {
|
||||
if (clazz != null)
|
||||
try {
|
||||
clazz.getConstructor(nmsEnt.getClass()).setAccessible(true);
|
||||
} catch (SecurityException | NoSuchMethodException ex2) {
|
||||
ex2.printStackTrace();
|
||||
}
|
||||
ex1.printStackTrace();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,8 +44,8 @@ public class EffShowEntityEffect extends Effect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "play entity effect " + toStringMark + "at" + entity.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "play entity effect " + toStringMark + "at" + entity.toString(e, debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,8 +29,8 @@ public class EffSimulateSnow extends Effect {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "make " + location.toString(e, false) + " snowy in a radius of " + radius.toString(e, false);
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "make " + location.toString(e, debug) + " snowy in a radius of " + radius.toString(e, debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,8 +31,8 @@ public class EffToggleVanish extends Effect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
return "toggle vanished state of " + player.toString(e, false) + toStringMark;
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return "toggle vanished state of " + player.toString(e, debug) + toStringMark;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,7 @@ public class EffUndoRedoSession extends Effect {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(@Nullable Event e, boolean arg1) {
|
||||
public String toString(@Nullable Event e, boolean debug) {
|
||||
return (redo == true ? "redo " : "undo ") + "changes from edit session";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user