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

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