Added experimental WE effects/expressions, fixed NPE when using the...
..."tag %string% of %compound%" expression with ItemStacks without NBT, tried to fix schematic expressions.
This commit is contained in:
parent
84907dd3a2
commit
ced2a2648d
@ -7,6 +7,8 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
|
||||||
import ch.njol.skript.Skript;
|
import ch.njol.skript.Skript;
|
||||||
import ch.njol.skript.classes.ClassInfo;
|
import ch.njol.skript.classes.ClassInfo;
|
||||||
import ch.njol.skript.classes.Parser;
|
import ch.njol.skript.classes.Parser;
|
||||||
@ -14,8 +16,12 @@ import ch.njol.skript.lang.ExpressionType;
|
|||||||
import ch.njol.skript.lang.ParseContext;
|
import ch.njol.skript.lang.ParseContext;
|
||||||
import ch.njol.skript.registrations.Classes;
|
import ch.njol.skript.registrations.Classes;
|
||||||
import me.TheBukor.conditions.CondSelectionContains;
|
import me.TheBukor.conditions.CondSelectionContains;
|
||||||
import me.TheBukor.effects.EffExecuteWorldEdit;
|
import me.TheBukor.effects.EffDrawLineWE;
|
||||||
|
import me.TheBukor.effects.EffUndoRedoSession;
|
||||||
import me.TheBukor.expressions.ExprAreaOfSelection;
|
import me.TheBukor.expressions.ExprAreaOfSelection;
|
||||||
|
import me.TheBukor.expressions.ExprChangedBlocksSession;
|
||||||
|
import me.TheBukor.expressions.ExprEditSession;
|
||||||
|
import me.TheBukor.expressions.ExprEditSessionLimit;
|
||||||
import me.TheBukor.expressions.ExprHeightOfSchematic;
|
import me.TheBukor.expressions.ExprHeightOfSchematic;
|
||||||
import me.TheBukor.expressions.ExprHeightOfSelection;
|
import me.TheBukor.expressions.ExprHeightOfSelection;
|
||||||
import me.TheBukor.expressions.ExprItemNBTv1_8_R1;
|
import me.TheBukor.expressions.ExprItemNBTv1_8_R1;
|
||||||
@ -44,7 +50,7 @@ public class SkStuff extends JavaPlugin {
|
|||||||
private int condAmount = 0;
|
private int condAmount = 0;
|
||||||
private int exprAmount = 0;
|
private int exprAmount = 0;
|
||||||
private int typeAmount = 0;
|
private int typeAmount = 0;
|
||||||
private int evtAmount = 0;
|
private int effAmount = 0;
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
if (Bukkit.getPluginManager().getPlugin("Skript") != null) {
|
if (Bukkit.getPluginManager().getPlugin("Skript") != null) {
|
||||||
Skript.registerAddon(this);
|
Skript.registerAddon(this);
|
||||||
@ -65,7 +71,7 @@ public class SkStuff extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public NBTTagCompound parse(String s, ParseContext arg1) {
|
public NBTTagCompound parse(String s, ParseContext context) {
|
||||||
NBTTagCompound NBT = new NBTTagCompound();
|
NBTTagCompound NBT = new NBTTagCompound();
|
||||||
NBTTagCompound NBT1 = MojangsonParser.parse(s);
|
NBTTagCompound NBT1 = MojangsonParser.parse(s);
|
||||||
NBT1.a(NBT);
|
NBT1.a(NBT);
|
||||||
@ -102,7 +108,7 @@ public class SkStuff extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public net.minecraft.server.v1_8_R2.NBTTagCompound parse(String s, ParseContext arg1) {
|
public net.minecraft.server.v1_8_R2.NBTTagCompound parse(String s, ParseContext context) {
|
||||||
net.minecraft.server.v1_8_R2.NBTTagCompound NBT = new net.minecraft.server.v1_8_R2.NBTTagCompound();
|
net.minecraft.server.v1_8_R2.NBTTagCompound NBT = new net.minecraft.server.v1_8_R2.NBTTagCompound();
|
||||||
try {
|
try {
|
||||||
net.minecraft.server.v1_8_R2.NBTTagCompound NBT1 = net.minecraft.server.v1_8_R2.MojangsonParser.parse(s);
|
net.minecraft.server.v1_8_R2.NBTTagCompound NBT1 = net.minecraft.server.v1_8_R2.MojangsonParser.parse(s);
|
||||||
@ -143,7 +149,7 @@ public class SkStuff extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public net.minecraft.server.v1_8_R3.NBTTagCompound parse(String s, ParseContext arg1) {
|
public net.minecraft.server.v1_8_R3.NBTTagCompound parse(String s, ParseContext context) {
|
||||||
net.minecraft.server.v1_8_R3.NBTTagCompound NBT = new net.minecraft.server.v1_8_R3.NBTTagCompound();
|
net.minecraft.server.v1_8_R3.NBTTagCompound NBT = new net.minecraft.server.v1_8_R3.NBTTagCompound();
|
||||||
try {
|
try {
|
||||||
net.minecraft.server.v1_8_R3.NBTTagCompound NBT1 = net.minecraft.server.v1_8_R3.MojangsonParser.parse(s);
|
net.minecraft.server.v1_8_R3.NBTTagCompound NBT1 = net.minecraft.server.v1_8_R3.MojangsonParser.parse(s);
|
||||||
@ -171,10 +177,17 @@ public class SkStuff extends JavaPlugin {
|
|||||||
if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
|
if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
|
||||||
getLogger().info("WorldEdit found! Registering WorldEdit stuff...");
|
getLogger().info("WorldEdit found! Registering WorldEdit stuff...");
|
||||||
condAmount += 1;
|
condAmount += 1;
|
||||||
evtAmount += 1;
|
effAmount += 2;
|
||||||
exprAmount += 12;
|
exprAmount += 15;
|
||||||
|
typeAmount += 1;
|
||||||
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.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(EffExecuteWorldEdit.class, "make %player% execute (world[ ]edit|we) [operation] set (using|with) %itemstack% [[with] limit [of] %integer% [blocks]]", "execute %player% (world[ ]edit|we) [operation] set (using|with) %itemstack% [[with] limit [of] %integer% [blocks]");
|
// EXPERIMENTAL EFFECTS/EXPRESSIONS
|
||||||
|
Skript.registerEffect(EffDrawLineWE.class, "(create|draw|make) [a] (no(n|t)(-| )hollow|filled) line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block] %itemstack% [[(and|with)] thick[ness] %-double%]", "(create|draw|make) [a] hollow line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block] %itemstack% [[(and|with)] thick[ness] %-double%]");
|
||||||
|
Skript.registerEffect(EffUndoRedoSession.class, "undo [last] (change|edit)[s] (of|from) [edit[ ]session] %editsession%", "redo [last] (change|edit)[s] (of|from) [edit[ ]session] %editsession%");
|
||||||
|
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(ExprEditSession.class, EditSession.class, ExpressionType.PROPERTY, "[new] edit[ ]session (for|from|of) %player%", "[new] %player% edit[ ]session");
|
||||||
|
// END OF EXPERIMENTAL EFFS/EXPRS
|
||||||
Skript.registerExpression(ExprSelectionOfPlayer.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection");
|
Skript.registerExpression(ExprSelectionOfPlayer.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection");
|
||||||
Skript.registerExpression(ExprSelectionPos1.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] po(s|int)[ ]1 of %player%", "%player%'s [(world[ ]edit|we)] po(s|int)[ ]1");
|
Skript.registerExpression(ExprSelectionPos1.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] po(s|int)[ ]1 of %player%", "%player%'s [(world[ ]edit|we)] po(s|int)[ ]1");
|
||||||
Skript.registerExpression(ExprSelectionPos2.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] po(s|int)[ ]2 of %player%", "%player%'s [(world[ ]edit|we)] po(s|int)[ ]2");
|
Skript.registerExpression(ExprSelectionPos2.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] po(s|int)[ ]2 of %player%", "%player%'s [(world[ ]edit|we)] po(s|int)[ ]2");
|
||||||
@ -183,24 +196,41 @@ public class SkStuff extends JavaPlugin {
|
|||||||
Skript.registerExpression(ExprLengthOfSelection.class, Integer.class, ExpressionType.SIMPLE, "(z( |-)size|length) of [(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we) ]selection (z( |-)size|length)");
|
Skript.registerExpression(ExprLengthOfSelection.class, Integer.class, ExpressionType.SIMPLE, "(z( |-)size|length) of [(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we) ]selection (z( |-)size|length)");
|
||||||
Skript.registerExpression(ExprHeightOfSelection.class, Integer.class, ExpressionType.SIMPLE, "(y( |-)size|height) of [(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we) ]selection (y( |-)size|height)");
|
Skript.registerExpression(ExprHeightOfSelection.class, Integer.class, ExpressionType.SIMPLE, "(y( |-)size|height) of [(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we) ]selection (y( |-)size|height)");
|
||||||
Skript.registerExpression(ExprAreaOfSelection.class, Integer.class, ExpressionType.SIMPLE, "area of [(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection area");
|
Skript.registerExpression(ExprAreaOfSelection.class, Integer.class, ExpressionType.SIMPLE, "area of [(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection area");
|
||||||
Skript.registerExpression(ExprVolumeOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "volume of schem[atic] %string% [from [folder] %string%]");
|
Skript.registerExpression(ExprVolumeOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "volume of schem[atic] %string% [from [folder] %-string%]");
|
||||||
Skript.registerExpression(ExprWidthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(x( |-)size|width) of schem[atic] %string% [from [folder] %string%]");
|
Skript.registerExpression(ExprWidthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(x( |-)size|width) of schem[atic] %string% [from [folder] %-string%]");
|
||||||
Skript.registerExpression(ExprHeightOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(y( |-)size|height) of schem[atic] %string% [from [folder] %string%]");
|
Skript.registerExpression(ExprHeightOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(y( |-)size|height) of schem[atic] %string% [from [folder] %-string%]");
|
||||||
Skript.registerExpression(ExprLengthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(z( |-)size|length) of schem[atic] %string% [from [folder] %string%]");
|
Skript.registerExpression(ExprLengthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(z( |-)size|length) of schem[atic] %string% [from [folder] %-string%]");
|
||||||
|
Classes.registerClass(new ClassInfo<EditSession>(EditSession.class, "editsession").name("Edit Session").parser(new Parser<EditSession>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVariableNamePattern() {
|
||||||
|
return ".+";
|
||||||
}
|
}
|
||||||
String pluralCond = "s";
|
|
||||||
String pluralType = "s";
|
@Override
|
||||||
String pluralEvt = "s";
|
@Nullable
|
||||||
if (condAmount == 1) {
|
public EditSession parse(String s, ParseContext context) {
|
||||||
pluralCond = "";
|
return null;
|
||||||
}
|
}
|
||||||
if (typeAmount == 1) {
|
|
||||||
pluralType = "";
|
@Override
|
||||||
|
public boolean canParse(ParseContext context) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (evtAmount == 1) {
|
|
||||||
pluralEvt = "";
|
@Override
|
||||||
|
public String toString(EditSession editSession, int arg1) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
getLogger().info("Everything ready! Loaded a total of " + condAmount + " condition" + pluralCond + ", " + evtAmount + "event" + pluralEvt + ", " + exprAmount + " expressions and " + typeAmount + " type" + pluralType + "!");
|
|
||||||
|
@Override
|
||||||
|
public String toVariableNameString(EditSession editSession) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
getLogger().info("Everything ready! Loaded a total of " + condAmount + (condAmount == 1 ? " condition, " : " conditions, ") + effAmount + (effAmount == 1 ? " effect, " : " effects, ") + exprAmount + (exprAmount == 1 ? " expression" : " expressions and ") + typeAmount + (typeAmount == 1 ? " type!" : " types!"));
|
||||||
} else {
|
} else {
|
||||||
getLogger().info("Unable to find Skript, disabling SkStuff...");
|
getLogger().info("Unable to find Skript, disabling SkStuff...");
|
||||||
this.onDisable();
|
this.onDisable();
|
||||||
|
63
src/me/TheBukor/effects/EffDrawLineWE.java
Normal file
63
src/me/TheBukor/effects/EffDrawLineWE.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package me.TheBukor.effects;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||||
|
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||||
|
|
||||||
|
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 EffDrawLineWE extends Effect {
|
||||||
|
private Expression<Location> location1;
|
||||||
|
private Expression<Location> location2;
|
||||||
|
private Expression<EditSession> editSession;
|
||||||
|
private Expression<ItemStack> block;
|
||||||
|
private Expression<Double> thickness;
|
||||||
|
private boolean filled = true;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||||
|
location1 = (Expression<Location>) expr[0];
|
||||||
|
location2 = (Expression<Location>) expr[1];
|
||||||
|
editSession = (Expression<EditSession>) expr[2];
|
||||||
|
block = (Expression<ItemStack>) expr[3];
|
||||||
|
thickness = (Expression<Double>) expr[4];
|
||||||
|
if (matchedPattern == 1) filled = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
|
return "draw a line using an edit session with " + block.toString(e, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute(Event e) {
|
||||||
|
Location pos1 = location1.getSingle(e);
|
||||||
|
Location pos2 = location2.getSingle(e);
|
||||||
|
EditSession session = editSession.getSingle(e);
|
||||||
|
ItemStack b = block.getSingle(e);
|
||||||
|
Double thick = thickness.getSingle(e);
|
||||||
|
if (thick == null) thick = (double) 1;
|
||||||
|
if (b.getType().isBlock()) {
|
||||||
|
try {
|
||||||
|
session.drawLine(new SingleBlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), BukkitUtil.toVector(pos1), BukkitUtil.toVector(pos2), thick, filled);
|
||||||
|
session.flushQueue();
|
||||||
|
} catch (MaxChangedBlocksException ex) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,7 +19,6 @@ import ch.njol.skript.lang.Expression;
|
|||||||
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||||
import ch.njol.util.Kleenean;
|
import ch.njol.util.Kleenean;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class EffExecuteWorldEdit extends Effect {
|
public class EffExecuteWorldEdit extends Effect {
|
||||||
private Expression<Player> player;
|
private Expression<Player> player;
|
||||||
private Expression<ItemStack> block;
|
private Expression<ItemStack> block;
|
||||||
@ -40,21 +39,19 @@ public class EffExecuteWorldEdit extends Effect {
|
|||||||
return "make " + player.toString(e, false) + " execute WorldEdit set using " + block.toString(e, false) + new String(blockLimit.getSingle(e) != null ? " with limit of " + blockLimit.toString(e, false) + " blocks" : "");
|
return "make " + player.toString(e, false) + " execute WorldEdit set using " + block.toString(e, false) + new String(blockLimit.getSingle(e) != null ? " with limit of " + blockLimit.toString(e, false) + " blocks" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
protected void execute(Event e) {
|
protected void execute(Event e) {
|
||||||
Player p = player.getSingle(e);
|
Player p = player.getSingle(e);
|
||||||
ItemStack b = block.getSingle(e);
|
ItemStack b = block.getSingle(e);
|
||||||
Integer limit = blockLimit.getSingle(e);
|
Integer limit = blockLimit.getSingle(e);
|
||||||
if (limit == null) limit = we.getWorldEdit().getConfiguration().defaultChangeLimit;
|
if (limit == null) limit = we.getLocalConfiguration().defaultChangeLimit;
|
||||||
if (we.getSelection(p) != null) {
|
if (we.getSelection(p) != null) {
|
||||||
if (b.getType().isBlock()) {
|
if (b.getType().isBlock()) {
|
||||||
try {
|
try {
|
||||||
EditSession session = we.createEditSession(p);
|
EditSession editSession = we.getWorldEdit().getEditSessionFactory().getEditSession((World) we.wrapPlayer(p).getWorld(), limit, (com.sk89q.worldedit.entity.Player) we.wrapPlayer(p));
|
||||||
p.sendMessage(Boolean.toString(session.isQueueEnabled()));
|
editSession.setBlocks(we.getSession(p).getSelection((World) we.wrapPlayer(p).getWorld()), new BaseBlock(b.getTypeId(), b.getDurability()));
|
||||||
session.enableQueue();
|
we.getSession(p).remember(editSession); //So the player can do //undo if he wants to
|
||||||
session.setBlockChangeLimit(limit);
|
|
||||||
session.setBlocks(we.getSession(p).getSelection((World) we.wrapPlayer(p).getWorld()), new BaseBlock(b.getTypeId(), b.getDurability()));
|
|
||||||
we.getSession(p).remember(session);
|
|
||||||
} catch (MaxChangedBlocksException | IncompleteRegionException ex) {
|
} catch (MaxChangedBlocksException | IncompleteRegionException ex) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
42
src/me/TheBukor/effects/EffUndoRedoSession.java
Normal file
42
src/me/TheBukor/effects/EffUndoRedoSession.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package me.TheBukor.effects;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
|
||||||
|
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 EffUndoRedoSession extends Effect {
|
||||||
|
private Expression<EditSession> editSession;
|
||||||
|
private boolean redo = false;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||||
|
editSession = (Expression<EditSession>) expr[0];
|
||||||
|
if (matchedPattern == 1) redo = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
|
return "undo last change of edit session";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void execute(Event e) {
|
||||||
|
EditSession session = editSession.getSingle(e);
|
||||||
|
if (session == null) return;
|
||||||
|
if (redo == false) {
|
||||||
|
session.undo(session);
|
||||||
|
} else {
|
||||||
|
session.redo(session);
|
||||||
|
}
|
||||||
|
session.flushQueue();
|
||||||
|
}
|
||||||
|
}
|
45
src/me/TheBukor/expressions/ExprChangedBlocksSession.java
Normal file
45
src/me/TheBukor/expressions/ExprChangedBlocksSession.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package me.TheBukor.expressions;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
|
||||||
|
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 ExprChangedBlocksSession extends SimpleExpression<Integer> {
|
||||||
|
private Expression<EditSession> editSession;
|
||||||
|
@Override
|
||||||
|
public Class<? extends Integer> getReturnType() {
|
||||||
|
return Integer.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSingle() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||||
|
editSession = (Expression<EditSession>) expr[0];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
|
return "the number of changed blocks in an edit session";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected Integer[] get(Event e) {
|
||||||
|
EditSession session = editSession.getSingle(e);
|
||||||
|
if (session == null) return null;
|
||||||
|
return new Integer[] { session.getBlockChangeCount() };
|
||||||
|
}
|
||||||
|
}
|
54
src/me/TheBukor/expressions/ExprEditSession.java
Normal file
54
src/me/TheBukor/expressions/ExprEditSession.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package me.TheBukor.expressions;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
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 ExprEditSession extends SimpleExpression<EditSession> {
|
||||||
|
private Expression<Player> player;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends EditSession> getReturnType() {
|
||||||
|
return EditSession.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSingle() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||||
|
player = (Expression<Player>) expr[0];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
|
return "the edit session of " + player.toString(e, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected EditSession[] get(Event e) {
|
||||||
|
Player p = player.getSingle(e);
|
||||||
|
WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
|
if (we.getWorldEdit().getEditSessionFactory().getEditSession((World) we.wrapPlayer(p).getWorld(), we.getSession(p).getBlockChangeLimit(), we.wrapPlayer(p)) == null) {
|
||||||
|
return new EditSession[] { we.createEditSession(p) };
|
||||||
|
}
|
||||||
|
return new EditSession[] { we.getWorldEdit().getEditSessionFactory().getEditSession((World) we.wrapPlayer(p).getWorld(), we.getSession(p).getBlockChangeLimit(), we.wrapPlayer(p)) };
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
73
src/me/TheBukor/expressions/ExprEditSessionLimit.java
Normal file
73
src/me/TheBukor/expressions/ExprEditSessionLimit.java
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package me.TheBukor.expressions;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
|
||||||
|
import ch.njol.skript.classes.Changer.ChangeMode;
|
||||||
|
import ch.njol.skript.lang.Expression;
|
||||||
|
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||||
|
import ch.njol.skript.lang.util.SimpleExpression;
|
||||||
|
import ch.njol.util.Kleenean;
|
||||||
|
import ch.njol.util.coll.CollectionUtils;
|
||||||
|
|
||||||
|
public class ExprEditSessionLimit extends SimpleExpression<Integer> {
|
||||||
|
private Expression<EditSession> editSession;
|
||||||
|
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends Integer> getReturnType() {
|
||||||
|
return Integer.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSingle() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||||
|
editSession = (Expression<EditSession>) expr[0];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
|
return "the block change limit of an edit session";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected Integer[] get(Event e) {
|
||||||
|
EditSession session = editSession.getSingle(e);
|
||||||
|
if (session == null) return null;
|
||||||
|
return new Integer[] { session.getBlockChangeLimit() };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
||||||
|
EditSession session = editSession.getSingle(e);
|
||||||
|
if (mode == ChangeMode.SET) {
|
||||||
|
Integer newLimit = (Integer) delta[0];
|
||||||
|
session.setBlockChangeLimit(newLimit);
|
||||||
|
} else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
|
||||||
|
session.setBlockChangeLimit(we.getLocalConfiguration().defaultChangeLimit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public Class<?>[] acceptChange(ChangeMode mode) {
|
||||||
|
if (mode == ChangeMode.SET || mode == ChangeMode.RESET || mode == ChangeMode.DELETE) {
|
||||||
|
return CollectionUtils.array(Integer.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -44,15 +44,15 @@ public class ExprHeightOfSchematic extends SimpleExpression<Integer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(@Nullable Event e, boolean arg1) {
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
return "the height of the schematic " + schematic.toString(e, false) + " in the folder " + new String(folder.getSingle(e) != null ? folder.toString(e, false) : "plugins/WorldEdit/schematics");
|
return "the height of the schematic " + schematic.toString(e, false) + " in the folder " + (folder.getSingle(e) == null ? "plugins/WorldEdit/schematics" : folder.toString(e, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Integer[] get(Event e) {
|
protected Integer[] get(Event e) {
|
||||||
String f = (folder.getSingle(e) != null) ? folder.getSingle(e) : "plugins/WorldEdit/schematics/";
|
String f = (folder.getSingle(e) == null) ? "plugins/WorldEdit/schematics/" : folder.getSingle(e);
|
||||||
String schem = schematic.getSingle(e);
|
String schem = schematic.getSingle(e);
|
||||||
File schemFile = new File((f.endsWith("/")) ? f : f + "/" + new String(schem.endsWith(".schematic") ? schem : schem + ".schematic"));
|
File schemFile = new File((f.endsWith("/")) ? f : (f + "/") + (schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
|
||||||
Integer h = null;
|
Integer h = null;
|
||||||
try {
|
try {
|
||||||
h = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getHeight();
|
h = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getHeight();
|
||||||
|
@ -44,15 +44,15 @@ public class ExprLengthOfSchematic extends SimpleExpression<Integer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(@Nullable Event e, boolean arg1) {
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
return "the length of the schematic " + schematic.toString(e, false) + " in the folder " + new String(folder.getSingle(e) != null ? folder.toString(e, false) : "plugins/WorldEdit/schematics");
|
return "the length of the schematic " + schematic.toString(e, false) + " in the folder " + (folder.getSingle(e) == null ? "plugins/WorldEdit/schematics" : folder.toString(e, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Integer[] get(Event e) {
|
protected Integer[] get(Event e) {
|
||||||
String f = (folder.getSingle(e) != null) ? folder.getSingle(e) : "plugins/WorldEdit/schematics/";
|
String f = (folder.getSingle(e) == null) ? "plugins/WorldEdit/schematics/" : folder.getSingle(e);
|
||||||
String schem = schematic.getSingle(e);
|
String schem = schematic.getSingle(e);
|
||||||
File schemFile = new File((f.endsWith("/")) ? f : f + "/" + new String(schem.endsWith(".schematic") ? schem : schem + ".schematic"));
|
File schemFile = new File((f.endsWith("/")) ? f : (f + "/") + (schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
|
||||||
Integer l = null;
|
Integer l = null;
|
||||||
try {
|
try {
|
||||||
l = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getLength();
|
l = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getLength();
|
||||||
|
@ -9,6 +9,7 @@ import ch.njol.skript.lang.SkriptParser.ParseResult;
|
|||||||
import ch.njol.skript.lang.util.SimpleExpression;
|
import ch.njol.skript.lang.util.SimpleExpression;
|
||||||
import ch.njol.util.Kleenean;
|
import ch.njol.util.Kleenean;
|
||||||
import net.minecraft.server.v1_8_R1.NBTTagCompound;
|
import net.minecraft.server.v1_8_R1.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_8_R1.NBTTagList;
|
||||||
|
|
||||||
public class ExprTagOfv1_8_R1 extends SimpleExpression<Object> {
|
public class ExprTagOfv1_8_R1 extends SimpleExpression<Object> {
|
||||||
private Expression<String> string;
|
private Expression<String> string;
|
||||||
@ -38,41 +39,41 @@ public class ExprTagOfv1_8_R1 extends SimpleExpression<Object> {
|
|||||||
@Nullable
|
@Nullable
|
||||||
protected Object[] get(Event e) {
|
protected Object[] get(Event e) {
|
||||||
NBTTagCompound NBT = compound.getSingle(e);
|
NBTTagCompound NBT = compound.getSingle(e);
|
||||||
|
if (NBT.isEmpty() || NBT == null) return null; //The NBT can be empty/inexistant for items
|
||||||
String tag = string.getSingle(e);
|
String tag = string.getSingle(e);
|
||||||
if (NBT.get(tag) == null) {
|
if (NBT.get(tag) == null) return null; //The tag doesn't exist? Return <none>.
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Byte id = NBT.get(tag).getTypeId();
|
Byte id = NBT.get(tag).getTypeId();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 1:
|
case 1:
|
||||||
returned = new Object[] { NBT.getByte(tag) };
|
returned = new Byte[] { NBT.getByte(tag) };
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
returned = new Object[] { NBT.getShort(tag) };
|
returned = new Short[] { NBT.getShort(tag) };
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
returned = new Object[] { NBT.getInt(tag) };
|
returned = new Integer[] { NBT.getInt(tag) };
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
returned = new Object[] { NBT.getLong(tag) };
|
returned = new Long[] { NBT.getLong(tag) };
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
returned = new Object[] { NBT.getFloat(tag) };
|
returned = new Float[] { NBT.getFloat(tag) };
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
returned = new Object[] { NBT.getDouble(tag) };
|
returned = new Double[] { NBT.getDouble(tag) };
|
||||||
|
break;
|
||||||
|
case 7: //Byte array, never seen this kind of tag (where is it used?)
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
returned = new Object[] { NBT.getString(tag) };
|
returned = new String[] { NBT.getString(tag) };
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9: //List, will need to make a new type if getCompound() doesn't work here
|
||||||
returned = null;
|
returned = new NBTTagList[] { NBT.getList(tag, 5) }; //Is the int argument the type ID?
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
returned = new Object[] { NBT.getCompound(tag) };
|
returned = new NBTTagCompound[] { NBT.getCompound(tag) };
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11: //Integer array, this one is only used on the chunk files I believe
|
||||||
returned = null;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -9,6 +9,7 @@ import ch.njol.skript.lang.SkriptParser.ParseResult;
|
|||||||
import ch.njol.skript.lang.util.SimpleExpression;
|
import ch.njol.skript.lang.util.SimpleExpression;
|
||||||
import ch.njol.util.Kleenean;
|
import ch.njol.util.Kleenean;
|
||||||
import net.minecraft.server.v1_8_R2.NBTTagCompound;
|
import net.minecraft.server.v1_8_R2.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_8_R2.NBTTagList;
|
||||||
|
|
||||||
public class ExprTagOfv1_8_R2 extends SimpleExpression<Object> {
|
public class ExprTagOfv1_8_R2 extends SimpleExpression<Object> {
|
||||||
private Expression<String> string;
|
private Expression<String> string;
|
||||||
@ -38,41 +39,41 @@ public class ExprTagOfv1_8_R2 extends SimpleExpression<Object> {
|
|||||||
@Nullable
|
@Nullable
|
||||||
protected Object[] get(Event e) {
|
protected Object[] get(Event e) {
|
||||||
NBTTagCompound NBT = compound.getSingle(e);
|
NBTTagCompound NBT = compound.getSingle(e);
|
||||||
|
if (NBT.isEmpty() || NBT == null) return null; //The NBT can be empty/inexistant for items
|
||||||
String tag = string.getSingle(e);
|
String tag = string.getSingle(e);
|
||||||
if (NBT.get(tag) == null) {
|
if (NBT.get(tag) == null) return null; //The tag doesn't exist? Return <none>.
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Byte id = NBT.get(tag).getTypeId();
|
Byte id = NBT.get(tag).getTypeId();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 1:
|
case 1:
|
||||||
returned = new Object[] { NBT.getByte(tag) };
|
returned = new Byte[] { NBT.getByte(tag) };
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
returned = new Object[] { NBT.getShort(tag) };
|
returned = new Short[] { NBT.getShort(tag) };
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
returned = new Object[] { NBT.getInt(tag) };
|
returned = new Integer[] { NBT.getInt(tag) };
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
returned = new Object[] { NBT.getLong(tag) };
|
returned = new Long[] { NBT.getLong(tag) };
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
returned = new Object[] { NBT.getFloat(tag) };
|
returned = new Float[] { NBT.getFloat(tag) };
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
returned = new Object[] { NBT.getDouble(tag) };
|
returned = new Double[] { NBT.getDouble(tag) };
|
||||||
|
break;
|
||||||
|
case 7: //Byte array, never seen this kind of tag (where is it used?)
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
returned = new Object[] { NBT.getString(tag) };
|
returned = new String[] { NBT.getString(tag) };
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9: //List, will need to make a new type if getCompound() doesn't work here
|
||||||
returned = null;
|
returned = new NBTTagList[] { NBT.getList(tag, 5) }; //Is the int argument the type ID?
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
returned = new Object[] { NBT.getCompound(tag) };
|
returned = new NBTTagCompound[] { NBT.getCompound(tag) };
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11: //Integer array, this one is only used on the chunk files I believe
|
||||||
returned = null;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -2,6 +2,7 @@ package me.TheBukor.expressions;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
import ch.njol.skript.lang.Expression;
|
import ch.njol.skript.lang.Expression;
|
||||||
@ -38,41 +39,42 @@ public class ExprTagOfv1_8_R3 extends SimpleExpression<Object> {
|
|||||||
@Nullable
|
@Nullable
|
||||||
protected Object[] get(Event e) {
|
protected Object[] get(Event e) {
|
||||||
NBTTagCompound NBT = compound.getSingle(e);
|
NBTTagCompound NBT = compound.getSingle(e);
|
||||||
|
if (NBT == null || NBT.isEmpty()) return null; //The NBT can be empty/inexistant for items
|
||||||
String tag = string.getSingle(e);
|
String tag = string.getSingle(e);
|
||||||
if (NBT.get(tag) == null) {
|
if (NBT.get(tag) == null) return null; //The tag doesn't exist? Return <none>.
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Byte id = NBT.get(tag).getTypeId();
|
Byte id = NBT.get(tag).getTypeId();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 1:
|
case 1:
|
||||||
returned = new Object[] { NBT.getByte(tag) };
|
returned = new Byte[] { NBT.getByte(tag) };
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
returned = new Object[] { NBT.getShort(tag) };
|
returned = new Short[] { NBT.getShort(tag) };
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
returned = new Object[] { NBT.getInt(tag) };
|
returned = new Integer[] { NBT.getInt(tag) };
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
returned = new Object[] { NBT.getLong(tag) };
|
returned = new Long[] { NBT.getLong(tag) };
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
returned = new Object[] { NBT.getFloat(tag) };
|
returned = new Float[] { NBT.getFloat(tag) };
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
returned = new Object[] { NBT.getDouble(tag) };
|
returned = new Double[] { NBT.getDouble(tag) };
|
||||||
|
break;
|
||||||
|
case 7: //Byte array, never seen this kind of tag (where is it used?)
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
returned = new Object[] { NBT.getString(tag) };
|
returned = new String[] { NBT.getString(tag) };
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9: //List, will need to make a new type if getCompound() doesn't work here
|
||||||
returned = null;
|
Bukkit.broadcastMessage("LIST!");
|
||||||
|
returned = new Object[] { NBT.getList(tag, 0).toString() }; //Is the int argument the type ID?
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
returned = new Object[] { NBT.getCompound(tag) };
|
returned = new NBTTagCompound[] { NBT.getCompound(tag) };
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11: //Integer array, this one is only used on the chunk files I believe
|
||||||
returned = null;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -44,15 +44,15 @@ public class ExprVolumeOfSchematic extends SimpleExpression<Integer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(@Nullable Event e, boolean arg1) {
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
return "the volume of the schematic " + schematic.toString(e, false) + " in the folder " + new String(folder.getSingle(e) != null ? folder.toString(e, false) : "plugins/WorldEdit/schematics");
|
return "the volume of the schematic " + schematic.toString(e, false) + " in the folder " + (folder.getSingle(e) == null ? "plugins/WorldEdit/schematics" : folder.toString(e, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Integer[] get(Event e) {
|
protected Integer[] get(Event e) {
|
||||||
String f = (folder.getSingle(e) != null) ? folder.getSingle(e) : "plugins/WorldEdit/schematics/";
|
String f = (folder.getSingle(e) == null) ? "plugins/WorldEdit/schematics/" : folder.getSingle(e);
|
||||||
String schem = schematic.getSingle(e);
|
String schem = schematic.getSingle(e);
|
||||||
File schemFile = new File((f.endsWith("/")) ? f : f + "/" + new String(schem.endsWith(".schematic") ? schem : schem + ".schematic"));
|
File schemFile = new File((f.endsWith("/")) ? f : (f + "/") + (schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
|
||||||
Integer w = 0;
|
Integer w = 0;
|
||||||
Integer h = 0;
|
Integer h = 0;
|
||||||
Integer l = 0;
|
Integer l = 0;
|
||||||
|
@ -44,15 +44,15 @@ public class ExprWidthOfSchematic extends SimpleExpression<Integer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(@Nullable Event e, boolean arg1) {
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
return "the width of the schematic " + schematic.toString(e, false) + " in the folder " + new String(folder.getSingle(e) != null ? folder.toString(e, false) : "plugins/WorldEdit/schematics");
|
return "the width of the schematic " + schematic.toString(e, false) + " in the folder " + (folder.getSingle(e) == null ? "plugins/WorldEdit/schematics" : folder.toString(e, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Integer[] get(Event e) {
|
protected Integer[] get(Event e) {
|
||||||
String f = (folder.getSingle(e) != null) ? folder.getSingle(e) : "plugins/WorldEdit/schematics/";
|
String f = (folder.getSingle(e) == null) ? "plugins/WorldEdit/schematics/" : folder.getSingle(e);
|
||||||
String schem = schematic.getSingle(e);
|
String schem = schematic.getSingle(e);
|
||||||
File schemFile = new File((f.endsWith("/")) ? f : f + "/" + new String(schem.endsWith(".schematic") ? schem : schem + ".schematic"));
|
File schemFile = new File((f.endsWith("/")) ? f : (f + "/") + (schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
|
||||||
Integer w = null;
|
Integer w = null;
|
||||||
try {
|
try {
|
||||||
w = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getWidth();
|
w = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getWidth();
|
||||||
|
Loading…
Reference in New Issue
Block a user