package cn.citycraft.LuckLottery.runnable; import java.util.List; import java.util.Map.Entry; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import cn.citycraft.LuckLottery.LuckLottery; import cn.citycraft.LuckLottery.config.Config; import cn.citycraft.LuckLottery.config.OfflineDate; import cn.citycraft.LuckLottery.utils.ChatUtils; import cn.citycraft.LuckLottery.utils.LotteryUtils; public class LotteryReward implements Runnable { boolean update; public LotteryReward(boolean b) { update = b; } @SuppressWarnings("deprecation") @Override public void run() { if (LotteryUtils.getSystemLottery() == null || LotteryUtils.getSystemLottery().isEmpty()) { LotteryUtils.updateSystemLottery(); return; } ChatUtils.broadcastMessage(ChatColor.GOLD + "本轮彩票开奖: " + ChatColor.RED + LotteryUtils.getSystemLottery().toString()); ChatUtils.broadcastMessage(ChatColor.BLUE + "使用命令: " + ChatColor.RED + "/ll" + ChatColor.BLUE + " 或闹钟菜单可以购买彩票!"); for (Entry>> players : LotteryUtils.playerLottery .entrySet()) { OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey()); List> pl = players.getValue(); if (pl != null && !pl.isEmpty()) for (List playerlottery : pl) { int win = LotteryUtils.getSameNumber(playerlottery); int winprices = 0; winprices = Config.getInstance().getInt("Reward." + win, 200); if (winprices > 0) { ChatUtils.broadcastMessage(ChatColor.GREEN + p.getName() + "的彩票: " + ChatColor.YELLOW + playerlottery.toString() + ChatColor.GREEN + "获得了" + ChatColor.GOLD + winprices + ChatColor.GREEN + "元!"); String message = ChatColor.GREEN + "您的彩票: " + ChatColor.YELLOW + playerlottery.toString() + ChatColor.GREEN + "获得了" + ChatColor.GOLD + winprices + ChatColor.GREEN + "元!"; if (p.isOnline()) { // ChatUtils.sendMessage((Player) p, message); } else { OfflineDate.addMessage(p.getName(), message); } LuckLottery.economy.depositPlayer(p, winprices); } } LotteryUtils.playerLottery.put(players.getKey(), null); } LotteryUtils.clearLottery(); if (update) LotteryUtils.updateSystemLottery(); } }