-
-
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.
Improve performances by not using Exceptions for code control flow wi…
…thin BlockBreakListener (#615) (#621) * Do not use Exceptions for code control flow for BlockBreakListener * Implement nitpicks * Formatting & refactor shouldCancel & add enums values computed once --------- Co-authored-by: Geolykt <[email protected]>
- Loading branch information
Showing
16 changed files
with
75 additions
and
80 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
21 changes: 21 additions & 0 deletions
21
common/src/main/java/fr/rakambda/fallingtree/common/tree/AbortedResult.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,21 @@ | ||
package fr.rakambda.fallingtree.common.tree; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public enum AbortedResult implements IBreakAttemptResult { | ||
INVALID_PLAYER_STATE(false), | ||
NOT_ENABLED(false), | ||
NOT_SERVER(false), | ||
NO_SUCH_TREE(false), | ||
REQUIRED_TOOL_ABSENT(true), | ||
TREE_TOO_BIG_BREAK(false), | ||
TREE_TOO_BIG_SCAN(false); | ||
|
||
private final boolean cancel; | ||
|
||
@Override | ||
public boolean shouldCancel() { | ||
return 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#breakTree(ILevel, IPlayer, IBlockPos)}, whether it succeeded or not. | ||
* Failures are generally instances of {@link AbortedResult}, where are succeeded attempts are instances of | ||
* {@link BreakTreeResult}. | ||
*/ | ||
public sealed interface IBreakAttemptResult permits BreakTreeResult, AbortedResult{ | ||
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
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
4 changes: 0 additions & 4 deletions
4
common/src/main/java/fr/rakambda/fallingtree/common/tree/exception/NoTreeFoundException.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
common/src/main/java/fr/rakambda/fallingtree/common/tree/exception/NotServerException.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...on/src/main/java/fr/rakambda/fallingtree/common/tree/exception/PlayerNotInRightState.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...n/src/main/java/fr/rakambda/fallingtree/common/tree/exception/ToolUseForcedException.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...on/src/main/java/fr/rakambda/fallingtree/common/tree/exception/TreeBreakingException.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...n/java/fr/rakambda/fallingtree/common/tree/exception/TreeBreakingNotEnabledException.java
This file was deleted.
Oops, something went wrong.
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