diff --git a/pom.xml b/pom.xml
index ba0ffc8..a7c1ff1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
cn.CityCraft
LuckLottery
- 0.0.5-SNAPSHOT
+ 0.0.6-SNAPSHOT
src
diff --git a/src/cn/citycraft/LuckLottery/LuckLottery.java b/src/cn/citycraft/LuckLottery/LuckLottery.java
index 9d29336..0c3e4e0 100644
--- a/src/cn/citycraft/LuckLottery/LuckLottery.java
+++ b/src/cn/citycraft/LuckLottery/LuckLottery.java
@@ -26,11 +26,12 @@ public class LuckLottery extends JavaPlugin {
public void onLoad() {
plugin = this;
- Config.load(this, "1.1");
+ Config.load(this, "1.2");
OfflineDate.load(this);
PlayerDate.load(this);
+ LotteryUtils.reloadPlayerLottery();
ChatUtils.setPluginname(Config.getMessage("pluginname"));
-
+
LotteryUtils.setNumbersame(Config.getInstance()
.getBoolean("numbersame"));
LotteryUtils.setPrice(Config.getInstance().getInt("price"));
@@ -51,9 +52,11 @@ public class LuckLottery extends JavaPlugin {
this.getServer().getPluginManager().disablePlugin(this);
return;
}
+ int rewardtime = Config.getInstance().getInt("RewardTime", 10);
this.getServer()
.getScheduler()
- .runTaskTimer(plugin, new LotteryReward(true), 10, 10 * 60 * 20);
+ .runTaskTimer(plugin, new LotteryReward(true), 10,
+ rewardtime * 60 * 20);
this.getLogger().info("彩票系统已开启...");
pm.registerEvents(new PlayerListen(), this);
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
diff --git a/src/cn/citycraft/LuckLottery/command/LuckLotteryCommand.java b/src/cn/citycraft/LuckLottery/command/LuckLotteryCommand.java
index f725d30..55dd5fe 100644
--- a/src/cn/citycraft/LuckLottery/command/LuckLotteryCommand.java
+++ b/src/cn/citycraft/LuckLottery/command/LuckLotteryCommand.java
@@ -53,6 +53,19 @@ public class LuckLotteryCommand implements CommandExecutor {
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);
@@ -76,6 +89,15 @@ public class LuckLotteryCommand implements CommandExecutor {
}
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;
diff --git a/src/cn/citycraft/LuckLottery/listen/PlayerListen.java b/src/cn/citycraft/LuckLottery/listen/PlayerListen.java
index c15f022..40c47af 100644
--- a/src/cn/citycraft/LuckLottery/listen/PlayerListen.java
+++ b/src/cn/citycraft/LuckLottery/listen/PlayerListen.java
@@ -25,7 +25,6 @@ public class PlayerListen implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerJoinEvent e) {
- LotteryUtils.loadPlayerLottery(e.getPlayer());
Player p = e.getPlayer();
List messages = OfflineDate.getMessage(p.getName());
if (messages != null && !messages.isEmpty()) {
diff --git a/src/cn/citycraft/LuckLottery/runnable/LotteryReward.java b/src/cn/citycraft/LuckLottery/runnable/LotteryReward.java
index bba11ed..5129628 100644
--- a/src/cn/citycraft/LuckLottery/runnable/LotteryReward.java
+++ b/src/cn/citycraft/LuckLottery/runnable/LotteryReward.java
@@ -33,8 +33,8 @@ public class LotteryReward implements Runnable {
+ LotteryUtils.getSystemLottery().toString());
ChatUtils.broadcastMessage(ChatColor.BLUE + "使用命令: " + ChatColor.RED
+ "/ll" + ChatColor.BLUE + " 或闹钟菜单可以购买彩票!");
- for (Entry>> players : LotteryUtils
- .getPlayerLottery().entrySet()) {
+ for (Entry>> players : LotteryUtils.playerLottery
+ .entrySet()) {
OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
List> pl = players.getValue();
if (pl != null && !pl.isEmpty())
@@ -44,25 +44,26 @@ public class LotteryReward implements Runnable {
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 + "元!");
+ 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);
+ // ChatUtils.sendMessage((Player) p, message);
} else {
OfflineDate.addMessage(p.getName(), message);
}
LuckLottery.economy.depositPlayer(p, winprices);
}
}
- LotteryUtils.getPlayerLottery().remove(p.getName());
- LotteryUtils.saveLottery();
+ LotteryUtils.playerLottery.put(players.getKey(), null);
}
+ LotteryUtils.clearLottery();
if (update)
LotteryUtils.updateSystemLottery();
}
diff --git a/src/cn/citycraft/LuckLottery/utils/ChatUtils.java b/src/cn/citycraft/LuckLottery/utils/ChatUtils.java
index 2d5dd0e..d0db4e9 100644
--- a/src/cn/citycraft/LuckLottery/utils/ChatUtils.java
+++ b/src/cn/citycraft/LuckLottery/utils/ChatUtils.java
@@ -13,8 +13,10 @@ public class ChatUtils {
"§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(管理员命令)"
};
diff --git a/src/cn/citycraft/LuckLottery/utils/LotteryUtils.java b/src/cn/citycraft/LuckLottery/utils/LotteryUtils.java
index 65cafc4..c8bb0e9 100644
--- a/src/cn/citycraft/LuckLottery/utils/LotteryUtils.java
+++ b/src/cn/citycraft/LuckLottery/utils/LotteryUtils.java
@@ -20,7 +20,7 @@ import cn.citycraft.LuckLottery.runnable.LotteryReward;
public class LotteryUtils {
protected static List systemLottery = new ArrayList();
- protected static Map>> playerLottery = new HashMap>>();
+ public static Map>> playerLottery = new HashMap>>();
protected static boolean numbersame;
@@ -79,6 +79,36 @@ public class LotteryUtils {
}
}
+ public static void showAllPlayerLottery(CommandSender sender) {
+ ChatUtils.sendMessage(sender, "§c正在检索玩家彩票数据...");
+ boolean has = false;
+ for (Entry>> phas : playerLottery.entrySet()) {
+ ChatUtils.sendMessage(sender, "§6玩家: §a" + phas.getKey()
+ + "§6购买的彩票有");
+ for (List lry : phas.getValue()) {
+ has = true;
+ ChatUtils.sendMessage(sender, "§a" + lry.toString());
+ }
+ }
+ if (!has) {
+ ChatUtils.sendMessage(sender, "§d没有玩家购买本轮彩票...");
+ }
+ }
+
+ public static void clearLottery() {
+ for (Entry>> pl : playerLottery.entrySet()) {
+ String p = pl.getKey();
+ PlayerDate.getInstance().set(p, null);
+ }
+ playerLottery.clear();
+ PlayerDate.save();
+ }
+
+ public static void clearPlayerLottery(CommandSender sender) {
+ ChatUtils.sendMessage(sender, "§c提示: 以清除所有玩家彩票数据...");
+ clearLottery();
+ }
+
public static void rewardLastLottery() {
Bukkit.getServer()
.getScheduler()
@@ -101,15 +131,6 @@ public class LotteryUtils {
public static void setPrice(int price) {
LotteryUtils.price = price;
}
-
- public static Map>> getPlayerLottery() {
- return playerLottery;
- }
-
- public static void setPlayerLottery(
- HashMap>> playerLottery) {
- LotteryUtils.playerLottery = playerLottery;
- }
public static void updateSystemLottery() {
LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
diff --git a/src/cn/citycraft/LuckLottery/utils/PermissionUtils.java b/src/cn/citycraft/LuckLottery/utils/PermissionUtils.java
index c181d62..3fd7d8d 100644
--- a/src/cn/citycraft/LuckLottery/utils/PermissionUtils.java
+++ b/src/cn/citycraft/LuckLottery/utils/PermissionUtils.java
@@ -6,12 +6,14 @@ import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
public class PermissionUtils {
- public static String Reward = "lucklottery.reward";
- public static String Random = "lucklottery.random";
- public static String Look = "lucklottery.look";
-// public static String Reward = "lucklottery.reward";
-// public static String Reward = "lucklottery.reward";
+ 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 String No_Permission = ChatColor.RED + "你没有此命令的权限!";
+
public static boolean Check(Player p,String perm){
if (p.hasPermission(perm)){
return true;
diff --git a/src/config.yml b/src/config.yml
index fd68ead..7475a06 100644
--- a/src/config.yml
+++ b/src/config.yml
@@ -1,9 +1,11 @@
#本文件为插件的主配置文件
-version: 1.1
+version: 1.2
#服务器名称
servername: ''
#插件名称
pluginname: '&6[&b彩票系统&6]&r '
+#每隔多久开奖一次(单位: 分钟)
+RewardTime: 5
#是否需要对应彩票号码位置
numbersame: true
#单张彩票价格
@@ -12,18 +14,18 @@ price: 200
#注意:请不要删除0这一行,配置错误将默认全部返还彩票价格的金钱.
Reward:
0: 0
- 1: 300
- 2: 500
- 3: 800
- 4: 1000
- 5: 2000
- 6: 3000
- 10: 500
- 11: 800
- 12: 1000
+ 1: 500
+ 2: 1000
+ 3: 1500
+ 4: 2000
+ 5: 4000
+ 6: 8000
+ 10: 800
+ 11: 1200
+ 12: 1500
13: 2000
14: 3000
15: 4000
- 16: 5000
+ 16: 10000
\ No newline at end of file
diff --git a/src/plugin.yml b/src/plugin.yml
index bd057c5..6780419 100644
--- a/src/plugin.yml
+++ b/src/plugin.yml
@@ -1,8 +1,33 @@
name: LuckLottery
main: cn.citycraft.LuckLottery.LuckLottery
author: 喵♂呜
-version: 0.0.5
+version: 0.0.6
depended: [Vault]
commands:
lucklottery:
- aliases: [ll]
\ No newline at end of file
+ aliases: [ll]
+permissions:
+ lucklottery.*:
+ description: 允许使用所有命令!
+ default: op
+ children:
+ lucklottery.showall: true
+ lucklottery.reward: true
+ lucklottery.random: true
+ lucklottery.look: true
+ lucklottery.clear: true
+ lucklottery.showall:
+ description: 允许查看所有已购买彩票!
+ default: op
+ lucklottery.reward:
+ description: 允许结算上一轮彩票!
+ default: op
+ lucklottery.random:
+ description: 允许重新生成本轮彩票!
+ default: op
+ lucklottery.look:
+ description: 允许查看本轮彩票号码!
+ default: op
+ lucklottery.clear:
+ description: 允许清理玩家彩票数据!
+ default: op
\ No newline at end of file