Ready for release of new version!... I hope.

This commit is contained in:
Richard 2015-11-29 17:36:14 -02:00
parent ced2a2648d
commit 34b05e4e2d
5 changed files with 25 additions and 22 deletions

View File

@ -1,6 +1,6 @@
name: SkStuff
author: TheBukor
description: A Skript addon which adds extra functionalities such as NBT and extended WorldEdit support.
version: 1.2.2
version: 1.2.3
main: me.TheBukor.SkStuff
softdepend: [Skript]

View File

@ -20,7 +20,6 @@ import me.TheBukor.effects.EffDrawLineWE;
import me.TheBukor.effects.EffUndoRedoSession;
import me.TheBukor.expressions.ExprAreaOfSelection;
import me.TheBukor.expressions.ExprChangedBlocksSession;
import me.TheBukor.expressions.ExprEditSession;
import me.TheBukor.expressions.ExprEditSessionLimit;
import me.TheBukor.expressions.ExprHeightOfSchematic;
import me.TheBukor.expressions.ExprHeightOfSelection;
@ -32,6 +31,7 @@ import me.TheBukor.expressions.ExprLengthOfSelection;
import me.TheBukor.expressions.ExprNBTv1_8_R1;
import me.TheBukor.expressions.ExprNBTv1_8_R2;
import me.TheBukor.expressions.ExprNBTv1_8_R3;
import me.TheBukor.expressions.ExprNewEditSession;
import me.TheBukor.expressions.ExprSelectionOfPlayer;
import me.TheBukor.expressions.ExprSelectionPos1;
import me.TheBukor.expressions.ExprSelectionPos2;
@ -182,11 +182,11 @@ public class SkStuff extends JavaPlugin {
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
Skript.registerEffect(EffDrawLineWE.class, "(create|draw|make) [a] (no(n|t)(-| )hollow|filled) line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block] %itemstack% [[(and|with)] thick[ness] %-double%]", "(create|draw|make) [a] hollow line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block] %itemstack% [[(and|with)] thick[ness] %-double%]");
Skript.registerEffect(EffDrawLineWE.class, "(create|draw|make) [a] (no(n|t)(-| )hollow|filled) line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block] %itemstack% [(and|with)] thick[ness] %double%", "(create|draw|make) [a] hollow line from %location% to %location% (using|with) [edit[ ]session] %editsession% (using|with) [block] %itemstack% [(and|with)] thick[ness] %double%");
Skript.registerEffect(EffUndoRedoSession.class, "undo [last] (change|edit)[s] (of|from) [edit[ ]session] %editsession%", "redo [last] (change|edit)[s] (of|from) [edit[ ]session] %editsession%");
Skript.registerExpression(ExprEditSessionLimit.class, Integer.class, ExpressionType.PROPERTY, "[block] limit [change] of [edit[ ]session] %editsession%");
Skript.registerExpression(ExprChangedBlocksSession.class, Integer.class, ExpressionType.PROPERTY, "number of [all] changed blocks (in|of) [edit[ ]session] %editsession%");
Skript.registerExpression(ExprEditSession.class, EditSession.class, ExpressionType.PROPERTY, "[new] edit[ ]session (for|from|of) %player%", "[new] %player% edit[ ]session");
Skript.registerExpression(ExprNewEditSession.class, EditSession.class, ExpressionType.PROPERTY, "[create] [a] new edit[ ]session in [world] %world% [with] [max[imum]] [block] limit [change] [of] %integer%");
// END OF EXPERIMENTAL EFFS/EXPRS
Skript.registerExpression(ExprSelectionOfPlayer.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] selection of %player%", "%player%'s [(world[ ]edit|we)] selection");
Skript.registerExpression(ExprSelectionPos1.class, Location.class, ExpressionType.PROPERTY, "[(world[ ]edit|we)] po(s|int)[ ]1 of %player%", "%player%'s [(world[ ]edit|we)] po(s|int)[ ]1");

View File

@ -40,7 +40,7 @@ public class EffDrawLineWE extends Effect {
@Override
public String toString(@Nullable Event e, boolean arg1) {
return "draw a line using an edit session with " + block.toString(e, false);
return "draw a line from " + location1.toString(e, false) + " to " + location2.toString(e, false) + " using an edit session with " + block.toString(e, false) + " and thickness " + thickness.toString(e, false);
}
@Override
@ -50,7 +50,6 @@ public class EffDrawLineWE extends Effect {
EditSession session = editSession.getSingle(e);
ItemStack b = block.getSingle(e);
Double thick = thickness.getSingle(e);
if (thick == null) thick = (double) 1;
if (b.getType().isBlock()) {
try {
session.drawLine(new SingleBlockPattern(new BaseBlock(b.getTypeId(), b.getDurability())), BukkitUtil.toVector(pos1), BukkitUtil.toVector(pos2), thick, filled);

View File

@ -53,11 +53,12 @@ public class ExprEditSessionLimit extends SimpleExpression<Integer> {
@Override
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
EditSession session = editSession.getSingle(e);
if (session == null) return;
if (mode == ChangeMode.SET) {
Integer newLimit = (Integer) delta[0];
session.setBlockChangeLimit(newLimit);
} else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
session.setBlockChangeLimit(we.getLocalConfiguration().defaultChangeLimit);
session.setBlockChangeLimit(Integer.valueOf(newLimit));
} else if (mode == ChangeMode.RESET) {
session.setBlockChangeLimit(Integer.valueOf(we.getLocalConfiguration().defaultChangeLimit));
}
}

View File

@ -1,22 +1,25 @@
package me.TheBukor.expressions;
import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
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;
import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
public class ExprEditSession extends SimpleExpression<EditSession> {
private Expression<Player> player;
@SuppressWarnings("deprecation")
public class ExprNewEditSession extends SimpleExpression<EditSession> {
private Expression<World> world;
private Expression<Integer> blockLimit;
@Override
public Class<? extends EditSession> getReturnType() {
@ -31,24 +34,24 @@ public class ExprEditSession extends SimpleExpression<EditSession> {
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult arg3) {
player = (Expression<Player>) expr[0];
world = (Expression<World>) expr[0];
blockLimit = (Expression<Integer>) expr[1];
return true;
}
@Override
public String toString(@Nullable Event e, boolean arg1) {
return "the edit session of " + player.toString(e, false);
return "create a new edit session in world " + world.toString(e, false) + " with maximum block change limit of " + blockLimit.toString(e, false);
}
@Override
@Nullable
protected EditSession[] get(Event e) {
Player p = player.getSingle(e);
WorldEditPlugin we = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (we.getWorldEdit().getEditSessionFactory().getEditSession((World) we.wrapPlayer(p).getWorld(), we.getSession(p).getBlockChangeLimit(), we.wrapPlayer(p)) == null) {
return new EditSession[] { we.createEditSession(p) };
}
return new EditSession[] { we.getWorldEdit().getEditSessionFactory().getEditSession((World) we.wrapPlayer(p).getWorld(), we.getSession(p).getBlockChangeLimit(), we.wrapPlayer(p)) };
World w = world.getSingle(e);
Integer limit = blockLimit.getSingle(e);
LocalWorld localWorld = BukkitUtil.getLocalWorld(w);
return new EditSession[] { we.getWorldEdit().getEditSessionFactory().getEditSession(localWorld, limit) };
}
}