@Override public void onEnable() { registerVariables(); getServer().getMessenger().registerOutgoingPluginChannel(this, Constants.channel); getServer().getMessenger().registerIncomingPluginChannel(this, Constants.channel, new PluginMessageListener() { @Override @SneakyThrows public void onPluginMessageReceived(String string, Player player, byte[] bytes) { try { ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes)); Object object = in.readObject(); Class c = Class.forName((String) object); Constructor[] constructors = c.getConstructors(); if (constructors.length == 1) { Object[] args = (Object[]) in.readObject(); BukkitTask task = (BukkitTask) constructors[0].newInstance(args); task.execute(FreeBungeeChatBukkit.this, player); } else { getLogger().severe("received invalid task from bungee: " + c); } } catch (Throwable th) { getLogger().log(Level.SEVERE, "failed to parse data from bungee", th); } } }); getServer().getPluginManager().registerEvents(this, this); initPlayerConnections(); }
@Override public PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { throw new UnsupportedOperationException(); }
@Override public void unregisterIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { throw new UnsupportedOperationException(); }
@Override public PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { return new PluginMessageListenerRegistration(this, plugin, channel, listener); }
@Override public void unregisterIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { // Do nothing }
@Override public PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { return null; //To change body of implemented methods use File | Settings | File Templates. }
@Override public void unregisterIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { //To change body of implemented methods use File | Settings | File Templates. }
public PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { return null; }
public void unregisterIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener) { }
public PluginMessageListenerRegistration(Messenger messenger, Plugin plugin, String channel, PluginMessageListener listener) { }
public PluginMessageListener getListener() { return null; }
PluginMessageListenerRegistration registerIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener);
void unregisterIncomingPluginChannel(Plugin plugin, String channel, PluginMessageListener listener);