3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 12:30:05 +01:00

Pass LocalPlayers to the EditSession getters for easy external access

Dieser Commit ist enthalten in:
Ammar Askar 2012-11-13 15:07:08 +05:00 committet von Wizjany
Ursprung 94a549214d
Commit 4b50e0e453
8 geänderte Dateien mit 42 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -14,6 +14,17 @@ public class EditSessionFactory {
return new EditSession(world, maxBlocks); 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. * 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); 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);
}
} }

Datei anzeigen

@ -136,14 +136,15 @@ public class LocalSession {
* Performs an undo. * Performs an undo.
* *
* @param newBlockBag * @param newBlockBag
* @param player
* @return whether anything was undone * @return whether anything was undone
*/ */
public EditSession undo(BlockBag newBlockBag) { public EditSession undo(BlockBag newBlockBag, LocalPlayer player) {
--historyPointer; --historyPointer;
if (historyPointer >= 0) { if (historyPointer >= 0) {
EditSession editSession = history.get(historyPointer); EditSession editSession = history.get(historyPointer);
EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory() EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory()
.getEditSession(editSession.getWorld(), -1, newBlockBag); .getEditSession(editSession.getWorld(), -1, newBlockBag, player);
newEditSession.enableQueue(); newEditSession.enableQueue();
newEditSession.setFastMode(fastMode); newEditSession.setFastMode(fastMode);
editSession.undo(newEditSession); editSession.undo(newEditSession);
@ -158,13 +159,14 @@ public class LocalSession {
* Performs a redo * Performs a redo
* *
* @param newBlockBag * @param newBlockBag
* @param player
* @return whether anything was redone * @return whether anything was redone
*/ */
public EditSession redo(BlockBag newBlockBag) { public EditSession redo(BlockBag newBlockBag, LocalPlayer player) {
if (historyPointer < history.size()) { if (historyPointer < history.size()) {
EditSession editSession = history.get(historyPointer); EditSession editSession = history.get(historyPointer);
EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory() EditSession newEditSession = WorldEdit.getInstance().getEditSessionFactory()
.getEditSession(editSession.getWorld(), -1, newBlockBag); .getEditSession(editSession.getWorld(), -1, newBlockBag, player);
newEditSession.enableQueue(); newEditSession.enableQueue();
newEditSession.setFastMode(fastMode); newEditSession.setFastMode(fastMode);
editSession.redo(newEditSession); editSession.redo(newEditSession);
@ -700,7 +702,7 @@ public class LocalSession {
// Create an edit session // Create an edit session
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory() EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
.getEditSession(player.isPlayer() ? player.getWorld() : null, .getEditSession(player.isPlayer() ? player.getWorld() : null,
getBlockChangeLimit(), blockBag); getBlockChangeLimit(), blockBag, player);
editSession.setFastMode(fastMode); editSession.setFastMode(fastMode);
if (mask != null) { if (mask != null) {
mask.prepare(this, player, null); mask.prepare(this, player, null);

Datei anzeigen

@ -239,7 +239,7 @@ public class WorldEditPlugin extends JavaPlugin {
BlockBag blockBag = session.getBlockBag(wePlayer); BlockBag blockBag = session.getBlockBag(wePlayer);
EditSession editSession = controller.getEditSessionFactory() EditSession editSession = controller.getEditSessionFactory()
.getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag); .getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag, wePlayer);
editSession.enableQueue(); editSession.enableQueue();
return editSession; return editSession;

Datei anzeigen

@ -56,7 +56,7 @@ public class HistoryCommands {
for (int i = 0; i < times; ++i) { for (int i = 0; i < times; ++i) {
EditSession undone; EditSession undone;
if (args.argsLength() < 2) { if (args.argsLength() < 2) {
undone = session.undo(session.getBlockBag(player)); undone = session.undo(session.getBlockBag(player), player);
} else { } else {
player.checkPermission("worldedit.history.undo.other"); player.checkPermission("worldedit.history.undo.other");
LocalSession sess = we.getSession(args.getString(1)); LocalSession sess = we.getSession(args.getString(1));
@ -64,7 +64,7 @@ public class HistoryCommands {
player.printError("Unable to find session for " + args.getString(1)); player.printError("Unable to find session for " + args.getString(1));
break; break;
} }
undone = sess.undo(session.getBlockBag(player)); undone = sess.undo(session.getBlockBag(player), player);
} }
if (undone != null) { if (undone != null) {
@ -98,7 +98,7 @@ public class HistoryCommands {
for (int i = 0; i < times; ++i) { for (int i = 0; i < times; ++i) {
EditSession redone; EditSession redone;
if (args.argsLength() < 2) { if (args.argsLength() < 2) {
redone = session.redo(session.getBlockBag(player)); redone = session.redo(session.getBlockBag(player), player);
} else { } else {
player.checkPermission("worldedit.history.redo.other"); player.checkPermission("worldedit.history.redo.other");
LocalSession sess = we.getSession(args.getString(1)); LocalSession sess = we.getSession(args.getString(1));
@ -106,7 +106,7 @@ public class HistoryCommands {
player.printError("Unable to find session for " + args.getString(1)); player.printError("Unable to find session for " + args.getString(1));
break; break;
} }
redone = sess.redo(session.getBlockBag(player)); redone = sess.redo(session.getBlockBag(player), player);
} }
if (redone != null) { if (redone != null) {

Datei anzeigen

@ -62,7 +62,7 @@ public class CraftScriptContext extends CraftScriptEnvironment {
public EditSession remember() { public EditSession remember() {
EditSession editSession = controller.getEditSessionFactory() EditSession editSession = controller.getEditSessionFactory()
.getEditSession(player.getWorld(), .getEditSession(player.getWorld(),
session.getBlockChangeLimit(), session.getBlockBag(player)); session.getBlockChangeLimit(), session.getBlockBag(player), player);
editSession.enableQueue(); editSession.enableQueue();
editSessions.add(editSession); editSessions.add(editSession);
return editSession; return editSession;

Datei anzeigen

@ -46,7 +46,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
BlockBag bag = session.getBlockBag(player); BlockBag bag = session.getBlockBag(player);
LocalWorld world = clicked.getWorld(); LocalWorld world = clicked.getWorld();
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag); EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player);
try { try {
editSession.setBlock(clicked, targetBlock); editSession.setBlock(clicked, targetBlock);
@ -66,7 +66,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
LocalSession session, WorldVector clicked) { LocalSession session, WorldVector clicked) {
LocalWorld world = clicked.getWorld(); 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); targetBlock = (editSession).getBlock(clicked);
BlockType type = BlockType.fromID(targetBlock.getType()); BlockType type = BlockType.fromID(targetBlock.getType());

Datei anzeigen

@ -37,7 +37,7 @@ public class QueryTool implements BlockTool {
LocalPlayer player, LocalSession session, WorldVector clicked) { LocalPlayer player, LocalSession session, WorldVector clicked) {
LocalWorld world = clicked.getWorld(); 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); BaseBlock block = (editSession).rawGetBlock(clicked);
BlockType type = BlockType.fromID(block.getType()); BlockType type = BlockType.fromID(block.getType());

Datei anzeigen

@ -215,7 +215,7 @@ public class WorldEditPlugin extends CommonPlugin {
BlockBag blockBag = session.getBlockBag(wePlayer); BlockBag blockBag = session.getBlockBag(wePlayer);
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory() EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
.getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag); .getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag, wePlayer);
editSession.enableQueue(); editSession.enableQueue();
return editSession; return editSession;