diff --git a/src/main/java/net/draycia/carbon/listeners/PlayerJoinListener.java b/src/main/java/net/draycia/carbon/listeners/PlayerJoinListener.java index 8e43d2d5..f7467a24 100644 --- a/src/main/java/net/draycia/carbon/listeners/PlayerJoinListener.java +++ b/src/main/java/net/draycia/carbon/listeners/PlayerJoinListener.java @@ -1,6 +1,7 @@ package net.draycia.carbon.listeners; import net.draycia.carbon.CarbonChat; +import net.draycia.carbon.channels.ChatChannel; import net.draycia.carbon.storage.ChatUser; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -24,6 +25,23 @@ public class PlayerJoinListener implements Listener { if (user.getNickname() != null) { user.setNickname(user.getNickname()); } + + String channel = carbonChat.getConfig().getString("channel-on-join"); + + if (channel == null || channel.isEmpty()) { + return; + } + + if (channel.equals("DEFAULT")) { + user.setSelectedChannel(carbonChat.getChannelManager().getDefaultChannel()); + return; + } + + ChatChannel chatChannel = carbonChat.getChannelManager().getRegistry().get(channel); + + if (chatChannel != null) { + user.setSelectedChannel(chatChannel); + } } @EventHandler diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 98a76ef6..8ad54373 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -99,6 +99,13 @@ placeholders: prefix: "[]" group: "%vault_group%" +# Sets the player's channel to the specified channel when they join +# Set to "" or remove to disable +# Set to DEFAULT to set the player's channel to the default channel on join +# Otherwise, set to a channel to set the player's channel to it on join +# For example, channel-on-join: "global" sets their channel to global on join +channel-on-join: "" + # Global context options contexts: Towny: