TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java

54 lines
1.9 KiB
Java
Raw Normal View History

2019-11-02 17:21:23 +00:00
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
2020-06-30 07:25:38 +00:00
import me.totalfreedom.totalfreedommod.player.PlayerData;
2019-11-02 17:21:23 +00:00
import me.totalfreedom.totalfreedommod.rank.Rank;
2020-07-01 03:38:29 +00:00
import me.totalfreedom.totalfreedommod.util.FUtil;
2019-11-02 17:21:23 +00:00
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
2020-06-30 07:25:38 +00:00
@CommandParameters(description = "Shows the amount of coins you have or another player has", usage = "/<command> [playername]")
2019-11-02 17:21:23 +00:00
public class Command_coins extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
{
msg("The shop is currently disabled!", ChatColor.RED);
return true;
}
Player p;
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
if (args.length > 0)
{
if (getPlayer(args[0]) != null)
{
p = getPlayer(args[0]);
}
else
{
msg(PLAYER_NOT_FOUND);
return true;
}
}
else
{
if (senderIsConsole)
{
msg(prefix + ChatColor.RED + "You are not a player, use /coins <playername>");
return true;
}
else
{
p = playerSender;
}
}
2020-06-30 07:25:38 +00:00
PlayerData playerData = plugin.pl.getData(p);
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + playerData.getCoins() + ChatColor.GREEN + " coins.");
2019-11-02 17:21:23 +00:00
return true;
}
}