diff --git a/api/src/main/java/net/draycia/carbon/api/event/events/ChannelSwitchEvent.java b/api/src/main/java/net/draycia/carbon/api/event/events/ChannelSwitchEvent.java
new file mode 100644
index 00000000..cd272dc0
--- /dev/null
+++ b/api/src/main/java/net/draycia/carbon/api/event/events/ChannelSwitchEvent.java
@@ -0,0 +1,58 @@
+/*
+ * CarbonChat
+ *
+ * Copyright (c) 2024 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.event.events;
+
+import net.draycia.carbon.api.channels.ChatChannel;
+import net.draycia.carbon.api.event.CarbonEvent;
+import net.draycia.carbon.api.users.CarbonPlayer;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+
+/**
+ * Called when a player switches channels.
+ *
+ * @since 3.0.0
+ */
+@DefaultQualifier(NonNull.class)
+public interface ChannelSwitchEvent extends CarbonEvent {
+
+ /**
+ * The player switching channels.
+ *
+ * @since 3.0.0
+ */
+ CarbonPlayer player();
+
+ /**
+ * The channel the player is switching to.
+ *
+ * @since 3.0.0
+ */
+ ChatChannel channel();
+
+ /**
+ * Sets the player's new channel.
+ *
+ * @param chatChannel the new channel
+ * @since 3.0.0
+ */
+ void channel(final ChatChannel chatChannel);
+
+}
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 f36cab81..b147558c 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
@@ -48,6 +48,7 @@ import net.draycia.carbon.api.channels.ChannelRegistry;
import net.draycia.carbon.api.channels.ChatChannel;
import net.draycia.carbon.api.event.CarbonEventHandler;
import net.draycia.carbon.api.event.events.CarbonChannelRegisterEvent;
+import net.draycia.carbon.api.event.events.ChannelSwitchEvent;
import net.draycia.carbon.api.users.CarbonPlayer;
import net.draycia.carbon.common.DataDirectory;
import net.draycia.carbon.common.command.Commander;
@@ -56,6 +57,7 @@ import net.draycia.carbon.common.config.ConfigManager;
import net.draycia.carbon.common.event.events.CarbonChatEventImpl;
import net.draycia.carbon.common.event.events.CarbonReloadEvent;
import net.draycia.carbon.common.event.events.ChannelRegisterEventImpl;
+import net.draycia.carbon.common.event.events.ChannelSwitchEventImpl;
import net.draycia.carbon.common.listeners.ChatListenerInternal;
import net.draycia.carbon.common.messages.CarbonMessages;
import net.draycia.carbon.common.users.ConsoleCarbonPlayer;
@@ -399,7 +401,10 @@ public class CarbonChannelRegistry extends ChatListenerInternal implements Chann
// TODO: trigger platform events related to chat
this.sendMessageInChannel(player, chatChannel, message);
} else {
- player.selectedChannel(chatChannel);
+ final ChannelSwitchEvent switchEvent = new ChannelSwitchEventImpl(player, chatChannel);
+ this.eventHandler.emit(switchEvent);
+
+ player.selectedChannel(switchEvent.channel());
this.carbonMessages.changedChannels(player, channelKey.value());
}
})
diff --git a/common/src/main/java/net/draycia/carbon/common/channels/PartyChatChannel.java b/common/src/main/java/net/draycia/carbon/common/channels/PartyChatChannel.java
index f4987897..2b3c0a2c 100644
--- a/common/src/main/java/net/draycia/carbon/common/channels/PartyChatChannel.java
+++ b/common/src/main/java/net/draycia/carbon/common/channels/PartyChatChannel.java
@@ -111,4 +111,5 @@ public class PartyChatChannel extends ConfigChatChannel {
party == null ? Component.text("null") : party.name()
);
}
+
}
diff --git a/common/src/main/java/net/draycia/carbon/common/config/IntegrationConfigContainer.java b/common/src/main/java/net/draycia/carbon/common/config/IntegrationConfigContainer.java
index 3aa32ae9..14960c42 100644
--- a/common/src/main/java/net/draycia/carbon/common/config/IntegrationConfigContainer.java
+++ b/common/src/main/java/net/draycia/carbon/common/config/IntegrationConfigContainer.java
@@ -97,4 +97,5 @@ public final class IntegrationConfigContainer {
return container;
}
}
+
}
diff --git a/common/src/main/java/net/draycia/carbon/common/event/events/ChannelSwitchEventImpl.java b/common/src/main/java/net/draycia/carbon/common/event/events/ChannelSwitchEventImpl.java
new file mode 100644
index 00000000..0231f6df
--- /dev/null
+++ b/common/src/main/java/net/draycia/carbon/common/event/events/ChannelSwitchEventImpl.java
@@ -0,0 +1,54 @@
+/*
+ * CarbonChat
+ *
+ * Copyright (c) 2024 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.events;
+
+import net.draycia.carbon.api.channels.ChatChannel;
+import net.draycia.carbon.api.event.events.ChannelSwitchEvent;
+import net.draycia.carbon.api.users.CarbonPlayer;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.framework.qual.DefaultQualifier;
+
+@DefaultQualifier(NonNull.class)
+public class ChannelSwitchEventImpl implements ChannelSwitchEvent {
+
+ private final CarbonPlayer player;
+ private ChatChannel chatChannel;
+
+ public ChannelSwitchEventImpl(final CarbonPlayer player, final ChatChannel chatChannel) {
+ this.player = player;
+ this.chatChannel = chatChannel;
+ }
+
+ @Override
+ public CarbonPlayer player() {
+ return this.player;
+ }
+
+ @Override
+ public ChatChannel channel() {
+ return this.chatChannel;
+ }
+
+ @Override
+ public void channel(final ChatChannel chatChannel) {
+ this.chatChannel = chatChannel;
+ }
+
+}
diff --git a/common/src/main/java/net/draycia/carbon/common/integration/miniplaceholders/MiniPlaceholdersExpansion.java b/common/src/main/java/net/draycia/carbon/common/integration/miniplaceholders/MiniPlaceholdersExpansion.java
index 2ffc81d5..bd07dc9b 100644
--- a/common/src/main/java/net/draycia/carbon/common/integration/miniplaceholders/MiniPlaceholdersExpansion.java
+++ b/common/src/main/java/net/draycia/carbon/common/integration/miniplaceholders/MiniPlaceholdersExpansion.java
@@ -117,4 +117,5 @@ public final class MiniPlaceholdersExpansion {
}
return this.channels.defaultKey().asString();
}
+
}
diff --git a/common/src/main/java/net/draycia/carbon/common/messages/TagPermissions.java b/common/src/main/java/net/draycia/carbon/common/messages/TagPermissions.java
index b3e4e4c7..f0780582 100644
--- a/common/src/main/java/net/draycia/carbon/common/messages/TagPermissions.java
+++ b/common/src/main/java/net/draycia/carbon/common/messages/TagPermissions.java
@@ -82,4 +82,5 @@ public final class TagPermissions {
public static Component parseTags(final String basePermission, final String message, final Predicate permission) {
return parseTags(basePermission, message, permission, TagResolver.builder());
}
+
}
diff --git a/common/src/main/java/net/draycia/carbon/common/users/CachingUserManager.java b/common/src/main/java/net/draycia/carbon/common/users/CachingUserManager.java
index b2aebd40..dfb1a975 100644
--- a/common/src/main/java/net/draycia/carbon/common/users/CachingUserManager.java
+++ b/common/src/main/java/net/draycia/carbon/common/users/CachingUserManager.java
@@ -335,4 +335,5 @@ public abstract class CachingUserManager implements UserManagerInternal