nightw0lv / itopz-java Goto Github PK
View Code? Open in Web Editor NEWiTopZ VDSystem Vote & Donate reward systems
Home Page: https://itopz.com
License: GNU General Public License v3.0
iTopZ VDSystem Vote & Donate reward systems
Home Page: https://itopz.com
License: GNU General Public License v3.0
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!
this could go longer but I think I have to post my global.java
/*
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();
}
}
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.
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 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.