Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Local Default Channel - Version 10 #166

Open
wants to merge 2 commits into
base: ten
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public abstract class LocalConfig {
// SERVER SETTINGS
private String serverName;

private String defaultChannel;

// GLOBAL CHAT SETTINGS
private boolean overrideGlobalFormat;
private String overrideGlobalFormatFormat;
Expand Down Expand Up @@ -118,6 +120,8 @@ private void setMemberAttributes() {
// Server
serverName = getString("server_name","SPIGOT_SERVER");

defaultChannel = getString("default_channel","global");

// Global Chat
overrideGlobalFormat = getBoolean("override_global_format", false);
overrideGlobalFormatFormat = getString("override_global_format_format", "&5[&dG&5] &f%DISPLAYNAME%&f: ");
Expand Down Expand Up @@ -181,7 +185,14 @@ public LocalConfigStatus reload() {
public String getServerName() {
return serverName;
}


/**
* @return the defaultChannel
*/
public String getDefaultChannel() {
return defaultChannel;
}

/**
* @return the overrideGlobalFormat
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
public abstract class LocalLoginLogoutListener {

protected abstract boolean isPlayerStillOnline(MultiChatLocalPlayer player);

protected void handleLoginEvent(MultiChatLocalPlayer player) {

MultiChatLocal.getInstance().getNameManager().registerPlayer(player.getUniqueId(), player.getName());

String defaultChannel = MultiChatLocal.getInstance().getConfigManager().getLocalConfig().getDefaultChannel();

Map<UUID, String> playerChannels = MultiChatLocal.getInstance().getDataStore().getPlayerChannels();
synchronized (playerChannels) {
if (!playerChannels.containsKey(player.getUniqueId())) {
playerChannels.put(player.getUniqueId(), "global");
playerChannels.put(player.getUniqueId(), defaultChannel);
}
}

Expand Down
3 changes: 3 additions & 0 deletions multichat/src/main/resources/localconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ version: "1.10" #
# Specify the name of this server here for the %SERVER% placeholder
server_name: "UNNAMED_SERVER"

# Specify the channel the user should connect to when first joining (local / global)
default_channel: "global"

############################################################
# +------------------------------------------------------+ #
# | Global | #
Expand Down