Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try another method of queueing it up, and write a test implementation…
… for Drain.
- Loading branch information
Showing
14 changed files
with
259 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...it-core/src/main/java/com/sk89q/worldedit/function/operation/AffectedFutureOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* WorldEdit, a Minecraft world manipulation toolkit | ||
* Copyright (C) sk89q <http://www.sk89q.com> | ||
* Copyright (C) WorldEdit team and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.sk89q.worldedit.function.operation; | ||
|
||
import com.sk89q.worldedit.WorldEditException; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public class AffectedFutureOperation implements Operation { | ||
|
||
private Operation operation; | ||
private CompletableFuture<Integer> future; | ||
private int affected = 0; | ||
|
||
public AffectedFutureOperation(Operation operation, CompletableFuture<Integer> future) { | ||
this.operation = operation; | ||
this.future = future; | ||
} | ||
|
||
@Override | ||
public Operation resume(RunContext run) throws WorldEditException { | ||
if (operation != null) { | ||
Operation nextOp = operation.resume(run); | ||
if (operation instanceof AffectingOperation) { | ||
affected += ((AffectingOperation) operation).getAffected(); | ||
} | ||
operation = nextOp; | ||
} | ||
|
||
if (operation != null) { | ||
return this; | ||
} | ||
|
||
future.complete(affected); | ||
return null; | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
} | ||
|
||
@Override | ||
public void addStatusMessages(List<String> messages) { | ||
messages.add("Affected " + affected); | ||
operation.addStatusMessages(messages); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/AffectingOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* WorldEdit, a Minecraft world manipulation toolkit | ||
* Copyright (C) sk89q <http://www.sk89q.com> | ||
* Copyright (C) WorldEdit team and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.sk89q.worldedit.function.operation; | ||
|
||
public interface AffectingOperation extends Operation { | ||
|
||
/** | ||
* Get the number of affected objects. | ||
* | ||
* @return the number of affected | ||
*/ | ||
int getAffected(); | ||
} |
60 changes: 60 additions & 0 deletions
60
worldedit-core/src/main/java/com/sk89q/worldedit/function/operation/FlushOperation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* WorldEdit, a Minecraft world manipulation toolkit | ||
* Copyright (C) sk89q <http://www.sk89q.com> | ||
* Copyright (C) WorldEdit team and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.sk89q.worldedit.function.operation; | ||
|
||
import com.sk89q.worldedit.EditSession; | ||
import com.sk89q.worldedit.LocalSession; | ||
import com.sk89q.worldedit.WorldEdit; | ||
import com.sk89q.worldedit.WorldEditException; | ||
import com.sk89q.worldedit.extension.platform.Actor; | ||
|
||
import java.util.List; | ||
|
||
public class FlushOperation implements Operation { | ||
|
||
private Actor actor; | ||
private EditSession editSession; | ||
|
||
public FlushOperation(Actor actor, EditSession editSession) { | ||
this.actor = actor; | ||
this.editSession = editSession; | ||
} | ||
|
||
@Override | ||
public Operation resume(RunContext run) throws WorldEditException { | ||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(actor); | ||
session.remember(editSession); | ||
editSession.flushQueue(); | ||
|
||
WorldEdit.getInstance().flushBlockBag(actor, editSession); | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
|
||
} | ||
|
||
@Override | ||
public void addStatusMessages(List<String> messages) { | ||
|
||
} | ||
} |
Oops, something went wrong.