示例#1
0
  private void sendChunk(final EntityPlayerMP player, final SchematicTransfer transfer) {
    transfer.setState(SchematicTransfer.State.CHUNK);

    Reference.logger.trace(
        "Sending chunk {},{},{}", transfer.baseX, transfer.baseY, transfer.baseZ);
    final MessageDownloadChunk message =
        new MessageDownloadChunk(
            transfer.schematic, transfer.baseX, transfer.baseY, transfer.baseZ);
    PacketHandler.INSTANCE.sendTo(message, player);
  }
示例#2
0
  private void processQueue() {
    if (this.transferMap.size() == 0) {
      return;
    }

    final EntityPlayerMP player = this.transferMap.keySet().iterator().next();
    final SchematicTransfer transfer = this.transferMap.remove(player);

    if (transfer == null) {
      return;
    }

    if (!transfer.state.isWaiting()) {
      if (++transfer.timeout >= Constants.Network.TIMEOUT) {
        if (++transfer.retries >= Constants.Network.RETRIES) {
          Reference.logger.warn("{}'s download was dropped!", player.getName());
          return;
        }

        Reference.logger.warn(
            "{}'s download timed out, retrying (#{})", player.getName(), transfer.retries);

        sendChunk(player, transfer);
        transfer.timeout = 0;
      }
    } else if (transfer.state == SchematicTransfer.State.BEGIN_WAIT) {
      sendBegin(player, transfer);
    } else if (transfer.state == SchematicTransfer.State.CHUNK_WAIT) {
      sendChunk(player, transfer);
    } else if (transfer.state == SchematicTransfer.State.END_WAIT) {
      sendEnd(player, transfer);
      return;
    }

    this.transferMap.put(player, transfer);
  }
示例#3
0
  private void sendBegin(final EntityPlayerMP player, final SchematicTransfer transfer) {
    transfer.setState(SchematicTransfer.State.BEGIN);

    final MessageDownloadBegin message = new MessageDownloadBegin(transfer.schematic);
    PacketHandler.INSTANCE.sendTo(message, player);
  }