diff --git a/.classpath b/.classpath
index 85626a7..db5b5e4 100644
--- a/.classpath
+++ b/.classpath
@@ -1,25 +1,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 604092d..cfda483 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
cn.citycraft
LuckLottery
- 1.2
+ 1.3
${project.name}
@@ -15,7 +15,7 @@
maven-compiler-plugin
- 3.1
+ 3.3
1.7
1.7
@@ -30,14 +30,14 @@
true
+ pw.yumc:YumCore
cn.citycraft:PluginHelper
- org.mcstats.*:*
- org.mcstats
- ${project.groupId}.${project.artifactId}.mcstats
+ pw.yumc.YumCore
+ ${project.groupId}.${project.artifactId}
cn.citycraft.PluginHelper
@@ -56,34 +56,28 @@
+
+ Jenkins
+ http://ci.yumc.pw/job/${project.artifactId}/
+
+
+
+
+ DEBUG
+ UTF-8
+
-
- mengcraft-repo
- http://ci.mengcraft.com:8080/plugin/repository/everything/
-
spigot-repo
https://hub.spigotmc.org/nexus/content/groups/public/
-
- vault-repo
- http://nexus.theyeticave.net/content/repositories/pub_releases
-
-
- citycraft-repo
- http://ci.sumcraft.net:8080/plugin/repository/everything/
-
-
- Plugin Metrics
- http://repo.mcstats.org/content/repositories/public
-
org.spigotmc
spigot-api
jar
- 1.8.3-R0.1-SNAPSHOT
+ 1.10.2-R0.1-SNAPSHOT
cn.citycraft
@@ -92,20 +86,15 @@
1.0
- net.milkbowl.vault
- VaultAPI
- 1.5
- system
- ${project.basedir}/lib/Vault.jar
+ pw.yumc
+ YumCore
+ jar
+ 1.0
- org.mcstats.bukkit
- metrics
- R8-SNAPSHOT
- compile
+ net.milkbowl.vault
+ Vault
+ 1.5.6
-
- UTF-8
-
\ No newline at end of file
diff --git a/src/main/java/cn/citycraft/LuckLottery/LuckLottery.java b/src/main/java/cn/citycraft/LuckLottery/LuckLottery.java
index 41032a1..528cdb2 100644
--- a/src/main/java/cn/citycraft/LuckLottery/LuckLottery.java
+++ b/src/main/java/cn/citycraft/LuckLottery/LuckLottery.java
@@ -6,6 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import cn.citycraft.LuckLottery.command.LuckLotteryCommand;
import cn.citycraft.LuckLottery.config.OfflineDate;
+import cn.citycraft.LuckLottery.config.PlayerData;
import cn.citycraft.LuckLottery.listen.PlayerListen;
import cn.citycraft.LuckLottery.runnable.LotteryReward;
import cn.citycraft.LuckLottery.utils.ChatUtils;
@@ -15,75 +16,68 @@ import cn.citycraft.PluginHelper.utils.VersionChecker;
import net.milkbowl.vault.economy.Economy;
public class LuckLottery extends JavaPlugin {
- public static Economy economy = null;
- public static boolean isEconomy;
- public static LuckLottery plugin;
- protected FileConfig config;
- protected OfflineDate offlinedata;
- protected FileConfig playerdata;
+ public static Economy economy = null;
+ public static boolean isEconomy;
+ public static LuckLottery plugin;
+ protected FileConfig config;
+ protected OfflineDate offlinedata;
- @Override
- public FileConfig getConfig() {
- return config;
- }
+ @Override
+ public FileConfig getConfig() {
+ return config;
+ }
- public OfflineDate getOfflineData() {
- return offlinedata;
- }
+ public OfflineDate getOfflineData() {
+ return offlinedata;
+ }
- public FileConfig getPlayerdata() {
- return playerdata;
- }
+ @Override
+ public void onDisable() {
+ this.getLogger().info("保存彩票数据中...");
+ this.getLogger().info("保存玩家数据中...");
+ PlayerData.saveLottery();
+ }
- @Override
- public void onDisable() {
- this.getLogger().info("保存彩票数据中...");
- this.getLogger().info("保存玩家数据中...");
- LotteryUtils.saveLottery();
- }
+ @Override
+ public void onEnable() {
+ final PluginManager pm = this.getServer().getPluginManager();
+ if (pm.getPlugin("Vault") == null && !pm.getPlugin("Vault").isEnabled()) {
+ this.getLogger().warning("未找到前置插件Vault 关闭插件...");
+ this.getServer().getPluginManager().disablePlugin(this);
+ return;
+ }
+ if (setupEconomy()) {
+ LuckLottery.isEconomy = true;
+ this.getLogger().info("发现Vault 载入数据...");
+ } else {
+ this.getLogger().warning("发现Vault 但是无法找到经济插件 关闭插件...");
+ this.getServer().getPluginManager().disablePlugin(this);
+ return;
+ }
+ final int rewardtime = config.getInt("RewardTime", 10);
+ this.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new LotteryReward(this, true), 10, rewardtime * 60 * 20);
+ this.getLogger().info("彩票系统已开启...");
+ pm.registerEvents(new PlayerListen(this), this);
+ new LuckLotteryCommand();
+ new VersionChecker(this);
+ }
- @Override
- public void onEnable() {
- final PluginManager pm = this.getServer().getPluginManager();
- if (pm.getPlugin("Vault") == null && !pm.getPlugin("Vault").isEnabled()) {
- this.getLogger().warning("未找到前置插件Vault 关闭插件...");
- this.getServer().getPluginManager().disablePlugin(this);
- return;
- }
- if (setupEconomy()) {
- LuckLottery.isEconomy = true;
- this.getLogger().info("发现Vault 载入数据...");
- } else {
- this.getLogger().warning("发现Vault 但是无法找到经济插件 关闭插件...");
- this.getServer().getPluginManager().disablePlugin(this);
- return;
- }
- final int rewardtime = config.getInt("RewardTime", 10);
- this.getServer().getScheduler().runTaskTimer(plugin, new LotteryReward(this, true), 10, rewardtime * 60 * 20);
- this.getLogger().info("彩票系统已开启...");
- pm.registerEvents(new PlayerListen(this), this);
- getCommand("ll").setExecutor(new LuckLotteryCommand(this));
- new VersionChecker(this);
- }
+ @Override
+ public void onLoad() {
+ plugin = this;
+ config = new FileConfig(this);
+ offlinedata = new OfflineDate(this);
+ PlayerData.reloadPlayerLottery();
+ ChatUtils.setPluginname(config.getMessage("pluginname"));
+ LotteryUtils.setNumbersame(config.getBoolean("numbersame"));
+ LotteryUtils.setPrice(config.getInt("price"));
+ }
- @Override
- public void onLoad() {
- plugin = this;
- config = new FileConfig(this);
- offlinedata = new OfflineDate(this);
- playerdata = new FileConfig(this, "playerdate.yml");
- LotteryUtils.init(this);
- LotteryUtils.reloadPlayerLottery();
- ChatUtils.setPluginname(config.getMessage("pluginname"));
- LotteryUtils.setNumbersame(config.getBoolean("numbersame"));
- LotteryUtils.setPrice(config.getInt("price"));
- }
-
- public boolean setupEconomy() {
- final RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
- if (economyProvider != null) {
- economy = economyProvider.getProvider();
- }
- return (economy != null);
- }
+ public boolean setupEconomy() {
+ final RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
+ if (economyProvider != null) {
+ economy = economyProvider.getProvider();
+ }
+ return (economy != null);
+ }
}
diff --git a/src/main/java/cn/citycraft/LuckLottery/command/LuckLotteryCommand.java b/src/main/java/cn/citycraft/LuckLottery/command/LuckLotteryCommand.java
index 5e5bef1..2c8b3fb 100644
--- a/src/main/java/cn/citycraft/LuckLottery/command/LuckLotteryCommand.java
+++ b/src/main/java/cn/citycraft/LuckLottery/command/LuckLotteryCommand.java
@@ -1,121 +1,106 @@
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 org.bukkit.plugin.PluginManager;
import cn.citycraft.LuckLottery.LuckLottery;
+import cn.citycraft.LuckLottery.config.PlayerData;
import cn.citycraft.LuckLottery.utils.ChatUtils;
import cn.citycraft.LuckLottery.utils.InvUtils;
import cn.citycraft.LuckLottery.utils.LotteryUtils;
-import cn.citycraft.LuckLottery.utils.PermissionUtils;
+import cn.citycraft.LuckLottery.utils.Perm;
+import pw.yumc.YumCore.commands.CommandArgument;
+import pw.yumc.YumCore.commands.CommandExecutor;
+import pw.yumc.YumCore.commands.CommandManager;
+import pw.yumc.YumCore.commands.annotation.Async;
+import pw.yumc.YumCore.commands.annotation.Cmd;
+import pw.yumc.YumCore.commands.annotation.Help;
+import pw.yumc.YumCore.commands.annotation.Sort;
public class LuckLotteryCommand implements CommandExecutor {
- LuckLottery plugin;
+ LuckLottery plugin;
- public LuckLotteryCommand(LuckLottery main) {
- plugin = main;
- }
+ public LuckLotteryCommand() {
+ new CommandManager("ll").register(this);
+ }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String string,
- String[] args) {
- switch (args.length) {
- case 0:
- if (isPlayer(sender)) {
- final Player p = (Player) sender;
- int price = LotteryUtils.getPrice();
- if (LuckLottery.economy.hasAccount(p)
- && LuckLottery.economy.has(p, price)) {
- InvUtils.openGui(p);
- } else {
- ChatUtils.sendMessage(p, ChatColor.GOLD
- + "你没有足够的金钱购买彩票,每张彩票" + ChatColor.RED + price
- + 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 "clear":
- if (PermissionUtils.Check(sender, PermissionUtils.Clear)) {
- ChatUtils.sendMessage(sender, ChatColor.LIGHT_PURPLE
- + "警告: 即将清理所有彩票数据,此操作将无法取消!");
- ChatUtils.sendMessage(sender, ChatColor.RED
- + "命令: 请使用/ll clear confirm 确定清理!");
- }
- return true;
- case "showall":
- if (PermissionUtils.Check(sender, PermissionUtils.ShowAll)) {
- LotteryUtils.showAllPlayerLottery(sender);
- }
- 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 "reload":
- if (PermissionUtils.Check(sender, PermissionUtils.Reload)) {
- PluginManager pm = plugin.getServer().getPluginManager();
- ChatUtils.sendMessage(sender, ChatColor.GREEN + "配置文件已重载!");
- pm.disablePlugin(plugin);
- pm.enablePlugin(plugin);
- }
- return true;
- case "help":
- ChatUtils.sendHelp(sender);
- return true;
- }
- break;
- case 2:
- switch (args[0]) {
- case "clear":
- if (PermissionUtils.Check(sender, PermissionUtils.Clear)) {
- ChatUtils.sendMessage(sender, ChatColor.DARK_RED
- + "警告: 已经清理所有彩票数据,此操作无法撤销!");
- LotteryUtils.clearPlayerLottery(sender);
- }
- return true;
- }
- default:
- }
- return false;
- }
+ @Cmd(permission = Perm.Clear)
+ @Help("清除所有已购买彩票§4(管理员命令)")
+ @Sort(6)
+ public void clear(final CommandArgument e) {
+ final CommandSender sender = e.getSender();
+ if (e.getArgs().length > 0) {
+ ChatUtils.sendMessage(sender, ChatColor.DARK_RED + "警告: 已经清理所有彩票数据,此操作无法撤销!");
+ LotteryUtils.clearPlayerLottery(sender);
+ } else {
+ ChatUtils.sendMessage(sender, ChatColor.LIGHT_PURPLE + "警告: 即将清理所有彩票数据,此操作将无法取消!");
+ ChatUtils.sendMessage(sender, ChatColor.RED + "命令: 请使用/ll clear confirm 确定清理!");
+ }
+ }
- public boolean isPlayer(CommandSender p) {
- if (p instanceof Player)
- return true;
- return false;
- }
+ @Cmd(onlyPlayer = true)
+ @Help("打开彩票购买界面")
+ public boolean ll(final CommandArgument e) {
+ final Player p = (Player) e.getSender();
+ final int price = LotteryUtils.getPrice();
+ if (LuckLottery.economy.hasAccount(p) && LuckLottery.economy.has(p, price)) {
+ InvUtils.openGui(p);
+ } else {
+ ChatUtils.sendMessage(p, ChatColor.GOLD + "你没有足够的金钱购买彩票,每张彩票" + ChatColor.RED + price + ChatColor.GOLD + "元!");
+ }
+ return true;
+ }
+ @Async
+ @Cmd(permission = Perm.Look)
+ @Help("查看彩票系统状态§4(管理员命令)")
+ @Sort(3)
+ public void look(final CommandArgument e) {
+ final CommandSender sender = e.getSender();
+ LotteryUtils.showSystemLottery(sender);
+ PlayerData.printStatus(sender);
+ }
+
+ @Cmd(permission = Perm.Random)
+ @Help("重新生成彩票号码§4(管理员命令)")
+ @Sort(4)
+ public void random(final CommandArgument e) {
+ LotteryUtils.updateSystemLottery(e.getSender());
+ }
+
+ @Cmd(permission = Perm.Reload)
+ @Help("重载彩票插件§4(管理员命令)")
+ @Sort(7)
+ public void reload(final CommandArgument e) {
+ final CommandSender sender = e.getSender();
+ final PluginManager pm = plugin.getServer().getPluginManager();
+ ChatUtils.sendMessage(sender, ChatColor.GREEN + "配置文件已重载!");
+ pm.disablePlugin(plugin);
+ pm.enablePlugin(plugin);
+ }
+
+ @Cmd(permission = Perm.Reward)
+ @Help("结算上一轮彩票§4(管理员命令)")
+ @Sort(5)
+ public void reward(final CommandArgument e) {
+ LotteryUtils.rewardLastLottery();
+ ChatUtils.sendMessage(e.getSender(), ChatColor.GREEN + "已结算上一轮彩票!");
+ }
+
+ @Cmd(onlyPlayer = true)
+ @Help("查看已购买彩票")
+ @Sort(1)
+ public void show(final CommandArgument e) {
+ PlayerData.showPlayerLottery((Player) e.getSender());
+ }
+
+ @Cmd(permission = Perm.ShowAll)
+ @Help("查看所以玩家已购买彩票§4(管理员命令)")
+ @Sort(2)
+ public void showall(final CommandArgument e) {
+ PlayerData.showAllPlayerLottery(e.getSender());
+ }
}
diff --git a/src/main/java/cn/citycraft/LuckLottery/config/PlayerData.java b/src/main/java/cn/citycraft/LuckLottery/config/PlayerData.java
new file mode 100644
index 0000000..73989ec
--- /dev/null
+++ b/src/main/java/cn/citycraft/LuckLottery/config/PlayerData.java
@@ -0,0 +1,132 @@
+package cn.citycraft.LuckLottery.config;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+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.LotteryUtils;
+import cn.citycraft.PluginHelper.config.FileConfig;
+
+public class PlayerData {
+ public static Map>> playerLottery = new HashMap>>();
+ public static FileConfig playerdata = new FileConfig(LuckLottery.plugin, "playerdate.yml");
+
+ public static void addCount() {
+ playerdata.set("Count", playerdata.getInt("Count", 0) + 1);
+ playerdata.set("PriceTotal", playerdata.getInt("PriceTotal", 0) + LotteryUtils.getPrice());
+ playerdata.save();
+ }
+
+ public static List> addLottery(final Player player, final List lottery) {
+ List> playerhas = playerLottery.get(player.getName());
+ if (playerhas == null) {
+ playerhas = new ArrayList>();
+ }
+ if (!player.isOnline()) {
+ return playerhas;
+ }
+ playerhas.add(lottery);
+ playerLottery.put(player.getName(), playerhas);
+ playerdata.set(player.getName(), playerhas);
+ addCount();
+ return playerhas;
+ }
+
+ public static void clearLottery() {
+ for (final Entry>> pl : playerLottery.entrySet()) {
+ final String p = pl.getKey();
+ playerdata.set(p, null);
+ }
+ playerLottery.clear();
+ playerdata.save();
+ }
+
+ public static Map>> getPlayerLottery() {
+ return playerLottery;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static void loadPlayerLottery(final Player p) {
+ final List> pl = playerdata.getList(p.getName());
+ if (pl != null) {
+ playerLottery.put(p.getName(), (List>) pl);
+ }
+ }
+
+ public static void printStatus(final CommandSender sender) {
+ int nc = 0;
+ int np = 0;
+ int ncc = 0;
+ for (final List> lls : playerLottery.values()) {
+ nc += lls.size();
+ np += LotteryUtils.getPrice();
+ for (final List a : lls) {
+ ncc += LuckLottery.plugin.getConfig().getInt("Reward." + LotteryUtils.getSameNumber(a), 200);
+ }
+ }
+ ChatUtils.sendMessage(sender, String.format("§a本轮当前售出彩票 §e%s §a张", nc));
+ ChatUtils.sendMessage(sender, String.format("§a本轮预计回收金额 §e%s§a(总: §e%s §a中奖返还: §e%s§a) §a元", np - ncc, np, ncc));
+ ChatUtils.sendMessage(sender, String.format("§d总计出售彩票 §e%s §d张", playerdata.getInt("Count", 0)));
+ ChatUtils.sendMessage(sender, String.format("§d总计回收金额 §e%s §d元", playerdata.getInt("PriceTotal", 0)));
+ }
+
+ @SuppressWarnings("unchecked")
+ public static void reloadPlayerLottery() {
+ final Set apl = playerdata.getKeys(false);
+ for (final String p : apl) {
+ final List> pl = playerdata.getList(p);
+ if (pl != null) {
+ playerLottery.put(p, (List>) pl);
+ }
+ }
+ }
+
+ public static void reward(final int price) {
+ playerdata.set("PriceTotal", playerdata.getInt("PriceTotal", 0) - price);
+ playerdata.save();
+ }
+
+ public static void saveLottery() {
+ for (final Entry>> pl : playerLottery.entrySet()) {
+ final String p = pl.getKey();
+ final List> l = pl.getValue();
+ playerdata.set(p, l);
+ }
+ playerdata.save();
+ }
+
+ public static void showAllPlayerLottery(final CommandSender sender) {
+ ChatUtils.sendMessage(sender, "§c正在检索玩家彩票数据...");
+ boolean has = false;
+ for (final Entry>> phas : playerLottery.entrySet()) {
+ ChatUtils.sendMessage(sender, "§6玩家: §a" + phas.getKey() + "§6购买的彩票有");
+ for (final List lry : phas.getValue()) {
+ has = true;
+ ChatUtils.sendMessage(sender, "§a" + lry.toString());
+ }
+ }
+ if (!has) {
+ ChatUtils.sendMessage(sender, "§d没有玩家购买本轮彩票...");
+ }
+ }
+
+ public static void showPlayerLottery(final Player p) {
+ final List> playerhas = playerLottery.get(p.getName());
+ if (playerhas != null && !playerhas.isEmpty()) {
+ ChatUtils.sendMessage(p, "§6您当前购买的彩票有:");
+ for (final List lry : playerhas) {
+ ChatUtils.sendMessage(p, "§a" + lry.toString());
+ }
+ } else {
+ ChatUtils.sendMessage(p, "§c您当前没有购买的彩票!");
+ }
+ }
+}
diff --git a/src/main/java/cn/citycraft/LuckLottery/listen/PlayerListen.java b/src/main/java/cn/citycraft/LuckLottery/listen/PlayerListen.java
index ee08229..840e257 100644
--- a/src/main/java/cn/citycraft/LuckLottery/listen/PlayerListen.java
+++ b/src/main/java/cn/citycraft/LuckLottery/listen/PlayerListen.java
@@ -15,6 +15,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import cn.citycraft.LuckLottery.LuckLottery;
+import cn.citycraft.LuckLottery.config.PlayerData;
import cn.citycraft.LuckLottery.runnable.LaterShow;
import cn.citycraft.LuckLottery.utils.ChatUtils;
import cn.citycraft.LuckLottery.utils.InvUtils;
@@ -50,7 +51,7 @@ public class PlayerListen implements Listener {
return;
}
final List lottery = InvUtils.getLotteryNumber(inv);
- LotteryUtils.addLottery(p, lottery);
+ PlayerData.addLottery(p, lottery);
ChatUtils.sendMessage(p, "§6您当前购买的彩票号码为: " + ChatColor.GREEN + lottery.toString());
ChatUtils.howToShow(p);
LuckLottery.economy.withdrawPlayer(p, LotteryUtils.getPrice());
diff --git a/src/main/java/cn/citycraft/LuckLottery/runnable/LotteryReward.java b/src/main/java/cn/citycraft/LuckLottery/runnable/LotteryReward.java
index 4cebc09..f852155 100644
--- a/src/main/java/cn/citycraft/LuckLottery/runnable/LotteryReward.java
+++ b/src/main/java/cn/citycraft/LuckLottery/runnable/LotteryReward.java
@@ -8,54 +8,56 @@ import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import cn.citycraft.LuckLottery.LuckLottery;
+import cn.citycraft.LuckLottery.config.PlayerData;
import cn.citycraft.LuckLottery.utils.ChatUtils;
import cn.citycraft.LuckLottery.utils.LotteryUtils;
public class LotteryReward implements Runnable {
- LuckLottery plugin;
- boolean update;
+ LuckLottery plugin;
+ boolean update;
- public LotteryReward(final LuckLottery plugin, final boolean b) {
- this.plugin = plugin;
- update = b;
- }
+ 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>> players : LotteryUtils.playerLottery.entrySet()) {
- final OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
- final List> pl = players.getValue();
- if (pl != null && !pl.isEmpty()) {
- for (final List 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();
- }
- }
+ @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 + " 或闹钟菜单可以购买彩票!");
+ int priceTotal = 0;
+ for (final Entry>> players : PlayerData.playerLottery.entrySet()) {
+ final OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
+ final List> pl = players.getValue();
+ if (pl != null && !pl.isEmpty()) {
+ for (final List playerlottery : pl) {
+ final int win = LotteryUtils.getSameNumber(playerlottery);
+ int winprices = 0;
+ winprices = plugin.getConfig().getInt("Reward." + win, 200);
+ if (winprices > 0) {
+ priceTotal += winprices;
+ 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()) {
+ plugin.getOfflineData().addMessage(p.getName(), message);
+ }
+ LuckLottery.economy.depositPlayer(p, winprices);
+ }
+ }
+ }
+ PlayerData.reward(priceTotal);
+ PlayerData.playerLottery.put(players.getKey(), null);
+ }
+ PlayerData.clearLottery();
+ if (update) {
+ LotteryUtils.updateSystemLottery();
+ }
+ }
}
diff --git a/src/main/java/cn/citycraft/LuckLottery/utils/ChatUtils.java b/src/main/java/cn/citycraft/LuckLottery/utils/ChatUtils.java
index 1ad79cb..fcefd12 100644
--- a/src/main/java/cn/citycraft/LuckLottery/utils/ChatUtils.java
+++ b/src/main/java/cn/citycraft/LuckLottery/utils/ChatUtils.java
@@ -8,70 +8,31 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ChatUtils {
- protected static String pluginname = "";
- public static String[] helps = new String[]{
- "§6=========彩票插件帮助========",
- "§a/ll 打开彩票购买界面",
- "§b/ll show 查看已购买彩票",
- "§3/ll showall查看所以玩家已购买彩票§4(管理员命令)",
- "§c/ll random 重新生成彩票§4(管理员命令)",
- "§d/ll reward 结算上一轮彩票§4(管理员命令)",
- "§e/ll clear 清除所有已购买彩票§4(管理员命令)",
- "§5/ll look 查看本轮彩票号码§4(管理员命令)",
- "§c/ll reload 重载彩票插件§4(管理员命令)"
- };
-
- public static String getPluginname() {
- return pluginname;
- }
+ protected static String pluginname = "";
- public static void setPluginname(String pluginname) {
- ChatUtils.pluginname = pluginname;
- }
+ public static void broadcastMessage(final String message) {
+ Bukkit.broadcastMessage(pluginname + message);
+ }
- public static void sendMessage(Player p, String message) {
- p.sendMessage(pluginname + message);
- }
-
- public static void sendMessage(CommandSender p, String message) {
- p.sendMessage(pluginname + message);
- }
-
- public static void sendMessage(Player p, String[] messages) {
- for (String msg : messages) {
- sendMessage(p, msg);
- }
- }
+ public static String getPluginname() {
+ return pluginname;
+ }
- public static void sendMessage(Player p, List messages) {
- for (String msg : messages) {
- sendMessage(p, msg);
- }
- }
-
- public static void sendHelp(Player p){
- p.sendMessage(helps);
- }
-
- public static void sendHelp(CommandSender sender) {
- sender.sendMessage(helps);
- }
-
- public static void broadcastMessage(String message) {
- Bukkit.broadcastMessage(pluginname + message);
- }
+ public static void howToShow(final Player p) {
+ sendMessage(p, ChatColor.GOLD + "命令: " + ChatColor.RED + "/ll show " + ChatColor.GOLD + "查看已购买彩票!");
+ }
- public static void howToShow(Player p) {
- sendMessage(p, ChatColor.GOLD + "命令: " + ChatColor.RED + "/ll show "
- + ChatColor.GOLD + "查看已购买彩票!");
- }
+ public static void sendMessage(final CommandSender p, final String message) {
+ p.sendMessage(pluginname + message);
+ }
- public static void noPermission(Player p) {
- ChatUtils.sendMessage(p, PermissionUtils.No_Permission);
- }
-
- public static void noPermission(CommandSender p) {
- ChatUtils.sendMessage(p, PermissionUtils.No_Permission);
- }
+ public static void sendMessage(final Player p, final List messages) {
+ for (final String msg : messages) {
+ sendMessage(p, msg);
+ }
+ }
+ public static void setPluginname(final String pluginname) {
+ ChatUtils.pluginname = pluginname;
+ }
}
diff --git a/src/main/java/cn/citycraft/LuckLottery/utils/InvUtils.java b/src/main/java/cn/citycraft/LuckLottery/utils/InvUtils.java
index 4d9a84f..c0fd368 100644
--- a/src/main/java/cn/citycraft/LuckLottery/utils/InvUtils.java
+++ b/src/main/java/cn/citycraft/LuckLottery/utils/InvUtils.java
@@ -13,265 +13,217 @@ import org.bukkit.inventory.meta.ItemMeta;
public class InvUtils {
- public static final String InvName = ChatUtils.getPluginname() + " §c§l售价: "
- + LotteryUtils.getPrice() + "元一份";
+ public static final String InvName = ChatUtils.getPluginname() + " §c§l售价: " + LotteryUtils.getPrice() + "元一份";
- public static final String NumPrefix = "§6§l";
- public static final String Normal1 = "§6§l1";
- public static final String Normal2 = "§6§l2";
- public static final String Normal3 = "§6§l3";
- public static final String Normal4 = "§6§l4";
- public static final String Normal5 = "§6§l5";
- public static final String Normal6 = "§6§l6";
- public static final String Normal7 = "§6§l7";
- public static final String Normal8 = "§6§l8";
- public static final String Normal9 = "§6§l9";
+ public static final String NumPrefix = "§6§l";
+ public static final String Normal1 = "§6§l1";
+ public static final String Normal2 = "§6§l2";
+ public static final String Normal3 = "§6§l3";
+ public static final String Normal4 = "§6§l4";
+ public static final String Normal5 = "§6§l5";
+ public static final String Normal6 = "§6§l6";
+ public static final String Normal7 = "§6§l7";
+ public static final String Normal8 = "§6§l8";
+ public static final String Normal9 = "§6§l9";
- public static final String Normal10 = "§6§l10";
- public static final String Normal11 = "§6§l11";
- public static final String Normal12 = "§6§l12";
- public static final String Normal13 = "§6§l13";
- public static final String Normal14 = "§6§l14";
- public static final String Normal15 = "§6§l15";
- public static final String Normal16 = "§6§l16";
- public static final String Normal17 = "§6§l17";
- public static final String Normal18 = "§6§l18";
- public static final String Normal19 = "§6§l19";
+ public static final String Normal10 = "§6§l10";
+ public static final String Normal11 = "§6§l11";
+ public static final String Normal12 = "§6§l12";
+ public static final String Normal13 = "§6§l13";
+ public static final String Normal14 = "§6§l14";
+ public static final String Normal15 = "§6§l15";
+ public static final String Normal16 = "§6§l16";
+ public static final String Normal17 = "§6§l17";
+ public static final String Normal18 = "§6§l18";
+ public static final String Normal19 = "§6§l19";
- public static final String Normal20 = "§6§l20";
- public static final String Normal21 = "§6§l21";
- public static final String Normal22 = "§6§l22";
- public static final String Normal23 = "§6§l23";
- public static final String Normal24 = "§6§l24";
- public static final String Normal25 = "§6§l25";
- public static final String Normal26 = "§6§l26";
- public static final String Normal27 = "§6§l27";
- public static final String Normal28 = "§6§l28";
- public static final String Normal29 = "§6§l29";
+ public static final String Normal20 = "§6§l20";
+ public static final String Normal21 = "§6§l21";
+ public static final String Normal22 = "§6§l22";
+ public static final String Normal23 = "§6§l23";
+ public static final String Normal24 = "§6§l24";
+ public static final String Normal25 = "§6§l25";
+ public static final String Normal26 = "§6§l26";
+ public static final String Normal27 = "§6§l27";
+ public static final String Normal28 = "§6§l28";
+ public static final String Normal29 = "§6§l29";
- public static final String Normal30 = "§6§l30";
- public static final String Normal31 = "§6§l31";
- public static final String Normal32 = "§6§l32";
- // public static final String Special1 = "§b§l1";
- // public static final String Special2 = "§b§l2";
- // public static final String Special3 = "§b§l3";
- // public static final String Special4 = "§b§l4";
- // public static final String Special5 = "§b§l5";
- // public static final String Special6 = "§b§l6";
- // public static final String Special7 = "§b§l7";
- // public static final String Special8 = "§b§l8";
- // public static final String Special9 = "§b§l9";
+ public static final String Normal30 = "§6§l30";
+ public static final String Normal31 = "§6§l31";
+ public static final String Normal32 = "§6§l32";
+ // public static final String Special1 = "§b§l1";
+ // public static final String Special2 = "§b§l2";
+ // public static final String Special3 = "§b§l3";
+ // public static final String Special4 = "§b§l4";
+ // public static final String Special5 = "§b§l5";
+ // public static final String Special6 = "§b§l6";
+ // public static final String Special7 = "§b§l7";
+ // public static final String Special8 = "§b§l8";
+ // public static final String Special9 = "§b§l9";
- public static final String WEB = "§c请选取=>§6橙色普通号码§r§l|§b蓝色特殊号码";
- public static final String ReSet = "§4§l重新选取";
- public static final String Create = "§a§l生成彩票";
- public static final String CantCreate = "§c§l请选取§66个普通号码§b1个特殊号码§a生成彩票";
+ public static final String WEB = "§c请选取=>§6橙色普通号码§r§l|§b蓝色特殊号码";
+ public static final String ReSet = "§4§l重新选取";
+ public static final String Create = "§a§l生成彩票";
+ public static final String CantCreate = "§c§l请选取§66个普通号码§b1个特殊号码§a生成彩票";
- // private static final ItemStack L0 = new
- // ItemStack(Material.DOUBLE_PLANT,1,(short)0);
+ // private static final ItemStack L0 = new
+ // ItemStack(Material.DOUBLE_PLANT,1,(short)0);
- public static final ItemStack L0 = new ItemStack(Material.WOOL);
- public static final ItemStack L1 = new ItemStack(Material.WOOL, 1, (short) 1);
- public static final ItemStack L2 = new ItemStack(Material.WOOL, 1, (short) 2);
- public static final ItemStack L3 = new ItemStack(Material.WOOL, 1, (short) 3);
- public static final ItemStack L4 = new ItemStack(Material.WOOL, 1, (short) 4);
- public static final ItemStack L5 = new ItemStack(Material.WOOL, 1, (short) 5);
- public static final ItemStack L6 = new ItemStack(Material.WOOL, 1, (short) 6);
- public static final ItemStack L7 = new ItemStack(Material.WOOL, 1, (short) 7);
- public static final ItemStack L8 = new ItemStack(Material.WOOL, 1, (short) 8);
- public static final ItemStack L9 = new ItemStack(Material.WOOL, 1, (short) 9);
- public static final ItemStack L10 = new ItemStack(Material.WOOL, 1, (short) 10);
- public static final ItemStack L11 = new ItemStack(Material.WOOL, 1, (short) 11);
- public static final ItemStack L12 = new ItemStack(Material.WOOL, 1, (short) 12);
- public static final ItemStack L13 = new ItemStack(Material.WOOL, 1, (short) 13);
- public static final ItemStack L14 = new ItemStack(Material.WOOL, 1, (short) 14);
- public static final ItemStack L15 = new ItemStack(Material.WOOL, 1, (short) 15);
+ public static final ItemStack L0 = new ItemStack(Material.WOOL);
+ public static final ItemStack L1 = new ItemStack(Material.WOOL, 1, (short) 1);
+ public static final ItemStack L2 = new ItemStack(Material.WOOL, 1, (short) 2);
+ public static final ItemStack L3 = new ItemStack(Material.WOOL, 1, (short) 3);
+ public static final ItemStack L4 = new ItemStack(Material.WOOL, 1, (short) 4);
+ public static final ItemStack L5 = new ItemStack(Material.WOOL, 1, (short) 5);
+ public static final ItemStack L6 = new ItemStack(Material.WOOL, 1, (short) 6);
+ public static final ItemStack L7 = new ItemStack(Material.WOOL, 1, (short) 7);
+ public static final ItemStack L8 = new ItemStack(Material.WOOL, 1, (short) 8);
+ public static final ItemStack L9 = new ItemStack(Material.WOOL, 1, (short) 9);
+ public static final ItemStack L10 = new ItemStack(Material.WOOL, 1, (short) 10);
+ public static final ItemStack L11 = new ItemStack(Material.WOOL, 1, (short) 11);
+ public static final ItemStack L12 = new ItemStack(Material.WOOL, 1, (short) 12);
+ public static final ItemStack L13 = new ItemStack(Material.WOOL, 1, (short) 13);
+ public static final ItemStack L14 = new ItemStack(Material.WOOL, 1, (short) 14);
+ public static final ItemStack L15 = new ItemStack(Material.WOOL, 1, (short) 15);
- public static final ItemStack B0 = new ItemStack(Material.STAINED_GLASS);
- public static final ItemStack B1 = new ItemStack(Material.STAINED_GLASS, 1, (short) 1);
- public static final ItemStack B2 = new ItemStack(Material.STAINED_GLASS, 1, (short) 2);
- public static final ItemStack B3 = new ItemStack(Material.STAINED_GLASS, 1, (short) 3);
- public static final ItemStack B4 = new ItemStack(Material.STAINED_GLASS, 1, (short) 4);
- public static final ItemStack B5 = new ItemStack(Material.STAINED_GLASS, 1, (short) 5);
- public static final ItemStack B6 = new ItemStack(Material.STAINED_GLASS, 1, (short) 6);
- public static final ItemStack B7 = new ItemStack(Material.STAINED_GLASS, 1, (short) 7);
- public static final ItemStack B8 = new ItemStack(Material.STAINED_GLASS, 1, (short) 8);
- public static final ItemStack B9 = new ItemStack(Material.STAINED_GLASS, 1, (short) 9);
- public static final ItemStack B10 = new ItemStack(Material.STAINED_GLASS, 1, (short) 10);
- public static final ItemStack B11 = new ItemStack(Material.STAINED_GLASS, 1, (short) 11);
- public static final ItemStack B12 = new ItemStack(Material.STAINED_GLASS, 1, (short) 12);
- public static final ItemStack B13 = new ItemStack(Material.STAINED_GLASS, 1, (short) 13);
- public static final ItemStack B14 = new ItemStack(Material.STAINED_GLASS, 1, (short) 14);
- public static final ItemStack B15 = new ItemStack(Material.STAINED_GLASS, 1, (short) 15);
+ public static final ItemStack B0 = new ItemStack(Material.STAINED_GLASS);
+ public static final ItemStack B1 = new ItemStack(Material.STAINED_GLASS, 1, (short) 1);
+ public static final ItemStack B2 = new ItemStack(Material.STAINED_GLASS, 1, (short) 2);
+ public static final ItemStack B3 = new ItemStack(Material.STAINED_GLASS, 1, (short) 3);
+ public static final ItemStack B4 = new ItemStack(Material.STAINED_GLASS, 1, (short) 4);
+ public static final ItemStack B5 = new ItemStack(Material.STAINED_GLASS, 1, (short) 5);
+ public static final ItemStack B6 = new ItemStack(Material.STAINED_GLASS, 1, (short) 6);
+ public static final ItemStack B7 = new ItemStack(Material.STAINED_GLASS, 1, (short) 7);
+ public static final ItemStack B8 = new ItemStack(Material.STAINED_GLASS, 1, (short) 8);
+ public static final ItemStack B9 = new ItemStack(Material.STAINED_GLASS, 1, (short) 9);
+ public static final ItemStack B10 = new ItemStack(Material.STAINED_GLASS, 1, (short) 10);
+ public static final ItemStack B11 = new ItemStack(Material.STAINED_GLASS, 1, (short) 11);
+ public static final ItemStack B12 = new ItemStack(Material.STAINED_GLASS, 1, (short) 12);
+ public static final ItemStack B13 = new ItemStack(Material.STAINED_GLASS, 1, (short) 13);
+ public static final ItemStack B14 = new ItemStack(Material.STAINED_GLASS, 1, (short) 14);
+ public static final ItemStack B15 = new ItemStack(Material.STAINED_GLASS, 1, (short) 15);
- public static final ItemStack W = new ItemStack(Material.SNOW_BALL);
- public static final ItemStack Creat = new ItemStack(Material.MAP);
- public static final ItemStack CM = new ItemStack(Material.WATER_LILY);
- public static final ItemStack CantCreat = new ItemStack(Material.EMPTY_MAP);
- public static final ItemStack A = new ItemStack(Material.AIR);
- public static final ItemStack RT = new ItemStack(Material.LAVA_BUCKET);
- static {
- setDisplayName(W, WEB);
- setDisplayName(L0, Normal1);
- setDisplayName(L1, Normal2);
- setDisplayName(L2, Normal3);
- setDisplayName(L3, Normal4);
- setDisplayName(L4, Normal5);
- setDisplayName(L5, Normal6);
- setDisplayName(L6, Normal7);
- setDisplayName(L7, Normal8);
- setDisplayName(L8, Normal9);
- setDisplayName(L9, Normal10);
- setDisplayName(L10, Normal11);
- setDisplayName(L11, Normal12);
- setDisplayName(L12, Normal13);
- setDisplayName(L13, Normal14);
- setDisplayName(L14, Normal15);
- setDisplayName(L15, Normal16);
+ public static final ItemStack W = new ItemStack(Material.SNOW_BALL);
+ public static final ItemStack Creat = new ItemStack(Material.MAP);
+ public static final ItemStack CM = new ItemStack(Material.WATER_LILY);
+ public static final ItemStack CantCreat = new ItemStack(Material.EMPTY_MAP);
+ public static final ItemStack A = new ItemStack(Material.AIR);
+ public static final ItemStack RT = new ItemStack(Material.LAVA_BUCKET);
- setDisplayName(B0, Normal17);
- setDisplayName(B1, Normal18);
- setDisplayName(B2, Normal19);
- setDisplayName(B3, Normal20);
- setDisplayName(B4, Normal21);
- setDisplayName(B5, Normal22);
- setDisplayName(B6, Normal23);
- setDisplayName(B7, Normal24);
- setDisplayName(B8, Normal25);
- setDisplayName(B9, Normal26);
- setDisplayName(B10, Normal27);
- setDisplayName(B11, Normal28);
- setDisplayName(B12, Normal29);
- setDisplayName(B13, Normal30);
- setDisplayName(B14, Normal31);
- setDisplayName(B15, Normal32);
+ static {
+ setDisplayName(W, WEB);
+ setDisplayName(L0, Normal1);
+ setDisplayName(L1, Normal2);
+ setDisplayName(L2, Normal3);
+ setDisplayName(L3, Normal4);
+ setDisplayName(L4, Normal5);
+ setDisplayName(L5, Normal6);
+ setDisplayName(L6, Normal7);
+ setDisplayName(L7, Normal8);
+ setDisplayName(L8, Normal9);
+ setDisplayName(L9, Normal10);
+ setDisplayName(L10, Normal11);
+ setDisplayName(L11, Normal12);
+ setDisplayName(L12, Normal13);
+ setDisplayName(L13, Normal14);
+ setDisplayName(L14, Normal15);
+ setDisplayName(L15, Normal16);
- setDisplayName(CM, "§6<=普通号码§r|§b特殊号码=>");
- setDisplayName(RT, ReSet);
- setDisplayName(CantCreat, CantCreate);
- setDisplayName(Creat, Create);
- }
+ setDisplayName(B0, Normal17);
+ setDisplayName(B1, Normal18);
+ setDisplayName(B2, Normal19);
+ setDisplayName(B3, Normal20);
+ setDisplayName(B4, Normal21);
+ setDisplayName(B5, Normal22);
+ setDisplayName(B6, Normal23);
+ setDisplayName(B7, Normal24);
+ setDisplayName(B8, Normal25);
+ setDisplayName(B9, Normal26);
+ setDisplayName(B10, Normal27);
+ setDisplayName(B11, Normal28);
+ setDisplayName(B12, Normal29);
+ setDisplayName(B13, Normal30);
+ setDisplayName(B14, Normal31);
+ setDisplayName(B15, Normal32);
- private static final ItemStack[] GUI_LINE1 = {
- W,
- L0,
- L1,
- L2,
- L3,
- L4,
- L5,
- L6,
- W
- /* 第一行结束 */};
- private static final ItemStack[] GUI_LINE2 = {
- L7,
- L8,
- L9,
- L10,
- L11,
- L12,
- L13,
- L14,
- L15
- /* 第二行结束 */};
- private static final ItemStack[] GUI_LINE3 = {
- B0,
- B1,
- B2,
- B3,
- B4,
- B5,
- B6,
- B7,
- B8
- /* 第三行结束 */};
- private static final ItemStack[] GUI_LINE4 = {
- W,
- B9,
- B10,
- B11,
- B12,
- B13,
- B14,
- B15,
- W
- /* 第四行结束 */};
- private static final ItemStack[] GUI_LINE5 = {
- W,
- W,
- W,
- W,
- W,
- W,
- RT,
- W,
- W
- /* 第五行结束 */};
- private static final ItemStack[] GUI_LINE6 = {
- A,
- A,
- A,
- A,
- A,
- A,
- CM,
- A,
- CantCreat
- /* 第六行结束 */};
+ setDisplayName(CM, "§6<=普通号码§r|§b特殊号码=>");
+ setDisplayName(RT, ReSet);
+ setDisplayName(CantCreat, CantCreate);
+ setDisplayName(Creat, Create);
+ }
- private static void setDisplayName(ItemStack item, String displayName) {
- ItemMeta itemMeta = item.getItemMeta();
- itemMeta.setDisplayName(displayName);
- item.setItemMeta(itemMeta);
- }
+ private static final ItemStack[] GUI_LINE1 = { W, L0, L1, L2, L3, L4, L5, L6, W
+ /* 第一行结束 */ };
+ private static final ItemStack[] GUI_LINE2 = { L7, L8, L9, L10, L11, L12, L13, L14, L15
+ /* 第二行结束 */ };
+ private static final ItemStack[] GUI_LINE3 = { B0, B1, B2, B3, B4, B5, B6, B7, B8
+ /* 第三行结束 */ };
+ private static final ItemStack[] GUI_LINE4 = { W, B9, B10, B11, B12, B13, B14, B15, W
+ /* 第四行结束 */ };
+ private static final ItemStack[] GUI_LINE5 = { W, W, W, W, W, W, RT, W, W
+ /* 第五行结束 */ };
+ private static final ItemStack[] GUI_LINE6 = { A, A, A, A, A, A, CM, A, CantCreat
+ /* 第六行结束 */ };
- public static ItemStack[] getGui() {
- List invgui = new ArrayList();
- invgui.addAll(Arrays.asList(GUI_LINE1));
- invgui.addAll(Arrays.asList(GUI_LINE2));
- invgui.addAll(Arrays.asList(GUI_LINE3));
- invgui.addAll(Arrays.asList(GUI_LINE4));
- invgui.addAll(Arrays.asList(GUI_LINE5));
- invgui.addAll(Arrays.asList(GUI_LINE6));
- return invgui.toArray(new ItemStack[0]);
- }
+ public static ItemStack[] getGui() {
+ final List invgui = new ArrayList();
+ invgui.addAll(Arrays.asList(GUI_LINE1));
+ invgui.addAll(Arrays.asList(GUI_LINE2));
+ invgui.addAll(Arrays.asList(GUI_LINE3));
+ invgui.addAll(Arrays.asList(GUI_LINE4));
+ invgui.addAll(Arrays.asList(GUI_LINE5));
+ invgui.addAll(Arrays.asList(GUI_LINE6));
+ return invgui.toArray(new ItemStack[0]);
+ }
- public static void openGui(Player p) {
- Inventory scrollInv = Bukkit.createInventory(null, 6 * 9, InvName);
- scrollInv.setContents(getGui());
- p.openInventory(scrollInv);
- }
+ public static String getItemNumber(final ItemStack item) {
+ final String num = item.getItemMeta().getDisplayName();
+ if (num.startsWith(NumPrefix)) {
+ return num.substring(NumPrefix.length());
+ }
+ return null;
+ }
- public static boolean isLotteryGUI(Inventory inv) {
- if (inv == null)
- return false;
- return inv.getHolder() == null && inv.getTitle().equals(InvName);
- }
+ public static List getLotteryNumber(final Inventory inv) {
+ final List lty = new ArrayList();
+ for (int i = 45; i < 51; i++) {
+ lty.add(getItemNumber(inv.getItem(i)));
+ }
+ lty.add(getItemNumber(inv.getItem(52)));
+ return lty;
+ }
- public static boolean selectFinish(Inventory inv) {
- return (inv.getItem(45) != null && inv.getItem(46) != null && inv.getItem(47) != null
- && inv.getItem(48) != null && inv.getItem(49) != null && inv.getItem(50) != null && inv
- .getItem(52) != null);
- }
+ public static boolean isLotteryGUI(final Inventory inv) {
+ if (inv == null) {
+ return false;
+ }
+ return inv.getHolder() == null && inv.getTitle().equals(InvName);
+ }
- public static List getLotteryNumber(Inventory inv) {
- List lty = new ArrayList();
- for (int i = 45; i < 51; i++) {
- lty.add(getItemNumber(inv.getItem(i)));
- }
- lty.add(getItemNumber(inv.getItem(52)));
- return lty;
- }
+ public static boolean isLotteryItem(final ItemStack item) {
+ final String num = item.getItemMeta().getDisplayName();
+ return num.startsWith(NumPrefix);
+ }
- public static String getItemNumber(ItemStack item) {
- String num = item.getItemMeta().getDisplayName();
- if (num.startsWith(NumPrefix))
- return num.substring(NumPrefix.length());
- return null;
- }
+ public static void openGui(final Player p) {
+ final Inventory scrollInv = Bukkit.createInventory(null, 6 * 9, InvName);
+ scrollInv.setContents(getGui());
+ p.openInventory(scrollInv);
+ }
- public static boolean isLotteryItem(ItemStack item) {
- String num = item.getItemMeta().getDisplayName();
- return num.startsWith(NumPrefix);
- }
+ public static boolean selectFinish(final Inventory inv) {
+ return (inv.getItem(45) != null
+ && inv.getItem(46) != null
+ && inv.getItem(47) != null
+ && inv.getItem(48) != null
+ && inv.getItem(49) != null
+ && inv.getItem(50) != null
+ && inv.getItem(52) != null);
+ }
+
+ private static void setDisplayName(final ItemStack item, final String displayName) {
+ final ItemMeta itemMeta = item.getItemMeta();
+ itemMeta.setDisplayName(displayName);
+ item.setItemMeta(itemMeta);
+ }
}
diff --git a/src/main/java/cn/citycraft/LuckLottery/utils/LotteryUtils.java b/src/main/java/cn/citycraft/LuckLottery/utils/LotteryUtils.java
index e6c7cf5..e56a71f 100644
--- a/src/main/java/cn/citycraft/LuckLottery/utils/LotteryUtils.java
+++ b/src/main/java/cn/citycraft/LuckLottery/utils/LotteryUtils.java
@@ -1,221 +1,113 @@
package cn.citycraft.LuckLottery.utils;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import java.util.Random;
-import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
import cn.citycraft.LuckLottery.LuckLottery;
+import cn.citycraft.LuckLottery.config.PlayerData;
import cn.citycraft.LuckLottery.runnable.LotteryReward;
-import cn.citycraft.PluginHelper.config.FileConfig;
public class LotteryUtils {
- public static Map>> playerLottery = new HashMap>>();
- protected static boolean numbersame;
- protected static FileConfig playerdata;
- protected static LuckLottery plugin;
- protected static int price;
- protected static List systemLottery = new ArrayList();
+ protected static LuckLottery plugin = LuckLottery.plugin;
+ protected static List systemLottery = new ArrayList();
+ protected static boolean numbersame;
+ protected static int price;
- public static List> addLottery(final Player player, final List lottery) {
- List> playerhas = playerLottery.get(player.getName());
- if (playerhas == null) {
- playerhas = new ArrayList>();
- }
- playerhas.add(lottery);
- playerLottery.put(player.getName(), playerhas);
- playerdata.set(player.getName(), playerhas);
- playerdata.save();
- return playerhas;
- }
+ public static void clearPlayerLottery(final CommandSender sender) {
+ ChatUtils.sendMessage(sender, "§c提示: 以清除所有玩家彩票数据...");
+ PlayerData.clearLottery();
+ }
- public static void clearLottery() {
- for (final Entry>> pl : playerLottery.entrySet()) {
- final String p = pl.getKey();
- playerdata.set(p, null);
- }
- playerLottery.clear();
- playerdata.save();
- }
+ public static int getPrice() {
+ return price;
+ }
- public static void clearPlayerLottery(final CommandSender sender) {
- ChatUtils.sendMessage(sender, "§c提示: 以清除所有玩家彩票数据...");
- clearLottery();
- }
+ public static List getRandomNumber() {
+ final Random rnd = new Random();
+ final List normal = new ArrayList();
+ for (int i = 1; i < 8; i++) {
+ String rr = rnd.nextInt(32) + 1 + "";
+ while (normal.contains(rr)) {
+ rr = rnd.nextInt(32) + 1 + "";
+ }
+ normal.add(rr);
+ }
+ return normal;
+ }
- public static int getPrice() {
- return price;
- }
+ public static int getSameNumber(final List lottery) {
+ return getSameNumber(lottery, systemLottery);
+ }
- public static List getRandomNumber() {
- final Random rnd = new Random();
- final List normal = new ArrayList();
- for (int i = 1; i < 8; i++) {
- String rr = rnd.nextInt(32) + 1 + "";
- while (normal.contains(rr)) {
- rr = rnd.nextInt(32) + 1 + "";
- }
- normal.add(rr);
- }
- return normal;
- }
+ public static int getSameNumber(final List lottery, final List system) {
+ int samenum = 0;
+ if (numbersame) {
+ for (int i = 0; i < lottery.size(); i++) {
+ if (lottery.get(i).equals(system.get(i))) {
+ samenum++;
+ }
+ }
+ } else {
+ for (final String pn : lottery) {
+ for (final String sn : system) {
+ if (pn.equals(sn)) {
+ samenum++;
+ }
+ }
+ }
+ }
+ if (lottery.get(lottery.size() - 1).equalsIgnoreCase(system.get(system.size() - 1))) {
+ samenum += 9;
+ }
+ return samenum;
+ }
- public static int getSameNumber(final List lottery) {
- int samenum = 0;
- final List system = systemLottery;
- if (numbersame) {
- for (int i = 0; i < lottery.size(); i++) {
- if (lottery.get(i).equals(system.get(i))) {
- samenum++;
- }
- }
- } else {
- for (final String pn : lottery) {
- for (final String sn : system) {
- if (pn.equals(sn)) {
- samenum++;
- }
- }
- }
- }
- if (lottery.get(lottery.size() - 1).equalsIgnoreCase(system.get(system.size() - 1))) {
- samenum += 9;
- }
- return samenum;
- }
+ public static List getSystemLottery() {
+ return systemLottery;
+ }
- public static int getSameNumber(final List lottery, final List system) {
- int samenum = 0;
- if (numbersame) {
- for (int i = 0; i < lottery.size(); i++) {
- if (lottery.get(i).equals(system.get(i))) {
- samenum++;
- }
- }
- } else {
- for (final String pn : lottery) {
- for (final String sn : system) {
- if (pn.equals(sn)) {
- samenum++;
- }
- }
- }
- }
- if (lottery.get(lottery.size() - 1).equalsIgnoreCase(system.get(system.size() - 1))) {
- samenum += 9;
- }
- return samenum;
- }
+ /**
+ * @return numbersame
+ */
+ public static boolean isNumbersame() {
+ return numbersame;
+ }
- public static List getSystemLottery() {
- return systemLottery;
- }
+ public static void rewardLastLottery() {
+ Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new LotteryReward(plugin, true));
+ }
- public static void init(final LuckLottery luckLottery) {
- plugin = luckLottery;
- playerdata = plugin.getPlayerdata();
- }
+ /**
+ * @param numbersame
+ * 要设置的 numbersame
+ */
+ public static void setNumbersame(final boolean numbersame) {
+ LotteryUtils.numbersame = numbersame;
+ }
- /**
- * @return numbersame
- */
- public static boolean isNumbersame() {
- return numbersame;
- }
+ public static void setPrice(final int price) {
+ LotteryUtils.price = price;
+ }
- @SuppressWarnings("unchecked")
- public static void loadPlayerLottery(final Player p) {
- final List> pl = playerdata.getList(p.getName());
- if (pl != null) {
- playerLottery.put(p.getName(), (List>) pl);
- }
- }
+ public static void setSystemLottery(final List systemLottery) {
+ LotteryUtils.systemLottery = systemLottery;
+ }
- @SuppressWarnings("unchecked")
- public static void reloadPlayerLottery() {
- final Set apl = playerdata.getKeys(false);
- for (final String p : apl) {
- final List> pl = playerdata.getList(p);
- if (pl != null) {
- playerLottery.put(p, (List>) pl);
- }
- }
- }
+ public static void showSystemLottery(final CommandSender p) {
+ ChatUtils.sendMessage(p, ChatColor.DARK_PURPLE + "此轮彩票号码为: " + ChatColor.YELLOW + LotteryUtils.systemLottery.toString());
+ }
- public static void rewardLastLottery() {
- Bukkit.getServer().getScheduler().runTaskAsynchronously(LuckLottery.plugin, new LotteryReward(plugin, true));
- }
+ public static void updateSystemLottery() {
+ LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
+ }
- public static void saveLottery() {
- for (final Entry>> pl : playerLottery.entrySet()) {
- final String p = pl.getKey();
- final List> l = pl.getValue();
- playerdata.set(p, l);
- }
- playerdata.save();
- }
-
- /**
- * @param numbersame
- * 要设置的 numbersame
- */
- public static void setNumbersame(final boolean numbersame) {
- LotteryUtils.numbersame = numbersame;
- }
-
- public static void setPrice(final int price) {
- LotteryUtils.price = price;
- }
-
- public static void setSystemLottery(final List systemLottery) {
- LotteryUtils.systemLottery = systemLottery;
- }
-
- public static void showAllPlayerLottery(final CommandSender sender) {
- ChatUtils.sendMessage(sender, "§c正在检索玩家彩票数据...");
- boolean has = false;
- for (final Entry>> phas : playerLottery.entrySet()) {
- ChatUtils.sendMessage(sender, "§6玩家: §a" + phas.getKey() + "§6购买的彩票有");
- for (final List lry : phas.getValue()) {
- has = true;
- ChatUtils.sendMessage(sender, "§a" + lry.toString());
- }
- }
- if (!has) {
- ChatUtils.sendMessage(sender, "§d没有玩家购买本轮彩票...");
- }
- }
-
- public static void showPlayerLottery(final Player p) {
- final List> playerhas = playerLottery.get(p.getName());
- if (playerhas != null && !playerhas.isEmpty()) {
- ChatUtils.sendMessage(p, "§6您当前购买的彩票有:");
- for (final List lry : playerhas) {
- ChatUtils.sendMessage(p, "§a" + lry.toString());
- }
- } else {
- ChatUtils.sendMessage(p, "§c您当前没有购买的彩票!");
- }
- }
-
- public static void showSystemLottery(final CommandSender p) {
- ChatUtils.sendMessage(p, ChatColor.DARK_PURPLE + "此轮彩票号码为: " + ChatColor.YELLOW + LotteryUtils.systemLottery.toString());
- }
-
- public static void updateSystemLottery() {
- LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
- }
-
- public static void updateSystemLottery(final CommandSender p) {
- LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
- ChatUtils.sendMessage(p, ChatColor.BLUE + "已随机生成彩票: " + ChatColor.YELLOW + LotteryUtils.systemLottery.toString());
- }
+ public static void updateSystemLottery(final CommandSender p) {
+ LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
+ ChatUtils.sendMessage(p, ChatColor.BLUE + "已随机生成彩票: " + ChatColor.YELLOW + LotteryUtils.systemLottery.toString());
+ }
}
diff --git a/src/main/java/cn/citycraft/LuckLottery/utils/Perm.java b/src/main/java/cn/citycraft/LuckLottery/utils/Perm.java
new file mode 100644
index 0000000..c5c51b2
--- /dev/null
+++ b/src/main/java/cn/citycraft/LuckLottery/utils/Perm.java
@@ -0,0 +1,11 @@
+package cn.citycraft.LuckLottery.utils;
+
+public class Perm {
+ public static final String ShowAll = "lucklottery.showall";
+ public static final String Status = "lucklottery.status";
+ public static final String Reward = "lucklottery.reward";
+ public static final String Random = "lucklottery.random";
+ public static final String Look = "lucklottery.look";
+ public static final String Clear = "lucklottery.clear";
+ public static final String Reload = "lucklottery.reload";
+}
diff --git a/src/main/java/cn/citycraft/LuckLottery/utils/PermissionUtils.java b/src/main/java/cn/citycraft/LuckLottery/utils/PermissionUtils.java
deleted file mode 100644
index ab0d412..0000000
--- a/src/main/java/cn/citycraft/LuckLottery/utils/PermissionUtils.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package cn.citycraft.LuckLottery.utils;
-
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import net.md_5.bungee.api.ChatColor;
-
-public class PermissionUtils {
- public static final String ShowAll = "lucklottery.showall";
- public static final String Reward = "lucklottery.reward";
- public static final String Random = "lucklottery.random";
- public static final String Look = "lucklottery.look";
- public static final String Clear = "lucklottery.clear";
- public static final String Reload = "lucklottery.reload";
-
- public static String No_Permission = ChatColor.RED + "你没有此命令的权限!";
-
- public static boolean Check(Player p, String perm) {
- if (p.hasPermission(perm)) {
- return true;
- } else {
- ChatUtils.noPermission(p);
- }
- return false;
- }
-
- public static boolean Check(CommandSender p, String perm) {
- if (p.hasPermission(perm)) {
- return true;
- } else {
- ChatUtils.noPermission(p);
- }
- return false;
- }
-}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index bb0c71a..665c5ff 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,10 +1,10 @@
name: ${project.artifactId}
description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
-version: ${project.version}
+version: ${project.version}-git-${env.GIT_COMMIT}
author: 喵♂呜
-website: http://ci.sumcraft.net:8080/job/${project.artifactId}/
-depended: [Vault]
+website: ${ciManagement.url}
+depend: [Vault]
commands:
lucklottery:
aliases: [ll]
@@ -19,6 +19,9 @@ permissions:
lucklottery.look: true
lucklottery.clear: true
lucklottery.reload: true
+ lucklottery.status:
+ description: 允许查看彩票状态!
+ default: op
lucklottery.showall:
description: 允许查看所有已购买彩票!
default: op