Jump to content

Recommended Posts

Posted (edited)


#=============================================================

# Auto Vote Reward

#=============================================================

# Enable vote system

EnableVoteSystem = False

 

# Enabled or Disabled Topzone

EnableTopzone = False

 

# Votes required for reward.

VotesRequiredForReward = 3

 

# Votes system initial delay.

VotesSystemInitialDelay = 100

 

# Votes system step delay.

VotesSystemStepDelay = 100

 

# Reward (item, count).

# Reward Hopzone

HopzoneRewardId = 4037

HopzoneRewardCount = 3

 

# Reward (item, count).

# Reward Topzone

TopzoneRewardId = 4037

TopzoneRewardCount = 3

 

# Site URL.

# Leave empty to disable one site if you need just one of these.

VotesSiteHopZoneUrl =

VotesSiteTopZoneUrl =  


/** Auto Vote */

public static boolean ENABLE_VOTE_SYSTEM;

public static int VOTES_FOR_REWARD;

public static int VOTES_SYSTEM_INITIAL_DELAY;

public static int VOTES_SYSTEM_STEP_DELAY;

public static int HOPZONE_REWARD_ID;

public static int HOPZONE_REWARD_COUNT;

public static int TOPZONE_REWARD_ID;

public static int TOPZONE_REWARD_COUNT;

public static String VOTES_HOPZONE_REWARDS;

public static String VOTES_TOPZONE_REWARDS;

public static String VOTES_SITE_HOPZONE_URL;

public static String VOTES_SITE_TOPZONE_URL;

public static boolean VOTE_TOPZONE_ENABLED;


/** Auto Vote */

ENABLE_VOTE_SYSTEM = Boolean.parseBoolean(tester.getProperty("EnableVoteSystem", "False"));

VOTE_TOPZONE_ENABLED = Boolean.parseBoolean(tester.getProperty("EnableTopzone", "False"));

VOTES_FOR_REWARD = Integer.parseInt(tester.getProperty("VotesRequiredForReward", "100"));

VOTES_SYSTEM_INITIAL_DELAY = Integer.parseInt(tester.getProperty("VotesSystemInitialDelay", "60000"));

VOTES_SYSTEM_STEP_DELAY = Integer.parseInt(tester.getProperty("VotesSystemStepDelay", "1800000"));

VOTES_HOPZONE_REWARDS = tester.getProperty("VotesHopZoneRewards", "");

VOTES_SYSTEM_INITIAL_DELAY = Integer.parseInt(tester.getProperty("VotesSystemInitialDelay", "60000"));

HOPZONE_REWARD_ID = Integer.parseInt(tester.getProperty("HopzoneRewardId", "3470"));

HOPZONE_REWARD_COUNT = Integer.parseInt(tester.getProperty("HopzoneRewardCount", "10"));

TOPZONE_REWARD_ID = Integer.parseInt(tester.getProperty("TopzoneRewardId", "3470"));

TOPZONE_REWARD_COUNT = Integer.parseInt(tester.getProperty("TopzoneRewardCount", "10"));

VOTES_SITE_HOPZONE_URL = tester.getProperty("VotesSiteHopZoneUrl", "");

VOTES_SITE_TOPZONE_URL = tester.getProperty("VotesSiteTopZoneUrl", "");


/*

* 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 2, 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, write to the Free Software

* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA

* 02111-1307, USA.

*

* http://www.gnu.org/copyleft/gpl.html

*/

package com.l2jfrozen.gameserver.custom;

 

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.HttpURLConnection;

import java.net.URL;

import java.util.ArrayList;

import java.util.Collection;

import java.util.List;

import java.util.logging.Logger;

 

import com.l2jfrozen.Config;

import com.l2jfrozen.gameserver.datatables.sql.ItemTable;

import com.l2jfrozen.gameserver.model.L2World;

import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;

import com.l2jfrozen.gameserver.model.entity.Announcements;

import com.l2jfrozen.gameserver.thread.ThreadPoolManager;

 

public class AutoVoteReward

{

public static Logger _log = Logger.getLogger(AutoVoteReward.class.getName());

 

private int hopzoneVotesCount = 0;

private int topzoneVotesCount = 0;

protected List<String> already_rewarded;

 

protected static boolean topzone = false;

protected static boolean hopzone = false;

 

private AutoVoteReward()

{

_log.info("VoteRewardSystem: Initialized.");

if(hopzone)

{

int hopzone_votes = getHopZoneVotes();

if(hopzone_votes == -1)

{

hopzone_votes = 0;

}

 

setHopZoneVoteCount(hopzone_votes);

}

 

if(Config.VOTE_TOPZONE_ENABLED)

{

if(topzone)

{

int topzone_votes = getTopZoneVotes();

if(topzone_votes == -1)

{

topzone_votes = 0;

}

 

setTopZoneVoteCount(topzone_votes);

}

}

 

ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), Config.VOTES_SYSTEM_INITIAL_DELAY, Config.VOTES_SYSTEM_STEP_DELAY);

}

 

protected class AutoReward implements Runnable

{

@Override

public void run()

{

if(hopzone)

{

int hopzone_votes = getHopZoneVotes();

if(hopzone_votes != -1)

{

_log.info("Hopzone Votes: " + hopzone_votes);

 

if(hopzone_votes != 0 && hopzone_votes >= getHopZoneVoteCount() + Config.VOTES_FOR_REWARD)

{

already_rewarded = new ArrayList<>();

 

Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();

 

for(L2PcInstance player : pls)

{

if(player != null && !player.isOffline())

{

if(checkSingleBox(player))

{

player.addItem("reward", Config.HOPZONE_REWARD_ID, Config.HOPZONE_REWARD_COUNT, player, true);

}

}

}

 

setHopZoneVoteCount(hopzone_votes);

}

Announcements.voteAnnounce("Votes Now " + hopzone_votes + ". " + (getHopZoneVoteCount() + Config.VOTES_FOR_REWARD) + " Votes left at HOPZONE until next reward (" + Config.HOPZONE_REWARD_COUNT + " " + ItemTable.getInstance().getTemplate(Config.HOPZONE_REWARD_ID).getName() + ")");

}

}

if(Config.VOTE_TOPZONE_ENABLED)

{

if(topzone && hopzone && Config.VOTES_SYSTEM_STEP_DELAY > 0)

{

try

{

Thread.sleep(Config.VOTES_SYSTEM_STEP_DELAY / 2);

}

catch(InterruptedException e)

{

e.printStackTrace();

}

}

}

 

if(Config.VOTE_TOPZONE_ENABLED)

{

if(topzone)

{

int topzone_votes = getTopZoneVotes();

if(topzone_votes != -1)

{

_log.info("TopZone Votes: " + topzone_votes);

 

if(topzone_votes != 0 && topzone_votes >= getTopZoneVoteCount() + Config.VOTES_FOR_REWARD)

{

already_rewarded = new ArrayList<>();

 

Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();

 

for(L2PcInstance player : pls)

{

if(player != null && !player.isOffline())

{

if(checkSingleBox(player))

{

player.addItem("reward", Config.TOPZONE_REWARD_ID, Config.TOPZONE_REWARD_COUNT, player, true);

}

}

}

 

setTopZoneVoteCount(topzone_votes);

}

Announcements.voteAnnounce("Votes Now " + topzone_votes + ". " + (getTopZoneVoteCount() + Config.VOTES_FOR_REWARD) + " Votes left at TOPZONE until next reward (" + Config.TOPZONE_REWARD_COUNT + " " + ItemTable.getInstance().getTemplate(Config.TOPZONE_REWARD_ID).getName() + ")");

}

}

}

}

}

 

protected boolean checkSingleBox(L2PcInstance player)

{

if(player.getClient()!=null && player.getClient().getConnection()!=null && !player.getClient().getConnection().isClosed() && !player.isOffline()){

 

String playerip = player.getClient().getConnection().getInetAddress().getHostAddress();

 

if(already_rewarded.contains(playerip))

return false;

already_rewarded.add(playerip);

return true;

}

return false;

}

 

 

 

protected int getHopZoneVotes()

{

URL url = null;

InputStreamReader isr = null;

BufferedReader in = null;

 

try

{

if(!Config.VOTES_SITE_HOPZONE_URL.endsWith(".html"))

Config.VOTES_SITE_HOPZONE_URL+=".html";

 

url = new URL(Config.VOTES_SITE_HOPZONE_URL);

HttpURLConnection con = (HttpURLConnection) url.openConnection();

HttpURLConnection.setFollowRedirects(false);

con.setConnectTimeout(10 * 1000);

con.addRequestProperty("User-L2Hopzone", "Mozilla/4.76");

isr = new InputStreamReader(con.getInputStream());

in = new BufferedReader(isr);

 

String line;

while ((line = in.readLine()) != null)

{

if (line.contains("no steal make love")||line.contains("no votes here")||line.contains("bang, you don't have votes")|| line.contains("la vita e bella"))

{

int votes = Integer.valueOf(line.split(">")[2].replace("</span", ""));

return votes;

}

}

}

catch (final Exception e)

{

_log.warning("[AutoVoteReward] Server L2Hopzone is offline or something is wrong in link");

Announcements.getInstance().AnnounceToAll("[AutoVoteReward] L2Hopzone is offline. We will check reward as it will be online again");

}

finally

{

if (in != null)

try

{

in.close();

}

catch (final IOException e1)

{

e1.printStackTrace();

}

if (isr != null)

try

{

isr.close();

}

catch (final IOException e1)

{

e1.printStackTrace();

}

}

return -1;

}

 

protected int getTopZoneVotes()

{

int votes = -1;

try

{

final URL obj = new URL(Config.VOTES_SITE_TOPZONE_URL);

final HttpURLConnection con = (HttpURLConnection) obj.openConnection();

 

con.addRequestProperty("User-Agent", "L2TopZone");

con.setConnectTimeout(5000);

 

final int responseCode = con.getResponseCode();

if (responseCode == 200) // OK

{

try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())))

{

String inputLine;

while ((inputLine = in.readLine()) != null)

{

if (inputLine.contains("Votes:"))

{

votes = Integer.valueOf(inputLine.split("<br>")[1].replace("</div>", ""));

break;

}

}

}

}

}

catch (Exception e)

{

if (topzone)

System.out.println("TOPZONE is offline. We will check reward as it will be online again.");

}

return votes;

}

 

protected void setHopZoneVoteCount(int voteCount)

{

hopzoneVotesCount = voteCount;

}

 

protected int getHopZoneVoteCount()

{

return hopzoneVotesCount;

}

 

protected void setTopZoneVoteCount(int voteCount)

{

topzoneVotesCount = voteCount;

}

 

protected int getTopZoneVoteCount()

{

return topzoneVotesCount;

}

 

public static AutoVoteReward getInstance()

{

if(Config.VOTES_SITE_HOPZONE_URL != null && !Config.VOTES_SITE_HOPZONE_URL.equals("")){

hopzone = true;

}

 

if(Config.VOTES_SITE_TOPZONE_URL != null && !Config.VOTES_SITE_TOPZONE_URL.equals("")){

topzone = true;

}

 

if(topzone || hopzone)

return SingletonHolder._instance;

return null;

}

 

@SuppressWarnings("synthetic-access")

private static class SingletonHolder

{

protected static final AutoVoteReward _instance = new AutoVoteReward();

}

 

}


Gameserver.java

 

 

import com.l2jfrozen.gameserver.custom.AutoVoteReward;

 

 

 

Util.printSection("Vote System - L2JFrozen");

if(Config.ENABLE_VOTE_SYSTEM)

{

AutoVoteReward.getInstance();

}

 

Edited by Harut
Posted

Topzone is ok. Since its method which I posted somewhere.

 

At least you could change hopzone to the same sexy style.. C/p since ages.

  • 1 month later...
Posted

i have error in tester.getProperty

Just throw the config java code in a already exist config.

Like "players.getProperty".

After change the tester.getProperty to players.getProperty

  • 3 weeks later...
Guest
This topic is now closed to further replies.


  • Posts

    • Hello Dexters! https://lineage2dex.com    This is pre-announcing of NEW season server, so we want to share some key points of it. Full details with road map, patch notes we will announce a bit latter Opening September 27 at 19:00 (UTC +3) Open Beta Test from September 23 What’s New This Season?, This is just a short preview of the most exciting changes and updates. A patch note with balance change will be posted later in this thread – one topic with all patchnotes history from 2022 year EXP/SP x25 - Over the past few seasons, our servers were drifting closer to a mid-rate style. And hard to call it now pure PVP server. That’s why we’ve reduced EXP/SP rates from x50 to x25 – making progression smoother, more balanced, and more in line with the mid-rate identity., Improved Olympiad matchmaking – opponents will be matched by strength, making feeding much harder., K/D stats for CC – track your real impact!, New In-Game Shop Interface - no more running to NPCs for supplies – buy everything directly from the interface. NPC Astarte will now only handle services like WH, sales, LS insertion, etc., Balance Adjustments - small but important tweaks for a smoother PvP experience (details in patch notes)., Replica Instance System Reworked - upgrading replicas now requires not only fragments but also real jewellery from B to S grades. You can choose from 3 instance types: PvP Instance – biggest rewards (everyone spawns together for mass PvP)., CC Instance – private instance for your CC., Party Instance – private instance for your party., , Dino Island Returns - back by popular demand: Dark Zone (PvP) and Light Zone (PvE)., Newbie Pass Questline - available at character creation – helps you get familiar with the server and make start progression faster., Clan members taxation system, Full announce - read on forum, https://forum.lineage2dex.com/threads/16723/ (edited)   We’re excited to show you how the Newbie Path will look on the Seasonal Server and share a few details about it. The Newbie Path is designed to help new players on Dex adapt more easily on project. While it won’t reveal the full content of the game, it will greatly assist during the early stages of your journey. But it’s not just for newcomers! Even veteran players will find it useful — completing Newbie Path steps will grant you small progression boosts and extra rewards(exp boosts, some gear, potions etc). Definitely worth using! You’ll be able to test the full Newbie Path system yourself during the Open Beta, launching on September 23rd!
    • 📢 [OFFICIAL ANNOUNCEMENT] 🔥 Lineage 2 Interlude x10 Craft-PvP 🔥 🎮 Grand Opening — September 19 @ 19:00 [UTC +2] 🧪 Open Beta — September 15 @ 19:00 [UTC +2]    🌐 Full server description - https://lineage2.ms/en/wiki 💥 Why Interlude x10 Craft-PvP? ✅ GM Shop up to B-Grade + Full Buffs — get straight to action, no pointless grinding. ✅ Unique Geodata & Geopathfinding Engine — smooth, tactical, and truly next-gen. ✅ Two Client Options — play in Classic or Interlude style. ✅ No Pay-to-Win — donations don’t break the balance. ✅ 1+1 Mode Enabled — max 2 windows, only 1 active = no box armies. ✅ Bot-Free Zone — advanced protection + non-intrusive popup captchas. ✅ No GM Interference — fair, competitive PvP environment. ✅ No Wipes — your progress is safe. ✅ Truly International — global reach, not just CIS players. 🛡 2nd Season. Stronger, Smarter, Updated. 🎯 Pure Craft-PvP. 🌍 Real Competition. 📅 Mark your calendars. Tell your clan. Invite your friends. Let’s make this season legendary. 💪 https://discord.gg/lineage2ms
    • As far as I know, L2Gold stated (unofficially) that closed for legal reasons. Although, my estimation is that it had reached such low popularity (believe me I know, I played till the last day), so they closed it because of that. As for "other" copies or w/e. I believe that everyone has the right to do what they think is best.  I have to say, I find your claims a bit exaggerating. Many servers have done a good job at recreating such a server. There are actually leaked files of C4 L2Gold (L2OFF) so many owners started working from there (L2Gold.cc (old Avellan), L2Gold.in, L2Gold.co etc.) There are other owners that took the idea 1 step further, adapting L2Gold in higher Chronicles and started working on a brand-new style with old features along. @Trance @Brado @To4kA (those are some of the owners that I can think of right now). I think you should re-think your opinions and don't judge them all together. Many of the servers you've mentioned has actually done a decent job and tried to take the brand, one step further. The argument here is that everyone should do what they want. Community will judge if it's good or bad.
    • Let’s start from the beginning. The original L2Gold.cc server shut down in 2013. Since that time, the real and authentic L2 Gold Rush has not existed, and the reasons for its closure remain unknown. From what I know, after that moment many copies started to appear – people who had no real idea how to recreate the original server simply began releasing imitations under different names such as gold.in, gold.net, gold.org, gold.us, and so on. Am I wrong?
  • Topics

×
×
  • 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