Search in sources :

Example 1 with CheckPermissionListener

use of com.github.games647.changeskin.bukkit.bungee.CheckPermissionListener in project ChangeSkin by games647.

the class ChangeSkinBukkit method onEnable.

@Override
public void onEnable() {
    try {
        bungeeCord = getServer().spigot().getConfig().getBoolean("settings.bungeecord");
    } catch (Exception | NoSuchMethodError ex) {
        logger.warn("Cannot check bungeecord support. You use a non-Spigot build");
    }
    registerCommands();
    try {
        core.load(!bungeeCord);
    } catch (Exception ex) {
        logger.error("Error initializing plugin. Disabling...", ex);
        setEnabled(false);
        return;
    }
    if (bungeeCord) {
        logger.info("BungeeCord detected. Activating BungeeCord support");
        logger.info("Make sure you installed the plugin on BungeeCord too");
        // outgoing
        Messenger messenger = getServer().getMessenger();
        String permissionResultChannel = new NamespaceKey(getName(), PERMISSION_RESULT_CHANNEL).getCombinedName();
        String forwardChannel = new NamespaceKey(getName(), FORWARD_COMMAND_CHANNEL).getCombinedName();
        messenger.registerOutgoingPluginChannel(this, permissionResultChannel);
        messenger.registerOutgoingPluginChannel(this, forwardChannel);
        // incoming
        String updateChannel = new NamespaceKey(getName(), UPDATE_SKIN_CHANNEL).getCombinedName();
        String permissionChannel = new NamespaceKey(getName(), CHECK_PERM_CHANNEL).getCombinedName();
        messenger.registerIncomingPluginChannel(this, updateChannel, new SkinUpdateListener(this));
        messenger.registerIncomingPluginChannel(this, permissionChannel, new CheckPermissionListener(this));
    } else {
        getServer().getPluginManager().registerEvents(new LoginListener(this), this);
    }
}
Also used : NamespaceKey(com.github.games647.changeskin.core.message.NamespaceKey) SkinUpdateListener(com.github.games647.changeskin.bukkit.bungee.SkinUpdateListener) Messenger(org.bukkit.plugin.messaging.Messenger) CheckPermissionListener(com.github.games647.changeskin.bukkit.bungee.CheckPermissionListener)

Aggregations

CheckPermissionListener (com.github.games647.changeskin.bukkit.bungee.CheckPermissionListener)1 SkinUpdateListener (com.github.games647.changeskin.bukkit.bungee.SkinUpdateListener)1 NamespaceKey (com.github.games647.changeskin.core.message.NamespaceKey)1 Messenger (org.bukkit.plugin.messaging.Messenger)1