diff --git a/.classpath b/.classpath
index 6c9e5e6..3706278 100644
--- a/.classpath
+++ b/.classpath
@@ -7,9 +7,10 @@
-
+
+
diff --git a/bin/.gitignore b/bin/.gitignore
index 4060509..9b0146c 100644
--- a/bin/.gitignore
+++ b/bin/.gitignore
@@ -1 +1,2 @@
/me/
+/protocollib/
diff --git a/plugin.yml b/plugin.yml
index 80ac5e2..0f1d77c 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -1,6 +1,6 @@
name: SkStuff
author: TheBukor
description: A Skript addon which adds extra functionalities such as NBT and extended WorldEdit support.
-version: 1.6.1
+version: 1.6.3
main: me.TheBukor.SkStuff.SkStuff
softdepend: [Skript, WorldEdit, VanishNoPacket]
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/SkStuff.java b/src/me/TheBukor/SkStuff/SkStuff.java
index 370db1d..464f5c8 100644
--- a/src/me/TheBukor/SkStuff/SkStuff.java
+++ b/src/me/TheBukor/SkStuff/SkStuff.java
@@ -32,7 +32,6 @@ 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.EffClientChat;
import me.TheBukor.SkStuff.effects.EffDrainLiquid;
import me.TheBukor.SkStuff.effects.EffDrawLineWE;
import me.TheBukor.SkStuff.effects.EffGZipFile;
@@ -58,7 +57,6 @@ import me.TheBukor.SkStuff.events.WorldEditChangeHandler;
import me.TheBukor.SkStuff.expressions.ExprChangedBlocksSession;
import me.TheBukor.SkStuff.expressions.ExprClickedInventory;
import me.TheBukor.SkStuff.expressions.ExprEditSessionLimit;
-import me.TheBukor.SkStuff.expressions.ExprEndermanBlocks;
import me.TheBukor.SkStuff.expressions.ExprFileNBT;
import me.TheBukor.SkStuff.expressions.ExprFireProof;
import me.TheBukor.SkStuff.expressions.ExprFlagOfWGRegion;
@@ -66,6 +64,7 @@ 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;
@@ -77,6 +76,7 @@ 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.ExprTagOf;
import me.TheBukor.SkStuff.expressions.ExprTimespanToNumber;
import me.TheBukor.SkStuff.expressions.ExprToLowerCase;
@@ -115,7 +115,7 @@ public class SkStuff extends JavaPlugin {
exprAmount += 6;
if (Skript.isRunningMinecraft(1, 9)) {
getLogger().info("WOW! You're using Minecraft 1.9! Lemme register some cool stuff and fixes right away!");
- Skript.registerEffect(EffResourceSound.class, "play [raw] [([resource[ ]]pack)] sound %string% for %players% at %location% [[with] (0¦volume|1¦pitch) %-number%[[(,| and)] (0¦pitch|1¦volume) %-number%]]");
+ Skript.registerEffect(EffResourceSound.class, "play [raw] [([resource[ ]]pack)] sound %string% (for|to) %players% at %location% [[with] volume %-number%[[(,| and)] pitch %-number%]]", "play [raw] [([resource[ ]]pack)] sound %string% for %players% at %location% [[with] pitch %-number%[[(,| and)] volume %-number%]]");
Skript.registerEvent("Elytra glide toggle", SimpleEvent.class, EntityToggleGlideEvent.class, "[entity] elytra (fl(y|ight)|glid(e|ing)) toggl(e|ing)", "[entity] toggle elytra (fl(y|ight)|glid(e|ing))");
Skript.registerExpression(ExprGlideState.class, Boolean.class, ExpressionType.PROPERTY, "elytra (fl(y|ight)|glid(e|ing)) state of %livingentity%", "%livingentity%'s elytra (fl(y|ight)|glid(e|ing)) state");
EventValues.registerEventValue(EntityToggleGlideEvent.class, Entity.class, new Getter() {
@@ -136,7 +136,6 @@ public class SkStuff extends JavaPlugin {
Skript.registerEffect(EffSetPathGoal.class, "add pathfind[er] goal [[with] priority %-integer%] (0¦(avoid|run away from) %*entitydatas%[, radius %-number%[, speed %-number%[, speed (if|when) (close|near) %-number%]]]|1¦break door[s]|2¦breed[,[move[ment]] speed %-number%]|3¦eat grass|4¦(flee from the sun|seek shad(e|ow))[, [move[ment]] speed %-number%]|5¦(float (in[side]|on) water|swim)|6¦follow (owner|tamer)[, speed %-number%[, min[imum] distance %-number%[, max[imum] distance %-number%]]]|7¦follow (adult|parent)[s][, [move[ment]] speed %-number%]|8¦(fight back|react to|target) (damager|attacker) [[of] type] %*entitydatas%[, call ([for] help|reinforcement) %-boolean%]|9¦o(c|z)elot jump on blocks[, [move[ment]] speed %-number%]|10¦leap at target[, [leap] height %-number%]|11¦look at %*entitydatas%[, (radius|max[imum] distance) %-number%]|12¦melee attack %*entitydatas%[, [move[ment]] speed %-number%[, (memorize|do('nt| not) forget) target [for [a] long[er] time] %-boolean%]]|13¦move to[wards] target[, [move[ment]] speed %-number%[, (radius|max[imum] distance) %-number%]]|14¦target nearest [entity [of] type] %*entitydatas%[, check sight %-boolean%]|15¦o(c|z)elot attack|16¦open door[s]|17¦(panic|flee)[, [move[ment]] speed %-number%]|18¦look around randomly|19¦(walk around randomly|wander)[, [move[ment]] speed %-number%[, min[imum] [of] %-timespan% between mov(e[ment][s]|ing)]]|20¦sit|21¦[creeper] (explode|inflate|swell)|22¦squid (swim around|wander)|23¦shoot fireball[s]|24¦[silverfish] hide (in[side]|on) block[s]|25¦((call|summon|wake) [other] [hidden] silverfish[es])|26¦[enderman] pick[[ ]up] block[s]|27¦[enderman] place block[s]|28¦[enderman] attack player (staring|looking) at [their] eye[s]]|29¦ghast move to[wards] target|30¦ghast (idle move[ment]|wander|random fl(ight|y[ing]))|31¦(tempt to|follow players (holding|with)) %-itemstack%[, [move[ment]] speed %number%[, scared of player movement %-boolean%]]|32¦target [random] %*entitydatas% (if|when) (not |un)tamed|33¦guardian attack [entities]|34¦[z[ombie[ ]]pig[man]] attack [player[s]] (if|when) angry|35¦[z[ombie[ ]]pig[man]] (react to|fight back|target) (attacker|damager) (if|when) angry|36¦[rabbit] eat carrot crops|37¦[killer] rabbit [melee] attack|38¦slime [random] jump|39¦slime change (direction|facing) randomly|40¦slime (idle move[ment]|wander)|41¦follow %*entitydatas%[, radius %-number%[, speed %-number%[, [custom[ ]]name[d] %-string%]]]) to %livingentities%");
Skript.registerEffect(EffMakeJump.class, "make %livingentities% jump", "force %livingentities% to jump");
Skript.registerEffect(EffGZipFile.class, "create [a] gzip[ped] file [at] [path] %string%");
- Skript.registerEffect(EffClientChat.class, "make %player% (say|chat) %string% client[( |-)]side", "force %player% to (say|chat) %string% client[( |-)]side");
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%");
@@ -145,13 +144,16 @@ public class SkStuff extends JavaPlugin {
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(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, " ");
+ Skript.registerExpression(ExprStepLength.class, Number.class, ExpressionType.PROPERTY, "[the] step length of %entity%", "%entity%'s step length");
nmsMethods.registerCompoundClassInfo();
nmsMethods.registerNBTListClassInfo();
- effAmount += 6;
- exprAmount += 11;
+ effAmount += 5;
+ exprAmount += 12;
+ // 13 with the ender blocks expression
typeAmount += 2;
}
if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
@@ -198,7 +200,7 @@ public class SkStuff extends JavaPlugin {
}, 0);
evtAmount += 1;
} catch (ClassNotFoundException ex) {
- Skript.error("Unable to register \"On WorldEdit block change\" event! You will need to upgrade to WorldEdit 6.0");
+ 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;
diff --git a/src/me/TheBukor/SkStuff/effects/EffResourceSound.java b/src/me/TheBukor/SkStuff/effects/EffResourceSound.java
new file mode 100644
index 0000000..b985bca
--- /dev/null
+++ b/src/me/TheBukor/SkStuff/effects/EffResourceSound.java
@@ -0,0 +1,57 @@
+package me.TheBukor.SkStuff.effects;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event;
+
+import ch.njol.skript.lang.Effect;
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.util.Kleenean;
+
+public class EffResourceSound extends Effect {
+ private Expression sound;
+ private Expression players;
+ private Expression location;
+ private Expression volume;
+ private Expression pitch;
+
+ private int pattern;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init(Expression>[] expr, int matchedPattern, Kleenean isDelayed, ParseResult result) {
+ sound = (Expression) expr[0];
+ players = (Expression) expr[1];
+ location = (Expression) expr[2];
+ pattern = matchedPattern;
+ if (pattern == 0) {
+ volume = (Expression) expr[3];
+ pitch = (Expression) expr[4];
+ } else {
+ pitch = (Expression) expr[3];
+ volume = (Expression) expr[4];
+ }
+ return true;
+ }
+
+ @Override
+ public String toString(@Nullable Event e, boolean debug) {
+ return "play raw sound for " + players.toString(e, debug) + " at " + location.toString(e, debug) + " with " + (pattern == 0 ? "volume " + volume.toString(e, debug) : "pitch " + pitch.toString(e, debug)) + " and " + (pattern == 0 ? "pitch " + pitch.toString(e, debug) : "volume " + volume.toString(e, debug));
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ protected void execute(Event e) {
+ String s = sound.getSingle(e);
+ Player[] ps = players.getAll(e);
+ Location loc = location.getSingle(e);
+ float vol = (volume == null ? 1.0F : volume.getSingle(e).floatValue());
+ float pitch = (this.pitch == null ? 1.0F : this.pitch.getSingle(e).floatValue());
+ for (Player p : ps) {
+ p.playSound(loc, s, vol, pitch );
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/me/TheBukor/SkStuff/events/EvtWorldEditChange.java b/src/me/TheBukor/SkStuff/events/EvtWorldEditChange.java
index b1fca1e..a677590 100644
--- a/src/me/TheBukor/SkStuff/events/EvtWorldEditChange.java
+++ b/src/me/TheBukor/SkStuff/events/EvtWorldEditChange.java
@@ -12,7 +12,7 @@ public class EvtWorldEditChange extends Event implements Cancellable {
private boolean cancelled;
private static final HandlerList handlers = new HandlerList();
- public EvtWorldEditChange(Player player, Block block) {
+ EvtWorldEditChange(Player player, Block block) {
EvtWorldEditChange.player = player;
EvtWorldEditChange.block = block;
this.cancelled = false;
diff --git a/src/me/TheBukor/SkStuff/expressions/ExprEndermanBlocks.java b/src/me/TheBukor/SkStuff/expressions/ExprEndermanBlocks.java
index 2031a3c..eddb731 100644
--- a/src/me/TheBukor/SkStuff/expressions/ExprEndermanBlocks.java
+++ b/src/me/TheBukor/SkStuff/expressions/ExprEndermanBlocks.java
@@ -82,7 +82,6 @@ public class ExprEndermanBlocks extends SimpleExpression {
items.add(bukkitItem);
} catch (Exception ex) {
ex.printStackTrace();
- ;
}
}
return Arrays.copyOf(items.toArray(), items.size(), ItemStack[].class);
diff --git a/src/me/TheBukor/SkStuff/expressions/ExprFireProof.java b/src/me/TheBukor/SkStuff/expressions/ExprFireProof.java
index 27044f8..0d037ca 100644
--- a/src/me/TheBukor/SkStuff/expressions/ExprFireProof.java
+++ b/src/me/TheBukor/SkStuff/expressions/ExprFireProof.java
@@ -1,9 +1,5 @@
package me.TheBukor.SkStuff.expressions;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
import javax.annotation.Nullable;
import org.bukkit.entity.Entity;
@@ -15,12 +11,11 @@ import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import ch.njol.util.coll.CollectionUtils;
-import me.TheBukor.SkStuff.util.ReflectionUtils;
+import me.TheBukor.SkStuff.SkStuff;
public class ExprFireProof extends SimpleExpression {
private Expression entities;
- private Class> craftEntClass = ReflectionUtils.getOBCClass("entity.CraftEntity");
@Override
public Class extends Boolean> getReturnType() {
return Boolean.class;
@@ -47,40 +42,30 @@ public class ExprFireProof extends SimpleExpression {
@Nullable
protected Boolean[] get(Event e) {
Entity[] ents = entities.getAll(e);
- if (ents == null)
+ if (ents.length == 0)
return null;
- List fireProofStates = new ArrayList();
+ Boolean[] fireProofStates = new Boolean[ents.length];
+ int i = 0;
for (Entity ent : ents) {
if (ent == null)
continue;
- Object nmsEnt = null;
- try {
- nmsEnt = craftEntClass.cast(ent).getClass().getMethod("getHandle").invoke(ent); //nmsEnt = ((CraftEntity) ent).getHandle();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- fireProofStates.add((Boolean) ReflectionUtils.getField("fireProof", nmsEnt.getClass(), nmsEnt));
+ fireProofStates[i] = SkStuff.getNMSMethods().getFireProof(ent);
+ i++;
}
- return Arrays.copyOf(fireProofStates.toArray(), fireProofStates.size(), Boolean[].class);
+ return fireProofStates;
}
@Override
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
Entity[] ents = entities.getAll(e);
- if (ents == null)
+ if (ents.length == 0)
return;
if (mode == ChangeMode.SET) {
Boolean newValue = (Boolean) delta[0];
for (Entity ent : ents) {
if (ent == null)
continue;
- Object nmsEnt = null;
- try {
- nmsEnt = craftEntClass.cast(ent).getClass().getMethod("getHandle").invoke(ent); //nmsEnt = ((CraftEntity) ent).getHandle();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- ReflectionUtils.setField("fireProof", nmsEnt.getClass(), nmsEnt, newValue);
+ SkStuff.getNMSMethods().setFireProof(ent, newValue);
}
}
}
diff --git a/src/me/TheBukor/SkStuff/expressions/ExprInventoryOwner.java b/src/me/TheBukor/SkStuff/expressions/ExprInventoryOwner.java
new file mode 100644
index 0000000..b88153c
--- /dev/null
+++ b/src/me/TheBukor/SkStuff/expressions/ExprInventoryOwner.java
@@ -0,0 +1,62 @@
+package me.TheBukor.SkStuff.expressions;
+
+import javax.annotation.Nullable;
+
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockState;
+import org.bukkit.entity.Entity;
+import org.bukkit.event.Event;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.InventoryHolder;
+
+import ch.njol.skript.Skript;
+import ch.njol.skript.lang.Expression;
+import ch.njol.skript.lang.SkriptParser.ParseResult;
+import ch.njol.skript.lang.util.SimpleExpression;
+import ch.njol.util.Kleenean;
+
+public class ExprInventoryOwner extends SimpleExpression