mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
Small tweaks
This commit is contained in:
1 parent
6bdcc15bca
commit
b393d7c5ec
4 files changed
+18
-13
No files matched your search
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.channels;
|
||||
|
||||
import co.aikar.commands.CommandManager;
|
||||
import co.aikar.commands.BukkitCommandManager;
|
||||
import net.draycia.carbon.CarbonChat;
|
||||
import net.draycia.carbon.commands.AliasedChannelCommand;
|
||||
import net.draycia.carbon.util.Registry;
|
||||
@@ -9,13 +9,13 @@ import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class ChannelRegistry implements Registry<ChatChannel> {
|
||||
|
||||
private final Map<String, ChatChannel> registry = new HashMap<>();
|
||||
private final List<AliasedChannelCommand> channelCommands = new ArrayList<>();
|
||||
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ChannelRegistry(CarbonChat carbonChat) {
|
||||
@@ -27,10 +27,13 @@ public class ChannelRegistry implements Registry<ChatChannel> {
|
||||
boolean registerSuccessful = registry.putIfAbsent(key, value) == null;
|
||||
|
||||
if (registerSuccessful) {
|
||||
CommandManager commandManager = carbonChat.getCommandManager().getCommandManager();
|
||||
|
||||
BukkitCommandManager commandManager = carbonChat.getCommandManager().getCommandManager();
|
||||
commandManager.getCommandReplacements().addReplacement("channelName", value.getAliases());
|
||||
commandManager.registerCommand(new AliasedChannelCommand(value));
|
||||
|
||||
AliasedChannelCommand command = new AliasedChannelCommand(value);
|
||||
|
||||
commandManager.registerCommand(command);
|
||||
channelCommands.add(command);
|
||||
|
||||
if (value instanceof Listener) {
|
||||
Bukkit.getPluginManager().registerEvents((Listener)value, carbonChat);
|
||||
@@ -55,6 +58,11 @@ public class ChannelRegistry implements Registry<ChatChannel> {
|
||||
@Override
|
||||
public void clearAll() {
|
||||
registry.clear();
|
||||
|
||||
for (AliasedChannelCommand command : channelCommands) {
|
||||
carbonChat.getLogger().info("Unregistering command for channel: " + command.getChatChannel().getName());
|
||||
carbonChat.getCommandManager().getCommandManager().unregisterCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user