parent
e5b52876e3
commit
4207a6557c
|
@ -1,105 +1,100 @@
|
|||
package cn.citycraft.LuckLottery;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.LuckLottery.command.LuckLotteryCommand;
|
||||
import cn.citycraft.LuckLottery.config.Config;
|
||||
import cn.citycraft.LuckLottery.config.OfflineDate;
|
||||
import cn.citycraft.LuckLottery.config.PlayerDate;
|
||||
import cn.citycraft.LuckLottery.listen.PlayerListen;
|
||||
import cn.citycraft.LuckLottery.runnable.LotteryReward;
|
||||
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
||||
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
||||
|
||||
public class LuckLottery extends JavaPlugin {
|
||||
public static boolean isEconomy;
|
||||
public static Permission permission = null;
|
||||
public static Economy economy = null;
|
||||
public static Chat chat = null;
|
||||
public static LuckLottery plugin;
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.getLogger().info("保存彩票数据中...");
|
||||
this.getLogger().info("保存玩家数据中...");
|
||||
LotteryUtils.saveLottery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
if (!pm.getPlugin("Vault").isEnabled()) {
|
||||
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;
|
||||
}
|
||||
int rewardtime = Config.getInstance().getInt("RewardTime", 10);
|
||||
this.getServer()
|
||||
.getScheduler()
|
||||
.runTaskTimer(plugin, new LotteryReward(true), 10,
|
||||
rewardtime * 60 * 20);
|
||||
this.getLogger().info("彩票系统已开启...");
|
||||
pm.registerEvents(new PlayerListen(), this);
|
||||
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
plugin = this;
|
||||
Config.load(this, "1.2");
|
||||
OfflineDate.load(this);
|
||||
PlayerDate.load(this);
|
||||
LotteryUtils.reloadPlayerLottery();
|
||||
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
||||
|
||||
LotteryUtils.setNumbersame(Config.getInstance()
|
||||
.getBoolean("numbersame"));
|
||||
LotteryUtils.setPrice(Config.getInstance().getInt("price"));
|
||||
}
|
||||
|
||||
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() {
|
||||
RegisteredServiceProvider<Economy> economyProvider = getServer()
|
||||
.getServicesManager().getRegistration(
|
||||
net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
package cn.citycraft.LuckLottery;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.LuckLottery.command.LuckLotteryCommand;
|
||||
import cn.citycraft.LuckLottery.config.Config;
|
||||
import cn.citycraft.LuckLottery.config.OfflineDate;
|
||||
import cn.citycraft.LuckLottery.config.PlayerDate;
|
||||
import cn.citycraft.LuckLottery.listen.PlayerListen;
|
||||
import cn.citycraft.LuckLottery.runnable.LotteryReward;
|
||||
import cn.citycraft.LuckLottery.utils.ChatUtils;
|
||||
import cn.citycraft.LuckLottery.utils.LotteryUtils;
|
||||
|
||||
public class LuckLottery extends JavaPlugin {
|
||||
public static boolean isEconomy;
|
||||
public static Permission permission = null;
|
||||
public static Economy economy = null;
|
||||
public static Chat chat = null;
|
||||
public static LuckLottery plugin;
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.getLogger().info("保存彩票数据中...");
|
||||
this.getLogger().info("保存玩家数据中...");
|
||||
LotteryUtils.saveLottery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
if (!pm.getPlugin("Vault").isEnabled()) {
|
||||
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;
|
||||
}
|
||||
int rewardtime = Config.getInstance().getInt("RewardTime", 10);
|
||||
this.getServer().getScheduler()
|
||||
.runTaskTimer(plugin, new LotteryReward(true), 10, rewardtime * 60 * 20);
|
||||
this.getLogger().info("彩票系统已开启...");
|
||||
pm.registerEvents(new PlayerListen(), this);
|
||||
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
plugin = this;
|
||||
Config.load(this, "1.2");
|
||||
OfflineDate.load(this);
|
||||
PlayerDate.load(this);
|
||||
LotteryUtils.reloadPlayerLottery();
|
||||
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
||||
|
||||
LotteryUtils.setNumbersame(Config.getInstance().getBoolean("numbersame"));
|
||||
LotteryUtils.setPrice(Config.getInstance().getInt("price"));
|
||||
}
|
||||
|
||||
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() {
|
||||
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager()
|
||||
.getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
package cn.citycraft.LuckLottery.config;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
private static String CONFIG_NAME = "config.yml";
|
||||
private static FileConfig instance;
|
||||
|
||||
public Config(Plugin p, String ver) {
|
||||
super(p, CONFIG_NAME, ver);
|
||||
instance = super.getInstance();
|
||||
}
|
||||
|
||||
public static void load(Plugin p, String ver) {
|
||||
new Config(p, ver);
|
||||
}
|
||||
|
||||
public static FileConfig getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static String getMessage(String path) {
|
||||
String message = instance.getString(path).replaceAll("&", "§");
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
package cn.citycraft.LuckLottery.config;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
private static String CONFIG_NAME = "config.yml";
|
||||
private static FileConfig instance;
|
||||
|
||||
public Config(Plugin p, String ver) {
|
||||
super(p, CONFIG_NAME, ver);
|
||||
instance = super.getInstance();
|
||||
}
|
||||
|
||||
public static void load(Plugin p, String ver) {
|
||||
new Config(p, ver);
|
||||
}
|
||||
|
||||
public static FileConfig getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static String getMessage(String path) {
|
||||
String message = instance.getString(path).replaceAll("&", "§");
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,35 +1,35 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue