62 lines
2.3 KiB
Java
62 lines
2.3 KiB
Java
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.utils.ChatUtils;
|
|
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
|
|
|
public class LotteryReward implements Runnable {
|
|
LuckLottery plugin;
|
|
boolean update;
|
|
|
|
public LotteryReward(final LuckLottery plugin, final boolean b) {
|
|
this.plugin = plugin;
|
|
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 (final Entry<String, List<List<String>>> players : LotteryUtils.playerLottery.entrySet()) {
|
|
final OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
|
|
final List<List<String>> pl = players.getValue();
|
|
if (pl != null && !pl.isEmpty()) {
|
|
for (final List<String> playerlottery : pl) {
|
|
final int win = LotteryUtils.getSameNumber(playerlottery);
|
|
int winprices = 0;
|
|
winprices = plugin.getConfig().getInt("Reward." + win, 200);
|
|
if (winprices > 0) {
|
|
ChatUtils.broadcastMessage(
|
|
ChatColor.GREEN + p.getName() + "的彩票: " + ChatColor.YELLOW + playerlottery.toString() + ChatColor.GREEN + "获得了" + ChatColor.GOLD + winprices + ChatColor.GREEN + "元!");
|
|
final String message = ChatColor.GREEN + "您的彩票: " + ChatColor.YELLOW + playerlottery.toString() + ChatColor.GREEN + "获得了" + ChatColor.GOLD + winprices + ChatColor.GREEN + "元!";
|
|
if (p.isOnline()) {
|
|
// ChatUtils.sendMessage((Player) p, message);
|
|
} else {
|
|
plugin.getOfflineData().addMessage(p.getName(), message);
|
|
}
|
|
LuckLottery.economy.depositPlayer(p, winprices);
|
|
}
|
|
}
|
|
}
|
|
LotteryUtils.playerLottery.put(players.getKey(), null);
|
|
}
|
|
LotteryUtils.clearLottery();
|
|
if (update) {
|
|
LotteryUtils.updateSystemLottery();
|
|
}
|
|
}
|
|
|
|
}
|