Lots of stuff yet only one new expression added. Should work with Java 7
This commit is contained in:
parent
91fdd40d19
commit
dd5d7ea91a
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<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/plugins/Skript.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Rubi/AppData/Roaming/.minecraft/workspace/Spigot 1.8, 1.8.3/1.8.3.jar"/>
|
||||
|
@ -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
|
||||
|
@ -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>(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)")){
|
||||
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>(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)")) {
|
||||
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>(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...");
|
||||
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>(EditSession.class, "editsession").name("Edit Session").parser(new Parser<EditSession>() {
|
||||
|
||||
@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.");
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
58
src/me/TheBukor/expressions/ExprAreaOfSchematic.java
Normal file
58
src/me/TheBukor/expressions/ExprAreaOfSchematic.java
Normal 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() };
|
||||
}
|
||||
}
|
@ -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<Integer> {
|
||||
@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() };
|
||||
}
|
||||
|
||||
}
|
@ -39,7 +39,8 @@ public class ExprChangedBlocksSession extends SimpleExpression<Integer> {
|
||||
@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() };
|
||||
}
|
||||
}
|
@ -46,14 +46,16 @@ public class ExprEditSessionLimit extends SimpleExpression<Integer> {
|
||||
@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));
|
||||
|
@ -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<Integer> {
|
||||
private Expression<String> schematic;
|
||||
private Expression<String> folder;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
|
||||
@Override
|
||||
public Class<? extends Integer> getReturnType() {
|
||||
@ -38,25 +33,23 @@ public class ExprHeightOfSchematic extends SimpleExpression<Integer> {
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||
schematic = (Expression<String>) expr[0];
|
||||
folder = (Expression<String>) 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 };
|
||||
|
@ -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<Integer> {
|
||||
@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() };
|
||||
}
|
||||
|
||||
}
|
@ -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<Integer> {
|
||||
private Expression<String> schematic;
|
||||
private Expression<String> folder;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
|
||||
@Override
|
||||
public Class<? extends Integer> getReturnType() {
|
||||
@ -38,25 +33,23 @@ public class ExprLengthOfSchematic extends SimpleExpression<Integer> {
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||
schematic = (Expression<String>) expr[0];
|
||||
folder = (Expression<String>) 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 };
|
||||
|
@ -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<Integer> {
|
||||
@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() };
|
||||
}
|
||||
|
||||
}
|
@ -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<EditSession> {
|
||||
private Expression<World> world;
|
||||
private Expression<Integer> blockLimit;
|
||||
@ -41,7 +39,7 @@ public class ExprNewEditSession extends SimpleExpression<EditSession> {
|
||||
|
||||
@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<EditSession> {
|
||||
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) };
|
||||
}
|
||||
|
||||
}
|
@ -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<Location> {
|
||||
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;
|
||||
}
|
||||
|
@ -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<Location> {
|
||||
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();
|
||||
|
@ -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<Location> {
|
||||
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();
|
||||
|
@ -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<Integer> {
|
||||
private Expression<String> schematic;
|
||||
private Expression<String> folder;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
|
||||
@Override
|
||||
public Class<? extends Integer> getReturnType() {
|
||||
@ -38,39 +33,25 @@ public class ExprVolumeOfSchematic extends SimpleExpression<Integer> {
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||
schematic = (Expression<String>) expr[0];
|
||||
folder = (Expression<String>) 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 };
|
||||
}
|
||||
}
|
@ -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<Integer> {
|
||||
|
||||
@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() };
|
||||
}
|
||||
|
||||
}
|
@ -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<Integer> {
|
||||
private Expression<String> schematic;
|
||||
private Expression<String> folder;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
|
||||
@Override
|
||||
public Class<? extends Integer> getReturnType() {
|
||||
@ -38,25 +33,23 @@ public class ExprWidthOfSchematic extends SimpleExpression<Integer> {
|
||||
@Override
|
||||
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
|
||||
schematic = (Expression<String>) expr[0];
|
||||
folder = (Expression<String>) 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 };
|
||||
|
@ -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<Integer> {
|
||||
@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() };
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user