use of net.minecraft.server.v1_8_R3.Packet in project jop by jop-devel.
the class Ppp method doSend.
void doSend() {
if (reconnectRequest) {
// System.out.print("3");
// start over
modemHangUp();
modemInit();
}
if (disconnectRequest) {
// stop the connection
modemHangUp();
}
if (state == CONNECTED) {
// send waiting ip packets
if (scnt == 0) {
// transmit buffer is free
// use IP timeout
globTimer = Timer.getTimeoutMs(IP_SEND);
//
// get a ready to send packet with source from this driver.
//
Packet p = PacketPool.getTxPacket(single);
if (p != null) {
// send one packet
sendIp(p);
}
} else {
// check sendTimer;
if (Timer.timeout(globTimer)) {
// System.out.print("4");
// start over
modemHangUp();
modemInit();
}
}
} else {
// do the negotiation stuff
dropIp();
if (Timer.timeout(globTimer)) {
/*
Dbg.intVal(state);
if (lcpAck) Dbg.wr('t'); else Dbg.wr('f');
*/
if (scnt == 0) {
// once every three seconds send a REQ
if (state == MODEM_OK) {
makeLCP();
state = LCP_SENT;
} else if (state == LCP_OK && lcpAck) {
makePAP();
state = PAP_SENT;
// } else if (state == PAP_OK && ipcpAck) { // wait for remote ipcp and ACK first on Linux
} else if (state >= PAP_OK && state < CONNECTED) {
// ONE
makeIPCP();
state = IPCP_SENT;
// incremenet counter to start over when no respond
++rejCnt;
}
// use negotiation timeout
globTimer = Timer.getTimeoutMs(NEG_SEND);
}
}
}
}
use of net.minecraft.server.v1_8_R3.Packet in project Denizen-For-Bukkit by DenizenScript.
the class ProfileEditor_v1_8_R3 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();
}
}
}
use of net.minecraft.server.v1_8_R3.Packet in project FireAPI by FireBlade-Serv.
the class BigBrotherPacketListenerAC method onPacketReceive.
@Override
public void onPacketReceive(Player p, Object packet) {
if (packet instanceof PacketPlayInFlying) {
PacketPlayInFlying fly = (PacketPlayInFlying) packet;
String status = (fly.f()) ? "ON GROUND" : "FLYING";
System.out.println(fly.getClass().getSimpleName() + " / " + status);
} else if (packet instanceof PacketPlayInEntityAction) {
PacketPlayInEntityAction ea = (PacketPlayInEntityAction) packet;
System.out.println(ea.getClass().getSimpleName() + " / " + ea.b());
} else {
System.out.println(packet.getClass().getSimpleName());
}
if (packet instanceof PacketPlayInUseEntity) {
PacketPlayInUseEntity puse = (PacketPlayInUseEntity) packet;
int id = (int) FireReflection.getFieldValueByName(puse, "a");
if (BigBrotherKillAuraAC.getFakePlayers().containsKey(p)) {
if (BigBrotherKillAuraAC.getFakePlayers().get(p) == id) {
if (BigBrotherKillAuraAC.getClicked().get(p) == false) {
BigBrotherKillAuraAC.getClicked().replace(p, true);
}
}
}
}
if (this.spackets.containsKey(p)) {
List<Object> list = this.spackets.get(p);
list.add(packet);
this.spackets.replace(p, list);
} else {
List<Object> list = new CopyOnWriteArrayList<>();
list.add(packet);
this.spackets.put(p, list);
}
}
use of net.minecraft.server.v1_8_R3.Packet in project vespa by vespa-engine.
the class FastSearcher method searchTwoPhase.
private Result searchTwoPhase(FS4Channel channel, Query query, QueryPacket queryPacket, CacheKey cacheKey) throws IOException {
if (isLoggingFine())
getLogger().finest("sending query packet");
try {
boolean couldSend = channel.sendPacket(queryPacket);
if (!couldSend)
return new Result(query, ErrorMessage.createBackendCommunicationError("Could not reach '" + getName() + "'"));
} catch (InvalidChannelException e) {
return new Result(query, ErrorMessage.createBackendCommunicationError("Invalid channel " + getName()));
} catch (IllegalStateException e) {
return new Result(query, ErrorMessage.createBackendCommunicationError("Illegal state in FS4: " + e.getMessage()));
}
BasicPacket[] basicPackets;
try {
basicPackets = channel.receivePackets(query.getTimeLeft(), 1);
} catch (ChannelTimeoutException e) {
return new Result(query, ErrorMessage.createTimeout("Timeout while waiting for " + getName()));
} catch (InvalidChannelException e) {
return new Result(query, ErrorMessage.createBackendCommunicationError("Invalid channel for " + getName()));
}
if (basicPackets.length == 0) {
return new Result(query, ErrorMessage.createBackendCommunicationError(getName() + " got no packets back"));
}
if (isLoggingFine())
getLogger().finest("got packets " + basicPackets.length + " packets");
ensureInstanceOf(QueryResultPacket.class, basicPackets[0], getName());
QueryResultPacket resultPacket = (QueryResultPacket) basicPackets[0];
if (isLoggingFine())
getLogger().finest("got query packet. " + "docsumClass=" + query.getPresentation().getSummary());
if (query.getPresentation().getSummary() == null)
query.getPresentation().setSummary(getDefaultDocsumClass());
Result result = new Result(query);
addMetaInfo(query, queryPacket.getQueryPacketData(), resultPacket, result, false);
addUnfilledHits(result, resultPacket.getDocuments(), false, queryPacket.getQueryPacketData(), cacheKey);
Packet[] packets;
PacketWrapper packetWrapper = cacheControl.lookup(cacheKey, query);
if (packetWrapper != null) {
cacheControl.updateCacheEntry(cacheKey, query, resultPacket);
} else {
if (resultPacket.getCoverageFeature() && !resultPacket.getCoverageFull()) {
// Don't add error here, it was done in first phase
// No check if packetWrapper already exists, since incomplete
// first phase data won't be cached anyway.
} else {
packets = new Packet[1];
packets[0] = resultPacket;
cacheControl.cache(cacheKey, query, new DocsumPacketKey[0], packets);
}
}
return result;
}
use of net.minecraft.server.v1_8_R3.Packet in project vespa by vespa-engine.
the class FS4Channel method receivePackets.
/**
* Receives the given number of packets and returns them, OR
* <ul>
* <li>Returns a smaller number of packets if an error or eol packet is received
* <li>Throws a ChannelTimeoutException if timeout occurs before all packets
* are received. Packets received with the wrong channel id are ignored.
* </ul>
*
* @param timeout the number of ms to attempt to get packets before throwing an exception
* @param packetCount the number of packets to receive, or -1 to receive any number up to eol/error
*/
public BasicPacket[] receivePackets(long timeout, int packetCount) throws InvalidChannelException, ChannelTimeoutException {
ensureValid();
List<BasicPacket> packets = new ArrayList<>(12);
long startTime = SystemTimer.INSTANCE.milliTime();
long timeLeft = timeout;
try {
while (timeLeft >= 0) {
BasicPacket p = nextPacket(timeLeft);
if (p == null)
throw new ChannelTimeoutException("Timed out");
if (!isPingChannel && ((Packet) p).getChannel() != getChannelId().intValue()) {
log.warning("Ignoring received " + p + ", when excepting channel " + getChannelId());
continue;
}
packets.add(p);
if (isLastPacket(p) || hasEnoughPackets(packetCount, packets)) {
BasicPacket[] packetArray = new BasicPacket[packets.size()];
packets.toArray(packetArray);
return packetArray;
}
// doing this last might save us one system call for the last
// packet.
timeLeft = timeout - (SystemTimer.INSTANCE.milliTime() - startTime);
}
} catch (InvalidChannelException e) {
// nop. if we get this we want to return the default
// zero length packet array indicating that we have no
// valid response
log.info("FS4Channel was invalid. timeLeft=" + timeLeft + ", timeout=" + timeout);
} catch (InterruptedException e) {
log.info("FS4Channel was interrupted. timeLeft=" + timeLeft + ", timeout=" + timeout);
Thread.currentThread().interrupt();
}
// did not get the end of the packet stream
throw new ChannelTimeoutException();
}
Aggregations