Added in mysql hooks for coins/gems/ranks for database conversion preperation.

Added in failover database calls in CoreClient/DonationManager
This commit is contained in:
Jonathan Williams 2014-10-11 01:32:22 -07:00
parent bf11635616
commit 19afebe53d
35 changed files with 774 additions and 428 deletions

View File

@ -1,5 +1,7 @@
package mineplex.core.account;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@ -13,7 +15,6 @@ import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.account.event.ClientWebResponseEvent;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.account.repository.AccountRepository;
import mineplex.core.account.repository.MysqlAccountRepository;
import mineplex.core.account.repository.token.ClientToken;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
@ -42,7 +43,6 @@ public class CoreClientManager extends MiniPlugin
{
private JavaPlugin _plugin;
private AccountRepository _repository;
private MysqlAccountRepository _mysqlRepository;
private NautHashMap<String, CoreClient> _clientList;
private HashSet<String> _duplicateLoginGlitchPreventionList;
@ -53,8 +53,7 @@ public class CoreClientManager extends MiniPlugin
super("Client Manager", plugin);
_plugin = plugin;
_repository = new AccountRepository(webServer);
_mysqlRepository = new MysqlAccountRepository(plugin);
_repository = new AccountRepository(plugin, webServer);
_clientList = new NautHashMap<String, CoreClient>();
_duplicateLoginGlitchPreventionList = new HashSet<String>();
}
@ -175,7 +174,7 @@ public class CoreClientManager extends MiniPlugin
{
public void run()
{
_mysqlRepository.login(uuid.toString(), client.GetPlayerName());
_repository.login(uuid.toString(), client.GetPlayerName());
Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent);
clientInformationEvent.decreaseProcessingCount();
@ -225,7 +224,7 @@ public class CoreClientManager extends MiniPlugin
{
public void run()
{
_mysqlRepository.login(uuid.toString(), client.GetPlayerName());
_repository.login(uuid.toString(), client.GetPlayerName());
Bukkit.getServer().getPluginManager().callEvent(clientInformationEvent);
}
@ -237,6 +236,8 @@ public class CoreClientManager extends MiniPlugin
client.SetAccountId(token.AccountId);
client.SetRank(Rank.valueOf(token.Rank));
_repository.updateMysqlRank(token.Name, token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response));
@ -322,7 +323,7 @@ public class CoreClientManager extends MiniPlugin
public void SaveRank(final String name, Rank rank, boolean perm)
{
_repository.SaveRank(new Callback<Rank>()
_repository.saveRank(new Callback<Rank>()
{
public void run(Rank newRank)
{

View File

@ -86,7 +86,7 @@ public class UpdateRank extends CommandBase<CoreClientManager>
return;
}
Plugin.getRepository().SaveRank(new Callback<Rank>()
Plugin.getRepository().saveRank(new Callback<Rank>()
{
public void run(Rank rank)
{

View File

@ -1,26 +1,58 @@
package mineplex.core.account.repository;
import java.sql.Timestamp;
import java.util.List;
import java.util.UUID;
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.repository.token.LoginToken;
import mineplex.core.account.repository.token.RankUpdateToken;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.server.remotecall.AsyncJsonWebCall;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.database.DatabaseRunnable;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.column.ColumnBoolean;
import mineplex.core.database.column.ColumnTimestamp;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.core.server.remotecall.JsonWebCall;
public class AccountRepository
public class AccountRepository extends RepositoryBase
{
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));";
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);";
private static String ACCOUNT_LOGIN_UPDATE = "UPDATE accounts SET uuid=?, name=?, lastLogin=now() WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_RANK = "UPDATE accounts SET rank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_RANK_DONOR = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=false, rankExpire=now() + INTERVAL 1 MONTH WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_RANK_PERM = "UPDATE accounts SET rank=?, rankPerm=true WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_RANK_DONOR_PERM = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=true WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_NULL_RANK = "UPDATE accounts SET rank=?, donorRank=?, rankPerm=?, rankExpire=? WHERE uuid = ? AND rank IS NULL;";
private String _webAddress;
public AccountRepository(String webAddress)
public AccountRepository(JavaPlugin plugin, String webAddress)
{
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
_webAddress = webAddress;
}
@Override
protected void initialize()
{
executeUpdate(CREATE_ACCOUNT_TABLE);
}
public void login(String uuid, String name)
{
int affectedRows = executeUpdate(ACCOUNT_LOGIN_UPDATE, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid));
if (affectedRows == 0)
executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name));
}
public String GetClient(String name, UUID uuid, String ipAddress)
{
LoginToken token = new LoginToken();
@ -36,14 +68,44 @@ public class AccountRepository
return new JsonWebCall(_webAddress + "PlayerAccount/GetAccountByUUID").ExecuteReturnStream(uuid.toString());
}
public void SaveRank(Callback<Rank> callback, String name, Rank rank, boolean perm)
public void saveRank(final Callback<Rank> callback, final String name, Rank rank, final boolean perm)
{
RankUpdateToken token = new RankUpdateToken();
final RankUpdateToken token = new RankUpdateToken();
token.Name = name;
token.Rank = rank.toString();
token.Perm = perm;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/RankUpdate").Execute(Rank.class, callback, token);
final Callback<Rank> extraCallback = new Callback<Rank>()
{
public void run(Rank response)
{
if (response == Rank.ULTRA || response == Rank.HERO)
{
if (perm)
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR_PERM, new ColumnVarChar("rank", 100, response.toString()), new ColumnVarChar("donorRank", 100, response.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
else
executeUpdate(UPDATE_ACCOUNT_RANK_DONOR, new ColumnVarChar("rank", 100, response.toString()), new ColumnVarChar("donorRank", 100, response.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
}
else
{
if (perm)
executeUpdate(UPDATE_ACCOUNT_RANK_PERM, new ColumnVarChar("rank", 100, response.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
else
executeUpdate(UPDATE_ACCOUNT_RANK, new ColumnVarChar("rank", 100, response.toString()), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
}
callback.run(response);
}
};
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
public void run()
{
new JsonWebCall(_webAddress + "PlayerAccount/RankUpdate").Execute(Rank.class, extraCallback, token);
}
}), "Error saving player " + token.Name + "'s rank in AccountRepository : ");
}
public void MatchPlayerName(final Callback<List<String>> callback, final String userName)
@ -59,4 +121,20 @@ public class AccountRepository
asyncThread.start();
}
@Override
protected void update()
{
}
public void updateMysqlRank(final String uuid, final String rank, final boolean perm, final String rankExpire)
{
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
public void run()
{
executeUpdate(UPDATE_ACCOUNT_NULL_RANK, new ColumnVarChar("rank", 100, rank), new ColumnVarChar("donorRank", 100, rank), new ColumnBoolean("rankPerm", perm), new ColumnTimestamp("rankExpire", Timestamp.valueOf(rankExpire)), new ColumnVarChar("uuid", 100, uuid));
}
}), "Error updating player's mysql rank AccountRepository : ");
}
}

View File

@ -1,35 +0,0 @@
package mineplex.core.account.repository;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.column.ColumnVarChar;
public class MysqlAccountRepository extends RepositoryBase
{
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accounts (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(100), name VARCHAR(40), gems INT, rank VARCHAR(40), rankPerm BOOL, rankExpire LONG, lastLogin LONG, totalPlayTime LONG, PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuid), UNIQUE INDEX nameIndex (name), INDEX rankIndex (rank));";
private static String ACCOUNT_LOGIN_NEW = "INSERT INTO accounts (uuid, name, lastLogin) values(?, ?, now()) ON DUPLICATE KEY UPDATE name=VALUES(name), lastLogin=VALUES(lastLogin);";
private static String ACCOUNT_LOGIN_UPDATE = "UPDATE accounts SET uuid=?, name=?, lastLogin=now() WHERE uuid = ?;";
public MysqlAccountRepository(JavaPlugin plugin)
{
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
}
@Override
protected void initialize()
{
executeUpdate(CREATE_ACCOUNT_TABLE);
}
@Override
protected void update() { }
public void login(String uuid, String name)
{
int affectedRows = executeUpdate(ACCOUNT_LOGIN_UPDATE, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid));
if (affectedRows == 0)
executeUpdate(ACCOUNT_LOGIN_NEW, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("name", 40, name));
}
}

View File

@ -5,6 +5,8 @@ public class ClientToken
public int AccountId;
public String Name;
public String Rank;
public boolean RankPerm;
public String RankExpire;
public int EconomyBalance;
public AccountToken AccountToken;

View File

@ -0,0 +1,27 @@
package mineplex.core.database;
public class DatabaseRunnable
{
private Runnable _runnable;
private int _failedAttempts = 0;
public DatabaseRunnable(Runnable runnable)
{
_runnable = runnable;
}
public void run()
{
_runnable.run();
}
public void incrementFailCount()
{
_failedAttempts++;
}
public int getFailedCounts()
{
return _failedAttempts;
}
}

View File

@ -5,24 +5,39 @@ import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.database.column.Column;
import mineplex.core.logger.Logger;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class RepositoryBase
public abstract class RepositoryBase implements Listener
{
protected static Object _connectionLock = new Object();
private Connection _connection = null;
private static Object _queueLock = new Object();
private NautHashMap<DatabaseRunnable, String> _failedQueue = new NautHashMap<DatabaseRunnable, String>();
private String _connectionString;
private String _userName;
private String _password;
protected JavaPlugin Plugin;
public RepositoryBase(JavaPlugin plugin, String connectionString, String username, String password)
{
Plugin = plugin;
_connectionString = connectionString;
_userName = username;
_password = password;
@ -38,6 +53,8 @@ public abstract class RepositoryBase
}
}
});
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
protected abstract void initialize();
@ -189,4 +206,81 @@ public abstract class RepositoryBase
return affectedRows;
}
protected void handleDatabaseCall(final DatabaseRunnable databaseRunnable, final String errorMessage)
{
Thread asyncThread = new Thread(new Runnable()
{
public void run()
{
try
{
databaseRunnable.run();
}
catch (Exception exception)
{
Logger.Instance.log(errorMessage + exception.getMessage());
databaseRunnable.incrementFailCount();
synchronized (_queueLock)
{
_failedQueue.put(databaseRunnable, errorMessage);
}
}
}
});
asyncThread.start();
}
@EventHandler
public void processDatabaseQueue(UpdateEvent event)
{
if (event.getType() != UpdateType.MIN_01)
return;
processFailedQueue();
}
private void processFailedQueue()
{
synchronized (_queueLock)
{
for (Iterator<DatabaseRunnable> runnablesIterator = _failedQueue.keySet().iterator(); runnablesIterator.hasNext();)
{
final DatabaseRunnable databaseRunnable = runnablesIterator.next();
Thread asyncThread = new Thread(new Runnable()
{
public void run()
{
try
{
databaseRunnable.run();
}
catch (Exception exception)
{
Logger.Instance.log(_failedQueue.get(databaseRunnable) + exception.getMessage());
if (databaseRunnable.getFailedCounts() < 4)
{
synchronized (_queueLock)
{
_failedQueue.put(databaseRunnable, _failedQueue.get(databaseRunnable));
}
}
else
{
Logger.Instance.log("Abandoning database call : " + _failedQueue.get(databaseRunnable));
}
}
}
});
runnablesIterator.remove();
asyncThread.start();
}
}
}
}

View File

@ -0,0 +1,42 @@
package mineplex.core.database.column;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class ColumnBoolean extends Column<Boolean>
{
public ColumnBoolean(String name)
{
super(name);
}
public ColumnBoolean(String name, boolean value)
{
super(name, value);
}
@Override
public String getCreateString()
{
return Name + " BOOLEAN";
}
@Override
public Boolean getValue(ResultSet resultSet) throws SQLException
{
return resultSet.getBoolean(Name);
}
@Override
public void setValue(PreparedStatement preparedStatement, int columnNumber) throws SQLException
{
preparedStatement.setBoolean(columnNumber, Value);
}
@Override
public ColumnBoolean clone()
{
return new ColumnBoolean(Name, Value);
}
}

View File

@ -0,0 +1,43 @@
package mineplex.core.database.column;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
public class ColumnTimestamp extends Column<Timestamp>
{
public ColumnTimestamp(String name)
{
super(name);
}
public ColumnTimestamp(String name, Timestamp value)
{
super(name, value);
}
@Override
public String getCreateString()
{
return Name + " TIMESTAMP";
}
@Override
public Timestamp getValue(ResultSet resultSet) throws SQLException
{
return resultSet.getTimestamp(Name);
}
@Override
public void setValue(PreparedStatement preparedStatement, int columnNumber) throws SQLException
{
preparedStatement.setTimestamp(columnNumber, Value);
}
@Override
public ColumnTimestamp clone()
{
return new ColumnTimestamp(Name, Value);
}
}

View File

@ -1,5 +1,7 @@
package mineplex.core.donation;
import java.util.UUID;
import mineplex.core.MiniPlugin;
import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.account.event.ClientWebResponseEvent;
@ -13,6 +15,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
@ -24,13 +27,13 @@ public class DonationManager extends MiniPlugin
private Object _donorLock = new Object();
private NautHashMap<String, NautHashMap<String, Integer>> _gemQueue = new NautHashMap<String, NautHashMap<String, Integer>>();
private NautHashMap<Player, NautHashMap<String, Integer>> _gemQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
public DonationManager(JavaPlugin plugin, String webAddress)
{
super("Donation", plugin);
_repository = new DonationRepository(webAddress);
_repository = new DonationRepository(plugin, webAddress);
_donors = new NautHashMap<String, Donor>();
}
@ -62,6 +65,7 @@ public class DonationManager extends MiniPlugin
synchronized (_donorLock)
{
_donors.put(token.Name, new Donor(token.DonorToken));
_repository.updateGemsAndCoins(token.Name, Get(token.Name).GetGems(), Get(token.Name).getCoins());
}
}
@ -73,7 +77,7 @@ public class DonationManager extends MiniPlugin
}
}
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final String packageName, final boolean coinPurchase, final int cost, boolean oneTimePurchase)
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final UUID uuid, final String packageName, final boolean coinPurchase, final int cost, boolean oneTimePurchase)
{
Donor donor = Get(name);
@ -106,10 +110,10 @@ public class DonationManager extends MiniPlugin
if (callback != null)
callback.run(response);
}
}, name, packageName, coinPurchase, cost);
}, name, uuid.toString(), packageName, coinPurchase, cost);
}
public void PurchaseKnownSalesPackage(final Callback<TransactionResponse> callback, final String name, final int salesPackageId)
public void PurchaseKnownSalesPackage(final Callback<TransactionResponse> callback, final String name, final UUID uuid, final int cost, final int salesPackageId)
{
_repository.PurchaseKnownSalesPackage(new Callback<TransactionResponse>()
{
@ -128,17 +132,17 @@ public class DonationManager extends MiniPlugin
if (callback != null)
callback.run(response);
}
}, name, salesPackageId);
}, name, uuid.toString(), cost, salesPackageId);
}
public void RewardGems(final Callback<Boolean> callback, final String caller, final String name, final int amount)
public void RewardGems(Callback<Boolean> callback, String caller, String name, UUID uuid, int amount)
{
RewardGems(callback, caller, name, amount, true);
RewardGems(callback, caller, name, uuid, amount, true);
}
public void RewardGems(final Callback<Boolean> callback, final String caller, final String name, final int amount, final boolean updateTotal)
public void RewardGems(final Callback<Boolean> callback, final String caller, final String name, final UUID uuid, final int amount, final boolean updateTotal)
{
_repository.PlayerUpdate(new Callback<Boolean>()
_repository.gemReward(new Callback<Boolean>()
{
public void run(Boolean success)
{
@ -158,23 +162,23 @@ public class DonationManager extends MiniPlugin
callback.run(true);
}
}
}, caller, name, amount);
}, caller, name, uuid.toString(), amount);
}
public void RewardGemsLater(final String caller, final String name, final int amount)
public void RewardGemsLater(final String caller, final Player player, final int amount)
{
if (!_gemQueue.containsKey(name))
_gemQueue.put(name, new NautHashMap<String, Integer>());
if (!_gemQueue.containsKey(player))
_gemQueue.put(player, new NautHashMap<String, Integer>());
int totalAmount = amount;
if (_gemQueue.get(name).containsKey(caller))
totalAmount += _gemQueue.get(name).get(caller);
if (_gemQueue.get(player).containsKey(caller))
totalAmount += _gemQueue.get(player).get(caller);
_gemQueue.get(name).put(caller, totalAmount);
_gemQueue.get(player).put(caller, totalAmount);
//Do Temp Change
Donor donor = Get(name);
Donor donor = Get(player.getName());
if (donor != null)
donor.AddGems(amount);
@ -186,39 +190,39 @@ public class DonationManager extends MiniPlugin
if (event.getType() != UpdateType.SLOWER)
return;
for (String name : _gemQueue.keySet())
for (Player player : _gemQueue.keySet())
{
String caller = null;
int total = 0;
for (String curCaller : _gemQueue.get(name).keySet())
for (String curCaller : _gemQueue.get(player).keySet())
{
caller = curCaller;
total += _gemQueue.get(name).get(curCaller);
total += _gemQueue.get(player).get(curCaller);
}
if (caller == null)
continue;
//Actually Add Gems
RewardGems(null, caller, name, total, false);
RewardGems(null, caller, player.getName(), player.getUniqueId(), total, false);
System.out.println("Queue Added [" + name + "] with Gems [" + total + "] for [" + caller + "]");
System.out.println("Queue Added [" + player + "] with Gems [" + total + "] for [" + caller + "]");
//Clean
_gemQueue.get(name).clear();
_gemQueue.get(player).clear();
}
//Clean
_gemQueue.clear();
}
public void RewardCoins(final Callback<Boolean> callback, final String caller, final String name, final int amount)
public void RewardCoins(Callback<Boolean> callback, String caller, String name, UUID uuid, int amount)
{
RewardCoins(callback, caller, name, amount, true);
RewardCoins(callback, caller, name, uuid, amount, true);
}
public void RewardCoins(final Callback<Boolean> callback, final String caller, final String name, final int amount, final boolean updateTotal)
public void RewardCoins(final Callback<Boolean> callback, final String caller, final String name, final UUID uuid, final int amount, final boolean updateTotal)
{
_repository.rewardCoins(new Callback<Boolean>()
{
@ -240,6 +244,6 @@ public class DonationManager extends MiniPlugin
callback.run(true);
}
}
}, caller, name, amount);
}, caller, name, uuid.toString(), amount);
}
}

View File

@ -41,7 +41,7 @@ public class GemCommand extends CommandBase<DonationManager>
UtilPlayer.message(caller, F.main("Gem", "You gave " + F.elem(gems + " Gems") + " to " + F.name(target.getName()) + "."));
UtilPlayer.message(target, F.main("Gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " Gems") + "."));
}
}, caller.getName(), target.getName(), gems);
}, caller.getName(), target.getName(), target.getUniqueId(), gems);
}
catch (Exception e)
{

View File

@ -1,58 +1,185 @@
package mineplex.core.donation.repository;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.database.DatabaseRunnable;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.column.ColumnInt;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.core.donation.repository.token.GemRewardToken;
import mineplex.core.donation.repository.token.PurchaseToken;
import mineplex.core.donation.repository.token.UnknownPurchaseToken;
import mineplex.core.server.remotecall.AsyncJsonWebCall;
import mineplex.core.server.remotecall.JsonWebCall;
import mineplex.core.server.util.TransactionResponse;
public class DonationRepository
public class DonationRepository extends RepositoryBase
{
private static String CREATE_COIN_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountCoinTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), coins INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX coinUuidIndex (accounts_uuid));";
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX gemUuidIndex (accounts_uuid));";
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accounts_uuid, reason, coins) VALUES(?, ?, ?);";
private static String INSERT_GEM_TRANSACTION = "INSERT INTO accountGemTransactions(accounts_uuid, reason, gems) VALUES(?, ?, ?);";
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE uuid = ?;";
private static String UPDATE_ACCOUNT_GEMS = "UPDATE accounts SET gems = gems + ? WHERE uuid = ?;";
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE uuid = ? AND gems IS NULL AND coins IS NULL;";
private String _webAddress;
public DonationRepository(String webAddress)
public DonationRepository(JavaPlugin plugin, String webAddress)
{
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
_webAddress = webAddress;
}
public void PurchaseKnownSalesPackage(Callback<TransactionResponse> callback, String name, int salesPackageId)
public void PurchaseKnownSalesPackage(final Callback<TransactionResponse> callback, String name, final String uuid, final int cost, final int salesPackageId)
{
PurchaseToken token = new PurchaseToken();
final PurchaseToken token = new PurchaseToken();
token.AccountName = name;
token.UsingCredits = false;
token.SalesPackageId = salesPackageId;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/PurchaseKnownSalesPackage").Execute(TransactionResponse.class, callback, token);
final Callback<TransactionResponse> extraCallback = new Callback<TransactionResponse>()
{
public void run(TransactionResponse response)
{
if (response == TransactionResponse.Success)
executeUpdate(UPDATE_ACCOUNT_GEMS, new ColumnInt("gems", cost), new ColumnVarChar("uuid", 100, uuid));
callback.run(response);
}
};
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
public void run()
{
new JsonWebCall(_webAddress + "PlayerAccount/PurchaseKnownSalesPackage").Execute(TransactionResponse.class, extraCallback, token);
}
}), "Error purchasing known sales package in DonationRepository : ");
}
public void PurchaseUnknownSalesPackage(Callback<TransactionResponse> callback, String name, String packageName, boolean coinPurchase, int cost)
public void PurchaseUnknownSalesPackage(final Callback<TransactionResponse> callback, final String name, final String uuid, final String packageName, final boolean coinPurchase, final int cost)
{
UnknownPurchaseToken token = new UnknownPurchaseToken();
final UnknownPurchaseToken token = new UnknownPurchaseToken();
token.AccountName = name;
token.SalesPackageName = packageName;
token.CoinPurchase = coinPurchase;
token.Cost = cost;
token.Premium = false;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/PurchaseUnknownSalesPackage").Execute(TransactionResponse.class, callback, token);
final Callback<TransactionResponse> extraCallback = new Callback<TransactionResponse>()
{
public void run(TransactionResponse response)
{
if (response == TransactionResponse.Success)
{
if (coinPurchase)
{
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", -cost), new ColumnVarChar("uuid", 100, uuid));
executeUpdate(INSERT_COIN_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("coins", -cost));
}
else
{
executeUpdate(UPDATE_ACCOUNT_GEMS, new ColumnInt("gems", -cost), new ColumnVarChar("uuid", 100, uuid));
executeUpdate(INSERT_GEM_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Purchased " + packageName), new ColumnInt("gems", -cost));
}
}
callback.run(response);
}
};
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
public void run()
{
new JsonWebCall(_webAddress + "PlayerAccount/PurchaseUnknownSalesPackage").Execute(TransactionResponse.class, extraCallback, token);
}
}), "Error purchasing unknown sales package in DonationRepository : ");
}
public void PlayerUpdate(Callback<Boolean> callback, String giver, String name, int greenGems)
public void gemReward(final Callback<Boolean> callback, final String giver, String name, final String uuid, final int greenGems)
{
GemRewardToken token = new GemRewardToken();
final GemRewardToken token = new GemRewardToken();
token.Source = giver;
token.Name = name;
token.Amount = greenGems;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/GemReward").Execute(Boolean.class, callback, token);
final Callback<Boolean> extraCallback = new Callback<Boolean>()
{
public void run(Boolean response)
{
if (response)
{
executeUpdate(UPDATE_ACCOUNT_GEMS, new ColumnInt("gems", greenGems), new ColumnVarChar("uuid", 100, uuid));
executeUpdate(INSERT_GEM_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Given by " + giver), new ColumnInt("gems", greenGems));
}
callback.run(response);
}
};
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
public void run()
{
new JsonWebCall(_webAddress + "PlayerAccount/GemReward").Execute(Boolean.class, extraCallback, token);
}
}), "Error updating player gem amount in DonationRepository : ");
}
public void rewardCoins(Callback<Boolean> callback, String giver, String name, int coins)
public void rewardCoins(final Callback<Boolean> callback, final String giver, String name, final String uuid, final int coins)
{
GemRewardToken token = new GemRewardToken();
final GemRewardToken token = new GemRewardToken();
token.Source = giver;
token.Name = name;
token.Amount = coins;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/CoinReward").Execute(Boolean.class, callback, token);
final Callback<Boolean> extraCallback = new Callback<Boolean>()
{
public void run(Boolean response)
{
if (response)
{
executeUpdate(UPDATE_ACCOUNT_COINS, new ColumnInt("coins", coins), new ColumnVarChar("uuid", 100, uuid));
executeUpdate(INSERT_COIN_TRANSACTION, new ColumnVarChar("uuid", 100, uuid), new ColumnVarChar("reason", 100, "Rewarded by " + giver), new ColumnInt("coins", coins));
}
callback.run(response);
}
};
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
public void run()
{
new JsonWebCall(_webAddress + "PlayerAccount/CoinReward").Execute(Boolean.class, extraCallback, token);
}
}), "Error updating player coin amount in DonationRepository : ");
}
@Override
protected void initialize()
{
executeUpdate(CREATE_COIN_TRANSACTION_TABLE);
executeUpdate(CREATE_GEM_TRANSACTION_TABLE);
}
@Override
protected void update()
{
}
public void updateGemsAndCoins(final String name, final int gems, final int coins)
{
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
public void run()
{
executeUpdate(UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_, new ColumnInt("gems", gems), new ColumnInt("coins", coins), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
}
}), "Error updating player's null gems and coins DonationRepository : ");
}
}

View File

@ -108,7 +108,7 @@ public class ItemCoinBomb extends ItemGadget
event.setCancelled(true);
event.getItem().remove();
Manager.getDonationManager().RewardCoins(null, this.GetName() + " Pickup", event.getPlayer().getName(), 4);
Manager.getDonationManager().RewardCoins(null, this.GetName() + " Pickup", event.getPlayer().getName(), event.getPlayer().getUniqueId(), 4);
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);

View File

@ -108,7 +108,7 @@ public class ItemGemBomb extends ItemGadget
event.setCancelled(true);
event.getItem().remove();
Manager.getDonationManager().RewardGems(null, this.GetName() + " Pickup", event.getPlayer().getName(), 4);
Manager.getDonationManager().RewardGems(null, this.GetName() + " Pickup", event.getPlayer().getName(), event.getPlayer().getUniqueId(), 4);
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.ORB_PICKUP, 1f, 2f);

View File

@ -52,6 +52,8 @@ public class Logger
public void log(final String message)
{
System.out.println(message);
Bukkit.getServer().getScheduler().runTaskAsynchronously(_plugin, new Runnable()
{
public void run()

View File

@ -53,7 +53,7 @@ public class CoinReward extends Reward
{
}
}, "Treasure Chest", player.getName(), gemsToReward);
}, "Treasure Chest", player.getName(), player.getUniqueId(), gemsToReward);
return new RewardData(getRarity().getColor() + gemsToReward + " Coins", new ItemStack(175));
}

View File

@ -31,7 +31,7 @@ public class UnknownPackageReward extends Reward
@Override
protected RewardData giveRewardCustom(Player player)
{
_donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _packageName, true, 0, true);
_donationManager.PurchaseUnknownSalesPackage(null, player.getName(), player.getUniqueId(), _packageName, true, 0, true);
return new RewardData(getRarity().getColor() + _name, _itemStack);
}

View File

@ -146,7 +146,7 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
{
ShowResultsPage(response);
}
}, Player.getName(), _salesItem.GetSalesPackageId());
}, Player.getName(), Player.getUniqueId(), _salesItem.GetCost(SelectedCurrency), _salesItem.GetSalesPackageId());
}
else
{
@ -156,7 +156,7 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
{
ShowResultsPage(response);
}
}, Player.getName(), _salesItem.GetName(), SelectedCurrency == CurrencyType.Coins, _salesItem.GetCost(SelectedCurrency), _salesItem.OneTimePurchase());
}, Player.getName(), Player.getUniqueId(), _salesItem.GetName(), SelectedCurrency == CurrencyType.Coins, _salesItem.GetCost(SelectedCurrency), _salesItem.OneTimePurchase());
}
_taskId = Plugin.GetScheduler().scheduleSyncRepeatingTask(Plugin.GetPlugin(), this, 2L, 2L);

View File

@ -14,6 +14,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.punish.Category;
@ -72,7 +73,8 @@ public class Enjin extends MiniPlugin implements CommandExecutor
String name = args[1];
int amount = Integer.parseInt(args[2]);
_donationManager.RewardGems(null, "purchase", name, amount);
;
_donationManager.RewardGems(null, "purchase", name, UUIDFetcher.getUUIDOf(name), amount);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " gems.");
}
else if (args.length == 3 && args[0].equalsIgnoreCase("coin"))
@ -80,7 +82,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
String name = args[1];
int amount = Integer.parseInt(args[2]);
_donationManager.RewardCoins(null, "purchase", name, amount);
_donationManager.RewardCoins(null, "purchase", name, UUIDFetcher.getUUIDOf(name), amount);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " coins.");
}
else if (args.length == 3 && args[0].equalsIgnoreCase("booster"))
@ -88,7 +90,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
String name = args[1];
int amount = Integer.parseInt(args[2]);
_donationManager.PurchaseUnknownSalesPackage(null, name, "Gem Booster " + amount, false, 0, false);
_donationManager.PurchaseUnknownSalesPackage(null, name, UUIDFetcher.getUUIDOf(name), "Gem Booster " + amount, false, 0, false);
_repository.addGemBooster(name, amount);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Gem Boosters" + ".");
}
@ -112,7 +114,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
packageName += " " + args[i];
}
_donationManager.PurchaseUnknownSalesPackage(null, name, packageName, false, 0, false);
_donationManager.PurchaseUnknownSalesPackage(null, name, UUIDFetcher.getUUIDOf(name), packageName, false, 0, false);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + packageName + ".");
}
else if (args.length >= 3 && args[0].equalsIgnoreCase("unban"))

View File

@ -389,7 +389,7 @@ public class ParkourManager extends MiniPlugin
//Sound
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
}
}, "Parkour " + data.Name, player.getName(), data.Gems);
}, "Parkour " + data.Name, player.getName(), player.getUniqueId(), data.Gems);
}
}
}

View File

@ -191,7 +191,7 @@ public class PollManager extends MiniClientPlugin<PlayerPollData>
}
});
}
}, "Poll", name, poll.getCoinReward());
}, "Poll", name, uuid, poll.getCoinReward());
}
}
});

View File

@ -263,12 +263,12 @@ public class ServerNpcPage extends ShopPageBase<ServerManager, ServerNpcShop> im
private boolean isStarting(ServerInfo serverInfo)
{
return (serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Cup"));
return (serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Open"));
}
private boolean isInProgress(ServerInfo serverInfo)
{
return serverInfo.MOTD.contains("In") || serverInfo.MOTD.contains("Restarting");
return serverInfo.MOTD.contains("Progress") || serverInfo.MOTD.contains("Restarting");
}
private boolean hasEnoughSlots(ServerInfo serverInfo, int slotsNeeded)

View File

@ -138,7 +138,7 @@ public class TutorialManager extends MiniPlugin
//Sound
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1.5f);
}
}, "Tutorial " + tut.GetTutName(), player.getName(), tut.GetGems());
}, "Tutorial " + tut.GetTutName(), player.getName(), player.getUniqueId(), tut.GetGems());
}
}
}

View File

@ -1,5 +1,7 @@
package mineplex.staffServer.salespackage.command;
import java.util.UUID;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
@ -24,8 +26,10 @@ public class BoosterCommand extends CommandBase<SalesPackageManager>
String playerName = args[0];
int amount = Integer.parseInt(args[1]);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Gem Booster " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(UUIDFetcher.getUUIDOf(playerName).toString(), "Utility", "Gem Booster", amount);
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Booster " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Utility", "Gem Booster", amount);
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " boosters to " + playerName + "'s account!"));
}
}

View File

@ -1,10 +1,13 @@
package mineplex.staffServer.salespackage.command;
import java.util.UUID;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.staffServer.salespackage.SalesPackageManager;
public class CoinCommand extends CommandBase<SalesPackageManager>
@ -23,7 +26,9 @@ public class CoinCommand extends CommandBase<SalesPackageManager>
String playerName = args[0];
int amount = Integer.parseInt(args[1]);
Plugin.getDonationManager().RewardCoins(null, caller.getName(), playerName, amount);
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
Plugin.getDonationManager().RewardCoins(null, caller.getName(), playerName, uuid, amount);
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " coins to " + playerName + "'s account!"));
}
}

View File

@ -1,5 +1,7 @@
package mineplex.staffServer.salespackage.command;
import java.util.UUID;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
@ -24,8 +26,10 @@ public class GemHunterCommand extends CommandBase<SalesPackageManager>
String playerName = args[0];
int amount = Integer.parseInt(args[1]);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Gem Hunter Level " + amount, false, 0, false);
Plugin.getStatsManager().incrementStat(UUIDFetcher.getUUIDOf(playerName).toString(), "Global.GemsEarned", 5000 + (amount * 5000));
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Hunter Level " + amount, false, 0, false);
Plugin.getStatsManager().incrementStat(uuid.toString(), "Global.GemsEarned", 5000 + (amount * 5000));
caller.sendMessage(F.main(Plugin.GetName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!"));
}
}

View File

@ -1,5 +1,7 @@
package mineplex.staffServer.salespackage.command;
import java.util.UUID;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
@ -24,8 +26,10 @@ public class TreasureChestCommand extends CommandBase<SalesPackageManager>
String playerName = args[0];
int amount = Integer.parseInt(args[1]);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Treasure Chest " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(UUIDFetcher.getUUIDOf(playerName).toString(), "Utility", "Treasure Chest", amount);
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Chest " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Utility", "Treasure Chest", amount);
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " treasure chests to " + playerName + "'s account!"));
}
}

View File

@ -1,5 +1,7 @@
package mineplex.staffServer.salespackage.command;
import java.util.UUID;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
@ -24,8 +26,10 @@ public class TreasureKeyCommand extends CommandBase<SalesPackageManager>
String playerName = args[0];
int amount = Integer.parseInt(args[1]);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Treasure Key " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(UUIDFetcher.getUUIDOf(playerName).toString(), "Treasure", "Treasure Key", amount);
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Key " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Treasure", "Treasure Key", amount);
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " treasure Keys to " + playerName + "'s account!"));
}
}

View File

@ -335,7 +335,7 @@ public class Christmas extends SoloGame
{
for (Player player : GetPlayers(false))
{
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), "Snowmans Head", false, 0, true);
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), player.getUniqueId(), "Snowmans Head", false, 0, true);
Manager.GetGame().AddGems(player, 30, "Slaying the Pumpkin King", false);
Manager.GetGame().AddGems(player, 10, "Participation", false);
}

View File

@ -316,7 +316,7 @@ public class Halloween extends SoloGame
{
for (Player player : GetPlayers(false))
{
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), "Pumpkin Kings Head", false, 0, true);
Manager.GetDonation().PurchaseUnknownSalesPackage(null, player.getName(), player.getUniqueId(), "Pumpkin Kings Head", false, 0, true);
Manager.GetGame().AddGems(player, 30, "Killing the Pumpkin King", false);
Manager.GetGame().AddGems(player, 10, "Participation", false);
}

View File

@ -113,7 +113,7 @@ public class GameAchievementManager implements Listener
{
Manager.GetTaskManager().completedTask(player, type.getName());
}
}, type.getName(), player.getName(), type.getGemReward());
}, type.getName(), player.getName(), player.getUniqueId(), type.getGemReward());
}
else
{

View File

@ -174,7 +174,7 @@ public class GameGemManager implements Listener
if (DoubleGem)
total += earned;
Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), total);
Manager.GetDonation().RewardGems(null, "Earned " + game.GetName(), player.getName(), player.getUniqueId(), total);
//Stats
Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", total);

View File

@ -20,6 +20,9 @@
Name = account.Name;
Uuid = account.Uuid;
Rank = account.Rank.Name;
RankPerm = account.RankPerm;
RankExpire = account.RankExpire.ToShortDateString();
Time = (long)TimeUtil.GetCurrentMilliseconds();
EconomyBalance = account.EconomyBalance;
@ -123,6 +126,10 @@
public string Rank { get; set; }
public bool RankPerm { get; set; }
public string RankExpire { get; set; }
public long Time { get; set; }
public int EconomyBalance { get; set; }

View File

@ -566,75 +566,6 @@
account.RankPerm = token.Perm;
repository.Edit(account);
if ((rank.Name == "HERO" || rank.Name == "ULTRA") && token.Perm)
{
addAccountTransaction(repository, account, "Bacon Brawl Bebe Piggles", 0, 0);
addAccountTransaction(repository, account, "Bacon Brawl `Pig`", 0, 0);
addAccountTransaction(repository, account, "A Barbarians Life Barbarian Archer", 0, 0);
addAccountTransaction(repository, account, "A Barbarians Life Bomber", 0, 0);
addAccountTransaction(repository, account, "The Bridges Archer", 0, 0);
addAccountTransaction(repository, account, "The Bridges Bomber", 0, 0);
addAccountTransaction(repository, account, "The Bridges Brawler", 0, 0);
addAccountTransaction(repository, account, "The Bridges Miner", 0, 0);
addAccountTransaction(repository, account, "Castle Siege Castle Assassin", 0, 0);
addAccountTransaction(repository, account, "Castle Siege Castle Brawler", 0, 0);
addAccountTransaction(repository, account, "Castle Siege Castle Knight", 0, 0);
addAccountTransaction(repository, account, "Castle Siege Undead Archer", 0, 0);
addAccountTransaction(repository, account, "Castle Siege Undead Zombie", 0, 0);
addAccountTransaction(repository, account, "Death Tag Runner Archer", 0, 0);
addAccountTransaction(repository, account, "Death Tag Runner Traitor", 0, 0);
addAccountTransaction(repository, account, "Dragon Escape Disruptor", 0, 0);
addAccountTransaction(repository, account, "Dragon Escape Warper", 0, 0);
addAccountTransaction(repository, account, "Dragons Marksman", 0, 0);
addAccountTransaction(repository, account, "Dragons Pyrotechnic", 0, 0);
addAccountTransaction(repository, account, "Block Hunt Instant Hider", 0, 0);
addAccountTransaction(repository, account, "Block Hunt Shocking Hider", 0, 0);
addAccountTransaction(repository, account, "Block Hunt Radar Hunter", 0, 0);
addAccountTransaction(repository, account, "Block Hunt TNT Hunter", 0, 0);
addAccountTransaction(repository, account, "Super Paintball Machine Gun", 0, 0);
addAccountTransaction(repository, account, "Super Paintball Shotgun", 0, 0);
addAccountTransaction(repository, account, "One in the Quiver Brawler", 0, 0);
addAccountTransaction(repository, account, "One in the Quiver Enchanter", 0, 0);
addAccountTransaction(repository, account, "Runner Archer", 0, 0);
addAccountTransaction(repository, account, "Runner Frosty", 0, 0);
addAccountTransaction(repository, account, "Sheep Quest Archer", 0, 0);
addAccountTransaction(repository, account, "Sheep Quest Brute", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Blaze", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Chicken", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Mad Cow", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Creeper", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Enderman", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Undead Knight", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Magma Cube", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Pig", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Skeletal Horse", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Sky Squid", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Snowman", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Witch", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Wither", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Wither Skeleton", 0, 0);
addAccountTransaction(repository, account, "Super Smash Mobs Wolf", 0, 0);
addAccountTransaction(repository, account, "Snake Super Snake", 0, 0);
addAccountTransaction(repository, account, "Snake Other Snake", 0, 0);
addAccountTransaction(repository, account, "Sneaky Assassins Ranged Assassin", 0, 0);
addAccountTransaction(repository, account, "Sneaky Assassins Revealer", 0, 0);
addAccountTransaction(repository, account, "Super Spleef Archer", 0, 0);
addAccountTransaction(repository, account, "Super Spleef Brawler", 0, 0);
addAccountTransaction(repository, account, "Squid Shooter Squid Blaster", 0, 0);
addAccountTransaction(repository, account, "Squid Shooter Squid Sniper", 0, 0);
addAccountTransaction(repository, account, "Survival Games Archer", 0, 0);
addAccountTransaction(repository, account, "Survival Games Assassin", 0, 0);
addAccountTransaction(repository, account, "Survival Games Beastmaster", 0, 0);
addAccountTransaction(repository, account, "Survival Games Bomber", 0, 0);
addAccountTransaction(repository, account, "Survival Games Brawler", 0, 0);
addAccountTransaction(repository, account, "Survival Games Necromancer", 0, 0);
addAccountTransaction(repository, account, "Turf Wars Infiltrator", 0, 0);
addAccountTransaction(repository, account, "Turf Wars Shredder", 0, 0);
addAccountTransaction(repository, account, "Zombie Survival Survivor Archer", 0, 0);
addAccountTransaction(repository, account, "Zombie Survival Survivor Rogue", 0, 0);
}
repository.CommitChanges();
_logger.Log("INFO", "TOKEN " + token.Name + "'s rank has been updated to " + token.Rank + " " + (token.Perm ? "Permanently" : "Monthly") + "." + " Rank expire : " + account.RankExpire.ToString());

File diff suppressed because it is too large Load Diff