Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex

This commit is contained in:
Chiss 2014-12-02 11:50:03 +11:00
commit e63ef8a607
14 changed files with 158 additions and 105 deletions

View File

@ -352,23 +352,26 @@ public class CoreClientManager extends MiniPlugin
}, playerName);
}
public void checkPlayerName(final Player caller, final String playerName, final Callback<Boolean> callback)
public void checkPlayerName(final Player caller, final String playerName, final Callback<String> callback)
{
_repository.matchPlayerName(new Callback<List<String>>()
{
public void run(List<String> matches)
{
boolean matchedExact = false;
String tempName = null;
for (String match : matches)
{
if (match.equalsIgnoreCase(playerName))
{
matchedExact = true;
tempName = match;
break;
}
}
if (matchedExact)
final String matchedName = tempName;
if (matchedName != null)
{
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
{
@ -385,11 +388,11 @@ public class CoreClientManager extends MiniPlugin
{
if (target == null)
{
callback.run(false);
callback.run(matchedName);
return;
}
callback.run(true);
callback.run(matchedName);
}
}, caller, playerName, true);
}

View File

@ -24,13 +24,13 @@ public class AddFriend extends CommandBase<FriendManager>
}
else
{
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<Boolean>()
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
{
public void run(Boolean result)
public void run(String result)
{
if (result)
if (result != null)
{
Plugin.addFriend(caller, args[0]);
Plugin.addFriend(caller, result);
}
}
});

View File

@ -22,13 +22,13 @@ public class DeleteFriend extends CommandBase<FriendManager>
F.main(Plugin.getName(), "You need to include a player's name.");
else
{
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<Boolean>()
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
{
public void run(Boolean result)
public void run(String result)
{
if (result)
if (result != null)
{
Plugin.removeFriend(caller, args[0]);
Plugin.removeFriend(caller, result);
}
}
});

View File

@ -30,11 +30,11 @@ public class SendCommand extends CommandBase<Portal>
final String playerTarget = args[0];
final String serverTarget = args[1];
CommandCenter.GetClientManager().checkPlayerName(player, playerTarget, new Callback<Boolean>()
CommandCenter.GetClientManager().checkPlayerName(player, playerTarget, new Callback<String>()
{
public void run(Boolean playerExists)
public void run(final String playerName)
{
if (!playerExists)
if (playerName == null)
{
UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "Player " + C.cGold + playerTarget + C.cGray + " does not exist!"));
return;
@ -50,9 +50,9 @@ public class SendCommand extends CommandBase<Portal>
return;
}
Portal.transferPlayer(playerTarget, serverTarget);
Portal.transferPlayer(playerName, serverTarget);
UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "You have sent player: " + C.cGold + playerTarget + C.cGray + " to server: " + C.cGold + serverTarget + C.cGray + "!"));
UtilPlayer.message(player, F.main(Plugin.getName(), C.cGray + "You have sent player: " + C.cGold + playerName + C.cGray + " to server: " + C.cGold + serverTarget + C.cGray + "!"));
return;
}
});

View File

@ -237,7 +237,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
}
}, playerUUID.toString(), "Treasure", "Treasure Key", amount);
}
}, name, playerUUID, "Treasure Key" + amount, false, 0, false);
}, name, playerUUID, "Treasure Key " + amount, false, 0, false);
}
else if (args.length == 3 && args[0].equalsIgnoreCase("chest"))
{
@ -261,7 +261,7 @@ public class Enjin extends MiniPlugin implements CommandExecutor
}
}, playerUUID.toString(), "Utility", "Treasure Chest", amount);
}
}, name, playerUUID, "Treasure Chest" + amount, false, 0, false);
}, name, playerUUID, "Treasure Chest " + amount, false, 0, false);
}
else if (args.length == 4 && args[0].equalsIgnoreCase("rank"))
{

View File

@ -1,6 +1,5 @@
package mineplex.staffServer.customerSupport;
import java.text.SimpleDateFormat;
import java.util.HashSet;
import org.bukkit.GameMode;
@ -23,6 +22,7 @@ import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.donation.Donor;
import mineplex.core.donation.repository.token.CoinTransactionToken;
@ -36,7 +36,6 @@ public class CustomerSupport extends MiniPlugin
private SalesPackageManager _salesPackageManager;
private NautHashMap<Player, HashSet<String>> _agentCacheMap = new NautHashMap<Player, HashSet<String>>();
private SimpleDateFormat _date = new SimpleDateFormat("MM/dd/yy HH:mm");
public CustomerSupport(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, SalesPackageManager salesPackageManager)
{
@ -97,6 +96,7 @@ public class CustomerSupport extends MiniPlugin
{
CoreClient client = _clientManager.Get(playerName);
Donor donor = _donationManager.Get(playerName);
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
caller.sendMessage(C.cBlue + "Name : " + C.cYellow + playerName);
caller.sendMessage(C.cBlue + "Rank : " + C.cYellow + (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name));
@ -106,8 +106,8 @@ public class CustomerSupport extends MiniPlugin
int coinTransactionTotal = 0;
int enjinCoinsReceived = 0;
int coinSpentTotal = 0;
int enjinBoostersReceived = 0;
int chestsReceived = 0;
int keysReceived = 0;
for (CoinTransactionToken transaction : donor.getCoinTransactions())
{
@ -124,15 +124,35 @@ public class CustomerSupport extends MiniPlugin
{
coinSpentTotal += transaction.Coins;
if (transaction.SalesPackageName.contains("Gem Booster"))
if (transaction.SalesPackageName.startsWith("Treasure Chest"))
{
if (transaction.SalesPackageName.startsWith("Gem Booster") && transaction.Coins == 0 && transaction.Gems == 0 && transaction.SalesPackageName.split(" ").length == 3)
enjinBoostersReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
chestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
chestsReceived += Integer.parseInt(transaction.SalesPackageName.replace("Treasure Chest", ""));
}
}
else if (transaction.SalesPackageName.startsWith("Treasure Key"))
{
if (transaction.SalesPackageName.split(" ").length == 3)
keysReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
{
String modifiedString = transaction.SalesPackageName.replace("Treasure Key", "");
if (modifiedString.length() > 0)
keysReceived += Integer.parseInt(modifiedString);
}
}
}
caller.sendMessage(C.cBlue + "Enjin Coin Total Received : " + C.cYellow + enjinCoinsReceived);
caller.sendMessage(C.cBlue + "Enjin Booster Total Received : " + C.cYellow + enjinBoostersReceived);
caller.sendMessage(C.cBlue + "Enjin Chest Total Received : " + C.cYellow + chestsReceived);
caller.sendMessage(C.cBlue + "Enjin Key Total Received : " + C.cYellow + keysReceived);
int coinsMissing = coinTransactionTotal - (donor.getCoins() + coinSpentTotal);

View File

@ -22,20 +22,20 @@ public class checkCommand extends CommandBase<CustomerSupport>
}
else
{
final String playerName = args[0];
String playerName = args[0];
CommandCenter.GetClientManager().checkPlayerName(caller, playerName, new Callback<Boolean>()
CommandCenter.GetClientManager().checkPlayerName(caller, playerName, new Callback<String>()
{
public void run(Boolean matched)
public void run(final String name)
{
if (matched)
if (name != null)
{
CommandCenter.GetClientManager().loadClientByName(playerName, new Runnable()
CommandCenter.GetClientManager().loadClientByName(name, new Runnable()
{
public void run()
{
Plugin.addAgentMapping(caller, playerName);
Plugin.showPlayerInfo(caller, playerName);
Plugin.addAgentMapping(caller, name);
Plugin.showPlayerInfo(caller, name);
}
});
}

View File

@ -20,6 +20,8 @@ import mineplex.staffServer.salespackage.salespackages.LifetimeUltra;
import mineplex.staffServer.salespackage.salespackages.MonthlyHero;
import mineplex.staffServer.salespackage.salespackages.MonthlyUltra;
import mineplex.staffServer.salespackage.salespackages.SalesPackageBase;
import mineplex.staffServer.salespackage.salespackages.TreasureChests;
import mineplex.staffServer.salespackage.salespackages.TreasureKeys;
public class SalesPackageManager extends MiniPlugin
{
@ -49,6 +51,8 @@ public class SalesPackageManager extends MiniPlugin
AddSalesPackage(new GemHunter(this, 4));
AddSalesPackage(new GemHunter(this, 8));
AddSalesPackage(new ApplyKits(this));
AddSalesPackage(new TreasureChests(this));
AddSalesPackage(new TreasureKeys(this));
}
private void AddSalesPackage(SalesPackageBase salesPackage)

View File

@ -1,47 +0,0 @@
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.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.staffServer.salespackage.SalesPackageManager;
public class BoosterCommand extends CommandBase<SalesPackageManager>
{
public BoosterCommand(SalesPackageManager plugin)
{
super(plugin, Rank.MODERATOR, "booster");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args == null || args.length != 2)
return;
final String playerName = args[0];
final int amount = Integer.parseInt(args[1]);
UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
if (uuid == null)
UUIDFetcher.getUUIDOf(playerName);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Booster " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
{
public void run(Boolean success)
{
if (success)
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " boosters to " + playerName + "'s account!"));
else
caller.sendMessage(F.main(Plugin.getName(), "There was an error adding " + amount + " boosters to " + playerName + "'s account!"));
}
}, uuid.toString(), "Utility", "Gem Booster", amount);
}
}

View File

@ -14,7 +14,6 @@ public class Sales extends MultiCommandBase<SalesPackageManager>
AddCommand(new RankCommand(plugin));
AddCommand(new CoinCommand(plugin));
AddCommand(new BoosterCommand(plugin));
AddCommand(new TreasureChestCommand(plugin));
AddCommand(new TreasureKeyCommand(plugin));
AddCommand(new GemHunterCommand(plugin));

View File

@ -9,6 +9,8 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.server.util.TransactionResponse;
import mineplex.staffServer.salespackage.SalesPackageManager;
public class TreasureChestCommand extends CommandBase<SalesPackageManager>
@ -25,24 +27,39 @@ public class TreasureChestCommand extends CommandBase<SalesPackageManager>
return;
final String playerName = args[0];
final int amount = Integer.parseInt(args[1]);
int amountSpecified = Integer.parseInt(args[1]);
UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
if (uuid == null)
UUIDFetcher.getUUIDOf(playerName);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Chest " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
if (amountSpecified != 10)
{
public void run(Boolean success)
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have specified an invalid amount of chests."));
amountSpecified = 0;
}
final int amount = amountSpecified;
Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
{
public void run(TransactionResponse data)
{
if (success)
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " treasure chests to " + playerName + "'s account!"));
else
caller.sendMessage(F.main(Plugin.getName(), "There was an error adding " + amount + " treasure chests to " + playerName + "'s account!"));
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
{
public void run(Boolean success)
{
if (success)
F.main(Plugin.getName(), playerName + " received " + amount + " Treasure Chests" + ".");
else
{
F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " Treasure Chests.");
}
}
}, uuid.toString(), "Utility", "Treasure Chest", amount);
}
}, uuid.toString(), "Utility", "Treasure Chest", amount);
}, playerName, uuid, "Treasure Chest " + amount, false, 0, false);
}
}

View File

@ -9,6 +9,8 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.server.util.TransactionResponse;
import mineplex.staffServer.salespackage.SalesPackageManager;
public class TreasureKeyCommand extends CommandBase<SalesPackageManager>
@ -25,23 +27,38 @@ public class TreasureKeyCommand extends CommandBase<SalesPackageManager>
return;
final String playerName = args[0];
final int amount = Integer.parseInt(args[1]);
int amountSpecified = Integer.parseInt(args[1]);
UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
if (uuid == null)
UUIDFetcher.getUUIDOf(playerName);
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Treasure Key " + amount, false, 0, false);
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
if (amountSpecified != 5)
{
public void run(Boolean success)
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have specified an invalid amount of keys."));
amountSpecified = 0;
}
final int amount = amountSpecified;
Plugin.getDonationManager().PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
{
public void run(TransactionResponse data)
{
if (success)
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " treasure Keys to " + playerName + "'s account!"));
else
caller.sendMessage(F.main(Plugin.getName(), "There was an error adding " + amount + " treasure Keys to " + playerName + "'s account!"));
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
{
public void run(Boolean success)
{
if (success)
UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " Treasure Keys" + "."));
else
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " Treasure Keys."));
}
}
}, uuid.toString(), "Treasure", "Treasure Key", amount);
}
}, uuid.toString(), "Treasure", "Treasure Key", amount);
}, playerName, uuid, "Treasure Key " + amount, false, 0, false);
}
}

View File

@ -0,0 +1,20 @@
package mineplex.staffServer.salespackage.salespackages;
import mineplex.staffServer.salespackage.SalesPackageManager;
import org.bukkit.entity.Player;
public class TreasureChests extends SalesPackageBase
{
public TreasureChests(SalesPackageManager manager)
{
super(manager, "10 Treasure Chests");
}
public void displayToAgent(Player agent, String playerName)
{
addButton(agent, "/sales chest " + playerName + " 10", "Give 10 Treasure Chests.");
agent.sendMessage(" ");
addBackButton(agent, playerName);
}
}

View File

@ -0,0 +1,20 @@
package mineplex.staffServer.salespackage.salespackages;
import mineplex.staffServer.salespackage.SalesPackageManager;
import org.bukkit.entity.Player;
public class TreasureKeys extends SalesPackageBase
{
public TreasureKeys(SalesPackageManager manager)
{
super(manager, "5 Treasure Keys");
}
public void displayToAgent(Player agent, String playerName)
{
addButton(agent, "/sales key " + playerName + " 5", "Give 5 Treasure Keys.");
agent.sendMessage(" ");
addBackButton(agent, playerName);
}
}