1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-02 15:33:30 +01:00
Jobs/com/gamingmesh/jobs/commands/list/limit.java

66 lines
2.5 KiB
Java

package com.gamingmesh.jobs.commands.list;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.commands.JobCommand;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.economy.PaymentData;
import com.gamingmesh.jobs.stuff.TimeManage;
public class limit implements Cmd {
@Override
@JobCommand(700)
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
if (args.length > 0) {
Jobs.getCommandManager().sendUsage(sender, "limit");
return true;
}
if (!(sender instanceof Player)) {
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.ingame"));
return false;
}
Player player = (Player) sender;
boolean disabled = true;
for (CurrencyType type : CurrencyType.values()) {
if (Jobs.getGCManager().currencyLimitUse.get(type).isEnabled()) {
disabled = false;
break;
}
}
if (disabled) {
player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output.notenabled"));
return true;
}
JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
for (CurrencyType type : CurrencyType.values()) {
if (!Jobs.getGCManager().currencyLimitUse.get(type).isEnabled())
continue;
PaymentData limit = JPlayer.getPaymentLimit();
if (limit == null) {
int lefttime1 = Jobs.getGCManager().currencyLimitUse.get(type).getTimeLimit() * 1000;
player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort((long) lefttime1)));
player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "limit",
"%" + type.getName().toLowerCase() + "%", "0.0",
"%total" + type.getName().toLowerCase() + "%", JPlayer.getLimit(type)));
continue;
}
if (limit.GetLeftTime(type) > 0) {
player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "time", "%time%", TimeManage.to24hourShort(limit.GetLeftTime(type))));
player.sendMessage(Jobs.getLanguage().getMessage("command.limit.output." + type.getName().toLowerCase() + "limit",
"%" + type.getName().toLowerCase() + "%", (int) (limit.GetAmount(type) * 100) / 100D,
"%total" + type.getName().toLowerCase() + "%", JPlayer.getLimit(type)));
}
}
return true;
}
}