Merge branch 'master' of git@git.coding.net:502647092/LuckLottery.git
Conflicts: src/cn/citycraft/LuckLottery/LuckLottery.java src/cn/citycraft/LuckLottery/config/FileConfig.java src/cn/citycraft/LuckLottery/runnable/LotteryReward.java src/plugin.yml Signed-off-by: j502647092 <jtb1@163.com>master
commit
dd1c0a0a7c
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<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"/>
|
||||||
|
</classpath>
|
|
@ -1,40 +1,35 @@
|
||||||
# Eclipse stuff
|
# netbeans
|
||||||
/.classpath
|
/nbproject
|
||||||
/.project
|
|
||||||
/.settings
|
# we use maven!
|
||||||
|
/build.xml
|
||||||
# netbeans
|
|
||||||
/nbproject
|
# maven
|
||||||
|
/target
|
||||||
# we use maven!
|
/repo
|
||||||
/build.xml
|
|
||||||
|
# vim
|
||||||
# maven
|
.*.sw[a-p]
|
||||||
/target
|
|
||||||
/repo
|
# various other potential build files
|
||||||
|
/build
|
||||||
# vim
|
/bin
|
||||||
.*.sw[a-p]
|
/dist
|
||||||
|
/manifest.mf
|
||||||
# various other potential build files
|
|
||||||
/build
|
/world
|
||||||
/bin
|
|
||||||
/dist
|
# Mac filesystem dust
|
||||||
/manifest.mf
|
*.DS_Store
|
||||||
|
|
||||||
/world
|
# intellij
|
||||||
|
*.iml
|
||||||
# Mac filesystem dust
|
*.ipr
|
||||||
*.DS_Store
|
*.iws
|
||||||
|
.idea/
|
||||||
# intellij
|
|
||||||
*.iml
|
# Project Stuff
|
||||||
*.ipr
|
/src/main/resources/Soulbound
|
||||||
*.iws
|
|
||||||
.idea/
|
# Atlassian Stuff
|
||||||
|
|
||||||
# Project Stuff
|
|
||||||
/src/main/resources/Soulbound
|
|
||||||
|
|
||||||
# Atlassian Stuff
|
|
||||||
/atlassian-ide-plugin.xml
|
/atlassian-ide-plugin.xml
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>LuckLottery</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
Binary file not shown.
115
pom.xml
115
pom.xml
|
@ -1,56 +1,61 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<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.3-SNAPSHOT</version>
|
<version>0.0.7-SNAPSHOT</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<finalName>${project.name}</finalName>
|
||||||
<resources>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<resource>
|
<resources>
|
||||||
<directory>src</directory>
|
<resource>
|
||||||
<excludes>
|
<directory>src</directory>
|
||||||
<exclude>**/*.java</exclude>
|
<excludes>
|
||||||
</excludes>
|
<exclude>**/*.java</exclude>
|
||||||
</resource>
|
</excludes>
|
||||||
</resources>
|
</resource>
|
||||||
<plugins>
|
</resources>
|
||||||
<plugin>
|
<plugins>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<plugin>
|
||||||
<version>3.1</version>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<version>3.1</version>
|
||||||
<source>1.7</source>
|
<configuration>
|
||||||
<target>1.7</target>
|
<source>1.7</source>
|
||||||
</configuration>
|
<target>1.7</target>
|
||||||
</plugin>
|
</configuration>
|
||||||
</plugins>
|
</plugin>
|
||||||
</build>
|
</plugins>
|
||||||
<repositories>
|
</build>
|
||||||
<repository>
|
<repositories>
|
||||||
<id>spigot-repo</id>
|
<repository>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<id>mengcraft-repo</id>
|
||||||
</repository>
|
<url>http://ci.mengcraft.com:8080/plugin/repository/everything/</url>
|
||||||
<repository>
|
</repository>
|
||||||
<id>vault-repo</id>
|
<repository>
|
||||||
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
<id>spigot-repo</id>
|
||||||
</repository>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
</repositories>
|
</repository>
|
||||||
<dependencies>
|
<repository>
|
||||||
<dependency>
|
<id>vault-repo</id>
|
||||||
<groupId>org.spigotmc</groupId>
|
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
||||||
<artifactId>spigot-api</artifactId>
|
</repository>
|
||||||
<type>jar</type>
|
</repositories>
|
||||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
<dependencies>
|
||||||
</dependency>
|
<dependency>
|
||||||
<dependency>
|
<groupId>org.spigotmc</groupId>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<type>jar</type>
|
||||||
<version>1.5</version>
|
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||||
<scope>system</scope>
|
</dependency>
|
||||||
<systemPath>${project.basedir}/lib/Vault-1.4.1.jar</systemPath>
|
<dependency>
|
||||||
</dependency>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
</dependencies>
|
<artifactId>VaultAPI</artifactId>
|
||||||
<properties>
|
<version>1.5</version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<scope>system</scope>
|
||||||
</properties>
|
<systemPath>${project.basedir}/lib/Vault.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -1,8 +1,6 @@
|
||||||
package cn.citycraft.LuckLottery;
|
package cn.citycraft.LuckLottery;
|
||||||
|
|
||||||
import net.milkbowl.vault.chat.Chat;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
|
||||||
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
@ -16,26 +14,24 @@ 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;
|
||||||
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
||||||
|
import cn.citycraft.LuckLottery.utils.VersionChecker;
|
||||||
|
|
||||||
public class LuckLottery extends JavaPlugin {
|
public class LuckLottery extends JavaPlugin {
|
||||||
public static boolean isEconomy;
|
public static boolean isEconomy;
|
||||||
public static Permission permission = null;
|
|
||||||
public static Economy economy = null;
|
public static Economy economy = null;
|
||||||
public static Chat chat = null;
|
|
||||||
public static LuckLottery plugin;
|
public static LuckLottery plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
this.getLogger().info("保存彩票数据中...");
|
this.getLogger().info("保存彩票数据中...");
|
||||||
LotteryUtils.saveLottery();
|
|
||||||
this.getLogger().info("保存玩家数据中...");
|
this.getLogger().info("保存玩家数据中...");
|
||||||
PlayerDate.save();
|
LotteryUtils.saveLottery();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
PluginManager pm = this.getServer().getPluginManager();
|
PluginManager pm = this.getServer().getPluginManager();
|
||||||
if (!pm.getPlugin("Vault").isEnabled()) {
|
if (pm.getPlugin("Vault") == null && !pm.getPlugin("Vault").isEnabled()) {
|
||||||
this.getLogger().warning("未找到前置插件Vault 关闭插件...");
|
this.getLogger().warning("未找到前置插件Vault 关闭插件...");
|
||||||
this.getServer().getPluginManager().disablePlugin(this);
|
this.getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
|
@ -48,9 +44,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().getScheduler()
|
this.getServer().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("彩票系统已开启...");
|
||||||
|
new VersionChecker(this);
|
||||||
pm.registerEvents(new PlayerListen(), this);
|
pm.registerEvents(new PlayerListen(), this);
|
||||||
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
||||||
}
|
}
|
||||||
|
@ -58,21 +56,13 @@ public class LuckLottery extends JavaPlugin {
|
||||||
@Override
|
@Override
|
||||||
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().getBoolean("numbersame"));
|
LotteryUtils.setNumbersame(Config.getInstance().getBoolean("numbersame"));
|
||||||
}
|
LotteryUtils.setPrice(Config.getInstance().getInt("price"));
|
||||||
|
|
||||||
public boolean setupChat() {
|
|
||||||
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager()
|
|
||||||
.getRegistration(net.milkbowl.vault.chat.Chat.class);
|
|
||||||
if (chatProvider != null) {
|
|
||||||
chat = chatProvider.getProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (chat != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setupEconomy() {
|
public boolean setupEconomy() {
|
||||||
|
@ -83,14 +73,4 @@ public class LuckLottery extends JavaPlugin {
|
||||||
}
|
}
|
||||||
return (economy != null);
|
return (economy != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setupPermissions() {
|
|
||||||
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager()
|
|
||||||
.getRegistration(net.milkbowl.vault.permission.Permission.class);
|
|
||||||
if (permissionProvider != null) {
|
|
||||||
permission = permissionProvider.getProvider();
|
|
||||||
}
|
|
||||||
return (permission != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
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 cn.citycraft.LuckLottery.LuckLottery;
|
import cn.citycraft.LuckLottery.LuckLottery;
|
||||||
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
||||||
|
@ -25,14 +26,15 @@ public class LuckLotteryCommand implements CommandExecutor {
|
||||||
String[] args) {
|
String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
if (isPlayer(sender)){
|
if (isPlayer(sender)) {
|
||||||
Player p = (Player) sender;
|
final Player p = (Player) sender;
|
||||||
|
int price = LotteryUtils.getPrice();
|
||||||
if (LuckLottery.economy.hasAccount(p)
|
if (LuckLottery.economy.hasAccount(p)
|
||||||
&& LuckLottery.economy.has(p, 200)) {
|
&& LuckLottery.economy.has(p, price)) {
|
||||||
InvUtils.openGui(p);
|
InvUtils.openGui(p);
|
||||||
} else {
|
} else {
|
||||||
ChatUtils.sendMessage(p, ChatColor.GOLD
|
ChatUtils.sendMessage(p, ChatColor.GOLD
|
||||||
+ "你没有足够的金钱购买彩票,每张彩票" + ChatColor.RED + "200"
|
+ "你没有足够的金钱购买彩票,每张彩票" + ChatColor.RED + price
|
||||||
+ ChatColor.GOLD + "元!");
|
+ ChatColor.GOLD + "元!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +54,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);
|
||||||
|
@ -60,20 +75,38 @@ public class LuckLotteryCommand implements CommandExecutor {
|
||||||
case "reward":
|
case "reward":
|
||||||
if (PermissionUtils.Check(sender, PermissionUtils.Reward)) {
|
if (PermissionUtils.Check(sender, PermissionUtils.Reward)) {
|
||||||
LotteryUtils.rewardLastLottery();
|
LotteryUtils.rewardLastLottery();
|
||||||
ChatUtils.sendMessage(sender, ChatColor.GREEN + "已结算上一轮彩票!");
|
ChatUtils
|
||||||
|
.sendMessage(sender, ChatColor.GREEN + "已结算上一轮彩票!");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "look":
|
case "look":
|
||||||
if (PermissionUtils.Check(sender, PermissionUtils.Reward)){
|
if (PermissionUtils.Check(sender, PermissionUtils.Reward)) {
|
||||||
LotteryUtils.showSystemLottery(sender);
|
LotteryUtils.showSystemLottery(sender);
|
||||||
}
|
}
|
||||||
return true;
|
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":
|
case "help":
|
||||||
ChatUtils.sendHelp(sender);
|
ChatUtils.sendHelp(sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
package cn.citycraft.LuckLottery.config;
|
package cn.citycraft.LuckLottery.config;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class Config extends ConfigLoader {
|
public class Config extends ConfigLoader {
|
||||||
private static String CONFIG_NAME = "config.yml";
|
private static String CONFIG_NAME = "config.yml";
|
||||||
private static FileConfig instance;
|
private static FileConfig instance;
|
||||||
|
|
||||||
public Config(Plugin p, String ver) {
|
public Config(Plugin p, String ver) {
|
||||||
super(p, CONFIG_NAME, ver);
|
super(p, CONFIG_NAME, ver);
|
||||||
instance = super.getInstance();
|
instance = super.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void load(Plugin p, String ver) {
|
public static void load(Plugin p, String ver) {
|
||||||
new Config(p, ver);
|
new Config(p, ver);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileConfig getInstance() {
|
public static FileConfig getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMessage(String path) {
|
public static String getMessage(String path) {
|
||||||
String message = instance.getString(path).replaceAll("&", "§");
|
String message = instance.getString(path).replaceAll("&", "§");
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.citycraft.LuckLottery.config;
|
package cn.citycraft.LuckLottery.config;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
@ -7,6 +8,7 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.io.Reader;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -25,8 +27,8 @@ import com.google.common.base.Charsets;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link Configuration} which saves all files in Yaml. Note that this
|
* An implementation of {@link Configuration} which saves all files in Yaml.
|
||||||
* implementation is not synchronized.
|
* Note that this implementation is not synchronized.
|
||||||
*/
|
*/
|
||||||
public class FileConfig extends YamlConfiguration {
|
public class FileConfig extends YamlConfiguration {
|
||||||
|
|
||||||
|
@ -52,21 +54,40 @@ public class FileConfig extends YamlConfiguration {
|
||||||
|
|
||||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||||
|
|
||||||
protected final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
|
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
||||||
|
yamlRepresenter, yamlOptions);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
public void load(File file) throws FileNotFoundException, IOException,
|
||||||
|
InvalidConfigurationException {
|
||||||
Validate.notNull(file, "File cannot be null");
|
Validate.notNull(file, "File cannot be null");
|
||||||
final FileInputStream stream = new FileInputStream(file);
|
final FileInputStream stream = new FileInputStream(file);
|
||||||
load(new InputStreamReader(stream, Charsets.UTF_8));
|
load(new InputStreamReader(stream, Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load(Reader reader) throws IOException, InvalidConfigurationException {
|
||||||
|
BufferedReader input = (reader instanceof BufferedReader) ? (BufferedReader) reader
|
||||||
|
: new BufferedReader(reader);
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
try {
|
||||||
|
String line;
|
||||||
|
while ((line = input.readLine()) != null) {
|
||||||
|
builder.append(line);
|
||||||
|
builder.append('\n');
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
loadFromString(builder.toString());
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void save(File file) throws IOException {
|
public void save(File file) throws IOException {
|
||||||
Validate.notNull(file, "File cannot be null");
|
Validate.notNull(file, "File cannot be null");
|
||||||
Files.createParentDirs(file);
|
Files.createParentDirs(file);
|
||||||
String data = saveToString();
|
String data = saveToString();
|
||||||
Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8);
|
Writer writer = new OutputStreamWriter(new FileOutputStream(file),
|
||||||
|
Charsets.UTF_8);
|
||||||
try {
|
try {
|
||||||
writer.write(data);
|
writer.write(data);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -1,123 +1,97 @@
|
||||||
package cn.citycraft.LuckLottery.listen;
|
package cn.citycraft.LuckLottery.listen;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
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.OfflineDate;
|
import cn.citycraft.LuckLottery.config.OfflineDate;
|
||||||
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;
|
||||||
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
||||||
|
|
||||||
public class PlayerListen implements Listener {
|
public class PlayerListen implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(
|
||||||
public void onPlayerInteract(PlayerJoinEvent e) {
|
priority = EventPriority.HIGH)
|
||||||
LotteryUtils.loadPlayerLottery(e.getPlayer());
|
public void onPlayerInteract(PlayerJoinEvent e) {
|
||||||
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()) {
|
||||||
Bukkit.getServer()
|
Bukkit.getServer().getScheduler()
|
||||||
.getScheduler()
|
.runTaskLaterAsynchronously(LuckLottery.plugin, new LaterShow(p, messages), 5);
|
||||||
.runTaskLaterAsynchronously(LuckLottery.plugin,
|
OfflineDate.getInstance().set(p.getName(), null);
|
||||||
new LaterShow(p, messages), 5);
|
OfflineDate.save();
|
||||||
OfflineDate.getInstance().set(p.getName(), null);
|
}
|
||||||
OfflineDate.save();
|
}
|
||||||
}
|
|
||||||
}
|
@EventHandler(
|
||||||
|
priority = EventPriority.HIGHEST,
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
ignoreCancelled = true)
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
if (InvUtils.isLotteryGUI(e.getInventory())) {
|
if (InvUtils.isLotteryGUI(e.getInventory())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
Player p = (Player) e.getWhoClicked();
|
Player p = (Player) e.getWhoClicked();
|
||||||
ItemStack ci = e.getCurrentItem();
|
ItemStack ci = e.getCurrentItem();
|
||||||
Inventory inv = e.getInventory();
|
Inventory inv = e.getInventory();
|
||||||
int solt = e.getRawSlot();
|
int solt = e.getRawSlot();
|
||||||
if (ci == null || ci.getType() == Material.AIR)
|
if (ci == null || ci.getType() == Material.AIR)
|
||||||
return;
|
return;
|
||||||
if (!ci.getItemMeta().hasDisplayName())
|
if (!ci.getItemMeta().hasDisplayName())
|
||||||
return;
|
return;
|
||||||
String clickName = ci.getItemMeta().getDisplayName();
|
String clickName = ci.getItemMeta().getDisplayName();
|
||||||
switch (clickName) {
|
switch (clickName) {
|
||||||
case InvUtils.Create:
|
case InvUtils.Create:
|
||||||
List<String> lottery = InvUtils.getLotteryNumber(inv);
|
if (!LuckLottery.economy.hasAccount(p)
|
||||||
LotteryUtils.addLottery(p, lottery);
|
|| !LuckLottery.economy.has(p, LotteryUtils.getPrice())) {
|
||||||
ChatUtils.sendMessage(p, "§6您当前购买的彩票号码为: " + ChatColor.GREEN
|
ChatUtils.sendMessage(p, ChatColor.GOLD + "你没有足够的金钱购买彩票,每张彩票" + ChatColor.RED
|
||||||
+ lottery.toString());
|
+ LotteryUtils.getPrice() + ChatColor.GOLD + "元!");
|
||||||
ChatUtils.howToShow(p);
|
p.closeInventory();
|
||||||
LuckLottery.economy.withdrawPlayer(p, 200);
|
return;
|
||||||
p.closeInventory();
|
}
|
||||||
break;
|
List<String> lottery = InvUtils.getLotteryNumber(inv);
|
||||||
case InvUtils.ReSet:
|
LotteryUtils.addLottery(p, lottery);
|
||||||
inv.setContents(InvUtils.getGui());
|
ChatUtils.sendMessage(p, "§6您当前购买的彩票号码为: " + ChatColor.GREEN + lottery.toString());
|
||||||
break;
|
ChatUtils.howToShow(p);
|
||||||
case InvUtils.Normal1:
|
LuckLottery.economy.withdrawPlayer(p, LotteryUtils.getPrice());
|
||||||
case InvUtils.Normal2:
|
p.closeInventory();
|
||||||
case InvUtils.Normal3:
|
break;
|
||||||
case InvUtils.Normal4:
|
case InvUtils.ReSet:
|
||||||
case InvUtils.Normal5:
|
inv.setContents(InvUtils.getGui());
|
||||||
case InvUtils.Normal6:
|
break;
|
||||||
case InvUtils.Normal7:
|
default:
|
||||||
case InvUtils.Normal8:
|
if (solt < 36 && InvUtils.isLotteryItem(ci)) {
|
||||||
case InvUtils.Normal9:
|
if (setSelect(inv, ci))
|
||||||
case InvUtils.Normal10:
|
inv.setItem(solt, InvUtils.A);
|
||||||
case InvUtils.Normal11:
|
}
|
||||||
case InvUtils.Normal12:
|
break;
|
||||||
case InvUtils.Normal13:
|
}
|
||||||
case InvUtils.Normal14:
|
if (InvUtils.selectFinish(inv)) {
|
||||||
case InvUtils.Normal15:
|
inv.setItem(53, InvUtils.Creat);
|
||||||
case InvUtils.Normal16:
|
} else {
|
||||||
case InvUtils.Normal17:
|
inv.setItem(53, InvUtils.CantCreat);
|
||||||
case InvUtils.Normal18:
|
}
|
||||||
case InvUtils.Normal19:
|
}
|
||||||
case InvUtils.Normal20:
|
}
|
||||||
case InvUtils.Normal21:
|
|
||||||
case InvUtils.Normal22:
|
private boolean setSelect(Inventory inv, ItemStack is) {
|
||||||
case InvUtils.Normal23:
|
for (int i = 45; i < 53; i++) {
|
||||||
case InvUtils.Normal24:
|
if (inv.getItem(i) == null) {
|
||||||
case InvUtils.Normal25:
|
inv.setItem(i, is);
|
||||||
case InvUtils.Normal26:
|
return true;
|
||||||
case InvUtils.Normal27:
|
}
|
||||||
case InvUtils.Normal28:
|
}
|
||||||
case InvUtils.Normal29:
|
return false;
|
||||||
case InvUtils.Normal30:
|
}
|
||||||
case InvUtils.Normal31:
|
}
|
||||||
case InvUtils.Normal32:
|
|
||||||
if (solt < 36) {
|
|
||||||
if (setSelect(inv, ci))
|
|
||||||
inv.setItem(solt, InvUtils.A);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (InvUtils.selectFinish(inv)) {
|
|
||||||
inv.setItem(53, InvUtils.Creat);
|
|
||||||
} else {
|
|
||||||
inv.setItem(53, InvUtils.CantCreat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean setSelect(Inventory inv, ItemStack is) {
|
|
||||||
for (int i = 45; i < 53; i++) {
|
|
||||||
if (inv.getItem(i) == null) {
|
|
||||||
inv.setItem(i, is);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -6,9 +6,9 @@ import java.util.Map.Entry;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import cn.citycraft.LuckLottery.LuckLottery;
|
import cn.citycraft.LuckLottery.LuckLottery;
|
||||||
|
import cn.citycraft.LuckLottery.config.Config;
|
||||||
import cn.citycraft.LuckLottery.config.OfflineDate;
|
import cn.citycraft.LuckLottery.config.OfflineDate;
|
||||||
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
||||||
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
||||||
|
@ -31,49 +31,39 @@ public class LotteryReward implements Runnable {
|
||||||
}
|
}
|
||||||
ChatUtils.broadcastMessage(ChatColor.GOLD + "本轮彩票开奖: " + ChatColor.RED
|
ChatUtils.broadcastMessage(ChatColor.GOLD + "本轮彩票开奖: " + ChatColor.RED
|
||||||
+ LotteryUtils.getSystemLottery().toString());
|
+ LotteryUtils.getSystemLottery().toString());
|
||||||
for (Entry<String, List<List<String>>> players : LotteryUtils
|
ChatUtils.broadcastMessage(ChatColor.BLUE + "使用命令: " + ChatColor.RED
|
||||||
.getPlayerLottery().entrySet()) {
|
+ "/ll" + ChatColor.BLUE + " 或闹钟菜单可以购买彩票!");
|
||||||
|
for (Entry<String, List<List<String>>> players : LotteryUtils.playerLottery
|
||||||
|
.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())
|
||||||
for (List<String> playerlottery : pl) {
|
for (List<String> playerlottery : pl) {
|
||||||
int win = LotteryUtils.getSameNumber(playerlottery);
|
int win = LotteryUtils.getSameNumber(playerlottery);
|
||||||
int winprices = 0;
|
int winprices = 0;
|
||||||
switch (win) {
|
winprices = Config.getInstance().getInt("Reward." + win,
|
||||||
case 10:
|
200);
|
||||||
case 11:
|
|
||||||
winprices = 500;
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
winprices = 1000;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
case 13:
|
|
||||||
winprices = 3000;
|
|
||||||
break;
|
|
||||||
case 14:
|
|
||||||
case 5:
|
|
||||||
case 15:
|
|
||||||
winprices = 5000;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
if (winprices > 0) {
|
if (winprices > 0) {
|
||||||
|
ChatUtils.broadcastMessage(ChatColor.GREEN
|
||||||
|
+ p.getName() + "的彩票: " + ChatColor.YELLOW
|
||||||
|
+ playerlottery.toString() + 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,9 +13,12 @@ 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(管理员命令)",
|
||||||
"§5/ll look 查看本轮彩票号码§4(管理员命令)"
|
"§e/ll clear 清除所有已购买彩票§4(管理员命令)",
|
||||||
|
"§5/ll look 查看本轮彩票号码§4(管理员命令)",
|
||||||
|
"§c/ll reload 重载彩票插件§4(管理员命令)"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static String getPluginname() {
|
public static String getPluginname() {
|
||||||
|
|
|
@ -1,312 +1,277 @@
|
||||||
package cn.citycraft.LuckLottery.utils;
|
package cn.citycraft.LuckLottery.utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class InvUtils {
|
public class InvUtils {
|
||||||
|
|
||||||
public static final String InvName = "§6[§3§l彩票系统§6]§c点击选取号码";
|
public static final String InvName = ChatUtils.getPluginname() + " §c§l售价: "
|
||||||
|
+ LotteryUtils.getPrice() + "元一份";
|
||||||
public static final String Normal1 = "§6§l1";
|
|
||||||
public static final String Normal2 = "§6§l2";
|
public static final String NumPrefix = "§6§l";
|
||||||
public static final String Normal3 = "§6§l3";
|
public static final String Normal1 = "§6§l1";
|
||||||
public static final String Normal4 = "§6§l4";
|
public static final String Normal2 = "§6§l2";
|
||||||
public static final String Normal5 = "§6§l5";
|
public static final String Normal3 = "§6§l3";
|
||||||
public static final String Normal6 = "§6§l6";
|
public static final String Normal4 = "§6§l4";
|
||||||
public static final String Normal7 = "§6§l7";
|
public static final String Normal5 = "§6§l5";
|
||||||
public static final String Normal8 = "§6§l8";
|
public static final String Normal6 = "§6§l6";
|
||||||
public static final String Normal9 = "§6§l9";
|
public static final String Normal7 = "§6§l7";
|
||||||
|
public static final String Normal8 = "§6§l8";
|
||||||
public static final String Normal10 = "§6§l10";
|
public static final String Normal9 = "§6§l9";
|
||||||
public static final String Normal11 = "§6§l11";
|
|
||||||
public static final String Normal12 = "§6§l12";
|
public static final String Normal10 = "§6§l10";
|
||||||
public static final String Normal13 = "§6§l13";
|
public static final String Normal11 = "§6§l11";
|
||||||
public static final String Normal14 = "§6§l14";
|
public static final String Normal12 = "§6§l12";
|
||||||
public static final String Normal15 = "§6§l15";
|
public static final String Normal13 = "§6§l13";
|
||||||
public static final String Normal16 = "§6§l16";
|
public static final String Normal14 = "§6§l14";
|
||||||
public static final String Normal17 = "§6§l17";
|
public static final String Normal15 = "§6§l15";
|
||||||
public static final String Normal18 = "§6§l18";
|
public static final String Normal16 = "§6§l16";
|
||||||
public static final String Normal19 = "§6§l19";
|
public static final String Normal17 = "§6§l17";
|
||||||
|
public static final String Normal18 = "§6§l18";
|
||||||
public static final String Normal20 = "§6§l20";
|
public static final String Normal19 = "§6§l19";
|
||||||
public static final String Normal21 = "§6§l21";
|
|
||||||
public static final String Normal22 = "§6§l22";
|
public static final String Normal20 = "§6§l20";
|
||||||
public static final String Normal23 = "§6§l23";
|
public static final String Normal21 = "§6§l21";
|
||||||
public static final String Normal24 = "§6§l24";
|
public static final String Normal22 = "§6§l22";
|
||||||
public static final String Normal25 = "§6§l25";
|
public static final String Normal23 = "§6§l23";
|
||||||
public static final String Normal26 = "§6§l26";
|
public static final String Normal24 = "§6§l24";
|
||||||
public static final String Normal27 = "§6§l27";
|
public static final String Normal25 = "§6§l25";
|
||||||
public static final String Normal28 = "§6§l28";
|
public static final String Normal26 = "§6§l26";
|
||||||
public static final String Normal29 = "§6§l29";
|
public static final String Normal27 = "§6§l27";
|
||||||
|
public static final String Normal28 = "§6§l28";
|
||||||
public static final String Normal30 = "§6§l30";
|
public static final String Normal29 = "§6§l29";
|
||||||
public static final String Normal31 = "§6§l31";
|
|
||||||
public static final String Normal32 = "§6§l32";
|
public static final String Normal30 = "§6§l30";
|
||||||
// public static final String Special1 = "§b§l1";
|
public static final String Normal31 = "§6§l31";
|
||||||
// public static final String Special2 = "§b§l2";
|
public static final String Normal32 = "§6§l32";
|
||||||
// public static final String Special3 = "§b§l3";
|
// public static final String Special1 = "§b§l1";
|
||||||
// public static final String Special4 = "§b§l4";
|
// public static final String Special2 = "§b§l2";
|
||||||
// public static final String Special5 = "§b§l5";
|
// public static final String Special3 = "§b§l3";
|
||||||
// public static final String Special6 = "§b§l6";
|
// public static final String Special4 = "§b§l4";
|
||||||
// public static final String Special7 = "§b§l7";
|
// public static final String Special5 = "§b§l5";
|
||||||
// public static final String Special8 = "§b§l8";
|
// public static final String Special6 = "§b§l6";
|
||||||
// public static final String Special9 = "§b§l9";
|
// public static final String Special7 = "§b§l7";
|
||||||
|
// public static final String Special8 = "§b§l8";
|
||||||
public static final String WEB = "§c请选取=>§6橙色普通号码§r§l|§b蓝色特殊号码";
|
// public static final String Special9 = "§b§l9";
|
||||||
public static final String ReSet = "§4§l重新选取";
|
|
||||||
public static final String Create = "§a§l生成彩票 §c§l200元一份";
|
public static final String WEB = "§c请选取=>§6橙色普通号码§r§l|§b蓝色特殊号码";
|
||||||
public static final String CantCreate = "§c§l请选取§66个普通号码§b1个特殊号码§a生成彩票";
|
public static final String ReSet = "§4§l重新选取";
|
||||||
|
public static final String Create = "§a§l生成彩票";
|
||||||
// private static final ItemStack L0 = new
|
public static final String CantCreate = "§c§l请选取§66个普通号码§b1个特殊号码§a生成彩票";
|
||||||
// ItemStack(Material.DOUBLE_PLANT,1,(short)0);
|
|
||||||
|
// private static final ItemStack L0 = new
|
||||||
public static final ItemStack L0 = new ItemStack(Material.WOOL);
|
// ItemStack(Material.DOUBLE_PLANT,1,(short)0);
|
||||||
public static final ItemStack L1 = new ItemStack(Material.WOOL, 1,
|
|
||||||
(short) 1);
|
public static final ItemStack L0 = new ItemStack(Material.WOOL);
|
||||||
public static final ItemStack L2 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack L1 = new ItemStack(Material.WOOL, 1, (short) 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,
|
public static final ItemStack L3 = new ItemStack(Material.WOOL, 1, (short) 3);
|
||||||
(short) 3);
|
public static final ItemStack L4 = new ItemStack(Material.WOOL, 1, (short) 4);
|
||||||
public static final ItemStack L4 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack L5 = new ItemStack(Material.WOOL, 1, (short) 5);
|
||||||
(short) 4);
|
public static final ItemStack L6 = new ItemStack(Material.WOOL, 1, (short) 6);
|
||||||
public static final ItemStack L5 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack L7 = new ItemStack(Material.WOOL, 1, (short) 7);
|
||||||
(short) 5);
|
public static final ItemStack L8 = new ItemStack(Material.WOOL, 1, (short) 8);
|
||||||
public static final ItemStack L6 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack L9 = new ItemStack(Material.WOOL, 1, (short) 9);
|
||||||
(short) 6);
|
public static final ItemStack L10 = new ItemStack(Material.WOOL, 1, (short) 10);
|
||||||
public static final ItemStack L7 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack L11 = new ItemStack(Material.WOOL, 1, (short) 11);
|
||||||
(short) 7);
|
public static final ItemStack L12 = new ItemStack(Material.WOOL, 1, (short) 12);
|
||||||
public static final ItemStack L8 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack L13 = new ItemStack(Material.WOOL, 1, (short) 13);
|
||||||
(short) 8);
|
public static final ItemStack L14 = new ItemStack(Material.WOOL, 1, (short) 14);
|
||||||
public static final ItemStack L9 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack L15 = new ItemStack(Material.WOOL, 1, (short) 15);
|
||||||
(short) 9);
|
|
||||||
public static final ItemStack L10 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack B0 = new ItemStack(Material.STAINED_GLASS);
|
||||||
(short) 10);
|
public static final ItemStack B1 = new ItemStack(Material.STAINED_GLASS, 1, (short) 1);
|
||||||
public static final ItemStack L11 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack B2 = new ItemStack(Material.STAINED_GLASS, 1, (short) 2);
|
||||||
(short) 11);
|
public static final ItemStack B3 = new ItemStack(Material.STAINED_GLASS, 1, (short) 3);
|
||||||
public static final ItemStack L12 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack B4 = new ItemStack(Material.STAINED_GLASS, 1, (short) 4);
|
||||||
(short) 12);
|
public static final ItemStack B5 = new ItemStack(Material.STAINED_GLASS, 1, (short) 5);
|
||||||
public static final ItemStack L13 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack B6 = new ItemStack(Material.STAINED_GLASS, 1, (short) 6);
|
||||||
(short) 13);
|
public static final ItemStack B7 = new ItemStack(Material.STAINED_GLASS, 1, (short) 7);
|
||||||
public static final ItemStack L14 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack B8 = new ItemStack(Material.STAINED_GLASS, 1, (short) 8);
|
||||||
(short) 14);
|
public static final ItemStack B9 = new ItemStack(Material.STAINED_GLASS, 1, (short) 9);
|
||||||
public static final ItemStack L15 = new ItemStack(Material.WOOL, 1,
|
public static final ItemStack B10 = new ItemStack(Material.STAINED_GLASS, 1, (short) 10);
|
||||||
(short) 15);
|
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 B0 = new ItemStack(Material.STAINED_GLASS);
|
public static final ItemStack B13 = new ItemStack(Material.STAINED_GLASS, 1, (short) 13);
|
||||||
public static final ItemStack B1 = new ItemStack(Material.STAINED_GLASS, 1,
|
public static final ItemStack B14 = new ItemStack(Material.STAINED_GLASS, 1, (short) 14);
|
||||||
(short) 1);
|
public static final ItemStack B15 = new ItemStack(Material.STAINED_GLASS, 1, (short) 15);
|
||||||
public static final ItemStack B2 = new ItemStack(Material.STAINED_GLASS, 1,
|
|
||||||
(short) 2);
|
public static final ItemStack W = new ItemStack(Material.SNOW_BALL);
|
||||||
public static final ItemStack B3 = new ItemStack(Material.STAINED_GLASS, 1,
|
public static final ItemStack Creat = new ItemStack(Material.MAP);
|
||||||
(short) 3);
|
public static final ItemStack CM = new ItemStack(Material.WATER_LILY);
|
||||||
public static final ItemStack B4 = new ItemStack(Material.STAINED_GLASS, 1,
|
public static final ItemStack CantCreat = new ItemStack(Material.EMPTY_MAP);
|
||||||
(short) 4);
|
public static final ItemStack A = new ItemStack(Material.AIR);
|
||||||
public static final ItemStack B5 = new ItemStack(Material.STAINED_GLASS, 1,
|
public static final ItemStack RT = new ItemStack(Material.LAVA_BUCKET);
|
||||||
(short) 5);
|
static {
|
||||||
public static final ItemStack B6 = new ItemStack(Material.STAINED_GLASS, 1,
|
setDisplayName(W, WEB);
|
||||||
(short) 6);
|
setDisplayName(L0, Normal1);
|
||||||
public static final ItemStack B7 = new ItemStack(Material.STAINED_GLASS, 1,
|
setDisplayName(L1, Normal2);
|
||||||
(short) 7);
|
setDisplayName(L2, Normal3);
|
||||||
public static final ItemStack B8 = new ItemStack(Material.STAINED_GLASS, 1,
|
setDisplayName(L3, Normal4);
|
||||||
(short) 8);
|
setDisplayName(L4, Normal5);
|
||||||
public static final ItemStack B9 = new ItemStack(Material.STAINED_GLASS, 1,
|
setDisplayName(L5, Normal6);
|
||||||
(short) 9);
|
setDisplayName(L6, Normal7);
|
||||||
public static final ItemStack B10 = new ItemStack(Material.STAINED_GLASS,
|
setDisplayName(L7, Normal8);
|
||||||
1, (short) 10);
|
setDisplayName(L8, Normal9);
|
||||||
public static final ItemStack B11 = new ItemStack(Material.STAINED_GLASS,
|
setDisplayName(L9, Normal10);
|
||||||
1, (short) 11);
|
setDisplayName(L10, Normal11);
|
||||||
public static final ItemStack B12 = new ItemStack(Material.STAINED_GLASS,
|
setDisplayName(L11, Normal12);
|
||||||
1, (short) 12);
|
setDisplayName(L12, Normal13);
|
||||||
public static final ItemStack B13 = new ItemStack(Material.STAINED_GLASS,
|
setDisplayName(L13, Normal14);
|
||||||
1, (short) 13);
|
setDisplayName(L14, Normal15);
|
||||||
public static final ItemStack B14 = new ItemStack(Material.STAINED_GLASS,
|
setDisplayName(L15, Normal16);
|
||||||
1, (short) 14);
|
|
||||||
public static final ItemStack B15 = new ItemStack(Material.STAINED_GLASS,
|
setDisplayName(B0, Normal17);
|
||||||
1, (short) 15);
|
setDisplayName(B1, Normal18);
|
||||||
|
setDisplayName(B2, Normal19);
|
||||||
public static final ItemStack W = new ItemStack(Material.SNOW_BALL);
|
setDisplayName(B3, Normal20);
|
||||||
public static final ItemStack Creat = new ItemStack(Material.MAP);
|
setDisplayName(B4, Normal21);
|
||||||
public static final ItemStack CM = new ItemStack(Material.WATER_LILY);
|
setDisplayName(B5, Normal22);
|
||||||
public static final ItemStack CantCreat = new ItemStack(Material.EMPTY_MAP);
|
setDisplayName(B6, Normal23);
|
||||||
public static final ItemStack A = new ItemStack(Material.AIR);
|
setDisplayName(B7, Normal24);
|
||||||
public static final ItemStack RT = new ItemStack(Material.LAVA);
|
setDisplayName(B8, Normal25);
|
||||||
static {
|
setDisplayName(B9, Normal26);
|
||||||
setDisplayName(W, WEB);
|
setDisplayName(B10, Normal27);
|
||||||
setDisplayName(L0, Normal1);
|
setDisplayName(B11, Normal28);
|
||||||
setDisplayName(L1, Normal2);
|
setDisplayName(B12, Normal29);
|
||||||
setDisplayName(L2, Normal3);
|
setDisplayName(B13, Normal30);
|
||||||
setDisplayName(L3, Normal4);
|
setDisplayName(B14, Normal31);
|
||||||
setDisplayName(L4, Normal5);
|
setDisplayName(B15, Normal32);
|
||||||
setDisplayName(L5, Normal6);
|
|
||||||
setDisplayName(L6, Normal7);
|
setDisplayName(CM, "§6<=普通号码§r|§b特殊号码=>");
|
||||||
setDisplayName(L7, Normal8);
|
setDisplayName(RT, ReSet);
|
||||||
setDisplayName(L8, Normal9);
|
setDisplayName(CantCreat, CantCreate);
|
||||||
setDisplayName(L9, Normal10);
|
setDisplayName(Creat, Create);
|
||||||
setDisplayName(L10, Normal11);
|
}
|
||||||
setDisplayName(L11, Normal12);
|
|
||||||
setDisplayName(L12, Normal13);
|
private static final ItemStack[] GUI_LINE1 = {
|
||||||
setDisplayName(L13, Normal14);
|
W,
|
||||||
setDisplayName(L14, Normal15);
|
L0,
|
||||||
|
L1,
|
||||||
setDisplayName(B0, Normal16);
|
L2,
|
||||||
setDisplayName(B1, Normal17);
|
L3,
|
||||||
setDisplayName(B2, Normal18);
|
L4,
|
||||||
setDisplayName(B3, Normal19);
|
L5,
|
||||||
setDisplayName(B4, Normal20);
|
L6,
|
||||||
setDisplayName(B5, Normal21);
|
W
|
||||||
setDisplayName(B6, Normal22);
|
/* 第一行结束 */};
|
||||||
setDisplayName(B7, Normal24);
|
private static final ItemStack[] GUI_LINE2 = {
|
||||||
setDisplayName(B8, Normal25);
|
L7,
|
||||||
setDisplayName(B9, Normal26);
|
L8,
|
||||||
setDisplayName(B10, Normal27);
|
L9,
|
||||||
setDisplayName(B11, Normal28);
|
L10,
|
||||||
setDisplayName(B12, Normal29);
|
L11,
|
||||||
setDisplayName(B13, Normal30);
|
L12,
|
||||||
setDisplayName(B14, Normal31);
|
L13,
|
||||||
setDisplayName(B15, Normal32);
|
L14,
|
||||||
|
L15
|
||||||
setDisplayName(CM, "§6<=普通号码§r|§b特殊号码=>");
|
/* 第二行结束 */};
|
||||||
setDisplayName(RT, ReSet);
|
private static final ItemStack[] GUI_LINE3 = {
|
||||||
setDisplayName(CantCreat, CantCreate);
|
B0,
|
||||||
setDisplayName(Creat, Create);
|
B1,
|
||||||
}
|
B2,
|
||||||
|
B3,
|
||||||
private static final ItemStack[] GUI_LINE1 = { W, L0, L1, L2, L3, L4, L5,
|
B4,
|
||||||
L6, W /* 第一行结束 */};
|
B5,
|
||||||
private static final ItemStack[] GUI_LINE2 = { L7, L8, L9, L10, L11, L12,
|
B6,
|
||||||
L13, L14, L15 /* 第二行结束 */};
|
B7,
|
||||||
private static final ItemStack[] GUI_LINE3 = { B0, B1, B2, B3, B4, B5, B6,
|
B8
|
||||||
B7, B8 /* 第三行结束 */};
|
/* 第三行结束 */};
|
||||||
private static final ItemStack[] GUI_LINE4 = { W, B9, B10, B11, B12, B13,
|
private static final ItemStack[] GUI_LINE4 = {
|
||||||
B14, B15, W /* 第四行结束 */};
|
W,
|
||||||
private static final ItemStack[] GUI_LINE5 = { W, W, W, W, W, W, RT, W, W /* 第五行结束 */};
|
B9,
|
||||||
private static final ItemStack[] GUI_LINE6 = { A, A, A, A, A, A, CM, A,
|
B10,
|
||||||
CantCreat /* 第六行结束 */};
|
B11,
|
||||||
|
B12,
|
||||||
private static void setDisplayName(ItemStack item, String displayName) {
|
B13,
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
B14,
|
||||||
itemMeta.setDisplayName(displayName);
|
B15,
|
||||||
item.setItemMeta(itemMeta);
|
W
|
||||||
}
|
/* 第四行结束 */};
|
||||||
|
private static final ItemStack[] GUI_LINE5 = {
|
||||||
public static ItemStack[] getGui() {
|
W,
|
||||||
List<ItemStack> invgui = new ArrayList<ItemStack>();
|
W,
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE1));
|
W,
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE2));
|
W,
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE3));
|
W,
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE4));
|
W,
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE5));
|
RT,
|
||||||
invgui.addAll(Arrays.asList(GUI_LINE6));
|
W,
|
||||||
return invgui.toArray(new ItemStack[0]);
|
W
|
||||||
}
|
/* 第五行结束 */};
|
||||||
|
private static final ItemStack[] GUI_LINE6 = {
|
||||||
public static void openGui(Player p) {
|
A,
|
||||||
Inventory scrollInv = Bukkit.createInventory(null, 6 * 9, InvName);
|
A,
|
||||||
scrollInv.setContents(getGui());
|
A,
|
||||||
p.openInventory(scrollInv);
|
A,
|
||||||
}
|
A,
|
||||||
|
A,
|
||||||
public static boolean isLotteryGUI(Inventory inv) {
|
CM,
|
||||||
if (inv == null)
|
A,
|
||||||
return false;
|
CantCreat
|
||||||
return inv.getHolder() == null && inv.getTitle().equals(InvName);
|
/* 第六行结束 */};
|
||||||
}
|
|
||||||
|
private static void setDisplayName(ItemStack item, String displayName) {
|
||||||
public static boolean selectFinish(Inventory inv) {
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
return (inv.getItem(45) != null && inv.getItem(46) != null
|
itemMeta.setDisplayName(displayName);
|
||||||
&& inv.getItem(47) != null && inv.getItem(48) != null
|
item.setItemMeta(itemMeta);
|
||||||
&& inv.getItem(49) != null && inv.getItem(50) != null && inv
|
}
|
||||||
.getItem(52) != null);
|
|
||||||
}
|
public static ItemStack[] getGui() {
|
||||||
|
List<ItemStack> invgui = new ArrayList<ItemStack>();
|
||||||
public static List<String> getLotteryNumber(Inventory inv) {
|
invgui.addAll(Arrays.asList(GUI_LINE1));
|
||||||
List<String> lty = new ArrayList<String>();
|
invgui.addAll(Arrays.asList(GUI_LINE2));
|
||||||
for (int i = 45; i < 51; i++) {
|
invgui.addAll(Arrays.asList(GUI_LINE3));
|
||||||
lty.add(item2number(inv.getItem(i)));
|
invgui.addAll(Arrays.asList(GUI_LINE4));
|
||||||
}
|
invgui.addAll(Arrays.asList(GUI_LINE5));
|
||||||
lty.add(item2number(inv.getItem(52)));
|
invgui.addAll(Arrays.asList(GUI_LINE6));
|
||||||
return lty;
|
return invgui.toArray(new ItemStack[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String item2number(ItemStack item) {
|
public static void openGui(Player p) {
|
||||||
return name2number(item.getItemMeta().getDisplayName());
|
Inventory scrollInv = Bukkit.createInventory(null, 6 * 9, InvName);
|
||||||
}
|
scrollInv.setContents(getGui());
|
||||||
|
p.openInventory(scrollInv);
|
||||||
public static String name2number(String name) {
|
}
|
||||||
switch (name) {
|
|
||||||
case Normal1:
|
public static boolean isLotteryGUI(Inventory inv) {
|
||||||
return "1";
|
if (inv == null)
|
||||||
case Normal2:
|
return false;
|
||||||
return "2";
|
return inv.getHolder() == null && inv.getTitle().equals(InvName);
|
||||||
case Normal3:
|
}
|
||||||
return "3";
|
|
||||||
case Normal4:
|
public static boolean selectFinish(Inventory inv) {
|
||||||
return "4";
|
return (inv.getItem(45) != null && inv.getItem(46) != null && inv.getItem(47) != null
|
||||||
case Normal5:
|
&& inv.getItem(48) != null && inv.getItem(49) != null && inv.getItem(50) != null && inv
|
||||||
return "5";
|
.getItem(52) != null);
|
||||||
case Normal6:
|
}
|
||||||
return "6";
|
|
||||||
case Normal7:
|
public static List<String> getLotteryNumber(Inventory inv) {
|
||||||
return "7";
|
List<String> lty = new ArrayList<String>();
|
||||||
case Normal8:
|
for (int i = 45; i < 51; i++) {
|
||||||
return "8";
|
lty.add(getItemNumber(inv.getItem(i)));
|
||||||
case Normal9:
|
}
|
||||||
return "9";
|
lty.add(getItemNumber(inv.getItem(52)));
|
||||||
case Normal10:
|
return lty;
|
||||||
return "10";
|
}
|
||||||
case Normal11:
|
|
||||||
return "11";
|
public static String getItemNumber(ItemStack item) {
|
||||||
case Normal12:
|
String num = item.getItemMeta().getDisplayName();
|
||||||
return "12";
|
if (num.startsWith(NumPrefix))
|
||||||
case Normal13:
|
return num.substring(NumPrefix.length());
|
||||||
return "13";
|
return null;
|
||||||
case Normal14:
|
}
|
||||||
return "14";
|
|
||||||
case Normal15:
|
public static boolean isLotteryItem(ItemStack item) {
|
||||||
return "15";
|
String num = item.getItemMeta().getDisplayName();
|
||||||
case Normal16:
|
return num.startsWith(NumPrefix);
|
||||||
return "16";
|
}
|
||||||
case Normal17:
|
}
|
||||||
return "17";
|
|
||||||
case Normal18:
|
|
||||||
return "18";
|
|
||||||
case Normal19:
|
|
||||||
return "19";
|
|
||||||
case Normal20:
|
|
||||||
return "20";
|
|
||||||
case Normal21:
|
|
||||||
return "21";
|
|
||||||
case Normal22:
|
|
||||||
return "22";
|
|
||||||
case Normal23:
|
|
||||||
return "23";
|
|
||||||
case Normal24:
|
|
||||||
return "24";
|
|
||||||
case Normal25:
|
|
||||||
return "25";
|
|
||||||
case Normal26:
|
|
||||||
return "26";
|
|
||||||
case Normal27:
|
|
||||||
return "27";
|
|
||||||
case Normal28:
|
|
||||||
return "28";
|
|
||||||
case Normal29:
|
|
||||||
return "29";
|
|
||||||
case Normal30:
|
|
||||||
return "30";
|
|
||||||
case Normal31:
|
|
||||||
return "31";
|
|
||||||
case Normal32:
|
|
||||||
return "32";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -20,10 +20,12 @@ 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;
|
||||||
|
|
||||||
|
protected static int price;
|
||||||
|
|
||||||
public static List<List<String>> addLottery(Player player,
|
public static List<List<String>> addLottery(Player player,
|
||||||
List<String> lottery) {
|
List<String> lottery) {
|
||||||
List<List<String>> playerhas = playerLottery.get(player.getName());
|
List<List<String>> playerhas = playerLottery.get(player.getName());
|
||||||
|
@ -77,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()
|
||||||
|
@ -92,13 +124,12 @@ public class LotteryUtils {
|
||||||
LotteryUtils.systemLottery = systemLottery;
|
LotteryUtils.systemLottery = systemLottery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, List<List<String>>> getPlayerLottery() {
|
public static int getPrice() {
|
||||||
return playerLottery;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPlayerLottery(
|
public static void setPrice(int price) {
|
||||||
HashMap<String, List<List<String>>> playerLottery) {
|
LotteryUtils.price = price;
|
||||||
LotteryUtils.playerLottery = playerLottery;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateSystemLottery() {
|
public static void updateSystemLottery() {
|
||||||
|
|
|
@ -1,32 +1,35 @@
|
||||||
package cn.citycraft.LuckLottery.utils;
|
package cn.citycraft.LuckLottery.utils;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
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 final String Reload = "lucklottery.reload";
|
||||||
public static boolean Check(Player p,String perm){
|
|
||||||
if (p.hasPermission(perm)){
|
public static String No_Permission = ChatColor.RED + "你没有此命令的权限!";
|
||||||
return true;
|
|
||||||
}else{
|
public static boolean Check(Player p, String perm) {
|
||||||
ChatUtils.noPermission(p);
|
if (p.hasPermission(perm)) {
|
||||||
}
|
return true;
|
||||||
return false;
|
} else {
|
||||||
}
|
ChatUtils.noPermission(p);
|
||||||
|
}
|
||||||
public static boolean Check(CommandSender p,String perm){
|
return false;
|
||||||
if (p.hasPermission(perm)){
|
}
|
||||||
return true;
|
|
||||||
}else{
|
public static boolean Check(CommandSender p, String perm) {
|
||||||
ChatUtils.noPermission(p);
|
if (p.hasPermission(perm)) {
|
||||||
}
|
return true;
|
||||||
return false;
|
} else {
|
||||||
}
|
ChatUtils.noPermission(p);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package cn.citycraft.LuckLottery.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
|
||||||
|
public class VersionChecker implements Listener {
|
||||||
|
Plugin plugin;
|
||||||
|
|
||||||
|
public VersionChecker(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
this.VersionCheck(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||||
|
if (e.getPlayer().isOp()) {
|
||||||
|
this.VersionCheck(e.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void VersionCheck(final Player player) {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String website = plugin.getDescription().getWebsite();
|
||||||
|
String readURL = website
|
||||||
|
+ (website.substring(website.length() - 1).equals("/") ? "" : "/")
|
||||||
|
+ "/lastSuccessfulBuild/artifact/src/plugin.yml";
|
||||||
|
FileConfiguration config;
|
||||||
|
String currentVersion = plugin.getDescription().getVersion();
|
||||||
|
try {
|
||||||
|
URL url = new URL(readURL);
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(),
|
||||||
|
Charsets.UTF_8));
|
||||||
|
config = YamlConfiguration.loadConfiguration(br);
|
||||||
|
String newVersion = config.getString("version");
|
||||||
|
br.close();
|
||||||
|
if (!newVersion.equals(currentVersion)) {
|
||||||
|
String[] msg = new String[] {
|
||||||
|
ChatColor.GREEN + plugin.getName() + "插件最新版本 v" + newVersion,
|
||||||
|
ChatColor.RED + "服务器运行版本: v" + currentVersion,
|
||||||
|
ChatColor.GOLD + "插件更新网站: " + ChatColor.BLUE
|
||||||
|
+ plugin.getDescription().getWebsite()
|
||||||
|
};
|
||||||
|
if (player != null) {
|
||||||
|
player.sendMessage(msg);
|
||||||
|
} else {
|
||||||
|
plugin.getServer().getConsoleSender().sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
plugin.getLogger().warning("版本更新检查失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,29 @@
|
||||||
#本文件为插件的主配置文件
|
#本文件为插件的主配置文件
|
||||||
version: 1.0
|
version: 1.2
|
||||||
#服务器名称
|
#服务器名称
|
||||||
servername: ''
|
servername: ''
|
||||||
#插件名称
|
#插件名称
|
||||||
pluginname: '&6[&b彩票系统&6]&r '
|
pluginname: '&6[&b彩票系统&6]&r '
|
||||||
#是否需要对应彩票号码位置
|
#每隔多久开奖一次(单位: 分钟)
|
||||||
numbersame: true
|
RewardTime: 5
|
||||||
|
#是否需要对应彩票号码位置
|
||||||
|
numbersame: true
|
||||||
|
#单张彩票价格
|
||||||
|
price: 200
|
||||||
|
#返现金额(红色球一个代表1点,蓝色球代表10点自行相加!)
|
||||||
|
#注意:请不要删除0这一行,配置错误将默认全部返还彩票价格的金钱.
|
||||||
|
Reward:
|
||||||
|
0: 0
|
||||||
|
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: 10000
|
|
@ -1,8 +1,38 @@
|
||||||
name: LuckLottery
|
name: LuckLottery
|
||||||
main: cn.citycraft.LuckLottery.LuckLottery
|
main: cn.citycraft.LuckLottery.LuckLottery
|
||||||
author: 喵♂呜
|
author: 喵♂呜
|
||||||
version: 0.0.3
|
website: http://ci.citycraft.cn:8800/jenkins/job/LuckLottery/
|
||||||
|
version: 0.1.0
|
||||||
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.reload: 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
|
||||||
|
lucklottery.reload:
|
||||||
|
description: 允许重载彩票插件!
|
||||||
|
default: op
|
Loading…
Reference in New Issue