Skip to content

Commit

Permalink
refactor(api)!: move Cancellable to the event package (#276)
Browse files Browse the repository at this point in the history
Move the Cancellable interface, and the AbstractCancellable abstract
implementation to the `dev.hypera.chameleon.event` package.

BREAKING CHANGE: Cancellable is now in the
`dev.hypera.chameleon.event` package.
  • Loading branch information
joshuasing authored Sep 8, 2023
1 parent 72a177a commit e47b2a7
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ address security vulnerabilities that affect the most recent version of this fra

| Version | Supported |
|---------------------|--------------------|
| `0.17.0-SNAPSHOT` | :white_check_mark: |
| < `0.17.0-SNAPSHOT` | :x: |
| `0.18.0-SNAPSHOT` | :white_check_mark: |
| < `0.18.0-SNAPSHOT` | :x: |

### Reporting a Vulnerability

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.hypera.chameleon.event.cancellable;
package dev.hypera.chameleon.event;

/**
* Cancellable implementation.
* An abstract implementation of {@link Cancellable}.
*/
public abstract class AbstractCancellable implements Cancellable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,42 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.hypera.chameleon.event.cancellable;
package dev.hypera.chameleon.event;

/**
* Cancellable.
* Represents an event that can be cancelled.
*/
public interface Cancellable {

/**
* Cancel the event.
* Cancels the event.
*
* @see #setCancelled(boolean)
*/
default void cancel() {
setCancelled(true);
}

/**
* Uncancel the event.
* Uncancels the event.
*
* @see #setCancelled(boolean)
*/
default void uncancel() {
setCancelled(false);
}

/**
* Set cancelled.
* Sets the event cancelled state.
*
* @param cancelled {@code true} if the event is cancelled, otherwise {@code false}.
* @param cancelled {@code true} if the event should be cancelled, otherwise {@code false}.
*/
void setCancelled(boolean cancelled);

/**
* Whether this event is cancelled.
* Returns whether the event has been cancelled.
*
* @return {@code true} if the event is cancelled, otherwise {@code false}.
* @return {@code true} if the event has been cancelled, otherwise {@code false}.
*/
boolean isCancelled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package dev.hypera.chameleon.event;

import dev.hypera.chameleon.event.cancellable.Cancellable;
import dev.hypera.chameleon.logger.ChameleonLogger;
import dev.hypera.chameleon.util.Preconditions;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
package dev.hypera.chameleon.event.common;

import dev.hypera.chameleon.event.cancellable.AbstractCancellable;
import dev.hypera.chameleon.event.AbstractCancellable;
import dev.hypera.chameleon.user.User;
import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
package dev.hypera.chameleon.event.common;

import dev.hypera.chameleon.event.cancellable.AbstractCancellable;
import dev.hypera.chameleon.event.cancellable.Cancellable;
import dev.hypera.chameleon.event.AbstractCancellable;
import dev.hypera.chameleon.event.Cancellable;
import dev.hypera.chameleon.user.User;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.ApiStatus.Internal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import dev.hypera.chameleon.event.cancellable.AbstractCancellable;
import dev.hypera.chameleon.logger.DummyChameleonLogger;
import org.junit.jupiter.api.Test;

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ plugins {
}

group = "dev.hypera"
version = "0.17.0-SNAPSHOT"
version = "0.18.0-SNAPSHOT"
description = "Cross-platform Minecraft plugin framework"

indraSonatype {
Expand Down

0 comments on commit e47b2a7

Please sign in to comment.