hello guys in server i have import the anarchy vote system but in gs i have errors
the syster work normal until cats the first time the limit to give the reward then i have this error in console
and the code is
/*
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
*/
package net.sf.l2j.gameserver.model.entity;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;
import javolution.util.FastMap;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Anarchy
*
*/
public class VoteRewardTopzone
{
// Configurations.
private static String topzoneUrl = Config.TOPZONE_SERVER_LINK;
private static String page1Url = Config.TOPZONE_FIRST_PAGE_LINK;
private static int voteRewardVotesDifference = Config.TOPZONE_VOTES_DIFFERENCE;
private static int firstPageRankNeeded = Config.TOPZONE_FIRST_PAGE_RANK_NEEDED;
private static int checkTime = 60*1000*Config.TOPZONE_REWARD_CHECK_TIME;
// Don't-touch variables.
private static int lastVotes = 0;
private static FastMap<String, Integer> playerIps = new FastMap<String, Integer>();
public static void updateConfigurations()
{
topzoneUrl = Config.TOPZONE_SERVER_LINK;
page1Url = Config.TOPZONE_FIRST_PAGE_LINK;
voteRewardVotesDifference = Config.TOPZONE_VOTES_DIFFERENCE;
firstPageRankNeeded = Config.TOPZONE_FIRST_PAGE_RANK_NEEDED;
checkTime = 60*1000*Config.TOPZONE_REWARD_CHECK_TIME;
}
public static void getInstance()
{
System.out.println("Vote reward system initialized.");
ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
{
@SuppressWarnings("synthetic-access")
public void run()
{
if (Config.ALLOW_TOPZONE_VOTE_REWARD)
{
reward();
}
else
{
return;
}
}
}, checkTime/2, checkTime);
}
private static void reward()
{
int firstPageVotes = getFirstPageRankVotes();
int currentVotes = getVotes();
if (firstPageVotes == -1 || currentVotes == -1)
{
if (firstPageVotes == -1)
{
System.out.println("There was a problem on getting votes from server with rank "+firstPageRankNeeded+".");
}
if (currentVotes == -1)
{
System.out.println("There was a problem on getting server votes.");
}
return;
}
if (lastVotes == 0)
{
lastVotes = currentVotes;
Announcements.getInstance().announceToAll("Topzone: Current vote count is "+currentVotes+" need "+((lastVotes+voteRewardVotesDifference)-currentVotes)+" vote(s) for reward.");
if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
{
System.out.println("Server votes on topzone: "+currentVotes);
System.out.println("Votes needed for reward: "+((lastVotes+voteRewardVotesDifference)-currentVotes));
}
if (firstPageVotes-lastVotes <= 0)
{
if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
{
System.out.println("Server is on the first page of topzone.");
}
}
else
{
if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
{
System.out.println("Server votes needed for first page: "+(firstPageVotes-lastVotes));
}
}
return;
}
if (currentVotes >= lastVotes+voteRewardVotesDifference)
{
Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
if (firstPageVotes-currentVotes <= 0)
{
if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
{
System.out.println("Server votes on topzone: "+currentVotes);
System.out.println("Server is on the first page of topzone.");
System.out.println("Votes needed for next reward: "+((currentVotes+voteRewardVotesDifference)-currentVotes));
}
Announcements.getInstance().announceToAll("Topzone: Everyone has been rewarded with.");
for (L2PcInstance p : pls)
{
boolean canReward = false;
String pIp = p.getClient().getConnection().getInetAddress().getHostAddress();
if (playerIps.containsKey(pIp))
{
int count = playerIps.get(pIp);
if (count < Config.TOPZONE_DUALBOXES_ALLOWED)
{
playerIps.remove(pIp);
playerIps.put(pIp, count+1);
canReward = true;
}
}
else
{
canReward = true;
playerIps.put(pIp, 1);
}
if (canReward)
{
for (int i : Config.TOPZONE_BIG_REWARD.keySet())
{
p.addItem("Vote reward.", i, Config.TOPZONE_BIG_REWARD.get(i), p, true);
}
}
else
{
p.sendMessage("Already "+Config.TOPZONE_DUALBOXES_ALLOWED+" character(s) of your ip have been rewarded, so this character won't be rewarded.");
}
}
playerIps.clear();
}
else
{
if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
{
System.out.println("Server votes on topzone: "+currentVotes);
System.out.println("Server votes needed for first page: "+(firstPageVotes-lastVotes));
System.out.println("Votes needed for next reward: "+((currentVotes+voteRewardVotesDifference)-currentVotes));
}
Announcements.getInstance().announceToAll("Vote reward: Everyone has been rewarded.");
Announcements.getInstance().announceToAll("Topzone: Current vote count is "+currentVotes+" need "+((lastVotes+voteRewardVotesDifference)-currentVotes)+" vote(s) for reward.");
for (L2PcInstance p : pls)
{
boolean canReward = false;
String pIp = p.getClient().getConnection().getInetAddress().getHostAddress();
if (playerIps.containsKey(pIp))
{
int count = playerIps.get(pIp);
if (count < Config.TOPZONE_DUALBOXES_ALLOWED)
{
playerIps.remove(pIp);
playerIps.put(pIp, count+1);
canReward = true;
}
}
else
{
canReward = true;
playerIps.put(pIp, 1);
}
if (canReward)
{
for (int i : Config.TOPZONE_SMALL_REWARD.keySet())
{
p.addItem("Vote reward.", i, Config.TOPZONE_SMALL_REWARD.get(i), p, true);
}
}
else
{
p.sendMessage("Already "+Config.TOPZONE_DUALBOXES_ALLOWED+" character(s) of your ip have been rewarded, so this character won't be rewarded.");
}
}
playerIps.clear();
}
lastVotes = currentVotes;
}
else
{
if (firstPageVotes-currentVotes <= 0)
{
if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
{
System.out.println("Server votes on topzone: "+currentVotes);
System.out.println("Server is on the first page of topzone.");
System.out.println("Votes needed for next reward: "+((lastVotes+voteRewardVotesDifference)-currentVotes));
}
Announcements.getInstance().announceToAll("Topzone: Current vote count is "+currentVotes+" need "+((lastVotes+voteRewardVotesDifference)-currentVotes)+" vote(s) for reward.");
}
else
{
if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
{
System.out.println("Server votes on topzone: "+currentVotes);
System.out.println("Server votes needed for first page: "+(firstPageVotes-lastVotes));
System.out.println("Votes needed for next reward: "+((lastVotes+voteRewardVotesDifference)-currentVotes));
}
Announcements.getInstance().announceToAll("Topzone: Current vote count is "+currentVotes+" need "+((lastVotes+voteRewardVotesDifference)-currentVotes)+" vote(s) for reward.");
}
}
}
private static int getFirstPageRankVotes()
{
InputStreamReader isr = null;
BufferedReader br = null;
try
{
URLConnection con = new URL(page1Url).openConnection();
con.addRequestProperty("User-Agent", "Mozilla/4.76");
isr = new InputStreamReader(con.getInputStream());
br = new BufferedReader(isr);
String line;
int i = 0;
while ((line = br.readLine()) != null)
{
if (line.contains("<td><div align=\"center\">"+firstPageRankNeeded+"</div></td>"))
{
i++;
}
if (line.contains("<td><div align=\"center\">") && i == 1)
{
i++;
}
if (line.contains("<td><div align=\"center\">") && i == 2)
{
i = 0;
int votes = Integer.valueOf(line.split(">")[2].replace("</div", ""));
return votes;
}
}
br.close();
isr.close();
}
catch (Exception e)
{
System.out.println(e);
System.out.println("Error while getting server vote count.");
}
return -1;
}
private static int getVotes()
{
InputStreamReader isr = null;
BufferedReader br = null;
try
{
URLConnection con = new URL(topzoneUrl).openConnection();
con.addRequestProperty("User-Agent", "Mozilla/4.76");
isr = new InputStreamReader(con.getInputStream());
br = new BufferedReader(isr);
boolean got = false;
String line;
while ((line = br.readLine()) != null)
{
if (line.contains("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\"") && !got)
{
got = true;
int votes = Integer.valueOf(line.split("=\"font-size:14px;color:#018BC1;\">")[1].replace("</font></b></div></td></tr>", ""));
return votes;
}
}
br.close();
isr.close();
}
catch (Exception e)
{
System.out.println(e);
System.out.println("Error while getting server vote count.");
}
return -1;
}
}
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Hello. You may encounter the Push item fail error when trying to pick up an item dropped on the ground by a mob.
or
You can throw something out of your inventory and pick it up again, several times.
Probably this is a quantum dependency) I don't understand at what point this happens, sometimes two items one after another experience push item errors, and sometimes I don't have enough thousands of attempts to repeat this trick)
In any case, this is just a visual error and after the relog, the item appears in the inventory. I think first i need to disconnect the extender and check it on a bare server. I still need time to check this, maybe it's not even about the autoloot function.
https://youtu.be/6mcfmdImofE
-----------
In general, I would like to thank our wonderful Emca Eressea for her deep knowledge in programming and reverse engineering. And for the fact that her work is open to everyone, this is very amazing, and incredibly valuable.
Question
Creactive
hello guys in server i have import the anarchy vote system but in gs i have errors
the syster work normal until cats the first time the limit to give the reward then i have this error in console
and the code is
any idea about the error??
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.