Giter Club home page Giter Club logo

itopz-java's Introduction

Project new version 1.5+ is continued here: VDSystem

!THIS IS THE OLD VERSION!

!THIS IS THE OLD VERSION!

!THIS IS THE OLD VERSION!

!THIS IS THE OLD VERSION!

!THIS IS THE OLD VERSION!

VDSystem

Vote System & Donate System for Java based Lineage2 Servers all in one

DenArt Designs Automatic Donation Panels are supported by this system

VDSystem supports 7 Topsites on 58 Projects and 2 Donation Systems

Keep project alive by Donating here: Donate

For anonymous donations

Map

VDSystem

Credits

  • Special thanks to Rationale ๐Ÿ˜ข

Chancelog

  • Version 1.4

    • Update Premium Mobius Projects
      • Update JDK 17
      • Update libraries
      • Removal of 8.0 Homunculus
      • Removal of 9.0 Return of the Queen Ant
      • Removal of 5.0 Sylph
      • Addition of 8.2 Homunculus
      • Addition of 9.2 Return of the Queen Ant
      • Addition of 5.2 Frost Lord
      • Updated Patch diffs
  • Version 1.3

    • Rework on VoteCMD
      • Fixed possible concurrent error on response thread (Ty Rationale)
      • Using StatsSet to transfer data in method isEligible (Ty Rationale)
      • Introducing a Flood Protector (Ty Rationale)
      • Using "NONE" for default errors to avoid NPE
      • Thread Execute will run on random between 1 and 10 seconds to avoid cheats
      • (LUCERA only) added window pop up and command .vote
    • IP Flood Protection
    • Typo in Url
    • Rework Flood Protector & Individual var save method
      • Flood Protector (thanks Rationale)
        • Added FloodProtectorHolder Private class
        • Added Logic VoteSite enum
        • Added FLOOD_PROTECTOR array list
        • NOTE: HWID is not available for all packs since mostly depend on client protection, is up to server admin to add it.
      • saveIndividualVar method
        • Drops player object
        • Recount on statement vars
    • INDIVIDUAL INSERT, SELECT queries drop char_id
    • Create individual table drops char_id and primary keys
    • for existing users must drop the table (it will be automatically created again)
    • Fixing path typo in readme files
    • Update main readme with new projects
    • Add L2JDP by Elesis (Request by CrazyRXD)
    • Lucera remove redudant parenthesis
    • Mobius Premium Sylph Extra wrong library import
    • Fixing 2 errors on out of box settings
      • Default configuration
        • ArrayIndexOutOfBoundsException caused by ; in the end of reward strings
      • Database tables
        • Global table creation fixed caused by an extra , (coma)
      • Thanks LLiuKe for the heads up (y)
    • Fixing IOOBE error
      • IOOBE error fix (thank you Huesitos)
      • Removing totally the player variable from Utilities#selectIndividualVar() method
      • missed on 133a00f
    • SQL Fix
      • Fixing individual Duplicate entry error (Thanks Francisco)
    • Fixing IP restriction after 1 player votes
      • Individual SQL select depends on ip now
      • Adding commend parameters that were missing
      • Capitalize ip to IP parameters
      • Utilities#selectIndividualVar
        • Adding IP string
  • Version 1.2

    • see lucera updates only.
  • Version 1.1

    • Minimal Requirement on server resources and class consistency along projects.
      • Addition of Thread class.
      • Addition of Random class.
      • Addition of Logs class.
      • Addition of Url class.
      • Addition of Rewards class.
      • SQL independence on tables with vds_individual and vds_global tables automatic install by default
    • Addition of topsites and their configs.
      • Hopzone.
      • L2Network.
      • L2TopGameServer.
      • L2TopServers.
      • L2Votes.
      • L2JBrasil.
    • Gui
      • Addition of Debug on/off button.
      • Addition of Bug report button.
      • Removed Debug mode.
      • Rework on the class to update all topsite statistics.
      • Rework on console size and re-arrange information and console.
    • Fixed Bug that made global with individual rewards conflict.
    • Improved custom JSon parser for wannabe-called APIs on a lot of topsites.
    • Improved Debug with External IP Address.
    • Improved code style on some cases like enchanted switch on mobius projects.
  • Version 1.0

    • Initial commit

FAQ

Q: What is VDSystem?

A: (V)ote (D)onation (S)ystem all in one!

Q: Will you install it for me?

A: No.

Q: how hard is to install this?

A: Very easy few clicks and comes with a Patch.diff for each project!

Q: What if I pay you will you help me then?

A: No.

Q: Can I report problems or fixes?

A: Obviously yes in fact it is encouraged!

Q: My server pack is not on the list!

A: I will need the server.jar from your project to release a source for this (nothing private)

Images

  • Version 1.1

https://prnt.sc/w6zkpg https://prnt.sc/w6zl79 https://prnt.sc/w6zp4l https://prnt.sc/w6zqok https://prnt.sc/w6zuyx https://prnt.sc/w6zxyo https://prnt.sc/w6zzcs

  • Version 1.2, 1.3, 1.4

https://prnt.sc/w6zzcs https://prnt.sc/w6zzcs https://prnt.sc/w6zzcs https://prnt.sc/w6zzcs

Wanna help maintain and keep the project alive donate here or Buy Me A Coffee

itopz-java's People

Contributors

nightw0lv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

itopz-java's Issues

Consola iTopz

Hello friend, when I try to open the server it gives me an error when I want to load the console I set the console configuration to false but it keeps giving an error. I understand that it is because I am on linux. Something can be implemented to prevent the graphical interface from firing.

L2jServer JDK8

Hello, how are you?
I'm using a source L2jServer with JDK 8 and i've got this error when i try to compile, i know whats the problem, but cant update my project java to 14 without losing time haha

"class file has wrong version 58.0, should be 52.0"

wich quickfix do you recommend me ?

Vote counting and global vote spawm

I've registred my server only in hopzone yet and using the demo API of itopz i was checking how things are going with the voting system when I vote I can earn my reward with .hopzone but that spam about vote-counting shows wrong votes I have like 10-11 votes but it shows 40-50-60-70 every time when I restart the server different vote numbers) and it doesn't reset.
I'll be so thankful if you could help me!
vote error

this could go longer but I think I have to post my global.java

/*

  • Copyright (c) 2021 iTopZ
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions:
  • The above copyright notice and this permission notice shall be included in all
  • copies or substantial portions of the Software.
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  • SOFTWARE.
    */
    package itopz.com.global;

import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.items.L2Item;
import itopz.com.Configurations;
import itopz.com.gui.Gui;
import itopz.com.model.GlobalResponse;
import itopz.com.util.*;
import itopz.com.vote.VDSystem;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

/**

  • @author Nightwolf

  • iToPz Discord: https://discord.gg/KkPms6B5aE

  • @author Rationale

  • Base structure credits goes on Rationale Discord: Rationale#7773

  • Vote Donation System

  • Script website: https://itopz.com/

  • Script version: 1.2

  • Pack Support: L2JServer

  • Personal Donate Panels: https://www.denart-designs.com/

  • Free Donate panel: https://itopz.com/
    */
    public class Global
    {
    // logger
    private static final Logs _log = new Logs(Global.class.getSimpleName());

    // global server vars
    private static int storedVotes, serverVotes, serverRank, serverNeededVotes, serverNextRank;
    private static int responseCode;

    // ip array list
    private final List FINGERPRINT = new ArrayList<>();

    /**

    • Global reward main function
      */
      public Global()
      {
      // check if allowed the ITOPZ reward to start
      if (Configurations.ITOPZ_GLOBAL_REWARD)
      {
      VDSThreadPool.scheduleAtFixedRate(() -> execute("ITOPZ"), 100, Configurations.ITOPZ_VOTE_CHECK_DELAY * 1000);
      _log.info(Global.class.getSimpleName() + ": ITOPZ reward started.");
      }

      // check if allowed the HOPZONE reward to start
      if (Configurations.HOPZONE_GLOBAL_REWARD)
      {
      VDSThreadPool.scheduleAtFixedRate(() -> execute("HOPZONE"), 100, Configurations.HOPZONE_VOTE_CHECK_DELAY * 1000);
      _log.info(Global.class.getSimpleName() + ": HOPZONE reward started.");
      }

      // check if allowed the L2TOPGAMESERVER reward to start
      if (Configurations.L2TOPGAMESERVER_GLOBAL_REWARD)
      {
      VDSThreadPool.scheduleAtFixedRate(() -> execute("L2TOPGAMESERVER"), 100, Configurations.L2TOPGAMESERVER_VOTE_CHECK_DELAY * 1000);
      _log.info(Global.class.getSimpleName() + ": L2TOPGAMESERVER reward started.");
      }

      // check if allowed the L2JBRASIL reward to start
      if (Configurations.L2JBRASIL_GLOBAL_REWARD)
      {
      VDSThreadPool.scheduleAtFixedRate(() -> execute("L2JBRASIL"), 100, Configurations.L2JBRASIL_VOTE_CHECK_DELAY * 1000);
      _log.info(Global.class.getSimpleName() + ": L2JBRASIL reward started.");
      }

      // check if allowed the L2NETWORK reward to start
      if (Configurations.L2NETWORK_GLOBAL_REWARD)
      {
      VDSThreadPool.scheduleAtFixedRate(() -> execute("L2NETWORK"), 100, Configurations.L2NETWORK_VOTE_CHECK_DELAY * 1000);
      _log.info(Global.class.getSimpleName() + ": L2NETWORK reward started.");
      }

      // check if allowed the L2TOPSERVERS reward to start
      if (Configurations.L2TOPSERVERS_GLOBAL_REWARD)
      {
      VDSThreadPool.scheduleAtFixedRate(() -> execute("L2TOPSERVERS"), 100, Configurations.L2TOPSERVERS_VOTE_CHECK_DELAY * 1000);
      _log.info(Global.class.getSimpleName() + ": L2TOPSERVERS reward started.");
      }

      // check if allowed the L2VOTES reward to start
      if (Configurations.L2VOTES_GLOBAL_REWARD)
      {
      VDSThreadPool.scheduleAtFixedRate(() -> execute("L2VOTES"), 100, Configurations.L2VOTES_VOTE_CHECK_DELAY * 1000);
      _log.info(Global.class.getSimpleName() + ": L2VOTES reward started.");
      }
      }

    /**

    • set server information vars
      */
      public void execute(String TOPSITE)
      {
      // get response from topsite about this ip address
      Optional.ofNullable(GlobalResponse.OPEN(Url.from(TOPSITE + "_GLOBAL_URL").toString()).connect(TOPSITE, VDSystem.VoteType.GLOBAL)).ifPresent(response ->
      {
      // set variables
      responseCode = response.getResponseCode();
      serverNeededVotes = response.getServerNeededVotes();
      serverNextRank = response.getServerNextRank();
      serverRank = response.getServerRank();
      serverVotes = response.getServerVotes();
      });
      // check topsite response
      if (responseCode != 200 || serverVotes == -2)
      {
      // write on console
      Gui.getInstance().ConsoleWrite(TOPSITE + " Not responding maybe its the end of the world.");
      if (Configurations.DEBUG)
      Gui.getInstance().ConsoleWrite(TOPSITE + " RESPONSE:" + responseCode + " VOTES:" + serverVotes);
      return;
      }

      // write console info from response
      switch (TOPSITE)
      {
      case "HOPZONE" ->
      {
      Gui.getInstance().ConsoleWrite(TOPSITE + " Server Votes: " + serverVotes + " votes.");
      Gui.getInstance().UpdateHopzoneStats(serverVotes);
      }
      case "ITOPZ" ->
      {
      Gui.getInstance().ConsoleWrite(TOPSITE + " Server Votes:" + serverVotes + " Rank:" + serverRank + " Next Rank(" + serverNextRank + ") need: " + serverNeededVotes + "votes.");
      Gui.getInstance().UpdateItopzStats(serverVotes, serverRank, serverNextRank, serverNeededVotes);
      }
      case "L2JBRASIL" ->
      {
      Gui.getInstance().ConsoleWrite(TOPSITE + " Server Votes: " + serverVotes + " votes.");
      Gui.getInstance().UpdateBrasilStats(serverVotes);
      }
      case "L2NETWORK" ->
      {
      Gui.getInstance().ConsoleWrite(TOPSITE + " Server Votes: " + serverVotes + " votes.");
      Gui.getInstance().UpdateNetworkStats(serverVotes);
      }
      case "L2TOPGAMESERVER" ->
      {
      Gui.getInstance().ConsoleWrite(TOPSITE + " Server Votes: " + serverVotes + " votes.");
      Gui.getInstance().UpdateTopGameServerStats(serverVotes);
      }
      case "L2TOPSERVERS" ->
      {
      Gui.getInstance().ConsoleWrite(TOPSITE + " Server Votes: " + serverVotes + " votes.");
      Gui.getInstance().UpdateTopServersStats(serverVotes);
      }
      case "L2VOTES" ->
      {
      Gui.getInstance().ConsoleWrite(TOPSITE + " Server Votes: " + serverVotes + " votes.");
      Gui.getInstance().UpdateVotesStats(serverVotes);
      }
      }
      storedVotes = Utilities.selectGlobalVar(TOPSITE, "votes");

      // check if default return value is -1 (failed)
      if (storedVotes == -1)
      {
      // re-set server votes
      Gui.getInstance().ConsoleWrite(TOPSITE + " recover votes.");
      // save votes
      Utilities.saveGlobalVar(TOPSITE, "votes", serverVotes);
      return;
      }

      // check stored votes are lower than server votes
      if (storedVotes < serverVotes)
      {
      // write on console
      Gui.getInstance().ConsoleWrite(TOPSITE + " update database");
      // save votes
      Utilities.saveGlobalVar(TOPSITE, "votes", storedVotes);
      }

      // monthly reset
      if (storedVotes > serverVotes)
      {
      // write on console
      Gui.getInstance().ConsoleWrite(TOPSITE + " monthly reset");
      // save votes
      Utilities.saveGlobalVar(TOPSITE, "votes", serverVotes);
      }

      // announce current votes
      switch (TOPSITE)
      {
      case "HOPZONE" ->
      {
      if (Configurations.HOPZONE_ANNOUNCE_STATISTICS)
      Gui.getInstance().UpdateHopzoneStats(serverVotes);
      // check for vote step reward
      if (serverVotes >= storedVotes + Configurations.HOPZONE_VOTE_STEP)
      {
      // reward all online players
      reward(TOPSITE);
      }
      // announce next reward
      Utilities.announce(TOPSITE, "Next reward at " + (storedVotes + Configurations.HOPZONE_VOTE_STEP) + " votes!");
      }
      case "ITOPZ" ->
      {
      if (Configurations.ITOPZ_ANNOUNCE_STATISTICS)
      Utilities.announce(TOPSITE, "Server Votes:" + serverVotes + " Rank:" + serverRank + " Next Rank(" + serverNextRank + ") need:" + serverNeededVotes + "votes");
      // check for vote step reward
      if (serverVotes >= storedVotes + Configurations.ITOPZ_VOTE_STEP)
      {
      // reward all online players
      reward(TOPSITE);
      }
      // announce next reward
      Utilities.announce(TOPSITE, "Next reward at " + (storedVotes + Configurations.ITOPZ_VOTE_STEP) + " votes!");
      }
      case "L2JBRASIL" ->
      {
      if (Configurations.L2JBRASIL_ANNOUNCE_STATISTICS)
      Gui.getInstance().UpdateBrasilStats(serverVotes);
      // check for vote step reward
      if (serverVotes >= storedVotes + Configurations.L2JBRASIL_VOTE_STEP)
      {
      // reward all online players
      reward(TOPSITE);
      }
      // announce next reward
      Utilities.announce(TOPSITE, "Next reward at " + (storedVotes + Configurations.L2JBRASIL_VOTE_STEP) + " votes!");
      }
      case "L2NETWORK" ->
      {
      if (Configurations.L2NETWORK_ANNOUNCE_STATISTICS)
      Gui.getInstance().UpdateNetworkStats(serverVotes);
      // check for vote step reward
      if (serverVotes >= storedVotes + Configurations.L2NETWORK_VOTE_STEP)
      {
      // reward all online players
      reward(TOPSITE);
      }
      // announce next reward
      Utilities.announce(TOPSITE, "Next reward at " + (storedVotes + Configurations.L2NETWORK_VOTE_STEP) + " votes!");
      }
      case "L2TOPGAMESERVER" ->
      {
      if (Configurations.L2TOPGAMESERVER_ANNOUNCE_STATISTICS)
      Gui.getInstance().UpdateTopGameServerStats(serverVotes);
      // check for vote step reward
      if (serverVotes >= storedVotes + Configurations.L2TOPGAMESERVER_VOTE_STEP)
      {
      // reward all online players
      reward(TOPSITE);
      }
      // announce next reward
      Utilities.announce(TOPSITE, "Next reward at " + (storedVotes + Configurations.L2TOPGAMESERVER_VOTE_STEP) + " votes!");
      }
      case "L2TOPSERVERS" ->
      {
      if (Configurations.L2TOPSERVERS_ANNOUNCE_STATISTICS)
      Gui.getInstance().UpdateTopServersStats(serverVotes);
      // check for vote step reward
      if (serverVotes >= storedVotes + Configurations.L2TOPSERVERS_VOTE_STEP)
      {
      // reward all online players
      reward(TOPSITE);
      }
      // announce next reward
      Utilities.announce(TOPSITE, "Next reward at " + (storedVotes + Configurations.L2TOPSERVERS_VOTE_STEP) + " votes!");
      }
      case "L2VOTES" ->
      {
      if (Configurations.L2VOTES_ANNOUNCE_STATISTICS)
      Gui.getInstance().UpdateVotesStats(serverVotes);
      // check for vote step reward
      if (serverVotes >= storedVotes + Configurations.L2VOTES_VOTE_STEP)
      {
      // reward all online players
      reward(TOPSITE);
      }
      // announce next reward
      Utilities.announce(TOPSITE, "Next reward at " + (storedVotes + Configurations.L2VOTES_VOTE_STEP) + " votes!");
      }
      }
      }

    /**

    • reward players
      */
      private void reward(String TOPSITE)
      {
      // iterate through all players
      for (L2PcInstance player : L2World.getInstance().getPlayers().stream().filter(Objects::nonNull).collect(Collectors.toList()))
      {
      // set player signature key
      String key = "";
      try
      {
      key = Objects.requireNonNull(player.getClient().getConnection().getInetAddress().getHostAddress(), player.getName());
      }
      catch(Exception e)
      {
      e.getMessage();
      continue;
      }

       // if key exists ignore player
       if (FINGERPRINT.contains(key))
       {
       	continue;
       }
       // add the key on ignore list
       FINGERPRINT.add(key);
      
       for (final int itemId : Rewards.from(TOPSITE + "_GLOBAL_REWARDS").keys())
       {
       	// check if the item id exists
       	final L2Item item = ItemTable.getInstance().getTemplate(itemId);
       	if (Objects.nonNull(item))
       	{
       		// get config values
       		final Long[] values = Rewards.from(TOPSITE + "_GLOBAL_REWARDS").get(itemId);
       		// set min count value of received item
       		long min = values[0];
       		// set max count value of received item
       		long max = values[1];
       		// set chances of getting the item
       		long chance = values[2];
       		// set count of each item
       		long count = Random.get(min, max);
       		// chance for each item
       		if (Random.get(100) > chance || chance >= 100)
       		{
       			// reward item
       			player.addItem(TOPSITE, itemId, count, player, true);
       			// write info on console
       			Gui.getInstance().ConsoleWrite(TOPSITE + ": player " + player.getName() + " received x" + count + " " + item.getName());
       		}
       	}
       }
      

      }

      FINGERPRINT.clear();

      // announce the reward
      Utilities.announce(TOPSITE,"Thanks for voting! Players rewarded!");
      // save votes
      Utilities.saveGlobalVar(TOPSITE, "votes", serverVotes);
      // write on console
      Gui.getInstance().ConsoleWrite(TOPSITE + ": Players rewarded!");
      }

    public static Global getInstance()
    {
    return SingletonHolder._instance;
    }

    private static class SingletonHolder
    {
    protected static final Global _instance = new Global();
    }
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.