LuckLottery/src/cn/citycraft/LuckLottery/command/LuckLotteryCommand.java

89 lines
2.3 KiB
Java

package cn.citycraft.LuckLottery.command;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import cn.citycraft.LuckLottery.LuckLottery;
import cn.citycraft.LuckLottery.utils.ChatUtils;
import cn.citycraft.LuckLottery.utils.InvUtils;
import cn.citycraft.LuckLottery.utils.LotteryUtils;
import cn.citycraft.LuckLottery.utils.PermissionUtils;
public class LuckLotteryCommand implements CommandExecutor {
LuckLottery plugin;
public LuckLotteryCommand(LuckLottery main) {
plugin = main;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String string,
String[] args) {
switch (args.length) {
case 0:
if (isPlayer(sender)){
Player p = (Player) sender;
if (LuckLottery.economy.hasAccount(p)
&& LuckLottery.economy.has(p, 200)) {
InvUtils.openGui(p);
} else {
ChatUtils.sendMessage(p, ChatColor.GOLD
+ "你没有足够的金钱购买彩票,每张彩票" + ChatColor.RED + "200"
+ ChatColor.GOLD + "元!");
}
}
return true;
case 1:
switch (args[0]) {
case "load":
if (isPlayer(sender)) {
Player p = (Player) sender;
LotteryUtils.loadPlayerLottery(p);
ChatUtils.sendMessage(p, ChatColor.BLUE + "已加载您的彩票数据...");
}
return true;
case "show":
if (isPlayer(sender)) {
Player p = (Player) sender;
LotteryUtils.showPlayerLottery(p);
}
return true;
case "random":
if (PermissionUtils.Check(sender, PermissionUtils.Random)) {
LotteryUtils.updateSystemLottery(sender);
}
return true;
case "reward":
if (PermissionUtils.Check(sender, PermissionUtils.Reward)) {
LotteryUtils.rewardLastLottery();
ChatUtils.sendMessage(sender, ChatColor.GREEN + "已结算上一轮彩票!");
}
return true;
case "look":
if (PermissionUtils.Check(sender, PermissionUtils.Reward)){
LotteryUtils.showSystemLottery(sender);
}
return true;
case "help":
ChatUtils.sendHelp(sender);
return true;
}
break;
case 2:
default:
}
return false;
}
public boolean isPlayer(CommandSender p) {
if (p instanceof Player)
return true;
return false;
}
}