77 lines
2.2 KiB
Java
77 lines
2.2 KiB
Java
package cn.citycraft.GuiACK;
|
|
|
|
import java.io.IOException;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
import org.mcstats.Metrics;
|
|
|
|
import cn.citycraft.GuiACK.gui.VerifyGui;
|
|
import cn.citycraft.GuiACK.listen.PlayerListen;
|
|
import cn.citycraft.GuiACK.runnable.TaskManager;
|
|
import cn.citycraft.PluginHelper.config.FileConfig;
|
|
import net.milkbowl.vault.economy.Economy;
|
|
|
|
public class GuiACK extends JavaPlugin {
|
|
public boolean isEconomy;
|
|
public Economy economy = null;
|
|
FileConfig config;
|
|
public int tasktime;
|
|
public double reward;
|
|
|
|
@Override
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
if (args.length != 1)
|
|
return false;
|
|
if (args[0].equalsIgnoreCase("reload")) {
|
|
onLoad();
|
|
sender.sendMessage("配置文件已重载!");
|
|
}
|
|
if (args[0].equalsIgnoreCase("test") && sender instanceof Player)
|
|
VerifyGui.open((Player) sender);
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
if (setupEconomy()) {
|
|
isEconomy = true;
|
|
this.getLogger().info("发现Vault 载入数据...");
|
|
} else {
|
|
this.getLogger().warning("发现Vault 但是无法找到经济插件 关闭插件...");
|
|
setEnabled(false);
|
|
return;
|
|
}
|
|
try {
|
|
Metrics metrics = new Metrics(this);
|
|
metrics.start();
|
|
} catch (IOException e) {
|
|
}
|
|
this.getServer().getPluginManager().registerEvents(new PlayerListen(this), this);
|
|
for (Player p : Bukkit.getOnlinePlayers())
|
|
TaskManager.add(p);
|
|
this.getLogger().info("图形化防挂机验证码加载完毕!");
|
|
}
|
|
|
|
@Override
|
|
public void onLoad() {
|
|
config = new FileConfig(this);
|
|
tasktime = config.getInt("TaskTime");
|
|
reward = config.getDouble("Reward");
|
|
VerifyGui.init(config.getStringList("VerifyList"));
|
|
TaskManager.init(this);
|
|
}
|
|
|
|
public boolean setupEconomy() {
|
|
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
|
if (economyProvider != null)
|
|
economy = economyProvider.getProvider();
|
|
return (economy != null);
|
|
}
|
|
|
|
}
|