remove additional events, make Event extend Monad

This commit is contained in:
dfsek
2022-09-02 22:51:57 -07:00
parent 3077178cd2
commit e887a9f1a1
10 changed files with 9 additions and 119 deletions

View File

@@ -1,28 +0,0 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the common/api directory.
*/
package com.dfsek.terra.api.event.events;
import com.dfsek.terra.api.util.mutable.MutableBoolean;
/**
* Abstract class containing basic {@link Cancellable} implementation.
*/
public abstract class AbstractCancellable implements Cancellable {
private final MutableBoolean cancelled = new MutableBoolean(false);
@Override
public boolean isCancelled() {
return cancelled.get();
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled.set(cancelled);
}
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the common/api directory.
*/
package com.dfsek.terra.api.event.events;
/**
* Events that implement this interface may be cancelled.
* <p>
* Cancelling an event is assumed to stop the execution of whatever action triggered the event.
*/
public interface Cancellable extends Event {
/**
* Get the cancellation status of the event.
*
* @return Whether event is cancelled.
*/
boolean isCancelled();
/**
* Set the cancellation status of the event.
*
* @param cancelled Whether event is cancelled.
*/
void setCancelled(boolean cancelled);
}

View File

@@ -7,8 +7,11 @@
package com.dfsek.terra.api.event.events;
import com.dfsek.terra.api.util.function.monad.Monad;
/**
* An event that addons may listen to.
*/
public interface Event {
public interface Event<T> extends Monad<T, Event<?>> {
}

View File

@@ -1,15 +0,0 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the common/api directory.
*/
package com.dfsek.terra.api.event.events;
/**
* An event which (optionally) passes exceptions thrown by listeners to
* the event caller.
*/
public interface FailThroughEvent extends Event {
}

View File

@@ -1,19 +0,0 @@
package com.dfsek.terra.api.event.events.platform;
import cloud.commandframework.CommandManager;
import com.dfsek.terra.api.command.CommandSender;
import com.dfsek.terra.api.event.events.Event;
public class CommandRegistrationEvent implements Event {
private final CommandManager<CommandSender> commandManager;
public CommandRegistrationEvent(CommandManager<CommandSender> commandManager) {
this.commandManager = commandManager;
}
public CommandManager<CommandSender> getCommandManager() {
return commandManager;
}
}

View File

@@ -1,17 +0,0 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the common/api directory.
*/
package com.dfsek.terra.api.event.events.platform;
import com.dfsek.terra.api.event.events.Event;
/**
* Called when the platform is initialized.
*/
public class PlatformInitializationEvent implements Event {
}