geforkt von Mirrors/FastAsyncWorldEdit
Alowed performing undos from other player sessions, if they exist.
Dieser Commit ist enthalten in:
Ursprung
a3186c2ce4
Commit
02d8acfa81
@ -631,4 +631,10 @@ public abstract class LocalPlayer {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getName().hashCode();
|
return getName().hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkPermission(String permission) throws WorldEditPermissionException {
|
||||||
|
if (!hasPermission(permission)) {
|
||||||
|
throw new WorldEditPermissionException();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,6 +173,16 @@ public class WorldEdit {
|
|||||||
commands.register(ToolCommands.class);
|
commands.register(ToolCommands.class);
|
||||||
commands.register(UtilityCommands.class);
|
commands.register(UtilityCommands.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets the LocalSession for a player name if it exists
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @return The session for the player, if it exists
|
||||||
|
*/
|
||||||
|
public LocalSession getSession(String player) {
|
||||||
|
return sessions.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the WorldEdit session for a player.
|
* Gets the WorldEdit session for a player.
|
||||||
|
10
src/main/java/com/sk89q/worldedit/WorldEditPermissionException.java
Normale Datei
10
src/main/java/com/sk89q/worldedit/WorldEditPermissionException.java
Normale Datei
@ -0,0 +1,10 @@
|
|||||||
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author zml2008
|
||||||
|
*/
|
||||||
|
public class WorldEditPermissionException extends WorldEditException {
|
||||||
|
public WorldEditPermissionException() {
|
||||||
|
super("You don't have permission to do this.");
|
||||||
|
}
|
||||||
|
}
|
@ -32,10 +32,10 @@ import com.sk89q.worldedit.*;
|
|||||||
public class HistoryCommands {
|
public class HistoryCommands {
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"/undo", "undo"},
|
aliases = {"/undo", "undo"},
|
||||||
usage = "[times]",
|
usage = "[times] [player]",
|
||||||
desc = "Undoes the last action",
|
desc = "Undoes the last action",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.history.undo"})
|
@CommandPermissions({"worldedit.history.undo"})
|
||||||
public static void undo(CommandContext args, WorldEdit we,
|
public static void undo(CommandContext args, WorldEdit we,
|
||||||
@ -43,9 +43,19 @@ public class HistoryCommands {
|
|||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
|
|
||||||
int times = Math.max(1, args.getInteger(0, 1));
|
int times = Math.max(1, args.getInteger(0, 1));
|
||||||
|
|
||||||
for (int i = 0; i < times; ++i) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession undone = session.undo(session.getBlockBag(player));
|
EditSession undone;
|
||||||
|
if (args.argsLength() < 2) {
|
||||||
|
undone = session.undo(session.getBlockBag(player));
|
||||||
|
} else {
|
||||||
|
player.checkPermission("worldedit.history.undo.other");
|
||||||
|
LocalSession sess = we.getSession(args.getString(1));
|
||||||
|
if (sess == null){
|
||||||
|
player.printError("Unable to find session for " + args.getString(1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
undone = sess.undo(session.getBlockBag(player));
|
||||||
|
}
|
||||||
if (undone != null) {
|
if (undone != null) {
|
||||||
player.print("Undo successful.");
|
player.print("Undo successful.");
|
||||||
we.flushBlockBag(player, undone);
|
we.flushBlockBag(player, undone);
|
||||||
@ -58,10 +68,10 @@ public class HistoryCommands {
|
|||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"/redo", "redo"},
|
aliases = {"/redo", "redo"},
|
||||||
usage = "[times]",
|
usage = "[times] [player]",
|
||||||
desc = "Redoes the last action (from history)",
|
desc = "Redoes the last action (from history)",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions({"worldedit.history.redo"})
|
@CommandPermissions({"worldedit.history.redo"})
|
||||||
public static void redo(CommandContext args, WorldEdit we,
|
public static void redo(CommandContext args, WorldEdit we,
|
||||||
@ -71,7 +81,18 @@ public class HistoryCommands {
|
|||||||
int times = Math.max(1, args.getInteger(0, 1));
|
int times = Math.max(1, args.getInteger(0, 1));
|
||||||
|
|
||||||
for (int i = 0; i < times; ++i) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession redone = session.redo(session.getBlockBag(player));
|
EditSession redone;
|
||||||
|
if (args.argsLength() < 2) {
|
||||||
|
redone = session.redo(session.getBlockBag(player));
|
||||||
|
} else {
|
||||||
|
player.checkPermission("worldedit.history.redo.other");
|
||||||
|
LocalSession sess = we.getSession(args.getString(1));
|
||||||
|
if (sess == null){
|
||||||
|
player.printError("Unable to find session for " + args.getString(1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
redone = sess.redo(session.getBlockBag(player));
|
||||||
|
}
|
||||||
if (redone != null) {
|
if (redone != null) {
|
||||||
player.print("Redo successful.");
|
player.print("Redo successful.");
|
||||||
we.flushBlockBag(player, redone);
|
we.flushBlockBag(player, redone);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren