parent
e17022ab40
commit
5a52046d0d
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cn.CityCraft</groupId>
|
||||
<artifactId>LuckLottery</artifactId>
|
||||
<version>0.0.5-SNAPSHOT</version>
|
||||
<version>0.0.6-SNAPSHOT</version>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String> messages = OfflineDate.getMessage(p.getName());
|
||||
if (messages != null && !messages.isEmpty()) {
|
||||
|
|
|
@ -33,8 +33,8 @@ public class LotteryReward implements Runnable {
|
|||
+ LotteryUtils.getSystemLottery().toString());
|
||||
ChatUtils.broadcastMessage(ChatColor.BLUE + "使用命令: " + ChatColor.RED
|
||||
+ "/ll" + ChatColor.BLUE + " 或闹钟菜单可以购买彩票!");
|
||||
for (Entry<String, List<List<String>>> players : LotteryUtils
|
||||
.getPlayerLottery().entrySet()) {
|
||||
for (Entry<String, List<List<String>>> players : LotteryUtils.playerLottery
|
||||
.entrySet()) {
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
|
||||
List<List<String>> 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();
|
||||
}
|
||||
|
|
|
@ -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(管理员命令)"
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import cn.citycraft.LuckLottery.runnable.LotteryReward;
|
|||
public class LotteryUtils {
|
||||
protected static List<String> systemLottery = new ArrayList<String>();
|
||||
|
||||
protected static Map<String, List<List<String>>> playerLottery = new HashMap<String, List<List<String>>>();
|
||||
public static Map<String, List<List<String>>> playerLottery = new HashMap<String, List<List<String>>>();
|
||||
|
||||
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<String, List<List<String>>> phas : playerLottery.entrySet()) {
|
||||
ChatUtils.sendMessage(sender, "§6玩家: §a" + phas.getKey()
|
||||
+ "§6购买的彩票有");
|
||||
for (List<String> lry : phas.getValue()) {
|
||||
has = true;
|
||||
ChatUtils.sendMessage(sender, "§a" + lry.toString());
|
||||
}
|
||||
}
|
||||
if (!has) {
|
||||
ChatUtils.sendMessage(sender, "§d没有玩家购买本轮彩票...");
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearLottery() {
|
||||
for (Entry<String, List<List<String>>> 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<String, List<List<String>>> getPlayerLottery() {
|
||||
return playerLottery;
|
||||
}
|
||||
|
||||
public static void setPlayerLottery(
|
||||
HashMap<String, List<List<String>>> playerLottery) {
|
||||
LotteryUtils.playerLottery = playerLottery;
|
||||
}
|
||||
|
||||
public static void updateSystemLottery() {
|
||||
LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
@ -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]
|
||||
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
|
Loading…
Reference in New Issue