New effects, selection positions now settable, selection now clearable.
This commit is contained in:
parent
dae953dc85
commit
653b66e30e
@ -18,10 +18,14 @@ import ch.njol.skript.registrations.Classes;
|
|||||||
import me.TheBukor.conditions.CondSelectionContains;
|
import me.TheBukor.conditions.CondSelectionContains;
|
||||||
import me.TheBukor.effects.EffDrainLiquid;
|
import me.TheBukor.effects.EffDrainLiquid;
|
||||||
import me.TheBukor.effects.EffDrawLineWE;
|
import me.TheBukor.effects.EffDrawLineWE;
|
||||||
|
import me.TheBukor.effects.EffMakeCylinder;
|
||||||
import me.TheBukor.effects.EffMakePyramid;
|
import me.TheBukor.effects.EffMakePyramid;
|
||||||
import me.TheBukor.effects.EffMakeSphere;
|
import me.TheBukor.effects.EffMakeSphere;
|
||||||
|
import me.TheBukor.effects.EffMakeWalls;
|
||||||
import me.TheBukor.effects.EffNaturalize;
|
import me.TheBukor.effects.EffNaturalize;
|
||||||
import me.TheBukor.effects.EffRememberChanges;
|
import me.TheBukor.effects.EffRememberChanges;
|
||||||
|
import me.TheBukor.effects.EffReplaceBlocksWE;
|
||||||
|
import me.TheBukor.effects.EffSetBlocksWE;
|
||||||
import me.TheBukor.effects.EffSimulateSnow;
|
import me.TheBukor.effects.EffSimulateSnow;
|
||||||
import me.TheBukor.effects.EffUndoRedoSession;
|
import me.TheBukor.effects.EffUndoRedoSession;
|
||||||
import me.TheBukor.expressions.ExprAreaOfSchematic;
|
import me.TheBukor.expressions.ExprAreaOfSchematic;
|
||||||
@ -381,18 +385,22 @@ public class SkStuff extends JavaPlugin {
|
|||||||
if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
|
if (Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
|
||||||
getLogger().info("WorldEdit found! Registering WorldEdit stuff...");
|
getLogger().info("WorldEdit found! Registering WorldEdit stuff...");
|
||||||
condAmount += 1;
|
condAmount += 1;
|
||||||
effAmount += 8;
|
effAmount += 12;
|
||||||
exprAmount += 16;
|
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%");
|
||||||
Skript.registerEffect(EffDrawLineWE.class, "(create|draw|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% [with] thick[ness] %double%");
|
Skript.registerEffect(EffDrawLineWE.class, "(create|draw|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks% [with] thick[ness] %double%");
|
||||||
Skript.registerEffect(EffUndoRedoSession.class, "(0¦undo|1¦redo) (change|edit)s (of|from) [edit[ ]session] %editsession%");
|
Skript.registerEffect(EffUndoRedoSession.class, "(0¦undo|1¦redo) (change|edit)s (of|from) [edit[ ]session] %editsession%");
|
||||||
Skript.registerEffect(EffRememberChanges.class, "make %player% (remember|be able to undo) changes (of|from) [edit[ ]session] %editsession%");
|
Skript.registerEffect(EffRememberChanges.class, "make %player% (remember|be able to undo) changes (of|from) [edit[ ]session] %editsession%");
|
||||||
Skript.registerEffect(EffMakeSphere.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) (ellipsoid|sphere) [centered] at %location% [with] radius [of] %double%, %double%(,| and) %double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
Skript.registerEffect(EffMakeSphere.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) (ellipsoid|sphere) [centered] at %location% [with] radius [of] %double%,[ ]%double%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
||||||
Skript.registerEffect(EffSimulateSnow.class, "(simulate snow at|place snow over) %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%", "make %location% snowy (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
|
Skript.registerEffect(EffSimulateSnow.class, "(simulate snow at|place snow over) %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%", "make %location% snowy (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
|
||||||
Skript.registerEffect(EffMakePyramid.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) pyramid at %location% [with] radius [of] %integer% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
Skript.registerEffect(EffMakePyramid.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) pyramid at %location% [with] radius [of] %integer% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
||||||
Skript.registerEffect(EffDrainLiquid.class, "(drain|remove) [all] liquid[s] at %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
|
Skript.registerEffect(EffDrainLiquid.class, "(drain|remove) [all] liquid[s] at %location% (in|within) [a] radius [of] %double% (using|with) [edit[ ]session] %editsession%");
|
||||||
Skript.registerEffect(EffNaturalize.class, "naturalize ([cuboid] region|[all] blocks) (from|between) %location% (to|and) %location% (using|with) [edit[ ]session] %editsession%");
|
Skript.registerEffect(EffNaturalize.class, "naturalize ([cuboid] region|[all] blocks) (from|between) %location% (to|and) %location% (using|with) [edit[ ]session] %editsession%");
|
||||||
|
Skript.registerEffect(EffMakeWalls.class, "(create|make) wall[s] from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
||||||
|
Skript.registerEffect(EffSetBlocksWE.class, "set [all] blocks (from|between) %location% (to|and) %location% to %itemstacks% (using|with) [edit[ ]session] %editsession%");
|
||||||
|
Skript.registerEffect(EffMakeCylinder.class, "(create|make) [a[n]] (0¦(no(n|t)(-| )hollow|filled|)|1¦hollow) cylinder at %location% [with] radius [of] %double%,[ ]%integer%(,[ ]| and )%double% (using|with) [edit[ ]session] %editsession% (using|with) [block[s]] %itemstacks%");
|
||||||
|
Skript.registerEffect(EffReplaceBlocksWE.class, "replace [all] %itemstacks% (from|between) %location% (to|and) %location% with %itemstacks% (using|with) [edit[ ]session] %editsession%");
|
||||||
Skript.registerExpression(ExprEditSessionLimit.class, Integer.class, ExpressionType.PROPERTY, "[block] limit [change] of [edit[ ]session] %editsession%");
|
Skript.registerExpression(ExprEditSessionLimit.class, Integer.class, ExpressionType.PROPERTY, "[block] limit [change] of [edit[ ]session] %editsession%");
|
||||||
Skript.registerExpression(ExprChangedBlocksSession.class, Integer.class, ExpressionType.PROPERTY, "number of [all] changed blocks (in|of) [edit[ ]session] %editsession%");
|
Skript.registerExpression(ExprChangedBlocksSession.class, Integer.class, ExpressionType.PROPERTY, "number of [all] changed blocks (in|of) [edit[ ]session] %editsession%");
|
||||||
Skript.registerExpression(ExprNewEditSession.class, EditSession.class, ExpressionType.PROPERTY, "new edit[ ]session in [world] %world% [with] [max[imum]] [block] limit [change] [of] %integer%");
|
Skript.registerExpression(ExprNewEditSession.class, EditSession.class, ExpressionType.PROPERTY, "new edit[ ]session in [world] %world% [with] [max[imum]] [block] limit [change] [of] %integer%");
|
||||||
|
75
src/me/TheBukor/effects/EffMakeCylinder.java
Normal file
75
src/me/TheBukor/effects/EffMakeCylinder.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
package me.TheBukor.effects;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||||
|
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||||
|
|
||||||
|
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 EffMakeCylinder extends Effect {
|
||||||
|
private Expression<Location> location;
|
||||||
|
private Expression<Double> radius1;
|
||||||
|
private Expression<Double> radius2;
|
||||||
|
private Expression<Integer> height;
|
||||||
|
private Expression<EditSession> editSession;
|
||||||
|
private Expression<ItemStack> blockList;
|
||||||
|
private boolean filled = true;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
|
||||||
|
location = (Expression<Location>) expr[0];
|
||||||
|
radius1 = (Expression<Double>) expr[1];
|
||||||
|
height = (Expression<Integer>) expr[2];
|
||||||
|
radius2 = (Expression<Double>) expr[3];
|
||||||
|
editSession = (Expression<EditSession>) expr[4];
|
||||||
|
blockList = (Expression<ItemStack>) expr[5];
|
||||||
|
if (result.mark == 1) filled = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
|
return "create a cylinder at " + location.toString(e, false) + " with a radius of " + radius1.toString(e, false) + " " + height.toString(e, false) + " " + radius2.toString(e, false) + " using an edit session with " + blockList.toString(e, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
protected void execute(Event e) {
|
||||||
|
Location loc = location.getSingle(e);
|
||||||
|
Double rad1 = radius1.getSingle(e);
|
||||||
|
Integer h = height.getSingle(e);
|
||||||
|
Double rad2 = radius2.getSingle(e);
|
||||||
|
EditSession session = editSession.getSingle(e);
|
||||||
|
ItemStack[] blocks = blockList.getAll(e);
|
||||||
|
RandomPattern random = new RandomPattern();
|
||||||
|
if (session == null) return;
|
||||||
|
for (ItemStack b : blocks) {
|
||||||
|
if (b.getType().isBlock()) {
|
||||||
|
random.add(new BlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
session.makeCylinder(BukkitUtil.toVector(loc), Patterns.wrap(random), rad1, rad2, h, filled);
|
||||||
|
session.flushQueue();
|
||||||
|
} catch (WorldEditException ex) {
|
||||||
|
if (ex instanceof MaxChangedBlocksException)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
69
src/me/TheBukor/effects/EffMakeWalls.java
Normal file
69
src/me/TheBukor/effects/EffMakeWalls.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package me.TheBukor.effects;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||||
|
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
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 EffMakeWalls extends Effect {
|
||||||
|
private Expression<Location> location1;
|
||||||
|
private Expression<Location> location2;
|
||||||
|
private Expression<EditSession> editSession;
|
||||||
|
private Expression<ItemStack> blockList;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
|
||||||
|
location1 = (Expression<Location>) expr[0];
|
||||||
|
location2 = (Expression<Location>) expr[1];
|
||||||
|
editSession = (Expression<EditSession>) expr[2];
|
||||||
|
blockList = (Expression<ItemStack>) expr[3];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
|
return "make walls from " + location1.toString(e, false) + " to " + location2.toString(e, false) + " using an edit session with " + blockList.toString(e, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
protected void execute(Event e) {
|
||||||
|
Location pos1 = location1.getSingle(e);
|
||||||
|
Location pos2 = location2.getSingle(e);
|
||||||
|
EditSession session = editSession.getSingle(e);
|
||||||
|
ItemStack[] blocks = blockList.getAll(e);
|
||||||
|
RandomPattern random = new RandomPattern();
|
||||||
|
if (session == null) return;
|
||||||
|
for (ItemStack b : blocks) {
|
||||||
|
if (b.getType().isBlock()) {
|
||||||
|
random.add(new BlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
session.makeWalls(new CuboidRegion((World) BukkitUtil.getLocalWorld(pos1.getWorld()), BukkitUtil.toVector(pos1), BukkitUtil.toVector(pos2)), Patterns.wrap(random));
|
||||||
|
session.flushQueue();
|
||||||
|
} catch (WorldEditException ex) {
|
||||||
|
if (ex instanceof MaxChangedBlocksException)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
src/me/TheBukor/effects/EffReplaceBlocksWE.java
Normal file
81
src/me/TheBukor/effects/EffReplaceBlocksWE.java
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
package me.TheBukor.effects;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||||
|
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
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 EffReplaceBlocksWE extends Effect {
|
||||||
|
private Expression<ItemStack> blockList1;
|
||||||
|
private Expression<Location> location1;
|
||||||
|
private Expression<Location> location2;
|
||||||
|
private Expression<ItemStack> blockList2;
|
||||||
|
private Expression<EditSession> editSession;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
|
||||||
|
blockList1 = (Expression<ItemStack>) expr[0];
|
||||||
|
location1 = (Expression<Location>) expr[1];
|
||||||
|
location2 = (Expression<Location>) expr[2];
|
||||||
|
blockList2 = (Expression<ItemStack>) expr[3];
|
||||||
|
editSession = (Expression<EditSession>) expr[4];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
|
return "replace all " + blockList1.toString(e, false) + " from " + location1.toString(e, false) + " to " + location2.toString(e, false) + " with " + blockList1.toString(e, false) + " using an edit session";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "deprecation" })
|
||||||
|
@Override
|
||||||
|
protected void execute(Event e) {
|
||||||
|
Location pos1 = location1.getSingle(e);
|
||||||
|
Location pos2 = location2.getSingle(e);
|
||||||
|
EditSession session = editSession.getSingle(e);
|
||||||
|
ItemStack[] blocks = blockList1.getAll(e);
|
||||||
|
ItemStack[] blocksToPlace = blockList2.getAll(e);
|
||||||
|
RandomPattern random = new RandomPattern();
|
||||||
|
Set<BaseBlock> blocksToReplace = new HashSet<BaseBlock>();
|
||||||
|
if (session == null) return;
|
||||||
|
for (ItemStack b : blocks) {
|
||||||
|
if (b.getType().isBlock()) {
|
||||||
|
blocksToReplace.add(new BaseBlock(b.getTypeId(), b.getDurability()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (ItemStack b : blocksToPlace) {
|
||||||
|
if (b.getType().isBlock()) {
|
||||||
|
random.add(new BlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
session.replaceBlocks(new CuboidRegion((World) BukkitUtil.getLocalWorld(pos1.getWorld()), BukkitUtil.toVector(pos1), BukkitUtil.toVector(pos2)), blocksToReplace, Patterns.wrap(random));
|
||||||
|
session.flushQueue();
|
||||||
|
} catch (WorldEditException ex) {
|
||||||
|
if (ex instanceof MaxChangedBlocksException)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
69
src/me/TheBukor/effects/EffSetBlocksWE.java
Normal file
69
src/me/TheBukor/effects/EffSetBlocksWE.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package me.TheBukor.effects;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
||||||
|
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||||
|
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
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 EffSetBlocksWE extends Effect {
|
||||||
|
private Expression<Location> location1;
|
||||||
|
private Expression<Location> location2;
|
||||||
|
private Expression<ItemStack> blockList;
|
||||||
|
private Expression<EditSession> editSession;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
|
||||||
|
location1 = (Expression<Location>) expr[0];
|
||||||
|
location2 = (Expression<Location>) expr[1];
|
||||||
|
blockList = (Expression<ItemStack>) expr[2];
|
||||||
|
editSession = (Expression<EditSession>) expr[3];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean arg1) {
|
||||||
|
return "set all blocks from " + location1.toString(e, false) + " to " + location2.toString(e, false) + " to " + blockList.toString(e, false) + " using an edit session";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
protected void execute(Event e) {
|
||||||
|
Location pos1 = location1.getSingle(e);
|
||||||
|
Location pos2 = location2.getSingle(e);
|
||||||
|
EditSession session = editSession.getSingle(e);
|
||||||
|
ItemStack[] blocks = blockList.getAll(e);
|
||||||
|
RandomPattern random = new RandomPattern();
|
||||||
|
if (session == null) return;
|
||||||
|
for (ItemStack b : blocks) {
|
||||||
|
if (b.getType().isBlock()) {
|
||||||
|
random.add(new BlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
session.setBlocks(new CuboidRegion((World) BukkitUtil.getLocalWorld(pos1.getWorld()), BukkitUtil.toVector(pos1), BukkitUtil.toVector(pos2)), Patterns.wrap(random));
|
||||||
|
session.flushQueue();
|
||||||
|
} catch (WorldEditException ex) {
|
||||||
|
if (ex instanceof MaxChangedBlocksException)
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,10 +15,12 @@ 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 com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import ch.njol.skript.classes.Changer.ChangeMode;
|
||||||
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;
|
||||||
|
import ch.njol.util.coll.CollectionUtils;
|
||||||
|
|
||||||
public class ExprSelectionOfPlayer extends SimpleExpression<Location> {
|
public class ExprSelectionOfPlayer extends SimpleExpression<Location> {
|
||||||
private Expression<Player> player;
|
private Expression<Player> player;
|
||||||
@ -66,21 +68,13 @@ public class ExprSelectionOfPlayer extends SimpleExpression<Location> {
|
|||||||
Location pos2 = new Location(we.getSelection(p).getWorld(), pos2Vec.getX(), pos2Vec.getY(), pos2Vec.getZ());
|
Location pos2 = new Location(we.getSelection(p).getWorld(), pos2Vec.getX(), pos2Vec.getY(), pos2Vec.getZ());
|
||||||
return new Location[] { pos1, pos2 };
|
return new Location[] { pos1, pos2 };
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
||||||
Player p = player.getSingle(e);
|
Player p = player.getSingle(e);
|
||||||
Object[] objs = getSource().getAll(e);
|
if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
|
||||||
for (int i = 0; i < objs.length; i++) {
|
if (we.getSelection(p) == null)
|
||||||
if (i > 0) {
|
return;
|
||||||
Bukkit.broadcastMessage("WOT M8!! GREATER THAN 1!!");
|
we.getSession(p).getRegionSelector((World) BukkitUtil.getLocalWorld(we.getSelection(p).getWorld())).clear();
|
||||||
Bukkit.broadcastMessage(objs[i].toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mode == ChangeMode.SET) {
|
|
||||||
we.setSelection(p, new CuboidSelection(((Location) objs[0]).getWorld(), (Location) objs[0], (Location) objs[1]));
|
|
||||||
} else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
|
|
||||||
we.setSelection(p, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,10 +82,9 @@ public class ExprSelectionOfPlayer extends SimpleExpression<Location> {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Class<?>[] acceptChange(ChangeMode mode) {
|
public Class<?>[] acceptChange(ChangeMode mode) {
|
||||||
if (mode == ChangeMode.SET || mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
|
if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
|
||||||
return CollectionUtils.array(Location.class);
|
return CollectionUtils.array(Location.class);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
@ -13,12 +13,15 @@ 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.regions.selector.CuboidRegionSelector;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import ch.njol.skript.classes.Changer.ChangeMode;
|
||||||
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;
|
||||||
|
import ch.njol.util.coll.CollectionUtils;
|
||||||
|
|
||||||
public class ExprSelectionPos1 extends SimpleExpression<Location> {
|
public class ExprSelectionPos1 extends SimpleExpression<Location> {
|
||||||
private Expression<Player> player;
|
private Expression<Player> player;
|
||||||
@ -56,11 +59,39 @@ public class ExprSelectionPos1 extends SimpleExpression<Location> {
|
|||||||
} catch (IncompleteRegionException ex) {
|
} catch (IncompleteRegionException ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!(region instanceof CuboidRegion)) {
|
if (!(region instanceof CuboidRegion))
|
||||||
return null; //Who uses polygonal and other selection types anyways?
|
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();
|
||||||
return new Location[] { new Location(we.getSelection(p).getWorld(), pos.getX(), pos.getY(), pos.getZ()) };
|
return new Location[] { BukkitUtil.toLocation(we.getSelection(p).getWorld(), pos) };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
||||||
|
Player p = player.getSingle(e);
|
||||||
|
Location newLoc = (Location) delta[0];
|
||||||
|
if (mode == ChangeMode.SET) {
|
||||||
|
Region region = null;
|
||||||
|
try {
|
||||||
|
region = we.getSession(p).getSelection((World) BukkitUtil.getLocalWorld(we.getSelection(p).getWorld()));
|
||||||
|
} catch (IncompleteRegionException | NullPointerException ex) {
|
||||||
|
CuboidRegionSelector cuboidregion = new CuboidRegionSelector(BukkitUtil.getLocalWorld((org.bukkit.World) newLoc.getWorld()), BukkitUtil.toVector(newLoc), BukkitUtil.toVector(newLoc));
|
||||||
|
we.getSession(p).setRegionSelector((World) BukkitUtil.getLocalWorld(p.getWorld()), cuboidregion);
|
||||||
|
}
|
||||||
|
if (!(region instanceof CuboidRegion))
|
||||||
|
return; //Who uses polygonal and other selection types anyways?
|
||||||
|
CuboidRegion cuboid = (CuboidRegion) region;
|
||||||
|
cuboid.setPos1(BukkitUtil.toVector(newLoc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public Class<?>[] acceptChange(ChangeMode mode) {
|
||||||
|
if (mode == ChangeMode.SET) {
|
||||||
|
return CollectionUtils.array(Location.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,12 +13,15 @@ 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.regions.selector.CuboidRegionSelector;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
|
import ch.njol.skript.classes.Changer.ChangeMode;
|
||||||
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;
|
||||||
|
import ch.njol.util.coll.CollectionUtils;
|
||||||
|
|
||||||
public class ExprSelectionPos2 extends SimpleExpression<Location> {
|
public class ExprSelectionPos2 extends SimpleExpression<Location> {
|
||||||
private Expression<Player> player;
|
private Expression<Player> player;
|
||||||
@ -56,11 +59,39 @@ public class ExprSelectionPos2 extends SimpleExpression<Location> {
|
|||||||
} catch (IncompleteRegionException ex) {
|
} catch (IncompleteRegionException ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!(region instanceof CuboidRegion)) {
|
if (!(region instanceof CuboidRegion))
|
||||||
return null; //Who uses polygonal and other selection types anyways?
|
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();
|
||||||
return new Location[] { new Location(we.getSelection(p).getWorld(), pos.getX(), pos.getY(), pos.getZ()) };
|
return new Location[] { BukkitUtil.toLocation(we.getSelection(p).getWorld(), pos) };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
||||||
|
Player p = player.getSingle(e);
|
||||||
|
Location newLoc = (Location) delta[0];
|
||||||
|
if (mode == ChangeMode.SET) {
|
||||||
|
Region region = null;
|
||||||
|
try {
|
||||||
|
region = we.getSession(p).getSelection((World) BukkitUtil.getLocalWorld(we.getSelection(p).getWorld()));
|
||||||
|
} catch (IncompleteRegionException | NullPointerException ex) {
|
||||||
|
CuboidRegionSelector cuboidregion = new CuboidRegionSelector(BukkitUtil.getLocalWorld((org.bukkit.World) newLoc.getWorld()), BukkitUtil.toVector(newLoc), BukkitUtil.toVector(newLoc));
|
||||||
|
we.getSession(p).setRegionSelector((World) BukkitUtil.getLocalWorld(p.getWorld()), cuboidregion);
|
||||||
|
}
|
||||||
|
if (!(region instanceof CuboidRegion))
|
||||||
|
return; //Who uses polygonal and other selection types anyways?
|
||||||
|
CuboidRegion cuboid = (CuboidRegion) region;
|
||||||
|
cuboid.setPos2(BukkitUtil.toVector(newLoc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public Class<?>[] acceptChange(ChangeMode mode) {
|
||||||
|
if (mode == ChangeMode.SET) {
|
||||||
|
return CollectionUtils.array(Location.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user