parent
0cbb61647f
commit
5b32f28d08
|
@ -24,18 +24,18 @@ public class LuckLottery extends JavaPlugin {
|
|||
public static Chat chat = null;
|
||||
public static LuckLottery plugin;
|
||||
|
||||
public void onLoad() {
|
||||
plugin = this;
|
||||
Config.load(this, "1.1");
|
||||
OfflineDate.load(this);
|
||||
PlayerDate.load(this);
|
||||
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
||||
LotteryUtils.setNumbersame(Config.getInstance().getBoolean("numbersame"));
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.getLogger().info("保存彩票数据中...");
|
||||
LotteryUtils.saveLottery();
|
||||
this.getLogger().info("保存玩家数据中...");
|
||||
PlayerDate.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
if (!pm.getPlugin("Vault").isEnabled()){
|
||||
if (!pm.getPlugin("Vault").isEnabled()) {
|
||||
this.getLogger().warning("未找到前置插件Vault 关闭插件...");
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
|
@ -49,33 +49,25 @@ public class LuckLottery extends JavaPlugin {
|
|||
return;
|
||||
}
|
||||
this.getServer().getScheduler()
|
||||
.runTaskTimer(plugin, new LotteryReward(true), 10, 10 * 60 * 20);
|
||||
.runTaskTimer(plugin, new LotteryReward(true), 10, 10 * 60 * 20);
|
||||
this.getLogger().info("彩票系统已开启...");
|
||||
pm.registerEvents(new PlayerListen(), this);
|
||||
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
this.getLogger().info("保存彩票数据中...");
|
||||
LotteryUtils.saveLottery();
|
||||
this.getLogger().info("保存玩家数据中...");
|
||||
PlayerDate.save();
|
||||
}
|
||||
|
||||
public boolean setupPermissions() {
|
||||
RegisteredServiceProvider<Permission> permissionProvider = getServer()
|
||||
.getServicesManager().getRegistration(
|
||||
net.milkbowl.vault.permission.Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
permission = permissionProvider.getProvider();
|
||||
}
|
||||
return (permission != null);
|
||||
@Override
|
||||
public void onLoad() {
|
||||
plugin = this;
|
||||
Config.load(this, "1.1");
|
||||
OfflineDate.load(this);
|
||||
PlayerDate.load(this);
|
||||
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
||||
LotteryUtils.setNumbersame(Config.getInstance().getBoolean("numbersame"));
|
||||
}
|
||||
|
||||
public boolean setupChat() {
|
||||
RegisteredServiceProvider<Chat> chatProvider = getServer()
|
||||
.getServicesManager().getRegistration(
|
||||
net.milkbowl.vault.chat.Chat.class);
|
||||
RegisteredServiceProvider<Chat> chatProvider = getServer().getServicesManager()
|
||||
.getRegistration(net.milkbowl.vault.chat.Chat.class);
|
||||
if (chatProvider != null) {
|
||||
chat = chatProvider.getProvider();
|
||||
}
|
||||
|
@ -84,13 +76,21 @@ public class LuckLottery extends JavaPlugin {
|
|||
}
|
||||
|
||||
public boolean setupEconomy() {
|
||||
RegisteredServiceProvider<Economy> economyProvider = getServer()
|
||||
.getServicesManager().getRegistration(
|
||||
net.milkbowl.vault.economy.Economy.class);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,16 +25,11 @@ import com.google.common.base.Charsets;
|
|||
import com.google.common.io.Files;
|
||||
|
||||
/**
|
||||
* An implementation of {@link Configuration} which saves all files in Yaml.
|
||||
* Note that this implementation is not synchronized.
|
||||
* An implementation of {@link Configuration} which saves all files in Yaml. Note that this
|
||||
* implementation is not synchronized.
|
||||
*/
|
||||
public class FileConfig extends YamlConfiguration {
|
||||
|
||||
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
||||
yamlRepresenter, yamlOptions);
|
||||
|
||||
public static FileConfig init(File file) {
|
||||
return FileConfig.loadConfiguration(file);
|
||||
}
|
||||
|
@ -53,6 +48,32 @@ public class FileConfig extends YamlConfiguration {
|
|||
return config;
|
||||
}
|
||||
|
||||
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||
|
||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||
|
||||
protected final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
|
||||
|
||||
@Override
|
||||
public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
final FileInputStream stream = new FileInputStream(file);
|
||||
load(new InputStreamReader(stream, Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(File file) throws IOException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Files.createParentDirs(file);
|
||||
String data = saveToString();
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8);
|
||||
try {
|
||||
writer.write(data);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveToString() {
|
||||
yamlOptions.setIndent(options().indent());
|
||||
|
@ -65,24 +86,4 @@ public class FileConfig extends YamlConfiguration {
|
|||
}
|
||||
return header + dump;
|
||||
}
|
||||
|
||||
public void load(File file) throws FileNotFoundException, IOException,
|
||||
InvalidConfigurationException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
final FileInputStream stream = new FileInputStream(file);
|
||||
load(new InputStreamReader(stream, Charsets.UTF_8));
|
||||
}
|
||||
|
||||
public void save(File file) throws IOException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Files.createParentDirs(file);
|
||||
String data = saveToString();
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(file),
|
||||
Charsets.UTF_8);
|
||||
try {
|
||||
writer.write(data);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue