Example #1
0
 private static void setBookState(EntityPlayer player, boolean state) {
   Team team = QuestingData.getQuestingData(player).getTeam();
   for (Team.PlayerEntry entry : team.getPlayers()) {
     if (entry.isInTeam() && entry.getName().equals(QuestingData.getUserName(player))) {
       entry.setBookOpen(state);
       break;
     }
   }
 }
Example #2
0
 @Override
 public void handleCommand(ICommandSender sender, String[] arguments) {
   sendChat(
       sender,
       QuestingData.isQuestActive()
           ? "hqm.message.questAlreadyActivated"
           : "hqm.message.questActivated");
   QuestingData.activateQuest();
 }
Example #3
0
 private void handleSelectTask(EntityPlayer player, DataReader dr) {
   int questId = dr.readData(DataBitHelper.QUESTS);
   int taskId = dr.readData(DataBitHelper.TASKS);
   Quest quest = Quest.getQuest(questId);
   if (quest != null && taskId >= 0 && taskId < quest.getTasks().size()) {
     QuestingData data = QuestingData.getQuestingData(player);
     data.selectedQuest = questId;
     data.selectedTask = taskId;
   }
 }
Example #4
0
  private static void sendToBookPlayer(String name, DataWriter dw) {
    if (QuestingData.getQuestingData(name).getTeam().getEntry(name).isBookOpen()) {
      EntityPlayer player = QuestingData.getPlayer(name);
      if (player != null) {
        dw.sendToPlayer((EntityPlayerMP) player);
      }
    }

    String playerName = nameOverrideReversed.get(name);
    if (playerName != null) {
      EntityPlayer other = QuestingData.getPlayer(playerName);
      if (other != null) {
        dw.sendToPlayer((EntityPlayerMP) other);
      }
    }
  }
Example #5
0
 public static void sendToAllPlayersWithOpenBook(DataWriter dw) {
   if (!Quest.isEditing || QuestingData.isSinglePlayer()) {
     for (String name :
         FMLCommonHandler.instance()
             .getMinecraftServerInstance()
             .getConfigurationManager()
             .getAllUsernames()) {
       sendToBookPlayer(name, dw);
     }
   }
   dw.close();
 }
Example #6
0
 public static void sendToServer(DataWriter dw) {
   if (!Quest.isEditing || QuestingData.isSinglePlayer()) {
     dw.sendToServer();
   }
   dw.close();
 }
Example #7
0
 public static void sendToAllPlayers(DataWriter dw) {
   if (!Quest.isEditing && !QuestingData.isSinglePlayer()) {
     dw.sendToAllPlayers();
   }
   dw.close();
 }
Example #8
0
 public static void sendToRawPlayer(EntityPlayer player, DataWriter dw) {
   if (!Quest.isEditing || QuestingData.isSinglePlayer()) {
     dw.sendToPlayer((EntityPlayerMP) player);
   }
   dw.close();
 }
Example #9
0
 public static void sendToPlayer(String name, DataWriter dw) {
   if (!Quest.isEditing || QuestingData.isSinglePlayer()) {
     sendToBookPlayer(name, dw);
   }
   dw.close();
 }
Example #10
0
  private void onPacketData(byte[] incomingData, EntityPlayer player, boolean onServer) {

    DataReader dr = null;
    try {
      dr = getDataReaderForPacket(incomingData);
      if (dr == null) {
        return;
      }

      // read the packet count that was manually read before the creation of the data reader
      dr.readByte();

      PacketId id = PacketId.getFromId((byte) dr.readData(DataBitHelper.PACKET_ID));

      switch (id) {
        case OPEN_INTERFACE:
          boolean isOpBook = dr.readBoolean();
          if (isOpBook) {
            String openName = dr.readString(DataBitHelper.NAME_LENGTH);
            clientNameOverride =
                openName.equals(player.getGameProfile().getName()) ? null : openName;
          }
          QuestingData.getQuestingData(player).receiveDataFromServer(dr);
          GuiQuestBook.displayGui(player, isOpBook);
          break;
        case QUEST_DATA:
          handleQuestData(player, dr);
          break;
        case TASK_REQUEST:
          handleTaskRequest(player, dr);
          break;
        case CLAIM_REWARD:
          handleRewardClaim(player, dr);
          break;
        case SELECT_TASK:
          handleSelectTask(player, dr);
          break;
        case SOUND:
          SoundHandler.handleSoundPacket(dr);
          break;
        case LORE:
          SoundHandler.handleLorePacket(player, dr);
          break;
        case TEAM:
          Team.handlePacket(player, dr, onServer);
          break;
        case REFRESH_INTERFACE:
          QuestingData.getQuestingData(player).receiveDataFromServer(dr);
          break;
        case CLOSE_INTERFACE:
          remove(player);
          break;
        case REFRESH_TEAM:
          QuestingData.getQuestingData(player).getTeam().onPacket(dr);
          break;
        case OP_BOOK:
          OPBookHelper.handlePacket(player, dr);
          break;
        case QUEST_SYNC:
          QuestLine.receiveServerSync(dr);
          GuiEditMenuItem.Search.initItems();
          break;
        case BAG_INTERFACE:
          GuiReward.open(player, dr);
          break;
        case DEATH_STATS_UPDATE:
          DeathStats.handlePacket(player, dr);
          break;
        case TEAM_STATS_UPDATE:
          TeamStats.handlePacket(player, dr);
          break;
        case TRACKER_ACTIVATE:
          TileEntityTracker.openInterface(player, dr);
          break;
        case TRACKER_RESPONSE:
          TileEntityTracker.saveToServer(player, dr);
          break;
        case BLOCK_SYNC:
          handleBlockSync(player, dr);
      }
    } catch (Throwable ex) {
      ex.printStackTrace();
    } finally {
      if (dr != null) {
        dr.close();
      }
    }
  }