mirror of
https://e.coding.net/circlecloud/LuckLottery.git
synced 2025-11-24 21:46:23 +00:00
25
.classpath
25
.classpath
@@ -1,25 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||||
<attributes>
|
<classpathentry kind="src" output="target/classes" path="src/main/resources"/>
|
||||||
<attribute name="optional" value="true"/>
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
57
pom.xml
57
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>1.2</version>
|
<version>1.3</version>
|
||||||
<build>
|
<build>
|
||||||
<finalName>${project.name}</finalName>
|
<finalName>${project.name}</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.7</source>
|
<source>1.7</source>
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
@@ -30,14 +30,14 @@
|
|||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>true</minimizeJar>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
|
<include>pw.yumc:YumCore</include>
|
||||||
<include>cn.citycraft:PluginHelper</include>
|
<include>cn.citycraft:PluginHelper</include>
|
||||||
<include>org.mcstats.*:*</include>
|
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.mcstats</pattern>
|
<pattern>pw.yumc.YumCore</pattern>
|
||||||
<shadedPattern>${project.groupId}.${project.artifactId}.mcstats</shadedPattern>
|
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>cn.citycraft.PluginHelper</pattern>
|
<pattern>cn.citycraft.PluginHelper</pattern>
|
||||||
@@ -56,34 +56,28 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<ciManagement>
|
||||||
|
<system>Jenkins</system>
|
||||||
|
<url>http://ci.yumc.pw/job/${project.artifactId}/</url>
|
||||||
|
</ciManagement>
|
||||||
|
<properties>
|
||||||
|
<update.description></update.description>
|
||||||
|
<update.changes></update.changes>
|
||||||
|
<env.GIT_COMMIT>DEBUG</env.GIT_COMMIT>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
|
||||||
<id>mengcraft-repo</id>
|
|
||||||
<url>http://ci.mengcraft.com:8080/plugin/repository/everything/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>vault-repo</id>
|
|
||||||
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>citycraft-repo</id>
|
|
||||||
<url>http://ci.sumcraft.net:8080/plugin/repository/everything/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>Plugin Metrics</id>
|
|
||||||
<url>http://repo.mcstats.org/content/repositories/public</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.citycraft</groupId>
|
<groupId>cn.citycraft</groupId>
|
||||||
@@ -92,20 +86,15 @@
|
|||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>pw.yumc</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>YumCore</artifactId>
|
||||||
<version>1.5</version>
|
<type>jar</type>
|
||||||
<scope>system</scope>
|
<version>1.0</version>
|
||||||
<systemPath>${project.basedir}/lib/Vault.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mcstats.bukkit</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
<artifactId>metrics</artifactId>
|
<artifactId>Vault</artifactId>
|
||||||
<version>R8-SNAPSHOT</version>
|
<version>1.5.6</version>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
</project>
|
</project>
|
||||||
@@ -6,6 +6,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import cn.citycraft.LuckLottery.command.LuckLotteryCommand;
|
import cn.citycraft.LuckLottery.command.LuckLotteryCommand;
|
||||||
import cn.citycraft.LuckLottery.config.OfflineDate;
|
import cn.citycraft.LuckLottery.config.OfflineDate;
|
||||||
|
import cn.citycraft.LuckLottery.config.PlayerData;
|
||||||
import cn.citycraft.LuckLottery.listen.PlayerListen;
|
import cn.citycraft.LuckLottery.listen.PlayerListen;
|
||||||
import cn.citycraft.LuckLottery.runnable.LotteryReward;
|
import cn.citycraft.LuckLottery.runnable.LotteryReward;
|
||||||
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
||||||
@@ -15,75 +16,68 @@ import cn.citycraft.PluginHelper.utils.VersionChecker;
|
|||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
public class LuckLottery extends JavaPlugin {
|
public class LuckLottery extends JavaPlugin {
|
||||||
public static Economy economy = null;
|
public static Economy economy = null;
|
||||||
public static boolean isEconomy;
|
public static boolean isEconomy;
|
||||||
public static LuckLottery plugin;
|
public static LuckLottery plugin;
|
||||||
protected FileConfig config;
|
protected FileConfig config;
|
||||||
protected OfflineDate offlinedata;
|
protected OfflineDate offlinedata;
|
||||||
protected FileConfig playerdata;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileConfig getConfig() {
|
public FileConfig getConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OfflineDate getOfflineData() {
|
public OfflineDate getOfflineData() {
|
||||||
return offlinedata;
|
return offlinedata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileConfig getPlayerdata() {
|
@Override
|
||||||
return playerdata;
|
public void onDisable() {
|
||||||
}
|
this.getLogger().info("保存彩票数据中...");
|
||||||
|
this.getLogger().info("保存玩家数据中...");
|
||||||
|
PlayerData.saveLottery();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onEnable() {
|
||||||
this.getLogger().info("保存彩票数据中...");
|
final PluginManager pm = this.getServer().getPluginManager();
|
||||||
this.getLogger().info("保存玩家数据中...");
|
if (pm.getPlugin("Vault") == null && !pm.getPlugin("Vault").isEnabled()) {
|
||||||
LotteryUtils.saveLottery();
|
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
|
@Override
|
||||||
public void onEnable() {
|
public void onLoad() {
|
||||||
final PluginManager pm = this.getServer().getPluginManager();
|
plugin = this;
|
||||||
if (pm.getPlugin("Vault") == null && !pm.getPlugin("Vault").isEnabled()) {
|
config = new FileConfig(this);
|
||||||
this.getLogger().warning("未找到前置插件Vault 关闭插件...");
|
offlinedata = new OfflineDate(this);
|
||||||
this.getServer().getPluginManager().disablePlugin(this);
|
PlayerData.reloadPlayerLottery();
|
||||||
return;
|
ChatUtils.setPluginname(config.getMessage("pluginname"));
|
||||||
}
|
LotteryUtils.setNumbersame(config.getBoolean("numbersame"));
|
||||||
if (setupEconomy()) {
|
LotteryUtils.setPrice(config.getInt("price"));
|
||||||
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 boolean setupEconomy() {
|
||||||
public void onLoad() {
|
final RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||||
plugin = this;
|
if (economyProvider != null) {
|
||||||
config = new FileConfig(this);
|
economy = economyProvider.getProvider();
|
||||||
offlinedata = new OfflineDate(this);
|
}
|
||||||
playerdata = new FileConfig(this, "playerdate.yml");
|
return (economy != null);
|
||||||
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<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
|
||||||
if (economyProvider != null) {
|
|
||||||
economy = economyProvider.getProvider();
|
|
||||||
}
|
|
||||||
return (economy != null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,121 +1,106 @@
|
|||||||
package cn.citycraft.LuckLottery.command;
|
package cn.citycraft.LuckLottery.command;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import cn.citycraft.LuckLottery.LuckLottery;
|
import cn.citycraft.LuckLottery.LuckLottery;
|
||||||
|
import cn.citycraft.LuckLottery.config.PlayerData;
|
||||||
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
||||||
import cn.citycraft.LuckLottery.utils.InvUtils;
|
import cn.citycraft.LuckLottery.utils.InvUtils;
|
||||||
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
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 {
|
public class LuckLotteryCommand implements CommandExecutor {
|
||||||
|
|
||||||
LuckLottery plugin;
|
LuckLottery plugin;
|
||||||
|
|
||||||
public LuckLotteryCommand(LuckLottery main) {
|
public LuckLotteryCommand() {
|
||||||
plugin = main;
|
new CommandManager("ll").register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Cmd(permission = Perm.Clear)
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String string,
|
@Help("清除所有已购买彩票§4(管理员命令)")
|
||||||
String[] args) {
|
@Sort(6)
|
||||||
switch (args.length) {
|
public void clear(final CommandArgument e) {
|
||||||
case 0:
|
final CommandSender sender = e.getSender();
|
||||||
if (isPlayer(sender)) {
|
if (e.getArgs().length > 0) {
|
||||||
final Player p = (Player) sender;
|
ChatUtils.sendMessage(sender, ChatColor.DARK_RED + "警告: 已经清理所有彩票数据,此操作无法撤销!");
|
||||||
int price = LotteryUtils.getPrice();
|
LotteryUtils.clearPlayerLottery(sender);
|
||||||
if (LuckLottery.economy.hasAccount(p)
|
} else {
|
||||||
&& LuckLottery.economy.has(p, price)) {
|
ChatUtils.sendMessage(sender, ChatColor.LIGHT_PURPLE + "警告: 即将清理所有彩票数据,此操作将无法取消!");
|
||||||
InvUtils.openGui(p);
|
ChatUtils.sendMessage(sender, ChatColor.RED + "命令: 请使用/ll clear confirm 确定清理!");
|
||||||
} 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPlayer(CommandSender p) {
|
@Cmd(onlyPlayer = true)
|
||||||
if (p instanceof Player)
|
@Help("打开彩票购买界面")
|
||||||
return true;
|
public boolean ll(final CommandArgument e) {
|
||||||
return false;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
132
src/main/java/cn/citycraft/LuckLottery/config/PlayerData.java
Normal file
132
src/main/java/cn/citycraft/LuckLottery/config/PlayerData.java
Normal file
@@ -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<String, List<List<String>>> playerLottery = new HashMap<String, List<List<String>>>();
|
||||||
|
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<List<String>> addLottery(final Player player, final List<String> lottery) {
|
||||||
|
List<List<String>> playerhas = playerLottery.get(player.getName());
|
||||||
|
if (playerhas == null) {
|
||||||
|
playerhas = new ArrayList<List<String>>();
|
||||||
|
}
|
||||||
|
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<String, List<List<String>>> pl : playerLottery.entrySet()) {
|
||||||
|
final String p = pl.getKey();
|
||||||
|
playerdata.set(p, null);
|
||||||
|
}
|
||||||
|
playerLottery.clear();
|
||||||
|
playerdata.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, List<List<String>>> 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<List<String>>) pl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printStatus(final CommandSender sender) {
|
||||||
|
int nc = 0;
|
||||||
|
int np = 0;
|
||||||
|
int ncc = 0;
|
||||||
|
for (final List<List<String>> lls : playerLottery.values()) {
|
||||||
|
nc += lls.size();
|
||||||
|
np += LotteryUtils.getPrice();
|
||||||
|
for (final List<String> 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<String> apl = playerdata.getKeys(false);
|
||||||
|
for (final String p : apl) {
|
||||||
|
final List<?> pl = playerdata.getList(p);
|
||||||
|
if (pl != null) {
|
||||||
|
playerLottery.put(p, (List<List<String>>) 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<String, List<List<String>>> pl : playerLottery.entrySet()) {
|
||||||
|
final String p = pl.getKey();
|
||||||
|
final List<List<String>> 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<String, List<List<String>>> phas : playerLottery.entrySet()) {
|
||||||
|
ChatUtils.sendMessage(sender, "§6玩家: §a" + phas.getKey() + "§6购买的彩票有");
|
||||||
|
for (final List<String> 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<List<String>> playerhas = playerLottery.get(p.getName());
|
||||||
|
if (playerhas != null && !playerhas.isEmpty()) {
|
||||||
|
ChatUtils.sendMessage(p, "§6您当前购买的彩票有:");
|
||||||
|
for (final List<String> lry : playerhas) {
|
||||||
|
ChatUtils.sendMessage(p, "§a" + lry.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ChatUtils.sendMessage(p, "§c您当前没有购买的彩票!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import cn.citycraft.LuckLottery.LuckLottery;
|
import cn.citycraft.LuckLottery.LuckLottery;
|
||||||
|
import cn.citycraft.LuckLottery.config.PlayerData;
|
||||||
import cn.citycraft.LuckLottery.runnable.LaterShow;
|
import cn.citycraft.LuckLottery.runnable.LaterShow;
|
||||||
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
||||||
import cn.citycraft.LuckLottery.utils.InvUtils;
|
import cn.citycraft.LuckLottery.utils.InvUtils;
|
||||||
@@ -50,7 +51,7 @@ public class PlayerListen implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final List<String> lottery = InvUtils.getLotteryNumber(inv);
|
final List<String> lottery = InvUtils.getLotteryNumber(inv);
|
||||||
LotteryUtils.addLottery(p, lottery);
|
PlayerData.addLottery(p, lottery);
|
||||||
ChatUtils.sendMessage(p, "§6您当前购买的彩票号码为: " + ChatColor.GREEN + lottery.toString());
|
ChatUtils.sendMessage(p, "§6您当前购买的彩票号码为: " + ChatColor.GREEN + lottery.toString());
|
||||||
ChatUtils.howToShow(p);
|
ChatUtils.howToShow(p);
|
||||||
LuckLottery.economy.withdrawPlayer(p, LotteryUtils.getPrice());
|
LuckLottery.economy.withdrawPlayer(p, LotteryUtils.getPrice());
|
||||||
|
|||||||
@@ -8,54 +8,56 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import cn.citycraft.LuckLottery.LuckLottery;
|
import cn.citycraft.LuckLottery.LuckLottery;
|
||||||
|
import cn.citycraft.LuckLottery.config.PlayerData;
|
||||||
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
||||||
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
||||||
|
|
||||||
public class LotteryReward implements Runnable {
|
public class LotteryReward implements Runnable {
|
||||||
LuckLottery plugin;
|
LuckLottery plugin;
|
||||||
boolean update;
|
boolean update;
|
||||||
|
|
||||||
public LotteryReward(final LuckLottery plugin, final boolean b) {
|
public LotteryReward(final LuckLottery plugin, final boolean b) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
update = b;
|
update = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (LotteryUtils.getSystemLottery() == null || LotteryUtils.getSystemLottery().isEmpty()) {
|
if (LotteryUtils.getSystemLottery() == null || LotteryUtils.getSystemLottery().isEmpty()) {
|
||||||
LotteryUtils.updateSystemLottery();
|
LotteryUtils.updateSystemLottery();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ChatUtils.broadcastMessage(ChatColor.GOLD + "本轮彩票开奖: " + ChatColor.RED + LotteryUtils.getSystemLottery().toString());
|
ChatUtils.broadcastMessage(ChatColor.GOLD + "本轮彩票开奖: " + ChatColor.RED + LotteryUtils.getSystemLottery().toString());
|
||||||
ChatUtils.broadcastMessage(ChatColor.BLUE + "使用命令: " + ChatColor.RED + "/ll" + ChatColor.BLUE + " 或闹钟菜单可以购买彩票!");
|
ChatUtils.broadcastMessage(ChatColor.BLUE + "使用命令: " + ChatColor.RED + "/ll" + ChatColor.BLUE + " 或闹钟菜单可以购买彩票!");
|
||||||
for (final Entry<String, List<List<String>>> players : LotteryUtils.playerLottery.entrySet()) {
|
int priceTotal = 0;
|
||||||
final OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
|
for (final Entry<String, List<List<String>>> players : PlayerData.playerLottery.entrySet()) {
|
||||||
final List<List<String>> pl = players.getValue();
|
final OfflinePlayer p = Bukkit.getOfflinePlayer(players.getKey());
|
||||||
if (pl != null && !pl.isEmpty()) {
|
final List<List<String>> pl = players.getValue();
|
||||||
for (final List<String> playerlottery : pl) {
|
if (pl != null && !pl.isEmpty()) {
|
||||||
final int win = LotteryUtils.getSameNumber(playerlottery);
|
for (final List<String> playerlottery : pl) {
|
||||||
int winprices = 0;
|
final int win = LotteryUtils.getSameNumber(playerlottery);
|
||||||
winprices = plugin.getConfig().getInt("Reward." + win, 200);
|
int winprices = 0;
|
||||||
if (winprices > 0) {
|
winprices = plugin.getConfig().getInt("Reward." + win, 200);
|
||||||
ChatUtils.broadcastMessage(
|
if (winprices > 0) {
|
||||||
ChatColor.GREEN + p.getName() + "的彩票: " + ChatColor.YELLOW + playerlottery.toString() + ChatColor.GREEN + "获得了" + ChatColor.GOLD + winprices + ChatColor.GREEN + "元!");
|
priceTotal += winprices;
|
||||||
final String message = ChatColor.GREEN + "您的彩票: " + ChatColor.YELLOW + playerlottery.toString() + ChatColor.GREEN + "获得了" + ChatColor.GOLD + winprices + ChatColor.GREEN + "元!";
|
ChatUtils.broadcastMessage(
|
||||||
if (p.isOnline()) {
|
ChatColor.GREEN + p.getName() + "的彩票: " + ChatColor.YELLOW + playerlottery.toString() + ChatColor.GREEN + "获得了" + ChatColor.GOLD + winprices + ChatColor.GREEN + "元!");
|
||||||
// ChatUtils.sendMessage((Player) p, message);
|
final String message = ChatColor.GREEN + "您的彩票: " + ChatColor.YELLOW + playerlottery.toString() + ChatColor.GREEN + "获得了" + ChatColor.GOLD + winprices + ChatColor.GREEN + "元!";
|
||||||
} else {
|
if (!p.isOnline()) {
|
||||||
plugin.getOfflineData().addMessage(p.getName(), message);
|
plugin.getOfflineData().addMessage(p.getName(), message);
|
||||||
}
|
}
|
||||||
LuckLottery.economy.depositPlayer(p, winprices);
|
LuckLottery.economy.depositPlayer(p, winprices);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LotteryUtils.playerLottery.put(players.getKey(), null);
|
PlayerData.reward(priceTotal);
|
||||||
}
|
PlayerData.playerLottery.put(players.getKey(), null);
|
||||||
LotteryUtils.clearLottery();
|
}
|
||||||
if (update) {
|
PlayerData.clearLottery();
|
||||||
LotteryUtils.updateSystemLottery();
|
if (update) {
|
||||||
}
|
LotteryUtils.updateSystemLottery();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,70 +8,31 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class ChatUtils {
|
public class ChatUtils {
|
||||||
protected static String pluginname = "";
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPluginname(String pluginname) {
|
public static void broadcastMessage(final String message) {
|
||||||
ChatUtils.pluginname = pluginname;
|
Bukkit.broadcastMessage(pluginname + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendMessage(Player p, String message) {
|
public static String getPluginname() {
|
||||||
p.sendMessage(pluginname + message);
|
return pluginname;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 void sendMessage(Player p, List<String> messages) {
|
public static void howToShow(final Player p) {
|
||||||
for (String msg : messages) {
|
sendMessage(p, ChatColor.GOLD + "命令: " + ChatColor.RED + "/ll show " + ChatColor.GOLD + "查看已购买彩票!");
|
||||||
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(Player p) {
|
public static void sendMessage(final CommandSender p, final String message) {
|
||||||
sendMessage(p, ChatColor.GOLD + "命令: " + ChatColor.RED + "/ll show "
|
p.sendMessage(pluginname + message);
|
||||||
+ ChatColor.GOLD + "查看已购买彩票!");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void noPermission(Player p) {
|
public static void sendMessage(final Player p, final List<String> messages) {
|
||||||
ChatUtils.sendMessage(p, PermissionUtils.No_Permission);
|
for (final String msg : messages) {
|
||||||
}
|
sendMessage(p, msg);
|
||||||
|
}
|
||||||
public static void noPermission(CommandSender p) {
|
}
|
||||||
ChatUtils.sendMessage(p, PermissionUtils.No_Permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public static void setPluginname(final String pluginname) {
|
||||||
|
ChatUtils.pluginname = pluginname;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,265 +13,217 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
public class InvUtils {
|
public class InvUtils {
|
||||||
|
|
||||||
public static final String InvName = ChatUtils.getPluginname() + " §c§l售价: "
|
public static final String InvName = ChatUtils.getPluginname() + " §c§l售价: " + LotteryUtils.getPrice() + "元一份";
|
||||||
+ LotteryUtils.getPrice() + "元一份";
|
|
||||||
|
|
||||||
public static final String NumPrefix = "§6§l";
|
public static final String NumPrefix = "§6§l";
|
||||||
public static final String Normal1 = "§6§l1";
|
public static final String Normal1 = "§6§l1";
|
||||||
public static final String Normal2 = "§6§l2";
|
public static final String Normal2 = "§6§l2";
|
||||||
public static final String Normal3 = "§6§l3";
|
public static final String Normal3 = "§6§l3";
|
||||||
public static final String Normal4 = "§6§l4";
|
public static final String Normal4 = "§6§l4";
|
||||||
public static final String Normal5 = "§6§l5";
|
public static final String Normal5 = "§6§l5";
|
||||||
public static final String Normal6 = "§6§l6";
|
public static final String Normal6 = "§6§l6";
|
||||||
public static final String Normal7 = "§6§l7";
|
public static final String Normal7 = "§6§l7";
|
||||||
public static final String Normal8 = "§6§l8";
|
public static final String Normal8 = "§6§l8";
|
||||||
public static final String Normal9 = "§6§l9";
|
public static final String Normal9 = "§6§l9";
|
||||||
|
|
||||||
public static final String Normal10 = "§6§l10";
|
public static final String Normal10 = "§6§l10";
|
||||||
public static final String Normal11 = "§6§l11";
|
public static final String Normal11 = "§6§l11";
|
||||||
public static final String Normal12 = "§6§l12";
|
public static final String Normal12 = "§6§l12";
|
||||||
public static final String Normal13 = "§6§l13";
|
public static final String Normal13 = "§6§l13";
|
||||||
public static final String Normal14 = "§6§l14";
|
public static final String Normal14 = "§6§l14";
|
||||||
public static final String Normal15 = "§6§l15";
|
public static final String Normal15 = "§6§l15";
|
||||||
public static final String Normal16 = "§6§l16";
|
public static final String Normal16 = "§6§l16";
|
||||||
public static final String Normal17 = "§6§l17";
|
public static final String Normal17 = "§6§l17";
|
||||||
public static final String Normal18 = "§6§l18";
|
public static final String Normal18 = "§6§l18";
|
||||||
public static final String Normal19 = "§6§l19";
|
public static final String Normal19 = "§6§l19";
|
||||||
|
|
||||||
public static final String Normal20 = "§6§l20";
|
public static final String Normal20 = "§6§l20";
|
||||||
public static final String Normal21 = "§6§l21";
|
public static final String Normal21 = "§6§l21";
|
||||||
public static final String Normal22 = "§6§l22";
|
public static final String Normal22 = "§6§l22";
|
||||||
public static final String Normal23 = "§6§l23";
|
public static final String Normal23 = "§6§l23";
|
||||||
public static final String Normal24 = "§6§l24";
|
public static final String Normal24 = "§6§l24";
|
||||||
public static final String Normal25 = "§6§l25";
|
public static final String Normal25 = "§6§l25";
|
||||||
public static final String Normal26 = "§6§l26";
|
public static final String Normal26 = "§6§l26";
|
||||||
public static final String Normal27 = "§6§l27";
|
public static final String Normal27 = "§6§l27";
|
||||||
public static final String Normal28 = "§6§l28";
|
public static final String Normal28 = "§6§l28";
|
||||||
public static final String Normal29 = "§6§l29";
|
public static final String Normal29 = "§6§l29";
|
||||||
|
|
||||||
public static final String Normal30 = "§6§l30";
|
public static final String Normal30 = "§6§l30";
|
||||||
public static final String Normal31 = "§6§l31";
|
public static final String Normal31 = "§6§l31";
|
||||||
public static final String Normal32 = "§6§l32";
|
public static final String Normal32 = "§6§l32";
|
||||||
// public static final String Special1 = "§b§l1";
|
// public static final String Special1 = "§b§l1";
|
||||||
// public static final String Special2 = "§b§l2";
|
// public static final String Special2 = "§b§l2";
|
||||||
// public static final String Special3 = "§b§l3";
|
// public static final String Special3 = "§b§l3";
|
||||||
// public static final String Special4 = "§b§l4";
|
// public static final String Special4 = "§b§l4";
|
||||||
// public static final String Special5 = "§b§l5";
|
// public static final String Special5 = "§b§l5";
|
||||||
// public static final String Special6 = "§b§l6";
|
// public static final String Special6 = "§b§l6";
|
||||||
// public static final String Special7 = "§b§l7";
|
// public static final String Special7 = "§b§l7";
|
||||||
// public static final String Special8 = "§b§l8";
|
// public static final String Special8 = "§b§l8";
|
||||||
// public static final String Special9 = "§b§l9";
|
// public static final String Special9 = "§b§l9";
|
||||||
|
|
||||||
public static final String WEB = "§c请选取=>§6橙色普通号码§r§l|§b蓝色特殊号码";
|
public static final String WEB = "§c请选取=>§6橙色普通号码§r§l|§b蓝色特殊号码";
|
||||||
public static final String ReSet = "§4§l重新选取";
|
public static final String ReSet = "§4§l重新选取";
|
||||||
public static final String Create = "§a§l生成彩票";
|
public static final String Create = "§a§l生成彩票";
|
||||||
public static final String CantCreate = "§c§l请选取§66个普通号码§b1个特殊号码§a生成彩票";
|
public static final String CantCreate = "§c§l请选取§66个普通号码§b1个特殊号码§a生成彩票";
|
||||||
|
|
||||||
// private static final ItemStack L0 = new
|
// private static final ItemStack L0 = new
|
||||||
// ItemStack(Material.DOUBLE_PLANT,1,(short)0);
|
// ItemStack(Material.DOUBLE_PLANT,1,(short)0);
|
||||||
|
|
||||||
public static final ItemStack L0 = new ItemStack(Material.WOOL);
|
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 L1 = new ItemStack(Material.WOOL, 1, (short) 1);
|
||||||
public static final ItemStack L2 = new ItemStack(Material.WOOL, 1, (short) 2);
|
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 L3 = new ItemStack(Material.WOOL, 1, (short) 3);
|
||||||
public static final ItemStack L4 = new ItemStack(Material.WOOL, 1, (short) 4);
|
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 L5 = new ItemStack(Material.WOOL, 1, (short) 5);
|
||||||
public static final ItemStack L6 = new ItemStack(Material.WOOL, 1, (short) 6);
|
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 L7 = new ItemStack(Material.WOOL, 1, (short) 7);
|
||||||
public static final ItemStack L8 = new ItemStack(Material.WOOL, 1, (short) 8);
|
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 L9 = new ItemStack(Material.WOOL, 1, (short) 9);
|
||||||
public static final ItemStack L10 = new ItemStack(Material.WOOL, 1, (short) 10);
|
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 L11 = new ItemStack(Material.WOOL, 1, (short) 11);
|
||||||
public static final ItemStack L12 = new ItemStack(Material.WOOL, 1, (short) 12);
|
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 L13 = new ItemStack(Material.WOOL, 1, (short) 13);
|
||||||
public static final ItemStack L14 = new ItemStack(Material.WOOL, 1, (short) 14);
|
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 L15 = new ItemStack(Material.WOOL, 1, (short) 15);
|
||||||
|
|
||||||
public static final ItemStack B0 = new ItemStack(Material.STAINED_GLASS);
|
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 B15 = new ItemStack(Material.STAINED_GLASS, 1, (short) 15);
|
||||||
|
|
||||||
public static final ItemStack W = new ItemStack(Material.SNOW_BALL);
|
public static final ItemStack W = new ItemStack(Material.SNOW_BALL);
|
||||||
public static final ItemStack Creat = new ItemStack(Material.MAP);
|
public static final ItemStack Creat = new ItemStack(Material.MAP);
|
||||||
public static final ItemStack CM = new ItemStack(Material.WATER_LILY);
|
public static final ItemStack CM = new ItemStack(Material.WATER_LILY);
|
||||||
public static final ItemStack CantCreat = new ItemStack(Material.EMPTY_MAP);
|
public static final ItemStack CantCreat = new ItemStack(Material.EMPTY_MAP);
|
||||||
public static final ItemStack A = new ItemStack(Material.AIR);
|
public static final ItemStack A = new ItemStack(Material.AIR);
|
||||||
public static final ItemStack RT = new ItemStack(Material.LAVA_BUCKET);
|
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);
|
|
||||||
|
|
||||||
setDisplayName(B0, Normal17);
|
static {
|
||||||
setDisplayName(B1, Normal18);
|
setDisplayName(W, WEB);
|
||||||
setDisplayName(B2, Normal19);
|
setDisplayName(L0, Normal1);
|
||||||
setDisplayName(B3, Normal20);
|
setDisplayName(L1, Normal2);
|
||||||
setDisplayName(B4, Normal21);
|
setDisplayName(L2, Normal3);
|
||||||
setDisplayName(B5, Normal22);
|
setDisplayName(L3, Normal4);
|
||||||
setDisplayName(B6, Normal23);
|
setDisplayName(L4, Normal5);
|
||||||
setDisplayName(B7, Normal24);
|
setDisplayName(L5, Normal6);
|
||||||
setDisplayName(B8, Normal25);
|
setDisplayName(L6, Normal7);
|
||||||
setDisplayName(B9, Normal26);
|
setDisplayName(L7, Normal8);
|
||||||
setDisplayName(B10, Normal27);
|
setDisplayName(L8, Normal9);
|
||||||
setDisplayName(B11, Normal28);
|
setDisplayName(L9, Normal10);
|
||||||
setDisplayName(B12, Normal29);
|
setDisplayName(L10, Normal11);
|
||||||
setDisplayName(B13, Normal30);
|
setDisplayName(L11, Normal12);
|
||||||
setDisplayName(B14, Normal31);
|
setDisplayName(L12, Normal13);
|
||||||
setDisplayName(B15, Normal32);
|
setDisplayName(L13, Normal14);
|
||||||
|
setDisplayName(L14, Normal15);
|
||||||
|
setDisplayName(L15, Normal16);
|
||||||
|
|
||||||
setDisplayName(CM, "§6<=普通号码§r|§b特殊号码=>");
|
setDisplayName(B0, Normal17);
|
||||||
setDisplayName(RT, ReSet);
|
setDisplayName(B1, Normal18);
|
||||||
setDisplayName(CantCreat, CantCreate);
|
setDisplayName(B2, Normal19);
|
||||||
setDisplayName(Creat, Create);
|
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 = {
|
setDisplayName(CM, "§6<=普通号码§r|§b特殊号码=>");
|
||||||
W,
|
setDisplayName(RT, ReSet);
|
||||||
L0,
|
setDisplayName(CantCreat, CantCreate);
|
||||||
L1,
|
setDisplayName(Creat, Create);
|
||||||
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
|
|
||||||
/* 第六行结束 */};
|
|
||||||
|
|
||||||
private static void setDisplayName(ItemStack item, String displayName) {
|
private static final ItemStack[] GUI_LINE1 = { W, L0, L1, L2, L3, L4, L5, L6, W
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
/* 第一行结束 */ };
|
||||||
itemMeta.setDisplayName(displayName);
|
private static final ItemStack[] GUI_LINE2 = { L7, L8, L9, L10, L11, L12, L13, L14, L15
|
||||||
item.setItemMeta(itemMeta);
|
/* 第二行结束 */ };
|
||||||
}
|
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() {
|
public static ItemStack[] getGui() {
|
||||||
List<ItemStack> invgui = new ArrayList<ItemStack>();
|
final List<ItemStack> invgui = new ArrayList<ItemStack>();
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE1));
|
invgui.addAll(Arrays.asList(GUI_LINE1));
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE2));
|
invgui.addAll(Arrays.asList(GUI_LINE2));
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE3));
|
invgui.addAll(Arrays.asList(GUI_LINE3));
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE4));
|
invgui.addAll(Arrays.asList(GUI_LINE4));
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE5));
|
invgui.addAll(Arrays.asList(GUI_LINE5));
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE6));
|
invgui.addAll(Arrays.asList(GUI_LINE6));
|
||||||
return invgui.toArray(new ItemStack[0]);
|
return invgui.toArray(new ItemStack[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openGui(Player p) {
|
public static String getItemNumber(final ItemStack item) {
|
||||||
Inventory scrollInv = Bukkit.createInventory(null, 6 * 9, InvName);
|
final String num = item.getItemMeta().getDisplayName();
|
||||||
scrollInv.setContents(getGui());
|
if (num.startsWith(NumPrefix)) {
|
||||||
p.openInventory(scrollInv);
|
return num.substring(NumPrefix.length());
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isLotteryGUI(Inventory inv) {
|
public static List<String> getLotteryNumber(final Inventory inv) {
|
||||||
if (inv == null)
|
final List<String> lty = new ArrayList<String>();
|
||||||
return false;
|
for (int i = 45; i < 51; i++) {
|
||||||
return inv.getHolder() == null && inv.getTitle().equals(InvName);
|
lty.add(getItemNumber(inv.getItem(i)));
|
||||||
}
|
}
|
||||||
|
lty.add(getItemNumber(inv.getItem(52)));
|
||||||
|
return lty;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean selectFinish(Inventory inv) {
|
public static boolean isLotteryGUI(final Inventory inv) {
|
||||||
return (inv.getItem(45) != null && inv.getItem(46) != null && inv.getItem(47) != null
|
if (inv == null) {
|
||||||
&& inv.getItem(48) != null && inv.getItem(49) != null && inv.getItem(50) != null && inv
|
return false;
|
||||||
.getItem(52) != null);
|
}
|
||||||
}
|
return inv.getHolder() == null && inv.getTitle().equals(InvName);
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> getLotteryNumber(Inventory inv) {
|
public static boolean isLotteryItem(final ItemStack item) {
|
||||||
List<String> lty = new ArrayList<String>();
|
final String num = item.getItemMeta().getDisplayName();
|
||||||
for (int i = 45; i < 51; i++) {
|
return num.startsWith(NumPrefix);
|
||||||
lty.add(getItemNumber(inv.getItem(i)));
|
}
|
||||||
}
|
|
||||||
lty.add(getItemNumber(inv.getItem(52)));
|
|
||||||
return lty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getItemNumber(ItemStack item) {
|
public static void openGui(final Player p) {
|
||||||
String num = item.getItemMeta().getDisplayName();
|
final Inventory scrollInv = Bukkit.createInventory(null, 6 * 9, InvName);
|
||||||
if (num.startsWith(NumPrefix))
|
scrollInv.setContents(getGui());
|
||||||
return num.substring(NumPrefix.length());
|
p.openInventory(scrollInv);
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isLotteryItem(ItemStack item) {
|
public static boolean selectFinish(final Inventory inv) {
|
||||||
String num = item.getItemMeta().getDisplayName();
|
return (inv.getItem(45) != null
|
||||||
return num.startsWith(NumPrefix);
|
&& 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,221 +1,113 @@
|
|||||||
package cn.citycraft.LuckLottery.utils;
|
package cn.citycraft.LuckLottery.utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import cn.citycraft.LuckLottery.LuckLottery;
|
import cn.citycraft.LuckLottery.LuckLottery;
|
||||||
|
import cn.citycraft.LuckLottery.config.PlayerData;
|
||||||
import cn.citycraft.LuckLottery.runnable.LotteryReward;
|
import cn.citycraft.LuckLottery.runnable.LotteryReward;
|
||||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
|
||||||
|
|
||||||
public class LotteryUtils {
|
public class LotteryUtils {
|
||||||
public static Map<String, List<List<String>>> playerLottery = new HashMap<String, List<List<String>>>();
|
protected static LuckLottery plugin = LuckLottery.plugin;
|
||||||
protected static boolean numbersame;
|
protected static List<String> systemLottery = new ArrayList<String>();
|
||||||
protected static FileConfig playerdata;
|
protected static boolean numbersame;
|
||||||
protected static LuckLottery plugin;
|
protected static int price;
|
||||||
protected static int price;
|
|
||||||
protected static List<String> systemLottery = new ArrayList<String>();
|
|
||||||
|
|
||||||
public static List<List<String>> addLottery(final Player player, final List<String> lottery) {
|
public static void clearPlayerLottery(final CommandSender sender) {
|
||||||
List<List<String>> playerhas = playerLottery.get(player.getName());
|
ChatUtils.sendMessage(sender, "§c提示: 以清除所有玩家彩票数据...");
|
||||||
if (playerhas == null) {
|
PlayerData.clearLottery();
|
||||||
playerhas = new ArrayList<List<String>>();
|
}
|
||||||
}
|
|
||||||
playerhas.add(lottery);
|
|
||||||
playerLottery.put(player.getName(), playerhas);
|
|
||||||
playerdata.set(player.getName(), playerhas);
|
|
||||||
playerdata.save();
|
|
||||||
return playerhas;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearLottery() {
|
public static int getPrice() {
|
||||||
for (final Entry<String, List<List<String>>> pl : playerLottery.entrySet()) {
|
return price;
|
||||||
final String p = pl.getKey();
|
}
|
||||||
playerdata.set(p, null);
|
|
||||||
}
|
|
||||||
playerLottery.clear();
|
|
||||||
playerdata.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clearPlayerLottery(final CommandSender sender) {
|
public static List<String> getRandomNumber() {
|
||||||
ChatUtils.sendMessage(sender, "§c提示: 以清除所有玩家彩票数据...");
|
final Random rnd = new Random();
|
||||||
clearLottery();
|
final List<String> normal = new ArrayList<String>();
|
||||||
}
|
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() {
|
public static int getSameNumber(final List<String> lottery) {
|
||||||
return price;
|
return getSameNumber(lottery, systemLottery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getRandomNumber() {
|
public static int getSameNumber(final List<String> lottery, final List<String> system) {
|
||||||
final Random rnd = new Random();
|
int samenum = 0;
|
||||||
final List<String> normal = new ArrayList<String>();
|
if (numbersame) {
|
||||||
for (int i = 1; i < 8; i++) {
|
for (int i = 0; i < lottery.size(); i++) {
|
||||||
String rr = rnd.nextInt(32) + 1 + "";
|
if (lottery.get(i).equals(system.get(i))) {
|
||||||
while (normal.contains(rr)) {
|
samenum++;
|
||||||
rr = rnd.nextInt(32) + 1 + "";
|
}
|
||||||
}
|
}
|
||||||
normal.add(rr);
|
} else {
|
||||||
}
|
for (final String pn : lottery) {
|
||||||
return normal;
|
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<String> lottery) {
|
public static List<String> getSystemLottery() {
|
||||||
int samenum = 0;
|
return systemLottery;
|
||||||
final List<String> 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 int getSameNumber(final List<String> lottery, final List<String> system) {
|
/**
|
||||||
int samenum = 0;
|
* @return numbersame
|
||||||
if (numbersame) {
|
*/
|
||||||
for (int i = 0; i < lottery.size(); i++) {
|
public static boolean isNumbersame() {
|
||||||
if (lottery.get(i).equals(system.get(i))) {
|
return numbersame;
|
||||||
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<String> getSystemLottery() {
|
public static void rewardLastLottery() {
|
||||||
return systemLottery;
|
Bukkit.getServer().getScheduler().runTaskAsynchronously(plugin, new LotteryReward(plugin, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init(final LuckLottery luckLottery) {
|
/**
|
||||||
plugin = luckLottery;
|
* @param numbersame
|
||||||
playerdata = plugin.getPlayerdata();
|
* 要设置的 numbersame
|
||||||
}
|
*/
|
||||||
|
public static void setNumbersame(final boolean numbersame) {
|
||||||
|
LotteryUtils.numbersame = numbersame;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public static void setPrice(final int price) {
|
||||||
* @return numbersame
|
LotteryUtils.price = price;
|
||||||
*/
|
}
|
||||||
public static boolean isNumbersame() {
|
|
||||||
return numbersame;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public static void setSystemLottery(final List<String> systemLottery) {
|
||||||
public static void loadPlayerLottery(final Player p) {
|
LotteryUtils.systemLottery = systemLottery;
|
||||||
final List<?> pl = playerdata.getList(p.getName());
|
}
|
||||||
if (pl != null) {
|
|
||||||
playerLottery.put(p.getName(), (List<List<String>>) pl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public static void showSystemLottery(final CommandSender p) {
|
||||||
public static void reloadPlayerLottery() {
|
ChatUtils.sendMessage(p, ChatColor.DARK_PURPLE + "此轮彩票号码为: " + ChatColor.YELLOW + LotteryUtils.systemLottery.toString());
|
||||||
final Set<String> apl = playerdata.getKeys(false);
|
}
|
||||||
for (final String p : apl) {
|
|
||||||
final List<?> pl = playerdata.getList(p);
|
|
||||||
if (pl != null) {
|
|
||||||
playerLottery.put(p, (List<List<String>>) pl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void rewardLastLottery() {
|
public static void updateSystemLottery() {
|
||||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(LuckLottery.plugin, new LotteryReward(plugin, true));
|
LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveLottery() {
|
public static void updateSystemLottery(final CommandSender p) {
|
||||||
for (final Entry<String, List<List<String>>> pl : playerLottery.entrySet()) {
|
LotteryUtils.systemLottery = LotteryUtils.getRandomNumber();
|
||||||
final String p = pl.getKey();
|
ChatUtils.sendMessage(p, ChatColor.BLUE + "已随机生成彩票: " + ChatColor.YELLOW + LotteryUtils.systemLottery.toString());
|
||||||
final List<List<String>> 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<String> systemLottery) {
|
|
||||||
LotteryUtils.systemLottery = systemLottery;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showAllPlayerLottery(final CommandSender sender) {
|
|
||||||
ChatUtils.sendMessage(sender, "§c正在检索玩家彩票数据...");
|
|
||||||
boolean has = false;
|
|
||||||
for (final Entry<String, List<List<String>>> phas : playerLottery.entrySet()) {
|
|
||||||
ChatUtils.sendMessage(sender, "§6玩家: §a" + phas.getKey() + "§6购买的彩票有");
|
|
||||||
for (final List<String> 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<List<String>> playerhas = playerLottery.get(p.getName());
|
|
||||||
if (playerhas != null && !playerhas.isEmpty()) {
|
|
||||||
ChatUtils.sendMessage(p, "§6您当前购买的彩票有:");
|
|
||||||
for (final List<String> 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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/main/java/cn/citycraft/LuckLottery/utils/Perm.java
Normal file
11
src/main/java/cn/citycraft/LuckLottery/utils/Perm.java
Normal file
@@ -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";
|
||||||
|
}
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
name: ${project.artifactId}
|
name: ${project.artifactId}
|
||||||
description: ${project.description}
|
description: ${project.description}
|
||||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||||
version: ${project.version}
|
version: ${project.version}-git-${env.GIT_COMMIT}
|
||||||
author: 喵♂呜
|
author: 喵♂呜
|
||||||
website: http://ci.sumcraft.net:8080/job/${project.artifactId}/
|
website: ${ciManagement.url}
|
||||||
depended: [Vault]
|
depend: [Vault]
|
||||||
commands:
|
commands:
|
||||||
lucklottery:
|
lucklottery:
|
||||||
aliases: [ll]
|
aliases: [ll]
|
||||||
@@ -19,6 +19,9 @@ permissions:
|
|||||||
lucklottery.look: true
|
lucklottery.look: true
|
||||||
lucklottery.clear: true
|
lucklottery.clear: true
|
||||||
lucklottery.reload: true
|
lucklottery.reload: true
|
||||||
|
lucklottery.status:
|
||||||
|
description: 允许查看彩票状态!
|
||||||
|
default: op
|
||||||
lucklottery.showall:
|
lucklottery.showall:
|
||||||
description: 允许查看所有已购买彩票!
|
description: 允许查看所有已购买彩票!
|
||||||
default: op
|
default: op
|
||||||
|
|||||||
Reference in New Issue
Block a user