Search in sources :

Example 1 with Packet

use of net.minecraft.server.v1_10_R1.Packet in project jop by jop-devel.

the class Ppp method readIp.

/**
*	get a Packet buffer and copy from receive buffer.
*/
void readIp() {
    int i, j, k;
    //PacketPool.getFreshRcvPacket(single);
    Packet p = null;
    if (p == null) {
        Dbg.wr('!');
        // try again later
        return;
    }
    // buf blocks receive buffer :-<
    int[] pb = p.buf;
    // minus ppp header and checksum
    cnt -= 6;
    rbuf[cnt + 4] = 0;
    rbuf[cnt + 4 + 1] = 0;
    rbuf[cnt + 4 + 2] = 0;
    // copy buffer
    k = 0;
    for (i = 0; i < cnt; i += 4) {
        for (j = 0; j < 4; ++j) {
            k <<= 8;
            // after header
            k += rbuf[i + j + 4];
        }
        pb[i >>> 2] = k;
    }
    p.setLen(cnt);
    Dbg.wr('r');
    Dbg.intVal(cnt);
    /*
dbgIp(pb[3]);
dbgIp(pb[4]);
for (i=0; i<(cnt+4)>>2; ++i) Dbg.hexVal(pb[i]);
Dbg.wr('\n');
*/
    cnt = 0;
    ready = false;
    // inform upper layer
    p.setStatus(Packet.RCV);
}
Also used : Packet(ejip123.Packet)

Example 2 with Packet

use of net.minecraft.server.v1_10_R1.Packet in project jop by jop-devel.

the class Tftp method resend.

private static void resend() {
    time <<= 1;
    if (time > 64) {
        Dbg.wr("TFTP give up");
        tftpInit();
        return;
    }
    Dbg.wr("TFTP resend ");
    Dbg.intVal(block_out);
    // retransmit DATA
    timeout = Timer.getTimeoutSec(time);
    Packet p = PacketPool.getFreshPacket();
    //		Packet p = PacketPool.getPacket(Packet.FREE, Packet.ALLOC, ipLink);
    if (p == null) {
        // got no free buffer!
        Dbg.wr('!');
        Dbg.wr('b');
        return;
    }
    p.buf[Udp.DATA] = (DAT << 16) + block_out;
    if (block_out == endBlock) {
        // last block is zero length
        p.setLen(Udp.DATA * 4 + 4);
    } else {
        read(p.buf, block_out);
        p.setLen(Udp.DATA * 4 + 4 + 512);
    }
    Udp.send(p, srcIp, dstIp, dstPort);
}
Also used : Packet(ejip123.Packet)

Example 3 with Packet

use of net.minecraft.server.v1_10_R1.Packet in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditor_v1_10_R1 method updatePlayerProfiles.

public static void updatePlayerProfiles(PacketPlayOutPlayerInfo packet) {
    PacketPlayOutPlayerInfo.EnumPlayerInfoAction action = ReflectionHelper.getFieldValue(PacketPlayOutPlayerInfo.class, "a", packet);
    if (action != PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER) {
        return;
    }
    List<?> dataList = ReflectionHelper.getFieldValue(PacketPlayOutPlayerInfo.class, "b", packet);
    if (dataList != null) {
        try {
            for (Object data : dataList) {
                GameProfile gameProfile = (GameProfile) playerInfoData_gameProfile.get(data);
                if (fakeProfiles.containsKey(gameProfile.getId())) {
                    playerInfoData_gameProfile.set(data, getGameProfile(fakeProfiles.get(gameProfile.getId())));
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : GameProfile(com.mojang.authlib.GameProfile) PacketPlayOutPlayerInfo(net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo)

Example 4 with Packet

use of net.minecraft.server.v1_10_R1.Packet in project PyrCore by PYRRH4.

the class ParticleManager_1_10_2 method sendColor.

public void sendColor(ParticleManager.Type type, Location loc, float speed, int count, Color color, ArrayList<Player> players) {
    float x = (float) loc.getX();
    float y = (float) loc.getY();
    float z = (float) loc.getZ();
    PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(EnumParticle.valueOf(type.getName()), true, x, y, z, color.getRed(), color.getGreen(), color.getBlue(), speed, count, null);
    for (Player pl : players) {
        ((CraftPlayer) pl).getHandle().playerConnection.sendPacket(packet);
    }
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer) PacketPlayOutWorldParticles(net.minecraft.server.v1_10_R1.PacketPlayOutWorldParticles) CraftPlayer(org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer)

Example 5 with Packet

use of net.minecraft.server.v1_10_R1.Packet in project vespa by vespa-engine.

the class FastSearcher method doPartialFill.

/**
 * Perform a partial docsum fill for a temporary result
 * representing a partition of the complete fill request.
 *
 * @param result result containing a partition of the unfilled hits
 * @param summaryClass the summary class we want to fill with
 */
protected void doPartialFill(Result result, String summaryClass) {
    if (result.isFilled(summaryClass))
        return;
    Query query = result.getQuery();
    traceQuery(getName(), "fill", query, query.getOffset(), query.getHits(), 2, quotedSummaryClass(summaryClass));
    if (wantsRPCSummaryFill(query)) {
        CompressionType compression = CompressionType.valueOf(query.properties().getString(dispatchCompression, "LZ4").toUpperCase());
        fillSDDocName(result);
        dispatcher.fill(result, summaryClass, compression);
        return;
    }
    CacheKey cacheKey = null;
    PacketWrapper packetWrapper = null;
    if (getCacheControl().useCache(query)) {
        cacheKey = fetchCacheKeyFromHits(result.hits(), summaryClass);
        if (cacheKey == null) {
            QueryPacket queryPacket = QueryPacket.create(query);
            cacheKey = new CacheKey(queryPacket);
        }
        packetWrapper = cacheLookupTwoPhase(cacheKey, result, summaryClass);
    }
    FS4Channel channel = chooseBackend(query).openChannel();
    channel.setQuery(query);
    Packet[] receivedPackets;
    try {
        DocsumPacketKey[] packetKeys;
        if (countFastHits(result) > 0) {
            packetKeys = getPacketKeys(result, summaryClass, false);
            if (packetKeys.length == 0) {
                receivedPackets = new Packet[0];
            } else {
                try {
                    receivedPackets = fetchSummaries(channel, result, summaryClass);
                } catch (InvalidChannelException e) {
                    result.hits().addError(ErrorMessage.createBackendCommunicationError("Invalid channel " + getName() + " (summary fetch)"));
                    return;
                } catch (ChannelTimeoutException e) {
                    result.hits().addError(ErrorMessage.createTimeout("timeout waiting for summaries from " + getName()));
                    return;
                } catch (IOException e) {
                    result.hits().addError(ErrorMessage.createBackendCommunicationError("IO error while talking on channel " + getName() + " (summary fetch): " + e.getMessage()));
                    return;
                }
                if (receivedPackets.length == 0) {
                    result.hits().addError(ErrorMessage.createBackendCommunicationError(getName() + " got no packets back (summary fetch)"));
                    return;
                }
            }
        } else {
            packetKeys = new DocsumPacketKey[0];
            receivedPackets = new Packet[0];
        }
        int skippedHits;
        try {
            FillHitsResult fillHitsResult = fillHits(result, receivedPackets, summaryClass);
            skippedHits = fillHitsResult.skippedHits;
            if (fillHitsResult.error != null) {
                result.hits().addError(ErrorMessage.createTimeout(fillHitsResult.error));
                return;
            }
        } catch (TimeoutException e) {
            result.hits().addError(ErrorMessage.createTimeout(e.getMessage()));
            return;
        } catch (IOException e) {
            result.hits().addError(ErrorMessage.createBackendCommunicationError("Error filling hits with summary fields, source: " + getName() + " Exception thrown: " + e.getMessage()));
            return;
        }
        if (skippedHits == 0 && packetWrapper != null) {
            cacheControl.updateCacheEntry(cacheKey, query, packetKeys, receivedPackets);
        }
        if (skippedHits > 0)
            result.hits().addError(com.yahoo.search.result.ErrorMessage.createEmptyDocsums("Missing hit data for summary '" + summaryClass + "' for " + skippedHits + " hits"));
        result.analyzeHits();
        if (query.getTraceLevel() >= 3) {
            int hitNumber = 0;
            for (Iterator<com.yahoo.search.result.Hit> i = hitIterator(result); i.hasNext(); ) {
                com.yahoo.search.result.Hit hit = i.next();
                if (!(hit instanceof FastHit))
                    continue;
                FastHit fastHit = (FastHit) hit;
                String traceMsg = "Hit: " + (hitNumber++) + " from " + (fastHit.isCached() ? "cache" : "backend");
                if (!fastHit.isFilled(summaryClass))
                    traceMsg += ". Error, hit, not filled";
                query.trace(traceMsg, false, 3);
            }
        }
    } finally {
        channel.close();
    }
}
Also used : Query(com.yahoo.search.Query) QueryPacket(com.yahoo.fs4.QueryPacket) ChannelTimeoutException(com.yahoo.fs4.ChannelTimeoutException) QueryResultPacket(com.yahoo.fs4.QueryResultPacket) QueryPacket(com.yahoo.fs4.QueryPacket) PongPacket(com.yahoo.fs4.PongPacket) BasicPacket(com.yahoo.fs4.BasicPacket) GetDocSumsPacket(com.yahoo.fs4.GetDocSumsPacket) Packet(com.yahoo.fs4.Packet) PingPacket(com.yahoo.fs4.PingPacket) IOException(java.io.IOException) InvalidChannelException(com.yahoo.fs4.mplex.InvalidChannelException) Hit(com.yahoo.search.result.Hit) Hit(com.yahoo.search.result.Hit) FS4Channel(com.yahoo.fs4.mplex.FS4Channel) ChannelTimeoutException(com.yahoo.fs4.ChannelTimeoutException) CompressionType(com.yahoo.compress.CompressionType)

Aggregations

Packet (com.yahoo.fs4.Packet)4 Location (org.bukkit.Location)4 BasicPacket (com.yahoo.fs4.BasicPacket)3 ChannelTimeoutException (com.yahoo.fs4.ChannelTimeoutException)3 QueryPacket (com.yahoo.fs4.QueryPacket)3 Packet (ejip123.Packet)3 GetDocSumsPacket (com.yahoo.fs4.GetDocSumsPacket)2 PingPacket (com.yahoo.fs4.PingPacket)2 PongPacket (com.yahoo.fs4.PongPacket)2 QueryResultPacket (com.yahoo.fs4.QueryResultPacket)2 InvalidChannelException (com.yahoo.fs4.mplex.InvalidChannelException)2 Result (com.yahoo.search.Result)2 IOException (java.io.IOException)2 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)2 PacketPlayOutWorldParticles (net.minecraft.server.v1_10_R1.PacketPlayOutWorldParticles)2 CraftPlayer (org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer)2 Player (org.bukkit.entity.Player)2 GameProfile (com.mojang.authlib.GameProfile)1 CompressionType (com.yahoo.compress.CompressionType)1 IdString (com.yahoo.document.idstring.IdString)1