diff --git a/.classpath b/.classpath index e462881..502a1af 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,7 @@ - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index bb35fa0..838bd9d 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ eclipse.preferences.version=1 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.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.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=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 diff --git a/src/me/TheBukor/SkStuff.java b/src/me/TheBukor/SkStuff.java index 7c8b4f9..5c01682 100644 --- a/src/me/TheBukor/SkStuff.java +++ b/src/me/TheBukor/SkStuff.java @@ -18,6 +18,7 @@ import ch.njol.skript.registrations.Classes; import me.TheBukor.conditions.CondSelectionContains; import me.TheBukor.effects.EffDrawLineWE; import me.TheBukor.effects.EffUndoRedoSession; +import me.TheBukor.expressions.ExprAreaOfSchematic; import me.TheBukor.expressions.ExprAreaOfSelection; import me.TheBukor.expressions.ExprChangedBlocksSession; import me.TheBukor.expressions.ExprEditSessionLimit; @@ -60,11 +61,12 @@ public class SkStuff extends JavaPlugin { getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!"); if (Bukkit.getVersion().contains("(MC: 1.8)")){ getLogger().info("Successfully found 1.8! Registering version specific expressions..."); - exprAmount += 3; + exprAmount += 4; 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(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%"); + //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%"); Classes.registerClass(new ClassInfo(NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser() { @@ -98,11 +100,12 @@ public class SkStuff extends JavaPlugin { } if (Bukkit.getVersion().contains("(MC: 1.8.3)")){ getLogger().info("Successfully found 1.8.3! Registering version specific expressions..."); - exprAmount += 3; + exprAmount += 4; 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(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%"); + //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%"); Classes.registerClass(new ClassInfo(net.minecraft.server.v1_8_R2.NBTTagCompound.class, "compound").name("NBT Tag Compound").parser(new Parser() { @@ -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)")) { getLogger().info("Successfully found 1.8.4 - 1.8.8! Registering version specific expressions..."); - exprAmount += 3; + exprAmount += 4; 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(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%"); + //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%"); Classes.registerClass(new ClassInfo(net.minecraft.server.v1_8_R3.NBTTagCompound.class, "compound").name("NBT Compound").parser(new Parser() { @@ -184,7 +188,7 @@ public class SkStuff extends JavaPlugin { getLogger().info("WorldEdit found! Registering WorldEdit stuff..."); condAmount += 1; effAmount += 2; - exprAmount += 15; + exprAmount += 16; 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%"); // 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(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(ExprVolumeOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "volume of schem[atic] %string%"); - Skript.registerExpression(ExprWidthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(x( |-)size|width) of schem[atic] %string%"); - Skript.registerExpression(ExprHeightOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(y( |-)size|height) of schem[atic] %string%"); - Skript.registerExpression(ExprLengthOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "(z( |-)size|length) 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] [from] %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] [from] %string%"); + Skript.registerExpression(ExprAreaOfSchematic.class, Integer.class, ExpressionType.SIMPLE, "area of schem[atic] [from] %string%"); Classes.registerClass(new ClassInfo(EditSession.class, "editsession").name("Edit Session").parser(new Parser() { @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!")); } else { getLogger().info("Unable to find Skript, disabling SkStuff..."); - this.onDisable(); + Bukkit.getPluginManager().disablePlugin(this);; } } public void onDisable() { - getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully disabled"); + getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully disabled."); } } diff --git a/src/me/TheBukor/effects/EffDrawLineWE.java b/src/me/TheBukor/effects/EffDrawLineWE.java index 595c01d..81296a2 100644 --- a/src/me/TheBukor/effects/EffDrawLineWE.java +++ b/src/me/TheBukor/effects/EffDrawLineWE.java @@ -10,7 +10,8 @@ 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 com.sk89q.worldedit.function.pattern.BlockPattern; +import com.sk89q.worldedit.patterns.Pattern; import ch.njol.skript.lang.Effect; import ch.njol.skript.lang.Expression; @@ -52,7 +53,7 @@ public class EffDrawLineWE extends Effect { Double thick = thickness.getSingle(e); if (b.getType().isBlock()) { 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(); } catch (MaxChangedBlocksException ex) { return; diff --git a/src/me/TheBukor/effects/EffExecuteWorldEdit.java b/src/me/TheBukor/effects/EffExecuteWorldEdit.java deleted file mode 100644 index 92e1e35..0000000 --- a/src/me/TheBukor/effects/EffExecuteWorldEdit.java +++ /dev/null @@ -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; - private Expression block; - private Expression 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) expr[0]; - block = (Expression) expr[1]; - blockLimit = (Expression) 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; - } - } - } - } -} diff --git a/src/me/TheBukor/expressions/ExprAreaOfSchematic.java b/src/me/TheBukor/expressions/ExprAreaOfSchematic.java new file mode 100644 index 0000000..c22f5db --- /dev/null +++ b/src/me/TheBukor/expressions/ExprAreaOfSchematic.java @@ -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 { + private Expression schematic; + + @Override + public Class 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) 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() }; + } +} \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprAreaOfSelection.java b/src/me/TheBukor/expressions/ExprAreaOfSelection.java index 4bb017b..aacfd32 100644 --- a/src/me/TheBukor/expressions/ExprAreaOfSelection.java +++ b/src/me/TheBukor/expressions/ExprAreaOfSelection.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.bukkit.selections.Selection; import javax.annotation.Nullable; @@ -41,11 +42,10 @@ public class ExprAreaOfSelection extends SimpleExpression { @Override @Nullable protected Integer[] get(Event e) { - WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); - if (worldEdit.getSelection(player.getSingle(e)) == null) { + WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); + Selection sel = we.getSelection(player.getSingle(e)); + if (sel == null) return null; - } - return new Integer[] { (worldEdit.getSelection(player.getSingle(e)).getWidth() * worldEdit.getSelection(player.getSingle(e)).getLength()) }; + return new Integer[] { sel.getWidth() * sel.getLength() }; } - -} +} \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprChangedBlocksSession.java b/src/me/TheBukor/expressions/ExprChangedBlocksSession.java index 22ddf51..a070a43 100644 --- a/src/me/TheBukor/expressions/ExprChangedBlocksSession.java +++ b/src/me/TheBukor/expressions/ExprChangedBlocksSession.java @@ -39,7 +39,8 @@ public class ExprChangedBlocksSession extends SimpleExpression { @Nullable protected Integer[] get(Event e) { EditSession session = editSession.getSingle(e); - if (session == null) return null; + if (session == null) + return null; return new Integer[] { session.getBlockChangeCount() }; } -} +} \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprEditSessionLimit.java b/src/me/TheBukor/expressions/ExprEditSessionLimit.java index 71fd595..0491bd3 100644 --- a/src/me/TheBukor/expressions/ExprEditSessionLimit.java +++ b/src/me/TheBukor/expressions/ExprEditSessionLimit.java @@ -46,14 +46,16 @@ public class ExprEditSessionLimit extends SimpleExpression { @Nullable protected Integer[] get(Event e) { EditSession session = editSession.getSingle(e); - if (session == null) return null; + 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 (session == null) return; + if (session == null) + return; if (mode == ChangeMode.SET) { Integer newLimit = (Integer) delta[0]; session.setBlockChangeLimit(Integer.valueOf(newLimit)); @@ -71,4 +73,4 @@ public class ExprEditSessionLimit extends SimpleExpression { } return null; } -} +} \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprHeightOfSchematic.java b/src/me/TheBukor/expressions/ExprHeightOfSchematic.java index c9f06d0..31aadd8 100644 --- a/src/me/TheBukor/expressions/ExprHeightOfSchematic.java +++ b/src/me/TheBukor/expressions/ExprHeightOfSchematic.java @@ -5,24 +5,19 @@ import java.io.IOException; import javax.annotation.Nullable; -import org.bukkit.Bukkit; import org.bukkit.event.Event; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import com.sk89q.worldedit.data.DataException; +import com.sk89q.worldedit.extent.clipboard.Clipboard; 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; -@SuppressWarnings("deprecation") public class ExprHeightOfSchematic extends SimpleExpression { private Expression schematic; - private Expression folder; - @SuppressWarnings("unused") - private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); @Override public Class getReturnType() { @@ -38,25 +33,23 @@ public class ExprHeightOfSchematic extends SimpleExpression { @Override public boolean init(Expression[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) { schematic = (Expression) expr[0]; - folder = (Expression) expr[1]; return true; } @Override 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 @Nullable protected Integer[] get(Event e) { - String f = (folder.getSingle(e) == null) ? "plugins/WorldEdit/schematics/" : folder.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; try { - h = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getHeight(); - } catch (DataException | IOException e1) { + h = ((Clipboard) MCEditSchematicFormat.getFormat(schemFile).load(schemFile)).getRegion().getHeight(); + } catch (DataException | IOException ex) { return null; } return new Integer[] { h }; diff --git a/src/me/TheBukor/expressions/ExprHeightOfSelection.java b/src/me/TheBukor/expressions/ExprHeightOfSelection.java index 541f791..ce38e14 100644 --- a/src/me/TheBukor/expressions/ExprHeightOfSelection.java +++ b/src/me/TheBukor/expressions/ExprHeightOfSelection.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.bukkit.selections.Selection; import javax.annotation.Nullable; @@ -41,11 +42,10 @@ public class ExprHeightOfSelection extends SimpleExpression { @Override @Nullable protected Integer[] get(Event e) { - WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); - if (worldEdit.getSelection(player.getSingle(e)) == null) { + WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); + Selection sel = we.getSelection(player.getSingle(e)); + if (sel == null) return null; - } - return new Integer[] { worldEdit.getSelection(player.getSingle(e)).getHeight() }; + return new Integer[] { sel.getHeight() }; } - -} +} \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprLengthOfSchematic.java b/src/me/TheBukor/expressions/ExprLengthOfSchematic.java index f5485f7..965dbf3 100644 --- a/src/me/TheBukor/expressions/ExprLengthOfSchematic.java +++ b/src/me/TheBukor/expressions/ExprLengthOfSchematic.java @@ -5,24 +5,19 @@ import java.io.IOException; import javax.annotation.Nullable; -import org.bukkit.Bukkit; import org.bukkit.event.Event; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import com.sk89q.worldedit.data.DataException; +import com.sk89q.worldedit.extent.clipboard.Clipboard; 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; -@SuppressWarnings("deprecation") public class ExprLengthOfSchematic extends SimpleExpression { private Expression schematic; - private Expression folder; - @SuppressWarnings("unused") - private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); @Override public Class getReturnType() { @@ -38,25 +33,23 @@ public class ExprLengthOfSchematic extends SimpleExpression { @Override public boolean init(Expression[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) { schematic = (Expression) expr[0]; - folder = (Expression) expr[1]; return true; } @Override 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 @Nullable protected Integer[] get(Event e) { - String f = (folder.getSingle(e) == null) ? "plugins/WorldEdit/schematics/" : folder.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; try { - l = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getLength(); - } catch (DataException | IOException e1) { + l = ((Clipboard) MCEditSchematicFormat.getFormat(schemFile).load(schemFile)).getRegion().getLength(); + } catch (DataException | IOException ex) { return null; } return new Integer[] { l }; diff --git a/src/me/TheBukor/expressions/ExprLengthOfSelection.java b/src/me/TheBukor/expressions/ExprLengthOfSelection.java index 8110a95..b1c34f3 100644 --- a/src/me/TheBukor/expressions/ExprLengthOfSelection.java +++ b/src/me/TheBukor/expressions/ExprLengthOfSelection.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.bukkit.selections.Selection; import javax.annotation.Nullable; @@ -41,11 +42,10 @@ public class ExprLengthOfSelection extends SimpleExpression { @Override @Nullable protected Integer[] get(Event e) { - WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); - if (worldEdit.getSelection(player.getSingle(e)) == null) { + WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); + Selection sel = we.getSelection(player.getSingle(e)); + if (sel == null) return null; - } - return new Integer[] { worldEdit.getSelection(player.getSingle(e)).getLength() }; + return new Integer[] { sel.getLength() }; } - -} +} \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprNewEditSession.java b/src/me/TheBukor/expressions/ExprNewEditSession.java index 504db5c..e38595c 100644 --- a/src/me/TheBukor/expressions/ExprNewEditSession.java +++ b/src/me/TheBukor/expressions/ExprNewEditSession.java @@ -7,7 +7,6 @@ import org.bukkit.World; import org.bukkit.event.Event; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.bukkit.BukkitUtil; 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.util.Kleenean; -@SuppressWarnings("deprecation") public class ExprNewEditSession extends SimpleExpression { private Expression world; private Expression blockLimit; @@ -41,7 +39,7 @@ public class ExprNewEditSession extends SimpleExpression { @Override 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 @@ -50,8 +48,7 @@ public class ExprNewEditSession extends SimpleExpression { WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); World w = world.getSingle(e); Integer limit = blockLimit.getSingle(e); - LocalWorld localWorld = BukkitUtil.getLocalWorld(w); - return new EditSession[] { we.getWorldEdit().getEditSessionFactory().getEditSession(localWorld, limit) }; + com.sk89q.worldedit.world.World weWorld = BukkitUtil.getLocalWorld(w); + return new EditSession[] { we.getWorldEdit().getEditSessionFactory().getEditSession(weWorld, limit) }; } - -} +} \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprSelectionOfPlayer.java b/src/me/TheBukor/expressions/ExprSelectionOfPlayer.java index c4cc177..83b4549 100644 --- a/src/me/TheBukor/expressions/ExprSelectionOfPlayer.java +++ b/src/me/TheBukor/expressions/ExprSelectionOfPlayer.java @@ -9,9 +9,11 @@ import org.bukkit.event.Event; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.bukkit.BukkitUtil; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.world.World; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; @@ -44,14 +46,13 @@ public class ExprSelectionOfPlayer extends SimpleExpression { return "the WorldEdit selection of " + player.toString(e, false); } - @SuppressWarnings("deprecation") @Override @Nullable protected Location[] get(Event e) { Player p = player.getSingle(e); Region region = null; try { - region = we.getSession(p).getRegion(); + region = we.getSession(p).getSelection((World) BukkitUtil.getLocalWorld(we.getSelection(p).getWorld())); } catch (IncompleteRegionException ex) { return null; } @@ -93,4 +94,4 @@ public class ExprSelectionOfPlayer extends SimpleExpression { return null; } */ -} +} \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprSelectionPos1.java b/src/me/TheBukor/expressions/ExprSelectionPos1.java index 8f1b878..9f5a8de 100644 --- a/src/me/TheBukor/expressions/ExprSelectionPos1.java +++ b/src/me/TheBukor/expressions/ExprSelectionPos1.java @@ -9,9 +9,11 @@ import org.bukkit.event.Event; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.bukkit.BukkitUtil; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.world.World; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; @@ -44,19 +46,18 @@ public class ExprSelectionPos1 extends SimpleExpression { return "the WorldEdit point 1 selection of " + player.toString(e, false); } - @SuppressWarnings("deprecation") @Override @Nullable protected Location[] get(Event e) { Player p = player.getSingle(e); Region region = null; try { - region = we.getSession(p).getRegion(); + region = we.getSession(p).getSelection((World) BukkitUtil.getLocalWorld(we.getSelection(p).getWorld())); } catch (IncompleteRegionException ex) { return null; } if (!(region instanceof CuboidRegion)) { - return null; + return null; //Who uses polygonal and other selection types anyways? } CuboidRegion cuboid = (CuboidRegion) region; Vector pos = cuboid.getPos1(); diff --git a/src/me/TheBukor/expressions/ExprSelectionPos2.java b/src/me/TheBukor/expressions/ExprSelectionPos2.java index a04126d..0291aac 100644 --- a/src/me/TheBukor/expressions/ExprSelectionPos2.java +++ b/src/me/TheBukor/expressions/ExprSelectionPos2.java @@ -9,9 +9,11 @@ import org.bukkit.event.Event; import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.bukkit.BukkitUtil; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.Region; +import com.sk89q.worldedit.world.World; import ch.njol.skript.lang.Expression; import ch.njol.skript.lang.SkriptParser.ParseResult; @@ -44,19 +46,18 @@ public class ExprSelectionPos2 extends SimpleExpression { return "the WorldEdit point 2 selection of " + player.toString(e, false); } - @SuppressWarnings("deprecation") @Override @Nullable protected Location[] get(Event e) { Player p = player.getSingle(e); Region region = null; try { - region = we.getSession(p).getRegion(); + region = we.getSession(p).getSelection((World) BukkitUtil.getLocalWorld(we.getSelection(p).getWorld())); } catch (IncompleteRegionException ex) { return null; } if (!(region instanceof CuboidRegion)) { - return null; + return null; //Who uses polygonal and other selection types anyways? } CuboidRegion cuboid = (CuboidRegion) region; Vector pos = cuboid.getPos2(); diff --git a/src/me/TheBukor/expressions/ExprVolumeOfSchematic.java b/src/me/TheBukor/expressions/ExprVolumeOfSchematic.java index dc1548e..865feca 100644 --- a/src/me/TheBukor/expressions/ExprVolumeOfSchematic.java +++ b/src/me/TheBukor/expressions/ExprVolumeOfSchematic.java @@ -5,24 +5,19 @@ import java.io.IOException; import javax.annotation.Nullable; -import org.bukkit.Bukkit; import org.bukkit.event.Event; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import com.sk89q.worldedit.data.DataException; +import com.sk89q.worldedit.extent.clipboard.Clipboard; 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; -@SuppressWarnings("deprecation") public class ExprVolumeOfSchematic extends SimpleExpression { private Expression schematic; - private Expression folder; - @SuppressWarnings("unused") - private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); @Override public Class getReturnType() { @@ -38,39 +33,25 @@ public class ExprVolumeOfSchematic extends SimpleExpression { @Override public boolean init(Expression[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) { schematic = (Expression) expr[0]; - folder = (Expression) expr[1]; return true; } @Override 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 @Nullable protected Integer[] get(Event e) { - String f = (folder.getSingle(e) == null) ? "plugins/WorldEdit/schematics/" : folder.getSingle(e); String schem = schematic.getSingle(e); - File schemFile = new File((f.endsWith("/")) ? f : (f + "/") + (schem.endsWith(".schematic") ? schem : (schem + ".schematic"))); - Integer w = 0; - Integer h = 0; - Integer l = 0; + File schemFile = new File((schem.endsWith(".schematic") ? schem : (schem + ".schematic"))); + Integer v = null; try { - w = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getWidth(); - } catch (DataException | IOException e1) { + v = ((Clipboard) MCEditSchematicFormat.getFormat(schemFile).load(schemFile)).getRegion().getArea(); + } catch (DataException | IOException ex) { return null; } - try { - 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 }; + return new Integer[] { v }; } } \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprVolumeOfSelection.java b/src/me/TheBukor/expressions/ExprVolumeOfSelection.java index 92fbd91..47137d2 100644 --- a/src/me/TheBukor/expressions/ExprVolumeOfSelection.java +++ b/src/me/TheBukor/expressions/ExprVolumeOfSelection.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.bukkit.selections.Selection; import javax.annotation.Nullable; @@ -35,17 +36,16 @@ public class ExprVolumeOfSelection extends SimpleExpression { @Override 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 @Nullable protected Integer[] get(Event e) { - WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); - if (worldEdit.getSelection(player.getSingle(e)) == null) { + WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); + Selection sel = we.getSelection(player.getSingle(e)); + if (sel == null) return null; - } - return new Integer[] { worldEdit.getSelection(player.getSingle(e)).getArea() }; + return new Integer[] { sel.getArea() }; } - -} +} \ No newline at end of file diff --git a/src/me/TheBukor/expressions/ExprWidthOfSchematic.java b/src/me/TheBukor/expressions/ExprWidthOfSchematic.java index 4f405f8..1a5d0e4 100644 --- a/src/me/TheBukor/expressions/ExprWidthOfSchematic.java +++ b/src/me/TheBukor/expressions/ExprWidthOfSchematic.java @@ -5,24 +5,19 @@ import java.io.IOException; import javax.annotation.Nullable; -import org.bukkit.Bukkit; import org.bukkit.event.Event; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; -import com.sk89q.worldedit.data.DataException; +import com.sk89q.worldedit.extent.clipboard.Clipboard; 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; -@SuppressWarnings("deprecation") public class ExprWidthOfSchematic extends SimpleExpression { private Expression schematic; - private Expression folder; - @SuppressWarnings("unused") - private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); @Override public Class getReturnType() { @@ -38,25 +33,23 @@ public class ExprWidthOfSchematic extends SimpleExpression { @Override public boolean init(Expression[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) { schematic = (Expression) expr[0]; - folder = (Expression) expr[1]; return true; } @Override 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 @Nullable protected Integer[] get(Event e) { - String f = (folder.getSingle(e) == null) ? "plugins/WorldEdit/schematics/" : folder.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; try { - w = MCEditSchematicFormat.getFormat(schemFile).load(schemFile).getWidth(); - } catch (DataException | IOException e1) { + w = ((Clipboard) MCEditSchematicFormat.getFormat(schemFile).load(schemFile)).getRegion().getWidth(); + } catch (DataException | IOException ex) { return null; } return new Integer[] { w }; diff --git a/src/me/TheBukor/expressions/ExprWidthOfSelection.java b/src/me/TheBukor/expressions/ExprWidthOfSelection.java index ca2a1f7..7a73ffa 100644 --- a/src/me/TheBukor/expressions/ExprWidthOfSelection.java +++ b/src/me/TheBukor/expressions/ExprWidthOfSelection.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.bukkit.selections.Selection; import javax.annotation.Nullable; @@ -41,11 +42,10 @@ public class ExprWidthOfSelection extends SimpleExpression { @Override @Nullable protected Integer[] get(Event e) { - WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); - if (worldEdit.getSelection(player.getSingle(e)) == null) { + WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); + Selection sel = we.getSelection(player.getSingle(e)); + if (sel == null) return null; - } - return new Integer[] { worldEdit.getSelection(player.getSingle(e)).getWidth() }; + return new Integer[] { sel.getWidth() }; } - -} +} \ No newline at end of file