parent
e17022ab40
commit
5a52046d0d
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>cn.CityCraft</groupId>
|
<groupId>cn.CityCraft</groupId>
|
||||||
<artifactId>LuckLottery</artifactId>
|
<artifactId>LuckLottery</artifactId>
|
||||||
<version>0.0.5-SNAPSHOT</version>
|
<version>0.0.6-SNAPSHOT</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
|
@ -26,9 +26,10 @@ public class LuckLottery extends JavaPlugin {
|
||||||
|
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
Config.load(this, "1.1");
|
Config.load(this, "1.2");
|
||||||
OfflineDate.load(this);
|
OfflineDate.load(this);
|
||||||
PlayerDate.load(this);
|
PlayerDate.load(this);
|
||||||
|
LotteryUtils.reloadPlayerLottery();
|
||||||
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
||||||
|
|
||||||
LotteryUtils.setNumbersame(Config.getInstance()
|
LotteryUtils.setNumbersame(Config.getInstance()
|
||||||
|
@ -51,9 +52,11 @@ public class LuckLottery extends JavaPlugin {
|
||||||
this.getServer().getPluginManager().disablePlugin(this);
|
this.getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int rewardtime = Config.getInstance().getInt("RewardTime", 10);
|
||||||
this.getServer()
|
this.getServer()
|
||||||
.getScheduler()
|
.getScheduler()
|
||||||
.runTaskTimer(plugin, new LotteryReward(true), 10, 10 * 60 * 20);
|
.runTaskTimer(plugin, new LotteryReward(true), 10,
|
||||||
|
rewardtime * 60 * 20);
|
||||||
this.getLogger().info("彩票系统已开启...");
|
this.getLogger().info("彩票系统已开启...");
|
||||||
pm.registerEvents(new PlayerListen(), this);
|
pm.registerEvents(new PlayerListen(), this);
|
||||||
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
||||||
|
|
|
@ -53,6 +53,19 @@ public class LuckLotteryCommand implements CommandExecutor {
|
||||||
LotteryUtils.showPlayerLottery(p);
|
LotteryUtils.showPlayerLottery(p);
|
||||||
}
|
}
|
||||||
return true;
|
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":
|
case "random":
|
||||||
if (PermissionUtils.Check(sender, PermissionUtils.Random)) {
|
if (PermissionUtils.Check(sender, PermissionUtils.Random)) {
|
||||||
LotteryUtils.updateSystemLottery(sender);
|
LotteryUtils.updateSystemLottery(sender);
|
||||||
|
@ -76,6 +89,15 @@ public class LuckLotteryCommand implements CommandExecutor {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
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:
|
default:
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -25,7 +25,6 @@ public class PlayerListen implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerInteract(PlayerJoinEvent e) {
|
public void onPlayerInteract(PlayerJoinEvent e) {
|
||||||
LotteryUtils.loadPlayerLottery(e.getPlayer());
|
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
List<String> messages = OfflineDate.getMessage(p.getName());
|
List<String> messages = OfflineDate.getMessage(p.getName());
|
||||||
if (messages != null && !messages.isEmpty()) {
|
if (messages != null && !messages.isEmpty()) {
|
||||||
|
|
|
@ -33,8 +33,8 @@ public class LotteryReward implements Runnable {
|
||||||
+ LotteryUtils.getSystemLottery().toString());
|
+ LotteryUtils.getSystemLottery().toString());
|
||||||
ChatUtils.broadcastMessage(ChatColor.BLUE + "使用命令: " + ChatColor.RED
|
ChatUtils.broadcastMessage(ChatColor.BLUE + "使用命令: " + ChatColor.RED
|
||||||
+ "/ll" + ChatColor.BLUE + " 或闹钟菜单可以购买彩票!");
|
+ "/ll" + ChatColor.BLUE + " 或闹钟菜单可以购买彩票!");
|
||||||
for (Entry<String, List<List<String>>> players : LotteryUtils
|
for (Entry<String, List<List<String>>> players : LotteryUtils.playerLottery
|
||||||
.getPlayerLottery().entrySet()) {
|
.entrySet()) {
|
||||||
OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
|
OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
|
||||||
List<List<String>> pl = players.getValue();
|
List<List<String>> pl = players.getValue();
|
||||||
if (pl != null && !pl.isEmpty())
|
if (pl != null && !pl.isEmpty())
|
||||||
|
@ -44,25 +44,26 @@ public class LotteryReward implements Runnable {
|
||||||
winprices = Config.getInstance().getInt("Reward." + win,
|
winprices = Config.getInstance().getInt("Reward." + win,
|
||||||
200);
|
200);
|
||||||
if (winprices > 0) {
|
if (winprices > 0) {
|
||||||
ChatUtils.broadcastMessage(ChatColor.GREEN + p.getName() +"的彩票: "
|
ChatUtils.broadcastMessage(ChatColor.GREEN
|
||||||
+ ChatColor.YELLOW + playerlottery.toString()
|
+ p.getName() + "的彩票: " + ChatColor.YELLOW
|
||||||
+ ChatColor.GREEN + "获得了" + ChatColor.GOLD
|
+ playerlottery.toString() + ChatColor.GREEN
|
||||||
+ winprices + ChatColor.GREEN + "元!");
|
+ "获得了" + ChatColor.GOLD + winprices
|
||||||
|
+ ChatColor.GREEN + "元!");
|
||||||
String message = ChatColor.GREEN + "您的彩票: "
|
String message = ChatColor.GREEN + "您的彩票: "
|
||||||
+ ChatColor.YELLOW + playerlottery.toString()
|
+ ChatColor.YELLOW + playerlottery.toString()
|
||||||
+ ChatColor.GREEN + "获得了" + ChatColor.GOLD
|
+ ChatColor.GREEN + "获得了" + ChatColor.GOLD
|
||||||
+ winprices + ChatColor.GREEN + "元!";
|
+ winprices + ChatColor.GREEN + "元!";
|
||||||
if (p.isOnline()) {
|
if (p.isOnline()) {
|
||||||
//ChatUtils.sendMessage((Player) p, message);
|
// ChatUtils.sendMessage((Player) p, message);
|
||||||
} else {
|
} else {
|
||||||
OfflineDate.addMessage(p.getName(), message);
|
OfflineDate.addMessage(p.getName(), message);
|
||||||
}
|
}
|
||||||
LuckLottery.economy.depositPlayer(p, winprices);
|
LuckLottery.economy.depositPlayer(p, winprices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LotteryUtils.getPlayerLottery().remove(p.getName());
|
LotteryUtils.playerLottery.put(players.getKey(), null);
|
||||||
LotteryUtils.saveLottery();
|
|
||||||
}
|
}
|
||||||
|
LotteryUtils.clearLottery();
|
||||||
if (update)
|
if (update)
|
||||||
LotteryUtils.updateSystemLottery();
|
LotteryUtils.updateSystemLottery();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,10 @@ public class ChatUtils {
|
||||||
"§6=========彩票插件帮助========",
|
"§6=========彩票插件帮助========",
|
||||||
"§a/ll 打开彩票购买界面",
|
"§a/ll 打开彩票购买界面",
|
||||||
"§b/ll show 查看已购买彩票",
|
"§b/ll show 查看已购买彩票",
|
||||||
|
"§3/ll showall查看所以玩家已购买彩票§4(管理员命令)",
|
||||||
"§c/ll random 重新生成彩票§4(管理员命令)",
|
"§c/ll random 重新生成彩票§4(管理员命令)",
|
||||||
"§d/ll reward 结算上一轮彩票§4(管理员命令)",
|
"§d/ll reward 结算上一轮彩票§4(管理员命令)",
|
||||||
|
"§e/ll clear 清除所有已购买彩票§4(管理员命令)",
|
||||||
"§5/ll look 查看本轮彩票号码§4(管理员命令)"
|
"§5/ll look 查看本轮彩票号码§4(管理员命令)"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import cn.citycraft.LuckLottery.runnable.LotteryReward;
|
||||||
public class LotteryUtils {
|
public class LotteryUtils {
|
||||||
protected static List<String> systemLottery = new ArrayList<String>();
|
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;
|
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() {
|
public static void rewardLastLottery() {
|
||||||
Bukkit.getServer()
|
Bukkit.getServer()
|
||||||
.getScheduler()
|
.getScheduler()
|
||||||
|
@ -102,15 +132,6 @@ public class LotteryUtils {
|
||||||
LotteryUtils.price = 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() {
|
public static void updateSystemLottery() {
|
||||||
LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
|
LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,14 @@ import org.bukkit.entity.Player;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
public class PermissionUtils {
|
public class PermissionUtils {
|
||||||
public static String Reward = "lucklottery.reward";
|
public static final String ShowAll = "lucklottery.showall";
|
||||||
public static String Random = "lucklottery.random";
|
public static final String Reward = "lucklottery.reward";
|
||||||
public static String Look = "lucklottery.look";
|
public static final String Random = "lucklottery.random";
|
||||||
// public static String Reward = "lucklottery.reward";
|
public static final String Look = "lucklottery.look";
|
||||||
// public static String Reward = "lucklottery.reward";
|
public static final String Clear = "lucklottery.clear";
|
||||||
|
|
||||||
public static String No_Permission = ChatColor.RED + "你没有此命令的权限!";
|
public static String No_Permission = ChatColor.RED + "你没有此命令的权限!";
|
||||||
|
|
||||||
public static boolean Check(Player p,String perm){
|
public static boolean Check(Player p,String perm){
|
||||||
if (p.hasPermission(perm)){
|
if (p.hasPermission(perm)){
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#本文件为插件的主配置文件
|
#本文件为插件的主配置文件
|
||||||
version: 1.1
|
version: 1.2
|
||||||
#服务器名称
|
#服务器名称
|
||||||
servername: ''
|
servername: ''
|
||||||
#插件名称
|
#插件名称
|
||||||
pluginname: '&6[&b彩票系统&6]&r '
|
pluginname: '&6[&b彩票系统&6]&r '
|
||||||
|
#每隔多久开奖一次(单位: 分钟)
|
||||||
|
RewardTime: 5
|
||||||
#是否需要对应彩票号码位置
|
#是否需要对应彩票号码位置
|
||||||
numbersame: true
|
numbersame: true
|
||||||
#单张彩票价格
|
#单张彩票价格
|
||||||
|
@ -12,18 +14,18 @@ price: 200
|
||||||
#注意:请不要删除0这一行,配置错误将默认全部返还彩票价格的金钱.
|
#注意:请不要删除0这一行,配置错误将默认全部返还彩票价格的金钱.
|
||||||
Reward:
|
Reward:
|
||||||
0: 0
|
0: 0
|
||||||
1: 300
|
1: 500
|
||||||
2: 500
|
2: 1000
|
||||||
3: 800
|
3: 1500
|
||||||
4: 1000
|
4: 2000
|
||||||
5: 2000
|
5: 4000
|
||||||
6: 3000
|
6: 8000
|
||||||
10: 500
|
10: 800
|
||||||
11: 800
|
11: 1200
|
||||||
12: 1000
|
12: 1500
|
||||||
13: 2000
|
13: 2000
|
||||||
14: 3000
|
14: 3000
|
||||||
15: 4000
|
15: 4000
|
||||||
16: 5000
|
16: 10000
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,33 @@
|
||||||
name: LuckLottery
|
name: LuckLottery
|
||||||
main: cn.citycraft.LuckLottery.LuckLottery
|
main: cn.citycraft.LuckLottery.LuckLottery
|
||||||
author: 喵♂呜
|
author: 喵♂呜
|
||||||
version: 0.0.5
|
version: 0.0.6
|
||||||
depended: [Vault]
|
depended: [Vault]
|
||||||
commands:
|
commands:
|
||||||
lucklottery:
|
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