use of com.github.games647.fastlogin.core.message.NamespaceKey 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);
}
}
use of com.github.games647.fastlogin.core.message.NamespaceKey in project ChangeSkin by games647.
the class ChangeSkinBungee method onEnable.
@Override
public void onEnable() {
logger = CommonUtil.createLoggerFromJDK(getLogger());
core = new ChangeSkinCore(this);
try {
core.load(true);
} catch (Exception ioExc) {
logger.error("Error initializing plugin. Disabling...", ioExc);
return;
}
PluginManager pluginManager = getProxy().getPluginManager();
pluginManager.registerListener(this, new ConnectListener(this));
pluginManager.registerListener(this, new ServerSwitchListener(this));
// this is required to listen to incoming messages from the server
getProxy().registerChannel(new NamespaceKey(getName(), PERMISSION_RESULT_CHANNEL).getCombinedName());
getProxy().registerChannel(new NamespaceKey(getName(), FORWARD_COMMAND_CHANNEL).getCombinedName());
pluginManager.registerListener(this, new PluginMessageListener(this));
// register commands
pluginManager.registerCommand(this, new SetCommand(this));
pluginManager.registerCommand(this, new InvalidateCommand(this));
pluginManager.registerCommand(this, new UploadCommand(this));
pluginManager.registerCommand(this, new SelectCommand(this));
pluginManager.registerCommand(this, new InfoCommand(this));
}
use of com.github.games647.fastlogin.core.message.NamespaceKey in project FastLogin by games647.
the class BungeeManager method sendPluginMessage.
public void sendPluginMessage(PluginMessageRecipient player, ChannelMessage message) {
if (player != null) {
ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
message.writeTo(dataOutput);
NamespaceKey channel = new NamespaceKey(plugin.getName(), message.getChannelName());
player.sendPluginMessage(plugin, channel.getCombinedName(), dataOutput.toByteArray());
}
}
use of com.github.games647.fastlogin.core.message.NamespaceKey in project FastLogin by games647.
the class BungeeManager method registerPluginChannels.
private void registerPluginChannels() {
Server server = Bukkit.getServer();
// check for incoming messages from the bungeecord version of this plugin
String groupId = plugin.getName();
String forceChannel = NamespaceKey.getCombined(groupId, LoginActionMessage.FORCE_CHANNEL);
server.getMessenger().registerIncomingPluginChannel(plugin, forceChannel, new BungeeListener(plugin));
// outgoing
String successChannel = new NamespaceKey(groupId, SUCCESS_CHANNEL).getCombinedName();
String changeChannel = new NamespaceKey(groupId, CHANGE_CHANNEL).getCombinedName();
server.getMessenger().registerOutgoingPluginChannel(plugin, successChannel);
server.getMessenger().registerOutgoingPluginChannel(plugin, changeChannel);
}
use of com.github.games647.fastlogin.core.message.NamespaceKey in project ChangeSkin by games647.
the class ChangeSkinSponge method onInit.
@Listener
public void onInit(GameInitializationEvent initEvent) {
if (!initialized)
return;
CommandManager cmdManager = Sponge.getCommandManager();
// command and event register
cmdManager.register(this, injector.getInstance(SelectCommand.class).buildSpec(), "skin-select", "skinselect");
cmdManager.register(this, injector.getInstance(InfoCommand.class).buildSpec(), "skin-info");
cmdManager.register(this, injector.getInstance(UploadCommand.class).buildSpec(), "skin-upload");
cmdManager.register(this, injector.getInstance(SetCommand.class).buildSpec(), "changeskin", "setskin", "skin");
cmdManager.register(this, injector.getInstance(InvalidateCommand.class).buildSpec(), "skininvalidate", "skin-invalidate");
Sponge.getEventManager().registerListeners(this, injector.getInstance(LoginListener.class));
// incoming channel
ChannelRegistrar channelReg = Sponge.getChannelRegistrar();
String updateChannelName = new NamespaceKey(ARTIFACT_ID, UPDATE_SKIN_CHANNEL).getCombinedName();
String permissionChannelName = new NamespaceKey(ARTIFACT_ID, CHECK_PERM_CHANNEL).getCombinedName();
RawDataChannel updateChannel = channelReg.getOrCreateRaw(this, updateChannelName);
RawDataChannel permChannel = channelReg.getOrCreateRaw(this, permissionChannelName);
updateChannel.addListener(Type.SERVER, injector.getInstance(UpdateSkinListener.class));
permChannel.addListener(Type.SERVER, injector.getInstance(CheckPermissionListener.class));
}
Aggregations