예제 #1
0
  // QHandler handles incoming queries.
  public void run() {
    // hmmm.. this seems like potential bug.  I want to check that query is not in table.  But even
    // if query table contains key,
    // that does not necessarily mean it is in table, b/c two queries can have SAME HASHCODE VALUE.
    // I need to have some other means.
    // Will talk to Rusty @ this on Monday.

    if (!qt.containsKey(query)) // check that query is not already in table
    {
      Searcher.inform(query); // Give information to the Search Monitor panel
      NetworkManager.writeButOne(query.getIP(), query); /*Query is forwarded to all connected nodes
								     except one from which query came. */
      qt.put((Packet) query, query); // add query to table, indexed by its unique MessageID
      searchResult =
          SharedDirectory.search(query.getSearchString()); // check shared directory for query match
      numHits = searchResult.getSize();

      if (numHits != 0) // package a query hit to send out if there is at least one query match
      {
        queryID = query.getMessageID();
        port = Mine.getPort();
        myIP = Mine.getIPAddress();
        speed = Mine.getSpeed();
        serventID = Mine.getServentIdentifier();
        queryHit = new QueryHit(numHits, port, myIP, speed, searchResult, serventID, queryID);
        NetworkManager.writeToOne(
            query.getIP(), queryHit); // send qHit back to node that sent original query
      }
    }
  }
  /** run once each game tick */
  public void networkTick() {
    field_72584_h = false;
    currentTicks++;
    mcServer.theProfiler.startSection("packetflow");
    theNetworkManager.processReadPackets();
    mcServer.theProfiler.endStartSection("keepAlive");

    if ((long) currentTicks - ticksOfLastKeepAlive > 20L) {
      ticksOfLastKeepAlive = currentTicks;
      keepAliveTimeSent = System.nanoTime() / 0xf4240L;
      keepAliveRandomID = randomGenerator.nextInt();
      sendPacketToPlayer(new Packet0KeepAlive(keepAliveRandomID));
    }

    if (chatSpamThresholdCount > 0) {
      chatSpamThresholdCount--;
    }

    if (creativeItemCreationSpamThresholdTally > 0) {
      creativeItemCreationSpamThresholdTally--;
    }

    mcServer.theProfiler.endStartSection("playerTick");

    if (!field_72584_h && !playerEntity.playerHasConqueredTheEnd) {
      playerEntity.onUpdateEntity();
    }

    mcServer.theProfiler.endSection();
  }
예제 #3
0
 public NetServerHandler(
     MinecraftServer minecraftserver,
     NetworkManager networkmanager,
     EntityPlayerMP entityplayermp) {
   connectionClosed = false;
   hasMoved = true;
   field_10_k = new HashMap();
   mcServer = minecraftserver;
   netManager = networkmanager;
   networkmanager.setNetHandler(this);
   playerEntity = entityplayermp;
   entityplayermp.playerNetServerHandler = this;
 }
 public NetServerHandler(
     MinecraftServer par1MinecraftServer,
     NetworkManager par2NetworkManager,
     EntityPlayerMP par3EntityPlayerMP) {
   serverShuttingDown = false;
   chatSpamThresholdCount = 0;
   creativeItemCreationSpamThresholdTally = 0;
   field_72587_r = true;
   field_72586_s = new IntHashMap();
   mcServer = par1MinecraftServer;
   theNetworkManager = par2NetworkManager;
   par2NetworkManager.setNetHandler(this);
   playerEntity = par3EntityPlayerMP;
   par3EntityPlayerMP.serverForThisPlayer = this;
 }
  /** addToSendQueue. if it is a chat packet, check before sending it */
  public void sendPacketToPlayer(Packet par1Packet) {
    if (par1Packet instanceof Packet3Chat) {
      Packet3Chat packet3chat = (Packet3Chat) par1Packet;
      int i = playerEntity.getChatVisibility();

      if (i == 2) {
        return;
      }

      if (i == 1 && !packet3chat.func_73475_d()) {
        return;
      }
    }

    theNetworkManager.addToSendQueue(par1Packet);
  }
 public void kickPlayerFromServer(String par1Str) {
   if (serverShuttingDown) {
     return;
   } else {
     playerEntity.mountEntityAndWakeUp();
     sendPacketToPlayer(new Packet255KickDisconnect(par1Str));
     theNetworkManager.serverShutdown();
     mcServer
         .getConfigurationManager()
         .sendPacketToAllPlayers(
             new Packet3Chat(
                 (new StringBuilder())
                     .append("\247e")
                     .append(playerEntity.username)
                     .append(" left the game.")
                     .toString()));
     mcServer.getConfigurationManager().func_72367_e(playerEntity);
     serverShuttingDown = true;
     return;
   }
 }
 /** returns 0 for memoryMapped connections */
 public int packetSize() {
   return theNetworkManager.packetSize();
 }
 public void handleKickDisconnect(Packet255KickDisconnect par1Packet255KickDisconnect) {
   theNetworkManager.networkShutdown("disconnect.quitting", new Object[0]);
 }
  public void func_72355_a(NetworkManager p_72355_1_, EntityPlayerMP p_72355_2_) {
    func_72380_a(p_72355_2_);
    p_72355_2_.func_70029_a(field_72400_f.func_71218_a(p_72355_2_.field_71093_bK));
    p_72355_2_.field_71134_c.func_73080_a((WorldServer) p_72355_2_.field_70170_p);
    String s = "local";
    if (p_72355_1_.func_74430_c() != null) {
      s = p_72355_1_.func_74430_c().toString();
    }
    field_72406_a.info(
        (new StringBuilder())
            .append(p_72355_2_.field_71092_bJ)
            .append("[")
            .append(s)
            .append("] logged in with entity id ")
            .append(p_72355_2_.field_70157_k)
            .append(" at (")
            .append(p_72355_2_.field_70165_t)
            .append(", ")
            .append(p_72355_2_.field_70163_u)
            .append(", ")
            .append(p_72355_2_.field_70161_v)
            .append(")")
            .toString());
    WorldServer worldserver = field_72400_f.func_71218_a(p_72355_2_.field_71093_bK);
    ChunkCoordinates chunkcoordinates = worldserver.func_72861_E();
    func_72381_a(p_72355_2_, null, worldserver);
    NetServerHandler netserverhandler = new NetServerHandler(field_72400_f, p_72355_1_, p_72355_2_);
    netserverhandler.func_72567_b(
        new Packet1Login(
            p_72355_2_.field_70157_k,
            worldserver.func_72912_H().func_76067_t(),
            p_72355_2_.field_71134_c.func_73081_b(),
            worldserver.func_72912_H().func_76093_s(),
            worldserver.field_73011_w.field_76574_g,
            worldserver.field_73013_u,
            worldserver.func_72800_K(),
            func_72352_l()));
    netserverhandler.func_72567_b(
        new Packet6SpawnPosition(
            chunkcoordinates.field_71574_a,
            chunkcoordinates.field_71572_b,
            chunkcoordinates.field_71573_c));
    netserverhandler.func_72567_b(new Packet202PlayerAbilities(p_72355_2_.field_71075_bZ));
    func_72354_b(p_72355_2_, worldserver);
    func_72384_a(
        new Packet3Chat(
            (new StringBuilder())
                .append("\247e")
                .append(p_72355_2_.field_71092_bJ)
                .append(" joined the game.")
                .toString()));
    func_72377_c(p_72355_2_);
    netserverhandler.func_72569_a(
        p_72355_2_.field_70165_t,
        p_72355_2_.field_70163_u,
        p_72355_2_.field_70161_v,
        p_72355_2_.field_70177_z,
        p_72355_2_.field_70125_A);
    field_72400_f.func_71212_ac().func_71745_a(netserverhandler);
    netserverhandler.func_72567_b(new Packet4UpdateTime(worldserver.func_72820_D()));
    if (field_72400_f.func_71202_P().length() > 0) {
      p_72355_2_.func_71115_a(field_72400_f.func_71202_P(), field_72400_f.func_71227_R());
    }
    PotionEffect potioneffect;
    for (Iterator iterator = p_72355_2_.func_70651_bq().iterator();
        iterator.hasNext();
        netserverhandler.func_72567_b(
            new Packet41EntityEffect(p_72355_2_.field_70157_k, potioneffect))) {
      potioneffect = (PotionEffect) iterator.next();
    }

    p_72355_2_.func_71116_b();
  }