Minor improvements for VoteReward system.

This commit is contained in:
MobiusDev
2017-04-29 19:26:51 +00:00
parent 62d2757cad
commit 06045a81be
12 changed files with 96 additions and 46 deletions

View File

@@ -11,7 +11,7 @@ NetworkRewardCheckTime = 5
NetworkReward = 3481,5; NetworkReward = 3481,5;
# Network reward max dual boxes reward. # Network reward max dual boxes reward.
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded. # For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
NetworkDuaboxesAllowed = 1 NetworkDualboxesAllowed = 1
# Game server console report. # Game server console report.
# If set to true, game server console will get a report of # If set to true, game server console will get a report of
# current vote count, votes needed for next reward and votes needed for first page. # current vote count, votes needed for next reward and votes needed for first page.
@@ -30,7 +30,7 @@ TopzoneRewardCheckTime = 5
TopzoneReward = 3481,5; TopzoneReward = 3481,5;
# Topzone reward max dual boxes reward. # Topzone reward max dual boxes reward.
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded. # For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
TopzoneDuaboxesAllowed = 1 TopzoneDualboxesAllowed = 1
# Game server console report. # Game server console report.
# If set to true, game server console will get a report of # If set to true, game server console will get a report of
# current vote count, votes needed for next reward and votes needed for first page. # current vote count, votes needed for next reward and votes needed for first page.
@@ -49,7 +49,7 @@ HopzoneRewardCheckTime = 5
HopzoneReward = 3481,5; HopzoneReward = 3481,5;
# Topzone reward max dual boxes reward. # Topzone reward max dual boxes reward.
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded. # For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
HopzoneDuaboxesAllowed = 1 HopzoneDualboxesAllowed = 1
# Game server console report. # Game server console report.
# If set to true, game server console will get a report of # If set to true, game server console will get a report of
# current vote count, votes needed for next reward and votes needed for first page. # current vote count, votes needed for next reward and votes needed for first page.

View File

@@ -352,6 +352,7 @@ public class GameServer
printSection("Event Engine"); printSection("Event Engine");
EventEngineData.getInstance(); EventEngineData.getInstance();
VoteSystem.initialize();
printSection("Siege"); printSection("Siege");
SiegeManager.getInstance().getSieges(); SiegeManager.getInstance().getSieges();
@@ -377,7 +378,6 @@ public class GameServer
} }
MonsterRace.getInstance(); MonsterRace.getInstance();
VoteSystem.initialize();
TaskManager.getInstance(); TaskManager.getInstance();
AntiFeedManager.getInstance().registerEvent(AntiFeedManager.GAME_ID); AntiFeedManager.getInstance().registerEvent(AntiFeedManager.GAME_ID);

View File

@@ -69,7 +69,7 @@ public class Hopzone extends VoteSystem
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Error while getting server vote count from " + getSiteName() + "."); LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
} }
return -1; return -1;

View File

@@ -69,7 +69,7 @@ public class Network extends VoteSystem
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Error while getting server vote count from " + getSiteName() + "."); LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
} }
return -1; return -1;

View File

@@ -66,7 +66,7 @@ public class Topzone extends VoteSystem
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Error while getting server vote count from " + getSiteName() + "."); LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
} }
return -1; return -1;

View File

@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
@@ -35,6 +36,8 @@ import com.l2jmobius.gameserver.util.Broadcast;
*/ */
public abstract class VoteSystem implements Runnable public abstract class VoteSystem implements Runnable
{ {
protected static final Logger LOGGER = Logger.getLogger(VoteSystem.class.getName());
private static List<VoteSystem> voteSystems = new ArrayList<>(); private static List<VoteSystem> voteSystems = new ArrayList<>();
protected int votesDiff; protected int votesDiff;
@@ -47,18 +50,40 @@ public abstract class VoteSystem implements Runnable
public static void initialize() public static void initialize()
{ {
System.out.println("Vote reward system initialized."); if (Config.ALLOW_NETWORK_VOTE_REWARD || Config.ALLOW_TOPZONE_VOTE_REWARD || Config.ALLOW_HOPZONE_VOTE_REWARD)
if (Config.ALLOW_NETWORK_VOTE_REWARD)
{ {
voteSystems.add(new Network(Config.NETWORK_VOTES_DIFFERENCE, Config.ALLOW_NETWORK_GAME_SERVER_REPORT, Config.NETWORK_DUALBOXES_ALLOWED, Config.NETWORK_REWARD, Config.NETWORK_REWARD_CHECK_TIME)); LOGGER.info("VoteSystem: Initialized.");
if (Config.ALLOW_NETWORK_VOTE_REWARD)
{
voteSystems.add(new Network(Config.NETWORK_VOTES_DIFFERENCE, Config.ALLOW_NETWORK_GAME_SERVER_REPORT, Config.NETWORK_DUALBOXES_ALLOWED, Config.NETWORK_REWARD, Config.NETWORK_REWARD_CHECK_TIME));
LOGGER.info("VoteSystem: Network votes enabled.");
}
else
{
LOGGER.info("VoteSystem: Network votes disabled.");
}
if (Config.ALLOW_TOPZONE_VOTE_REWARD)
{
voteSystems.add(new Topzone(Config.TOPZONE_VOTES_DIFFERENCE, Config.ALLOW_TOPZONE_GAME_SERVER_REPORT, Config.TOPZONE_DUALBOXES_ALLOWED, Config.TOPZONE_REWARD, Config.TOPZONE_REWARD_CHECK_TIME));
LOGGER.info("VoteSystem: Topzone votes enabled.");
}
else
{
LOGGER.info("VoteSystem: Topzone votes disabled.");
}
if (Config.ALLOW_HOPZONE_VOTE_REWARD)
{
voteSystems.add(new Hopzone(Config.HOPZONE_VOTES_DIFFERENCE, Config.ALLOW_HOPZONE_GAME_SERVER_REPORT, Config.HOPZONE_DUALBOXES_ALLOWED, Config.HOPZONE_REWARD, Config.HOPZONE_REWARD_CHECK_TIME));
LOGGER.info("VoteSystem: Hopzone votes enabled.");
}
else
{
LOGGER.info("VoteSystem: Hopzone votes disabled.");
}
} }
if (Config.ALLOW_TOPZONE_VOTE_REWARD) else
{ {
voteSystems.add(new Topzone(Config.TOPZONE_VOTES_DIFFERENCE, Config.ALLOW_TOPZONE_GAME_SERVER_REPORT, Config.TOPZONE_DUALBOXES_ALLOWED, Config.TOPZONE_REWARD, Config.TOPZONE_REWARD_CHECK_TIME)); LOGGER.info("VoteSystem: Disabled.");
}
if (Config.ALLOW_HOPZONE_VOTE_REWARD)
{
voteSystems.add(new Hopzone(Config.HOPZONE_VOTES_DIFFERENCE, Config.ALLOW_HOPZONE_GAME_SERVER_REPORT, Config.HOPZONE_DUALBOXES_ALLOWED, Config.HOPZONE_REWARD, Config.HOPZONE_REWARD_CHECK_TIME));
} }
} }
@@ -92,7 +117,7 @@ public abstract class VoteSystem implements Runnable
if (currentVotes == -1) if (currentVotes == -1)
{ {
System.out.println("There was a problem on getting server votes."); LOGGER.info("VoteSystem: There was a problem on getting server votes.");
return; return;
} }
@@ -103,8 +128,8 @@ public abstract class VoteSystem implements Runnable
announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward."); announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward.");
if (allowReport) if (allowReport)
{ {
System.out.println("Server votes on " + getSiteName() + ": " + currentVotes); LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
System.out.println("Votes needed for reward: " + ((lastVotes + votesDiff) - currentVotes)); LOGGER.info("VoteSystem: Votes needed for reward: " + ((lastVotes + votesDiff) - currentVotes));
} }
return; return;
} }
@@ -114,8 +139,8 @@ public abstract class VoteSystem implements Runnable
Collection<L2PcInstance> pls = L2World.getInstance().getPlayers(); Collection<L2PcInstance> pls = L2World.getInstance().getPlayers();
if (allowReport) if (allowReport)
{ {
System.out.println("Server votes on " + getSiteName() + ": " + currentVotes); LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
System.out.println("Votes needed for next reward: " + ((currentVotes + votesDiff) - currentVotes)); LOGGER.info("VoteSystem: Votes needed for next reward: " + ((currentVotes + votesDiff) - currentVotes));
} }
announce(getSiteName() + ": Everyone has been rewarded."); announce(getSiteName() + ": Everyone has been rewarded.");
announce(getSiteName() + ": Current vote count is " + currentVotes + "."); announce(getSiteName() + ": Current vote count is " + currentVotes + ".");
@@ -164,8 +189,8 @@ public abstract class VoteSystem implements Runnable
{ {
if (allowReport) if (allowReport)
{ {
System.out.println("Server votes on " + getSiteName() + ": " + currentVotes); LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
System.out.println("Votes needed for next reward: " + ((lastVotes + votesDiff) - currentVotes)); LOGGER.info("VoteSystem: Votes needed for next reward: " + ((lastVotes + votesDiff) - currentVotes));
} }
announce(getSiteName() + ": Current vote count is " + currentVotes + "."); announce(getSiteName() + ": Current vote count is " + currentVotes + ".");
announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward."); announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward.");

View File

@@ -11,7 +11,7 @@ NetworkRewardCheckTime = 5
NetworkReward = 3481,5; NetworkReward = 3481,5;
# Network reward max dual boxes reward. # Network reward max dual boxes reward.
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded. # For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
NetworkDuaboxesAllowed = 1 NetworkDualboxesAllowed = 1
# Game server console report. # Game server console report.
# If set to true, game server console will get a report of # If set to true, game server console will get a report of
# current vote count, votes needed for next reward and votes needed for first page. # current vote count, votes needed for next reward and votes needed for first page.
@@ -30,7 +30,7 @@ TopzoneRewardCheckTime = 5
TopzoneReward = 3481,5; TopzoneReward = 3481,5;
# Topzone reward max dual boxes reward. # Topzone reward max dual boxes reward.
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded. # For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
TopzoneDuaboxesAllowed = 1 TopzoneDualboxesAllowed = 1
# Game server console report. # Game server console report.
# If set to true, game server console will get a report of # If set to true, game server console will get a report of
# current vote count, votes needed for next reward and votes needed for first page. # current vote count, votes needed for next reward and votes needed for first page.
@@ -49,7 +49,7 @@ HopzoneRewardCheckTime = 5
HopzoneReward = 3481,5; HopzoneReward = 3481,5;
# Topzone reward max dual boxes reward. # Topzone reward max dual boxes reward.
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded. # For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
HopzoneDuaboxesAllowed = 1 HopzoneDualboxesAllowed = 1
# Game server console report. # Game server console report.
# If set to true, game server console will get a report of # If set to true, game server console will get a report of
# current vote count, votes needed for next reward and votes needed for first page. # current vote count, votes needed for next reward and votes needed for first page.

View File

@@ -352,6 +352,7 @@ public class GameServer
printSection("Event Engine"); printSection("Event Engine");
EventEngineData.getInstance(); EventEngineData.getInstance();
VoteSystem.initialize();
printSection("Siege"); printSection("Siege");
SiegeManager.getInstance().getSieges(); SiegeManager.getInstance().getSieges();
@@ -377,7 +378,6 @@ public class GameServer
} }
MonsterRace.getInstance(); MonsterRace.getInstance();
VoteSystem.initialize();
TaskManager.getInstance(); TaskManager.getInstance();
AntiFeedManager.getInstance().registerEvent(AntiFeedManager.GAME_ID); AntiFeedManager.getInstance().registerEvent(AntiFeedManager.GAME_ID);

View File

@@ -69,7 +69,7 @@ public class Hopzone extends VoteSystem
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Error while getting server vote count from " + getSiteName() + "."); LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
} }
return -1; return -1;

View File

@@ -69,7 +69,7 @@ public class Network extends VoteSystem
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Error while getting server vote count from " + getSiteName() + "."); LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
} }
return -1; return -1;

View File

@@ -66,7 +66,7 @@ public class Topzone extends VoteSystem
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
System.out.println("Error while getting server vote count from " + getSiteName() + "."); LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
} }
return -1; return -1;

View File

@@ -21,6 +21,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.ThreadPoolManager; import com.l2jmobius.gameserver.ThreadPoolManager;
@@ -35,6 +36,8 @@ import com.l2jmobius.gameserver.util.Broadcast;
*/ */
public abstract class VoteSystem implements Runnable public abstract class VoteSystem implements Runnable
{ {
protected static final Logger LOGGER = Logger.getLogger(VoteSystem.class.getName());
private static List<VoteSystem> voteSystems = new ArrayList<>(); private static List<VoteSystem> voteSystems = new ArrayList<>();
protected int votesDiff; protected int votesDiff;
@@ -47,18 +50,40 @@ public abstract class VoteSystem implements Runnable
public static void initialize() public static void initialize()
{ {
System.out.println("Vote reward system initialized."); if (Config.ALLOW_NETWORK_VOTE_REWARD || Config.ALLOW_TOPZONE_VOTE_REWARD || Config.ALLOW_HOPZONE_VOTE_REWARD)
if (Config.ALLOW_NETWORK_VOTE_REWARD)
{ {
voteSystems.add(new Network(Config.NETWORK_VOTES_DIFFERENCE, Config.ALLOW_NETWORK_GAME_SERVER_REPORT, Config.NETWORK_DUALBOXES_ALLOWED, Config.NETWORK_REWARD, Config.NETWORK_REWARD_CHECK_TIME)); LOGGER.info("VoteSystem: Initialized.");
if (Config.ALLOW_NETWORK_VOTE_REWARD)
{
voteSystems.add(new Network(Config.NETWORK_VOTES_DIFFERENCE, Config.ALLOW_NETWORK_GAME_SERVER_REPORT, Config.NETWORK_DUALBOXES_ALLOWED, Config.NETWORK_REWARD, Config.NETWORK_REWARD_CHECK_TIME));
LOGGER.info("VoteSystem: Network votes enabled.");
}
else
{
LOGGER.info("VoteSystem: Network votes disabled.");
}
if (Config.ALLOW_TOPZONE_VOTE_REWARD)
{
voteSystems.add(new Topzone(Config.TOPZONE_VOTES_DIFFERENCE, Config.ALLOW_TOPZONE_GAME_SERVER_REPORT, Config.TOPZONE_DUALBOXES_ALLOWED, Config.TOPZONE_REWARD, Config.TOPZONE_REWARD_CHECK_TIME));
LOGGER.info("VoteSystem: Topzone votes enabled.");
}
else
{
LOGGER.info("VoteSystem: Topzone votes disabled.");
}
if (Config.ALLOW_HOPZONE_VOTE_REWARD)
{
voteSystems.add(new Hopzone(Config.HOPZONE_VOTES_DIFFERENCE, Config.ALLOW_HOPZONE_GAME_SERVER_REPORT, Config.HOPZONE_DUALBOXES_ALLOWED, Config.HOPZONE_REWARD, Config.HOPZONE_REWARD_CHECK_TIME));
LOGGER.info("VoteSystem: Hopzone votes enabled.");
}
else
{
LOGGER.info("VoteSystem: Hopzone votes disabled.");
}
} }
if (Config.ALLOW_TOPZONE_VOTE_REWARD) else
{ {
voteSystems.add(new Topzone(Config.TOPZONE_VOTES_DIFFERENCE, Config.ALLOW_TOPZONE_GAME_SERVER_REPORT, Config.TOPZONE_DUALBOXES_ALLOWED, Config.TOPZONE_REWARD, Config.TOPZONE_REWARD_CHECK_TIME)); LOGGER.info("VoteSystem: Disabled.");
}
if (Config.ALLOW_HOPZONE_VOTE_REWARD)
{
voteSystems.add(new Hopzone(Config.HOPZONE_VOTES_DIFFERENCE, Config.ALLOW_HOPZONE_GAME_SERVER_REPORT, Config.HOPZONE_DUALBOXES_ALLOWED, Config.HOPZONE_REWARD, Config.HOPZONE_REWARD_CHECK_TIME));
} }
} }
@@ -92,7 +117,7 @@ public abstract class VoteSystem implements Runnable
if (currentVotes == -1) if (currentVotes == -1)
{ {
System.out.println("There was a problem on getting server votes."); LOGGER.info("VoteSystem: There was a problem on getting server votes.");
return; return;
} }
@@ -103,8 +128,8 @@ public abstract class VoteSystem implements Runnable
announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward."); announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward.");
if (allowReport) if (allowReport)
{ {
System.out.println("Server votes on " + getSiteName() + ": " + currentVotes); LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
System.out.println("Votes needed for reward: " + ((lastVotes + votesDiff) - currentVotes)); LOGGER.info("VoteSystem: Votes needed for reward: " + ((lastVotes + votesDiff) - currentVotes));
} }
return; return;
} }
@@ -114,8 +139,8 @@ public abstract class VoteSystem implements Runnable
Collection<L2PcInstance> pls = L2World.getInstance().getPlayers(); Collection<L2PcInstance> pls = L2World.getInstance().getPlayers();
if (allowReport) if (allowReport)
{ {
System.out.println("Server votes on " + getSiteName() + ": " + currentVotes); LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
System.out.println("Votes needed for next reward: " + ((currentVotes + votesDiff) - currentVotes)); LOGGER.info("VoteSystem: Votes needed for next reward: " + ((currentVotes + votesDiff) - currentVotes));
} }
announce(getSiteName() + ": Everyone has been rewarded."); announce(getSiteName() + ": Everyone has been rewarded.");
announce(getSiteName() + ": Current vote count is " + currentVotes + "."); announce(getSiteName() + ": Current vote count is " + currentVotes + ".");
@@ -164,8 +189,8 @@ public abstract class VoteSystem implements Runnable
{ {
if (allowReport) if (allowReport)
{ {
System.out.println("Server votes on " + getSiteName() + ": " + currentVotes); LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
System.out.println("Votes needed for next reward: " + ((lastVotes + votesDiff) - currentVotes)); LOGGER.info("VoteSystem: Votes needed for next reward: " + ((lastVotes + votesDiff) - currentVotes));
} }
announce(getSiteName() + ": Current vote count is " + currentVotes + "."); announce(getSiteName() + ": Current vote count is " + currentVotes + ".");
announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward."); announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward.");