Jump to content
  • 0

hopzone java code


Question

Posted

package net.sf.l2j.gameserver.instancemanager;

 

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.URL;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

 

import net.sf.l2j.Config;

import net.sf.l2j.L2DatabaseFactory;

import net.sf.l2j.gameserver.Announcements;

import net.sf.l2j.gameserver.ThreadPoolManager;

import net.sf.l2j.gameserver.model.L2ItemInstance;

import net.sf.l2j.gameserver.model.L2World;

import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;

 

public class AutoVoteRewardHandler

{

private final String HOPZONE = "Config.HopZone_ID";

// 60 * 1000(1000milliseconds = 1 second) = 60seconds

private final int initialCheck = 60 * 1000;

// 1800 * 1000(1000milliseconds = 1 second) = 1800seconds = 30minutes

private final int delayForCheck = Config.Delay_for_check * 1000;

private final int[] itemId = {Config.Item_ID};

private final int[] itemCount = {Config.Item_Count};

private final int[] maxStack = {Config.Max_Stack};

private final int votesRequiredForReward = Config.Votes_Required;

// do not change

private int lastVoteCount = 0;

 

private AutoVoteRewardHandler()

{

System.out.println("Vote Reward System Initiated.");

ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);

}

 

private class AutoReward implements Runnable

{

public void run()

{

int votes = getVotes();

System.out.println("Server Votes: " + votes);

if (votes != 0 && getLastVoteCount() != 0 && votes >= getLastVoteCount() + votesRequiredForReward)

{

Connection con = null;

try

{

con = L2DatabaseFactory.getInstance().getConnection();

PreparedStatement statement = con.prepareStatement("" +

"SELECT" +

" c.charId," +

" c.char_name" +

"FROM" +

" characters AS c" +

"LEFT JOIN" +

" accounts AS a" +

"ON" +

" c.account_name = a.login" +

"WHERE" +

" c.online > 0" +

"GROUP BY" +

" a.lastIP" +

"ORDER BY" +

" c.level" +

"DESC");

ResultSet rset = statement.executeQuery();

L2PcInstance player = null;

L2ItemInstance item = null;

while (rset.next())

{

player = L2World.getInstance().getPlayer("charId");

if (player != null && !player.getClient().isDetached())

{

for (int i = 0; i < itemId.length; i++)

{

item = player.getInventory().getItemByItemId(itemId);

if (item == null || item.getCount() < maxStack)

player.addItem("reward", itemId, itemCount, player, true);

}

}

}

statement.close();

}

catch (SQLException e)

{

e.printStackTrace();

}

finally

{

                          try { if (con != null) con.close(); } catch (SQLException e) { e.printStackTrace(); }

}

 

setLastVoteCount(getLastVoteCount() + votesRequiredForReward);

}

Announcements.getInstance().announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + votesRequiredForReward) + " Votes.");

if (getLastVoteCount() == 0)

setLastVoteCount(votes);

}

}

 

private int getVotes()

{

URL url = null;

InputStreamReader isr = null;

BufferedReader in = null;

try

{

url = new URL(HOPZONE);

isr = new InputStreamReader(url.openStream());

in = new BufferedReader(isr);

String inputLine;

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

{

if (inputLine.contains("moreinfo_total_rank_text"))

return Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));

}

}

catch (IOException e)

{

e.printStackTrace();

}

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;

}

 

public static AutoVoteRewardHandler getInstance()

{

return SingletonHolder._instance;

}

 

@SuppressWarnings("synthetic-access")

private static class SingletonHolder

{

protected static final AutoVoteRewardHandler _instance = new AutoVoteRewardHandler();

}

}

 

 

to code beni ok exw vali kai ta ipolipa gameserver+config alla m vgeni ena error sto parapano code

 

 

if (player != null && !player.getClient().isDetached())

 

 

 

bori kapios na m pi pos to fix afto??

10 answers to this question

Recommended Posts

  • 0
Posted

To quick fix που σου δίνει το eclipse το δοκίμασες;

ti? den to gnorizo afto pou les :) ase pou twra pros8ata arxisa na vazo java codes.
  • 0
Posted

L2GameClient.java line 70

 

private boolean _isDetached = false;

 

line 168

public boolean isDetached()
{
	return _isDetached;
}

public void setDetached(boolean b)
{
	_isDetached = b;
}

Βάλτο και θα είσαι οκ,για όποια απορία κάνε ένα reply.

  • 0
Posted

re ka8usterimene ti mlks les?

xaxaxa0  XD

ty m vgike to error alla otan anigo ton server to gameserver m vgazi error kai den 3ekinai ka9olou :) twra ti ftei??

πιθανός να έχει κάποιο λάθος το vote system,

φέρε μια φώτο με το error.

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

    • So dont plat that waste time&money server.   GM promises pie in the sky, but does nothing. It's all about money, money, money. And wipe.   SCAM server!
    • I'm looking for someone to remove GameGuard from a game that uses XTRAP. The game no longer uses XTRAP. I have a game server. But the client is kicked from the game after a few minutes of logging in. If I try to remove XTRAP (just by deleting it), the game opens and closes quickly.   Send me a PM. The game is Audition, a dance game.
    • 🎉 L2Dead StuckSub - GRAND OPENING 14 February 2026🎉 After beta, testing, mistakes, laughs and a lot of PvP, the moment has finally come. L2Dead StuckSub is officially opening its gates on 14 February 2026.   ⚔️What to expect: ✦Main Class +6 Stuck Sub system ✦Balanced PvP & custom party farm areas ✦Custom events, bosses and strong rewards ✦Competitive clan scene with castle rewards   📌Until the opening: ✦Create your clans and register them in the Clan-Register channel ✦Invite your friends / old parties / CPs ✦Stay tuned for more information (rates, events, siege times, etc.)   Get your setups ready, prepare your macros and your Discord/voice. On 14 February 2026 20:00 GMT+2, we write the first chapter of L2Dead together. 🔥 https://www.l2dead.com/ https://discord.gg/TGnATuZmdt
    • Here’s the **clean, L2jAcis-style way** to make **Auto Loot work ONLY for Premium players** on **Interlude**.   I’ll give you **two options** — pick what fits your server philosophy.   ---   ## ✅ OPTION 1 (BEST PRACTICE): Premium-Only Auto Loot (Code-based)   ### 🔹 Step 1: Add config option   **`config/Premium.properties`**   ```properties # Enable auto loot only for premium players PremiumAutoLoot = True ```   ---   ### 🔹 Step 2: Read config   **`Config.java`**   ```java public static boolean PREMIUM_AUTO_LOOT; ```   Load it:   ```java PREMIUM_AUTO_LOOT = Premium.getProperty("PremiumAutoLoot", false); ```   ---   ### 🔹 Step 3: Modify drop handling   **File:**   ``` net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance ```   Find **dropItems()** or **doItemDrop()** Replace / modify logic like this:   ```java if (player != null && player.isPremium() && Config.PREMIUM_AUTO_LOOT) {     for (ItemInstance item : items)         player.getInventory().addItem("AutoLoot", item, player, this); } else {     for (ItemInstance item : items)         dropItem(player, item); } ```   ✅ Result:   * **Premium players** → instant loot * **Normal players** → loot on ground   ---   ## ✅ OPTION 2: Auto Loot via Character Variable (More Flexible)   Useful if you want **GM control** per character.   ### 🔹 Premium activation   When premium is added:   ```java player.setVar("AUTO_LOOT", "1"); ```   ### 🔹 Drop check   ```java if (player != null && player.getVarB("AUTO_LOOT")) {     player.addItem("AutoLoot", item, player, true); } else {     dropItem(player, item); } ```   ---   ## 🎯 BONUS (Recommended Add-Ons)   ### 🔸 Adena always auto-loot (even non-premium)   ```java if (item.getItemId() == 57) {     player.addAdena("Loot", item.getCount(), this, true);     continue; } ```   ### 🔸 Party check (premium leader only)   ```java player.isInParty() && player.getParty().getLeader().isPremium() ```   ---   ## ⚠️ Notes (Interlude Safe)   ✔ Compatible with **L2jAcis Interlude** ✔ No client-side changes ✔ No exploit risk ✔ Retail-like behavior   ---      
  • 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..