-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pablete1234 <[email protected]>
- Loading branch information
1 parent
8b4f94b
commit 9c8ad73
Showing
2 changed files
with
52 additions
and
1 deletion.
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
38 changes: 38 additions & 0 deletions
38
core/src/main/java/tc/oc/pgm/action/actions/FillAction.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,38 @@ | ||
package tc.oc.pgm.action.actions; | ||
|
||
import org.bukkit.block.Block; | ||
import org.bukkit.block.BlockState; | ||
import org.bukkit.event.block.BlockFormEvent; | ||
import org.bukkit.material.MaterialData; | ||
import tc.oc.pgm.api.match.Match; | ||
import tc.oc.pgm.api.region.Region; | ||
|
||
public class FillAction extends AbstractAction<Match> { | ||
|
||
private final Region region; | ||
private final MaterialData materialData; | ||
private final boolean events; | ||
|
||
public FillAction(Region region, MaterialData materialData, boolean events) { | ||
super(Match.class); | ||
this.region = region; | ||
this.materialData = materialData; | ||
this.events = events; | ||
} | ||
|
||
@Override | ||
public void trigger(Match match) { | ||
for (Block block : region.getBlocks(match.getWorld())) { | ||
BlockState newState = block.getState(); | ||
newState.setMaterialData(materialData); | ||
|
||
if (events) { | ||
BlockFormEvent event = new BlockFormEvent(block, newState); | ||
match.callEvent(event); | ||
if (event.isCancelled()) continue; | ||
} | ||
|
||
newState.update(true, true); | ||
} | ||
} | ||
} |