2015-05-20 15:30:56 +00:00
|
|
|
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;
|
2015-05-20 15:48:42 +00:00
|
|
|
import cn.citycraft.LuckLottery.config.Config;
|
2015-05-20 15:30:56 +00:00
|
|
|
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());
|
2015-05-20 16:30:12 +00:00
|
|
|
ChatUtils.broadcastMessage(ChatColor.BLUE + "使用命令: " + ChatColor.RED
|
|
|
|
+ "/ll" + ChatColor.BLUE + " 或闹钟菜单可以购买彩票!");
|
2015-05-22 15:31:03 +00:00
|
|
|
for (Entry<String, List<List<String>>> players : LotteryUtils.playerLottery
|
|
|
|
.entrySet()) {
|
2015-05-20 15:30:56 +00:00
|
|
|
OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
|
|
|
|
List<List<String>> pl = players.getValue();
|
|
|
|
if (pl != null && !pl.isEmpty())
|
|
|
|
for (List<String> playerlottery : pl) {
|
|
|
|
int win = LotteryUtils.getSameNumber(playerlottery);
|
|
|
|
int winprices = 0;
|
2015-05-20 15:48:42 +00:00
|
|
|
winprices = Config.getInstance().getInt("Reward." + win,
|
|
|
|
200);
|
2015-05-20 15:30:56 +00:00
|
|
|
if (winprices > 0) {
|
2015-05-22 15:31:03 +00:00
|
|
|
ChatUtils.broadcastMessage(ChatColor.GREEN
|
|
|
|
+ p.getName() + "的彩票: " + ChatColor.YELLOW
|
|
|
|
+ playerlottery.toString() + ChatColor.GREEN
|
|
|
|
+ "获得了" + ChatColor.GOLD + winprices
|
|
|
|
+ ChatColor.GREEN + "元!");
|
2015-05-20 15:30:56 +00:00
|
|
|
String message = ChatColor.GREEN + "您的彩票: "
|
|
|
|
+ ChatColor.YELLOW + playerlottery.toString()
|
|
|
|
+ ChatColor.GREEN + "获得了" + ChatColor.GOLD
|
|
|
|
+ winprices + ChatColor.GREEN + "元!";
|
|
|
|
if (p.isOnline()) {
|
2015-05-22 15:31:03 +00:00
|
|
|
// ChatUtils.sendMessage((Player) p, message);
|
2015-05-20 15:30:56 +00:00
|
|
|
} else {
|
|
|
|
OfflineDate.addMessage(p.getName(), message);
|
|
|
|
}
|
|
|
|
LuckLottery.economy.depositPlayer(p, winprices);
|
|
|
|
}
|
|
|
|
}
|
2015-05-22 15:31:03 +00:00
|
|
|
LotteryUtils.playerLottery.put(players.getKey(), null);
|
2015-05-20 15:30:56 +00:00
|
|
|
}
|
2015-05-22 15:31:03 +00:00
|
|
|
LotteryUtils.clearLottery();
|
2015-05-20 15:30:56 +00:00
|
|
|
if (update)
|
|
|
|
LotteryUtils.updateSystemLottery();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|