本文整理汇总了Java中com.sk89q.worldedit.LocalSession.undo方法的典型用法代码示例。如果您正苦于以下问题:Java LocalSession.undo方法的具体用法?Java LocalSession.undo怎么用?Java LocalSession.undo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.LocalSession
的用法示例。
在下文中一共展示了LocalSession.undo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: undo
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@Command(
aliases = {"/undo", "undo"},
usage = "[times] [player]",
desc = "Undoes the last action",
min = 0,
max = 2
)
@CommandPermissions("worldedit.history.undo")
public void undo(Player player, LocalSession session, CommandContext args) throws WorldEditException {
int times = Math.max(1, args.getInteger(0, 1));
for (int i = 0; i < times; ++i) {
EditSession undone;
if (args.argsLength() < 2) {
undone = session.undo(session.getBlockBag(player), player);
} else {
player.checkPermission("worldedit.history.undo.other");
LocalSession sess = worldEdit.getSession(args.getString(1));
if (sess == null) {
BBC.COMMAND_HISTORY_OTHER_ERROR.send(player, args.getString(1));
break;
}
undone = sess.undo(session.getBlockBag(player), player);
}
if (undone != null) {
BBC.COMMAND_UNDO_SUCCESS.send(player);
worldEdit.flushBlockBag(player, undone);
} else {
BBC.COMMAND_UNDO_ERROR.send(player);
break;
}
}
}