public boolean acceptPetition(L2PcInstance respondingAdmin, int petitionId) { if (!isValidPetition(petitionId)) return false; Petition currPetition = getPendingPetitions().get(petitionId); if (currPetition.getResponder() != null) return false; currPetition.setResponder(respondingAdmin); currPetition.setState(PetitionState.In_Process); // Petition application accepted. (Send to Petitioner) currPetition.sendPetitionerPacket( SystemMessage.getSystemMessage(SystemMessageId.PETITION_APP_ACCEPTED)); // Petition application accepted. Reciept No. is <ID> currPetition.sendResponderPacket( SystemMessage.getSystemMessage(SystemMessageId.PETITION_ACCEPTED_RECENT_NO_S1) .addNumber(currPetition.getId())); // Petition consultation with <Player> underway. currPetition.sendResponderPacket( SystemMessage.getSystemMessage(SystemMessageId.PETITION_WITH_S1_UNDER_WAY) .addPcName(currPetition.getPetitioner())); return true; }
public void viewPetition(L2PcInstance activeChar, int petitionId) { if (!activeChar.isGM()) return; if (!isValidPetition(petitionId)) return; Petition currPetition = getPendingPetitions().get(petitionId); TextBuilder htmlContent = new TextBuilder("<html><body>"); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE dd MMM HH:mm z"); htmlContent .append("<center><br><font color=\"LEVEL\">Petition #") .append(currPetition.getId()) .append("</font><br1>"); htmlContent.append("<img src=\"L2UI.SquareGray\" width=\"200\" height=\"1\"></center><br>"); htmlContent .append("Submit Time: ") .append(dateFormat.format(new Date(currPetition.getSubmitTime()))) .append("<br1>"); htmlContent .append("Petitioner: ") .append(currPetition.getPetitioner().getName()) .append("<br1>"); htmlContent .append("Petition Type: ") .append(currPetition.getTypeAsString()) .append("<br>") .append(currPetition.getContent()) .append("<br>"); htmlContent .append("<center><button value=\"Accept\" action=\"bypass -h admin_accept_petition ") .append(currPetition.getId()) .append("\"") .append("width=\"50\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br1>"); htmlContent .append("<button value=\"Reject\" action=\"bypass -h admin_reject_petition ") .append(currPetition.getId()) .append("\" ") .append("width=\"50\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br>"); htmlContent.append( "<button value=\"Back\" action=\"bypass -h admin_view_petitions\" width=\"40\" height=\"15\" back=\"sek.cbui94\" " + "fore=\"sek.cbui92\"></center>"); htmlContent.append("</body></html>"); NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0); htmlMsg.setHtml(htmlContent.toString()); activeChar.sendPacket(htmlMsg); }
public int submitPetition(L2PcInstance petitioner, String petitionText, int petitionType) { // Create a new petition instance and add it to the list of pending petitions. Petition newPetition = new Petition(petitioner, petitionText, petitionType); int newPetitionId = newPetition.getId(); getPendingPetitions().put(newPetitionId, newPetition); // Notify all GMs that a new petition has been submitted. String msgContent = petitioner.getName() + " has submitted a new petition."; // (ID: " + newPetitionId + ")."; GmListTable.broadcastToGMs( new CreatureSay(petitioner.getObjectId(), 17, "Petition System", msgContent)); return newPetitionId; }
public void sendPendingPetitionList(L2PcInstance activeChar) { TextBuilder htmlContent = new TextBuilder( "<html><body>" + "<center><font color=\"LEVEL\">Current Petitions</font><br><table width=\"300\">"); SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM HH:mm z"); if (getPendingPetitionCount() == 0) htmlContent.append( "<tr><td colspan=\"4\">There are no currently pending petitions.</td></tr>"); else htmlContent.append( "<tr><td></td><td><font color=\"999999\">Petitioner</font></td>" + "<td><font color=\"999999\">Petition Type</font></td><td><font color=\"999999\">Submitted</font></td></tr>"); for (Petition currPetition : getPendingPetitions().values()) { if (currPetition == null) continue; htmlContent.append("<tr><td>"); if (currPetition.getState() != PetitionState.In_Process) htmlContent .append("<button value=\"View\" action=\"bypass -h admin_view_petition ") .append(currPetition.getId()) .append("\" ") .append("width=\"40\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\">"); else htmlContent.append("<font color=\"999999\">In Process</font>"); htmlContent .append("</td><td>") .append(currPetition.getPetitioner().getName()) .append("</td><td>") .append(currPetition.getTypeAsString()) .append("</td><td>") .append(dateFormat.format(new Date(currPetition.getSubmitTime()))) .append("</td></tr>"); } htmlContent.append( "</table><br><button value=\"Refresh\" action=\"bypass -h admin_view_petitions\" width=\"50\" " + "height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"><br><button value=\"Back\" action=\"bypass -h admin_admin\" " + "width=\"40\" height=\"15\" back=\"sek.cbui94\" fore=\"sek.cbui92\"></center></body></html>"); NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0); htmlMsg.setHtml(htmlContent.toString()); activeChar.sendPacket(htmlMsg); }