Add a command to allow support agents to check for ownership of internal sales packages

This commit is contained in:
AlexTheCoder 2016-09-04 22:11:05 -04:00
parent e2d3763ec0
commit 866c3ee7c9
3 changed files with 90 additions and 11 deletions

View File

@ -9,6 +9,18 @@ import java.util.List;
import java.util.Locale;
import java.util.UUID;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
@ -24,17 +36,6 @@ import mineplex.core.donation.repository.token.TransactionToken;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.serverdata.database.ResultSetCallable;
import mineplex.staffServer.salespackage.SalesPackageManager;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class CustomerSupport extends MiniPlugin implements ResultSetCallable
{
@ -89,6 +90,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
public void addCommands()
{
addCommand(new checkCommand(this));
addCommand(new checkOwnsPackageCommand(this));
}
public void Help(Player caller)
@ -309,6 +311,27 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
});
}
public void showPlayerPackageInfo(Player caller, CoreClient client, String salesPackage)
{
CustomerSupport instance = this;
runAsync(new Runnable()
{
public void run()
{
_repository.loadBonusLogForAccountId(client.getAccountId(), instance);
runSync(new Runnable()
{
public void run()
{
caller.sendMessage(C.cBlue + salesPackage + ": " + getLockedFreedomStr(client.getUniqueId(), salesPackage));
_accountBonusLog.remove(client.getAccountId());
}
});
}
});
}
@EventHandler
public void blockBreak(BlockBreakEvent event)
{

View File

@ -0,0 +1,54 @@
package mineplex.staffServer.customerSupport;
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.UtilPlayer;
public class checkOwnsPackageCommand extends CommandBase<CustomerSupport>
{
public checkOwnsPackageCommand(CustomerSupport plugin)
{
super(plugin, Rank.MODERATOR, "checkownspackage");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args == null || args.length < 2)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Usage: /" + _aliasUsed + " <Player> <Package>"));
}
else
{
String playerName = args[0];
String packageName = args[1];
for (int i = 2; i < args.length; i++)
{
packageName += (" " + args[i]);
}
final String salesPackage = packageName;
_commandCenter.GetClientManager().checkPlayerName(caller, playerName, name ->
{
if (name != null)
{
_commandCenter.GetClientManager().loadClientByName(name, client ->
{
if (client != null)
{
Plugin.showPlayerPackageInfo(caller, client, salesPackage);
}
else
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not load data for " + name));
}
});
}
});
}
}
}

View File

@ -7,6 +7,7 @@ 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.UtilPlayer;
import mineplex.staffServer.salespackage.SalesPackageManager;
public class PowerPlayCommand extends CommandBase<SalesPackageManager>
@ -35,6 +36,7 @@ public class PowerPlayCommand extends CommandBase<SalesPackageManager>
if (client != null)
{
Plugin.getPowerPlay().addSubscription(client.getAccountId(), LocalDate.now(), duration.toLowerCase());
UtilPlayer.message(caller, F.main(Plugin.getName(), "Given a Power Play Club 1 " + duration + " subscription to " + playerName + "!"));
}
else
{