Jump to content

Question

Posted

Kalispera 8elo na me help me tin vote manager den mou doulevi to hopzone to topzone einai ok kati exi to hopzone sas dixno ta codes mou mimpos exo la8os egw L2jFrozen Exo

 

 

Extensions.Vote.DDSConverter.java

package Extensions.Vote;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.logging.Logger;

import javax.imageio.ImageIO;

public class DDSConverter
{
	public static final Logger log = Logger.getLogger(DDSConverter.class.getName());
	
	protected static class Color
	{
		
		@Override
		public boolean equals(Object obj)
		{
			if (this == obj)
			{
				return true;
			}
			if ((obj == null) || (getClass() != obj.getClass()))
			{
				return false;
			}
			Color color = (Color) obj;
			if (b != color.b)
			{
				return false;
			}
			if (g != color.g)
			{
				return false;
			}
			return r == color.r;
		}
		
		@Override
		public int hashCode()
		{
			int i = r;
			i = (29 * i) + g;
			i = (29 * i) + b;
			return i;
		}
		
		protected int r;
		protected int g;
		protected int b;
		
		public Color()
		{
			r = g = b = 0;
		}
		
		public Color(int i, int j, int k)
		{
			r = i;
			g = j;
			b = k;
		}
	}
	
	public static ByteBuffer convertToDDS(File file) throws IOException
	{
		if (file == null)
		{
			String s = "nullValue.FileIsNull";
			log.severe(s);
			throw new IllegalArgumentException(s);
		}
		if (!file.exists() || !file.canRead())
		{
			String s1 = "DDSConverter.NoFileOrNoPermission";
			log.severe(s1);
			throw new IllegalArgumentException(s1);
		}
		BufferedImage bufferedimage = ImageIO.read(file);
		if (bufferedimage == null)
		{
			return null;
		}
		if (bufferedimage.getColorModel().hasAlpha())
		{
			return convertToDxt3(bufferedimage);
		}
		return convertToDxt1NoTransparency(bufferedimage);
	}
	
	public static ByteBuffer convertToDxt1NoTransparency(BufferedImage bufferedimage)
	{
		if (bufferedimage == null)
		{
			return null;
		}
		int ai[] = new int[16];
		int i = 128 + ((bufferedimage.getWidth() * bufferedimage.getHeight()) / 2);
		ByteBuffer bytebuffer = ByteBuffer.allocate(i);
		bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
		buildHeaderDxt1(bytebuffer, bufferedimage.getWidth(), bufferedimage.getHeight());
		int j = bufferedimage.getWidth() / 4;
		int k = bufferedimage.getHeight() / 4;
		for (int l = 0; l < k; l++)
		{
			for (int i1 = 0; i1 < j; i1++)
			{
				BufferedImage bufferedimage1 = bufferedimage.getSubimage(i1 * 4, l * 4, 4, 4);
				bufferedimage1.getRGB(0, 0, 4, 4, ai, 0, 4);
				Color acolor[] = getColors888(ai);
				for (int j1 = 0; j1 < ai.length; j1++)
				{
					ai[j1] = getPixel565(acolor[j1]);
					acolor[j1] = getColor565(ai[j1]);
				}
				
				int ai1[] = determineExtremeColors(acolor);
				if (ai[ai1[0]] < ai[ai1[1]])
				{
					int k1 = ai1[0];
					ai1[0] = ai1[1];
					ai1[1] = k1;
				}
				bytebuffer.putShort((short) ai[ai1[0]]);
				bytebuffer.putShort((short) ai[ai1[1]]);
				long l1 = computeBitMask(acolor, ai1);
				bytebuffer.putInt((int) l1);
			}
		}
		return bytebuffer;
	}
	
	public static ByteBuffer convertToDxt3(BufferedImage bufferedimage)
	{
		if (bufferedimage == null)
		{
			return null;
		}
		if (!bufferedimage.getColorModel().hasAlpha())
		{
			return convertToDxt1NoTransparency(bufferedimage);
		}
		int ai[] = new int[16];
		int i = 128 + (bufferedimage.getWidth() * bufferedimage.getHeight());
		ByteBuffer bytebuffer = ByteBuffer.allocate(i);
		bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
		buildHeaderDxt3(bytebuffer, bufferedimage.getWidth(), bufferedimage.getHeight());
		int j = bufferedimage.getWidth() / 4;
		int k = bufferedimage.getHeight() / 4;
		for (int l = 0; l < k; l++)
		{
			for (int i1 = 0; i1 < j; i1++)
			{
				BufferedImage bufferedimage1 = bufferedimage.getSubimage(i1 * 4, l * 4, 4, 4);
				bufferedimage1.getRGB(0, 0, 4, 4, ai, 0, 4);
				Color acolor[] = getColors888(ai);
				for (int j1 = 0; j1 < ai.length; j1 += 2)
				{
					bytebuffer.put((byte) ((ai[j1] >>> 28) | (ai[j1 + 1] >>> 24)));
				}
				
				for (int k1 = 0; k1 < ai.length; k1++)
				{
					ai[k1] = getPixel565(acolor[k1]);
					acolor[k1] = getColor565(ai[k1]);
				}
				
				int ai1[] = determineExtremeColors(acolor);
				if (ai[ai1[0]] < ai[ai1[1]])
				{
					int l1 = ai1[0];
					ai1[0] = ai1[1];
					ai1[1] = l1;
				}
				bytebuffer.putShort((short) ai[ai1[0]]);
				bytebuffer.putShort((short) ai[ai1[1]]);
				long l2 = computeBitMask(acolor, ai1);
				bytebuffer.putInt((int) l2);
			}
		}
		return bytebuffer;
	}
	
	protected static void buildHeaderDxt1(ByteBuffer bytebuffer, int i, int j)
	{
		bytebuffer.rewind();
		bytebuffer.put((byte) 68);
		bytebuffer.put((byte) 68);
		bytebuffer.put((byte) 83);
		bytebuffer.put((byte) 32);
		bytebuffer.putInt(124);
		int k = 0xa1007;
		bytebuffer.putInt(k);
		bytebuffer.putInt(j);
		bytebuffer.putInt(i);
		bytebuffer.putInt((i * j) / 2);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.position(bytebuffer.position() + 44);
		bytebuffer.putInt(32);
		bytebuffer.putInt(4);
		bytebuffer.put((byte) 68);
		bytebuffer.put((byte) 88);
		bytebuffer.put((byte) 84);
		bytebuffer.put((byte) 49);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.putInt(4096);
		bytebuffer.putInt(0);
		bytebuffer.position(bytebuffer.position() + 12);
	}
	
	protected static void buildHeaderDxt3(ByteBuffer bytebuffer, int i, int j)
	{
		bytebuffer.rewind();
		bytebuffer.put((byte) 68);
		bytebuffer.put((byte) 68);
		bytebuffer.put((byte) 83);
		bytebuffer.put((byte) 32);
		bytebuffer.putInt(124);
		int k = 0xa1007;
		bytebuffer.putInt(k);
		bytebuffer.putInt(j);
		bytebuffer.putInt(i);
		bytebuffer.putInt(i * j);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.position(bytebuffer.position() + 44);
		bytebuffer.putInt(32);
		bytebuffer.putInt(4);
		bytebuffer.put((byte) 68);
		bytebuffer.put((byte) 88);
		bytebuffer.put((byte) 84);
		bytebuffer.put((byte) 51);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.putInt(0);
		bytebuffer.putInt(4096);
		bytebuffer.putInt(0);
		bytebuffer.position(bytebuffer.position() + 12);
	}
	
	protected static int[] determineExtremeColors(Color acolor[])
	{
		int i = 0x80000000;
		int ai[] = new int[2];
		for (int j = 0; j < (acolor.length - 1); j++)
		{
			for (int k = j + 1; k < acolor.length; k++)
			{
				int l = distance(acolor[j], acolor[k]);
				if (l > i)
				{
					i = l;
					ai[0] = j;
					ai[1] = k;
				}
			}
			
		}
		return ai;
	}
	
	protected static long computeBitMask(Color acolor[], int ai[])
	{
		Color acolor1[] =
		{
			null,
			null,
			new Color(),
			new Color()
		};
		acolor1[0] = acolor[ai[0]];
		acolor1[1] = acolor[ai[1]];
		if (acolor1[0].equals(acolor1[1]))
		{
			return 0L;
		}
		acolor1[2].r = ((2 * acolor1[0].r) + acolor1[1].r + 1) / 3;
		acolor1[2].g = ((2 * acolor1[0].g) + acolor1[1].g + 1) / 3;
		acolor1[2].b = ((2 * acolor1[0].b) + acolor1[1].b + 1) / 3;
		acolor1[3].r = (acolor1[0].r + (2 * acolor1[1].r) + 1) / 3;
		acolor1[3].g = (acolor1[0].g + (2 * acolor1[1].g) + 1) / 3;
		acolor1[3].b = (acolor1[0].b + (2 * acolor1[1].b) + 1) / 3;
		long l = 0L;
		for (int i = 0; i < acolor.length; i++)
		{
			int j = 0x7fffffff;
			int k = 0;
			for (int i1 = 0; i1 < acolor1.length; i1++)
			{
				int j1 = distance(acolor[i], acolor1[i1]);
				if (j1 < j)
				{
					j = j1;
					k = i1;
				}
			}
			
			l |= k << (i * 2);
		}
		return l;
	}
	
	protected static int getPixel565(Color color)
	{
		int i = color.r >> 3;
		int j = color.g >> 2;
		int k = color.b >> 3;
		return (i << 11) | (j << 5) | k;
	}
	
	protected static Color getColor565(int i)
	{
		Color color = new Color();
		color.r = (int) (i & 63488L) >> 11;
		color.g = (int) (i & 2016L) >> 5;
		color.b = (int) (i & 31L);
		return color;
	}
	
	protected static Color[] getColors888(int ai[])
	{
		Color acolor[] = new Color[ai.length];
		for (int i = 0; i < ai.length; i++)
		{
			acolor[i] = new Color();
			acolor[i].r = (int) (ai[i] & 0xff0000L) >> 16;
			acolor[i].g = (int) (ai[i] & 65280L) >> 8;
			acolor[i].b = (int) (ai[i] & 255L);
		}
		return acolor;
	}
	
	protected static int distance(Color color, Color color1)
	{
		return ((color1.r - color.r) * (color1.r - color.r)) + ((color1.g - color.g) * (color1.g - color.g)) + ((color1.b - color.b) * (color1.b - color.b));
	}
}

Extensions.Vote.Votemanager.java

/*
 * 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 Extensions.Vote;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

import Extensions.Vote.Tasks.MonthlyResetTask;
import Extensions.Vote.Tasks.TriesResetTask;

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.util.database.L2DatabaseFactory;

public class VoteManager
{
	protected static final Logger _log = Logger.getLogger(VoteManager.class.getName());

	private static boolean hasVotedHop;
	private static boolean hasVotedTop;

	public VoteManager()
	{
	}

	public static void load()
	{
		_log.log(Level.INFO, "VoteManager: initialized.");
		TriesResetTask.getInstance();
		MonthlyResetTask.getInstance();
	}

	protected static int getHopZoneVotes()
	{
		int votes = -1;
		String Hopzonelink = Config.VOTE_LINK_HOPZONE;
		InputStreamReader isr = null;
		BufferedReader br = null;
		
		try
		{
			URLConnection con = new URL(Hopzonelink).openConnection();
			con.addRequestProperty("User-L2Hopzone", "Mozilla/4.76");
			isr = new InputStreamReader(con.getInputStream());
			br = new BufferedReader(isr);
			
			String line;
			while ((line = br.readLine()) != null)
			{
				if (line.contains("rank anonymous tooltip"))
				{
					votes = Integer.valueOf(line.split(">")[2].replace("</span", ""));
					break;
				}
			}
			
			br.close();
			isr.close();
		}
		catch (Exception e)
		{
			if (Config.DEVELOPER)
			{
				e.printStackTrace();
			}
		}
		return votes;
	}

	protected static int getTopZoneVotes()
	{
		int votes = -1;
		URL url = null;
		URLConnection con = null;
		InputStream is = null;
		InputStreamReader isr = null;
		BufferedReader in = null;
		try
		{
			url = new URL(Config.VOTE_LINK_TOPZONE);
			con = url.openConnection();
			con.addRequestProperty("User-Agent", "L2TopZone");
			is = con.getInputStream();
			isr = new InputStreamReader(is);
			in = new BufferedReader(isr);
			String inputLine;
			while ((inputLine = in.readLine()) != null)
			{
				if (inputLine.contains("Votes"))
				{
					String votesLine = inputLine;
					
					votes = Integer.valueOf(votesLine.split(">")[3].replace("</div", ""));
					break;
				}
			}
		}
		catch (Exception e)
		{
			if (Config.DEVELOPER)
			{
				e.printStackTrace();
			}
		}
		return votes;
	}

	public static String hopCd(L2PcInstance player)
	{
		long hopCdMs = 0;
		long voteDelay = 43200000L;
		PreparedStatement statement = null;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			statement = con.prepareStatement("SELECT lastVoteHopzone FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());

			ResultSet rset = statement.executeQuery();

			while (rset.next())
			{
				hopCdMs = rset.getLong("lastVoteHopzone");
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
		 
		SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");

		Date resultdate = new Date(hopCdMs + voteDelay);
		return sdf.format(resultdate);
	}

	public static String topCd(L2PcInstance player)
	{
		long topCdMs = 0;
		long voteDelay = 43200000L;
		PreparedStatement statement = null;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			statement = con.prepareStatement("SELECT lastVoteTopzone FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());

			ResultSet rset = statement.executeQuery();

			while (rset.next())
			{
				topCdMs = rset.getLong("lastVoteTopzone");
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
		 
		SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");

		Date resultdate = new Date(topCdMs + voteDelay);
		return sdf.format(resultdate);
	}

	public static String whosVoting()
	{
		for (L2PcInstance voter : L2World.getInstance().getAllPlayers())
		{
			if (voter.isVoting())
			{
				return voter.getName();
			}
		}
		return "None";
	}

	public static void hopvote(final L2PcInstance player)
	{
		long lastVoteHopzone = 0L;
		long voteDelay = 43200000L;
		final int firstvoteshop;

		firstvoteshop = getHopZoneVotes();

		class hopvotetask implements Runnable
		{
			private final L2PcInstance p;

			public hopvotetask(L2PcInstance player)
			{
				p = player;
			}

			@Override
			public void run()
			{
				if (firstvoteshop < getHopZoneVotes())
				{
					p.setIsVoting(false);
					p.setIsImobilised(false);
					VoteManager.setHasVotedHop(player);
					p.sendMessage("Thank you for voting for us!");
					VoteManager.updateLastVoteHopzone(p);
					VoteManager.updateVotes(p);
				}
				else
				{
					p.setIsVoting(false);
					p.setIsImobilised(false);
					p.sendMessage("You did not vote.Please try again.");
					VoteManager.setTries(player, VoteManager.getTries(p) - 1);
				}
			}

		}

		PreparedStatement statement = null;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			statement = con.prepareStatement("SELECT lastVoteHopzone FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());

			ResultSet rset = statement.executeQuery();

			while (rset.next())
			{
				lastVoteHopzone = rset.getLong("lastVoteHopzone");
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }

		if (getTries(player) <= 0)
		{
			player.sendMessage("Due to your multiple failures in voting you lost your chance to vote today");
		}
		else if (((lastVoteHopzone + voteDelay) < System.currentTimeMillis()) && (getTries(player) > 0))
		{
			for (L2PcInstance j : L2World.getInstance().getAllPlayers())
			{
				if (j.isVoting())
				{
					player.sendMessage("Someone is already voting.Wait for your turn please!");
					return;
				}
			}

			player.setIsVoting(true);
			player.setIsImobilised(true);
			player.sendMessage("Go fast on the site and vote on the hopzone banner!");
			player.sendMessage("You have " + Config.SECS_TO_VOTE + " seconds.Hurry!");
			ThreadPoolManager.getInstance().scheduleGeneral(new hopvotetask(player), Config.SECS_TO_VOTE * 1000);
		}
		else if ((getTries(player) <= 0) && ((lastVoteHopzone + voteDelay) < System.currentTimeMillis()))
		{
			for (L2PcInstance j : L2World.getInstance().getAllPlayers())
			{
				if (j.isVoting())
				{
					player.sendMessage("Someone is already voting.Wait for your turn please!");
					return;
				}
			}

			player.setIsVoting(true);
			player.setIsImobilised(true);
			player.sendMessage("Go fast on the site and vote on the hopzone banner!");
			player.sendMessage("You have " + Config.SECS_TO_VOTE + " seconds.Hurry!");
			ThreadPoolManager.getInstance().scheduleGeneral(new hopvotetask(player), Config.SECS_TO_VOTE * 1000);

		}
		else
		{
			player.sendMessage("12 hours have to pass till you are able to vote again.");
		}

	}

	public static void topvote(final L2PcInstance player)
	{
		long lastVoteTopzone = 0L;
		long voteDelay = 43200000L;
		final int firstvotestop;

		firstvotestop = getTopZoneVotes();

		class topvotetask implements Runnable
		{
			private final L2PcInstance p;

			public topvotetask(L2PcInstance player)
			{
				p = player;
			}

			@Override
			public void run()
			{
				if (firstvotestop < getTopZoneVotes())
				{
					p.setIsVoting(false);
					p.setIsImobilised(false);
					VoteManager.setHasVotedTop(p);
					p.sendMessage("Thank you for voting for us!");
					VoteManager.updateLastVoteTopzone(p);
					VoteManager.updateVotes(p);
				}
				else
				{
					p.setIsVoting(false);
					p.setIsImobilised(false);
					p.sendMessage("You did not vote.Please try again.");
					VoteManager.setTries(p, VoteManager.getTries(p) - 1);
				}
			}

		}

		PreparedStatement statement = null;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			statement = con.prepareStatement("SELECT lastVoteTopzone FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());

			ResultSet rset = statement.executeQuery();

			while (rset.next())
			{
				lastVoteTopzone = rset.getLong("lastVoteTopzone");
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }

		if (getTries(player) <= 0)
		{
			player.sendMessage("Due to your multiple failures in voting you lost your chance to vote today");
		}
		else if ((getTries(player) <= 0) && ((lastVoteTopzone + voteDelay) < System.currentTimeMillis()))
		{
			for (L2PcInstance j : L2World.getInstance().getAllPlayers())
			{
				if (j.isVoting())
				{
					player.sendMessage("Someone is already voting.Wait for your turn please!");
					return;
				}
			}
			player.setIsVoting(true);
			player.setIsImobilised(true);
			player.sendMessage("Go fast on the site and vote on the topzone banner!");
			player.sendMessage((new StringBuilder()).append("You have ").append(Config.SECS_TO_VOTE).append(" seconds.Hurry!").toString());
			ThreadPoolManager.getInstance().scheduleGeneral(new topvotetask(player), Config.SECS_TO_VOTE * 1000);
		}
		else if (((lastVoteTopzone + voteDelay) < System.currentTimeMillis()) && (getTries(player) > 0))
		{
			for (L2PcInstance j : L2World.getInstance().getAllPlayers())
			{
				if (j.isVoting())
				{
					player.sendMessage("Someone is already voting.Wait for your turn please!");
					return;
				}
			}
			player.setIsVoting(true);
			player.setIsImobilised(true);
			player.sendMessage("Go fast on the site and vote on the topzone banner!");
			player.sendMessage((new StringBuilder()).append("You have ").append(Config.SECS_TO_VOTE).append(" seconds.Hurry!").toString());
			ThreadPoolManager.getInstance().scheduleGeneral(new topvotetask(player), Config.SECS_TO_VOTE * 1000);
		}
		else
		{
			player.sendMessage("12 hours have to pass till you are able to vote again.");
		}

	}

	public static void hasVotedHop(L2PcInstance player)
	{
		int hasVotedHop = -1;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT hasVotedHop FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());

			ResultSet rset = statement.executeQuery();

			while (rset.next())
			{
				hasVotedHop = rset.getInt("hasVotedHop");
			}

			if (hasVotedHop == 1)
			{
				setHasVotedHop(true);
			}
			else if (hasVotedHop == 0)
			{
				setHasVotedHop(false);
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	public static void hasVotedTop(L2PcInstance player)
	{
		int hasVotedTop = -1;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT hasVotedTop FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());

			ResultSet rset = statement.executeQuery();

			while (rset.next())
			{
				hasVotedTop = rset.getInt("hasVotedTop");
			}

			if (hasVotedTop == 1)
			{
				setHasVotedTop(true);
			}
			else if (hasVotedTop == 0)
			{
				setHasVotedTop(false);
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	public static void updateVotes(L2PcInstance activeChar)
	{
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET monthVotes=?, totalVotes=? WHERE obj_Id=?");

			statement.setInt(1, getMonthVotes(activeChar) + 1);
			statement.setInt(2, getTotalVotes(activeChar) + 1);
			statement.setInt(3, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	public static void setHasVotedHop(L2PcInstance activeChar)
	{
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET hasVotedHop=? WHERE obj_Id=?");

			statement.setInt(1, 1);
			statement.setInt(2, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	public static void setHasVotedTop(L2PcInstance activeChar)
	{
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET hasVotedTop=? WHERE obj_Id=?");

			statement.setInt(1, 1);
			statement.setInt(2, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	public static void setHasNotVotedHop(L2PcInstance activeChar)
	{
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET hasVotedHop=? WHERE obj_Id=?");

			statement.setInt(1, 0);
			statement.setInt(2, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	public static void setHasNotVotedTop(L2PcInstance activeChar)
	{
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET hasVotedTop=? WHERE obj_Id=?");

			statement.setInt(1, 0);
			statement.setInt(2, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	public static int getTries(L2PcInstance player)
	{
		int tries = -1;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT tries FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());
			for (ResultSet rset = statement.executeQuery(); rset.next();)
			{
				tries = rset.getInt("tries");
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
		return tries;
	}

	public static void setTries(L2PcInstance player, int tries)
	{
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET tries=? WHERE obj_Id=?");

			statement.setInt(1, tries);
			statement.setInt(2, player.getObjectId());
			statement.execute();
			statement.close();
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	public static int getMonthVotes(L2PcInstance player)
	{
		int monthVotes = -1;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT monthVotes FROM characters WHERE obj_Id=?");

			statement.setInt(1, player.getObjectId());
			for (ResultSet rset = statement.executeQuery(); rset.next();)
			{
				monthVotes = rset.getInt("monthVotes");
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
		return monthVotes;
	}

	public static int getTotalVotes(L2PcInstance player)
	{
		int totalVotes = -1;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT totalVotes FROM characters WHERE obj_Id=?");

			statement.setInt(1, player.getObjectId());
			for (ResultSet rset = statement.executeQuery(); rset.next();)
			{
				totalVotes = rset.getInt("totalVotes");
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
		return totalVotes;
	}

	public static int getBigTotalVotes(L2PcInstance player)
	{
		int bigTotalVotes = -1;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT SUM(totalVotes) FROM characters");

			for (ResultSet rset = statement.executeQuery(); rset.next();)
			{
				bigTotalVotes = rset.getInt("SUM(totalVotes)");
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
		return bigTotalVotes;
	}

	public static int getBigMonthVotes(L2PcInstance player)
	{
		int bigMonthVotes = -1;
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT SUM(monthVotes) FROM characters");

			for (ResultSet rset = statement.executeQuery(); rset.next();)
			{
				bigMonthVotes = rset.getInt("SUM(monthVotes)");
			}
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
		return bigMonthVotes;
	}

	public static void updateLastVoteHopzone(L2PcInstance player)
	{
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET lastVoteHopzone=? WHERE obj_Id=?");
			statement.setLong(1, System.currentTimeMillis());
			statement.setInt(2, player.getObjectId());
			statement.execute();
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	public static void updateLastVoteTopzone(L2PcInstance player)
	{
		Connection con = null;
		try
		{
		con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET lastVoteTopzone=? WHERE obj_Id=?");
			statement.setLong(1, System.currentTimeMillis());
			statement.setInt(2, player.getObjectId());
			statement.execute();
		}
		 catch (Exception e)
		 {
		 _log.warning(" ");
		 }
		 finally
		 {
		 try
		 {
		 if (con != null)
		 con.close();
		 }
		 catch (SQLException e)
		 {
		 _log.warning("Failed to close database connection!");
		 }
		 }
	}

	// Getters and Setters
	public static boolean hasVotedHop()
	{
		return hasVotedHop;
	}

	public static void setHasVotedHop(boolean hasVotedHop)
	{
		VoteManager.hasVotedHop = hasVotedHop;
	}

	public static boolean hasVotedTop()
	{
		return hasVotedTop;
	}

	public static void setHasVotedTop(boolean hasVotedTop)
	{
		VoteManager.hasVotedTop = hasVotedTop;
	}
}

Extensions.vote.VoteConfig.java

/*
 * 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 Extensions.Vote;

public class VoteConfig
{
	public VoteConfig()
	{
	}
}

Extensions.Vote.Tasks.MonthlyResetTask.java

/*
 * 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 Extensions.Vote.Tasks;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.util.database.L2DatabaseFactory;

public class MonthlyResetTask
{
	protected static final Logger _log = Logger.getLogger(MonthlyResetTask.class.getName());

	public MonthlyResetTask()
	{
	}

	public static void getInstance()
	{
		ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
		{
			@Override
			public void run()
			{
				Connection con = null;
				try
				{
				con = L2DatabaseFactory.getInstance().getConnection();
					PreparedStatement statement = con.prepareStatement("UPDATE characters SET monthVotes=?");

					statement.setInt(1, 0);
					statement.execute();
					statement.close();
				}
				 catch (Exception e)
				 {
				 _log.warning(" ");
				 }
				 finally
				 {
				 try
				 {
				 if (con != null)
				 con.close();
				 }
				 catch (SQLException e)
				 {
				 _log.warning("Failed to close database connection!");
				 }
				 }
			}
		}, getValidationTime());
	}

	private static long getValidationTime()
	{
		Calendar cld = Calendar.getInstance();
		cld.set(5, 1);
		long time = cld.getTimeInMillis();
		if ((System.currentTimeMillis() - time) <= 0L)
		{
			long delay = cld.getTimeInMillis() - System.currentTimeMillis();
			return delay;
		}
		return 0L;
	}
}

Extensions.Vote.Tasks.TriesResetTask.java

/*
 * 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 Extensions.Vote.Tasks;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.util.database.L2DatabaseFactory;

public class TriesResetTask
{
	protected static final Logger _log = Logger.getLogger(TriesResetTask.class.getName());

	public TriesResetTask()
	{
	}

	public static void getInstance()
	{
		ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
		{
			@Override
			public void run()
			{
				Connection con = null;
				try
				{
				con = L2DatabaseFactory.getInstance().getConnection();
					PreparedStatement statement = con.prepareStatement("UPDATE characters SET tries=?");

					statement.setInt(1, 3);
					statement.execute();
					statement.close();
				}
				 catch (Exception e)
				 {
				 _log.warning(" ");
				 }
				 finally
				 {
				 try
				 {
				 if (con != null)
				 con.close();
				 }
				 catch (SQLException e)
				 {
				 _log.warning("Failed to close database connection!");
				 }
				 }
			}
		}, getValidationTime());
	}

	private static long getValidationTime()
	{
		Calendar cld = Calendar.getInstance();
		cld.set(11, 12);
		cld.set(12, 1);
		long time = cld.getTimeInMillis();
		if ((System.currentTimeMillis() - time) <= 0L)
		{
			long delay = cld.getTimeInMillis() - System.currentTimeMillis();
			return delay;
		}
		return 0L;
	}
}

com.l2jfrozen.gameserver.model.actor.instance.L2VoteManagerInstance.java

/*
 * 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.l2jfrozen.gameserver.model.actor.instance;

import java.io.File;

import javolution.text.TextBuilder;
import Extensions.Vote.DDSConverter;
import Extensions.Vote.VoteManager;

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.ai.CtrlIntention;
import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.network.serverpackets.PledgeCrest;
import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;

public class L2VoteManagerInstance extends L2NpcInstance
{
	public L2VoteManagerInstance(int objectId, L2NpcTemplate template)
	{
		super(objectId, template);
	}

	@Override
	public void onBypassFeedback(final L2PcInstance player, String command)
	{
		if (player == null)
			return;

		if (command.startsWith("votehopzone"))
			VoteManager.hopvote(player);

		if (command.startsWith("votetopzone"))
			VoteManager.topvote(player);

		if (command.startsWith("rewards"))
			showRewardsHtml(player);

		if (command.startsWith("reward1"))
		{
			player.getInventory().addItem("reward", Config.VOTE_REWARD_ID1, Config.VOTE_REWARD_AMOUNT1, player, null);
			player.sendMessage("Good choice!");
			player.getInventory().updateDatabase(); // update database
			VoteManager.setHasNotVotedHop(player);
			VoteManager.setHasNotVotedTop(player);
			VoteManager.setTries(player, VoteManager.getTries(player) + 1);
		}
		if (command.startsWith("reward2"))
		{
			player.getInventory().addItem("reward", Config.VOTE_REWARD_ID2, Config.VOTE_REWARD_AMOUNT2, player, null);
			player.sendMessage("Good choice!");
			player.getInventory().updateDatabase(); // update database
			VoteManager.setHasNotVotedHop(player);
			VoteManager.setHasNotVotedTop(player);
			VoteManager.setTries(player, VoteManager.getTries(player) + 1);
		}
		if (command.startsWith("reward3"))
		{
			player.getInventory().addItem("reward", Config.VOTE_REWARD_ID3, Config.VOTE_REWARD_AMOUNT3, player, null);
			player.sendMessage("Good choice!");
			player.getInventory().updateDatabase(); // update database
			VoteManager.setHasNotVotedHop(player);
			VoteManager.setHasNotVotedTop(player);
			VoteManager.setTries(player, VoteManager.getTries(player) + 1);
		}
		if (command.startsWith("reward4"))
		{
			player.getInventory().addItem("reward", Config.VOTE_REWARD_ID4, Config.VOTE_REWARD_AMOUNT4, player, null);
			player.sendMessage("Good choice!");
			player.getInventory().updateDatabase(); // update database
			VoteManager.setHasNotVotedHop(player);
			VoteManager.setHasNotVotedTop(player);
			VoteManager.setTries(player, VoteManager.getTries(player) + 1);
		}
	}

	@Override
	public void onAction(L2PcInstance player)
	{
		if (this != player.getTarget())
		{
			player.setTarget(this);

			player.sendPacket(new MyTargetSelected(getObjectId(), 0));

			player.sendPacket(new ValidateLocation(this));
		}
		else if (!canInteract(player))
		{
			player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
		}
		if (Config.ENABLE_PIN_SYSTEM && player.isSubmitingPin())
		{
			player.sendMessage("Please submit your security code in order to continue with actions.");
			return;
		}
		else
		{
			showHtmlWindow(player);
		}
	}

	public void showHtmlWindow(L2PcInstance activeChar)
	{
		generateLogo(activeChar, 75);
		generateLogo(activeChar, 76);
		generateLogo(activeChar, 85);
		generateLogo(activeChar, 86);
		VoteManager.hasVotedHop(activeChar);
		VoteManager.hasVotedTop(activeChar);

		NpcHtmlMessage nhm = new NpcHtmlMessage(5);
		TextBuilder tb = new TextBuilder("");

		tb.append("<html><head><title>Lineage II  - Vote Manager</title></head><body>");
		tb.append("<center><img src=\"l2ui_ch3.herotower_deco\" width=256 height=32>");
		tb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
		tb.append("<table bgcolor=000000 width=300 height=40>");
		tb.append("<tr>");
		tb.append("<td width=\"300\" align=\"center\"><font color=\"666666\">Welcome " + activeChar.getName() +" in Lineage II</font><font color=\"FF9900\"> --</font><font color=\"666666\"> Server</font></td>");
		tb.append("</tr>");
		tb.append("</table>");
		tb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
		tb.append("<br>");
		tb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
		tb.append("</center>");
		tb.append("<center>");
		tb.append("<table bgcolor=000000 width=300 height=12>");
		tb.append("<tr>");
		tb.append("<td width=\"300\" align=\"center\"><font color=\"666666\">Who's voting now:</font><font color=\"FF5555\"> " + VoteManager.whosVoting() +"</font></td>");
		tb.append("</tr>");
		tb.append("<tr>");
		tb.append("<td width=\"300\" align=\"center\"><font color=\"666666\">Tries left:</font><font color=\"FF5555\"> " + VoteManager.getTries(activeChar) + "</font></td>");
		tb.append("</tr>");
		tb.append("<tr>");
		tb.append("<td width=\"300\" align=\"center\"><font color=\"666666\">Your votes:</font><font color=\"FF5555\"> " + VoteManager.getTotalVotes(activeChar) +"</font></td>");
		tb.append("</tr>");
		tb.append("</table>");
		tb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
		tb.append("</center>");
		if (!VoteManager.hasVotedHop() || !VoteManager.hasVotedTop())
		{
			tb.append("<center>");
			tb.append("<table width=\"250\" cellpadding=\"5\">");
			tb.append("<tr>");
			tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><button action=\"bypass -h npc_" + getObjectId() + "_votehopzone\" width=256 height=64 back=\"Crest.crest_" + Config.SERVER_ID + "_" + 75 + "\" fore=\"Crest.crest_" + Config.SERVER_ID + "_" + 76 + "\"></td>");
			tb.append("</tr>");
			tb.append("</table>");
			tb.append("<table width=\"250\" cellpadding=\"5\">");
			tb.append("<tr>");
			tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><button action=\"bypass -h npc_" + getObjectId() + "_votetopzone\" width=256 height=64 back=\"Crest.crest_" + Config.SERVER_ID + "_" + 85 + "\" fore=\"Crest.crest_" + Config.SERVER_ID + "_" + 86 + "\"></td>");
			tb.append("</tr>");
			tb.append("</table>");
			tb.append("</center>");
		}
		if (VoteManager.hasVotedHop() && VoteManager.hasVotedTop())
		{
			tb.append("<br>");
			tb.append("<center>");
			tb.append("<img src=\"L2UI.SquareGray\" width=200 height=1>");
			tb.append("<table border=0 bgcolor=000000 width=200 height=10>");
			tb.append("<tr><td width=\"200\" align=\"center\"><font color=\"FF0000\"><a action=\"bypass -h npc_" + getObjectId() + "_reward1\">"+ Config.VOTE_REWARD_AMOUNT1 +" "+ ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID1).getName() +"</font></a></td></tr>");
			tb.append("<tr><td width=\"200\" align=\"center\"><font color=\"FF0000\"><a action=\"bypass -h npc_" + getObjectId() + "_reward2\">"+ Config.VOTE_REWARD_AMOUNT2 +" "+ ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID2).getName() +"</font></a></td></tr>");
			tb.append("<tr><td width=\"200\" align=\"center\"><font color=\"FF0000\"><a action=\"bypass -h npc_" + getObjectId() + "_reward3\">"+ Config.VOTE_REWARD_AMOUNT3 +" "+ ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID3).getName() +"</font></a></td></tr>");

			if (VoteManager.getTotalVotes(activeChar) >= Config.EXTRA_REW_VOTE_AM)
			{
				activeChar.sendMessage("Due to your votes you now have a 4th choise!");
				tb.append("<tr><td width=\"200\" align=\"center\"><font color=\"FF0000\"><a action=\"bypass -h npc_" + getObjectId() + "_reward4\">"+ Config.VOTE_REWARD_AMOUNT4 +" "+ ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID4).getName() +"</font></a></td></tr>");

			}
			tb.append("</table>");
			tb.append("<img src=\"L2UI.SquareGray\" width=200 height=1>");
			tb.append("</center>");
			tb.append("<br>");
		}
		tb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
		tb.append("<table border=0 bgcolor=000000 width=300 height=10>");
		if (!VoteManager.hasVotedHop())
		{
			tb.append("<tr>");
			tb.append("<td width=\"300\" align=\"center\"><font color=\"FF9900\">Hopzone:</font><font color=\"FF0000\"> Not Voted</font></td>");
		}
		if (VoteManager.hasVotedHop())
		{
			tb.append("<tr>");
			tb.append("<td width=\"300\" align=\"center\"><font color=\"FF9900\">Hopzone:</font><font color=\"5EA82E\"> Voted</font></td>");
		}
		if (!VoteManager.hasVotedTop())
		{
			tb.append("<td width=\"1\" align=\"center\"><font color=\"505050\">|</font></td>");
			tb.append("<td width=\"300\" align=\"center\"><font color=\"FF9900\">Topzone:</font><font color=\"FF0000\"> Not Voted</font></td>");
			tb.append("</tr>");
		}
		if (VoteManager.hasVotedTop())
		{
			tb.append("<td width=\"1\" align=\"center\"><font color=\"505050\">|</font></td>");
			tb.append("<td width=\"300\" align=\"center\"><font color=\"FF9900\">Topzone:</font><font color=\"5EA82E\"> Voted</font></td>");
			tb.append("</tr>");
		}
		tb.append("</table>");
		tb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
		tb.append("</center>");
		tb.append("<br>");
		tb.append("<center>");
		tb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
		tb.append("<table border=0 bgcolor=000000 width=300 height=20>");
		tb.append("<tr>");
		tb.append("<td align=\"center\" width=\"300\"><font color=\"666666\">Vote for us :</font><font color=\"FF5555\"></font></td>");
		tb.append("</tr>");
		tb.append("</table>");
		tb.append("<img src=\"L2UI.SquareGray\" width=300 height=1>");
		tb.append("</center>");
		tb.append("</body></html>");

		nhm.setHtml(tb.toString());
		activeChar.sendPacket(nhm);
		activeChar.sendPacket(ActionFailed.STATIC_PACKET);
	}

	public static void generateLogo(L2PcInstance activeChar, int imgId)
	{
		try
		{
			if (imgId == 75)
			{
				File captcha = new File("data/images/hopzone2.png");
				PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array());
				activeChar.sendPacket(packet);
			}
			if (imgId == 76)
			{
				File captcha = new File("data/images/hopzone.png");
				PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array());
				activeChar.sendPacket(packet);
			}
			if (imgId == 85)
			{
				File captcha = new File("data/images/topzone2.png");
				PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array());
				activeChar.sendPacket(packet);
			}
			if (imgId == 86)
			{
				File captcha = new File("data/images/topzone.png");
				PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array());
				activeChar.sendPacket(packet);
			}
		}
		catch (Exception e)
		{
			activeChar.sendMessage("Could not genarate vote manager logo.");
		}
	}

	public void showRewardsHtml(L2PcInstance player)
	{
		TextBuilder tb = new TextBuilder();
		NpcHtmlMessage html = new NpcHtmlMessage(1);

		tb.append("<html><head><title>Vote Reward Manager</title></head><body>");
		tb.append("<center>");
		tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
		tb.append("<tr>");
		tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
		tb.append("<td valign=\"top\"><font color=\"FF6600\">Vote Manager</font>");
		tb.append("<br1><font color=\"00FF00\">" + player.getName() + "</font>, get your reward here.</td>");
		tb.append("</tr>");
		tb.append("</table>");
		tb.append("</center>");
		tb.append("<center>");
		tb.append("<td valign=\"top\"><font color=\"FF6600\">Choose your reward " + player.getName() + ".</font>");
		tb.append("<button value=\"Item:" + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID1).getName() + "   Amount:" + Config.VOTE_REWARD_AMOUNT1 + "\" action=\"bypass -h npc_" + getObjectId() + "_reward1\" width=204 height=20>");
		tb.append("<button value=\"Item:" + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID2).getName() + "   Amount:" + Config.VOTE_REWARD_AMOUNT2 + "\" action=\"bypass -h npc_" + getObjectId() + "_reward2\" width=204 height=20>");
		tb.append("<button value=\"Item:" + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID3).getName() + "   Amount:" + Config.VOTE_REWARD_AMOUNT3 + "\" action=\"bypass -h npc_" + getObjectId() + "_reward3\" width=204 height=20>");
		if (VoteManager.getTotalVotes(player) >= Config.EXTRA_REW_VOTE_AM)
		{
			tb.append("<font color=\"FF6600\">Due to your votes you now have a 4th choice!</font><br><button value=\"Item:" + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID4).getName() + "   Amount:" + Config.VOTE_REWARD_AMOUNT4 + "\" action=\"bypass -h npc_" + getObjectId() + "_reward4\" width=204 height=20>");
		}
		tb.append("</center>");

		tb.append("</body></html>");

		html.setHtml(tb.toString());
		player.sendPacket(html);
		player.sendPacket(ActionFailed.STATIC_PACKET);
	}
}

3 answers to this question

Recommended Posts

  • 0
Posted (edited)

Κοίταξε τα tag στον κωδικα του HTML Vote Page .

(Φιλικα αν εγραφες ελληνικους χαρακτηρες θα μας βοηθουσες να διαβαζουμε καλυτερα ...

Edited by BlackDevilDev
  • 0
Posted

Κοίταξε τα tag στον κωδικα του HTML Vote Page .

(Φιλικα αν εγραφες ελληνικους χαρακτηρες θα μας βοηθουσες να διαβαζουμε καλυτερα ...

8a Egrafa Sta Elinika Apla einai kai ta or8ografika la8i Gia auto  Kita Tin Vote Page ..

 

PowerPack.properties

# Automatic Vote Reward System
VoteRewardSystem= True
VotesRequiredForReward = 1
VotesSystemInitialDelay= 60000
VotesSystemStepDelay= 1800000
VotesRewards= 4355,5;
#Leave empty to disable one site
#if you need just one of these
VotesSiteHopZoneUrl=http://l2.hopzone.net/lineage2/details/97057/Spirit
VotesSiteTopZoneUrl=http://l2topzone.com/lineage2/server-info/7737/wwwl2speuCustom.html
ServerWebSite= http://www.l2sp.eu/

l2jfrozen.properties

# ------------------------------
# Vote System Ingame  -
# ------------------------------
HopzoneUrl = http://l2.hopzone.net/lineage2/details/97057/Spirit
TopzoneUrl = http://l2topzone.com/lineage2/server-info/7737/wwwl2speuCustom.html
# The characters will have a choice between 3 rewards.Set id for them
VoteRewardId1 = 4355
VoteRewardId2 = 4355
VoteRewardId3 = 4355# Set the amount of each reward.
VoteRewardAmount1 = 2
VoteRewardAmount2 = 5
VoteRewardAmount3 = 8# Set the seconds that the character has
# until he votes in the site's banners
SecondsToVote = 60# Amount of votes a character must collect
# in order to get the 4th vote reward
ExtraRewVoteAm = 20# Info of the extra reward item
VoteRewardId4 = 4355
VoteRewardAmount4 = 10

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • ## [1.5.5] - 2026-02-02   ### ✨ New Features - **Discord Login**: You can now sign in with your Discord account. Admins enable and configure Discord login in **cpadmin → Users** (Discord auth settings: Client ID, Client Secret, Redirect URI). If you already have an account with the same email (e.g. forum, Google, or legacy), signing in with Discord links to that account so you keep one profile. Discord login is available on Add Server, My Servers, Vote page, and Premium Ads booking. - **Setup Links**: In **cpadmin → Users**, both Google and Discord login settings now include direct links to their official developer portals (Google Cloud Console and Discord Developer Portal) for easier OAuth app setup.   ### 🔒 Security - **Email Required for Registration**: New user registration via OAuth (Forum, Google, Discord) now requires a valid email address. If the OAuth provider doesn't provide an email (e.g. unverified Discord email), registration is rejected with a clear message. This prevents anonymous accounts and ensures all users can receive important notifications.   ### 🔄 Improvements - **User Auth Badges**: In **cpadmin → Users**, the Registered Members table now shows auth method badges: **Forum**, **Google**, **Discord**, or **Legacy**. Users can have multiple badges if they've linked multiple login methods. - **Server Info Labels**: Translated server info labels (Owner Name, Language, Server Location) are now properly localized in all 5 languages (English, Spanish, Portuguese, Greek, Russian).   ---   ## [1.5.4] - 2026-02-01   ### ✨ New Features - **Google Login**: You can now sign in with your Google account. Admins enable and configure Google login in **cpadmin → Users** (Google auth settings: Client ID, Client Secret, Redirect URI). If you already have an account with the same email (e.g. forum or legacy), signing in with Google links to that account so you keep one profile. The login menu (navbar and login prompts) offers **Login with Forum Account**, **Login with Google** (when enabled), and **Create Forum Account**. Google login is available on Add Server, My Servers, Profile Settings, Vote page, and Premium Ads booking. - **Ban/Unban Members**: In **cpadmin → Users**, admins can ban or unban registered members. Banned users see a full-page message: "Sorry, you are banned from using this site." When a user is banned, all their servers are set to inactive. - **Moderator Activity Log**: **cpadmin → Moderators** now records when a moderator or admin enters the CPAdmin panel (e.g. "Moderator X entered CPAdmin panel at &lt;time&gt;") and when they change any cpadmin settings (only write actions are logged; read-only use is not). - **Clear Moderator Logs**: Admins can clear all moderator activity log entries via a **Clear logs** button with confirmation. Logs are shown at 100 per page with pagination. - **Filter by Moderator**: In the Moderator Activity Log, a **Filter by moderator** dropdown lets you view activity for a specific moderator or "All moderators." - **cpadmin → Users Tab**: New **Users** tab in the admin panel with Registered Members list (paginated), Google auth settings card, and per-user Ban/Unban and server links.   ### 🔄 Improvements - **cpadmin → Servers**: Each server name in the servers table is now clickable and opens that server’s info page. - **cpadmin → Users – Servers column**: The servers count/list is clickable and opens a small modal listing that user’s servers; each server name in the modal links to the server info page. - **cpadmin → Users – Search**: A search bar above the Registered Members table lets you search by **username**, **email**, or **server name**. Results are filtered on the server (paginated); clearing the search resets the list. - **Moderator Activity Log**: Pagination shows "Showing X–Y of Z" and "Page N of M" with Previous/Next when there are more than 100 entries. - **Login UI**: Login options (Forum, Google, Create account) are shown in a consistent dropdown and in modals (Add Server, My Servers, Vote, Premium Ads) for a clearer sign-in experience. - **Vote Page – Unauthenticated**: When you must log in to vote, the page now shows "Vote for [Server Name]" as the main heading and presents login options in a compact section.   ---   ## [1.5.3] - 2026-01-30   ### ✨ New Features - **File Logs in Admin Panel**: Admins can now view CodeIgniter PHP logs (api/writable/logs) directly in **cpadmin → Logs**. Select a date to view the log file, refresh to reload, or delete all log files to free up space.   ### 🔄 Improvements - **Cache System**: Full cache audit and improvements — when you clear cache in cpadmin, both backend and frontend caches are cleared. Server listings, My Servers, pricing, ad config, and chronicles all refresh with fresh data. New paid servers now appear in listings and My Servers immediately. - **Admin Panel – Server Rates**: Server rates in the admin servers table now display in compact format (e.g. x10000 → x10k, x100000 → x100k, x1000000 → x1m) for easier scanning. Hover to see the full value.
    • WTB High Five source running on Salvation/Fafurion client
    • MoMoProxy has updated more static residential proxies for USA location, anyone interested in can view: https://momoproxy.com/static-residential-proxies
    • Hello, i am selling a project that was going to open but at the end i have not the time to do it Its a c4 server ( scripts) with all the c5 changes played from Interlude Client    the server is 1:1 copy of the legendary 2007 L2Revenge server with some bits like events and some more sync stuff There is a lot of retail fixes included  , extender is vanganth and has a lot of mods but mostly fixes on the retail stuff.   Test server is available through discord , i offer client/patch/server/sources The price is 300 Euro and for testing the server you have to pm me at discord banshee1019 , dont really wanna let anybody log because some people are "bad"   Once you buy you also have free support for 1 year , that doesnt mean i will code all your ideas but support you if something comes up , and guide you to do simple edits
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..