parent
e5b52876e3
commit
4207a6557c
|
@ -1,105 +1,100 @@
|
||||||
package cn.citycraft.LuckLottery;
|
package cn.citycraft.LuckLottery;
|
||||||
|
|
||||||
import net.milkbowl.vault.chat.Chat;
|
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 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;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import cn.citycraft.LuckLottery.command.LuckLotteryCommand;
|
import cn.citycraft.LuckLottery.command.LuckLotteryCommand;
|
||||||
import cn.citycraft.LuckLottery.config.Config;
|
import cn.citycraft.LuckLottery.config.Config;
|
||||||
import cn.citycraft.LuckLottery.config.OfflineDate;
|
import cn.citycraft.LuckLottery.config.OfflineDate;
|
||||||
import cn.citycraft.LuckLottery.config.PlayerDate;
|
import cn.citycraft.LuckLottery.config.PlayerDate;
|
||||||
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;
|
||||||
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
||||||
|
|
||||||
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 Permission permission = null;
|
||||||
public static Economy economy = null;
|
public static Economy economy = null;
|
||||||
public static Chat chat = 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("保存彩票数据中...");
|
||||||
this.getLogger().info("保存玩家数据中...");
|
this.getLogger().info("保存玩家数据中...");
|
||||||
LotteryUtils.saveLottery();
|
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").isEnabled()) {
|
||||||
this.getLogger().warning("未找到前置插件Vault 关闭插件...");
|
this.getLogger().warning("未找到前置插件Vault 关闭插件...");
|
||||||
this.getServer().getPluginManager().disablePlugin(this);
|
this.getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (setupEconomy()) {
|
if (setupEconomy()) {
|
||||||
LuckLottery.isEconomy = true;
|
LuckLottery.isEconomy = true;
|
||||||
this.getLogger().info("发现Vault 载入数据...");
|
this.getLogger().info("发现Vault 载入数据...");
|
||||||
} else {
|
} else {
|
||||||
this.getLogger().warning("发现Vault 但是无法找到经济插件 关闭插件...");
|
this.getLogger().warning("发现Vault 但是无法找到经济插件 关闭插件...");
|
||||||
this.getServer().getPluginManager().disablePlugin(this);
|
this.getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int rewardtime = Config.getInstance().getInt("RewardTime", 10);
|
int rewardtime = Config.getInstance().getInt("RewardTime", 10);
|
||||||
this.getServer()
|
this.getServer().getScheduler()
|
||||||
.getScheduler()
|
.runTaskTimer(plugin, new LotteryReward(true), 10, rewardtime * 60 * 20);
|
||||||
.runTaskTimer(plugin, new LotteryReward(true), 10,
|
this.getLogger().info("彩票系统已开启...");
|
||||||
rewardtime * 60 * 20);
|
pm.registerEvents(new PlayerListen(), this);
|
||||||
this.getLogger().info("彩票系统已开启...");
|
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
||||||
pm.registerEvents(new PlayerListen(), this);
|
}
|
||||||
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
|
||||||
}
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
@Override
|
plugin = this;
|
||||||
public void onLoad() {
|
Config.load(this, "1.2");
|
||||||
plugin = this;
|
OfflineDate.load(this);
|
||||||
Config.load(this, "1.2");
|
PlayerDate.load(this);
|
||||||
OfflineDate.load(this);
|
LotteryUtils.reloadPlayerLottery();
|
||||||
PlayerDate.load(this);
|
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
||||||
LotteryUtils.reloadPlayerLottery();
|
|
||||||
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
LotteryUtils.setNumbersame(Config.getInstance().getBoolean("numbersame"));
|
||||||
|
LotteryUtils.setPrice(Config.getInstance().getInt("price"));
|
||||||
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);
|
||||||
public boolean setupChat() {
|
if (chatProvider != null) {
|
||||||
RegisteredServiceProvider<Chat> chatProvider = getServer()
|
chat = chatProvider.getProvider();
|
||||||
.getServicesManager().getRegistration(
|
}
|
||||||
net.milkbowl.vault.chat.Chat.class);
|
|
||||||
if (chatProvider != null) {
|
return (chat != null);
|
||||||
chat = chatProvider.getProvider();
|
}
|
||||||
}
|
|
||||||
|
public boolean setupEconomy() {
|
||||||
return (chat != null);
|
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager()
|
||||||
}
|
.getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||||
|
if (economyProvider != null) {
|
||||||
public boolean setupEconomy() {
|
economy = economyProvider.getProvider();
|
||||||
RegisteredServiceProvider<Economy> economyProvider = getServer()
|
}
|
||||||
.getServicesManager().getRegistration(
|
return (economy != null);
|
||||||
net.milkbowl.vault.economy.Economy.class);
|
}
|
||||||
if (economyProvider != null) {
|
|
||||||
economy = economyProvider.getProvider();
|
public boolean setupPermissions() {
|
||||||
}
|
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager()
|
||||||
return (economy != null);
|
.getRegistration(net.milkbowl.vault.permission.Permission.class);
|
||||||
}
|
if (permissionProvider != null) {
|
||||||
|
permission = permissionProvider.getProvider();
|
||||||
public boolean setupPermissions() {
|
}
|
||||||
RegisteredServiceProvider<Permission> permissionProvider = getServer()
|
return (permission != null);
|
||||||
.getServicesManager().getRegistration(
|
|
||||||
net.milkbowl.vault.permission.Permission.class);
|
}
|
||||||
if (permissionProvider != null) {
|
|
||||||
permission = permissionProvider.getProvider();
|
}
|
||||||
}
|
|
||||||
return (permission != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -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,35 +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 final String ShowAll = "lucklottery.showall";
|
public static final String ShowAll = "lucklottery.showall";
|
||||||
public static final String Reward = "lucklottery.reward";
|
public static final String Reward = "lucklottery.reward";
|
||||||
public static final String Random = "lucklottery.random";
|
public static final String Random = "lucklottery.random";
|
||||||
public static final String Look = "lucklottery.look";
|
public static final String Look = "lucklottery.look";
|
||||||
public static final String Clear = "lucklottery.clear";
|
public static final String Clear = "lucklottery.clear";
|
||||||
public static final String Reload = "lucklottery.reload";
|
public static final String Reload = "lucklottery.reload";
|
||||||
|
|
||||||
public static String No_Permission = ChatColor.RED + "你没有此命令的权限!";
|
public static String No_Permission = ChatColor.RED + "你没有此命令的权限!";
|
||||||
|
|
||||||
public static boolean Check(Player p, String perm) {
|
public static boolean Check(Player p, String perm) {
|
||||||
if (p.hasPermission(perm)) {
|
if (p.hasPermission(perm)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ChatUtils.noPermission(p);
|
ChatUtils.noPermission(p);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean Check(CommandSender p, String perm) {
|
public static boolean Check(CommandSender p, String perm) {
|
||||||
if (p.hasPermission(perm)) {
|
if (p.hasPermission(perm)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
ChatUtils.noPermission(p);
|
ChatUtils.noPermission(p);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue