Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-08 04:20:06 +01:00
Pass LocalPlayers to the EditSession getters for easy external access
Dieser Commit ist enthalten in:
Ursprung
94a549214d
Commit
4b50e0e453
@ -14,6 +14,17 @@ public class EditSessionFactory {
|
||||
return new EditSession(world, maxBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an edit session with a maximum number of blocks.
|
||||
*
|
||||
* @param world
|
||||
* @param maxBlocks
|
||||
* @param player
|
||||
*/
|
||||
public EditSession getEditSession(LocalWorld world, int maxBlocks, LocalPlayer player) {
|
||||
return this.getEditSession(world, maxBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an edit session with a maximum number of blocks and a block bag.
|
||||
*
|
||||
@ -25,4 +36,16 @@ public class EditSessionFactory {
|
||||
return new EditSession(world, maxBlocks, blockBag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an edit session with a maximum number of blocks and a block bag.
|
||||
*
|
||||
* @param world
|
||||
* @param maxBlocks
|
||||
* @param blockBag
|
||||
* @param player
|
||||
*/
|
||||
public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
|
||||
return this.getEditSession(world, maxBlocks, blockBag);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -136,14 +136,15 @@ public class LocalSession {
|
||||
* Performs an undo.
|
||||
*
|
||||
* @param newBlockBag
|
||||
* @param player
|
||||
* @return whether anything was undone
|
||||
*/
|
||||
public EditSession undo(BlockBag newBlockBag) {
|
||||
public EditSession undo(BlockBag newBlockBag, LocalPlayer player) {
|
||||
--historyPointer;
|
||||
if (historyPointer >= 0) {
|
||||
EditSession editSession = history.get(historyPointer);
|
||||
EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||
.getEditSession(editSession.getWorld(), -1, newBlockBag);
|
||||
.getEditSession(editSession.getWorld(), -1, newBlockBag, player);
|
||||
newEditSession.enableQueue();
|
||||
newEditSession.setFastMode(fastMode);
|
||||
editSession.undo(newEditSession);
|
||||
@ -158,13 +159,14 @@ public class LocalSession {
|
||||
* Performs a redo
|
||||
*
|
||||
* @param newBlockBag
|
||||
* @param player
|
||||
* @return whether anything was redone
|
||||
*/
|
||||
public EditSession redo(BlockBag newBlockBag) {
|
||||
public EditSession redo(BlockBag newBlockBag, LocalPlayer player) {
|
||||
if (historyPointer < history.size()) {
|
||||
EditSession editSession = history.get(historyPointer);
|
||||
EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||
.getEditSession(editSession.getWorld(), -1, newBlockBag);
|
||||
.getEditSession(editSession.getWorld(), -1, newBlockBag, player);
|
||||
newEditSession.enableQueue();
|
||||
newEditSession.setFastMode(fastMode);
|
||||
editSession.redo(newEditSession);
|
||||
@ -700,7 +702,7 @@ public class LocalSession {
|
||||
// Create an edit session
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||
.getEditSession(player.isPlayer() ? player.getWorld() : null,
|
||||
getBlockChangeLimit(), blockBag);
|
||||
getBlockChangeLimit(), blockBag, player);
|
||||
editSession.setFastMode(fastMode);
|
||||
if (mask != null) {
|
||||
mask.prepare(this, player, null);
|
||||
|
@ -239,7 +239,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
BlockBag blockBag = session.getBlockBag(wePlayer);
|
||||
|
||||
EditSession editSession = controller.getEditSessionFactory()
|
||||
.getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag);
|
||||
.getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag, wePlayer);
|
||||
editSession.enableQueue();
|
||||
|
||||
return editSession;
|
||||
|
@ -56,7 +56,7 @@ public class HistoryCommands {
|
||||
for (int i = 0; i < times; ++i) {
|
||||
EditSession undone;
|
||||
if (args.argsLength() < 2) {
|
||||
undone = session.undo(session.getBlockBag(player));
|
||||
undone = session.undo(session.getBlockBag(player), player);
|
||||
} else {
|
||||
player.checkPermission("worldedit.history.undo.other");
|
||||
LocalSession sess = we.getSession(args.getString(1));
|
||||
@ -64,7 +64,7 @@ public class HistoryCommands {
|
||||
player.printError("Unable to find session for " + args.getString(1));
|
||||
break;
|
||||
}
|
||||
undone = sess.undo(session.getBlockBag(player));
|
||||
undone = sess.undo(session.getBlockBag(player), player);
|
||||
}
|
||||
|
||||
if (undone != null) {
|
||||
@ -98,7 +98,7 @@ public class HistoryCommands {
|
||||
for (int i = 0; i < times; ++i) {
|
||||
EditSession redone;
|
||||
if (args.argsLength() < 2) {
|
||||
redone = session.redo(session.getBlockBag(player));
|
||||
redone = session.redo(session.getBlockBag(player), player);
|
||||
} else {
|
||||
player.checkPermission("worldedit.history.redo.other");
|
||||
LocalSession sess = we.getSession(args.getString(1));
|
||||
@ -106,7 +106,7 @@ public class HistoryCommands {
|
||||
player.printError("Unable to find session for " + args.getString(1));
|
||||
break;
|
||||
}
|
||||
redone = sess.redo(session.getBlockBag(player));
|
||||
redone = sess.redo(session.getBlockBag(player), player);
|
||||
}
|
||||
|
||||
if (redone != null) {
|
||||
|
@ -62,7 +62,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
public EditSession remember() {
|
||||
EditSession editSession = controller.getEditSessionFactory()
|
||||
.getEditSession(player.getWorld(),
|
||||
session.getBlockChangeLimit(), session.getBlockBag(player));
|
||||
session.getBlockChangeLimit(), session.getBlockBag(player), player);
|
||||
editSession.enableQueue();
|
||||
editSessions.add(editSession);
|
||||
return editSession;
|
||||
|
@ -46,7 +46,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
BlockBag bag = session.getBlockBag(player);
|
||||
|
||||
LocalWorld world = clicked.getWorld();
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag);
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player);
|
||||
|
||||
try {
|
||||
editSession.setBlock(clicked, targetBlock);
|
||||
@ -66,7 +66,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
||||
LocalSession session, WorldVector clicked) {
|
||||
|
||||
LocalWorld world = clicked.getWorld();
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, player);
|
||||
targetBlock = (editSession).getBlock(clicked);
|
||||
BlockType type = BlockType.fromID(targetBlock.getType());
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class QueryTool implements BlockTool {
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
|
||||
LocalWorld world = clicked.getWorld();
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 0);
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 0, player);
|
||||
BaseBlock block = (editSession).rawGetBlock(clicked);
|
||||
BlockType type = BlockType.fromID(block.getType());
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class WorldEditPlugin extends CommonPlugin {
|
||||
BlockBag blockBag = session.getBlockBag(wePlayer);
|
||||
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||
.getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag);
|
||||
.getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag, wePlayer);
|
||||
editSession.enableQueue();
|
||||
|
||||
return editSession;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren