Jump to content

Search the Community

Showing results for tags 'javacode'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General Zone
    • Announcements and News
    • Newbies Introduce Urself
    • Maxcheaters Competitions & Events
    • Votes/Polls Area
    • Report Section
    • Downloads Section
    • Suggestions/Feedback Board
  • Lineage II General Section
    • General Discussion [English]
    • Request Support [English]
  • Lineage II Hacks,Cheats and Bots
    • Hacks & Cheats [English]
    • Request Hacks & Cheats [English]
    • Botting [English]
    • Request Botting [English]
  • Lineage II Private Servers
    • Buy Advertising Link #1
    • Private Servers
    • Buy Advertising Link #2
    • [Previews] L2 Private Servers
    • Clans and Alliances
  • Lineage II Marketplace
    • Marketplace [Items & Chars]
    • Marketplace [L2Packs & Files]
    • Marketplace [Powerlvl & Support]
    • Marketplace [Webdesign & Webdevelop]
  • Lineage II OFF Server Development
    • Server Development Discussion [L2OFF]
    • Request Server Development Help [L2OFF]
    • Server Shares & Files [L2OFF]
  • Lineage II Java Server Development
    • Server Development Discussion [L2J]
    • Request Server Development Help [L2J]
    • Server Shares & Files [L2J]
    • Private Projects [L2J]
  • Lineage II Client Development
    • Client Development Discussion
  • MMO Games
    • Grand Theft Auto V: FiveM
    • League of Legends
    • Other Multiplayer Games
  • General Section
    • General Marketplace
    • Crypto Zone
    • Consoles/Mobile Gaming Zone
    • Webmasters Zone
    • Hacking/Coding Zone
  • Graphics/GFX Zone
    • Graphics/GFX General Discussion
    • Graphics/GFX Showcase
    • Graphics/GFX Resources/Tools
  • Premium Zone
    • General Discussion [Premium]
    • Lineage II [Premium]
    • GFX Area [Premium]
  • MaxCheaters Corner
    • Tech/World News
    • Off-Topics
    • Spam Topics
  • L2Classic Club's Just trying this thing out
  • Lineage 2 Revolution Club's Discussions
  • Lineage 2 Revolution Club's Tutorials
  • Lineage 2 Revolution Club's Request Help
  • DenArt Designs's Hello and welcome to my club!
  • DenArt Designs's News

Product Groups

  • Advertisements
  • Old Vips
  • Premium Member

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


LocationNew

Found 3 results

  1. Hi guys once again i need your help. I added a shift + click droplist panel on my server works fine except one missfaction. When the droplist is too big for example grandbosses the html page crashes. "Your html is too long use database for this action" So i need to seperate the droplist data in pages [1,2,3] or adding a next page button. Looking for someone to help me! Thank you! My java code is here i use only requestbypasstoserver.java : else if (_command.startsWith("DropListNpc")) { final L2Object object = activeChar.getTarget(); if (object instanceof L2NpcInstance) { NpcHtmlMessage html = new NpcHtmlMessage(0); StringBuilder html1 = new StringBuilder("<html>"); html1.append("<title>Npc Name: " + object.getName() + "</title>"); html1.append("<body>"); html1.append("<br>"); html1.append("<table cellspacing=2 cellpadding=1 width=\"280\">"); if (((L2NpcInstance) object).getTemplate().getDropData() != null) { for (L2DropCategory cat : ((L2NpcInstance) object).getTemplate().getDropData()) { for (L2DropData drop : cat.getAllDrops()) { final L2Item item = ItemTable.getInstance().getTemplate(drop.getItemId()); if (item == null) continue; int mind = 0, maxd = 0; String smind = null, smaxd = null; String name = item.getName(); if (cat.isSweep()) { mind = (int) (Config.RATE_DROP_SPOIL * drop.getMinDrop()); maxd = (int) (Config.RATE_DROP_SPOIL * drop.getMaxDrop()); } else if (drop.getItemId() == 57) { mind = 300 * drop.getMinDrop(); maxd = 300 * drop.getMaxDrop(); } else { mind = (int) (Config.RATE_DROP_ITEMS * drop.getMinDrop()); maxd = (int) (Config.RATE_DROP_ITEMS * drop.getMaxDrop()); } if (mind > 999999) { DecimalFormat df = new DecimalFormat("###.#"); smind = df.format(((double) (mind)) / 1000000) + " KK"; smaxd = df.format(((double) (maxd)) / 1000000) + " KK"; } else if (mind > 999) { smind = ((mind / 1000)) + " K"; smaxd = ((maxd / 1000)) + " K"; } else { smind = Integer.toString(mind); smaxd = Integer.toString(maxd); } if (name.startsWith("Common Item - ")) { name = "(CI)" + name.substring(14); } if (name.length() >= 34) { name = name.substring(0, 30) + "..."; } html1.append("<tr>"); html1.append("<td valign=top align=center height=38 width=40><img src=\"" + getIcon(item.getItemId()) + "\" height=32 width=32></td>"); html1.append("<td>"); html1.append("<table cellpadding=0 cellspacing=1 width=260>"); html1.append("<tr>"); html1.append("<td><font color=fff600>" + name + "</font> " + (maxd == 1 ? "[1]" : "[" + smind + " - " + smaxd + "]") + "</td>"); html1.append("</tr>"); html1.append("<tr>"); html1.append("<td><font color=00ff00>Chance: </font>" + (drop.getChance() >= 10000 ? (double) drop.getChance() / 10000 : drop.getChance() < 10000 ? (double) drop.getChance() / 10000 : "N/A") + "% "+ "</td>"); html1.append("</tr>"); html1.append("<tr>"); html1.append("<td><font color=00b3b3>Drop Type:</font> " + (drop.isQuestDrop() ? "<font color=00b3b3>[Quest]</font>" : (cat.isSweep() ? "<font color=ff00ff>[Spoil]</font> " : "<font color=00b3b3>[Drop]</font>")) + "</td>"); html1.append("</tr>"); html1.append("</table><img src=L2UI.SquareGray width=260 height=1>"); html1.append("</td>"); } } } html1.append("</tr></table>"); html1.append("</body>"); html1.append("</html>"); html.setHtml(html1.toString()); activeChar.sendPacket(html); html1 = null; html = null; } } }
  2. /* 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.model.actor.instance; import com.l2jfrozen.gameserver.ai.CtrlIntention; import com.l2jfrozen.gameserver.managers.TownManager; import com.l2jfrozen.gameserver.model.L2Character; import com.l2jfrozen.gameserver.model.zone.L2ZoneType; 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.ValidateLocation; import com.l2jfrozen.gameserver.templates.L2NpcTemplate; import javolution.text.TextBuilder; public class L2SpecialGatekeeperInstance extends L2FolkInstance { public L2SpecialGatekeeperInstance(int objectId, L2NpcTemplate template) { super(objectId, template); } @Override public void onBypassFeedback(L2PcInstance player, String command) { if(player == null) { return; } if(command.startsWith("giran")) { player.teleToLocation(82698, 148638, -3473); } if(command.startsWith("aden")) { player.teleToLocation(147456, 26886, -2207); } if(command.startsWith("goddard")) { player.teleToLocation(147725, -56517, -2780); } if(command.startsWith("ti")) { player.teleToLocation(-83838, 242732, -3732); } if(command.startsWith("elv")) { player.teleToLocation(45873, 49288, -3059); } if(command.startsWith("delv")) { player.teleToLocation(12428, 16551, -4588); } if(command.startsWith("dwarf")) { player.teleToLocation(116551, -182493, -1525); } if(command.startsWith("orc")) { player.teleToLocation(-44133, -113911, -244); } if(command.startsWith("oren")) { player.teleToLocation(82321, 55139, -1529); } if(command.startsWith("dion")) { player.teleToLocation(18748, 145437, -3132); } if(command.startsWith("heine")) { player.teleToLocation(111383, 219107, -3546); } if(command.startsWith("gludio")) { player.teleToLocation(-14225, 123540, -3121); } if(command.startsWith("stut")) { player.teleToLocation(87358, -141982, -1336); } if(command.startsWith("gludin")) { player.teleToLocation(-83063, 150791, -3128); } if(command.startsWith("floran")) { player.teleToLocation(17144, 170156, -3502); } if(command.startsWith("rune")) { player.teleToLocation(44070, -50243, -796); } } @Override public void onAction(L2PcInstance player) { if (!canTarget(player)) { return; } 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); } else { showHtmlWindow(player); } player.sendPacket(new ActionFailed()); } private void showHtmlWindow(L2PcInstance activeChar) { NpcHtmlMessage nhm = new NpcHtmlMessage(5); TextBuilder tb = new TextBuilder(""); tb.append("<html><head><title>Global Gatekeeper</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\">Advanced Gatekeeper</font>"); tb.append("<br1><font color=\"00FF00\">"+activeChar.getName()+"</font>, here you can spy who's where.</td>"); tb.append("</tr>"); tb.append("</table>"); tb.append("</center>"); tb.append("<center>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Where you gonna teleport " + activeChar.getName()+".</font><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Talking I. : " + pewpew(2)+".</font>"); tb.append("<button value=\"Talking I.\" action=\"bypass -h npc_" + getObjectId() + "_ti\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Elven V. : " + pewpew(3)+".</font>"); tb.append("<button value=\"Elven V.\" action=\"bypass -h npc_" + getObjectId() + "_elv\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside D.Elven V. : " + pewpew(1)+".</font>"); tb.append("<button value=\"D.Elven V.\" action=\"bypass -h npc_" + getObjectId() + "_delv\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Orc V. : " + pewpew(4)+".</font>"); tb.append("<button value=\"Orc V.\" action=\"bypass -h npc_" + getObjectId() + "_orc\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Dwarven V. : " + pewpew(6)+".</font>"); tb.append("<button value=\"Dwarven V.\" action=\"bypass -h npc_" + getObjectId() + "_dwarf\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Giran : " + pewpew(9)+".</font>"); tb.append("<button value=\"Giran\" action=\"bypass -h npc_" + getObjectId() + "_giran\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Aden : " + pewpew(12)+".</font>"); tb.append("<button value=\"Aden\" action=\"bypass -h npc_" + getObjectId() + "_aden\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Gludio : " + pewpew(7)+".</font>"); tb.append("<button value=\"Gludio\" action=\"bypass -h npc_" + getObjectId() + "_gludio\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Gludin : " + pewpew(5)+".</font>"); tb.append("<button value=\"Gludin\" action=\"bypass -h npc_" + getObjectId() + "_gludin\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Dion : " + pewpew(8)+".</font>"); tb.append("<button value=\"Dion\" action=\"bypass -h npc_" + getObjectId() + "_dion\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Oren : " + pewpew(10)+".</font>"); tb.append("<button value=\"Oren\" action=\"bypass -h npc_" + getObjectId() + "_oren\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Heine : " + pewpew(15)+".</font>"); tb.append("<button value=\"Heine\" action=\"bypass -h npc_" + getObjectId() + "_heine\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Rune : " + pewpew(14)+".</font>"); tb.append("<button value=\"Rune\" action=\"bypass -h npc_" + getObjectId() + "_rune\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Goddard : " + pewpew(13)+".</font>"); tb.append("<button value=\"Goddard\" action=\"bypass -h npc_" + getObjectId() + "_goddard\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Schuttgart : " + pewpew(17)+".</font>"); tb.append("<button value=\"Schuttgart\" action=\"bypass -h npc_" + getObjectId() + "_stut\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("<td valign=\"top\"><font color=\"FF6600\">Players Inside Floran : " + pewpew(16)+".</font>"); tb.append("<button value=\"Floran\" action=\"bypass -h npc_" + getObjectId() + "_floran\" width=70 height=21 back=\"L2UI.DefaultButton_click\" fore=\"L2UI.DefaultButton\"><br>"); tb.append("</center>"); tb.append("<center>"); tb.append("<img src=\"l2ui_ch3.herotower_deco\" width=256 height=32 align=center>"); tb.append("<font color=\"FF6600\">www.private.com</font>"); tb.append("</center>"); tb.append("</body></html>"); nhm.setHtml(tb.toString()); activeChar.sendPacket(nhm); activeChar.sendPacket(new ActionFailed()); } public static int pewpew(int bitch) { L2ZoneType zone = TownManager.getInstance().getTown(bitch); int i = 0; if(zone != null) { for (L2Character character : zone.getCharactersInside().values()) if (character instanceof L2PcInstance) i++; return i; } return -1; } } is there any Developer , that can make this gatekeeper instance to be editable in html npc.!!
  3. Δεν μπορω να βρω το Reward ουτε στο java code ουτε στα config δεν βρηκα κατι σχετικο με Vote μπορει καποιος να μου προτεiνει κατι? code com.l2jfrozen.gameserver.handler; package com.l2jfrozen.gameserver.handler; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Set; import org.apache.log4j.Level; import org.apache.log4j.Logger; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.l2jfrozen.Config; 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.powerpak.PowerPakConfig; import com.l2jfrozen.gameserver.thread.ThreadPoolManager; /** * @author L2jFrozen <br> * <br> * Network working with L2jFrozen AutoVoteReward: <br> * Hopzone -> http://l2.hopzone.net/ <br> * Topzone -> http://l2topzone.com/ <br> * L2network -> http://l2network.eu/ <br> */ public class AutoVoteRewardHandler { protected static final Logger LOGGER = Logger.getLogger(AutoVoteRewardHandler.class); protected List<String> already_rewarded; private int _l2networkVotesCount = 0; private int _hopzoneVotesCount = 0; private int _topzoneVotesCount = 0; protected List<String> _already_rewarded; protected static boolean _l2network = false; protected static boolean _topzone = false; protected static boolean _hopzone = false; private AutoVoteRewardHandler() { LOGGER.info("Vote Reward System Initiated."); if (_hopzone) { int hopzone_votes = getHopZoneVotes(); if (hopzone_votes == -1) { hopzone_votes = 0; } setHopZoneVoteCount(hopzone_votes); } if (_l2network) { int l2network_votes = getL2NetworkVotes(); if (l2network_votes == -1) { l2network_votes = 0; } setL2NetworkVoteCount(l2network_votes); } if (_topzone) { int topzone_votes = getTopZoneVotes(); if (topzone_votes == -1) { topzone_votes = 0; } setTopZoneVoteCount(topzone_votes); } ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), PowerPakConfig.VOTES_SYSYEM_INITIAL_DELAY, PowerPakConfig.VOTES_SYSYEM_STEP_DELAY); } protected class AutoReward implements Runnable { @Override public void run() { final int minutes = (PowerPakConfig.VOTES_SYSYEM_STEP_DELAY / 1000) / 60; if (_hopzone) { final int hopzone_votes = getHopZoneVotes(); if (hopzone_votes != -1) { LOGGER.info("[AutoVoteReward] Server HOPZONE Votes: " + hopzone_votes); Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] Actual HOPZONE Votes are " + hopzone_votes + "..."); if (hopzone_votes != 0 && hopzone_votes >= getHopZoneVoteCount() + PowerPakConfig.VOTES_FOR_REWARD) { _already_rewarded = new ArrayList<>(); final Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers(); Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] Great Work! Check your inventory for Reward!!"); // L2ItemInstance item; for (final L2PcInstance player : pls) { if (player != null && !player.isInOfflineMode() && player.isOnline() == 1) { if (player._active_boxes <= 1 || (player._active_boxes > 1 && checkSingleBox(player))) { final Set<Integer> items = PowerPakConfig.VOTES_REWARDS_LIST.keySet(); for (final Integer i : items) { // item = player.getInventory().getItemByItemId(i); // TODO: check on maxstack for item player.addItem("reward", i, PowerPakConfig.VOTES_REWARDS_LIST.get(i), player, true); } } } } setHopZoneVoteCount(hopzone_votes); } Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] Next HOPZONE Reward in " + minutes + " minutes at " + (getHopZoneVoteCount() + PowerPakConfig.VOTES_FOR_REWARD) + " Votes!!"); // site web Announcements.getInstance().gameAnnounceToAll("[SiteWeb] " + PowerPakConfig.SERVER_WEB_SITE); } } if (_topzone && _hopzone && PowerPakConfig.VOTES_SYSYEM_STEP_DELAY > 0) { try { Thread.sleep(PowerPakConfig.VOTES_SYSYEM_STEP_DELAY / 2); } catch (final InterruptedException e) { if (Config.ENABLE_ALL_EXCEPTIONS) e.printStackTrace(); } } if (_topzone) { final int topzone_votes = getTopZoneVotes(); if (topzone_votes != -1) { LOGGER.info("[AutoVoteReward] Server TOPZONE Votes: " + topzone_votes); Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] Actual TOPZONE Votes are " + topzone_votes + "..."); if (topzone_votes != 0 && topzone_votes >= getTopZoneVoteCount() + PowerPakConfig.VOTES_FOR_REWARD) { _already_rewarded = new ArrayList<>(); final Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers(); Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] Great Work! Check your inventory for Reward!!"); // L2ItemInstance item; for (final L2PcInstance player : pls) { if (player != null && !player.isInOfflineMode() && player.isOnline() == 1) { if (player._active_boxes <= 1 || (player._active_boxes > 1 && checkSingleBox(player))) { final Set<Integer> items = PowerPakConfig.VOTES_REWARDS_LIST.keySet(); for (final Integer i : items) { // item = player.getInventory().getItemByItemId(i); // TODO: check on maxstack for item player.addItem("reward", i, PowerPakConfig.VOTES_REWARDS_LIST.get(i), player, true); } } } } setTopZoneVoteCount(topzone_votes); } Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] Next TOPZONE Reward in " + minutes + " minutes at " + (getTopZoneVoteCount() + PowerPakConfig.VOTES_FOR_REWARD) + " Votes!!"); // site web Announcements.getInstance().gameAnnounceToAll("[SiteWeb] " + PowerPakConfig.SERVER_WEB_SITE); } } if (_topzone && _hopzone && _l2network && PowerPakConfig.VOTES_SYSYEM_STEP_DELAY > 0) { try { Thread.sleep(PowerPakConfig.VOTES_SYSYEM_STEP_DELAY / 2); } catch (final InterruptedException e) { if (Config.ENABLE_ALL_EXCEPTIONS) e.printStackTrace(); } } if (_l2network) { final int l2network_votes = getL2NetworkVotes(); if (l2network_votes != -1) { LOGGER.info("[AutoVoteReward] Server L2NETWORK Votes: " + l2network_votes); Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] Actual L2Network Votes are " + l2network_votes + "..."); if (l2network_votes != 0 && l2network_votes >= getL2NetworkVoteCount() + PowerPakConfig.VOTES_FOR_REWARD) { already_rewarded = new ArrayList<>(); final Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers(); Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] Great Work! Check your inventory for Reward!!"); // L2ItemInstance item; for (final L2PcInstance player : pls) { if (player != null && !player.isInOfflineMode() && player.isOnline() == 1) { if (player._active_boxes <= 1 || (player._active_boxes > 1 && checkSingleBox(player))) { final Set<Integer> items = PowerPakConfig.VOTES_REWARDS_LIST.keySet(); for (final Integer i : items) { // item = player.getInventory().getItemByItemId(i); // TODO: check on maxstack for item player.addItem("reward", i, PowerPakConfig.VOTES_REWARDS_LIST.get(i), player, true); } } } } setL2NetworkVoteCount(l2network_votes); } Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] Next L2Network Reward in " + minutes + " minutes at " + (getL2NetworkVoteCount() + PowerPakConfig.VOTES_FOR_REWARD) + " Votes!!"); // site web Announcements.getInstance().gameAnnounceToAll("[SiteWeb] " + PowerPakConfig.SERVER_WEB_SITE); } } } } // Check boxes protected boolean checkSingleBox(final L2PcInstance player) { if (player == null) return false; if (player.getClient() != null && player.getClient().getConnection() != null && !player.getClient().getConnection().isClosed() && player.isOnline() == 1 && !player.isInOfflineMode()) { final String playerip = player.getClient().getConnection().getInetAddress().getHostAddress(); if (_already_rewarded.contains(playerip)) return false; _already_rewarded.add(playerip); return true; } // if no connection (maybe offline shop) dnt reward return false; } protected int getHopZoneVotes() { int votes = -1; try { final WebClient webClient = new WebClient(BrowserVersion.CHROME); webClient.getOptions().setThrowExceptionOnFailingStatusCode(false); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.getOptions().setPrintContentOnFailingStatusCode(false); final HtmlPage page = webClient.getPage(PowerPakConfig.VOTES_SITE_HOPZONE_URL); final String fullPage = page.asXml(); final int constrainA = fullPage.indexOf("rank anonymous tooltip") + 24; String voteSection = fullPage.substring(constrainA); final int constrainB = voteSection.indexOf("span") - 2; voteSection = voteSection.substring(0, constrainB).trim(); votes = Integer.parseInt(voteSection); // Try to free all the freaking resources page.cleanUp(); webClient.getJavaScriptEngine().shutdown(); webClient.closeAllWindows(); } catch (final Exception e) { LOGGER.warn("[AutoVoteReward] Server HOPZONE is offline or something is wrong in link", e); Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] HOPZONE is offline. We will check reward as it will be online again"); } return votes; } protected int getTopZoneVotes() { int votes = -1; URL url = null; URLConnection con = null; InputStream is = null; InputStreamReader isr = null; BufferedReader in = null; try { url = new URL(PowerPakConfig.VOTES_SITE_TOPZONE_URL); 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")) { votes = Integer.valueOf(inputLine.split(">")[3].replace("</div", "")); break; } } } catch (final Exception e) { LOGGER.warn("[AutoVoteReward] Server TOPZONE is offline or something is wrong in link"); Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] TOPZONE is offline. We will check reward as it will be online again"); // e.printStackTrace(); } 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(); } if (is != null) try { is.close(); } catch (final IOException e1) { e1.printStackTrace(); } } return votes; } protected int getL2NetworkVotes() { int votes = -1; URL url = null; URLConnection con = null; InputStream is = null; InputStreamReader isr = null; BufferedReader in = null; try { url = new URL(PowerPakConfig.VOTES_SITE_L2NETWORK_URL); con = url.openConnection(); con.addRequestProperty("User-Agent", "L2Network"); is = con.getInputStream(); isr = new InputStreamReader(is); in = new BufferedReader(isr); String inputLine; while ((inputLine = in.readLine()) != null) { if (inputLine.contains("color:#e7ebf2")) { votes = Integer.valueOf(inputLine.split(">")[2].replace("</b", "")); break; } } } catch (final Exception e) { LOGGER.warn("[AutoVoteReward] Server L2NETWORK is offline or something is wrong in link"); Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] L2Network is offline. We will check reward as it will be online again"); // e.printStackTrace(); } 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(); } if (is != null) try { is.close(); } catch (final IOException e1) { e1.printStackTrace(); } } return votes; } protected void setHopZoneVoteCount(final int voteCount) { _hopzoneVotesCount = voteCount; } protected int getHopZoneVoteCount() { return _hopzoneVotesCount; } protected void setTopZoneVoteCount(final int voteCount) { _topzoneVotesCount = voteCount; } protected int getTopZoneVoteCount() { return _topzoneVotesCount; } protected void setL2NetworkVoteCount(final int voteCount) { _l2networkVotesCount = voteCount; } protected int getL2NetworkVoteCount() { return _l2networkVotesCount; } public static AutoVoteRewardHandler getInstance() { Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF); if (PowerPakConfig.VOTES_SITE_HOPZONE_URL != null && !PowerPakConfig.VOTES_SITE_HOPZONE_URL.equals("")) _hopzone = true; if (PowerPakConfig.VOTES_SITE_TOPZONE_URL != null && !PowerPakConfig.VOTES_SITE_TOPZONE_URL.equals("")) _topzone = true; if (PowerPakConfig.VOTES_SITE_L2NETWORK_URL != null && !PowerPakConfig.VOTES_SITE_L2NETWORK_URL.equals("")) _l2network = true; if (_topzone || _hopzone || _l2network) return SingletonHolder._instance; return null; } @SuppressWarnings("synthetic-access") private static class SingletonHolder { protected static final AutoVoteRewardHandler _instance = new AutoVoteRewardHandler(); } }
×
×
  • 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