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,5 +1,7 @@
package com.dfsek.terra.addons.biome.query;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import com.dfsek.terra.addons.biome.query.impl.BiomeTagFlattener;
@@ -15,8 +17,6 @@ import com.dfsek.terra.api.properties.PropertyKey;
import com.dfsek.terra.api.util.function.monad.Monad;
import com.dfsek.terra.api.world.biome.Biome;
import org.jetbrains.annotations.NotNull;
public class BiomeQueryAPIAddon implements MonadAddonInitializer {
public static PropertyKey<BiomeTagHolder> BIOME_TAG_KEY = Context.create(BiomeTagHolder.class);

View File

@@ -1,15 +1,12 @@
package com.dfsek.terra.addons.manifest.api.monad;
import java.util.function.Consumer;
import java.util.function.Function;
import com.dfsek.terra.addons.manifest.impl.InitInfo;
import com.dfsek.terra.api.util.function.Functions;
import com.dfsek.terra.api.util.function.monad.Monad;
import io.vavr.Function0;
import io.vavr.Function1;
import java.util.function.Consumer;
import java.util.function.Function;
public class Init<T> implements Monad<T, Init<?>> {
private final Function<InitInfo, T> get;

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 {
}

View File

@@ -26,7 +26,6 @@ import java.util.function.Consumer;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.event.events.Event;
import com.dfsek.terra.api.event.events.FailThroughEvent;
import com.dfsek.terra.api.event.functional.EventContext;
import com.dfsek.terra.api.util.reflection.ReflectionUtil;

View File

@@ -30,7 +30,6 @@ import java.util.Map;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.event.events.Event;
import com.dfsek.terra.api.event.events.FailThroughEvent;
import com.dfsek.terra.api.event.functional.EventContext;
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
import com.dfsek.terra.api.util.reflection.TypeKey;