Jump to content

vl4d

Members
  • Posts

    1,068
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by vl4d

  1. oxi den ginete

    axaxaxxaa re mlk psa3e prota kai meta mila omgggggggg

     

    package custom.VoteEngine;
    
    import java.io.*;
    import java.net.*;
    import java.util.Collection;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    import net.sf.l2j.gameserver.Announcements;
    import net.sf.l2j.gameserver.ThreadPoolManager;
    import net.sf.l2j.gameserver.model.L2World;
    import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    
    public class AutoVoteRewardHandler
    {
    protected static final Logger _log = Logger.getLogger(AutoVoteRewardHandler.class.getName());
    //URL from your server site at HopZone.net
    //Example: http://l2.hopzone.net/lineage2/moreinfo/YourServer/ID.html
    private final static String _url = "http://l2.hopzone.net/lineage2/moreinfo/L2WorldPvP/74078.html";//Add your URL from HopZone here!
    //Reward all online players each '_votesRequiredForReward' votes.
    private final int _votesRequiredForReward = 1;//
    //Initial check, time in minutes:
    //Default: 1 minute
    private final int initialCheck = 1;
    //Delay interval, time in minutes (do not set it too low):
    //Default: 10 minutes
    private final int delayForCheck = 1;
    
    //Item Id, Amount.
    private final static int[][] ITEMs =
    {
    	{ 5575, 10 }, //10 Event - Apiga(s)
    	{ 57, 1000000 }, //1 million Adena
    };
    
    //Do not change
    private int _lastVoteCount = 0;
    
    private AutoVoteRewardHandler()
    {
    	_log.info("[AutoVoteRewardHandler]: Vote Reward System Initiated.");
    	ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck * 60000, delayForCheck * 60000);
    }
    
    private class AutoReward implements Runnable
    {
    	public void run()
    	{
    		int votes = getVotes();
    		int rewardedPlayers = 0;
    		if (votes > -1)
    		{
    			if  ((getLastVoteCount() != 0) && (votes >= (getLastVoteCount() + _votesRequiredForReward)))
    			{
    				Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
    				for (L2PcInstance player : pls)
    				{
    					if ((player != null) && !player.getClient().isDetached())
    					{
    						for (int[] reward : ITEMs)
    						{
    							if (player.getInventory().validateCapacityByItemId(reward[0]))
    							{
    								player.addItem("reward", reward[0], reward[1], player, true);
    							}
    						}
    						rewardedPlayers++;
    					}
    				}
    				setLastVoteCount(getLastVoteCount() + _votesRequiredForReward);
    			}
    			else if (getLastVoteCount() == 0)
    			{
    				setLastVoteCount(votes);
    			}
    			_log.info("[AutoVoteRewardHandler]: Server Votes: " + votes + ", Rewarded players: " + rewardedPlayers);
    			Announcements.getInstance().announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + _votesRequiredForReward) + " votes!");
    		}
    		else
    		{
    			_log.log(Level.WARNING, "[AutoVoteRewardHandler]: Error retreiving server votes count!");
    		}
    	}
    }
    
    private static int getVotes()
    {
           		InputStreamReader isr = null;
    	BufferedReader in = null;
    	int votes = -1;
    	try
    	{
    	URLConnection conn = new URL(_url).openConnection();
    	conn.addRequestProperty("User-Agent", "Mozilla/4.76");
    	isr = new InputStreamReader(conn.getInputStream());
             	in = new BufferedReader(isr);
    		String inputLine;
    		while (((inputLine = in.readLine()) != null) && (votes == -1))
    		{
    			if (inputLine.contains("moreinfo_total_rank_text"))
    			{
    				try
    				{
    					votes = Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));
    				}
    				catch (Exception e)
    				{
    				}
    			}
    		}
    		in.close();
    	}
    	catch (Exception e)
    	{
    		_log.log(Level.WARNING, "[AutoVoteRewardHandler]: " + e.getMessage(), e);
    	}
    	return votes;
    }
    
    private void setLastVoteCount(int voteCount)
    {
    	_lastVoteCount = voteCount;
    }
    
    private int getLastVoteCount()
    {
    	return _lastVoteCount;
    }
    
    public static AutoVoteRewardHandler getInstance()
    {
    	return SingletonHolder._instance;
    }
    
    @SuppressWarnings("synthetic-access")
    private static class SingletonHolder
    {
    	protected static final AutoVoteRewardHandler _instance = new AutoVoteRewardHandler();
    }
    
    public static void main(String[] args)
    {
    	//System.out.println("Server votes: " + getVotes());//Just a test.
    	AutoVoteRewardHandler.getInstance();
    }
    }
    

     

    ama exi problima pesto m ;)

  2. 9elw help apo kapion empeiro se java ;)

     

    9elw na ftia3w ena java(oxi .py) quest ala exw kolisi se ena pragma ph sta quest gia na to arxiseis 8eli na ftia3eis ena htm sto deafult to anoigeis kai meta arxizi to quest egw 8elw na kano to e3is xwris htm sto deafult na arxisei to quest alla me ena .htm pou 8a einai mazh sto quest (ph: buffer.java + main.htm)

    kai na anoigei to quest...

    prospa8hsa oso mporw kalutera na to e3hghsw ;)

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock