Fixed global player count.
Fixed tasks.
This commit is contained in:
parent
303cfd02fa
commit
96b1df4ee0
@ -377,10 +377,7 @@
|
|||||||
<zipfileset src="../Libraries/jedis-2.4.2.jar" />
|
<zipfileset src="../Libraries/jedis-2.4.2.jar" />
|
||||||
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
|
||||||
<zipfileset src="../Libraries/commons-dbcp2-2.0.1.jar" />
|
<zipfileset src="../Libraries/commons-dbcp2-2.0.1.jar" />
|
||||||
<zipfileset src="../Libraries/cxf-bundle-2.7.2.jar" />
|
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
|
||||||
<zipfileset src="../Libraries/wss4j-1.6.9.jar" />
|
|
||||||
<zipfileset src="../Libraries/org-apache-commons-lang.jar" />
|
|
||||||
<zipfileset src="../Libraries/cxf-rt-ws-policy-2.7.2.jar" />
|
|
||||||
</jar>
|
</jar>
|
||||||
<copy file="../bin/BungeeRotator.jar" todir="../../Testing/BungeeRotator/"/>
|
<copy file="../bin/BungeeRotator.jar" todir="../../Testing/BungeeRotator/"/>
|
||||||
</target>
|
</target>
|
||||||
|
@ -9,6 +9,7 @@ import mineplex.serverdata.Region;
|
|||||||
import mineplex.serverdata.data.BungeeServer;
|
import mineplex.serverdata.data.BungeeServer;
|
||||||
import mineplex.serverdata.data.DataRepository;
|
import mineplex.serverdata.data.DataRepository;
|
||||||
import mineplex.serverdata.redis.RedisDataRepository;
|
import mineplex.serverdata.redis.RedisDataRepository;
|
||||||
|
import mineplex.serverdata.servers.ConnectionData;
|
||||||
import mineplex.serverdata.servers.ServerManager;
|
import mineplex.serverdata.servers.ServerManager;
|
||||||
import mineplex.serverdata.servers.ServerRepository;
|
import mineplex.serverdata.servers.ServerRepository;
|
||||||
import net.md_5.bungee.api.ServerPing.Players;
|
import net.md_5.bungee.api.ServerPing.Players;
|
||||||
@ -21,6 +22,7 @@ import net.md_5.bungee.event.EventHandler;
|
|||||||
public class PlayerCount implements Listener, Runnable
|
public class PlayerCount implements Listener, Runnable
|
||||||
{
|
{
|
||||||
private DataRepository<BungeeServer> _repository;
|
private DataRepository<BungeeServer> _repository;
|
||||||
|
private DataRepository<BungeeServer> _secondRepository;
|
||||||
private UUID _uuid;
|
private UUID _uuid;
|
||||||
private Region _region;
|
private Region _region;
|
||||||
|
|
||||||
@ -42,11 +44,17 @@ public class PlayerCount implements Listener, Runnable
|
|||||||
|
|
||||||
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||||
|
|
||||||
|
if (_region == Region.US)
|
||||||
|
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.81.1.156", 6379), new ConnectionData("10.81.1.156", 6377),
|
||||||
|
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||||
|
else
|
||||||
|
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.33.53.16", 6379), new ConnectionData("10.33.53.16", 6377),
|
||||||
|
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
|
||||||
BungeeServer snapshot = generateSnapshot();
|
BungeeServer snapshot = generateSnapshot();
|
||||||
_repository.addElement(snapshot, 15); // Update with a 15 second expiry on session
|
_repository.addElement(snapshot, 15); // Update with a 15 second expiry on session
|
||||||
|
|
||||||
@ -64,6 +72,11 @@ public class PlayerCount implements Listener, Runnable
|
|||||||
totalPlayers += server.getPlayerCount();
|
totalPlayers += server.getPlayerCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (BungeeServer server : _secondRepository.getElements())
|
||||||
|
{
|
||||||
|
totalPlayers += server.getPlayerCount();
|
||||||
|
}
|
||||||
|
|
||||||
return totalPlayers;
|
return totalPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -14,14 +13,6 @@ import java.util.logging.Formatter;
|
|||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.apache.commons.lang.RandomStringUtils;
|
|
||||||
|
|
||||||
import biz.neustar.ultra.client.UltraAPIClient;
|
|
||||||
import biz.neustar.ultra.client.UltraAPIClientImpl;
|
|
||||||
import biz.neustar.ultra.client.UltraAPIException;
|
|
||||||
|
|
||||||
import com.neustar.ultraservice.schema.v01.AccountDetailsList;
|
|
||||||
|
|
||||||
import mineplex.bungee.api.ApiDeleteCall;
|
import mineplex.bungee.api.ApiDeleteCall;
|
||||||
import mineplex.bungee.api.ApiGetCall;
|
import mineplex.bungee.api.ApiGetCall;
|
||||||
import mineplex.bungee.api.ApiPostCall;
|
import mineplex.bungee.api.ApiPostCall;
|
||||||
@ -33,11 +24,13 @@ import mineplex.serverdata.Region;
|
|||||||
import mineplex.serverdata.data.BungeeServer;
|
import mineplex.serverdata.data.BungeeServer;
|
||||||
import mineplex.serverdata.data.DataRepository;
|
import mineplex.serverdata.data.DataRepository;
|
||||||
import mineplex.serverdata.redis.RedisDataRepository;
|
import mineplex.serverdata.redis.RedisDataRepository;
|
||||||
|
import mineplex.serverdata.servers.ConnectionData;
|
||||||
import mineplex.serverdata.servers.ServerManager;
|
import mineplex.serverdata.servers.ServerManager;
|
||||||
|
|
||||||
public class BungeeRotator
|
public class BungeeRotator
|
||||||
{
|
{
|
||||||
private static DataRepository<BungeeServer> _repository;
|
private static DataRepository<BungeeServer> _repository;
|
||||||
|
private static DataRepository<BungeeServer> _secondRepository;
|
||||||
private static PlayerStatsRepository _ipRepository;
|
private static PlayerStatsRepository _ipRepository;
|
||||||
//private static ServerRepository _repository = null;
|
//private static ServerRepository _repository = null;
|
||||||
|
|
||||||
@ -76,6 +69,7 @@ public class BungeeRotator
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
String username = "mineplex";
|
String username = "mineplex";
|
||||||
String password = "gjxcVf%nk.";
|
String password = "gjxcVf%nk.";
|
||||||
String accountId = null;
|
String accountId = null;
|
||||||
@ -105,13 +99,16 @@ public class BungeeRotator
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
*/
|
||||||
_debug = new File("debug.dat").exists();
|
_debug = new File("debug.dat").exists();
|
||||||
|
|
||||||
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
_repository = new RedisDataRepository<BungeeServer>(ServerManager.getMasterConnection(), ServerManager.getSlaveConnection(),
|
||||||
Region.ALL, BungeeServer.class, "bungeeServers");
|
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||||
|
|
||||||
_ipRepository = new PlayerStatsRepository();
|
_secondRepository = new RedisDataRepository<BungeeServer>(new ConnectionData("10.81.1.156", 6379), new ConnectionData("10.81.1.156", 6377),
|
||||||
|
Region.ALL, BungeeServer.class, "bungeeServers");
|
||||||
|
|
||||||
|
//_ipRepository = new PlayerStatsRepository();
|
||||||
|
|
||||||
BungeeSorter bungeeSorter = new BungeeSorter();
|
BungeeSorter bungeeSorter = new BungeeSorter();
|
||||||
int maxRecordCount = 10;
|
int maxRecordCount = 10;
|
||||||
@ -121,6 +118,8 @@ public class BungeeRotator
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<BungeeServer> bungeeServers = new ArrayList<BungeeServer>(_repository.getElements());
|
List<BungeeServer> bungeeServers = new ArrayList<BungeeServer>(_repository.getElements());
|
||||||
|
bungeeServers.addAll(_secondRepository.getElements());
|
||||||
|
|
||||||
Collections.sort(bungeeServers, bungeeSorter);
|
Collections.sort(bungeeServers, bungeeSorter);
|
||||||
|
|
||||||
if (_debug)
|
if (_debug)
|
||||||
@ -249,6 +248,7 @@ public class BungeeRotator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
List<IpInfo> updatedAddresses = new ArrayList<IpInfo>(1000);
|
List<IpInfo> updatedAddresses = new ArrayList<IpInfo>(1000);
|
||||||
|
|
||||||
for (IpInfo ipInfo : _ipRepository.getIpAddresses())
|
for (IpInfo ipInfo : _ipRepository.getIpAddresses())
|
||||||
@ -269,7 +269,7 @@ public class BungeeRotator
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ipRepository.updateIps(updatedAddresses);
|
_ipRepository.updateIps(updatedAddresses);
|
||||||
|
*/
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.sleep(15000);
|
Thread.sleep(15000);
|
||||||
@ -279,6 +279,7 @@ public class BungeeRotator
|
|||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -295,7 +296,6 @@ public class BungeeRotator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void log(String message)
|
private static void log(String message)
|
||||||
|
@ -40,7 +40,7 @@ public class ChestConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
_repository = new ChestConverterRepository();
|
_repository = new ChestConverterRepository();
|
||||||
int lastId = 11056929;
|
int lastId = 18279475;
|
||||||
int count = 50000;
|
int count = 50000;
|
||||||
int numOfRowsProcessed = lastId;
|
int numOfRowsProcessed = lastId;
|
||||||
|
|
||||||
|
@ -5,10 +5,10 @@ import java.util.List;
|
|||||||
|
|
||||||
public class TaskClient
|
public class TaskClient
|
||||||
{
|
{
|
||||||
public List<String> TasksCompleted;
|
public List<Integer> TasksCompleted;
|
||||||
|
|
||||||
public TaskClient()
|
public TaskClient()
|
||||||
{
|
{
|
||||||
TasksCompleted = new ArrayList<String>();
|
TasksCompleted = new ArrayList<Integer>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,26 @@ public class TaskManager extends MiniDbClientPlugin<TaskClient>
|
|||||||
|
|
||||||
public boolean hasCompletedTask(Player player, String taskName)
|
public boolean hasCompletedTask(Player player, String taskName)
|
||||||
{
|
{
|
||||||
return Get(player.getName()).TasksCompleted.contains(taskName);
|
synchronized (_taskLock)
|
||||||
|
{
|
||||||
|
if (!_tasks.containsKey(taskName))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Get(player.getName()).TasksCompleted.contains(_tasks.get(taskName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void completedTask(final Callback<Boolean> callback, final Player player, final String taskName)
|
public void completedTask(final Callback<Boolean> callback, final Player player, final String taskName)
|
||||||
{
|
{
|
||||||
Get(player.getName()).TasksCompleted.add(taskName);
|
synchronized (_taskLock)
|
||||||
|
{
|
||||||
|
if (_tasks.containsKey(taskName))
|
||||||
|
{
|
||||||
|
Get(player.getName()).TasksCompleted.add(_tasks.get(taskName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addTaskForOfflinePlayer(new Callback<Boolean>()
|
addTaskForOfflinePlayer(new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
@ -102,9 +116,12 @@ public class TaskManager extends MiniDbClientPlugin<TaskClient>
|
|||||||
{
|
{
|
||||||
System.out.println("Add task FAILED for " + player.getName());
|
System.out.println("Add task FAILED for " + player.getName());
|
||||||
|
|
||||||
if (_tasks.containsKey(taskName))
|
synchronized (_taskLock)
|
||||||
{
|
{
|
||||||
Get(player.getName()).TasksCompleted.remove(taskName);
|
if (_tasks.containsKey(taskName))
|
||||||
|
{
|
||||||
|
Get(player.getName()).TasksCompleted.remove(_tasks.get(taskName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class TaskRepository extends RepositoryBase
|
|||||||
|
|
||||||
while (resultSet.next())
|
while (resultSet.next())
|
||||||
{
|
{
|
||||||
taskClient.TasksCompleted.add(resultSet.getString(1));
|
taskClient.TasksCompleted.add(resultSet.getInt(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return taskClient;
|
return taskClient;
|
||||||
|
@ -71,7 +71,6 @@
|
|||||||
<Compile Include="Model\Server\GameServer\CaptureThePig\Stats\CaptureThePigPlayerStatsToken.cs" />
|
<Compile Include="Model\Server\GameServer\CaptureThePig\Stats\CaptureThePigPlayerStatsToken.cs" />
|
||||||
<Compile Include="Model\Server\GameServer\Dominate\Stats\DominatePlayerStatsToken.cs" />
|
<Compile Include="Model\Server\GameServer\Dominate\Stats\DominatePlayerStatsToken.cs" />
|
||||||
<Compile Include="Model\Server\GameServer\Dominate\Stats\DominateGameStatsToken.cs" />
|
<Compile Include="Model\Server\GameServer\Dominate\Stats\DominateGameStatsToken.cs" />
|
||||||
<Compile Include="Model\Server\GameServer\GameTask.cs" />
|
|
||||||
<Compile Include="Model\Server\GameServer\MineKart\KartArmor.cs" />
|
<Compile Include="Model\Server\GameServer\MineKart\KartArmor.cs" />
|
||||||
<Compile Include="Model\Server\GameServer\MineKart\MineKart.cs" />
|
<Compile Include="Model\Server\GameServer\MineKart\MineKart.cs" />
|
||||||
<Compile Include="Model\Server\GameServer\MineKart\MineKartStats.cs" />
|
<Compile Include="Model\Server\GameServer\MineKart\MineKartStats.cs" />
|
||||||
|
@ -55,8 +55,6 @@
|
|||||||
|
|
||||||
public virtual List<CustomBuild> CustomBuilds { get; set; }
|
public virtual List<CustomBuild> CustomBuilds { get; set; }
|
||||||
|
|
||||||
public virtual List<GameTask> Tasks { get; set; }
|
|
||||||
|
|
||||||
public virtual List<LoginAddress> IpAddresses { get; set; }
|
public virtual List<LoginAddress> IpAddresses { get; set; }
|
||||||
public virtual List<MacAddress> MacAddresses { get; set; }
|
public virtual List<MacAddress> MacAddresses { get; set; }
|
||||||
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
namespace LOC.Core.Model.Server.GameServer
|
|
||||||
{
|
|
||||||
public class GameTask
|
|
||||||
{
|
|
||||||
public int GameTaskId { get; set; }
|
|
||||||
|
|
||||||
public Account.Account Account { get; set; }
|
|
||||||
|
|
||||||
public string TaskName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -52,17 +52,6 @@
|
|||||||
PetNameTagCount = account.PetNameTagCount
|
PetNameTagCount = account.PetNameTagCount
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TasksCompleted = new List<string>();
|
|
||||||
|
|
||||||
if (account.Tasks != null)
|
|
||||||
{
|
|
||||||
foreach (var task in account.Tasks)
|
|
||||||
{
|
|
||||||
TasksCompleted.Add(task.TaskName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (account.Clan != null)
|
if (account.Clan != null)
|
||||||
{
|
{
|
||||||
ClanToken = new ClientClanToken
|
ClanToken = new ClientClanToken
|
||||||
@ -136,8 +125,6 @@
|
|||||||
|
|
||||||
public List<Punishment> Punishments { get; set; }
|
public List<Punishment> Punishments { get; set; }
|
||||||
|
|
||||||
public List<String> TasksCompleted { get; set; }
|
|
||||||
|
|
||||||
public List<FishToken> FishTokens;
|
public List<FishToken> FishTokens;
|
||||||
|
|
||||||
public List<string> IgnoredPlayers { get; set; }
|
public List<string> IgnoredPlayers { get; set; }
|
||||||
|
@ -72,6 +72,7 @@
|
|||||||
return accounts;
|
return accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public List<AccountTask> GetTasksByCount(SearchConf searchConf)
|
public List<AccountTask> GetTasksByCount(SearchConf searchConf)
|
||||||
{
|
{
|
||||||
var tasks = new List<AccountTask>();
|
var tasks = new List<AccountTask>();
|
||||||
@ -100,6 +101,7 @@
|
|||||||
|
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private object getAccountLock(string name)
|
private object getAccountLock(string name)
|
||||||
{
|
{
|
||||||
@ -353,31 +355,6 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTask(UpdateTaskToken token)
|
|
||||||
{
|
|
||||||
using (var repository = _repositoryFactory.CreateRepository())
|
|
||||||
{
|
|
||||||
var account = repository.Where<Account>(x => x.Name == token.Name).OrderByDescending(x => x.LastLogin).Include(x => x.Tasks).FirstOrDefault();
|
|
||||||
|
|
||||||
if (account != null)
|
|
||||||
{
|
|
||||||
if (account.Tasks == null)
|
|
||||||
account.Tasks = new List<GameTask>();
|
|
||||||
|
|
||||||
var task = new GameTask
|
|
||||||
{
|
|
||||||
Account = account,
|
|
||||||
TaskName = token.NewTaskCompleted,
|
|
||||||
};
|
|
||||||
|
|
||||||
account.Tasks.Add(task);
|
|
||||||
|
|
||||||
repository.Edit(account);
|
|
||||||
repository.CommitChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PunishmentResponse Punish(PunishToken punish)
|
public PunishmentResponse Punish(PunishToken punish)
|
||||||
{
|
{
|
||||||
using (var repository = _repositoryFactory.CreateRepository())
|
using (var repository = _repositoryFactory.CreateRepository())
|
||||||
|
@ -35,14 +35,11 @@
|
|||||||
string PurchaseUnknownSalesPackage(UnknownPurchaseToken token);
|
string PurchaseUnknownSalesPackage(UnknownPurchaseToken token);
|
||||||
string UpdateRank(RankUpdateToken token);
|
string UpdateRank(RankUpdateToken token);
|
||||||
void RemoveBan(RemovePunishmentToken token);
|
void RemoveBan(RemovePunishmentToken token);
|
||||||
void AddTask(UpdateTaskToken token);
|
|
||||||
|
|
||||||
void UpdateAccountUUIDs(List<AccountNameToken> tokens);
|
void UpdateAccountUUIDs(List<AccountNameToken> tokens);
|
||||||
|
|
||||||
bool CoinReward(GemRewardToken token);
|
bool CoinReward(GemRewardToken token);
|
||||||
|
|
||||||
ClientToken GetAccountByUUID(string uuid);
|
ClientToken GetAccountByUUID(string uuid);
|
||||||
|
|
||||||
List<AccountTask> GetTasksByCount(SearchConf searchConf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
return Content(json, "application/json");
|
return Content(json, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult GetTasksByCount(SearchConf searchConf)
|
public ActionResult GetTasksByCount(SearchConf searchConf)
|
||||||
{
|
{
|
||||||
@ -48,6 +49,7 @@
|
|||||||
var json = JsonConvert.SerializeObject(tasks);
|
var json = JsonConvert.SerializeObject(tasks);
|
||||||
return Content(json, "application/json");
|
return Content(json, "application/json");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public ActionResult GetAccountByUUID(string uuid)
|
public ActionResult GetAccountByUUID(string uuid)
|
||||||
@ -86,12 +88,6 @@
|
|||||||
return Content(json, "application/json");
|
return Content(json, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public void AddTask(UpdateTaskToken token)
|
|
||||||
{
|
|
||||||
_accountAdministrator.AddTask(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void ApplyKits(string name)
|
public void ApplyKits(string name)
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in New Issue
Block a user