mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
idek anymore dude
This commit is contained in:
1 parent
224c7723d6
commit
8a7ab5f858
9 files changed
+80
-8
No files matched your search
@@ -31,7 +31,7 @@ public interface CarbonChat {
|
||||
.useUnusualXRepeatedCharacterHexFormat()
|
||||
.build();
|
||||
|
||||
void reloadConfig();
|
||||
void reload();
|
||||
|
||||
@NonNull File dataDirectory();
|
||||
|
||||
|
||||
@@ -69,4 +69,9 @@ public class ChannelRegistry implements Registry<String, ChatChannel>, Defaulted
|
||||
public @NonNull ChatChannel getOrDefault(final @NonNull String key) {
|
||||
return this.registry.getOrDefault(key, this.defaultValue());
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.registry.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.draycia.carbon.api.channels;
|
||||
|
||||
import net.draycia.carbon.api.config.ChannelOptions;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
@@ -72,4 +73,8 @@ public interface ChatChannel extends Audience {
|
||||
|
||||
@NonNull String cannotUseMessage();
|
||||
|
||||
@NonNull ChannelOptions options();
|
||||
|
||||
void options(@NonNull ChannelOptions options);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.draycia.carbon.api.channels;
|
||||
|
||||
import net.draycia.carbon.api.Context;
|
||||
import net.draycia.carbon.api.config.ChannelOptions;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
@@ -24,6 +25,16 @@ public class EmptyTextChannel implements TextChannel {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ChannelOptions options() {
|
||||
return ChannelOptions.defaultChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void options(final @NonNull ChannelOptions options) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String format(final @NonNull Group group) {
|
||||
return null;
|
||||
|
||||
@@ -4,6 +4,7 @@ import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.paper.PaperCommandManager;
|
||||
import io.github.leonardosnt.bungeechannelapi.BungeeChannelApi;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.bukkit.listeners.events.BukkitChatListener;
|
||||
import net.draycia.carbon.bukkit.listeners.events.ItemLinkHandler;
|
||||
import net.draycia.carbon.bukkit.messaging.BungeeMessageService;
|
||||
@@ -121,7 +122,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
// Setup metrics
|
||||
final Metrics metrics = new Metrics(this, BSTATS_PLUGIN_ID);
|
||||
|
||||
this.reloadConfig();
|
||||
this.loadConfigs();
|
||||
|
||||
// Setup Adventure
|
||||
final BukkitAudiences audiences = BukkitAudiences.create(this);
|
||||
@@ -248,7 +249,28 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
public void reload() {
|
||||
this.loadConfigs();
|
||||
this.channelManager.reloadChannels();
|
||||
|
||||
final ChatChannel defaultChannel = this.channelManager.defaultChannel();
|
||||
|
||||
for (final PlayerUser user : this.userService().onlineUsers()) {
|
||||
final ChatChannel selectedChannel = user.selectedChannel();
|
||||
|
||||
if (selectedChannel != null) {
|
||||
final ChatChannel channel = this.channelManager.channelOrDefault(selectedChannel.key());
|
||||
|
||||
if (channel != null) {
|
||||
user.selectedChannel(channel);
|
||||
} else if (defaultChannel != null) {
|
||||
user.selectedChannel(defaultChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadConfigs() {
|
||||
this.getDataFolder().mkdir();
|
||||
|
||||
try {
|
||||
@@ -259,8 +281,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
this.channelSettings = ChannelSettings.loadFrom(loader.loadConfig("channels.yml"));
|
||||
this.translations = CarbonTranslations.loadFrom(loader.loadConfig("language.yml"));
|
||||
this.moderationSettings = ModerationSettings.loadFrom(loader.loadConfig("moderation.yml"));
|
||||
} catch(final ConfigurateException ignored) {
|
||||
|
||||
} catch(final ConfigurateException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -38,17 +38,23 @@ public class CarbonChatChannel implements TextChannel {
|
||||
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
private final @NonNull ChannelOptions options;
|
||||
private @NonNull ChannelOptions options;
|
||||
|
||||
public CarbonChatChannel(final @NonNull CarbonChat carbonChat, final @NonNull ChannelOptions options) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NonNull ChannelOptions options() {
|
||||
return this.options;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void options(final @NonNull ChannelOptions options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public @NonNull CarbonChat carbonChat() {
|
||||
return this.carbonChat;
|
||||
}
|
||||
|
||||
+11
@@ -3,6 +3,7 @@ package net.draycia.carbon.common.channels;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.WhisperChannel;
|
||||
import net.draycia.carbon.api.config.ChannelOptions;
|
||||
import net.draycia.carbon.api.events.ChatComponentEvent;
|
||||
import net.draycia.carbon.api.events.ChatFormatEvent;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
@@ -37,6 +38,16 @@ public class CarbonWhisperChannel implements WhisperChannel {
|
||||
this.audience = audience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ChannelOptions options() {
|
||||
return ChannelOptions.defaultChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void options(final @NonNull ChannelOptions options) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull PlayerUser sender() {
|
||||
return this.sender;
|
||||
|
||||
+12
@@ -112,4 +112,16 @@ public class ChannelManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadChannels() {
|
||||
for (final Map.Entry<String, ChannelOptions> options :
|
||||
this.carbonChat.channelSettings().channelOptions().entrySet()) {
|
||||
|
||||
final ChatChannel channel = this.registry().get(options.getValue().key());
|
||||
|
||||
if (channel != null) {
|
||||
channel.options(options.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class ChatReloadCommand {
|
||||
}
|
||||
|
||||
private void reloadConfig(final @NonNull CommandContext<CarbonUser> context) {
|
||||
this.carbonChat.reloadConfig();
|
||||
this.carbonChat.reload();
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor()
|
||||
.processMessage(this.carbonChat.translations().reloaded().replace("br", "\n"));
|
||||
|
||||
Reference in new issue
Block a user