mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 14:56:28 +00:00
remove additional events, make Event extend Monad
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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<?>> {
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user