Added Kit unlocks to staff server

Added password persistence in db.
This commit is contained in:
Jonathan Williams 2014-11-12 19:20:41 -08:00
parent 2e848c2ac2
commit 0193c397fb
19 changed files with 388 additions and 239 deletions

View File

@ -15,6 +15,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.donation.repository.DonationRepository; import mineplex.core.donation.repository.DonationRepository;
import mineplex.core.donation.repository.token.DonorTokenWrapper; import mineplex.core.donation.repository.token.DonorTokenWrapper;
import mineplex.core.server.remotecall.JsonWebCall;
import mineplex.core.server.util.TransactionResponse; import mineplex.core.server.util.TransactionResponse;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -42,8 +43,8 @@ public class DonationManager extends MiniPlugin
@Override @Override
public void AddCommands() public void AddCommands()
{ {
AddCommand(new GemCommand(this)); addCommand(new GemCommand(this));
AddCommand(new CoinCommand(this)); addCommand(new CoinCommand(this));
} }
@EventHandler @EventHandler
@ -300,4 +301,9 @@ public class DonationManager extends MiniPlugin
//Clean //Clean
_coinQueue.clear(); _coinQueue.clear();
} }
public void applyKits(String playerName)
{
_repository.applyKits(playerName);
}
} }

View File

@ -13,6 +13,7 @@ import mineplex.core.database.column.ColumnVarChar;
import mineplex.core.donation.repository.token.GemRewardToken; import mineplex.core.donation.repository.token.GemRewardToken;
import mineplex.core.donation.repository.token.PurchaseToken; import mineplex.core.donation.repository.token.PurchaseToken;
import mineplex.core.donation.repository.token.UnknownPurchaseToken; import mineplex.core.donation.repository.token.UnknownPurchaseToken;
import mineplex.core.server.remotecall.AsyncJsonWebCall;
import mineplex.core.server.remotecall.JsonWebCall; import mineplex.core.server.remotecall.JsonWebCall;
import mineplex.core.server.util.TransactionResponse; import mineplex.core.server.util.TransactionResponse;
@ -184,4 +185,9 @@ public class DonationRepository extends RepositoryBase
} }
}), "Error updating player's null gems and coins DonationRepository : "); }), "Error updating player's null gems and coins DonationRepository : ");
} }
public void applyKits(String playerName)
{
new AsyncJsonWebCall(_webAddress + "PlayerAccount/ApplyKits").Execute(playerName);
}
} }

View File

@ -56,7 +56,7 @@ public class StaffServer extends JavaPlugin
new FileUpdater(this, portal); new FileUpdater(this, portal);
new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this), new StatsManager(this))); new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this), new StatsManager(this)));
new Password(this); new Password(this, serverStatusManager.getCurrentServerName());
//Updates //Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);

View File

@ -77,12 +77,12 @@ public class CustomerSupport extends MiniPlugin
@Override @Override
public void AddCommands() public void AddCommands()
{ {
AddCommand(new checkCommand(this)); addCommand(new checkCommand(this));
} }
public void Help(Player caller) public void Help(Player caller)
{ {
caller.sendMessage(F.main(GetName(), "Usage : /check defek7")); caller.sendMessage(F.main(getName(), "Usage : /check defek7"));
} }
public void addAgentMapping(Player caller, String playerName) public void addAgentMapping(Player caller, String playerName)

View File

@ -9,30 +9,41 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.recharge.Recharge;
public class Password extends MiniPlugin public class Password extends MiniPlugin
{ {
private PasswordRepository _repository;
private HashSet<Player> _accepted = new HashSet<Player>(); private HashSet<Player> _accepted = new HashSet<Player>();
private String _password = "ClothStarRust"; private String _serverName;
private String _password = null;
public Password(JavaPlugin plugin) public Password(JavaPlugin plugin, String serverName)
{ {
super("Password", plugin); super("Password", plugin);
_serverName = serverName;
_repository = new PasswordRepository(plugin, serverName);
_password = _repository.retrievePassword();
} }
@Override @Override
public void AddCommands() public void AddCommands()
{ {
AddCommand(new PasswordCommand(this)); addCommand(new PasswordCommand(this));
AddCommand(new ChangePasswordCommand(this)); addCommand(new ChangePasswordCommand(this));
addCommand(new RemovePasswordCommand(this));
addCommand(new CreatePasswordCommand(this));
} }
@EventHandler @EventHandler
public void promptForPassword(final PlayerJoinEvent event) public void promptForPassword(final PlayerJoinEvent event)
{ {
event.getPlayer().sendMessage(F.main(GetName(), "Please enter the server password within 10 seconds.")); if (_password == null)
return;
event.getPlayer().sendMessage(F.main(getName(), "Please enter the server password within 10 seconds."));
GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable() GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{ {
@ -46,16 +57,56 @@ public class Password extends MiniPlugin
public void checkPassword(Player caller, String attempt) public void checkPassword(Player caller, String attempt)
{ {
if (_password == null)
return;
if (attempt.equals(_password)) if (attempt.equals(_password))
{ {
_accepted.add(caller); _accepted.add(caller);
caller.sendMessage(F.main(GetName(), "I guess you get to stay.")); caller.sendMessage(F.main(getName(), "That is correct, enjoy your time here...and GET TO WORK ;)"));
} }
} }
public void changePassword(Player caller, String password) public void changePassword(Player caller, String password)
{ {
_password = password; _password = password;
caller.sendMessage(F.main(GetName(), "Password changed to " + _password));
runAsync(new Runnable()
{
public void run()
{
_repository.updatePassword(_password);
}
});
caller.sendMessage(F.main(getName(), "Password changed to " + _password));
}
public void removePassword(Player caller)
{
runAsync(new Runnable()
{
public void run()
{
_password = null;
_repository.removePassword();
}
});
caller.sendMessage(F.main(getName(), "Password removed for " + _serverName));
}
public void createPassword(Player caller, String password)
{
_password = password;
runAsync(new Runnable()
{
public void run()
{
_repository.createPassword(_password);
}
});
caller.sendMessage(F.main(getName(), "Password created : " + _password));
} }
} }

View File

@ -9,7 +9,7 @@ public class PasswordCommand extends CommandBase<Password>
{ {
public PasswordCommand(Password plugin) public PasswordCommand(Password plugin)
{ {
super(plugin, Rank.MODERATOR, "password"); super(plugin, Rank.MODERATOR, "pass", "password");
} }
@Override @Override

View File

@ -12,6 +12,7 @@ import mineplex.core.inventory.InventoryManager;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
import mineplex.staffServer.salespackage.command.DisplayPackageCommand; import mineplex.staffServer.salespackage.command.DisplayPackageCommand;
import mineplex.staffServer.salespackage.command.Sales; import mineplex.staffServer.salespackage.command.Sales;
import mineplex.staffServer.salespackage.salespackages.ApplyKits;
import mineplex.staffServer.salespackage.salespackages.Coins; import mineplex.staffServer.salespackage.salespackages.Coins;
import mineplex.staffServer.salespackage.salespackages.GemHunter; import mineplex.staffServer.salespackage.salespackages.GemHunter;
import mineplex.staffServer.salespackage.salespackages.LifetimeHero; import mineplex.staffServer.salespackage.salespackages.LifetimeHero;
@ -47,6 +48,7 @@ public class SalesPackageManager extends MiniPlugin
AddSalesPackage(new LifetimeHero(this)); AddSalesPackage(new LifetimeHero(this));
AddSalesPackage(new GemHunter(this, 4)); AddSalesPackage(new GemHunter(this, 4));
AddSalesPackage(new GemHunter(this, 8)); AddSalesPackage(new GemHunter(this, 8));
AddSalesPackage(new ApplyKits(this));
} }
private void AddSalesPackage(SalesPackageBase salesPackage) private void AddSalesPackage(SalesPackageBase salesPackage)
@ -57,8 +59,8 @@ public class SalesPackageManager extends MiniPlugin
@Override @Override
public void AddCommands() public void AddCommands()
{ {
AddCommand(new DisplayPackageCommand(this)); addCommand(new DisplayPackageCommand(this));
AddCommand(new Sales(this)); addCommand(new Sales(this));
} }
public DonationManager getDonationManager() public DonationManager getDonationManager()

View File

@ -30,6 +30,6 @@ public class BoosterCommand extends CommandBase<SalesPackageManager>
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Booster " + amount, false, 0, false); Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Booster " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Utility", "Gem Booster", amount); Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Utility", "Gem Booster", amount);
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " boosters to " + playerName + "'s account!")); caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " boosters to " + playerName + "'s account!"));
} }
} }

View File

@ -29,6 +29,6 @@ public class CoinCommand extends CommandBase<SalesPackageManager>
UUID uuid = UUIDFetcher.getUUIDOf(playerName); UUID uuid = UUIDFetcher.getUUIDOf(playerName);
Plugin.getDonationManager().RewardCoins(null, caller.getName(), playerName, uuid, amount); Plugin.getDonationManager().RewardCoins(null, caller.getName(), playerName, uuid, amount);
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " coins to " + playerName + "'s account!")); caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " coins to " + playerName + "'s account!"));
} }
} }

View File

@ -35,6 +35,6 @@ public class GemHunterCommand extends CommandBase<SalesPackageManager>
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Hunter Level " + amount, false, 0, false); Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Hunter Level " + amount, false, 0, false);
Plugin.getStatsManager().incrementStat(uuid.toString(), "Global.GemsEarned", experience); Plugin.getStatsManager().incrementStat(uuid.toString(), "Global.GemsEarned", experience);
caller.sendMessage(F.main(Plugin.GetName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!")); caller.sendMessage(F.main(Plugin.getName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!"));
} }
} }

View File

@ -29,7 +29,7 @@ public class RankCommand extends CommandBase<SalesPackageManager>
if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA) if (rankEnum == Rank.HERO || rankEnum == Rank.ULTRA)
{ {
Plugin.getClientManager().SaveRank(playerName, mineplex.core.common.Rank.valueOf(rank), perm); Plugin.getClientManager().SaveRank(playerName, mineplex.core.common.Rank.valueOf(rank), perm);
caller.sendMessage(F.main(Plugin.GetName(), playerName + "'s rank has been updated to " + rank + "!")); caller.sendMessage(F.main(Plugin.getName(), playerName + "'s rank has been updated to " + rank + "!"));
} }
} }
} }

View File

@ -22,6 +22,7 @@ public class Sales extends MultiCommandBase<SalesPackageManager>
AddCommand(new HeroCommand(plugin)); AddCommand(new HeroCommand(plugin));
AddCommand(new LifetimeUltraCommand(plugin)); AddCommand(new LifetimeUltraCommand(plugin));
AddCommand(new LifetimeHeroCommand(plugin)); AddCommand(new LifetimeHeroCommand(plugin));
AddCommand(new KitsCommand(plugin));
} }
@Override @Override

View File

@ -30,6 +30,6 @@ public class TreasureChestCommand extends CommandBase<SalesPackageManager>
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Chest " + amount, false, 0, false); Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Chest " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Utility", "Treasure Chest", amount); Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Utility", "Treasure Chest", amount);
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " treasure chests to " + playerName + "'s account!")); caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " treasure chests to " + playerName + "'s account!"));
} }
} }

View File

@ -30,6 +30,6 @@ public class TreasureKeyCommand extends CommandBase<SalesPackageManager>
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Key " + amount, false, 0, false); Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Key " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Treasure", "Treasure Key", amount); Plugin.getInventoryManager().addItemToInventoryForOffline(uuid.toString(), "Treasure", "Treasure Key", amount);
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " treasure Keys to " + playerName + "'s account!")); caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " treasure Keys to " + playerName + "'s account!"));
} }
} }

View File

@ -568,6 +568,82 @@
} }
} }
public void ApplyKits(String name)
{
using (var repository = _repositoryFactory.CreateRepository())
{
var account = repository.Where<Account>(x => String.Equals(x.Name, name)).Include(x => x.Rank).FirstOrDefault();
account.LoadNavigationProperties(repository.Context);
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();
}
}
public string UpdateRank(RankUpdateToken token) public string UpdateRank(RankUpdateToken token)
{ {
Rank rank = null; Rank rank = null;

View File

@ -21,6 +21,7 @@
void ApplySalesPackage(SalesPackage salesPackage, int accountId, decimal gross, decimal fee); void ApplySalesPackage(SalesPackage salesPackage, int accountId, decimal gross, decimal fee);
Account Login(LoginRequestToken loginToken); Account Login(LoginRequestToken loginToken);
void Logout(string name); void Logout(string name);
void ApplyKits(string name);
PunishmentResponse Punish(PunishToken punish); PunishmentResponse Punish(PunishToken punish);
PunishmentResponse RemovePunishment(RemovePunishmentToken ban); PunishmentResponse RemovePunishment(RemovePunishmentToken ban);

View File

@ -82,6 +82,12 @@
_accountAdministrator.AddTask(token); _accountAdministrator.AddTask(token);
} }
[HttpPost]
public void ApplyKits(string name)
{
_accountAdministrator.ApplyKits(name);
}
[HttpPost] [HttpPost]
public void Logout(string name) public void Logout(string name)
{ {

File diff suppressed because it is too large Load Diff

Binary file not shown.