Bring back /sales :(
This commit is contained in:
parent
c5106f8042
commit
b5aca834fa
@ -0,0 +1,89 @@
|
||||
package mineplex.staffServer.salespackage;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.permissions.Permission;
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.pet.repository.PetRepository;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.staffServer.salespackage.command.DisplayPackageCommand;
|
||||
import mineplex.staffServer.salespackage.command.Sales;
|
||||
|
||||
public class SalesPackageManager extends MiniPlugin
|
||||
{
|
||||
public enum Perm implements Permission
|
||||
{
|
||||
SALES_COMMAND,
|
||||
DISPLAY_PACKAGE_COMMAND,
|
||||
}
|
||||
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
private StatsManager _statsManager;
|
||||
private PowerPlayClubRepository _powerPlayRepo;
|
||||
private PetRepository _petRepo;
|
||||
|
||||
public SalesPackageManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, StatsManager statsManager, PowerPlayClubRepository powerPlayRepo)
|
||||
{
|
||||
super("SalesPackageManager", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
_donationManager = donationManager;
|
||||
_inventoryManager = inventoryManager;
|
||||
_statsManager = statsManager;
|
||||
_powerPlayRepo = powerPlayRepo;
|
||||
|
||||
_petRepo = new PetRepository();
|
||||
|
||||
generatePermissions();
|
||||
}
|
||||
|
||||
private void generatePermissions()
|
||||
{
|
||||
PermissionGroup.SUPPORT.setPermission(Perm.SALES_COMMAND, true, true);
|
||||
PermissionGroup.SUPPORT.setPermission(Perm.DISPLAY_PACKAGE_COMMAND, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new DisplayPackageCommand(this));
|
||||
addCommand(new Sales(this));
|
||||
}
|
||||
|
||||
public DonationManager getDonationManager()
|
||||
{
|
||||
return _donationManager;
|
||||
}
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
{
|
||||
return _clientManager;
|
||||
}
|
||||
|
||||
public InventoryManager getInventoryManager()
|
||||
{
|
||||
return _inventoryManager;
|
||||
}
|
||||
|
||||
public PowerPlayClubRepository getPowerPlay()
|
||||
{
|
||||
return _powerPlayRepo;
|
||||
}
|
||||
|
||||
public PetRepository getPetRepo()
|
||||
{
|
||||
return _petRepo;
|
||||
}
|
||||
|
||||
public StatsManager getStatsManager()
|
||||
{
|
||||
return _statsManager;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class CoinCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public CoinCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "coin", "shard", "shards");
|
||||
}
|
||||
|
||||
@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]);
|
||||
|
||||
Plugin.getClientManager().getOrLoadClient(playerName, client ->
|
||||
{
|
||||
if (client != null)
|
||||
{
|
||||
Plugin.getDonationManager().rewardCurrency(GlobalCurrency.TREASURE_SHARD, client, caller.getName(), amount, completed ->
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Added " + amount + " shards to " + playerName + "'s account!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "There was an error giving " + F.elem(amount + "Shards") + " to " + F.name(playerName) + "."));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!"));
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class DisplayPackageCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public DisplayPackageCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.DISPLAY_PACKAGE_COMMAND, "display");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length < 2)
|
||||
return;
|
||||
|
||||
String playerName = args[0];
|
||||
String packageName = args[1];
|
||||
|
||||
if (args.length > 2)
|
||||
{
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
packageName += " " + args[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (packageName.equalsIgnoreCase("ALL"))
|
||||
Plugin.displaySalesPackages(caller, playerName);
|
||||
else
|
||||
Plugin.displayPackage(caller, playerName, packageName);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class GemHunterCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public GemHunterCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "gemhunter");
|
||||
}
|
||||
|
||||
@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]);
|
||||
int tempExp = 0;
|
||||
|
||||
if (amount == 4)
|
||||
tempExp = 70000;
|
||||
else if (amount == 8)
|
||||
tempExp = 220000;
|
||||
|
||||
final long experience = tempExp;
|
||||
|
||||
Plugin.getClientManager().loadClientByName(playerName, client ->
|
||||
{
|
||||
if (client != null)
|
||||
{
|
||||
Plugin.getDonationManager().purchaseUnknownSalesPackage(client, "Gem Hunter Level " + amount, GlobalCurrency.GEM, 0, false, null);
|
||||
Plugin.getStatsManager().incrementStat(client.getAccountId(), "Global.GemsEarned", experience);
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class HeroCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public HeroCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "hero");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO false"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 15000"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 90"));
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class ItemCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public ItemCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "item");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
return;
|
||||
|
||||
final String playerName = args[0];
|
||||
int amountSpecified = Integer.parseInt(args[1]);
|
||||
final String category = args[2];
|
||||
String tempName = args[3];
|
||||
|
||||
for (int i = 4; i < args.length; i++)
|
||||
{
|
||||
tempName += " " + args[i];
|
||||
}
|
||||
|
||||
final String itemName = tempName;
|
||||
final int amount = amountSpecified;
|
||||
|
||||
if (!Plugin.getInventoryManager().validItem(itemName))
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Item."));
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getClientManager().loadClientByName(playerName, client ->
|
||||
{
|
||||
final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
|
||||
|
||||
if (uuid != null)
|
||||
{
|
||||
Plugin.getDonationManager().purchaseUnknownSalesPackage(client, (amount == 1 ? itemName : itemName + " " + amount), GlobalCurrency.GEM, 0, false, data ->
|
||||
{
|
||||
if (category.equalsIgnoreCase("ITEM"))
|
||||
{
|
||||
Plugin.getInventoryManager().addItemToInventoryForOffline(new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " " + itemName + "."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + "."));
|
||||
}
|
||||
}
|
||||
}, uuid, itemName, amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data == TransactionResponse.Success || data == TransactionResponse.AlreadyOwns)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), playerName + " received " + amount + " " + itemName + "."));
|
||||
}
|
||||
else if (data == TransactionResponse.Failed || data == TransactionResponse.InsufficientFunds)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "ERROR processing " + playerName + " " + amount + " " + itemName + "."));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class KitsCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public KitsCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "kits");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length != 1)
|
||||
return;
|
||||
|
||||
String playerName = args[0];
|
||||
|
||||
Plugin.getDonationManager().applyKits(playerName);
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Unlocked kits for " + playerName + "'s account!"));
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class LifetimeEternalCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public LifetimeEternalCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "lifetimeeternal");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ETERNAL"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 2 Item Mythical Chest"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 2 Item Illuminated Chest"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 1 Item Omega Chest"));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class LifetimeHeroCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public LifetimeHeroCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "lifetimehero");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 2 Item Mythical Chest"));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class LifetimeLegendCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public LifetimeLegendCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "lifetimelegend");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " LEGEND"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 3 Item Mythical Chest"));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class LifetimeTitanCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public LifetimeTitanCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "lifetimetitan");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " TITAN"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 5 Item Mythical Chest"));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class LifetimeUltraCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public LifetimeUltraCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "lifetimeultra");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales item " + args[0] + " 1 Item Mythical Chest"));
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.pet.PetClient;
|
||||
import mineplex.core.pet.PetType;
|
||||
import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
|
||||
import mineplex.core.pet.repository.token.PetChangeToken;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class PetCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public PetCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "pet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
return;
|
||||
|
||||
final String playerName = args[0];
|
||||
int petId = Integer.parseInt(args[1]);
|
||||
|
||||
if (petId < 0 || petId >= PetType.values().length)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "You have entered an invalid Pet Type."));
|
||||
return;
|
||||
}
|
||||
|
||||
final PetType petType = PetType.values()[petId];
|
||||
|
||||
Plugin.getClientManager().loadClientByName(playerName, client ->
|
||||
{
|
||||
final UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
|
||||
|
||||
if (uuid != null)
|
||||
{
|
||||
final Callback<PetClient> clientCallback = new Callback<PetClient>()
|
||||
{
|
||||
public void run(PetClient petClient)
|
||||
{
|
||||
if (petClient.getPets().containsKey(petType))
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), F.elem(playerName) + " already has that Pet!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
PetChangeToken token = new PetChangeToken();
|
||||
token.AccountId = client.getAccountId();
|
||||
token.Name = playerName;
|
||||
token.PetType = petType.toString();
|
||||
token.PetName = petType.getName();
|
||||
|
||||
Plugin.getPetRepo().AddPet(token);
|
||||
Plugin.getInventoryManager().addItemToInventoryForOffline(success ->
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), F.elem(playerName) + " has been given their Pet!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Attempt to give Pet has failed!"));
|
||||
}
|
||||
}, client.getAccountId(), petType.toString(), 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
Gson gson = new Gson();
|
||||
ClientPetTokenWrapper token = null;
|
||||
String response = Plugin.getClientManager().getRepository().getClientByUUID(uuid);
|
||||
token = gson.fromJson(response, ClientPetTokenWrapper.class);
|
||||
|
||||
PetClient petClient = new PetClient();
|
||||
petClient.load(token.DonorToken);
|
||||
|
||||
clientCallback.run(petClient);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class PowerPlayCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public PowerPlayCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "powerplay");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length < 2)
|
||||
return;
|
||||
|
||||
final String playerName = args[0];
|
||||
final String duration = args[1];
|
||||
|
||||
if (!duration.equalsIgnoreCase("month") && !duration.equalsIgnoreCase("year"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getClientManager().loadClientByName(playerName, client ->
|
||||
{
|
||||
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
|
||||
{
|
||||
caller.sendMessage(F.main(Plugin.getName(), "Couldn't find " + playerName + "'s account!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.permissions.PermissionGroup;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class RankCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
private static final List<String> ACCEPTED_RANKS = Collections.unmodifiableList(Arrays.asList("PLAYER", "ULTRA", "HERO", "LEGEND", "TITAN", "ETERNAL"));
|
||||
|
||||
public RankCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "rank");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String playerName = args[0];
|
||||
String rank = args[1].toUpperCase();
|
||||
|
||||
if (ACCEPTED_RANKS.contains(rank))
|
||||
{
|
||||
PermissionGroup group = PermissionGroup.valueOf(rank);
|
||||
Plugin.runAsync(() ->
|
||||
{
|
||||
UUID uuid = Plugin.getClientManager().loadUUIDFromDB(playerName);
|
||||
|
||||
Plugin.getClientManager().loadAccountIdFromUUID(uuid, id ->
|
||||
{
|
||||
Plugin.runSync(() ->
|
||||
{
|
||||
if (id == -1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.getName(), "Could not find " + F.elem(playerName) + "!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plugin.getClientManager().setPrimaryGroup(id, group, () -> UtilPlayer.message(caller, F.main(Plugin.getName(), F.elem(playerName) + "'s rank has been updated to " + rank + "!")));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class Sales extends MultiCommandBase<SalesPackageManager>
|
||||
{
|
||||
public Sales(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "sales");
|
||||
|
||||
AddCommand(new RankCommand(plugin));
|
||||
AddCommand(new CoinCommand(plugin));
|
||||
AddCommand(new ItemCommand(plugin));
|
||||
AddCommand(new GemHunterCommand(plugin));
|
||||
AddCommand(new UltraCommand(plugin));
|
||||
AddCommand(new HeroCommand(plugin));
|
||||
AddCommand(new LifetimeUltraCommand(plugin));
|
||||
AddCommand(new LifetimeHeroCommand(plugin));
|
||||
AddCommand(new LifetimeLegendCommand(plugin));
|
||||
AddCommand(new LifetimeTitanCommand(plugin));
|
||||
AddCommand(new LifetimeEternalCommand(plugin));
|
||||
AddCommand(new KitsCommand(plugin));
|
||||
AddCommand(new PowerPlayCommand(plugin));
|
||||
AddCommand(new PetCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void Help(Player caller, String[] args) {}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class UltraCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public UltraCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, SalesPackageManager.Perm.SALES_COMMAND, "ultra");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA false"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 7500"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 30"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user