Java Code Examples for co.aikar.timings.Timings#getSendDataPacketTiming()

The following examples show how to use co.aikar.timings.Timings#getSendDataPacketTiming() . 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 vote down vote up
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 vote down vote up
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 vote down vote up
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 vote down vote up
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 vote down vote up
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 vote down vote up
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;
}