protected void registerHooks() { this.playerListener = new PlayerListener(this); if (VersionHelper.hasRequiredVersion("1.4.7")) this.dynamicPlayerListener = new DynamicPlayerListener_1_5(this, playerListener); else this.dynamicPlayerListener = new DynamicPlayerListener_1_4_2(this, playerListener); this.dynamicVehicleListener = new DynamicVehicleListener(this); final CrazyListener crazylistener = new CrazyListener(this, playerListener); final PluginManager pm = Bukkit.getPluginManager(); pm.registerEvents(playerListener, this); pm.registerEvents(crazylistener, this); pm.registerEvents(new WorldListener(this), this); registerDynamicHooks(); messageListener = new MessageListener(this); final Messenger ms = getServer().getMessenger(); ms.registerIncomingPluginChannel(this, "CrazyLogin", messageListener); ms.registerOutgoingPluginChannel(this, "CrazyLogin"); }
@Nullable public static String getOutput(@Nullable Object object) { if (object == null) { return null; } if (object instanceof String) { return (String) object; } else if (object instanceof Collection) { return handleCollection((Collection) object); } else if (object instanceof Map) { return handleMap((Map) object); } else if (object.getClass().isArray()) { return handleArray(object); } else if (object instanceof OfflinePlayer) { return handleOfflinePlayer((OfflinePlayer) object); } else if (object instanceof BlockState) { return handleBlockState((BlockState) object); } else if (object instanceof Inventory) { return handleInventory((Inventory) object); } else if (object instanceof WorldBorder) { return handleWorldBorder((WorldBorder) object); } else if (object instanceof CommandSender) { return handleCommandSender((CommandSender) object); } else if (object instanceof Messenger) { return handleMessenger((Messenger) object); } else if (object instanceof HelpMap) { return handleHelpMap((HelpMap) object); } else { return String.valueOf(object); } }
@Nonnull private static String handleMessenger(Messenger messenger) { String incomingBanner = "-- Incoming Channels --\n"; String incomingChannels = handleCollection(messenger.getIncomingChannels()); String outgoingBanner = "\n-- Outgoing Channels --\n"; String outgoingChannels = handleCollection(messenger.getOutgoingChannels()); return incomingBanner + incomingChannels + outgoingBanner + outgoingChannels; }
@Test public void testMessenger() { String debuggeryIn = "Debuggery In"; String debuggeryOut = "Debuggery Out"; String tacoInOut = "Taco Listener"; String stuffIn = "Other stuff"; String stuffOut = "Something here"; Set<String> messengersIn = new HashSet<>(); Set<String> messengersOut = new HashSet<>(); messengersIn.add(debuggeryIn); messengersIn.add(tacoInOut); messengersIn.add(stuffIn); messengersOut.add(debuggeryOut); messengersOut.add(tacoInOut); messengersOut.add(stuffOut); Messenger messenger = new TestMessenger(messengersIn, messengersOut); String out = OutputFormatter.getOutput(messenger); assertNotNull(out); String[] sections = out.split("}\\n"); String incoming = sections[0]; String outgoing = sections[1]; assertTrue(incoming.contains(debuggeryIn)); assertTrue(incoming.contains(tacoInOut)); assertTrue(incoming.contains(stuffIn)); assertTrue(outgoing.contains(debuggeryOut)); assertTrue(outgoing.contains(tacoInOut)); assertTrue(outgoing.contains(stuffOut)); }
public void setTexturePack(String url) { Validate.notNull(url, "Texture pack URL cannot be null"); byte[] message = (url + "\0" + "16").getBytes(); Validate.isTrue(message.length <= Messenger.MAX_MESSAGE_SIZE, "Texture pack URL is too long"); getHandle().playerConnection.sendPacket(new Packet250CustomPayload("MC|TPack", message)); }
private void init() { Messenger m = Bukkit.getServer().getMessenger(); if ( !m.isOutgoingChannelRegistered(ParchmentPluginLite.instance(), channel) ) m.registerOutgoingPluginChannel(ParchmentPluginLite.instance(), channel); if ( !m.isIncomingChannelRegistered(ParchmentPluginLite.instance(), channel) ) { m.registerIncomingPluginChannel(ParchmentPluginLite.instance(), channel, this); } }
public BukkitPacketManager(JavaPlugin bukkitPlugin, String channel){ super(channel); this.bukkitPlugin = bukkitPlugin; Messenger messenger = Bukkit.getMessenger(); messenger.registerOutgoingPluginChannel(bukkitPlugin, channel); messenger.registerIncomingPluginChannel(bukkitPlugin, channel, this); messenger.registerIncomingPluginChannel(bukkitPlugin, "BungeeCord", this); messenger.registerOutgoingPluginChannel(bukkitPlugin, "BungeeCord"); Bukkit.getPluginManager().registerEvents(this, bukkitPlugin); }
@Override public void register() { Messenger messenger = Bukkit.getMessenger(); messenger.registerOutgoingPluginChannel(plugin, BUNGEE_CHANNEL); messenger.registerIncomingPluginChannel(plugin, BUNGEE_CHANNEL, this); Bukkit.getScheduler().runTaskTimer(plugin, this, UPDATE_INTERVAL, UPDATE_INTERVAL); register("bungee-online").scoreSupply(() -> onlinePlayers); }
@Override public void reload(Settings settings) { this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD); this.destinationServerOnLogin = settings.getProperty(HooksSettings.BUNGEECORD_SERVER); if (this.isEnabled) { Messenger messenger = plugin.getServer().getMessenger(); if (!messenger.isOutgoingChannelRegistered(plugin, "BungeeCord")) { messenger.registerOutgoingPluginChannel(plugin, "BungeeCord"); } } }
@Override public void reload(Settings settings) { this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD); if (this.isEnabled) { Messenger messenger = plugin.getServer().getMessenger(); if (!messenger.isIncomingChannelRegistered(plugin, "BungeeCord")) { messenger.registerIncomingPluginChannel(plugin, "BungeeCord", this); } } }
public void setTexturePack(String url) { Validate.notNull(url, "Texture pack URL cannot be null"); byte[] message = (url + "\0" + "16").getBytes(); Validate.isTrue(message.length <= Messenger.MAX_MESSAGE_SIZE, "Texture pack URL is too long"); getHandle().field_71135_a.func_72567_b(new net.minecraft.network.packet.Packet250CustomPayload("MC|TPack", message)); }
@Override public Messenger getMessenger() { return messenger; }
@Inject PlayerServerChanger(Plugin plugin, Messenger messenger, Server localServer) { this.plugin = plugin; this.messenger = messenger; this.localServer = localServer; }
@Override public Messenger getMessenger() { // TODO Auto-generated method stub throw new UnimplementedOperationException(); }
@Override public Messenger getMessenger() { throw new UnsupportedOperationException(); }
@Override public Messenger getMessenger() { return null; // TODO: Create Messenger }
@Override public Messenger getMessenger() { // TODO Auto-generated method stub return null; }
@Override public Messenger getMessenger() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
/** * @see Server#getMessenger() */ public static Messenger getMessenger() { return server.getMessenger(); }
@Override public Messenger getMessenger() { return null; }
public Messenger getMessenger() { return messenger; }