New Coin/Gem Command
This commit is contained in:
parent
01d44cd250
commit
054c26dfbc
@ -1,11 +1,14 @@
|
|||||||
package mineplex.core.donation;
|
package mineplex.core.donation;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
public class CoinCommand extends CommandBase<DonationManager>
|
public class CoinCommand extends CommandBase<DonationManager>
|
||||||
@ -20,32 +23,58 @@ public class CoinCommand extends CommandBase<DonationManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Coin", "Missing Args"));
|
UtilPlayer.message(caller, F.main("Coin", "Missing Args: " + F.elem("/coin <player> <amount>")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Try Online
|
String targetName = args[0];
|
||||||
final Player target = UtilPlayer.searchOnline(caller, args[0], true);
|
String coinsString = args[1];
|
||||||
|
Player target = UtilPlayer.searchExact(targetName);
|
||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
return;
|
{
|
||||||
|
UUID uuid = UUIDFetcher.getUUIDOf(targetName);
|
||||||
|
if (uuid != null)
|
||||||
|
{
|
||||||
|
rewardCoins(caller, null, targetName, uuid, coinsString);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Coin", "Could not find player " + F.name(targetName)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rewardCoins(caller, target, target.getName(), target.getUniqueId(), coinsString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Give Coins to Target
|
private void rewardCoins(final Player caller, final Player target, final String targetName, final UUID uuid, String coinsString)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final int coins = Integer.parseInt(args[1]);
|
int coins = Integer.parseInt(coinsString);
|
||||||
Plugin.RewardCoins(new Callback<Boolean>()
|
rewardCoins(caller, target, targetName, uuid, coins);
|
||||||
{
|
|
||||||
public void run(Boolean completed)
|
|
||||||
{
|
|
||||||
UtilPlayer.message(caller, F.main("Coin", "You gave " + F.elem(coins + " Coins") + " to " + F.name(target.getName()) + "."));
|
|
||||||
UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + "."));
|
|
||||||
}
|
|
||||||
}, caller.getName(), target.getName(), target.getUniqueId(), coins);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Coin", "Invalid Coins Amount"));
|
UtilPlayer.message(caller, F.main("Coin", "Invalid Coins Amount"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rewardCoins(final Player caller, final Player target, final String targetName, final UUID uuid, final int coins)
|
||||||
|
{
|
||||||
|
Plugin.RewardCoins(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean completed)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Coin", "You gave " + F.elem(coins + " Coins") + " to " + F.name(targetName) + "."));
|
||||||
|
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + "."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, caller.getName(), targetName, uuid, coins);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package mineplex.core.donation;
|
package mineplex.core.donation;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UUIDFetcher;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
|
||||||
public class GemCommand extends CommandBase<DonationManager>
|
public class GemCommand extends CommandBase<DonationManager>
|
||||||
@ -20,32 +23,58 @@ public class GemCommand extends CommandBase<DonationManager>
|
|||||||
{
|
{
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Gem", "Missing Args"));
|
UtilPlayer.message(caller, F.main("gem", "Missing Args: " + F.elem("/gem <player> <amount>")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Try Online
|
String targetName = args[0];
|
||||||
final Player target = UtilPlayer.searchOnline(caller, args[0], true);
|
String gemsString = args[1];
|
||||||
|
Player target = UtilPlayer.searchExact(targetName);
|
||||||
if (target == null)
|
|
||||||
return;
|
if (target == null)
|
||||||
|
{
|
||||||
//Give Gems to Target
|
UUID uuid = UUIDFetcher.getUUIDOf(targetName);
|
||||||
|
if (uuid != null)
|
||||||
|
{
|
||||||
|
rewardGems(caller, null, targetName, uuid, gemsString);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Gem", "Could not find player " + F.name(targetName)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rewardGems(caller, target, target.getName(), target.getUniqueId(), gemsString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rewardGems(final Player caller, final Player target, final String targetName, final UUID uuid, String gemsString)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final int gems = Integer.parseInt(args[1]);
|
int gems = Integer.parseInt(gemsString);
|
||||||
Plugin.RewardGems(new Callback<Boolean>()
|
rewardGems(caller, target, targetName, uuid, gems);
|
||||||
{
|
|
||||||
public void run(Boolean completed)
|
|
||||||
{
|
|
||||||
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(), target.getUniqueId(), gems);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Gem", "Invalid Gem Amount"));
|
UtilPlayer.message(caller, F.main("gem", "Invalid gems Amount"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void rewardGems(final Player caller, final Player target, final String targetName, final UUID uuid, final int gems)
|
||||||
|
{
|
||||||
|
Plugin.RewardGems(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean completed)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("gem", "You gave " + F.elem(gems + " gems") + " to " + F.name(targetName) + "."));
|
||||||
|
|
||||||
|
if (target != null)
|
||||||
|
{
|
||||||
|
UtilPlayer.message(target, F.main("gem", F.name(caller.getName()) + " gave you " + F.elem(gems + " gems") + "."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, caller.getName(), targetName, uuid, gems);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
@ -63,7 +62,7 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayUsage(Player caller)
|
private void displayUsage(Player caller)
|
||||||
{
|
{
|
||||||
UtilPlayer.message(caller, F.main("Item", "Usage: " + F.elem("/giveitem <playername> <item name> <amount>")));
|
UtilPlayer.message(caller, F.main("Item", "Usage: " + F.elem("/giveitem <playername> <item name> <amount>")));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user