Start hiding relocated api libs

This commit is contained in:
Draycia committed 2023-07-08 15:16:55 -07:00
1 parent 9f20afc33a
commit 43d2754018
7 files changed
+140 -23

No files matched your search

+5 -5
View File
@@ -20,13 +20,13 @@ dependencies {
compileOnlyApi(libs.checkerQual)
api(libs.event)
api(libs.kyoriRegistry) {
compileOnlyApi(libs.event)
compileOnlyApi(libs.kyoriRegistry) {
exclude("com.google.guava")
}
api(libs.kyoriMoonshine)
api(libs.kyoriMoonshineCore)
api(libs.kyoriMoonshineStandard)
compileOnlyApi(libs.kyoriMoonshine)
compileOnlyApi(libs.kyoriMoonshineCore)
compileOnlyApi(libs.kyoriMoonshineStandard)
// Provided by Minecraft
compileOnlyApi(libs.gson)
@@ -19,15 +19,15 @@
*/
package net.draycia.carbon.api.event;
import com.seiama.event.EventSubscriber;
import com.seiama.event.EventSubscription;
import java.util.function.Consumer;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
/**
* Carbon event dispatcher.
*
* @since 2.1.0
*/
@DefaultQualifier(NonNull.class)
public interface CarbonEventHandler {
/**
@@ -39,9 +39,9 @@ public interface CarbonEventHandler {
* @return the subscription, so that it may be unregistered
* @since 2.0.0
*/
<T extends CarbonEvent> EventSubscription<T> subscribe(
<T extends CarbonEvent> CarbonEventSubscription<T> subscribe(
final Class<T> eventClass,
final EventSubscriber<T> subscriber
final CarbonEventSubscriber<T> subscriber
);
/**
@@ -51,16 +51,16 @@ public interface CarbonEventHandler {
* @param eventClass the class to listen for
* @param order the order of the consumer
* @param acceptsCancelled if the consumer should be executed if the event is cancelled early
* @param consumer the consumer that's executed when the event is emitted
* @param subscriber the consumer that's executed when the event is emitted
* @param <T> the class to listen for
* @return the subscription, so that it may be unregistered
* @since 2.0.0
*/
<T extends CarbonEvent> EventSubscription<T> subscribe(
<T extends CarbonEvent> CarbonEventSubscription<T> subscribe(
final Class<T> eventClass,
final int order,
final boolean acceptsCancelled,
final Consumer<T> consumer
final CarbonEventSubscriber<T> subscriber
);
/**
@@ -69,8 +69,9 @@ public interface CarbonEventHandler {
* the event while it's being emitted.
*
* @param event the event to be emitted
* @param <T> the class to emit
* @since 2.0.0
*/
void emit(final CarbonEvent event);
<T extends CarbonEvent> void emit(final T event);
}
@@ -0,0 +1,38 @@
/*
* CarbonChat
*
* Copyright (c) 2023 Josua Parks (Vicarious)
* Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.draycia.carbon.api.event;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
import org.jetbrains.annotations.NotNull;
@DefaultQualifier(NonNull.class)
public interface CarbonEventSubscriber<T extends CarbonEvent> {
/**
* Invokes this event consumer.
*
* @param event the event
* @throws Throwable if an exception is thrown
* @since 1.0.0
*/
void on(final @NotNull T event) throws Throwable;
}
@@ -0,0 +1,44 @@
/*
* CarbonChat
*
* Copyright (c) 2023 Josua Parks (Vicarious)
* Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.draycia.carbon.api.event;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
public interface CarbonEventSubscription<T extends CarbonEvent> {
/**
* Gets the event type.
*
* @return the event type
* @since 2.1.0
*/
Class<T> event();
/**
* Gets the subscriber.
*
* @return the subscriber
* @since 2.1.0
*/
CarbonEventSubscriber<T> subscriber();
}
+1
View File
@@ -27,6 +27,7 @@ dependencies {
isTransitive = false
}
compileOnlyApi(libs.luckPermsApi)
compileOnlyApi(libs.event)
// Storage
compileOnlyApi(libs.jdbiCore)
@@ -22,15 +22,15 @@ package net.draycia.carbon.common.event;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.seiama.event.EventConfig;
import com.seiama.event.EventSubscriber;
import com.seiama.event.EventSubscription;
import com.seiama.event.bus.EventBus;
import com.seiama.event.bus.SimpleEventBus;
import com.seiama.event.registry.EventRegistry;
import com.seiama.event.registry.SimpleEventRegistry;
import java.util.function.Consumer;
import net.draycia.carbon.api.event.CarbonEvent;
import net.draycia.carbon.api.event.CarbonEventHandler;
import net.draycia.carbon.api.event.CarbonEventSubscriber;
import net.draycia.carbon.api.event.CarbonEventSubscription;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@@ -56,27 +56,29 @@ public final class CarbonEventHandlerImpl implements CarbonEventHandler {
}
@Override
public <T extends CarbonEvent> EventSubscription<T> subscribe(
public <T extends CarbonEvent> CarbonEventSubscription subscribe(
final Class<T> eventClass,
final EventSubscriber<T> subscriber
final CarbonEventSubscriber<T> subscriber
) {
return this.eventRegistry.subscribe(eventClass, subscriber);
this.eventRegistry.subscribe(eventClass, subscriber::on);
return new CarbonEventSubscriptionImpl<>(eventClass, subscriber);
}
// TODO: support EventConfig#exact()
@Override
public <T extends CarbonEvent> EventSubscription<T> subscribe(
public <T extends CarbonEvent> CarbonEventSubscription<T> subscribe(
final Class<T> eventClass,
final int order,
final boolean acceptsCancelled,
final Consumer<T> consumer
final CarbonEventSubscriber<T> subscriber
) {
final EventConfig eventConfig = EventConfig.defaults().order(order).acceptsCancelled(acceptsCancelled);
return this.eventRegistry.subscribe(eventClass, eventConfig, consumer::accept);
this.eventRegistry.subscribe(eventClass, eventConfig, subscriber::on);
return new CarbonEventSubscriptionImpl<>(eventClass, subscriber);
}
@Override
public void emit(final CarbonEvent event) {
public <T extends CarbonEvent> void emit(final T event) {
this.eventBus.post(event);
}
@@ -0,0 +1,31 @@
/*
* CarbonChat
*
* Copyright (c) 2023 Josua Parks (Vicarious)
* Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.draycia.carbon.common.event;
import net.draycia.carbon.api.event.CarbonEvent;
import net.draycia.carbon.api.event.CarbonEventSubscriber;
import net.draycia.carbon.api.event.CarbonEventSubscription;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
record CarbonEventSubscriptionImpl<T extends CarbonEvent>(Class<T> event, CarbonEventSubscriber<T> subscriber) implements CarbonEventSubscription<T> {
}