
mariusumf
Members-
Posts
7 -
Credits
0 -
Joined
-
Last visited
-
Feedback
0%
mariusumf's Achievements
Newbie (1/16)
0
Reputation
-
Resolved! Topic Locked!
-
[Share]L2J Server Freya Project + Source
mariusumf replied to 'Baggos''s topic in Server Development Discussion [Greek]
Tnx KnipeX -
I need need help from one Dev to implement auto vote system and one event engine in a Freya Pack! Pls pm me!
-
[HELP] Autovote system error in Eclipse...
mariusumf posted a question in Request Server Development Help [L2J]
I have this auto vote system: Index: dist/game/config/l2jmods.properties =================================================================== --- dist/game/config/l2jmods.properties (revision 5038) +++ dist/game/config/l2jmods.properties (working copy) @@ -456,7 +459,67 @@ # Default: 127.0.0.1,0 (no limits from localhost) DualboxCheckWhitelist = 127.0.0.1,0 + # --------------------------------------------------------------------------- +# Vote System +# --------------------------------------------------------------------------- + +# Enable vote system? +EnableVoteSystem = true + +#Hopzone = true / Topzone = false +VoteSystemHopzone = true + +# Save Votes in Database? +# Recomendable true if you Shutdown/Restart the server. +SaveVotesIntoDataBase = true + +# Vote Page URL. +# Working/Tested in HopZone. +VoteSystemPage = http://l2.hopzone.net/lineage2/details/74078/L2World-Servers + +# Reward players every xxx votes. +VoteSystemVotes = 10 + +# Frist Check delay. +# In Seconds. +VoteSystemStartCheckTime = 60 + +# Continue Check delay. +# In Seconds. +VoteSystemRunCheckTime = 120 + +# Items Rewards ID. +# Separated whit a ",". +VoteSystemItemID = 57,20034 + +# Items Rewards Count. +# Separated whit a ",". +VoteSystemItemCount = 1000,2 \ No newline at end of file Index: java/com/l2jserver/gameserver/GameServer.java =================================================================== --- java/com/l2jserver/gameserver/GameServer.java (revision 5038) +++ java/com/l2jserver/gameserver/GameServer.java (working copy) @@ -79,6 +79,7 @@ import com.l2jserver.gameserver.instancemanager.AirShipManager; import com.l2jserver.gameserver.instancemanager.AntiFeedManager; import com.l2jserver.gameserver.instancemanager.AuctionManager; +import com.l2jserver.gameserver.instancemanager.AutoVoteRewardManager; import com.l2jserver.gameserver.instancemanager.BoatManager; import com.l2jserver.gameserver.instancemanager.CHSiegeManager; import com.l2jserver.gameserver.instancemanager.CastleManager; @@ -311,6 +314,11 @@ BoatManager.getInstance(); AirShipManager.getInstance(); GraciaSeedsManager.getInstance(); + if(Config.VOTE_SYSTEM_ENABLE == true){ + AutoVoteRewardManager.getInstance(); + } try { Index: java/com/l2jserver/gameserver/instancemanager/AutoVoteRewardManager.java =================================================================== --- java/com/l2jserver/gameserver/instancemanager/AutoVoteRewardManager.java (revision 0) +++ java/com/l2jserver/gameserver/instancemanager/AutoVoteRewardManager.java (revision 0) @@ -0,0 +1,222 @@ +package com.l2jserver.gameserver.instancemanager; + +import java.io.BufferedReader; +import java.io.IOException; +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.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import com.l2jserver.Config; +import com.l2jserver.L2DatabaseFactory; +import com.l2jserver.gameserver.Announcements; +import com.l2jserver.gameserver.ThreadPoolManager; +import com.l2jserver.gameserver.model.L2World; +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; + +public class AutoVoteRewardManager +{ + private static Logger _log = Logger.getLogger(AutoVoteRewardManager.class.getName()); + + private static final int initialCheck = Config.VOTE_SYSTEM_START_TIME * 1000; + private static final int delayForCheck = Config.VOTE_SYSTEM_CHECK_TIME * 1000; + private int votesneed; + + private static List<String> _ips = new ArrayList<String>(); + private static int lastVoteCount = 0; + + private AutoVoteRewardManager() + { + _log.info("AutoVoteRewardManager: Vote reward system initiated."); + if (Config.VOTE_SYSTEM_DATABASE_SAVE) + load(); + ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck); + } + + private class AutoReward implements Runnable + { + @Override + public void run() + { + int votes = getVotes(); + _log.info("AutoVoteRewardManager: Current Votes: " + getVotes()); + _log.info("AutoVoteRewardManager: Votes needed: "+(getLastVoteCount()+Config.VOTE_SYSTEM_COUNT)); + _log.info("AutoVoteRewardManager: Next Check in: "+(delayForCheck/1000)+" sec."); + Announcements.getInstance().announceToAll("Vote for us in HopZone!"); + + if (votes >= getLastVoteCount() + Config.VOTE_SYSTEM_COUNT) + { + Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().valueCollection(); + { + for (L2PcInstance onlinePlayer : pls) + { + if (onlinePlayer.isOnline() && !onlinePlayer.getClient().isDetached() && !_ips.contains(onlinePlayer.getClient().getConnection().getInetAddress().getHostAddress())) + { + String[] parase = Config.VOTE_SYSTEM_ITEM_ID.split(","); + String[] parase3 = Config.VOTE_SYSTEM_ITEM_COUNT.split(","); + for(int o = 0; o <parase.length; o++){ + int parase2 = Integer.parseInt(parase[o]); + int parase4 = Integer.parseInt(parase3[o]); + for (int i = 0; i < parase.length; i++) + { + onlinePlayer.addItem("vote_reward", parase2, parase4, onlinePlayer, true); + } + } + _ips.add(onlinePlayer.getClient().getConnection().getInetAddress().getHostAddress()); + } + } + } + _log.info("AutoVoteRewardManager: All players has been rewared!"); + Announcements.getInstance().announceToAll("Thanks for vote, you has been rewarded!"); + setLastVoteCount(getLastVoteCount() + Config.VOTE_SYSTEM_COUNT); + } + + if (getLastVoteCount() == 0) + { + setLastVoteCount(votes); + } + else if ((getLastVoteCount() + Config.VOTE_SYSTEM_COUNT) - votes > Config.VOTE_SYSTEM_COUNT || votes > (getLastVoteCount() + Config.VOTE_SYSTEM_COUNT)) + { + setLastVoteCount(votes); + } + votesneed = (getLastVoteCount()+Config.VOTE_SYSTEM_COUNT) - votes; + if(votesneed == 0){ + votesneed = Config.VOTE_SYSTEM_COUNT; + } + Announcements.getInstance().announceToAll("Need " + votesneed + " votes more to reward all players."); + _ips.clear(); + } + } + + private int getVotes() + { + URL url = null; + InputStreamReader isr = null; + BufferedReader in = null; + try + { + url = new URL(Config.VOTE_SYSTEM_PAGE); + URLConnection con = url.openConnection(); + con.addRequestProperty("User-Agent", "Mozilla/4.76"); + isr = new InputStreamReader(con.getInputStream()); + in = new BufferedReader(isr); + String inputLine; + while ((inputLine = in.readLine()) != null) + { + if(Config.VOTE_SYSTEM_HOPZONE == false){ + //TopZone + if(inputLine.contains("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\">")){ + String i = inputLine.replace("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\">", ""); + i = i.replace("</font></b></div></td></tr>", ""); + i = i.trim(); + int o = Integer.parseInt(i); + return Integer.valueOf(o); + } + } else { + //for hopzone + if (inputLine.contains("Anonymous User Votes")) + return Integer.valueOf(inputLine.split(">")[2].replace("</span", "")); + + } + } + } + catch (IOException e) + { + _log.warning("AutoVoteRewardHandler: "+e); + } + finally + { + try + { + in.close(); + } + catch (IOException e) + {} + try + { + isr.close(); + } + catch (IOException e) + {} + } + return 0; + } + + private void setLastVoteCount(int voteCount) + { + lastVoteCount = voteCount; + } + + private int getLastVoteCount() + { + return lastVoteCount; + } + + private void load() + { + int votes = 0; + Connection con = null; + try + { + con = L2DatabaseFactory.getInstance().getConnection(); + PreparedStatement statement = con.prepareStatement("SELECT vote FROM votes LIMIT 1"); + ResultSet rset = statement.executeQuery(); + + while (rset.next()) + { + votes = rset.getInt("vote"); + } + rset.close(); + statement.close(); + } + catch (Exception e) + { + _log.log(Level.WARNING, "data error on vote: ", e); + } + finally + { + L2DatabaseFactory.close(con); + } + + setLastVoteCount(votes); + } + + public void save() + { + Connection con = null; + try + { + con = L2DatabaseFactory.getInstance().getConnection(); + PreparedStatement statement = con.prepareStatement("UPDATE votes SET vote = ? WHERE id=1"); + statement.setInt(1, getLastVoteCount()); + statement.execute(); + statement.close(); + } + catch (Exception e) + { + _log.log(Level.WARNING, "data error on vote: ", e); + } + finally + { + L2DatabaseFactory.close(con); + } + } + + public static AutoVoteRewardManager getInstance() + { + return SingletonHolder._instance; + } + + @SuppressWarnings("synthetic-access") + private static class SingletonHolder + { + protected static final AutoVoteRewardManager _instance = new AutoVoteRewardManager(); + } +} \ No newline at end of file Index: java/com/l2jserver/Config.java =================================================================== --- java/com/l2jserver/Config.java (revision 5038) +++ java/com/l2jserver/Config.java (working copy) @@ -763,6 +764,26 @@ public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP; public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP; public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST; + public static boolean VOTE_SYSTEM_ENABLE; + public static boolean VOTE_SYSTEM_HOPZONE; + public static boolean VOTE_SYSTEM_DATABASE_SAVE; + public static String VOTE_SYSTEM_PAGE; + public static int VOTE_SYSTEM_COUNT; + public static int VOTE_SYSTEM_START_TIME; + public static int VOTE_SYSTEM_CHECK_TIME; + public static String VOTE_SYSTEM_ITEM_ID; + public static String VOTE_SYSTEM_ITEM_COUNT; //-------------------------------------------------- @@ -2628,7 +2649,17 @@ L2WALKER_PROTECTION = Boolean.parseBoolean(L2JModSettings.getProperty("L2WalkerProtection", "False")); L2JMOD_DEBUG_VOICE_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("DebugVoiceCommand", "False")); - + + VOTE_SYSTEM_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("EnableVoteSystem", "False")); + VOTE_SYSTEM_HOPZONE = Boolean.parseBoolean(L2JModSettings.getProperty("VoteSystemHopzone", "true")); + VOTE_SYSTEM_DATABASE_SAVE = Boolean.parseBoolean(L2JModSettings.getProperty("SaveVotesIntoDataBase", "true")); + VOTE_SYSTEM_PAGE = L2JModSettings.getProperty("VoteSystemPage", ""); + VOTE_SYSTEM_COUNT = Integer.parseInt(L2JModSettings.getProperty("VoteSystemVotes", "10")); + VOTE_SYSTEM_START_TIME = Integer.parseInt(L2JModSettings.getProperty("VoteSystemStartCheckTime", "60")); + VOTE_SYSTEM_CHECK_TIME = Integer.parseInt(L2JModSettings.getProperty("VoteSystemRunCheckTime", "120")); + VOTE_SYSTEM_ITEM_ID = L2JModSettings.getProperty("VoteSystemItemID", "57, 1000"); + VOTE_SYSTEM_ITEM_COUNT = L2JModSettings.getProperty("VoteSystemItemCount", "1000, 1"); + L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("DualboxCheckMaxPlayersPerIP", "0")); L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("DualboxCheckMaxOlympiadParticipantsPerIP", "0")); L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("DualboxCheckMaxL2EventParticipantsPerIP", "0")); Index: java/com/l2jserver/gameserver/Shutdown.java =================================================================== --- java/com/l2jserver/gameserver/Shutdown.java (revision 5038) +++ java/com/l2jserver/gameserver/Shutdown.java (working copy) @@ -44,6 +44,7 @@ import com.l2jserver.gameserver.network.serverpackets.ServerClose; import com.l2jserver.gameserver.network.serverpackets.SystemMessage; import com.l2jserver.gameserver.util.Broadcast; +import com.l2jserver.gameserver.instancemanager.AutoVoteRewardManager; /** @@ -543,6 +544,12 @@ SevenSigns.getInstance().saveSevenSignsStatus(); _log.info("SevenSigns: Seven Signs status saved("+tc.getEstimatedTimeAndRestartCounter()+"ms)."); + //Save Votes if save votes enable + if(Config.VOTE_SYSTEM_DATABASE_SAVE){ + AutoVoteRewardManager.getInstance().save(); + _log.info("Vote System: Votes has been saved!!"); + } + // Save all raidboss and GrandBoss status ^_^ RaidBossSpawnManager.getInstance().cleanUp(); _log.info("RaidBossSpawnManager: All raidboss info saved("+tc.getEstimatedTimeAndRestartCounter()+"ms)."); But it gives me some errors in Eclipse: http://imageshack.us/photo/my-images/14/autovoterewardmanager.jpg/ http://imageshack.us/photo/my-images/197/gameserver.JPG/ Anyone can help??? -
[Share]L2J Server Freya Project + Source
mariusumf replied to 'Baggos''s topic in Server Development Discussion [L2J]
Source link is dead. Auto vote system doesn't work, it need's some changes in java..... -
[Share]L2J Server Freya Project + Source
mariusumf replied to 'Baggos''s topic in Server Development Discussion [Greek]
Why auto vote reward doesn't work! That vote link cannot be changed! It's good that there is a source link that doesn't work! // Source File Name: AutoVoteRewardManager.java package com.l2jserver.gameserver.instancemanager; import com.l2jserver.Config; import com.l2jserver.L2DatabaseFactory; import com.l2jserver.gameserver.Announcements; import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.model.L2World; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.network.L2GameClient; import java.io.*; import java.net.InetAddress; import java.net.URL; import java.sql.*; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; import org.mmocore.network.MMOConnection; public class AutoVoteRewardManager { private static class SingletonHolder { protected static final AutoVoteRewardManager _instance = new AutoVoteRewardManager(); private SingletonHolder() { } } private class AutoReward implements Runnable { public void run() { int votes = getVotes(); AutoVoteRewardManager._log.info((new StringBuilder()).append("AutoVoteRewardManager: We now have ").append(votes).append("/").append(getLastVoteCount() + 5).append(" vote(s). Next check in ").append(160).append(" sec.").toString()); Announcements.getInstance().announceToAll("Vote on http://L2TopZone.com"); if(votes >= getLastVoteCount() + 5) { Collection pls = L2World.getInstance().getAllPlayers().values(); Iterator i$ = pls.iterator(); do { if(!i$.hasNext()) break; L2PcInstance onlinePlayer = (L2PcInstance)i$.next(); if(onlinePlayer.isOnline() && !onlinePlayer.getClient().isDetached() && !AutoVoteRewardManager._ips.contains(onlinePlayer.getClient().getConnection().getInetAddress().getHostAddress())) { for(int i = 0; i < AutoVoteRewardManager.itemId.length; i++) onlinePlayer.addItem("vote_reward", AutoVoteRewardManager.itemId, AutoVoteRewardManager.itemCount, onlinePlayer, true); AutoVoteRewardManager._ips.add(onlinePlayer.getClient().getConnection().getInetAddress().getHostAddress()); } } while(true); AutoVoteRewardManager._log.info("AutoVoteRewardManager: Reward for votes now!"); Announcements.getInstance().announceToAll("Reward for players! Thanks for Vote."); setLastVoteCount(getLastVoteCount() + 5); } if(getLastVoteCount() == 0) setLastVoteCount(votes); else if((getLastVoteCount() + 5) - votes > 5 || votes > getLastVoteCount() + 5) setLastVoteCount(votes); Announcements.getInstance().announceToAll((new StringBuilder()).append("We have ").append(votes).append(" vote(s). Next reward on ").append(getLastVoteCount() + 5).append(" vote.").toString()); AutoVoteRewardManager._ips.clear(); } final AutoVoteRewardManager this$0; private AutoReward() { this$0 = AutoVoteRewardManager.this; super(); } } private AutoVoteRewardManager() { _log.info("AutoVoteRewardManager: Vote reward system initiated."); if(Config.L2JMOD_VOTE_ENGINE_SAVE) load(); ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), 1000L, 0x27100L); } private int getVotes() { InputStreamReader isr; BufferedReader in; URL url = null; isr = null; in = null; int i; URL url = new URL("http://l2topzone.com/lineage2/server-info/5239/L2Sigmo.html"); isr = new InputStreamReader(url.openStream()); in = new BufferedReader(isr); String inputLine; do if((inputLine = in.readLine()) == null) break MISSING_BLOCK_LABEL_102; while(!inputLine.contains("moreinfo_total_rank_text")); i = Integer.valueOf(inputLine.split(">")[2].replace("</div", "")).intValue(); try { in.close(); } catch(IOException e) { } try { isr.close(); } catch(IOException e) { } return i; IOException e; try { in.close(); } // Misplaced declaration of an exception variable catch(IOException e) { } try { isr.close(); } // Misplaced declaration of an exception variable catch(IOException e) { } break MISSING_BLOCK_LABEL_195; e; _log.warning((new StringBuilder()).append("AutoVoteRewardHandler: ").append(e).toString()); try { in.close(); } // Misplaced declaration of an exception variable catch(IOException e) { } try { isr.close(); } // Misplaced declaration of an exception variable catch(IOException e) { } break MISSING_BLOCK_LABEL_195; Exception exception; exception; try { in.close(); } catch(IOException e) { } try { isr.close(); } catch(IOException e) { } throw exception; return 0; } private void setLastVoteCount(int voteCount) { lastVoteCount = voteCount; } private int getLastVoteCount() { return lastVoteCount; } private void load() { int votes; Connection con; votes = 0; con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT vote FROM votes LIMIT 1"); ResultSet rset; for(rset = statement.executeQuery(); rset.next();) votes = rset.getInt("vote"); rset.close(); statement.close(); L2DatabaseFactory.close(con); break MISSING_BLOCK_LABEL_100; Exception e; e; _log.log(Level.WARNING, "data error on vote: ", e); L2DatabaseFactory.close(con); break MISSING_BLOCK_LABEL_100; Exception exception; exception; L2DatabaseFactory.close(con); throw exception; setLastVoteCount(votes); return; } public void save() { Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("UPDATE votes SET vote = ? WHERE id=1"); statement.setInt(1, getLastVoteCount()); statement.execute(); statement.close(); L2DatabaseFactory.close(con); break MISSING_BLOCK_LABEL_76; Exception e; e; _log.log(Level.WARNING, "data error on vote: ", e); L2DatabaseFactory.close(con); break MISSING_BLOCK_LABEL_76; Exception exception; exception; L2DatabaseFactory.close(con); throw exception; } public static AutoVoteRewardManager getInstance() { return SingletonHolder._instance; } private static Logger _log = Logger.getLogger(com/l2jserver/gameserver/instancemanager/AutoVoteRewardManager.getName()); private static final String http = "http://l2topzone.com/lineage2/server-info/5239/L2Sigmo.html"; private static final int initialCheck = 1000; private static final int delayForCheck = 0x27100; private static final int itemId[] = { 14169, 9143 }; private static final int itemCount[] = { 1, 3 }; private static final int votesRequiredForReward = 5; private static List _ips = new ArrayList(); private static int lastVoteCount = 0; } -
[Share]L2J Server Freya Project + Source
mariusumf replied to 'Baggos''s topic in Server Development Discussion [Greek]
Auto Vote System doesn't work on topzone nor hopzone( i have l2jls and l2jgs maybe i need to bind them)! When i try to import the decompiled datapack or core in eclipse it doesnt work because it asks for user and password!!!! Any ideea??