Java Code Examples for com.velocitypowered.api.event.connection.PluginMessageEvent#setResult()
The following examples show how to use
com.velocitypowered.api.event.connection.PluginMessageEvent#setResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginMessageMessenger.java From LuckPerms with MIT License | 6 votes |
@Subscribe public void onPluginMessage(PluginMessageEvent e) { // compare the underlying text representation of the channel // the namespaced representation is used by legacy servers too, so we // are able to support both. :) if (!e.getIdentifier().getId().equals(CHANNEL.getId())) { return; } e.setResult(ForwardResult.handled()); if (e.getSource() instanceof Player) { return; } ByteArrayDataInput in = e.dataAsDataStream(); String msg = in.readUTF(); if (this.consumer.consumeIncomingMessageAsString(msg)) { // Forward to other servers this.plugin.getBootstrap().getScheduler().executeAsync(() -> dispatchMessage(e.getData())); } }
Example 2
Source File: PluginMessenger.java From TAB with Apache License 2.0 | 5 votes |
@Subscribe public void on(PluginMessageEvent event){ if (!event.getIdentifier().getId().equalsIgnoreCase(Shared.CHANNEL_NAME)) return; ByteArrayDataInput in = ByteStreams.newDataInput(event.getData()); String subChannel = in.readUTF(); if (event.getTarget() instanceof Player && subChannel.equalsIgnoreCase("Placeholder")){ event.setResult(ForwardResult.handled()); ITabPlayer receiver = Shared.getPlayer(((Player) event.getTarget()).getUniqueId()); if (receiver == null) return; String placeholder = in.readUTF(); String output = in.readUTF(); long cpu = in.readLong(); PlayerPlaceholder pl = (PlayerPlaceholder) Placeholders.getPlaceholder(placeholder); //all bridge placeholders are marked as player if (pl != null) { pl.lastValue.put(receiver.getName(), output); pl.lastValue.put("null", output); Set<Refreshable> update = PlaceholderManager.getPlaceholderUsage(pl.getIdentifier()); Shared.featureCpu.runTask("refreshing", new Runnable() { @Override public void run() { for (Refreshable r : update) { long startTime = System.nanoTime(); r.refresh(receiver, false); Shared.featureCpu.addTime(r.getRefreshCPU(), System.nanoTime()-startTime); } } }); Shared.bukkitBridgePlaceholderCpu.addTime(pl.getIdentifier(), cpu); } else { Shared.debug("Received output for unknown placeholder " + placeholder); } } }
Example 3
Source File: OnlineForwardPluginMessagingForwardingSource.java From NuVotifier with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onPluginMessage(PluginMessageEvent e) { if (e.getIdentifier().equals(velocityChannelId)) { e.setResult(PluginMessageEvent.ForwardResult.handled()); } }
Example 4
Source File: PluginMessagingForwardingSource.java From NuVotifier with GNU General Public License v3.0 | 4 votes |
@Subscribe public void onPluginMessage(PluginMessageEvent e) { if (e.getIdentifier().equals(velocityChannelId)) { e.setResult(PluginMessageEvent.ForwardResult.handled()); } }