-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not use Exceptions for code control flow for BlockBreakListener
- Loading branch information
Showing
7 changed files
with
97 additions
and
39 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
common/src/main/java/fr/rakambda/fallingtree/common/tree/BreakAbortionCause.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,22 @@ | ||
package fr.rakambda.fallingtree.common.tree; | ||
|
||
public enum BreakAbortionCause implements IBreakAttemptResult { | ||
NOT_SERVER(false), | ||
NOT_ENABLED(false), | ||
REQUIRED_TOOL_ABSENT(true), | ||
INVALID_PLAYER_STATE(false), | ||
NO_SUCH_TREE(false), | ||
TREE_TOO_BIG_SCAN(false), | ||
TREE_TOO_BIG_BREAK(false); | ||
|
||
private final boolean cancel; | ||
|
||
BreakAbortionCause(boolean cancel) { | ||
this.cancel = cancel; | ||
} | ||
|
||
@Override | ||
public boolean shouldCancel(){ | ||
return this.cancel; | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
common/src/main/java/fr/rakambda/fallingtree/common/tree/IBreakAttemptResult.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,14 @@ | ||
package fr.rakambda.fallingtree.common.tree; | ||
|
||
import fr.rakambda.fallingtree.common.wrapper.IBlockPos; | ||
import fr.rakambda.fallingtree.common.wrapper.ILevel; | ||
import fr.rakambda.fallingtree.common.wrapper.IPlayer; | ||
|
||
/** | ||
* The result of a {@link TreeHandler#attemptTreeBreaking(ILevel, IPlayer, IBlockPos)}, whether it succeeded or not. | ||
* Failures are generally instances of {@link BreakAbortionCause}, where are succeeded attempts are instances of | ||
* {@link BreakTreeResult}. | ||
*/ | ||
public interface IBreakAttemptResult{ | ||
boolean shouldCancel(); | ||
} |
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
4 changes: 4 additions & 0 deletions
4
...on/src/main/java/fr/rakambda/fallingtree/common/tree/exception/TreeBreakingException.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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package fr.rakambda.fallingtree.common.tree.exception; | ||
|
||
public class TreeBreakingException extends Exception{ | ||
@Deprecated | ||
public TreeBreakingException(Throwable throwable){ | ||
super(throwable); | ||
} | ||
public TreeBreakingException(String message){ | ||
super(message); | ||
} | ||
} |
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