Jump to content
  • 0

Question

Posted (edited)

So here I have one OFFLINE petition.. how does it works? if there is no gms on the list or online , the petition msg will be send into email of the choosen char.

 

I made it working for my rev , and fixed few bugs. I have only 2 small problems now.. I want to add Config on this system , to send the mail in more than 1 char.. Is this possible? and if Yes what type of Config will do the proper work? public static String ?

 

And my other problem is , If you register on /gmlist ( list on by admin panel ) After you cant be removed from list xD LIST OFF from admin panel not working after my edits to make it work with offline and mail :D

If gm restart , remove by list is working automatic like it should 

private static String   _MAIL_PETITION_RECEIPT              = "TESTTEST";
/*
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jserver.gameserver.network.clientpackets;

import com.l2jserver.Config;
import com.l2jserver.gameserver.GmListTable;
import com.l2jserver.gameserver.instancemanager.PetitionManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.datatables.CharNameTable;
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.instancemanager.MailManager;
import com.l2jserver.gameserver.model.entity.Message;

/**
 * <p>Format: (c) Sd
 * <ul>
 * <li>S: content</li>
 * <li>d: type</li>
 * </ul></p>
 * @author -Wooden-, TempyIncursion
 *
 */
public final class RequestPetition extends L2GameClientPacket
{
	private static final String _C__7F_RequestPetition = "[C] 7F RequestPetition";
	//private static Logger _log = Logger.getLogger(RequestPetition.class.getName());
	
	private String _content;
	private int _type;       // 1 = on : 0 = off;
	   /*
	    * SL2 ADDON: v0.3349 -- true=if no GM online, petition will be sent to specified character as mail
	    *                      (for him to be able to read it next logon...)
	    */
	   private static boolean  _SEND_MAIL_IF_NO_GM_FOR_PETITION    = Config.OFFLINE_PETITION_ENABLE;
	   private static boolean  _SEND_MAIL_ONLY_WHEN_NO_GM_ONLINE   = false; //-- false=will send mail even when GM is on, just not on GM LIST (available for petitioning)
	   private static String   _MAIL_PETITION_RECEIPT              = "TESTTEST";
	   private static int      _MAIL_PETITION_RECEIPT_ID           = CharNameTable.getInstance().getIdByName(_MAIL_PETITION_RECEIPT);
	
	
	@Override
	protected void readImpl()
	{
		_content = readS();
		_type    = readD();
	}
	
	@Override
	protected void runImpl()
	{
		L2PcInstance activeChar = getClient().getActiveChar();
		if (activeChar == null)
			return;
		
		if (!GmListTable.getInstance().isGmOnline(false))
		{
			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_GM_PROVIDING_SERVICE_NOW));
			          
			           if (!_SEND_MAIL_IF_NO_GM_FOR_PETITION && _MAIL_PETITION_RECEIPT_ID < 1)
			               return;
		}
		
		if (!PetitionManager.getInstance().isPetitioningAllowed())
		{
			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.GAME_CLIENT_UNABLE_TO_CONNECT_TO_PETITION_SERVER));
			return;
		}
		
		if (PetitionManager.getInstance().isPlayerPetitionPending(activeChar))
		{
			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ONLY_ONE_ACTIVE_PETITION_AT_TIME));
			return;
		}
		
		if (PetitionManager.getInstance().getPendingPetitionCount() == Config.MAX_PETITIONS_PENDING)
		{
			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PETITION_SYSTEM_CURRENT_UNAVAILABLE));
			return;
		}
		
		int totalPetitions = PetitionManager.getInstance().getPlayerTotalPetitionCount(activeChar) + 1;
		
		if (totalPetitions > Config.MAX_PETITIONS_PER_PLAYER)
		{
			SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.WE_HAVE_RECEIVED_S1_PETITIONS_TODAY);
			sm.addNumber(totalPetitions);
			activeChar.sendPacket(sm);
			sm = null;
			return;
		}
		
		if (_content.length() > 255)
		{
			activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PETITION_MAX_CHARS_255));
			return;
		}
		       if (!GmListTable.getInstance().isGmOnline(false))
			       {          
			         //  activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_GM_PROVIDING_SERVICE_NOW));
		    	        activeChar.sendPacket(new CreatureSay(1, Say2.PARTY, "Petition", "There are no GM's Online or on Gmlist!"));
		    	        activeChar.sendPacket(new CreatureSay(1, Say2.PARTY, "Petition", "Initializing OFFLINE Pettition System!"));
			          
			           if (!_SEND_MAIL_IF_NO_GM_FOR_PETITION || (_SEND_MAIL_IF_NO_GM_FOR_PETITION && _MAIL_PETITION_RECEIPT_ID < 1))
			               return;
			           else
			           {
			               activeChar.sendMessage("=> YOUR PETITION MESSAGE WILL BE SENT TO ADMIN BY E-MAIL INSTEAD <=");
			               activeChar.sendMessage("Wait patiently for an answer, and always remember to describe petition/problem/question/matter of petition.");
			
			               //SEND SYSTEM MAIL (WITH PETITION MSG) TO DEFINED ADMIN/GM ACCOUNT          
			               if (_SEND_MAIL_ONLY_WHEN_NO_GM_ONLINE && GmListTable.getInstance().isGmOnline(true))
			               {
			                   activeChar.sendMessage("ERROR: You are not allowed to send offline petition.");
			                   return;
			               }
			          
			               int petitionId = IdFactory.getInstance().getNextId();              
			               Message petitionMsg = new Message(activeChar.getObjectId(), _MAIL_PETITION_RECEIPT_ID, false, "[P: " + PetitionManager.getPetitionTypeString(_type) + "] " + petitionId, _content, 0);            
			               activeChar.sendMessage("OFFLINE PETITION: Your petition is now going to be send with unique Petition ID: " + petitionId);            
			               MailManager.getInstance().sendMessage(petitionMsg);            
			               return;
			           }
			       }              
			
		int petitionId = PetitionManager.getInstance().submitPetition(activeChar, _content, _type);
		
		SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.PETITION_ACCEPTED_RECENT_NO_S1);
		sm.addNumber(petitionId);
		activeChar.sendPacket(sm);
		
		sm = SystemMessage.getSystemMessage(SystemMessageId.SUBMITTED_YOU_S1_TH_PETITION_S2_LEFT);
		sm.addNumber(totalPetitions);
		sm.addNumber(Config.MAX_PETITIONS_PER_PLAYER - totalPetitions);
		activeChar.sendPacket(sm);
		
		sm = SystemMessage.getSystemMessage(SystemMessageId.S1_PETITION_ON_WAITING_LIST);
		sm.addNumber(PetitionManager.getInstance().getPendingPetitionCount());
		activeChar.sendPacket(sm);
		sm = null;
	}
	
	/* (non-Javadoc)
	 * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()
	 */
	@Override
	public String getType()
	{
		return _C__7F_RequestPetition;
	}
}


I tryed This about configs

public static List<Integer> GM_NAMES_OFFLINE_PETITION = new ArrayList<Integer>();
			          String[] propertySplit2 = L2JModSettings.getProperty("GmNamesForOfflinePetition", "name").split(",");
						for(String gmnames: propertySplit2)
						{
						try
						{
						GM_NAMES_OFFLINE_PETITION.add(Integer.parseInt(gmnames));
						}
						catch (NumberFormatException nfe)
						{
						if (propertySplit2.length > 0)
						_log.warning("Error in load config.");
						}
						}

and on take config

private static List<Integer>   _MAIL_PETITION_RECEIPT              = Config.GM_NAMES_OFFLINE_PETITION;

But i have error on 

private static int      _MAIL_PETITION_RECEIPT_ID           = CharNameTable.getInstance().getIdByName(_MAIL_PETITION_RECEIPT);

The method getIdByName(String) in the type CharNameTable is not applicable for the arguments (List<Integer>)

 

61v2.png

 

 

any idea? :/

Edited by ČυяŞŀŅğ

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

_MAIL_PETITION_RECEIPT_ID must be a List<Integer> or an int[] from now, not an int anymore.

 

CharNameTable.getInstance().getIdByName( returns an int, as it's used on multiple places over the sources you shouldn't edit it directly, so you either create a new method in CharNameTable to retrieve multiple ints and return it in a List (putting your String as a parameter, parsing it (.split or StringTokenizer), and for looping the result of the parsing to finally getIdByName( each result, add it in a List / int[] and returning it).

 

You could also rework getIdByName( in order to parse the String in any case, and if hasMoreTokens(), for loop it instead of regular case.

Edited by Tryskell

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...