Add files via upload
1.13 & 1.14 update
This commit is contained in:
parent
97eafe9ddd
commit
ecda37b584
3
src/META-INF/MANIFEST.MF
Normal file
3
src/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: me.TheBukor.SkStuff.SkStuff
|
||||
|
@ -7,93 +7,41 @@ import javax.annotation.Nullable;
|
||||
import me.TheBukor.SkStuff.util.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityToggleGlideEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.kitteh.vanish.event.VanishStatusChangeEvent;
|
||||
import org.mcstats.Metrics;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldguard.bukkit.WGBukkit;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
|
||||
import ch.njol.skript.Skript;
|
||||
import ch.njol.skript.classes.ClassInfo;
|
||||
import ch.njol.skript.classes.Parser;
|
||||
import ch.njol.skript.expressions.base.EventValueExpression;
|
||||
import ch.njol.skript.lang.ExpressionType;
|
||||
import ch.njol.skript.lang.ParseContext;
|
||||
import ch.njol.skript.lang.util.SimpleEvent;
|
||||
import ch.njol.skript.registrations.Classes;
|
||||
import ch.njol.skript.registrations.EventValues;
|
||||
import ch.njol.skript.util.Getter;
|
||||
import me.TheBukor.SkStuff.conditions.CondSelectionContains;
|
||||
import me.TheBukor.SkStuff.effects.EffClearPathGoals;
|
||||
import me.TheBukor.SkStuff.effects.EffDrainLiquid;
|
||||
import me.TheBukor.SkStuff.effects.EffDrawLineWE;
|
||||
import me.TheBukor.SkStuff.effects.EffGZipFile;
|
||||
import me.TheBukor.SkStuff.effects.EffMakeCylinder;
|
||||
import me.TheBukor.SkStuff.effects.EffMakeJump;
|
||||
import me.TheBukor.SkStuff.effects.EffMakePyramid;
|
||||
import me.TheBukor.SkStuff.effects.EffMakeSphere;
|
||||
import me.TheBukor.SkStuff.effects.EffMakeWalls;
|
||||
import me.TheBukor.SkStuff.effects.EffNaturalize;
|
||||
import me.TheBukor.SkStuff.effects.EffPasteSchematic;
|
||||
import me.TheBukor.SkStuff.effects.EffRememberChanges;
|
||||
import me.TheBukor.SkStuff.effects.EffRemovePathGoal;
|
||||
import me.TheBukor.SkStuff.effects.EffReplaceBlocksWE;
|
||||
import me.TheBukor.SkStuff.effects.EffResourceSound;
|
||||
import me.TheBukor.SkStuff.effects.EffSetBlocksWE;
|
||||
import me.TheBukor.SkStuff.effects.EffSetPathGoal;
|
||||
import me.TheBukor.SkStuff.effects.EffShowEntityEffect;
|
||||
import me.TheBukor.SkStuff.effects.EffSimulateSnow;
|
||||
import me.TheBukor.SkStuff.effects.EffToggleVanish;
|
||||
import me.TheBukor.SkStuff.effects.EffUndoRedoSession;
|
||||
import me.TheBukor.SkStuff.events.EvtWorldEditChange;
|
||||
import me.TheBukor.SkStuff.events.WorldEditChangeHandler;
|
||||
import me.TheBukor.SkStuff.expressions.ExprChangedBlocksSession;
|
||||
import me.TheBukor.SkStuff.expressions.ExprClickedInventory;
|
||||
import me.TheBukor.SkStuff.expressions.ExprEditSessionLimit;
|
||||
import me.TheBukor.SkStuff.expressions.ExprFileNBT;
|
||||
|
||||
import me.TheBukor.SkStuff.expressions.ExprFireProof;
|
||||
import me.TheBukor.SkStuff.expressions.ExprFlagOfWGRegion;
|
||||
import me.TheBukor.SkStuff.expressions.ExprFlagsOfWGRegion;
|
||||
import me.TheBukor.SkStuff.expressions.ExprGlideState;
|
||||
import me.TheBukor.SkStuff.expressions.ExprInventoryOwner;
|
||||
import me.TheBukor.SkStuff.expressions.ExprItemNBT;
|
||||
import me.TheBukor.SkStuff.expressions.ExprLastLocation;
|
||||
import me.TheBukor.SkStuff.expressions.ExprMCIdOf;
|
||||
import me.TheBukor.SkStuff.expressions.ExprMCIdToItem;
|
||||
import me.TheBukor.SkStuff.expressions.ExprNBTListContents;
|
||||
import me.TheBukor.SkStuff.expressions.ExprNBTListIndex;
|
||||
import me.TheBukor.SkStuff.expressions.ExprNBTOf;
|
||||
import me.TheBukor.SkStuff.expressions.ExprNewEditSession;
|
||||
|
||||
|
||||
|
||||
import me.TheBukor.SkStuff.expressions.ExprNoClip;
|
||||
import me.TheBukor.SkStuff.expressions.ExprNoGravityState;
|
||||
import me.TheBukor.SkStuff.expressions.ExprRegionsWithinLocation;
|
||||
import me.TheBukor.SkStuff.expressions.ExprSchematicArea;
|
||||
import me.TheBukor.SkStuff.expressions.ExprSelectionArea;
|
||||
import me.TheBukor.SkStuff.expressions.ExprSelectionOfPlayer;
|
||||
import me.TheBukor.SkStuff.expressions.ExprSelectionPos;
|
||||
import me.TheBukor.SkStuff.expressions.ExprStepLength;
|
||||
import me.TheBukor.SkStuff.expressions.ExprSuperPickaxe;
|
||||
import me.TheBukor.SkStuff.expressions.ExprTagOf;
|
||||
|
||||
import me.TheBukor.SkStuff.expressions.ExprTimespanToNumber;
|
||||
import me.TheBukor.SkStuff.expressions.ExprToLowerCase;
|
||||
import me.TheBukor.SkStuff.expressions.ExprToUpperCase;
|
||||
import me.TheBukor.SkStuff.expressions.ExprVanishState;
|
||||
import me.TheBukor.SkStuff.expressions.ExprWGMemberOwner;
|
||||
import me.TheBukor.SkStuff.expressions.ExprWordsToUpperCase;
|
||||
|
||||
public class SkStuff extends JavaPlugin {
|
||||
@ -111,11 +59,11 @@ public class SkStuff extends JavaPlugin {
|
||||
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.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0¦firework[s] explo(de|sion)|1¦hurt|2¦[[iron] golem] (give|offer) (rose|poppy)|3¦[sheep] eat grass|4¦wolf shake) at %entity%");
|
||||
Skript.registerExpression(ExprToUpperCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] (cap[ital]s|upper[ ]case)", "convert %string% to [all] (cap[ital]s|upper[ ]case)", "capitalize [all] [char[acter]s (of|in)] %string%");
|
||||
Skript.registerExpression(ExprToLowerCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] lower[ ]case", "convert %string% to [all] lower[ ]case", "un[( |-)]capitalize [all] [char[acter]s (of|in)] %string%");
|
||||
Skript.registerExpression(ExprWordsToUpperCase.class, String.class, ExpressionType.SIMPLE, "(first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% [converted] to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "convert (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "capitalize (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])");
|
||||
Skript.registerExpression(ExprTimespanToNumber.class, Number.class, ExpressionType.SIMPLE, "%timespan% [converted] [in]to (0¦ticks|1¦sec[ond]s|2¦min[ute]s|3¦hours|4¦days)");
|
||||
Skript.registerExpression(ExprWordsToUpperCase.class, String.class, ExpressionType.SIMPLE, "(first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% [converted] to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "convert (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% to (cap[ital]s|upper[ ]case) (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])", "capitalize (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% (0¦|1¦ignoring [other] upper[ ]case [(char[acter]s|letters)])");
|
||||
Skript.registerExpression(ExprTimespanToNumber.class, Number.class, ExpressionType.SIMPLE, "%timespan% [converted] [in]to (0¦ticks|1¦sec[ond]s|2¦min[ute]s|3¦hours|4¦days)");
|
||||
Skript.registerExpression(ExprClickedInventory.class, Inventory.class, ExpressionType.SIMPLE, "[skstuff] clicked inventory");
|
||||
Skript.registerExpression(ExprInventoryOwner.class, Object.class, ExpressionType.PROPERTY, "[inventory] (owner|holder) of %inventory%", "%inventory%'s [inventory] (owner|holder)");
|
||||
effAmount += 1;
|
||||
@ -144,175 +92,22 @@ public class SkStuff extends JavaPlugin {
|
||||
if (setupNMSVersion()) {
|
||||
getLogger().info("Trying to register version specific stuff...");
|
||||
Skript.registerEffect(EffClearPathGoals.class, "(clear|delete) [all] pathfind[er] goals (of|from) %livingentities%");
|
||||
Skript.registerEffect(EffRemovePathGoal.class, "remove pathfind[er] goal (0¦(avoid|run away from) entit(y|ies)|1¦break door[s]|2¦breed|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))|5¦float (in[side]|on) water|6¦follow (owner|tamer)|7¦follow (adult|parent)[s]|8¦(fight back|react to|target) (damager|attacker)|9¦o(c|z)elot jump on blocks|10¦leap at target|11¦look at entit(y|ies)|12¦melee attack entit(y|ies)|13¦move to[wards] target|14¦target nearest entity|15¦o(c|z)elot attack [chicken[s]]|16¦open door[s]|17¦(panic|flee)|18¦look around randomly|19¦(walk around randomly|wander)|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦(wake other silverfish[es]|[silverfish] call (help|reinforcement|other [hidden] silverfish[es]))|26¦[enderm(a|e)n] pick[[ ]up] block[s]|27¦[enderm(a|e)n] place block[s]|28¦[enderman] attack player (staring|looking) [at eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) [a[n]] item|32¦target [random] entity (if|when) (not tamed|untamed)|33¦guardian attack [entity]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow [entity]|42¦bow shoot) from %livingentities%");
|
||||
Skript.registerEffect(EffRemovePathGoal.class, "remove pathfind[er] goal (0¦(avoid|run away from) entit(y|ies)|1¦break door[s]|2¦breed|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))|5¦float (in[side]|on) water|6¦follow (owner|tamer)|7¦follow (adult|parent)[s]|8¦(fight back|react to|target) (damager|attacker)|9¦o(c|z)elot jump on blocks|10¦leap at target|11¦look at entit(y|ies)|12¦melee attack entit(y|ies)|13¦move to[wards] target|14¦target nearest entity|15¦o(c|z)elot attack [chicken[s]]|16¦open door[s]|17¦(panic|flee)|18¦look around randomly|19¦(walk around randomly|wander)|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦(wake other silverfish[es]|[silverfish] call (help|reinforcement|other [hidden] silverfish[es]))|26¦[enderm(a|e)n] pick[[ ]up] block[s]|27¦[enderm(a|e)n] place block[s]|28¦[enderman] attack player (staring|looking) [at eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) [a[n]] item|32¦target [random] entity (if|when) (not tamed|untamed)|33¦guardian attack [entity]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow [entity]|42¦bow shoot) from %livingentities%");
|
||||
// Note to self: whenever adding a new pathfinder goal, increase the expression index for 'entities' in EffSetPathGoal
|
||||
Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %*entitydatas%[, radius %-number%[, speed %-number%[, speed (if|when) (close|near) %-number%]]]|1¦break door[s]|2¦breed[,[move[ment]] speed %-number%]|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))[, [move[ment]] speed %-number%]|5¦(float (in[side]|on) water|swim)|6¦follow (owner|tamer)[, speed %-number%[, min[imum] distance %-number%[, max[imum] distance %-number%]]]|7¦follow (adult|parent)[s][, [move[ment]] speed %-number%]|8¦(fight back|react to|target) (damager|attacker) [[of] type] %*entitydatas%[, call ([for] help|reinforcement) %-boolean%]|9¦o(c|z)elot jump on blocks[, [move[ment]] speed %-number%]|10¦leap at target[, [leap] height %-number%]|11¦look at %*entitydatas%[, (radius|max[imum] distance) %-number%]|12¦melee attack %*entitydatas%[, [move[ment]] speed %-number%[, (memorize|do('nt| not) forget) target [for [a] long[er] time] %-boolean%]]|13¦move to[wards] target[, [move[ment]] speed %-number%[, (radius|max[imum] distance) %-number%]]|14¦target nearest [entity [of] type] %*entitydatas%[, check sight %-boolean%]|15¦o(c|z)elot attack|16¦open door[s]|17¦(panic|flee)[, [move[ment]] speed %-number%]|18¦look around randomly|19¦(walk around randomly|wander)[, [move[ment]] speed %-number%[, min[imum] [of] %-timespan% between mov(e[ment][s]|ing)]]|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim around|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦((call|summon|wake) [other] [hidden] silverfish[es])|26¦[enderman] pick[[ ]up] block[s]|27¦[enderman] place block[s]|28¦[enderman] attack player (staring|looking) at [their] eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) %-itemstack%[, [move[ment]] speed %number%[, scared of player movement %-boolean%]]|32¦target [random] %*entitydatas% (if|when) (not |un)tamed|33¦guardian attack [entities]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow %*entitydatas%[, radius %-number%[, speed %-number%[, [custom[ ]]name[d] %-string%]]]|42¦bow shoot[, [move[ment]] speed %-number%[, unk[nown] param[eter] %-number%[, follow range %-number%]]])) to %livingentities%");
|
||||
Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %*entitydatas%[, radius %-number%[, speed %-number%[, speed (if|when) (close|near) %-number%]]]|1¦break door[s]|2¦breed[,[move[ment]] speed %-number%]|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))[, [move[ment]] speed %-number%]|5¦(float (in[side]|on) water|swim)|6¦follow (owner|tamer)[, speed %-number%[, min[imum] distance %-number%[, max[imum] distance %-number%]]]|7¦follow (adult|parent)[s][, [move[ment]] speed %-number%]|8¦(fight back|react to|target) (damager|attacker) [[of] type] %*entitydatas%[, call ([for] help|reinforcement) %-boolean%]|9¦o(c|z)elot jump on blocks[, [move[ment]] speed %-number%]|10¦leap at target[, [leap] height %-number%]|11¦look at %*entitydatas%[, (radius|max[imum] distance) %-number%]|12¦melee attack %*entitydatas%[, [move[ment]] speed %-number%[, (memorize|do('nt| not) forget) target [for [a] long[er] time] %-boolean%]]|13¦move to[wards] target[, [move[ment]] speed %-number%[, (radius|max[imum] distance) %-number%]]|14¦target nearest [entity [of] type] %*entitydatas%[, check sight %-boolean%]|15¦o(c|z)elot attack|16¦open door[s]|17¦(panic|flee)[, [move[ment]] speed %-number%]|18¦look around randomly|19¦(walk around randomly|wander)[, [move[ment]] speed %-number%[, min[imum] [of] %-timespan% between mov(e[ment][s]|ing)]]|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim around|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦((call|summon|wake) [other] [hidden] silverfish[es])|26¦[enderman] pick[[ ]up] block[s]|27¦[enderman] place block[s]|28¦[enderman] attack player (staring|looking) at [their] eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) %-itemstack%[, [move[ment]] speed %number%[, scared of player movement %-boolean%]]|32¦target [random] %*entitydatas% (if|when) (not |un)tamed|33¦guardian attack [entities]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow %*entitydatas%[, radius %-number%[, speed %-number%[, [custom[ ]]name[d] %-string%]]]|42¦bow shoot[, [move[ment]] speed %-number%[, unk[nown] param[eter] %-number%[, follow range %-number%]]])) to %livingentities%");
|
||||
Skript.registerEffect(EffMakeJump.class, "make %livingentities% jump", "force %livingentities% to jump");
|
||||
Skript.registerEffect(EffGZipFile.class, "create [a] gzip[ped] file [at] [path] %string%");
|
||||
Skript.registerExpression(ExprNBTOf.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %~object%", "%~object%'s nbt[[ ]tag[s]]");
|
||||
Skript.registerExpression(ExprItemNBT.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
|
||||
Skript.registerExpression(ExprTagOf.class, Object.class, ExpressionType.PROPERTY, "[nbt[ ]]tag %string% of [[nbt] compound] %compound%");
|
||||
Skript.registerExpression(ExprFileNBT.class, Object.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] from [file] %string%");
|
||||
Skript.registerExpression(ExprNBTListIndex.class, Object.class, ExpressionType.PROPERTY, "[nbt[ ]list] %nbtlist% index %number%");
|
||||
Skript.registerExpression(ExprNBTListContents.class, Object.class, ExpressionType.PROPERTY, "[all] contents (of|from) [nbt[ ]list] %nbtlist%", "[nbt[ ]list] %nbtlist% contents");
|
||||
Skript.registerExpression(ExprNoClip.class, Boolean.class, ExpressionType.PROPERTY, "no[( |-)]clip (state|mode) of %entities%", "%entities%'s no[( |-)]clip (state|mode)");
|
||||
Skript.registerExpression(ExprFireProof.class, Boolean.class, ExpressionType.PROPERTY, "fire[ ]proof (state|mode) of %entities%", "%entities%'s fire[ ]proof (state|mode)");
|
||||
//Skript.registerExpression(ExprEndermanBlocks.class, ItemStack.class, ExpressionType.PROPERTY, "blocks that %entity% can (carry|hold|grab|steal)");
|
||||
Skript.registerExpression(ExprMCIdOf.class, String.class, ExpressionType.PROPERTY, "(mc|minecraft) [(string|native)] id of %itemtype%", "%itemtype%'s minecraft [(string|native)] id");
|
||||
Skript.registerExpression(ExprMCIdToItem.class, ItemStack.class, ExpressionType.SIMPLE, "item[[ ](stack|type)] (of|from) (mc|minecraft) [(string|native)] id %string%");
|
||||
Skript.registerExpression(ExprLastLocation.class, Location.class, ExpressionType.SIMPLE, "[the] (last|past|former) location of %entity%", "%entity%'s (last|past|former) location", "[the] location of %entity% (1|one) tick before", "%entity%'s location (1|one) tick before");
|
||||
Skript.registerExpression(ExprStepLength.class, Number.class, ExpressionType.PROPERTY, "[the] step length of %entity%", "%entity%'s step length");
|
||||
nmsMethods.registerCompoundClassInfo();
|
||||
nmsMethods.registerNBTListClassInfo();
|
||||
|
||||
effAmount += 5;
|
||||
exprAmount += 12;
|
||||
// 13 with the ender blocks expression
|
||||
typeAmount += 2;
|
||||
}
|
||||
if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
|
||||
getLogger().info("WorldEdit found! Registering WorldEdit stuff...");
|
||||
Skript.registerCondition(CondSelectionContains.class, "[(world[ ]edit|we)] selection of %player% (contains|has) %location%", "%player%'s [(world[ ]edit|we)] selection (contains|has) %location%", "[(world[ ]edit|we)] selection of %player% does(n't| not) (contain|have) %location%", "%player%'s [(world[ ]edit|we)] selection does(n't| not) (contain|have) %location%");
|
||||
Skript.registerEffect(EffDrawLineWE.class, "(create|draw|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% [with] thick[ness] %double%");
|
||||
Skript.registerEffect(EffUndoRedoSession.class, "(0¦undo|1¦redo) (change|edit)s (of|from) [edit[ ]session] %editsession%");
|
||||
Skript.registerEffect(EffRememberChanges.class, "make %player% (remember|be able to undo) changes (of|from) [edit[ ]session] %editsession%");
|
||||
Skript.registerEffect(EffMakeSphere.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) (ellipsoid|sphere) [centered] at %location% [with] radius [of] %double%,[ ]%double%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
||||
Skript.registerEffect(EffSimulateSnow.class, "(simulate snow at|place snow over) %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%", "make %location% snowy (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
|
||||
Skript.registerEffect(EffMakePyramid.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) pyramid at %location% [with] radius [of] %integer% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
||||
Skript.registerEffect(EffDrainLiquid.class, "(drain|remove) [all] liquid[s] at %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
|
||||
Skript.registerEffect(EffNaturalize.class, "naturalize ([cuboid] region|[all] blocks) (from|between) %location% (to|and) %location% (using|with) [edit[ ]session] %editsession%");
|
||||
Skript.registerEffect(EffMakeWalls.class, "(create|make) wall[s] from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
||||
Skript.registerEffect(EffSetBlocksWE.class, "set [all] blocks (from|between) %location% (to|and) %location% to %itemstacks% (using|with) [edit[ ]session] %editsession%");
|
||||
Skript.registerEffect(EffMakeCylinder.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) cylinder at %location% [with] radius [of] %double%,[ ]%integer%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
||||
Skript.registerEffect(EffReplaceBlocksWE.class, "replace [all] %itemstacks% (from|between) %location% (to|and) %location% with %itemstacks% (using|with) [edit[ ]session] %editsession%");
|
||||
Skript.registerEffect(EffPasteSchematic.class, "paste schem[atic] %string% at %location% using [edit[ ]session] %editsession% (0¦|1¦(ignor(e|ing)|without|[with] no) air)");
|
||||
Skript.registerExpression(ExprEditSessionLimit.class, Integer.class, ExpressionType.PROPERTY, "[block] limit [change] of [edit[ ]session] %editsession%");
|
||||
Skript.registerExpression(ExprChangedBlocksSession.class, Integer.class, ExpressionType.PROPERTY, "number of [all] changed blocks (in|of) [edit[ ]session] %editsession%");
|
||||
Skript.registerExpression(ExprNewEditSession.class, EditSession.class, ExpressionType.PROPERTY, "[new] edit[ ]session in [world] %world% [with] [max[imum]] [block] limit [change] [of] %integer%");
|
||||
Skript.registerExpression(ExprSelectionOfPlayer.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection");
|
||||
Skript.registerExpression(ExprSelectionPos.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] po(s|int)[ ](0¦1|1¦2) of %player%", "%player%'s [(world[ ]edit|we)] po(s|int)[ ](0¦1|1¦2)");
|
||||
Skript.registerExpression(ExprSelectionArea.class, Integer.class, ExpressionType.SIMPLE, "(0¦volume|1¦(x( |-)size|width)|2¦(y( |-)size|height)|3¦(z( |-)size|length)|4¦area) of [(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection (0¦volume|1¦(x( |-)size|width)|2¦(y( |-)size|height)|3¦(z( |-)size|length)|4¦area)");
|
||||
Skript.registerExpression(ExprSchematicArea.class, Integer.class, ExpressionType.SIMPLE, "(0¦volume|1¦(x( |-)size|width)|2¦(y( |-)size|height)|3¦(z( |-)size|length)|4¦area) of schem[atic] [from] %string%");
|
||||
Skript.registerExpression(ExprSuperPickaxe.class, Boolean.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] super[ ]pick[axe] (state|mode) of %players%", "%players%'s [(world[ ]edit|we)] super[ ]pick[axe] (state|mode)");
|
||||
Classes.registerClass(new ClassInfo<EditSession>(EditSession.class, "editsession").name("Edit Session").user("edit ?sessions?"));
|
||||
try {
|
||||
Class.forName("com.sk89q.worldedit.extent.logging.AbstractLoggingExtent");
|
||||
new WorldEditChangeHandler();
|
||||
Skript.registerEvent("WorldEdit block change", SimpleEvent.class, EvtWorldEditChange.class, "world[ ]edit [block] (chang(e|ing)|edit[ing])");
|
||||
EventValues.registerEventValue(EvtWorldEditChange.class, Player.class, new Getter<Player, EvtWorldEditChange>() {
|
||||
@Override
|
||||
@Nullable
|
||||
public Player get(EvtWorldEditChange e) {
|
||||
return EvtWorldEditChange.getPlayer();
|
||||
}
|
||||
}, 0);
|
||||
EventValues.registerEventValue(EvtWorldEditChange.class, Block.class, new Getter<Block, EvtWorldEditChange>() {
|
||||
@Override
|
||||
@Nullable
|
||||
public Block get(EvtWorldEditChange e) {
|
||||
return EvtWorldEditChange.getBlock();
|
||||
}
|
||||
}, 0);
|
||||
evtAmount += 1;
|
||||
} catch (ClassNotFoundException ex) {
|
||||
Skript.error("Unable to register \"On WorldEdit block change\" event! You will need to upgrade to WorldEdit 6.x if you want to use it!");
|
||||
}
|
||||
condAmount += 1;
|
||||
effAmount += 13;
|
||||
exprAmount += 8;
|
||||
typeAmount += 1;
|
||||
final Plugin worldGuard = Bukkit.getPluginManager().getPlugin("WorldGuard");
|
||||
if (worldGuard != null) { //WorldGuard depends on WorldEdit
|
||||
getLogger().info("WorldGuard found! Registering WorldGuard stuff...");
|
||||
Plugin umbaska = Bukkit.getPluginManager().getPlugin("Umbaska");
|
||||
Plugin skRambled = Bukkit.getPluginManager().getPlugin("SkRambled");
|
||||
boolean registerNewTypes = (umbaska == null && skRambled == null);
|
||||
if (registerNewTypes) {
|
||||
Skript.registerExpression(ExprFlagOfWGRegion.class, String.class, ExpressionType.PROPERTY, "[(world[ ]guard|wg)] flag %wgflag% of %wgregion%");
|
||||
Skript.registerExpression(ExprFlagsOfWGRegion.class, Flag.class, ExpressionType.PROPERTY, "[(all|the)] [(world[ ]guard|wg)] flags of %wgregion%");
|
||||
Skript.registerExpression(ExprWGMemberOwner.class, OfflinePlayer.class, ExpressionType.PROPERTY, "[the] (0¦members|1¦owner[s]) of [[the] (world[ ]guard|wg) region] %wgregion%");
|
||||
Classes.registerClass(new ClassInfo<Flag>(Flag.class, "wgflag").name("WorldGuard Flag").user("((world ?guard|wg) )?flags?").defaultExpression(new EventValueExpression<Flag>(Flag.class)).parser(new Parser<Flag<?>>() {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Flag<?> parse(String flag, ParseContext context) {
|
||||
FlagRegistry flagRegistry = ((WorldGuardPlugin) worldGuard).getFlagRegistry();
|
||||
return DefaultFlag.fuzzyMatchFlag(flagRegistry, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Flag<?> flag, int flags) {
|
||||
return flag.getName().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVariableNameString(Flag<?> flag) {
|
||||
return flag.getName().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVariableNamePattern() {
|
||||
return ".+";
|
||||
}
|
||||
}));
|
||||
Classes.registerClass(new ClassInfo<ProtectedRegion>(ProtectedRegion.class, "wgregion").name("WorldGuard Region").user("((world ?guard|wg) )?regions?").defaultExpression(new EventValueExpression<>(ProtectedRegion.class)).parser(new Parser<ProtectedRegion>() {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ProtectedRegion parse(String region, ParseContext context) {
|
||||
for (World w : Bukkit.getWorlds()) {
|
||||
if (WGBukkit.getRegionManager(w).hasRegion(region)) {
|
||||
return WGBukkit.getRegionManager(w).getRegion(region);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(ProtectedRegion region, int flags) {
|
||||
return region.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toVariableNameString(ProtectedRegion region) {
|
||||
return region.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVariableNamePattern() {
|
||||
return ".+";
|
||||
}
|
||||
|
||||
}));
|
||||
typeAmount += 2;
|
||||
} else {
|
||||
Skript.registerExpression(ExprFlagOfWGRegion.class, String.class, ExpressionType.PROPERTY, "[skstuff] [w[orld[ ]]g[uard]] flag %flag% of %protectedregion%");
|
||||
Skript.registerExpression(ExprFlagsOfWGRegion.class, Flag.class, ExpressionType.PROPERTY, "[skstuff] [all] [w[orld[ ]]g[uard]] flags of %protectedregion%");
|
||||
Skript.registerExpression(ExprWGMemberOwner.class, OfflinePlayer.class, ExpressionType.PROPERTY, "[the] [skstuff] (0¦members|1¦owner[s]) of [[the] (world[ ]guard|wg) region] %protectedregion%");
|
||||
}
|
||||
Skript.registerExpression(ExprRegionsWithinLocation.class, ProtectedRegion.class, ExpressionType.SIMPLE, "[all] [the] regions (containing|within|inside) %location%");
|
||||
exprAmount += 4;
|
||||
|
||||
if (!Skript.classExists("com.sk89q.protection.flags.registry.FlagRegistry")) {
|
||||
getLogger().warning("Detected old unsupported version of WorldGuard, please update to WorldGuard 6.2. Flags will not fully work with your current version!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Bukkit.getPluginManager().getPlugin("VanishNoPacket") != null) {
|
||||
getLogger().info("VanishNoPacket was found! Registering vanishing features...");
|
||||
Skript.registerEffect(EffToggleVanish.class, "toggle vanish (state|mode) of %player% (0¦|1¦(silently|quietly))", "toggle %player%'s vanish (state|mode) (0¦|1¦(silently|quietly))");
|
||||
Skript.registerEvent("Vanish toggle event", SimpleEvent.class, VanishStatusChangeEvent.class, "[player] vanish [(state|mode)] (chang|toggl)(e|ing)");
|
||||
Skript.registerExpression(ExprVanishState.class, Boolean.class, ExpressionType.PROPERTY, "vanish (state|mode) of %player%", "%player%'s vanish (state|mode)");
|
||||
EventValues.registerEventValue(VanishStatusChangeEvent.class, Player.class, new Getter<Player, VanishStatusChangeEvent>() {
|
||||
@Override
|
||||
@Nullable
|
||||
public Player get(VanishStatusChangeEvent e) {
|
||||
return e.getPlayer();
|
||||
}
|
||||
}, 0);
|
||||
effAmount += 1;
|
||||
evtAmount += 1;
|
||||
exprAmount += 1;
|
||||
}
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
@ -330,27 +125,13 @@ public class SkStuff extends JavaPlugin {
|
||||
|
||||
private boolean setupNMSVersion() {
|
||||
String version = ReflectionUtils.getVersion();
|
||||
if (version.equals("v1_7_R4.")) {
|
||||
nmsMethods = new NMS_v1_7_R4();
|
||||
getLogger().info("It looks like you're running 1.7.10!");
|
||||
} else if (version.equals("v1_8_R3.")) {
|
||||
nmsMethods = new NMS_v1_8_R3();
|
||||
getLogger().info("It looks like you're either running 1.8.4, 1.8.7, 1.8.8 or 1.8.9!");
|
||||
} else if (version.equals("v1_9_R1.")) {
|
||||
nmsMethods = new NMS_v1_9_R1();
|
||||
getLogger().info("It looks like you're either running 1.9.0 or 1.9.2!");
|
||||
} else if (version.equals("v1_9_R2.")) {
|
||||
nmsMethods = new NMS_v1_9_R2();
|
||||
getLogger().info("It looks like you're running 1.9.4!");
|
||||
} else if (version.equals("v1_10_R1.")) {
|
||||
nmsMethods = new NMS_v1_10_R1();
|
||||
getLogger().info("It looks like you're running 1.10!");
|
||||
} else if (version.equals("v1_11_R1.")) {
|
||||
nmsMethods = new NMS_v1_11_R1();
|
||||
getLogger().info("It looks like you're running 1.11!");
|
||||
} else if (version.equals("v1_12_R1.")) {
|
||||
nmsMethods = new NMS_v1_12_R1();
|
||||
getServer().getConsoleSender().sendMessage("§c[SkStuff] You are running an unofficial fork of SkStuff, by Tuke_Nuke. Some nbt stuffs may not work properly!");
|
||||
|
||||
if (version.equals("v1_13_R2.")) {
|
||||
nmsMethods = new NMS_v1_13_R2();
|
||||
getLogger().info("It looks like you're running 1.13.2!");
|
||||
} else if (version.equals("v1_14_R1.")) {
|
||||
nmsMethods = new NMS_v1_14_R1();
|
||||
getLogger().info("It looks like you're running 1.14.2!");
|
||||
} else {
|
||||
getLogger().warning("It looks like you're running an unsupported server version, some features will not be available :(");
|
||||
}
|
||||
|
@ -20,9 +20,9 @@ import ch.njol.skript.lang.Expression;
|
||||
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||
import ch.njol.util.Kleenean;
|
||||
import me.TheBukor.SkStuff.SkStuff;
|
||||
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_8_R3;
|
||||
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_9_R1;
|
||||
import me.TheBukor.SkStuff.util.ReflectionUtils;
|
||||
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_13_R2;
|
||||
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_14_R1;
|
||||
|
||||
public class EffRemovePathGoal extends Effect {
|
||||
private Expression<LivingEntity> entities;
|
||||
@ -178,10 +178,10 @@ public class EffRemovePathGoal extends Effect {
|
||||
toRemove = ReflectionUtils.getNMSClass("EntitySlime$PathfinderGoalSlimeIdle");
|
||||
} else if (mark == 41) {
|
||||
String version = ReflectionUtils.getVersion();
|
||||
if (version.equals("v1_8_R3.")) {
|
||||
toRemove = PathfinderGoalFollow_v1_8_R3.class;
|
||||
} else if (version.equals("v1_9_R1.")) {
|
||||
toRemove = PathfinderGoalFollow_v1_9_R1.class;
|
||||
if (version.equals("v1_13_R2.")) {
|
||||
toRemove = PathfinderGoalFollow_v1_13_R2.class;
|
||||
} else if (version.equals("v1_14_R1.")) {
|
||||
toRemove = PathfinderGoalFollow_v1_14_R1.class;
|
||||
}
|
||||
} else if (mark == 42) {
|
||||
if (Skript.isRunningMinecraft(1, 9)) {
|
||||
|
@ -40,12 +40,12 @@ import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||
import ch.njol.skript.util.Timespan;
|
||||
import ch.njol.util.Kleenean;
|
||||
import me.TheBukor.SkStuff.SkStuff;
|
||||
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_8_R3;
|
||||
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_9_R1;
|
||||
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_13_R2;
|
||||
import me.TheBukor.SkStuff.pathfinders.PathfinderGoalFollow_v1_14_R1;
|
||||
import me.TheBukor.SkStuff.util.ReflectionUtils;
|
||||
import net.minecraft.server.v1_8_R3.EntityCreature;
|
||||
|
||||
public class EffSetPathGoal extends Effect {
|
||||
public final class EffSetPathGoal extends Effect {
|
||||
private Expression<Integer> goalPriority;
|
||||
private Expression<? extends EntityData<?>> typeToAvoid;
|
||||
private Expression<Number> avoidRadius;
|
||||
@ -98,7 +98,7 @@ public class EffSetPathGoal extends Effect {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
|
||||
public final boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
|
||||
goalPriority = (Expression<Integer>) expr[0];
|
||||
mark = result.mark;
|
||||
if (mark == 0) {
|
||||
@ -539,10 +539,10 @@ public class EffSetPathGoal extends Effect {
|
||||
className = "Living";
|
||||
}
|
||||
Class<?> nmsClass = ReflectionUtils.getNMSClass("Entity" + className);
|
||||
if (version.equals("v1_8_R3.")) {
|
||||
newGoals.add(new PathfinderGoalFollow_v1_8_R3((EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
|
||||
} else if (version.equals("v1_9_R1.")) {
|
||||
newGoals.add(new PathfinderGoalFollow_v1_9_R1((net.minecraft.server.v1_9_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
|
||||
if (version.equals("v1_13_R2.")) {
|
||||
newGoals.add(new PathfinderGoalFollow_v1_13_R2((net.minecraft.server.v1_13_R2.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
|
||||
} else if (version.equals("v1_14_R1.")) {
|
||||
newGoals.add(new PathfinderGoalFollow_v1_14_R1((net.minecraft.server.v1_14_R1.EntityCreature) nmsEnt, nmsClass, radius, spd, usesName, customName));
|
||||
}
|
||||
}
|
||||
} else if (mark == 42) {
|
||||
|
@ -0,0 +1,79 @@
|
||||
package me.TheBukor.SkStuff.pathfinders;
|
||||
|
||||
import net.minecraft.server.v1_13_R2.Entity;
|
||||
import net.minecraft.server.v1_13_R2.EntityCreature;
|
||||
import net.minecraft.server.v1_13_R2.EntityLiving;
|
||||
import net.minecraft.server.v1_13_R2.PathfinderGoal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PathfinderGoalFollow_v1_13_R2 extends PathfinderGoal {
|
||||
private EntityCreature follower;
|
||||
private EntityLiving followed;
|
||||
private Class<?> followedClass;
|
||||
private float radius;
|
||||
private double speed;
|
||||
private boolean isByName;
|
||||
private String customName;
|
||||
|
||||
public PathfinderGoalFollow_v1_13_R2(EntityCreature follower, Class<?> followedClass, float radius, double speed, boolean isByName, String customName) {
|
||||
this.follower = follower;
|
||||
this.followedClass = followedClass;
|
||||
this.radius = radius;
|
||||
this.speed = speed;
|
||||
this.isByName = isByName;
|
||||
this.customName = customName;
|
||||
}
|
||||
|
||||
// a() is shouldExecute()
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean a() {
|
||||
if (followed == null) {
|
||||
List<?> list = follower.world.a((Class<? extends Entity>) followedClass, follower.getBoundingBox().grow(radius, 4.0D, radius));
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (isByName) {
|
||||
for (Object entity : list) {
|
||||
if (((EntityLiving) entity).getCustomName().equals(customName)) {
|
||||
followed = (EntityLiving) entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
followed = (EntityLiving) list.get(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// b() is shouldContinueExecuting()
|
||||
@Override
|
||||
public boolean b() {
|
||||
if (followed.dead) {
|
||||
followed = null;
|
||||
return false;
|
||||
} else if (followed.h(follower) < 9.0D || followed.h(follower) > Math.pow(radius, 2)) { // h() = distanceSquaredFrom()
|
||||
return false; // if 3 blocks away or not in radius, stop moving.
|
||||
//Maybe I'll add a teleport feature later.
|
||||
} else if (isByName) {
|
||||
if (!followed.getCustomName().equals(customName)) {
|
||||
followed = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//return follower.getNavigation().n(); // n() means hasNoPath()
|
||||
return true;
|
||||
// n() is now protected void and I'm not sure how to access it, so I'm just returning a boolean, this probably will cause some issues with this pathfinder goal, if you know a better solution, let me know. - Govindas.
|
||||
}
|
||||
|
||||
// c() is execute()
|
||||
@Override
|
||||
public void c () {
|
||||
follower.getNavigation().a(followed, speed); // a() means moveTo()
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package me.TheBukor.SkStuff.pathfinders;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.Entity;
|
||||
import net.minecraft.server.v1_14_R1.EntityCreature;
|
||||
import net.minecraft.server.v1_14_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_14_R1.PathfinderGoal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PathfinderGoalFollow_v1_14_R1 extends PathfinderGoal {
|
||||
private EntityCreature follower;
|
||||
private EntityLiving followed;
|
||||
private Class<?> followedClass;
|
||||
private float radius;
|
||||
private double speed;
|
||||
private boolean isByName;
|
||||
private String customName;
|
||||
|
||||
public PathfinderGoalFollow_v1_14_R1(EntityCreature follower, Class<?> followedClass, float radius, double speed, boolean isByName, String customName) {
|
||||
this.follower = follower;
|
||||
this.followedClass = followedClass;
|
||||
this.radius = radius;
|
||||
this.speed = speed;
|
||||
this.isByName = isByName;
|
||||
this.customName = customName;
|
||||
}
|
||||
|
||||
// a() is shouldExecute()
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean a() {
|
||||
if (followed == null) {
|
||||
List<?> list = follower.world.a((Class<? extends Entity>) followedClass, follower.getBoundingBox().grow(radius, 4.0D, radius));
|
||||
if (list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (isByName) {
|
||||
for (Object entity : list) {
|
||||
if (((EntityLiving) entity).getCustomName().equals(customName)) {
|
||||
followed = (EntityLiving) entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
followed = (EntityLiving) list.get(0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// b() is shouldContinueExecuting()
|
||||
@Override
|
||||
public boolean b() {
|
||||
if (followed.dead) {
|
||||
followed = null;
|
||||
return false;
|
||||
} else if (followed.h(follower) < 9.0D || followed.h(follower) > Math.pow(radius, 2)) { // h() = distanceSquaredFrom()
|
||||
return false; // if 3 blocks away or not in radius, stop moving.
|
||||
//Maybe I'll add a teleport feature later.
|
||||
} else if (isByName) {
|
||||
if (!followed.getCustomName().equals(customName)) {
|
||||
followed = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//return follower.getNavigation().n(); // n() means hasNoPath()
|
||||
return true;
|
||||
// n() is now protected void and I'm not sure how to access it, so I'm just returning a boolean, this probably will cause some issues with this pathfinder goal, if you know a better solution, let me know. - Govindas.
|
||||
}
|
||||
|
||||
// c() is execute()
|
||||
@Override
|
||||
public void c () {
|
||||
follower.getNavigation().a(followed, speed); // a() means moveTo()
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package me.TheBukor.SkStuff.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.server.v1_13_R2.EntityTypes;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -9,31 +10,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface NMSInterface {
|
||||
|
||||
public Object getNBTTag(Object compound, String tag);
|
||||
|
||||
public void setNBTTag(Object compound, String tag, Object toSet);
|
||||
|
||||
public void removeNBTTag(Object compound, String tag);
|
||||
|
||||
public byte getTypeId(Object nbtBase);
|
||||
|
||||
public Object getNBTTagValue(Object compound, String tag, byte typeId);
|
||||
|
||||
public void addToCompound(Object compound, Object toAdd);
|
||||
|
||||
public void removeFromCompound(Object compound, String ... toRemove);
|
||||
|
||||
public Object parseRawNBT(String rawNBT);
|
||||
|
||||
public Object[] getContents(Object nbtList);
|
||||
|
||||
public void addToList(Object nbtList, Object toAdd);
|
||||
|
||||
public void removeFromList(Object nbtList, int index);
|
||||
|
||||
public void setIndex(Object nbtList, int index, Object toSet);
|
||||
|
||||
public Object getIndex(Object nbtList, int index);
|
||||
|
||||
public void clearPathfinderGoals(Entity entity);
|
||||
|
||||
@ -41,34 +21,6 @@ public interface NMSInterface {
|
||||
|
||||
public void addPathfinderGoal(Object entity, int priority, Object goal, boolean isTargetSelector);
|
||||
|
||||
public void registerCompoundClassInfo();
|
||||
|
||||
public void registerNBTListClassInfo();
|
||||
|
||||
public Object getEntityNBT(Entity entity);
|
||||
|
||||
public Object getTileNBT(Block block);
|
||||
|
||||
public Object getItemNBT(ItemStack itemStack);
|
||||
|
||||
public void setEntityNBT(Entity entity, Object newCompound);
|
||||
|
||||
public void setTileNBT(Block block, Object newCompound);
|
||||
|
||||
public ItemStack getItemWithNBT(ItemStack itemStack, Object compound);
|
||||
|
||||
public Object getFileNBT(File file);
|
||||
|
||||
public void setFileNBT(File file, Object newCompound);
|
||||
|
||||
public Object convertToNBT(Number number);
|
||||
|
||||
public Object convertToNBT(String string);
|
||||
|
||||
public String getMCId(ItemStack itemStack);
|
||||
|
||||
public ItemStack getItemFromMcId(String mcId);
|
||||
|
||||
public boolean getNoClip(Entity entity);
|
||||
|
||||
public void setNoClip(Entity entity, boolean noclip);
|
||||
@ -77,17 +29,8 @@ public interface NMSInterface {
|
||||
|
||||
public void setFireProof(Entity entity, boolean fireProof);
|
||||
|
||||
/*
|
||||
public ItemStack[] getEndermanBlocks(Entity enderman);
|
||||
|
||||
public void setEndermanBlocks(Entity enderman, ItemStack... blocks);
|
||||
*/
|
||||
|
||||
public Location getLastLocation(Entity entity);
|
||||
|
||||
public float getEntityStepLength(Entity entity);
|
||||
|
||||
public void setEntityStepLength(Entity entity, float length);
|
||||
|
||||
public boolean getElytraGlideState(Entity entity);
|
||||
|
||||
|
115
src/me/TheBukor/SkStuff/util/NMS_v1_13_R2.java
Normal file
115
src/me/TheBukor/SkStuff/util/NMS_v1_13_R2.java
Normal file
@ -0,0 +1,115 @@
|
||||
package me.TheBukor.SkStuff.util;
|
||||
|
||||
|
||||
|
||||
import net.minecraft.server.v1_13_R2.*;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.entity.CraftLivingEntity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public class NMS_v1_13_R2 implements NMSInterface {
|
||||
|
||||
|
||||
|
||||
@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) {
|
||||
((EntityInsentient) entity).setGoalTarget(null);
|
||||
if (isTargetSelector) {
|
||||
Iterator<?> goals = ((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).targetSelector)).iterator();
|
||||
while (goals.hasNext()) {
|
||||
Object goal = goals.next();
|
||||
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
|
||||
goals.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Iterator<?> goals = ((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).goalSelector)).iterator();
|
||||
while (goals.hasNext()) {
|
||||
Object goal = goals.next();
|
||||
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
|
||||
goals.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPathfinderGoal(Object entity, int priority, Object goal, boolean isTargetSelector) {
|
||||
if (entity instanceof EntityInsentient && goal instanceof PathfinderGoal) {
|
||||
if (isTargetSelector)
|
||||
((EntityInsentient) entity).targetSelector.a(priority, (PathfinderGoal) goal);
|
||||
else
|
||||
((EntityInsentient) entity).goalSelector.a(priority, (PathfinderGoal) goal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getNoClip(Entity entity) {
|
||||
net.minecraft.server.v1_13_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
return nmsEntity.noclip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoClip(Entity entity, boolean noclip) {
|
||||
net.minecraft.server.v1_13_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
nmsEntity.noclip = noclip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFireProof(Entity entity) {
|
||||
net.minecraft.server.v1_13_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
return nmsEntity.isFireProof();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFireProof(Entity entity, boolean fireProof) {
|
||||
net.minecraft.server.v1_13_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
ReflectionUtils.setField("fireProof", nmsEntity.getClass(), nmsEntity, fireProof);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getElytraGlideState(Entity entity) {
|
||||
EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle();
|
||||
return nmsEntity.getFlag(7);
|
||||
}
|
||||
|
||||
public void setElytraGlideState(Entity entity, boolean glide) {
|
||||
EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle();
|
||||
nmsEntity.setFlag(7, glide);
|
||||
}
|
||||
|
||||
public boolean getNoGravity(Entity entity) {
|
||||
net.minecraft.server.v1_13_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
return nmsEntity.isNoGravity();
|
||||
}
|
||||
|
||||
public void setNoGravity(Entity entity, boolean noGravity) {
|
||||
net.minecraft.server.v1_13_R2.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
nmsEntity.setNoGravity(noGravity);
|
||||
}
|
||||
}
|
112
src/me/TheBukor/SkStuff/util/NMS_v1_14_R1.java
Normal file
112
src/me/TheBukor/SkStuff/util/NMS_v1_14_R1.java
Normal file
@ -0,0 +1,112 @@
|
||||
package me.TheBukor.SkStuff.util;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_14_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_14_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_14_R1.PathfinderGoal;
|
||||
import net.minecraft.server.v1_14_R1.PathfinderGoalSelector;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftLivingEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
public class NMS_v1_14_R1 implements NMSInterface {
|
||||
|
||||
|
||||
|
||||
@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) {
|
||||
((EntityInsentient) entity).setGoalTarget(null);
|
||||
if (isTargetSelector) {
|
||||
Iterator<?> goals = ((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).targetSelector)).iterator();
|
||||
while (goals.hasNext()) {
|
||||
Object goal = goals.next();
|
||||
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
|
||||
goals.remove();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Iterator<?> goals = ((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).goalSelector)).iterator();
|
||||
while (goals.hasNext()) {
|
||||
Object goal = goals.next();
|
||||
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
|
||||
goals.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPathfinderGoal(Object entity, int priority, Object goal, boolean isTargetSelector) {
|
||||
if (entity instanceof EntityInsentient && goal instanceof PathfinderGoal) {
|
||||
if (isTargetSelector)
|
||||
((EntityInsentient) entity).targetSelector.a(priority, (PathfinderGoal) goal);
|
||||
else
|
||||
((EntityInsentient) entity).goalSelector.a(priority, (PathfinderGoal) goal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getNoClip(Entity entity) {
|
||||
net.minecraft.server.v1_14_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
return nmsEntity.noclip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoClip(Entity entity, boolean noclip) {
|
||||
net.minecraft.server.v1_14_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
nmsEntity.noclip = noclip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFireProof(Entity entity) {
|
||||
net.minecraft.server.v1_14_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
return nmsEntity.isFireProof();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFireProof(Entity entity, boolean fireProof) {
|
||||
net.minecraft.server.v1_14_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
ReflectionUtils.setField("fireProof", nmsEntity.getClass(), nmsEntity, fireProof);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getElytraGlideState(Entity entity) {
|
||||
EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle();
|
||||
return nmsEntity.getFlag(7);
|
||||
}
|
||||
|
||||
public void setElytraGlideState(Entity entity, boolean glide) {
|
||||
EntityLiving nmsEntity = ((CraftLivingEntity) entity).getHandle();
|
||||
nmsEntity.setFlag(7, glide);
|
||||
}
|
||||
|
||||
public boolean getNoGravity(Entity entity) {
|
||||
net.minecraft.server.v1_14_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
return nmsEntity.isNoGravity();
|
||||
}
|
||||
|
||||
public void setNoGravity(Entity entity, boolean noGravity) {
|
||||
net.minecraft.server.v1_14_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
nmsEntity.setNoGravity(noGravity);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user