public boolean isPetitionInProcess() { for (Petition currPetition : getPendingPetitions().values()) { if (currPetition == null) continue; if (currPetition.getState() == PetitionState.In_Process) return true; } return false; }
public boolean rejectPetition(L2PcInstance respondingAdmin, int petitionId) { if (!isValidPetition(petitionId)) return false; Petition currPetition = getPendingPetitions().get(petitionId); if (currPetition.getResponder() != null) return false; currPetition.setResponder(respondingAdmin); return (currPetition.endPetitionConsultation(PetitionState.Responder_Reject)); }
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 boolean isPlayerPetitionPending(L2PcInstance petitioner) { if (petitioner != null) for (Petition currPetition : getPendingPetitions().values()) { if (currPetition == null) continue; if (currPetition.getPetitioner() != null && currPetition.getPetitioner().getObjectId() == petitioner.getObjectId()) return true; } return false; }
public boolean endActivePetition(L2PcInstance player) { if (!player.isGM()) return false; for (Petition currPetition : getPendingPetitions().values()) { if (currPetition == null) continue; if (currPetition.getResponder() != null && currPetition.getResponder().getObjectId() == player.getObjectId()) return (currPetition.endPetitionConsultation(PetitionState.Completed)); } return false; }
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 checkPetitionMessages(L2PcInstance petitioner) { if (petitioner != null) for (Petition currPetition : getPendingPetitions().values()) { if (currPetition == null) continue; if (currPetition.getPetitioner() != null && currPetition.getPetitioner().getObjectId() == petitioner.getObjectId()) { for (CreatureSay logMessage : currPetition.getLogMessages()) petitioner.sendPacket(logMessage); return; } } }
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 boolean cancelActivePetition(L2PcInstance player) { for (Petition currPetition : getPendingPetitions().values()) { if (currPetition.getPetitioner() != null && currPetition.getPetitioner().getObjectId() == player.getObjectId()) return (currPetition.endPetitionConsultation(PetitionState.Petitioner_Cancel)); if (currPetition.getResponder() != null && currPetition.getResponder().getObjectId() == player.getObjectId()) return (currPetition.endPetitionConsultation(PetitionState.Responder_Cancel)); } return false; }
public boolean isPlayerInConsultation(L2PcInstance player) { if (player != null) for (Petition currPetition : getPendingPetitions().values()) { if (currPetition == null) continue; if (currPetition.getState() != PetitionState.In_Process) continue; if ((currPetition.getPetitioner() != null && currPetition.getPetitioner().getObjectId() == player.getObjectId()) || (currPetition.getResponder() != null && currPetition.getResponder().getObjectId() == player.getObjectId())) return true; } return false; }
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); }
public int getPlayerTotalPetitionCount(L2PcInstance player) { if (player == null) return 0; int petitionCount = 0; for (Petition currPetition : getPendingPetitions().values()) { if (currPetition == null) continue; if (currPetition.getPetitioner() != null && currPetition.getPetitioner().getObjectId() == player.getObjectId()) petitionCount++; } for (Petition currPetition : getCompletedPetitions().values()) { if (currPetition == null) continue; if (currPetition.getPetitioner() != null && currPetition.getPetitioner().getObjectId() == player.getObjectId()) petitionCount++; } return petitionCount; }
public boolean sendActivePetitionMessage(L2PcInstance player, String messageText) { // if (!isPlayerInConsultation(player)) // return false; CreatureSay cs; for (Petition currPetition : getPendingPetitions().values()) { if (currPetition == null) continue; if (currPetition.getPetitioner() != null && currPetition.getPetitioner().getObjectId() == player.getObjectId()) { cs = new CreatureSay( player.getObjectId(), Say2.PETITION_PLAYER, player.getName(), messageText); currPetition.addLogMessage(cs); currPetition.sendResponderPacket(cs); currPetition.sendPetitionerPacket(cs); return true; } if (currPetition.getResponder() != null && currPetition.getResponder().getObjectId() == player.getObjectId()) { cs = new CreatureSay(player.getObjectId(), Say2.PETITION_GM, player.getName(), messageText); currPetition.addLogMessage(cs); currPetition.sendResponderPacket(cs); currPetition.sendPetitionerPacket(cs); return true; } } return false; }
public boolean isPetitionInProcess(int petitionId) { if (!isValidPetition(petitionId)) return false; Petition currPetition = getPendingPetitions().get(petitionId); return (currPetition.getState() == PetitionState.In_Process); }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { StringBuffer jb = new StringBuffer(); String line = null; try { BufferedReader reader = request.getReader(); while ((line = reader.readLine()) != null) jb.append(line); } catch (Exception e) { System.out.println("Erreur"); } JSONObject json = new JSONObject(jb.toString()); System.out.println(jb.toString()); Petition p = new Petition(); p.setTitle(json.getValue("title")); p.setDescription(json.getValue("text")); response.getWriter().println(p.toString()); UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); // Récupération de l'utilisateur google courant if (user != null) { System.out.println(user.toString()); } else { System.out.println("user null"); } ObjectifyService.ofy().save().entities(p).now(); response.getWriter().println("Ajout effectué"); }