forked from Aurorion/BlockRegen
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
154 additions
and
26 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
29 changes: 29 additions & 0 deletions
29
src/main/java/nl/aurorion/blockregen/api/BlockRegenBlockBreakEvent.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,29 @@ | ||
package nl.aurorion.blockregen.api; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import nl.aurorion.blockregen.system.preset.BlockPreset; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.block.BlockBreakEvent; | ||
|
||
/** | ||
* Fired after the original BlockBreakEvent. | ||
* Cancelling this event causes BlockRegen not to do any action after the block is broken. It does not cancel BlockBreakEvent itself. | ||
*/ | ||
public class BlockRegenBlockBreakEvent extends BlockRegenBlockEvent implements Cancellable { | ||
|
||
/** | ||
* Original BLockBreakEvent which caused BlockRegen to take action. | ||
*/ | ||
@Getter | ||
private final BlockBreakEvent blockBreakEvent; | ||
|
||
@Getter | ||
@Setter | ||
private boolean cancelled = false; | ||
|
||
public BlockRegenBlockBreakEvent(BlockBreakEvent blockBreakEvent, BlockPreset blockPreset) { | ||
super(blockBreakEvent.getBlock(), blockPreset); | ||
this.blockBreakEvent = blockBreakEvent; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/nl/aurorion/blockregen/api/BlockRegenBlockEvent.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 @@ | ||
package nl.aurorion.blockregen.api; | ||
|
||
import lombok.Getter; | ||
import nl.aurorion.blockregen.system.preset.BlockPreset; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.event.block.BlockEvent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Base class for Events regarding BlockRegenBlock actions. | ||
*/ | ||
public class BlockRegenBlockEvent extends BlockEvent { | ||
|
||
private static final HandlerList HANDLERS = new HandlerList(); | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
@Getter | ||
private final BlockPreset blockPreset; | ||
|
||
public BlockRegenBlockEvent(Block block, BlockPreset blockPreset) { | ||
super(block); | ||
this.blockPreset = blockPreset; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/nl/aurorion/blockregen/api/BlockRegenBlockRegenerationEvent.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,42 @@ | ||
package nl.aurorion.blockregen.api; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import nl.aurorion.blockregen.system.RegenerationProcess; | ||
import org.bukkit.Material; | ||
import org.bukkit.event.Cancellable; | ||
|
||
/** | ||
* Event fired before a block is regenerated. | ||
* Cancelling this event causes the block not to regenerate into another, also deletes the regeneration process. | ||
*/ | ||
public class BlockRegenBlockRegenerationEvent extends BlockRegenBlockEvent implements Cancellable { | ||
|
||
@Getter | ||
@Setter | ||
private boolean cancelled = false; | ||
|
||
/** | ||
* Regeneration process responsible for this block. | ||
*/ | ||
@Getter | ||
private final RegenerationProcess regenerationProcess; | ||
|
||
public BlockRegenBlockRegenerationEvent(RegenerationProcess regenerationProcess) { | ||
super(regenerationProcess.getBlock(), regenerationProcess.getPreset()); | ||
this.regenerationProcess = regenerationProcess; | ||
} | ||
|
||
|
||
/* | ||
* Shortcuts. | ||
* */ | ||
|
||
public Material getRegenerateInto() { | ||
return regenerationProcess.getRegenerateInto(); | ||
} | ||
|
||
public void setRegenerateInto(Material material) { | ||
regenerationProcess.setRegenerateInto(material); | ||
} | ||
} |
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