cn.nukkit.event.server.DataPacketSendEvent Java Examples
The following examples show how to use
cn.nukkit.event.server.DataPacketSendEvent.
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: Player.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public boolean batchDataPacket(DataPacket packet) { if (!this.connected) { return false; } try (Timing timing = Timings.getSendDataPacketTiming(packet)) { DataPacketSendEvent event = new DataPacketSendEvent(this, packet); this.server.getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } if (!this.batchedPackets.containsKey(packet.getChannel())) { this.batchedPackets.put(packet.getChannel(), new ArrayList<>()); } this.batchedPackets.get(packet.getChannel()).add(packet.clone()); } return true; }
Example #2
Source File: Player.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public int dataPacket(DataPacket packet, boolean needACK) { if (!this.connected) { return -1; } try (Timing timing = Timings.getSendDataPacketTiming(packet)) { DataPacketSendEvent ev = new DataPacketSendEvent(this, packet); this.server.getPluginManager().callEvent(ev); if (ev.isCancelled()) { return -1; } if (log.isTraceEnabled() && !(packet instanceof BatchPacket)) { log.trace("Outbound {}: {}", this.getName(), packet); } Integer identifier = this.interfaz.putPacket(this, packet, needACK, false); if (needACK && identifier != null) { this.needACK.put(identifier, Boolean.FALSE); return identifier; } } return 0; }
Example #3
Source File: Player.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public int directDataPacket(DataPacket packet, boolean needACK) { if (!this.connected) { return -1; } try (Timing timing = Timings.getSendDataPacketTiming(packet)) { DataPacketSendEvent ev = new DataPacketSendEvent(this, packet); this.server.getPluginManager().callEvent(ev); if (ev.isCancelled()) { return -1; } Integer identifier = this.interfaz.putPacket(this, packet, needACK, true); if (needACK && identifier != null) { this.needACK.put(identifier, Boolean.FALSE); return identifier; } } return 0; }
Example #4
Source File: Player.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public boolean batchDataPacket(DataPacket packet) { if (!this.connected) { return false; } try (Timing timing = Timings.getSendDataPacketTiming(packet)) { DataPacketSendEvent event = new DataPacketSendEvent(this, packet); this.server.getPluginManager().callEvent(event); if (event.isCancelled()) { timing.stopTiming(); return false; } if (!this.batchedPackets.containsKey(packet.getChannel())) { this.batchedPackets.put(packet.getChannel(), new ArrayList<>()); } this.batchedPackets.get(packet.getChannel()).add(packet.clone()); } return true; }
Example #5
Source File: Player.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public int dataPacket(DataPacket packet, boolean needACK) { if (!this.connected) { return -1; } try (Timing timing = Timings.getSendDataPacketTiming(packet)) { DataPacketSendEvent ev = new DataPacketSendEvent(this, packet); this.server.getPluginManager().callEvent(ev); if (ev.isCancelled()) { timing.stopTiming(); return -1; } Integer identifier = this.interfaz.putPacket(this, packet, needACK, false); if (needACK && identifier != null) { this.needACK.put(identifier, Boolean.FALSE); timing.stopTiming(); return identifier; } } return 0; }
Example #6
Source File: Player.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public int directDataPacket(DataPacket packet, boolean needACK) { if (!this.connected) { return -1; } try (Timing timing = Timings.getSendDataPacketTiming(packet)) { DataPacketSendEvent ev = new DataPacketSendEvent(this, packet); this.server.getPluginManager().callEvent(ev); if (ev.isCancelled()) { timing.stopTiming(); return -1; } Integer identifier = this.interfaz.putPacket(this, packet, needACK, true); if (needACK && identifier != null) { this.needACK.put(identifier, Boolean.FALSE); timing.stopTiming(); return identifier; } } return 0; }
Example #7
Source File: SynapsePlayer.java From SynapseAPI with GNU General Public License v3.0 | 5 votes |
public int sendDataPacket(DataPacket packet, boolean needACK, boolean direct) { packet = DataPacketEidReplacer.replace(packet, this.getId(), REPLACE_ID); DataPacketSendEvent ev = new DataPacketSendEvent(this, packet); this.server.getPluginManager().callEvent(ev); if (ev.isCancelled()) { return -1; } if (!packet.isEncoded) { packet.encode(); packet.isEncoded = true; } return this.interfaz.putPacket(this, packet, needACK, direct); }