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; } } }
@Override public void handleCommand(ICommandSender sender, String[] arguments) { sendChat( sender, QuestingData.isQuestActive() ? "hqm.message.questAlreadyActivated" : "hqm.message.questActivated"); QuestingData.activateQuest(); }
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; } }
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); } } }
public static void sendToAllPlayersWithOpenBook(DataWriter dw) { if (!Quest.isEditing || QuestingData.isSinglePlayer()) { for (String name : FMLCommonHandler.instance() .getMinecraftServerInstance() .getConfigurationManager() .getAllUsernames()) { sendToBookPlayer(name, dw); } } dw.close(); }
public static void sendToServer(DataWriter dw) { if (!Quest.isEditing || QuestingData.isSinglePlayer()) { dw.sendToServer(); } dw.close(); }
public static void sendToAllPlayers(DataWriter dw) { if (!Quest.isEditing && !QuestingData.isSinglePlayer()) { dw.sendToAllPlayers(); } dw.close(); }
public static void sendToRawPlayer(EntityPlayer player, DataWriter dw) { if (!Quest.isEditing || QuestingData.isSinglePlayer()) { dw.sendToPlayer((EntityPlayerMP) player); } dw.close(); }
public static void sendToPlayer(String name, DataWriter dw) { if (!Quest.isEditing || QuestingData.isSinglePlayer()) { sendToBookPlayer(name, dw); } dw.close(); }
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(); } } }