Lots of stuff yet only one new expression added. Should work with Java 7

This commit is contained in:
Richard 2015-12-04 22:35:39 -02:00
parent 91fdd40d19
commit dd5d7ea91a
21 changed files with 161 additions and 195 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/Server - Survival - 1.8/spigot.jar"/> <classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/Server - Survival - 1.8/spigot.jar"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/Server - Survival - 1.8/plugins/Skript.jar"/> <classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/Server - Survival - 1.8/plugins/Skript.jar"/>
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/workspace/Spigot 1.8, 1.8.3/1.8.3.jar"/> <classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/workspace/Spigot 1.8, 1.8.3/1.8.3.jar"/>

View File

@ -1,11 +1,11 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.7

View File

@ -18,6 +18,7 @@ import ch.njol.skript.registrations.Classes;
import me.TheBukor.conditions.CondSelectionContains; import me.TheBukor.conditions.CondSelectionContains;
import me.TheBukor.effects.EffDrawLineWE; import me.TheBukor.effects.EffDrawLineWE;
import me.TheBukor.effects.EffUndoRedoSession; import me.TheBukor.effects.EffUndoRedoSession;
import me.TheBukor.expressions.ExprAreaOfSchematic;
import me.TheBukor.expressions.ExprAreaOfSelection; import me.TheBukor.expressions.ExprAreaOfSelection;
import me.TheBukor.expressions.ExprChangedBlocksSession; import me.TheBukor.expressions.ExprChangedBlocksSession;
import me.TheBukor.expressions.ExprEditSessionLimit; import me.TheBukor.expressions.ExprEditSessionLimit;
@ -60,11 +61,12 @@ public class SkStuff extends JavaPlugin {
getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!"); getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!");
if (Bukkit.getVersion().contains("(MC: 1.8)")){ if (Bukkit.getVersion().contains("(MC: 1.8)")){
getLogger().info("Successfully found 1.8! Registering version specific expressions..."); getLogger().info("Successfully found 1.8! Registering version specific expressions...");
exprAmount += 3; exprAmount += 4;
typeAmount += 1; typeAmount += 1;
Skript.registerExpression(ExprNBTv1_8_R1.class, NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]"); Skript.registerExpression(ExprNBTv1_8_R1.class, NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]");
Skript.registerExpression(ExprItemNBTv1_8_R1.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%"); Skript.registerExpression(ExprItemNBTv1_8_R1.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
Skript.registerExpression(ExprTagOfv1_8_R1.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%"); Skript.registerExpression(ExprTagOfv1_8_R1.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%");
//WARNING! HIGHLY EXPERIMENTAL, IT CAN CORRUPT WORLDS AT CURRENT VERSION, USE AT YOUR OWN RISK!
Skript.registerExpression(ExprFileNBTv1_8_R1.class, NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%"); Skript.registerExpression(ExprFileNBTv1_8_R1.class, NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%");
Classes.registerClass(new ClassInfo<NBTTagCompound>(NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser<NBTTagCompound>() { Classes.registerClass(new ClassInfo<NBTTagCompound>(NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser<NBTTagCompound>() {
@ -98,11 +100,12 @@ public class SkStuff extends JavaPlugin {
} }
if (Bukkit.getVersion().contains("(MC: 1.8.3)")){ if (Bukkit.getVersion().contains("(MC: 1.8.3)")){
getLogger().info("Successfully found 1.8.3! Registering version specific expressions..."); getLogger().info("Successfully found 1.8.3! Registering version specific expressions...");
exprAmount += 3; exprAmount += 4;
typeAmount += 1; typeAmount += 1;
Skript.registerExpression(ExprNBTv1_8_R2.class, net.minecraft.server.v1_8_R2.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]"); Skript.registerExpression(ExprNBTv1_8_R2.class, net.minecraft.server.v1_8_R2.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]");
Skript.registerExpression(ExprItemNBTv1_8_R2.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%"); Skript.registerExpression(ExprItemNBTv1_8_R2.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
Skript.registerExpression(ExprTagOfv1_8_R2.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%"); Skript.registerExpression(ExprTagOfv1_8_R2.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%");
//WARNING! HIGHLY EXPERIMENTAL, IT CAN CORRUPT WORLDS AT CURRENT VERSION, USE AT YOUR OWN RISK!
Skript.registerExpression(ExprFileNBTv1_8_R2.class, net.minecraft.server.v1_8_R2.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%"); Skript.registerExpression(ExprFileNBTv1_8_R2.class, net.minecraft.server.v1_8_R2.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%");
Classes.registerClass(new ClassInfo<net.minecraft.server.v1_8_R2.NBTTagCompound>(net.minecraft.server.v1_8_R2.NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser<net.minecraft.server.v1_8_R2.NBTTagCompound>() { Classes.registerClass(new ClassInfo<net.minecraft.server.v1_8_R2.NBTTagCompound>(net.minecraft.server.v1_8_R2.NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser<net.minecraft.server.v1_8_R2.NBTTagCompound>() {
@ -140,11 +143,12 @@ public class SkStuff extends JavaPlugin {
} }
if (Bukkit.getVersion().contains("(MC: 1.8.4)") || Bukkit.getVersion().contains("(MC: 1.8.5)") || Bukkit.getVersion().contains("(MC: 1.8.6)") || Bukkit.getVersion().contains("(MC: 1.8.7)") || Bukkit.getVersion().contains("(MC: 1.8.8)")) { if (Bukkit.getVersion().contains("(MC: 1.8.4)") || Bukkit.getVersion().contains("(MC: 1.8.5)") || Bukkit.getVersion().contains("(MC: 1.8.6)") || Bukkit.getVersion().contains("(MC: 1.8.7)") || Bukkit.getVersion().contains("(MC: 1.8.8)")) {
getLogger().info("Successfully found 1.8.4 - 1.8.8! Registering version specific expressions..."); getLogger().info("Successfully found 1.8.4 - 1.8.8! Registering version specific expressions...");
exprAmount += 3; exprAmount += 4;
typeAmount += 1; typeAmount += 1;
Skript.registerExpression(ExprNBTv1_8_R3.class, net.minecraft.server.v1_8_R3.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]"); Skript.registerExpression(ExprNBTv1_8_R3.class, net.minecraft.server.v1_8_R3.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of %entity/block/itemstack%", "%entity/block/itemstack%'s nbt[[ ]tag[s]]");
Skript.registerExpression(ExprItemNBTv1_8_R3.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%"); Skript.registerExpression(ExprItemNBTv1_8_R3.class, ItemStack.class, ExpressionType.SIMPLE, "%itemstack% with [custom] nbt[[ ]tag[s]] %string%");
Skript.registerExpression(ExprTagOfv1_8_R3.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%"); Skript.registerExpression(ExprTagOfv1_8_R3.class, Object.class, ExpressionType.SIMPLE, "[nbt[ ]]tag %string% of [nbt [compound]] %compound%");
//WARNING! HIGHLY EXPERIMENTAL, IT CAN CORRUPT WORLDS AT CURRENT VERSION, USE AT YOUR OWN RISK!
Skript.registerExpression(ExprFileNBTv1_8_R3.class, net.minecraft.server.v1_8_R3.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%"); Skript.registerExpression(ExprFileNBTv1_8_R3.class, net.minecraft.server.v1_8_R3.NBTTagCompound.class, ExpressionType.PROPERTY, "nbt[[ ]tag[s]] of [file] %string%");
Classes.registerClass(new ClassInfo<net.minecraft.server.v1_8_R3.NBTTagCompound>(net.minecraft.server.v1_8_R3.NBTTagCompound.class, "compound").name("NBT Compound").parser(new Parser<net.minecraft.server.v1_8_R3.NBTTagCompound>() { Classes.registerClass(new ClassInfo<net.minecraft.server.v1_8_R3.NBTTagCompound>(net.minecraft.server.v1_8_R3.NBTTagCompound.class, "compound").name("NBT Compound").parser(new Parser<net.minecraft.server.v1_8_R3.NBTTagCompound>() {
@ -184,7 +188,7 @@ public class SkStuff extends JavaPlugin {
getLogger().info("WorldEdit found! Registering WorldEdit stuff..."); getLogger().info("WorldEdit found! Registering WorldEdit stuff...");
condAmount += 1; condAmount += 1;
effAmount += 2; effAmount += 2;
exprAmount += 15; exprAmount += 16;
typeAmount += 1; 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%");
// EXPERIMENTAL EFFECTS/EXPRESSIONS // EXPERIMENTAL EFFECTS/EXPRESSIONS
@ -202,10 +206,11 @@ 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%"); Skript.registerExpression(ExprVolumeOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "volume of schem[atic] [from] %string%");
Skript.registerExpression(ExprWidthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(x( |-)size|width) of schem[atic] %string%"); Skript.registerExpression(ExprWidthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(x( |-)size|width) of schem[atic] [from] %string%");
Skript.registerExpression(ExprHeightOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(y( |-)size|height) of schem[atic] %string%"); Skript.registerExpression(ExprHeightOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(y( |-)size|height) of schem[atic] [from] %string%");
Skript.registerExpression(ExprLengthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(z( |-)size|length) of schem[atic] %string%"); Skript.registerExpression(ExprLengthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(z( |-)size|length) of schem[atic] [from] %string%");
Skript.registerExpression(ExprAreaOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "area of schem[atic] [from] %string%");
Classes.registerClass(new ClassInfo<EditSession>(EditSession.class, "editsession").name("Edit Session").parser(new Parser<EditSession>() { Classes.registerClass(new ClassInfo<EditSession>(EditSession.class, "editsession").name("Edit Session").parser(new Parser<EditSession>() {
@Override @Override
@ -239,11 +244,11 @@ public class SkStuff extends JavaPlugin {
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!")); 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(); Bukkit.getPluginManager().disablePlugin(this);;
} }
} }
public void onDisable() { public void onDisable() {
getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully disabled"); getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully disabled.");
} }
} }

View File

@ -10,7 +10,8 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitUtil; import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.patterns.SingleBlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.patterns.Pattern;
import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
@ -52,7 +53,7 @@ public class EffDrawLineWE extends Effect {
Double thick = thickness.getSingle(e); Double thick = thickness.getSingle(e);
if (b.getType().isBlock()) { if (b.getType().isBlock()) {
try { try {
session.drawLine(new SingleBlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), BukkitUtil.toVector(pos1), BukkitUtil.toVector(pos2), thick, filled); session.drawLine((Pattern) new BlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), BukkitUtil.toVector(pos1), BukkitUtil.toVector(pos2), thick, filled);
session.flushQueue(); session.flushQueue();
} catch (MaxChangedBlocksException ex) { } catch (MaxChangedBlocksException ex) {
return; return;

View File

@ -1,61 +0,0 @@
package me.TheBukor.effects;
import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.world.World;
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 EffExecuteWorldEdit extends Effect {
private Expression<Player> player;
private Expression<ItemStack> block;
private Expression<Integer> blockLimit;
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
player = (Expression<Player>) expr[0];
block = (Expression<ItemStack>) expr[1];
blockLimit = (Expression<Integer>) expr[2];
return true;
}
@Override
public String toString(@Nullable Event e, boolean arg1) {
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
protected void execute(Event e) {
Player p = player.getSingle(e);
ItemStack b = block.getSingle(e);
Integer limit = blockLimit.getSingle(e);
if (limit == null) limit = we.getLocalConfiguration().defaultChangeLimit;
if (we.getSelection(p) != null) {
if (b.getType().isBlock()) {
try {
EditSession editSession = we.getWorldEdit().getEditSessionFactory().getEditSession((World) we.wrapPlayer(p).getWorld(), limit, (com.sk89q.worldedit.entity.Player) we.wrapPlayer(p));
editSession.setBlocks(we.getSession(p).getSelection((World) we.wrapPlayer(p).getWorld()), new BaseBlock(b.getTypeId(), b.getDurability()));
we.getSession(p).remember(editSession); //So the player can do //undo if he wants to
} catch (MaxChangedBlocksException | IncompleteRegionException ex) {
return;
}
}
}
}
}

View File

@ -0,0 +1,58 @@
package me.TheBukor.expressions;
import java.io.File;
import java.io.IOException;
import javax.annotation.Nullable;
import org.bukkit.event.Event;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.schematic.MCEditSchematicFormat;
import com.sk89q.worldedit.world.DataException;
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 ExprAreaOfSchematic extends SimpleExpression<Integer> {
private Expression<String> schematic;
@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) {
schematic = (Expression<String>) expr[0];
return true;
}
@Override
public String toString(@Nullable Event e, boolean arg1) {
return "the area of the schematic from " + schematic.toString(e, false);
}
@Override
@Nullable
protected Integer[] get(Event e) {
String schem = schematic.getSingle(e);
File schemFile = new File((schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
Region region = null;
try {
region = ((Clipboard) MCEditSchematicFormat.getFormat(schemFile).load(schemFile)).getRegion();
} catch (DataException | IOException ex) {
return null;
}
return new Integer[] { region.getWidth() * region.getLength() };
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.Selection;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -41,11 +42,10 @@ public class ExprAreaOfSelection extends SimpleExpression<Integer> {
@Override @Override
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (worldEdit.getSelection(player.getSingle(e)) == null) { Selection sel = we.getSelection(player.getSingle(e));
if (sel == null)
return null; return null;
} return new Integer[] { sel.getWidth() * sel.getLength() };
return new Integer[] { (worldEdit.getSelection(player.getSingle(e)).getWidth() * worldEdit.getSelection(player.getSingle(e)).getLength()) };
} }
}
}

View File

@ -39,7 +39,8 @@ public class ExprChangedBlocksSession extends SimpleExpression<Integer> {
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
EditSession session = editSession.getSingle(e); EditSession session = editSession.getSingle(e);
if (session == null) return null; if (session == null)
return null;
return new Integer[] { session.getBlockChangeCount() }; return new Integer[] { session.getBlockChangeCount() };
} }
} }

View File

@ -46,14 +46,16 @@ public class ExprEditSessionLimit extends SimpleExpression<Integer> {
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
EditSession session = editSession.getSingle(e); EditSession session = editSession.getSingle(e);
if (session == null) return null; if (session == null)
return null;
return new Integer[] { session.getBlockChangeLimit() }; return new Integer[] { session.getBlockChangeLimit() };
} }
@Override @Override
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) { public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
EditSession session = editSession.getSingle(e); EditSession session = editSession.getSingle(e);
if (session == null) return; if (session == null)
return;
if (mode == ChangeMode.SET) { if (mode == ChangeMode.SET) {
Integer newLimit = (Integer) delta[0]; Integer newLimit = (Integer) delta[0];
session.setBlockChangeLimit(Integer.valueOf(newLimit)); session.setBlockChangeLimit(Integer.valueOf(newLimit));
@ -71,4 +73,4 @@ public class ExprEditSessionLimit extends SimpleExpression<Integer> {
} }
return null; return null;
} }
} }

View File

@ -5,24 +5,19 @@ import java.io.IOException;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.data.DataException;
import com.sk89q.worldedit.schematic.MCEditSchematicFormat; import com.sk89q.worldedit.schematic.MCEditSchematicFormat;
import com.sk89q.worldedit.world.DataException;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult; 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;
@SuppressWarnings("deprecation")
public class ExprHeightOfSchematic extends SimpleExpression<Integer> { public class ExprHeightOfSchematic extends SimpleExpression<Integer> {
private Expression<String> schematic; private Expression<String> schematic;
private Expression<String> folder;
@SuppressWarnings("unused")
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
@Override @Override
public Class<? extends Integer> getReturnType() { public Class<? extends Integer> getReturnType() {
@ -38,25 +33,23 @@ public class ExprHeightOfSchematic extends SimpleExpression<Integer> {
@Override @Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) { public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
schematic = (Expression<String>) expr[0]; schematic = (Expression<String>) expr[0];
folder = (Expression<String>) expr[1];
return true; return true;
} }
@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 " + (folder.getSingle(e) == null ? "plugins/WorldEdit/schematics" : folder.toString(e, false)); return "the height of the schematic from " + schematic.toString(e, false);
} }
@Override @Override
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
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 + "/") + (schem.endsWith(".schematic") ? schem : (schem + ".schematic"))); File schemFile = new File((schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
Integer h = null; Integer h = null;
try { try {
h = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getHeight(); h = ((Clipboard) MCEditSchematicFormat.getFormat(schemFile).load(schemFile)).getRegion().getHeight();
} catch (DataException | IOException e1) { } catch (DataException | IOException ex) {
return null; return null;
} }
return new Integer[] { h }; return new Integer[] { h };

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.Selection;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -41,11 +42,10 @@ public class ExprHeightOfSelection extends SimpleExpression<Integer> {
@Override @Override
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (worldEdit.getSelection(player.getSingle(e)) == null) { Selection sel = we.getSelection(player.getSingle(e));
if (sel == null)
return null; return null;
} return new Integer[] { sel.getHeight() };
return new Integer[] { worldEdit.getSelection(player.getSingle(e)).getHeight() };
} }
}
}

View File

@ -5,24 +5,19 @@ import java.io.IOException;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.data.DataException;
import com.sk89q.worldedit.schematic.MCEditSchematicFormat; import com.sk89q.worldedit.schematic.MCEditSchematicFormat;
import com.sk89q.worldedit.world.DataException;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult; 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;
@SuppressWarnings("deprecation")
public class ExprLengthOfSchematic extends SimpleExpression<Integer> { public class ExprLengthOfSchematic extends SimpleExpression<Integer> {
private Expression<String> schematic; private Expression<String> schematic;
private Expression<String> folder;
@SuppressWarnings("unused")
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
@Override @Override
public Class<? extends Integer> getReturnType() { public Class<? extends Integer> getReturnType() {
@ -38,25 +33,23 @@ public class ExprLengthOfSchematic extends SimpleExpression<Integer> {
@Override @Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) { public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
schematic = (Expression<String>) expr[0]; schematic = (Expression<String>) expr[0];
folder = (Expression<String>) expr[1];
return true; return true;
} }
@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 " + (folder.getSingle(e) == null ? "plugins/WorldEdit/schematics" : folder.toString(e, false)); return "the length of the schematic from " + schematic.toString(e, false);
} }
@Override @Override
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
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 + "/") + (schem.endsWith(".schematic") ? schem : (schem + ".schematic"))); File schemFile = new File((schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
Integer l = null; Integer l = null;
try { try {
l = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getLength(); l = ((Clipboard) MCEditSchematicFormat.getFormat(schemFile).load(schemFile)).getRegion().getLength();
} catch (DataException | IOException e1) { } catch (DataException | IOException ex) {
return null; return null;
} }
return new Integer[] { l }; return new Integer[] { l };

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.Selection;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -41,11 +42,10 @@ public class ExprLengthOfSelection extends SimpleExpression<Integer> {
@Override @Override
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (worldEdit.getSelection(player.getSingle(e)) == null) { Selection sel = we.getSelection(player.getSingle(e));
if (sel == null)
return null; return null;
} return new Integer[] { sel.getLength() };
return new Integer[] { worldEdit.getSelection(player.getSingle(e)).getLength() };
} }
}
}

View File

@ -7,7 +7,6 @@ import org.bukkit.World;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.bukkit.BukkitUtil; import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
@ -16,7 +15,6 @@ 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;
@SuppressWarnings("deprecation")
public class ExprNewEditSession extends SimpleExpression<EditSession> { public class ExprNewEditSession extends SimpleExpression<EditSession> {
private Expression<World> world; private Expression<World> world;
private Expression<Integer> blockLimit; private Expression<Integer> blockLimit;
@ -41,7 +39,7 @@ public class ExprNewEditSession extends SimpleExpression<EditSession> {
@Override @Override
public String toString(@Nullable Event e, boolean arg1) { public String toString(@Nullable Event e, boolean arg1) {
return "create a new edit session in world " + world.toString(e, false) + " with maximum block change limit of " + blockLimit.toString(e, false); return "new edit session in world " + world.toString(e, false) + " with maximum block change limit of " + blockLimit.toString(e, false);
} }
@Override @Override
@ -50,8 +48,7 @@ public class ExprNewEditSession extends SimpleExpression<EditSession> {
WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
World w = world.getSingle(e); World w = world.getSingle(e);
Integer limit = blockLimit.getSingle(e); Integer limit = blockLimit.getSingle(e);
LocalWorld localWorld = BukkitUtil.getLocalWorld(w); com.sk89q.worldedit.world.World weWorld = BukkitUtil.getLocalWorld(w);
return new EditSession[] { we.getWorldEdit().getEditSessionFactory().getEditSession(localWorld, limit) }; return new EditSession[] { we.getWorldEdit().getEditSessionFactory().getEditSession(weWorld, limit) };
} }
}
}

View File

@ -9,9 +9,11 @@ import org.bukkit.event.Event;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.lang.SkriptParser.ParseResult;
@ -44,14 +46,13 @@ public class ExprSelectionOfPlayer extends SimpleExpression<Location> {
return "the WorldEdit selection of " + player.toString(e, false); return "the WorldEdit selection of " + player.toString(e, false);
} }
@SuppressWarnings("deprecation")
@Override @Override
@Nullable @Nullable
protected Location[] get(Event e) { protected Location[] get(Event e) {
Player p = player.getSingle(e); Player p = player.getSingle(e);
Region region = null; Region region = null;
try { try {
region = we.getSession(p).getRegion(); region = we.getSession(p).getSelection((World) BukkitUtil.getLocalWorld(we.getSelection(p).getWorld()));
} catch (IncompleteRegionException ex) { } catch (IncompleteRegionException ex) {
return null; return null;
} }
@ -93,4 +94,4 @@ public class ExprSelectionOfPlayer extends SimpleExpression<Location> {
return null; return null;
} }
*/ */
} }

View File

@ -9,9 +9,11 @@ import org.bukkit.event.Event;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.lang.SkriptParser.ParseResult;
@ -44,19 +46,18 @@ public class ExprSelectionPos1 extends SimpleExpression<Location> {
return "the WorldEdit point 1 selection of " + player.toString(e, false); return "the WorldEdit point 1 selection of " + player.toString(e, false);
} }
@SuppressWarnings("deprecation")
@Override @Override
@Nullable @Nullable
protected Location[] get(Event e) { protected Location[] get(Event e) {
Player p = player.getSingle(e); Player p = player.getSingle(e);
Region region = null; Region region = null;
try { try {
region = we.getSession(p).getRegion(); region = we.getSession(p).getSelection((World) BukkitUtil.getLocalWorld(we.getSelection(p).getWorld()));
} catch (IncompleteRegionException ex) { } catch (IncompleteRegionException ex) {
return null; return null;
} }
if (!(region instanceof CuboidRegion)) { if (!(region instanceof CuboidRegion)) {
return null; return null; //Who uses polygonal and other selection types anyways?
} }
CuboidRegion cuboid = (CuboidRegion) region; CuboidRegion cuboid = (CuboidRegion) region;
Vector pos = cuboid.getPos1(); Vector pos = cuboid.getPos1();

View File

@ -9,9 +9,11 @@ import org.bukkit.event.Event;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitUtil;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult; import ch.njol.skript.lang.SkriptParser.ParseResult;
@ -44,19 +46,18 @@ public class ExprSelectionPos2 extends SimpleExpression<Location> {
return "the WorldEdit point 2 selection of " + player.toString(e, false); return "the WorldEdit point 2 selection of " + player.toString(e, false);
} }
@SuppressWarnings("deprecation")
@Override @Override
@Nullable @Nullable
protected Location[] get(Event e) { protected Location[] get(Event e) {
Player p = player.getSingle(e); Player p = player.getSingle(e);
Region region = null; Region region = null;
try { try {
region = we.getSession(p).getRegion(); region = we.getSession(p).getSelection((World) BukkitUtil.getLocalWorld(we.getSelection(p).getWorld()));
} catch (IncompleteRegionException ex) { } catch (IncompleteRegionException ex) {
return null; return null;
} }
if (!(region instanceof CuboidRegion)) { if (!(region instanceof CuboidRegion)) {
return null; return null; //Who uses polygonal and other selection types anyways?
} }
CuboidRegion cuboid = (CuboidRegion) region; CuboidRegion cuboid = (CuboidRegion) region;
Vector pos = cuboid.getPos2(); Vector pos = cuboid.getPos2();

View File

@ -5,24 +5,19 @@ import java.io.IOException;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.data.DataException;
import com.sk89q.worldedit.schematic.MCEditSchematicFormat; import com.sk89q.worldedit.schematic.MCEditSchematicFormat;
import com.sk89q.worldedit.world.DataException;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult; 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;
@SuppressWarnings("deprecation")
public class ExprVolumeOfSchematic extends SimpleExpression<Integer> { public class ExprVolumeOfSchematic extends SimpleExpression<Integer> {
private Expression<String> schematic; private Expression<String> schematic;
private Expression<String> folder;
@SuppressWarnings("unused")
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
@Override @Override
public Class<? extends Integer> getReturnType() { public Class<? extends Integer> getReturnType() {
@ -38,39 +33,25 @@ public class ExprVolumeOfSchematic extends SimpleExpression<Integer> {
@Override @Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) { public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
schematic = (Expression<String>) expr[0]; schematic = (Expression<String>) expr[0];
folder = (Expression<String>) expr[1];
return true; return true;
} }
@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 " + (folder.getSingle(e) == null ? "plugins/WorldEdit/schematics" : folder.toString(e, false)); return "the volume of the schematic from " + schematic.toString(e, false);
} }
@Override @Override
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
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 + "/") + (schem.endsWith(".schematic") ? schem : (schem + ".schematic"))); File schemFile = new File((schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
Integer w = 0; Integer v = null;
Integer h = 0;
Integer l = 0;
try { try {
w = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getWidth(); v = ((Clipboard) MCEditSchematicFormat.getFormat(schemFile).load(schemFile)).getRegion().getArea();
} catch (DataException | IOException e1) { } catch (DataException | IOException ex) {
return null; return null;
} }
try { return new Integer[] { v };
h = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getHeight();
} catch (DataException | IOException e2) {
return null;
}
try {
l = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getLength();
} catch (DataException | IOException e1) {
return null;
}
return new Integer[] { w * h * l };
} }
} }

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.Selection;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -35,17 +36,16 @@ public class ExprVolumeOfSelection 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 WorldEdit selection of " + player.toString(e, false); return "the width of the WorldEdit selection of " + player.toString(e, false);
} }
@Override @Override
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (worldEdit.getSelection(player.getSingle(e)) == null) { Selection sel = we.getSelection(player.getSingle(e));
if (sel == null)
return null; return null;
} return new Integer[] { sel.getArea() };
return new Integer[] { worldEdit.getSelection(player.getSingle(e)).getArea() };
} }
}
}

View File

@ -5,24 +5,19 @@ import java.io.IOException;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.data.DataException;
import com.sk89q.worldedit.schematic.MCEditSchematicFormat; import com.sk89q.worldedit.schematic.MCEditSchematicFormat;
import com.sk89q.worldedit.world.DataException;
import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult; 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;
@SuppressWarnings("deprecation")
public class ExprWidthOfSchematic extends SimpleExpression<Integer> { public class ExprWidthOfSchematic extends SimpleExpression<Integer> {
private Expression<String> schematic; private Expression<String> schematic;
private Expression<String> folder;
@SuppressWarnings("unused")
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
@Override @Override
public Class<? extends Integer> getReturnType() { public Class<? extends Integer> getReturnType() {
@ -38,25 +33,23 @@ public class ExprWidthOfSchematic extends SimpleExpression<Integer> {
@Override @Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) { public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
schematic = (Expression<String>) expr[0]; schematic = (Expression<String>) expr[0];
folder = (Expression<String>) expr[1];
return true; return true;
} }
@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 " + (folder.getSingle(e) == null ? "plugins/WorldEdit/schematics" : folder.toString(e, false)); return "the height of the schematic from " + schematic.toString(e, false);
} }
@Override @Override
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
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 + "/") + (schem.endsWith(".schematic") ? schem : (schem + ".schematic"))); File schemFile = new File((schem.endsWith(".schematic") ? schem : (schem + ".schematic")));
Integer w = null; Integer w = null;
try { try {
w = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getWidth(); w = ((Clipboard) MCEditSchematicFormat.getFormat(schemFile).load(schemFile)).getRegion().getWidth();
} catch (DataException | IOException e1) { } catch (DataException | IOException ex) {
return null; return null;
} }
return new Integer[] { w }; return new Integer[] { w };

View File

@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.Selection;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -41,11 +42,10 @@ public class ExprWidthOfSelection extends SimpleExpression<Integer> {
@Override @Override
@Nullable @Nullable
protected Integer[] get(Event e) { protected Integer[] get(Event e) {
WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (worldEdit.getSelection(player.getSingle(e)) == null) { Selection sel = we.getSelection(player.getSingle(e));
if (sel == null)
return null; return null;
} return new Integer[] { sel.getWidth() };
return new Integer[] { worldEdit.getSelection(player.getSingle(e)).getWidth() };
} }
}
}