diff --git a/api/build.gradle.kts b/api/build.gradle.kts
index d889e1c6..aee8ecdc 100644
--- a/api/build.gradle.kts
+++ b/api/build.gradle.kts
@@ -18,7 +18,7 @@ dependencies {
compileOnlyApi(libs.checkerQual)
- api(libs.kyoriEventApi)
+ api(libs.event)
api(libs.kyoriRegistry) {
exclude("com.google.guava")
}
diff --git a/api/src/main/java/net/draycia/carbon/api/CarbonChat.java b/api/src/main/java/net/draycia/carbon/api/CarbonChat.java
index 7a4904f7..c61a3eeb 100644
--- a/api/src/main/java/net/draycia/carbon/api/CarbonChat.java
+++ b/api/src/main/java/net/draycia/carbon/api/CarbonChat.java
@@ -22,7 +22,7 @@ package net.draycia.carbon.api;
import java.nio.file.Path;
import java.util.UUID;
import net.draycia.carbon.api.channels.ChannelRegistry;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
import net.draycia.carbon.api.users.UserManager;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
diff --git a/api/src/main/java/net/draycia/carbon/api/CarbonServer.java b/api/src/main/java/net/draycia/carbon/api/CarbonServer.java
index 6a52a5df..a9caff56 100644
--- a/api/src/main/java/net/draycia/carbon/api/CarbonServer.java
+++ b/api/src/main/java/net/draycia/carbon/api/CarbonServer.java
@@ -21,7 +21,6 @@ package net.draycia.carbon.api;
import java.util.List;
import net.draycia.carbon.api.users.CarbonPlayer;
-import net.draycia.carbon.api.users.UserManager;
import net.kyori.adventure.audience.Audience;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@@ -50,14 +49,4 @@ public interface CarbonServer extends Audience {
*/
List extends CarbonPlayer> players();
- /**
- * Manager used to load/obtain and save {@link CarbonPlayer CarbonPlayers}.
- *
- * @deprecated Use {@link CarbonChat#userManager} (internal code: inject the UserManager)
- * @return the user manager
- * @since 2.1.0
- */
- @Deprecated(forRemoval = true)
- UserManager extends CarbonPlayer> userManager();
-
}
diff --git a/api/src/main/java/net/draycia/carbon/api/events/CarbonEvent.java b/api/src/main/java/net/draycia/carbon/api/event/CarbonEvent.java
similarity index 95%
rename from api/src/main/java/net/draycia/carbon/api/events/CarbonEvent.java
rename to api/src/main/java/net/draycia/carbon/api/event/CarbonEvent.java
index 9a6668a6..7fbd6849 100644
--- a/api/src/main/java/net/draycia/carbon/api/events/CarbonEvent.java
+++ b/api/src/main/java/net/draycia/carbon/api/event/CarbonEvent.java
@@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package net.draycia.carbon.api.events;
+package net.draycia.carbon.api.event;
/**
* Interface to represent that an event belongs to carbon.
diff --git a/api/src/main/java/net/draycia/carbon/api/event/CarbonEventHandler.java b/api/src/main/java/net/draycia/carbon/api/event/CarbonEventHandler.java
new file mode 100644
index 00000000..403694fa
--- /dev/null
+++ b/api/src/main/java/net/draycia/carbon/api/event/CarbonEventHandler.java
@@ -0,0 +1,52 @@
+package net.draycia.carbon.api.event;
+
+import com.seiama.event.EventSubscriber;
+import com.seiama.event.EventSubscription;
+import java.util.function.Consumer;
+
+public interface CarbonEventHandler {
+
+ /**
+ * Registers a subscriber for the given event class.
+ *
+ * @param eventClass the class to listen for
+ * @param subscriber the subscriber that's executed when the event is emitted
+ * @param the class to listen for
+ * @return the subscription, so that it may be unregistered
+ * @since 2.0.0
+ */
+ EventSubscription subscribe(
+ final Class eventClass,
+ final EventSubscriber subscriber
+ );
+
+ /**
+ * Registers a subscriber for the given event class.
+ * Includes extra values to control when the consumer is executed.
+ *
+ * @param eventClass the class to listen for
+ * @param priority the priority 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 the class to listen for
+ * @return the subscription, so that it may be unregistered
+ * @since 2.0.0
+ */
+ EventSubscription subscribe(
+ final Class eventClass,
+ final int priority,
+ final boolean acceptsCancelled,
+ final Consumer consumer
+ );
+
+ /**
+ * Emits the supplied event.
+ * Events are modified in place, so care should be taken to keep a reference to
+ * the event while it's being emitted.
+ *
+ * @param event the event to be emitted
+ * @since 2.0.0
+ */
+ void emit(final CarbonEvent event);
+
+}
diff --git a/api/src/main/java/net/draycia/carbon/api/events/CarbonChannelRegisterEvent.java b/api/src/main/java/net/draycia/carbon/api/event/events/CarbonChannelRegisterEvent.java
similarity index 94%
rename from api/src/main/java/net/draycia/carbon/api/events/CarbonChannelRegisterEvent.java
rename to api/src/main/java/net/draycia/carbon/api/event/events/CarbonChannelRegisterEvent.java
index d73fd935..f210e429 100644
--- a/api/src/main/java/net/draycia/carbon/api/events/CarbonChannelRegisterEvent.java
+++ b/api/src/main/java/net/draycia/carbon/api/event/events/CarbonChannelRegisterEvent.java
@@ -17,9 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package net.draycia.carbon.api.events;
+package net.draycia.carbon.api.event.events;
import net.draycia.carbon.api.channels.ChatChannel;
+import net.draycia.carbon.api.event.CarbonEvent;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
diff --git a/api/src/main/java/net/draycia/carbon/api/events/CarbonChatEvent.java b/api/src/main/java/net/draycia/carbon/api/event/events/CarbonChatEvent.java
similarity index 76%
rename from api/src/main/java/net/draycia/carbon/api/events/CarbonChatEvent.java
rename to api/src/main/java/net/draycia/carbon/api/event/events/CarbonChatEvent.java
index 3c6cd813..ecab7cd2 100644
--- a/api/src/main/java/net/draycia/carbon/api/events/CarbonChatEvent.java
+++ b/api/src/main/java/net/draycia/carbon/api/event/events/CarbonChatEvent.java
@@ -17,10 +17,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package net.draycia.carbon.api.events;
+package net.draycia.carbon.api.event.events;
+import com.seiama.event.Cancellable;
import java.util.List;
import net.draycia.carbon.api.channels.ChatChannel;
+import net.draycia.carbon.api.event.CarbonEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.KeyedRenderer;
import net.kyori.adventure.audience.Audience;
@@ -31,15 +33,13 @@ import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.framework.qual.DefaultQualifier;
-import static net.kyori.adventure.text.Component.empty;
-
/**
- * {@link ResultedCarbonEvent} that's called when chat components are rendered for online players.
+ * Event that's called when chat components are rendered for online players.
*
* @since 2.0.0
*/
@DefaultQualifier(NonNull.class)
-public class CarbonChatEvent implements ResultedCarbonEvent {
+public class CarbonChatEvent implements CarbonEvent, Cancellable {
private final List renderers;
private final CarbonPlayer sender;
@@ -48,10 +48,10 @@ public class CarbonChatEvent implements ResultedCarbonEvent.
*/
-package net.draycia.carbon.api.events;
+package net.draycia.carbon.api.event.events;
// TODO: emit event on server shutdown
+import net.draycia.carbon.api.event.CarbonEvent;
+
/**
* An event that's called when the server shuts down.
*
diff --git a/api/src/main/java/net/draycia/carbon/api/events/CarbonEventHandler.java b/api/src/main/java/net/draycia/carbon/api/events/CarbonEventHandler.java
deleted file mode 100644
index 0a8239ba..00000000
--- a/api/src/main/java/net/draycia/carbon/api/events/CarbonEventHandler.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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 .
- */
-package net.draycia.carbon.api.events;
-
-import java.util.function.Consumer;
-import net.kyori.event.EventBus;
-import net.kyori.event.EventSubscriber;
-import net.kyori.event.EventSubscription;
-import net.kyori.event.PostResult;
-import org.checkerframework.checker.nullness.qual.NonNull;
-import org.checkerframework.framework.qual.DefaultQualifier;
-
-/**
- * Event handler for listening to and emitting carbon events.
- *
- * @since 1.0.0
- */
-@DefaultQualifier(NonNull.class)
-public final class CarbonEventHandler {
-
- private final EventBus eventBus = EventBus.create(CarbonEvent.class, (type, event, subscriber) -> {
- if (event instanceof ResultedCarbonEvent<@NonNull ?> rce) {
- return !rce.result().cancelled();
- }
-
- return true;
- });
-
- /**
- * Registers a subscriber for the given event class.
- *
- * @param eventClass the class to listen for
- * @param subscriber the subscriber that's executed when the event is emitted
- * @param the class to listen for
- * @return the subscription, so that it may be unregistered
- * @since 2.0.0
- */
- public EventSubscription subscribe(
- final Class eventClass,
- final EventSubscriber subscriber
- ) {
- return this.eventBus.subscribe(eventClass, subscriber);
- }
-
- /**
- * Registers a subscriber for the given event class.
- * Includes extra values to control when the consumer is executed.
- *
- * @param eventClass the class to listen for
- * @param priority the priority 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 the class to listen for
- * @return the subscription, so that it may be unregistered
- * @since 2.0.0
- */
- public EventSubscription subscribe(
- final Class eventClass,
- final int priority,
- final boolean acceptsCancelled,
- final Consumer consumer
- ) {
- return this.eventBus.subscribe(eventClass, new EventSubscriberImpl<>(consumer, priority, acceptsCancelled));
- }
-
- /**
- * Emits the supplied event and returns its result.
- * Events are modified in place, so care should be taken to keep a reference to
- * the event while it's being emitted.
- *
- * @param event the event to be emitted
- * @return the result
- * @since 2.0.0
- */
- public PostResult emit(final CarbonEvent event) {
- return this.eventBus.post(event);
- }
-
-}
diff --git a/api/src/main/java/net/draycia/carbon/api/events/ResultedCarbonEvent.java b/api/src/main/java/net/draycia/carbon/api/events/ResultedCarbonEvent.java
deleted file mode 100644
index af9db11a..00000000
--- a/api/src/main/java/net/draycia/carbon/api/events/ResultedCarbonEvent.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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 .
- */
-package net.draycia.carbon.api.events;
-
-import net.kyori.adventure.text.Component;
-import org.checkerframework.checker.nullness.qual.NonNull;
-import org.checkerframework.framework.qual.DefaultQualifier;
-
-/**
- * Represents a {@link CarbonEvent} that has a result.
- *
- * @since 2.0.0
- */
-@DefaultQualifier(NonNull.class)
-public interface ResultedCarbonEvent extends CarbonEvent {
-
- /**
- * The result of the event.
- *
- * @return the event's result
- * @since 2.0.0
- */
- R result();
-
- /**
- * Sets the result of the event.
- *
- * @param result the result
- * @since 2.0.0
- */
- void result(final R result);
-
- /**
- * Represents the result of the event.
- *
- * @since 2.0.0
- */
- interface Result {
-
- /**
- * If the event is cancelled to continue execution.
- *
- * @return if listeners will continue executing
- * @since 2.0.0
- */
- boolean cancelled();
-
- /**
- * The reason of the result.
- * Typically empty unless allowed is false.
- *
- * @return the reason of the result
- * @since 2.0.0
- */
- Component reason();
-
- }
-
-}
diff --git a/api/src/main/java/net/draycia/carbon/api/users/ComponentPlayerResult.java b/api/src/main/java/net/draycia/carbon/api/users/ComponentPlayerResult.java
deleted file mode 100644
index 13753fb6..00000000
--- a/api/src/main/java/net/draycia/carbon/api/users/ComponentPlayerResult.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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 .
- */
-package net.draycia.carbon.api.users;
-
-import net.kyori.adventure.text.Component;
-import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
-import org.jetbrains.annotations.ApiStatus;
-
-/**
- * The result of a player data operation.
- *
- * @param player the {@link CarbonPlayer}, or null if unsuccessful
- * @param reason the reason of the result, typically empty unless {@link #player} is null
- * @since 2.0.0
- */
-@Deprecated(forRemoval = true)
-@ApiStatus.Internal
-public record ComponentPlayerResult(@MonotonicNonNull C player, Component reason) {
-
-}
diff --git a/api/src/main/java/net/draycia/carbon/api/users/UserManager.java b/api/src/main/java/net/draycia/carbon/api/users/UserManager.java
index b940c015..12217009 100644
--- a/api/src/main/java/net/draycia/carbon/api/users/UserManager.java
+++ b/api/src/main/java/net/draycia/carbon/api/users/UserManager.java
@@ -21,8 +21,6 @@ package net.draycia.carbon.api.users;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.util.ComponentMessageThrowable;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
@@ -34,21 +32,6 @@ import org.checkerframework.framework.qual.DefaultQualifier;
@DefaultQualifier(NonNull.class)
public interface UserManager {
- /**
- * Loads and returns a {@link CarbonPlayer} with the given {@link UUID}.
- *
- * @deprecated use {@link #user(UUID)} instead
- * @param uuid the player's uuid
- * @return the result
- * @since 2.0.0
- */
- @Deprecated(forRemoval = true)
- default CompletableFuture> carbonPlayer(final UUID uuid) {
- return this.user(uuid)
- .thenApply(user -> new ComponentPlayerResult<>(user, Component.empty()))
- .exceptionally(thr -> new ComponentPlayerResult<>(null, ComponentMessageThrowable.getOrConvertMessage(thr)));
- }
-
/**
* Gets the {@link CarbonPlayer} for the provided player {@link UUID}, whether they are online or not.
*
diff --git a/common/src/main/java/net/draycia/carbon/common/CarbonChatInternal.java b/common/src/main/java/net/draycia/carbon/common/CarbonChatInternal.java
index b568a55b..6903ed9d 100644
--- a/common/src/main/java/net/draycia/carbon/common/CarbonChatInternal.java
+++ b/common/src/main/java/net/draycia/carbon/common/CarbonChatInternal.java
@@ -27,10 +27,11 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.api.CarbonServer;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
import net.draycia.carbon.common.command.commands.ExecutionCoordinatorHolder;
+import net.draycia.carbon.common.event.CarbonEventHandlerImpl;
import net.draycia.carbon.common.listeners.RadiusListener;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.messaging.MessagingManager;
@@ -80,7 +81,7 @@ public abstract class CarbonChatInternal implements Carb
final ExecutionCoordinatorHolder commandExecutor,
final CarbonServer carbonServer,
final CarbonMessages carbonMessages,
- final CarbonEventHandler eventHandler,
+ final CarbonEventHandlerImpl eventHandler,
final CarbonChannelRegistry channelRegistry,
final IMessageRenderer renderer,
final Provider messagingManagerProvider
@@ -180,6 +181,7 @@ public abstract class CarbonChatInternal implements Carb
}
@Override
+ @SuppressWarnings("unchecked")
public IMessageRenderer messageRenderer() {
return (IMessageRenderer) this.renderer;
}
diff --git a/common/src/main/java/net/draycia/carbon/common/CarbonCommonModule.java b/common/src/main/java/net/draycia/carbon/common/CarbonCommonModule.java
index 26af7843..238234fa 100644
--- a/common/src/main/java/net/draycia/carbon/common/CarbonCommonModule.java
+++ b/common/src/main/java/net/draycia/carbon/common/CarbonCommonModule.java
@@ -29,11 +29,12 @@ import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ScheduledExecutorService;
import net.draycia.carbon.api.channels.ChannelRegistry;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
import net.draycia.carbon.common.command.ArgumentFactory;
import net.draycia.carbon.common.command.commands.ExecutionCoordinatorHolder;
import net.draycia.carbon.common.config.ConfigFactory;
+import net.draycia.carbon.common.event.CarbonEventHandlerImpl;
import net.draycia.carbon.common.messages.CarbonMessageSender;
import net.draycia.carbon.common.messages.CarbonMessageSource;
import net.draycia.carbon.common.messages.CarbonMessages;
@@ -86,7 +87,7 @@ public final class CarbonCommonModule extends AbstractModule {
@Provides
@Singleton
public CarbonEventHandler eventHandler() {
- return new CarbonEventHandler();
+ return new CarbonEventHandlerImpl();
}
@Provides
diff --git a/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java b/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java
index 58be9255..c7945075 100644
--- a/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java
+++ b/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java
@@ -44,16 +44,16 @@ import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.api.CarbonChatProvider;
import net.draycia.carbon.api.channels.ChannelRegistry;
import net.draycia.carbon.api.channels.ChatChannel;
-import net.draycia.carbon.api.events.CarbonChatEvent;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.KeyedRenderer;
import net.draycia.carbon.common.DataDirectory;
import net.draycia.carbon.common.command.Commander;
import net.draycia.carbon.common.command.PlayerCommander;
import net.draycia.carbon.common.config.ConfigFactory;
-import net.draycia.carbon.common.events.CarbonReloadEvent;
-import net.draycia.carbon.common.events.ChannelRegisterEvent;
+import net.draycia.carbon.common.event.events.CarbonReloadEvent;
+import net.draycia.carbon.common.event.events.ChannelRegisterEventImpl;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.messaging.packets.ChatMessagePacket;
import net.kyori.adventure.audience.Audience;
@@ -75,7 +75,6 @@ import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.transformation.ConfigurationTransformation;
import static net.draycia.carbon.api.util.KeyedRenderer.keyedRenderer;
-import static net.kyori.adventure.text.Component.empty;
@Singleton
@DefaultQualifier(NonNull.class)
@@ -246,7 +245,7 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
exception.printStackTrace();
}
- this.carbonChat.eventHandler().emit(new ChannelRegisterEvent(this.channelMap.values(), this));
+ this.carbonChat.eventHandler().emit(new ChannelRegisterEventImpl(this.channelMap.values(), this));
}
public @Nullable ChatChannel loadChannel(final Path channelFile) {
@@ -312,21 +311,10 @@ public class CarbonChannelRegistry implements ChannelRegistry, DefaultedRegistry
renderers.add(keyedRenderer(Key.key("carbon", "default"), channel));
final var chatEvent = new CarbonChatEvent(sender, Component.text(plainMessage), recipients, renderers, channel, null);
- final var result = this.carbonChat.eventHandler().emit(chatEvent);
+ this.carbonChat.eventHandler().emit(chatEvent);
- if (!result.wasSuccessful() || chatEvent.result().cancelled()) {
- if (!result.exceptions().isEmpty()) {
- for (final var entry : result.exceptions().entrySet()) {
- this.carbonChat.logger().error("Exception in event handler: " + entry.getKey().getClass().getName());
- entry.getValue().printStackTrace();
- }
- }
-
- final var failure = chatEvent.result().reason();
-
- if (!failure.equals(empty())) {
- sender.sendMessage(failure);
- }
+ if (chatEvent.cancelled()) {
+ return;
}
for (final Audience recipient : chatEvent.recipients()) {
diff --git a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChannelSettings.java b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChannelSettings.java
index 993cf60c..6ba0a382 100644
--- a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChannelSettings.java
+++ b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChannelSettings.java
@@ -36,7 +36,7 @@ public final class ConfigChannelSettings {
You only need to change the second part of the key. "global" by default.
The value is what's used in commands, this is probably what you want to change.
""")
- private @Nullable Key key = Key.key("carbon", "basic");
+ private final @Nullable Key key = Key.key("carbon", "basic");
@Comment("""
The permission required to use the channel.
@@ -44,19 +44,19 @@ public final class ConfigChannelSettings {
To send messages you must have the permission carbon.channel.basic.speak
If you want to give both, grant carbon.channel.basic or carbon.channel.basic.*
""")
- private @Nullable String permission = "carbon.channel.basic";
+ private final @Nullable String permission = "carbon.channel.basic";
@Setting("format")
@Comment("The chat formats for this channel.")
- private @Nullable ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
+ private final @Nullable ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
@Comment("Messages will be sent in this channel if they start with this prefix.")
- private @Nullable String quickPrefix = "";
+ private final @Nullable String quickPrefix = "";
- private @Nullable Boolean shouldRegisterCommands = true;
+ private final @Nullable Boolean shouldRegisterCommands = true;
- private @Nullable String commandName = null;
+ private final @Nullable String commandName = null;
- private @Nullable List commandAliases = Collections.emptyList();
+ private final @Nullable List commandAliases = Collections.emptyList();
}
diff --git a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java
index 6cf6bb25..4094fbbf 100644
--- a/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java
+++ b/common/src/main/java/net/draycia/carbon/common/channels/ConfigChatChannel.java
@@ -75,7 +75,7 @@ public final class ConfigChatChannel implements ChatChannel {
You only need to change the second part of the key. "global" by default.
The value is what's used in commands, this is probably what you want to change.
""")
- private @Nullable Key key = Key.key("carbon", "global");
+ private final @Nullable Key key = Key.key("carbon", "global");
@Comment("""
The permission required to use the /channel and / commands.
@@ -84,22 +84,22 @@ public final class ConfigChatChannel implements ChatChannel {
To read messages you must have the permission carbon.channel.global.see
To send messages you must have the permission carbon.channel.global.speak
""")
- private @Nullable String permission = "carbon.channel.global";
+ private final @Nullable String permission = "carbon.channel.global";
@Setting("format")
@Comment("The chat formats for this channel.")
- private @Nullable ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
+ private final @Nullable ConfigChannelMessageSource messageSource = new ConfigChannelMessageSource();
@Comment("Messages will be sent in this channel if they start with this prefix.")
- private @Nullable String quickPrefix = "";
+ private final @Nullable String quickPrefix = "";
- private @Nullable
+ private final @Nullable
Boolean shouldRegisterCommands = true;
- private @Nullable
+ private final @Nullable
String commandName = null;
- private @Nullable
+ private final @Nullable
List commandAliases = Collections.emptyList();
private transient @Nullable ConfigChannelMessages carbonMessages = null;
@@ -109,15 +109,15 @@ public final class ConfigChatChannel implements ChatChannel {
A value of '0' requires that both players are in the same world.
On velocity, '0' requires that both players are in the same server.
""")
- private int radius = -1;
+ private final int radius = -1;
@Comment("""
If true, players will be able to see if they're not sending messages to anyone
because they're out of range from the radius.
""")
- private boolean emptyRadiusRecipientsMessage = true;
+ private final boolean emptyRadiusRecipientsMessage = true;
- private transient @Nullable ConfigChannelMessages messageService = null;
+ private final transient @Nullable ConfigChannelMessages messageService = null;
@Override
public @Nullable String quickPrefix() {
diff --git a/common/src/main/java/net/draycia/carbon/common/channels/messages/ConfigChannelMessageSource.java b/common/src/main/java/net/draycia/carbon/common/channels/messages/ConfigChannelMessageSource.java
index c7e50047..7b726aba 100644
--- a/common/src/main/java/net/draycia/carbon/common/channels/messages/ConfigChannelMessageSource.java
+++ b/common/src/main/java/net/draycia/carbon/common/channels/messages/ConfigChannelMessageSource.java
@@ -57,7 +57,7 @@ public class ConfigChannelMessageSource implements IMessageSource defaults = Map.of(
+ private final Map defaults = Map.of(
"default_format", ": ",
"console", "[] - : ",
"discord", ""
@@ -69,7 +69,7 @@ public class ConfigChannelMessageSource implements IMessageSource> locales = Map.of(
+ private final Map> locales = Map.of(
Locale.US, Map.of("default_format", ": ")
);
diff --git a/common/src/main/java/net/draycia/carbon/common/command/commands/ReloadCommand.java b/common/src/main/java/net/draycia/carbon/common/command/commands/ReloadCommand.java
index 48514ada..08f1cdc6 100644
--- a/common/src/main/java/net/draycia/carbon/common/command/commands/ReloadCommand.java
+++ b/common/src/main/java/net/draycia/carbon/common/command/commands/ReloadCommand.java
@@ -26,7 +26,7 @@ import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.common.command.CarbonCommand;
import net.draycia.carbon.common.command.CommandSettings;
import net.draycia.carbon.common.command.Commander;
-import net.draycia.carbon.common.events.CarbonReloadEvent;
+import net.draycia.carbon.common.event.events.CarbonReloadEvent;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.NonNull;
diff --git a/common/src/main/java/net/draycia/carbon/common/config/ClearChatSettings.java b/common/src/main/java/net/draycia/carbon/common/config/ClearChatSettings.java
index 07b5ff6d..9e657be4 100644
--- a/common/src/main/java/net/draycia/carbon/common/config/ClearChatSettings.java
+++ b/common/src/main/java/net/draycia/carbon/common/config/ClearChatSettings.java
@@ -35,13 +35,13 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
public class ClearChatSettings {
@Comment("The message that will be sent to each player.")
- private String message = "";
+ private final String message = "";
@Comment("The number of times the message will be sent to each player.")
- private int iterations = 50;
+ private final int iterations = 50;
@Comment("The message to be sent after chat is cleared.")
- private String broadcast = "Chat has been cleared by .";
+ private final String broadcast = "Chat has been cleared by .";
private @MonotonicNonNull Component messageComponent = null;
diff --git a/common/src/main/java/net/draycia/carbon/common/config/ConfigFactory.java b/common/src/main/java/net/draycia/carbon/common/config/ConfigFactory.java
index 0e719d34..93f7fd41 100644
--- a/common/src/main/java/net/draycia/carbon/common/config/ConfigFactory.java
+++ b/common/src/main/java/net/draycia/carbon/common/config/ConfigFactory.java
@@ -24,9 +24,9 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Locale;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
import net.draycia.carbon.common.DataDirectory;
-import net.draycia.carbon.common.events.CarbonReloadEvent;
+import net.draycia.carbon.common.event.events.CarbonReloadEvent;
import net.draycia.carbon.common.serialisation.gson.LocaleSerializerConfigurate;
import net.kyori.adventure.serializer.configurate4.ConfigurateComponentSerializer;
import org.checkerframework.checker.nullness.qual.NonNull;
diff --git a/common/src/main/java/net/draycia/carbon/common/config/DatabaseSettings.java b/common/src/main/java/net/draycia/carbon/common/config/DatabaseSettings.java
index 36c0e106..2a78a673 100644
--- a/common/src/main/java/net/draycia/carbon/common/config/DatabaseSettings.java
+++ b/common/src/main/java/net/draycia/carbon/common/config/DatabaseSettings.java
@@ -34,13 +34,13 @@ public class DatabaseSettings {
MariaDB: jdbc:mariadb://host:3306/DB
PostgreSQL: jdbc:postgresql://host:5432/database
""")
- private String url = "jdbc:mysql://localhost:3306/carbon";
+ private final String url = "jdbc:mysql://localhost:3306/carbon";
@Comment("The connection username.")
- private String username = "username";
+ private final String username = "username";
@Comment("The connection password.")
- private String password = "password";
+ private final String password = "password";
public String url() {
return this.url;
diff --git a/common/src/main/java/net/draycia/carbon/common/config/MessagingSettings.java b/common/src/main/java/net/draycia/carbon/common/config/MessagingSettings.java
index 56c1c5fc..dfcfcd2f 100644
--- a/common/src/main/java/net/draycia/carbon/common/config/MessagingSettings.java
+++ b/common/src/main/java/net/draycia/carbon/common/config/MessagingSettings.java
@@ -30,28 +30,28 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
@ConfigSerializable
public class MessagingSettings {
- private boolean enabled = false;
+ private final boolean enabled = false;
@Comment("Options: RABBITMQ, NATS, REDIS")
- private MessagingManager.@NonNull BrokerType brokerType = MessagingManager.BrokerType.NONE;
+ private final MessagingManager.@NonNull BrokerType brokerType = MessagingManager.BrokerType.NONE;
@Comment("")
- private String url = "127.0.0.1";
+ private final String url = "127.0.0.1";
@Comment("")
- private int port = 5672; // RabbitMQ 5672, NATS 4222, Redis 6379
+ private final int port = 5672; // RabbitMQ 5672, NATS 4222, Redis 6379
@Comment("RabbitMQ VHost")
- private String vhost = "/"; // RabbitMQ only
+ private final String vhost = "/"; // RabbitMQ only
@Comment("NATS credentials file")
- private String credentialsFile = ""; // NATS only
+ private final String credentialsFile = ""; // NATS only
@Comment("RabbitMQ username")
- private String username = "username"; // RabbitMQ only
+ private final String username = "username"; // RabbitMQ only
@Comment("RabbitMQ and Redis password")
- private String password = "password"; // RabbitMQ and Redis only
+ private final String password = "password"; // RabbitMQ and Redis only
public boolean enabled() {
return this.enabled;
diff --git a/common/src/main/java/net/draycia/carbon/common/config/PingSettings.java b/common/src/main/java/net/draycia/carbon/common/config/PingSettings.java
index 00a9b1d3..31d003a4 100644
--- a/common/src/main/java/net/draycia/carbon/common/config/PingSettings.java
+++ b/common/src/main/java/net/draycia/carbon/common/config/PingSettings.java
@@ -30,15 +30,15 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
public class PingSettings {
@Comment("The color your name will be when another player mentions you.")
- private TextColor highlightTextColor = NamedTextColor.YELLOW;
+ private final TextColor highlightTextColor = NamedTextColor.YELLOW;
- private String prefix = "@";
+ private final String prefix = "@";
- private boolean playSound = false;
- private Key name = Key.key("block.anvil.use");
- private Sound.Source source = Sound.Source.MASTER;
- private float volume = 1.0f; // 0.0 -> infinity
- private float pitch = 1.0f; // 0.0 -> 2.0
+ private final boolean playSound = false;
+ private final Key name = Key.key("block.anvil.use");
+ private final Sound.Source source = Sound.Source.MASTER;
+ private final float volume = 1.0f; // 0.0 -> infinity
+ private final float pitch = 1.0f; // 0.0 -> 2.0
public TextColor highlightTextColor() {
return this.highlightTextColor;
diff --git a/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java b/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java
index 6fc28f0c..a1a6863d 100644
--- a/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java
+++ b/common/src/main/java/net/draycia/carbon/common/config/PrimaryConfig.java
@@ -35,22 +35,22 @@ import org.spongepowered.configurate.objectmapping.meta.Comment;
public class PrimaryConfig {
@Comment("The default locale for plugin messages.")
- private Locale defaultLocale = Locale.US;
+ private final Locale defaultLocale = Locale.US;
@Comment("""
The default channel that new players will be in when they join.
If the channel is not found or the player cannot use the channel, they will speak in basic non-channel chat.
""")
- private Key defaultChannel = Key.key("carbon", "global");
+ private final Key defaultChannel = Key.key("carbon", "global");
@Comment("The service that will be used to store and load player information.")
- private StorageType storageType = StorageType.JSON;
+ private final StorageType storageType = StorageType.JSON;
@Comment("")
- private DatabaseSettings databaseSettings = new DatabaseSettings();
+ private final DatabaseSettings databaseSettings = new DatabaseSettings();
@Comment("Various ClearChat command settings.")
- private ClearChatSettings clearChatSettings = new ClearChatSettings();
+ private final ClearChatSettings clearChatSettings = new ClearChatSettings();
@Comment("""
Plugin-wide custom placeholders.
@@ -59,26 +59,26 @@ public class PrimaryConfig {
Make sure to close your tags so they do not bleed into other formats.
Only a single pass is done so custom placeholders will not work within each other.
""")
- private Map customPlaceholders = Map.of();
+ private final Map customPlaceholders = Map.of();
@Comment("The suggestions shown when using the TAB key in chat.")
- private List customChatSuggestions = List.of();
+ private final List customChatSuggestions = List.of();
@Comment("The placeholders replaced in chat messages, this WILL work with chat previews.")
- private Map chatPlaceholders = Map.of();
+ private final Map chatPlaceholders = Map.of();
@Comment("Various settings related to pinging players in channels.")
- private PingSettings pingSettings = new PingSettings();
+ private final PingSettings pingSettings = new PingSettings();
@Comment("Various sound settings for messages.")
- private @Nullable Sound messageSound = Sound.sound(
+ private final @Nullable Sound messageSound = Sound.sound(
Key.key("entity.experience_orb.pickup"),
Sound.Source.MASTER,
1.0F,
1.0F
);
- private MessagingSettings messagingSettings = new MessagingSettings();
+ private final MessagingSettings messagingSettings = new MessagingSettings();
public Locale defaultLocale() {
return this.defaultLocale;
diff --git a/common/src/main/java/net/draycia/carbon/common/event/CarbonEventHandlerImpl.java b/common/src/main/java/net/draycia/carbon/common/event/CarbonEventHandlerImpl.java
new file mode 100644
index 00000000..75db641d
--- /dev/null
+++ b/common/src/main/java/net/draycia/carbon/common/event/CarbonEventHandlerImpl.java
@@ -0,0 +1,72 @@
+/*
+ * 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 .
+ */
+package net.draycia.carbon.common.event;
+
+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 org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+
+/**
+ * Event handler for listening to and emitting carbon events.
+ *
+ * @since 1.0.0
+ */
+@DefaultQualifier(NonNull.class)
+public final class CarbonEventHandlerImpl implements CarbonEventHandler {
+
+ private final EventRegistry eventRegistry = new SimpleEventRegistry<>(CarbonEvent.class);
+ private final EventBus eventBus = new SimpleEventBus<>(this.eventRegistry, this::onException);
+
+ private void onException(final EventSubscription subscription, final E event, final Throwable throwable) {
+ throwable.printStackTrace();
+ }
+
+ @Override
+ public EventSubscription subscribe(
+ final Class eventClass,
+ final EventSubscriber subscriber
+ ) {
+ return this.eventRegistry.subscribe(eventClass, subscriber);
+ }
+
+ @Override
+ public EventSubscription subscribe(
+ final Class eventClass,
+ final int priority,
+ final boolean acceptsCancelled,
+ final Consumer consumer
+ ) {
+ return this.eventRegistry.subscribe(eventClass, new EventSubscriberImpl<>(consumer, priority, acceptsCancelled));
+ }
+
+ @Override
+ public void emit(final CarbonEvent event) {
+ this.eventBus.post(event);
+ }
+
+}
diff --git a/api/src/main/java/net/draycia/carbon/api/events/EventSubscriberImpl.java b/common/src/main/java/net/draycia/carbon/common/event/EventSubscriberImpl.java
similarity index 77%
rename from api/src/main/java/net/draycia/carbon/api/events/EventSubscriberImpl.java
rename to common/src/main/java/net/draycia/carbon/common/event/EventSubscriberImpl.java
index 8fc53663..b0c0aac9 100644
--- a/api/src/main/java/net/draycia/carbon/api/events/EventSubscriberImpl.java
+++ b/common/src/main/java/net/draycia/carbon/common/event/EventSubscriberImpl.java
@@ -17,13 +17,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package net.draycia.carbon.api.events;
+package net.draycia.carbon.common.event;
+import com.seiama.event.EventSubscriber;
import java.util.function.Consumer;
-import net.kyori.event.EventSubscriber;
+import net.draycia.carbon.api.event.CarbonEvent;
import org.checkerframework.checker.nullness.qual.NonNull;
-record EventSubscriberImpl(Consumer consumer, int postOrder, boolean acceptsCancelled) implements EventSubscriber {
+public record EventSubscriberImpl(Consumer consumer, int postOrder, boolean acceptsCancelled) implements EventSubscriber {
@Override
public void on(final @NonNull T event) {
diff --git a/common/src/main/java/net/draycia/carbon/common/events/CarbonReloadEvent.java b/common/src/main/java/net/draycia/carbon/common/event/events/CarbonReloadEvent.java
similarity index 89%
rename from common/src/main/java/net/draycia/carbon/common/events/CarbonReloadEvent.java
rename to common/src/main/java/net/draycia/carbon/common/event/events/CarbonReloadEvent.java
index 03dfd3fc..7487517b 100644
--- a/common/src/main/java/net/draycia/carbon/common/events/CarbonReloadEvent.java
+++ b/common/src/main/java/net/draycia/carbon/common/event/events/CarbonReloadEvent.java
@@ -17,9 +17,9 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package net.draycia.carbon.common.events;
+package net.draycia.carbon.common.event.events;
-import net.draycia.carbon.api.events.CarbonEvent;
+import net.draycia.carbon.api.event.CarbonEvent;
public class CarbonReloadEvent implements CarbonEvent {
diff --git a/common/src/main/java/net/draycia/carbon/common/events/ChannelRegisterEvent.java b/common/src/main/java/net/draycia/carbon/common/event/events/ChannelRegisterEventImpl.java
similarity index 83%
rename from common/src/main/java/net/draycia/carbon/common/events/ChannelRegisterEvent.java
rename to common/src/main/java/net/draycia/carbon/common/event/events/ChannelRegisterEventImpl.java
index 0aa3d349..c3a78f04 100644
--- a/common/src/main/java/net/draycia/carbon/common/events/ChannelRegisterEvent.java
+++ b/common/src/main/java/net/draycia/carbon/common/event/events/ChannelRegisterEventImpl.java
@@ -17,11 +17,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-package net.draycia.carbon.common.events;
+package net.draycia.carbon.common.event.events;
import net.draycia.carbon.api.channels.ChatChannel;
-import net.draycia.carbon.api.events.CarbonChannelRegisterEvent;
-import net.draycia.carbon.api.events.CarbonEvent;
+import net.draycia.carbon.api.event.CarbonEvent;
+import net.draycia.carbon.api.event.events.CarbonChannelRegisterEvent;
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -33,7 +33,7 @@ import org.checkerframework.framework.qual.DefaultQualifier;
* @since 2.1.0
*/
@DefaultQualifier(NonNull.class)
-public class ChannelRegisterEvent implements CarbonChannelRegisterEvent {
+public class ChannelRegisterEventImpl implements CarbonChannelRegisterEvent {
private final Iterable channels;
private final CarbonChannelRegistry registry;
@@ -44,7 +44,7 @@ public class ChannelRegisterEvent implements CarbonChannelRegisterEvent {
* @param channels the channels that were registered
* @since 2.1.0
*/
- public ChannelRegisterEvent(final Iterable channels, final CarbonChannelRegistry registry) {
+ public ChannelRegisterEventImpl(final Iterable channels, final CarbonChannelRegistry registry) {
this.channels = channels;
this.registry = registry;
}
diff --git a/common/src/main/java/net/draycia/carbon/common/listeners/DeafenHandler.java b/common/src/main/java/net/draycia/carbon/common/listeners/DeafenHandler.java
index 7cb0e420..5a2b30fb 100644
--- a/common/src/main/java/net/draycia/carbon/common/listeners/DeafenHandler.java
+++ b/common/src/main/java/net/draycia/carbon/common/listeners/DeafenHandler.java
@@ -20,8 +20,8 @@
package net.draycia.carbon.common.listeners;
import com.google.inject.Inject;
-import net.draycia.carbon.api.events.CarbonChatEvent;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
diff --git a/common/src/main/java/net/draycia/carbon/common/listeners/IgnoreHandler.java b/common/src/main/java/net/draycia/carbon/common/listeners/IgnoreHandler.java
index 7b7b94d6..77778947 100644
--- a/common/src/main/java/net/draycia/carbon/common/listeners/IgnoreHandler.java
+++ b/common/src/main/java/net/draycia/carbon/common/listeners/IgnoreHandler.java
@@ -20,8 +20,8 @@
package net.draycia.carbon.common.listeners;
import com.google.inject.Inject;
-import net.draycia.carbon.api.events.CarbonChatEvent;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.framework.qual.DefaultQualifier;
diff --git a/common/src/main/java/net/draycia/carbon/common/listeners/ItemLinkHandler.java b/common/src/main/java/net/draycia/carbon/common/listeners/ItemLinkHandler.java
index 081c484c..64e9e80f 100644
--- a/common/src/main/java/net/draycia/carbon/common/listeners/ItemLinkHandler.java
+++ b/common/src/main/java/net/draycia/carbon/common/listeners/ItemLinkHandler.java
@@ -20,8 +20,8 @@
package net.draycia.carbon.common.listeners;
import com.google.inject.Inject;
-import net.draycia.carbon.api.events.CarbonChatEvent;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.util.InventorySlot;
import net.kyori.adventure.text.TextReplacementConfig;
diff --git a/common/src/main/java/net/draycia/carbon/common/listeners/MuteHandler.java b/common/src/main/java/net/draycia/carbon/common/listeners/MuteHandler.java
index 3a1462d5..a1714005 100644
--- a/common/src/main/java/net/draycia/carbon/common/listeners/MuteHandler.java
+++ b/common/src/main/java/net/draycia/carbon/common/listeners/MuteHandler.java
@@ -20,8 +20,8 @@
package net.draycia.carbon.common.listeners;
import com.google.inject.Inject;
-import net.draycia.carbon.api.events.CarbonChatEvent;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.KeyedRenderer;
import net.draycia.carbon.common.messages.CarbonMessages;
diff --git a/common/src/main/java/net/draycia/carbon/common/listeners/PingHandler.java b/common/src/main/java/net/draycia/carbon/common/listeners/PingHandler.java
index 1b545696..df0ab478 100644
--- a/common/src/main/java/net/draycia/carbon/common/listeners/PingHandler.java
+++ b/common/src/main/java/net/draycia/carbon/common/listeners/PingHandler.java
@@ -22,8 +22,8 @@ package net.draycia.carbon.common.listeners;
import com.google.inject.Inject;
import java.util.Optional;
import java.util.regex.Pattern;
-import net.draycia.carbon.api.events.CarbonChatEvent;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.KeyedRenderer;
import net.draycia.carbon.common.config.ConfigFactory;
diff --git a/common/src/main/java/net/draycia/carbon/common/listeners/RadiusListener.java b/common/src/main/java/net/draycia/carbon/common/listeners/RadiusListener.java
index 4a543c74..a95cfa9f 100644
--- a/common/src/main/java/net/draycia/carbon/common/listeners/RadiusListener.java
+++ b/common/src/main/java/net/draycia/carbon/common/listeners/RadiusListener.java
@@ -20,8 +20,8 @@
package net.draycia.carbon.common.listeners;
import com.google.inject.Inject;
-import net.draycia.carbon.api.events.CarbonChatEvent;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.common.messages.CarbonMessages;
import org.checkerframework.checker.nullness.qual.NonNull;
diff --git a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageSender.java b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageSender.java
index da56afda..600150a1 100644
--- a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageSender.java
+++ b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageSender.java
@@ -19,10 +19,8 @@
*/
package net.draycia.carbon.common.messages;
-import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.SourcedAudience;
import net.kyori.adventure.audience.Audience;
-import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.moonshine.message.IMessageSender;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -34,13 +32,9 @@ public class CarbonMessageSender implements IMessageSender
@Override
public void send(final Audience receiver, final Component renderedMessage) {
if (receiver instanceof SourcedAudience sourcedAudience) {
- if (sourcedAudience.sender() instanceof CarbonPlayer sender && !sender.hasPermission("carbon.hideidentity")) {
- sourcedAudience.recipient().sendMessage(Identity.identity(sender.uuid()), renderedMessage);
- } else {
- sourcedAudience.recipient().sendMessage(Identity.nil(), renderedMessage);
- }
+ sourcedAudience.recipient().sendMessage(renderedMessage);
} else {
- receiver.sendMessage(Identity.nil(), renderedMessage);
+ receiver.sendMessage(renderedMessage);
}
}
diff --git a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageSource.java b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageSource.java
index 91c06c18..316739b2 100644
--- a/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageSource.java
+++ b/common/src/main/java/net/draycia/carbon/common/messages/CarbonMessageSource.java
@@ -47,12 +47,12 @@ import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import net.draycia.carbon.api.events.CarbonEventHandler;
+import net.draycia.carbon.api.event.CarbonEventHandler;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.common.DataDirectory;
import net.draycia.carbon.common.command.PlayerCommander;
import net.draycia.carbon.common.config.ConfigFactory;
-import net.draycia.carbon.common.events.CarbonReloadEvent;
+import net.draycia.carbon.common.event.events.CarbonReloadEvent;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.translation.Translator;
import net.kyori.moonshine.message.IMessageSource;
diff --git a/common/src/main/java/net/draycia/carbon/common/messages/SourcedMessageSender.java b/common/src/main/java/net/draycia/carbon/common/messages/SourcedMessageSender.java
index 3b8ce3ee..386e86ba 100644
--- a/common/src/main/java/net/draycia/carbon/common/messages/SourcedMessageSender.java
+++ b/common/src/main/java/net/draycia/carbon/common/messages/SourcedMessageSender.java
@@ -19,9 +19,7 @@
*/
package net.draycia.carbon.common.messages;
-import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.SourcedAudience;
-import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.moonshine.message.IMessageSender;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -32,11 +30,7 @@ public class SourcedMessageSender implements IMessageSender renderer,
final Provider messagingManagerProvider,
diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabricModule.java b/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabricModule.java
index 557269f5..cb4244d2 100644
--- a/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabricModule.java
+++ b/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabricModule.java
@@ -96,12 +96,14 @@ public final class CarbonChatFabricModule extends AbstractModule {
@Provides
@Singleton
+ @SuppressWarnings("unchecked,unused")
public IMessageRenderer messageRenderer(final Injector injector) {
return injector.getInstance(FabricMessageRenderer.class);
}
@Provides
@Singleton
+ @SuppressWarnings("unchecked,unused")
public IMessageRenderer sourcedRenderer(final Injector injector) {
return injector.getInstance(FabricMessageRenderer.class);
}
diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/CarbonServerFabric.java b/fabric/src/main/java/net/draycia/carbon/fabric/CarbonServerFabric.java
index ab43e7f7..ab235322 100644
--- a/fabric/src/main/java/net/draycia/carbon/fabric/CarbonServerFabric.java
+++ b/fabric/src/main/java/net/draycia/carbon/fabric/CarbonServerFabric.java
@@ -25,8 +25,6 @@ import java.util.List;
import java.util.Objects;
import net.draycia.carbon.api.CarbonServer;
import net.draycia.carbon.api.users.CarbonPlayer;
-import net.draycia.carbon.api.users.UserManager;
-import net.draycia.carbon.fabric.users.CarbonPlayerFabric;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.ForwardingAudience;
import net.kyori.adventure.platform.fabric.FabricServerAudiences;
@@ -65,9 +63,4 @@ public final class CarbonServerFabric implements CarbonServer, ForwardingAudienc
.toList();
}
- @Override
- public UserManager userManager() {
- return this.userManager;
- }
-
}
diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricChatHandler.java b/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricChatHandler.java
index 62db542b..c483d0f6 100644
--- a/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricChatHandler.java
+++ b/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricChatHandler.java
@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.Map;
import java.util.regex.Pattern;
import net.draycia.carbon.api.channels.ChannelRegistry;
-import net.draycia.carbon.api.events.CarbonChatEvent;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.KeyedRenderer;
import net.draycia.carbon.common.config.ConfigFactory;
@@ -48,7 +48,6 @@ import org.jetbrains.annotations.Nullable;
import static java.util.Objects.requireNonNullElse;
import static net.draycia.carbon.api.util.KeyedRenderer.keyedRenderer;
import static net.kyori.adventure.key.Key.key;
-import static net.kyori.adventure.text.Component.empty;
public class FabricChatHandler implements ServerMessageEvents.AllowChatMessage {
@@ -115,22 +114,9 @@ public class FabricChatHandler implements ServerMessageEvents.AllowChatMessage {
final var recipients = channel.recipients(sender);
final var chatEvent = new CarbonChatEvent(sender, message, recipients, renderers, channel, null);
- final var result = this.carbonChat.eventHandler().emit(chatEvent);
-
- if (!result.wasSuccessful() || chatEvent.result().cancelled()) {
- if (!result.exceptions().isEmpty()) {
- for (final var entry : result.exceptions().entrySet()) {
- this.carbonChat.logger().error("Exception in event handler: " + entry.getKey().getClass().getName());
- entry.getValue().printStackTrace();
- }
- }
-
- final var failure = chatEvent.result().reason();
-
- if (!failure.equals(empty())) {
- sender.sendMessage(failure);
- }
+ this.carbonChat.eventHandler().emit(chatEvent);
+ if (chatEvent.cancelled()) {
return false;
}
diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/mixin/RegistryDataLoaderMixin.java b/fabric/src/main/java/net/draycia/carbon/fabric/mixin/RegistryDataLoaderMixin.java
index d63ce596..f28e6399 100644
--- a/fabric/src/main/java/net/draycia/carbon/fabric/mixin/RegistryDataLoaderMixin.java
+++ b/fabric/src/main/java/net/draycia/carbon/fabric/mixin/RegistryDataLoaderMixin.java
@@ -50,7 +50,7 @@ abstract class RegistryDataLoaderMixin {
),
locals = LocalCapture.CAPTURE_FAILEXCEPTION
)
- @SuppressWarnings("unchecked")
+ @SuppressWarnings("unchecked,rawtypes")
private static void carbon$injectMessageTypes(
final ResourceManager resourceManager,
final RegistryAccess registryAccess,
diff --git a/gradle/libs.versions.yml b/gradle/libs.versions.yml
index 69067233..b24e37a4 100644
--- a/gradle/libs.versions.yml
+++ b/gradle/libs.versions.yml
@@ -27,7 +27,7 @@ versions:
paperApi: 1.19.4-R0.1-SNAPSHOT
paperTrail: 0.0.1-SNAPSHOT
foliaApi: 1.19.4-R0.1-SNAPSHOT
- kyoriEventApi: 5.0.0-SNAPSHOT
+ event: 1.0.0-SNAPSHOT
kyoriRegistry: 1.0.0-SNAPSHOT
kyoriMoonshine: 2.0.4
log4j: 2.17.2
@@ -101,10 +101,11 @@ dependencies:
group: org.apache.logging.log4j
name: log4j-api
- kyoriEventApi:
- group: net.kyori
+ event:
+ group: com.seiama
name: event-api
- version: { ref: kyoriEventApi }
+ version: { ref: event }
+
kyoriRegistry:
group: net.kyori
name: registry
diff --git a/paper/src/main/java/net/draycia/carbon/paper/CarbonChatPaper.java b/paper/src/main/java/net/draycia/carbon/paper/CarbonChatPaper.java
index 28180abb..5e0d27ae 100644
--- a/paper/src/main/java/net/draycia/carbon/paper/CarbonChatPaper.java
+++ b/paper/src/main/java/net/draycia/carbon/paper/CarbonChatPaper.java
@@ -28,12 +28,12 @@ import java.nio.file.Path;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import net.draycia.carbon.api.CarbonServer;
-import net.draycia.carbon.api.events.CarbonEventHandler;
import net.draycia.carbon.common.CarbonChatInternal;
import net.draycia.carbon.common.DataDirectory;
import net.draycia.carbon.common.PeriodicTasks;
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
import net.draycia.carbon.common.command.commands.ExecutionCoordinatorHolder;
+import net.draycia.carbon.common.event.CarbonEventHandlerImpl;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.messaging.MessagingManager;
import net.draycia.carbon.common.users.ProfileCache;
@@ -71,7 +71,7 @@ public final class CarbonChatPaper extends CarbonChatInternal
final Injector injector,
final JavaPlugin plugin,
final CarbonMessages carbonMessages,
- final CarbonEventHandler eventHandler,
+ final CarbonEventHandlerImpl eventHandler,
final CarbonChannelRegistry channelRegistry,
final Provider messagingManager,
final CarbonServer carbonServer,
diff --git a/paper/src/main/java/net/draycia/carbon/paper/CarbonChatPaperModule.java b/paper/src/main/java/net/draycia/carbon/paper/CarbonChatPaperModule.java
index aa250e9d..5b71d651 100644
--- a/paper/src/main/java/net/draycia/carbon/paper/CarbonChatPaperModule.java
+++ b/paper/src/main/java/net/draycia/carbon/paper/CarbonChatPaperModule.java
@@ -71,6 +71,7 @@ public final class CarbonChatPaperModule extends AbstractModule {
@Provides
@Singleton
+ @SuppressWarnings("unused")
public CommandManager commandManager(final UserManager> userManager, final CarbonMessages messages, final ExecutionCoordinatorHolder executionCoordinatorHolder) {
final PaperCommandManager commandManager;
@@ -107,12 +108,14 @@ public final class CarbonChatPaperModule extends AbstractModule {
@Provides
@Singleton
+ @SuppressWarnings("unchecked,unused")
public IMessageRenderer messageRenderer(final Injector injector) {
return injector.getInstance(PaperMessageRenderer.class);
}
@Provides
@Singleton
+ @SuppressWarnings("unchecked,unused")
public IMessageRenderer sourcedRenderer(final Injector injector) {
return injector.getInstance(PaperMessageRenderer.class);
}
diff --git a/paper/src/main/java/net/draycia/carbon/paper/CarbonServerPaper.java b/paper/src/main/java/net/draycia/carbon/paper/CarbonServerPaper.java
index 31dae15c..87fc53c4 100644
--- a/paper/src/main/java/net/draycia/carbon/paper/CarbonServerPaper.java
+++ b/paper/src/main/java/net/draycia/carbon/paper/CarbonServerPaper.java
@@ -25,8 +25,6 @@ import java.util.List;
import java.util.Objects;
import net.draycia.carbon.api.CarbonServer;
import net.draycia.carbon.api.users.CarbonPlayer;
-import net.draycia.carbon.api.users.UserManager;
-import net.draycia.carbon.paper.users.CarbonPlayerPaper;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.ForwardingAudience;
import org.bukkit.Server;
@@ -64,11 +62,6 @@ public final class CarbonServerPaper implements CarbonServer, ForwardingAudience
.toList();
}
- @Override
- public UserManager userManager() {
- return this.userManager;
- }
-
public static boolean isFolia() {
try {
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
diff --git a/paper/src/main/java/net/draycia/carbon/paper/command/DeleteMessageCommand.java b/paper/src/main/java/net/draycia/carbon/paper/command/DeleteMessageCommand.java
index 4d99ba67..f58aaa79 100644
--- a/paper/src/main/java/net/draycia/carbon/paper/command/DeleteMessageCommand.java
+++ b/paper/src/main/java/net/draycia/carbon/paper/command/DeleteMessageCommand.java
@@ -27,7 +27,7 @@ import com.github.benmanes.caffeine.cache.Caffeine;
import com.google.inject.Inject;
import java.util.UUID;
import net.draycia.carbon.api.CarbonChat;
-import net.draycia.carbon.api.events.CarbonChatEvent;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.common.command.CarbonCommand;
import net.draycia.carbon.common.command.CommandSettings;
diff --git a/paper/src/main/java/net/draycia/carbon/paper/hooks/DSRVChatHook.java b/paper/src/main/java/net/draycia/carbon/paper/hooks/DSRVChatHook.java
index eb858e7b..af736308 100644
--- a/paper/src/main/java/net/draycia/carbon/paper/hooks/DSRVChatHook.java
+++ b/paper/src/main/java/net/draycia/carbon/paper/hooks/DSRVChatHook.java
@@ -31,7 +31,7 @@ import github.scarsz.discordsrv.util.PluginUtil;
import java.time.Duration;
import net.draycia.carbon.api.CarbonChatProvider;
import net.draycia.carbon.api.channels.ChatChannel;
-import net.draycia.carbon.api.events.CarbonChatEvent;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.common.channels.ConfigChatChannel;
import net.draycia.carbon.common.util.ChannelUtils;
@@ -95,7 +95,7 @@ public class DSRVChatHook implements ChatHook {
final String message = PlainTextComponentSerializer.plainText().serialize(eventMessage);
if (player != null) {
- DiscordSRV.getPlugin().processChatMessage(player, message, chatChannel.commandName(), event.result().cancelled());
+ DiscordSRV.getPlugin().processChatMessage(player, message, chatChannel.commandName(), event.cancelled());
}
});
diff --git a/paper/src/main/java/net/draycia/carbon/paper/listeners/PaperChatListener.java b/paper/src/main/java/net/draycia/carbon/paper/listeners/PaperChatListener.java
index 166b9523..1830f6c5 100644
--- a/paper/src/main/java/net/draycia/carbon/paper/listeners/PaperChatListener.java
+++ b/paper/src/main/java/net/draycia/carbon/paper/listeners/PaperChatListener.java
@@ -24,7 +24,7 @@ import io.papermc.paper.event.player.AsyncChatEvent;
import java.util.ArrayList;
import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.api.channels.ChannelRegistry;
-import net.draycia.carbon.api.events.CarbonChatEvent;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.util.KeyedRenderer;
import net.draycia.carbon.common.channels.ConfigChatChannel;
@@ -47,7 +47,6 @@ import static java.util.Objects.requireNonNullElse;
import static net.draycia.carbon.api.util.KeyedRenderer.keyedRenderer;
import static net.draycia.carbon.common.util.Strings.URL_REPLACEMENT_CONFIG;
import static net.kyori.adventure.key.Key.key;
-import static net.kyori.adventure.text.Component.empty;
@DefaultQualifier(NonNull.class)
public final class PaperChatListener implements Listener {
@@ -97,21 +96,11 @@ public final class PaperChatListener implements Listener {
final var recipients = channel.recipients(sender);
final var chatEvent = new CarbonChatEvent(sender, eventMessage, recipients, renderers, channel, event.signedMessage());
- final var result = this.carbonChat.eventHandler().emit(chatEvent);
+ this.carbonChat.eventHandler().emit(chatEvent);
- if (!result.wasSuccessful() || chatEvent.result().cancelled()) {
- if (!result.exceptions().isEmpty()) {
- for (final var entry : result.exceptions().entrySet()) {
- this.carbonChat.logger().error("Exception in event handler: " + entry.getKey().getClass().getName());
- entry.getValue().printStackTrace();
- }
- }
-
- final var failure = chatEvent.result().reason();
-
- if (!failure.equals(empty())) {
- sender.sendMessage(failure);
- }
+ if (chatEvent.cancelled()) {
+ event.setCancelled(true);
+ return;
}
try {
diff --git a/sponge/src/main/java/net/draycia/carbon/sponge/listeners/SpongeReloadListener.java b/sponge/src/main/java/net/draycia/carbon/sponge/listeners/SpongeReloadListener.java
index 0c5b5743..969cc16c 100644
--- a/sponge/src/main/java/net/draycia/carbon/sponge/listeners/SpongeReloadListener.java
+++ b/sponge/src/main/java/net/draycia/carbon/sponge/listeners/SpongeReloadListener.java
@@ -23,7 +23,7 @@ import com.google.inject.Inject;
import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
import net.draycia.carbon.common.config.ConfigFactory;
-import net.draycia.carbon.common.events.CarbonReloadEvent;
+import net.draycia.carbon.common.event.CarbonReloadEvent;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.lifecycle.RefreshGameEvent;
diff --git a/velocity/src/main/java/net/draycia/carbon/velocity/CarbonChatVelocity.java b/velocity/src/main/java/net/draycia/carbon/velocity/CarbonChatVelocity.java
index e4e66696..5125fdb0 100644
--- a/velocity/src/main/java/net/draycia/carbon/velocity/CarbonChatVelocity.java
+++ b/velocity/src/main/java/net/draycia/carbon/velocity/CarbonChatVelocity.java
@@ -30,11 +30,11 @@ import java.nio.file.Path;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import net.draycia.carbon.api.CarbonChatProvider;
-import net.draycia.carbon.api.events.CarbonEventHandler;
import net.draycia.carbon.common.CarbonChatInternal;
import net.draycia.carbon.common.PeriodicTasks;
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
import net.draycia.carbon.common.command.commands.ExecutionCoordinatorHolder;
+import net.draycia.carbon.common.event.CarbonEventHandlerImpl;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.messaging.MessagingManager;
import net.draycia.carbon.common.users.ProfileCache;
@@ -74,7 +74,7 @@ public class CarbonChatVelocity extends CarbonChatInternal
final VelocityUserManager userManager,
final CarbonServerVelocity carbonServer,
final CarbonMessages carbonMessages,
- final CarbonEventHandler eventHandler,
+ final CarbonEventHandlerImpl eventHandler,
final CarbonChannelRegistry channelRegistry,
final Provider messagingManager
) {
diff --git a/velocity/src/main/java/net/draycia/carbon/velocity/CarbonChatVelocityModule.java b/velocity/src/main/java/net/draycia/carbon/velocity/CarbonChatVelocityModule.java
index 522bc8de..354986b9 100644
--- a/velocity/src/main/java/net/draycia/carbon/velocity/CarbonChatVelocityModule.java
+++ b/velocity/src/main/java/net/draycia/carbon/velocity/CarbonChatVelocityModule.java
@@ -97,12 +97,14 @@ public final class CarbonChatVelocityModule extends AbstractModule {
@Provides
@Singleton
+ @SuppressWarnings("unchecked,unused")
public IMessageRenderer messageRenderer(final Injector injector) {
return injector.getInstance(VelocityMessageRenderer.class);
}
@Provides
@Singleton
+ @SuppressWarnings("unchecked,unused")
public IMessageRenderer sourcedRenderer(final Injector injector) {
return injector.getInstance(VelocityMessageRenderer.class);
}
diff --git a/velocity/src/main/java/net/draycia/carbon/velocity/CarbonServerVelocity.java b/velocity/src/main/java/net/draycia/carbon/velocity/CarbonServerVelocity.java
index f3fda76d..9295d963 100644
--- a/velocity/src/main/java/net/draycia/carbon/velocity/CarbonServerVelocity.java
+++ b/velocity/src/main/java/net/draycia/carbon/velocity/CarbonServerVelocity.java
@@ -63,9 +63,4 @@ public final class CarbonServerVelocity implements CarbonServer, ForwardingAudie
.toList();
}
- @Override
- public UserManager extends CarbonPlayer> userManager() {
- return this.userManager;
- }
-
}
diff --git a/velocity/src/main/java/net/draycia/carbon/velocity/listeners/VelocityChatListener.java b/velocity/src/main/java/net/draycia/carbon/velocity/listeners/VelocityChatListener.java
index 7e2ccdf5..dc914127 100644
--- a/velocity/src/main/java/net/draycia/carbon/velocity/listeners/VelocityChatListener.java
+++ b/velocity/src/main/java/net/draycia/carbon/velocity/listeners/VelocityChatListener.java
@@ -29,7 +29,7 @@ import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import net.draycia.carbon.api.CarbonChat;
import net.draycia.carbon.api.channels.ChannelRegistry;
-import net.draycia.carbon.api.events.CarbonChatEvent;
+import net.draycia.carbon.api.event.events.CarbonChatEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.api.users.UserManager;
import net.draycia.carbon.api.util.KeyedRenderer;
@@ -44,7 +44,6 @@ import static java.util.Objects.requireNonNullElse;
import static net.draycia.carbon.api.util.KeyedRenderer.keyedRenderer;
import static net.draycia.carbon.common.util.Strings.URL_REPLACEMENT_CONFIG;
import static net.kyori.adventure.key.Key.key;
-import static net.kyori.adventure.text.Component.empty;
import static net.kyori.adventure.text.Component.text;
@DefaultQualifier(NonNull.class)
@@ -132,21 +131,11 @@ public final class VelocityChatListener {
renderers.add(keyedRenderer(key("carbon", "default"), channel));
final var chatEvent = new CarbonChatEvent(sender, eventMessage, recipients, renderers, channel, null);
- final var result = this.carbonChat.eventHandler().emit(chatEvent);
+ this.carbonChat.eventHandler().emit(chatEvent);
- if (!result.wasSuccessful() || chatEvent.result().cancelled()) {
- if (!result.exceptions().isEmpty()) {
- for (final var entry : result.exceptions().entrySet()) {
- this.carbonChat.logger().error("Exception in event handler: " + entry.getKey().getClass().getName());
- entry.getValue().printStackTrace();
- }
- }
-
- final var failure = chatEvent.result().reason();
-
- if (!failure.equals(empty())) {
- sender.sendMessage(failure);
- }
+ if (chatEvent.cancelled()) {
+ event.setResult(PlayerChatEvent.ChatResult.denied());
+ return;
}
for (final var recipient : chatEvent.recipients()) {