mirror of
https://e.coding.net/circlecloud/LuckLottery.git
synced 2025-11-26 22:06:09 +00:00
@@ -24,19 +24,14 @@ public class LuckLottery extends JavaPlugin {
|
||||
public static Chat chat = null;
|
||||
public static LuckLottery plugin;
|
||||
|
||||
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"));
|
||||
@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()) {
|
||||
@@ -62,20 +57,18 @@ public class LuckLottery extends JavaPlugin {
|
||||
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
this.getLogger().info("保存彩票数据中...");
|
||||
this.getLogger().info("保存玩家数据中...");
|
||||
LotteryUtils.saveLottery();
|
||||
}
|
||||
@Override
|
||||
public void onLoad() {
|
||||
plugin = this;
|
||||
Config.load(this, "1.2");
|
||||
OfflineDate.load(this);
|
||||
PlayerDate.load(this);
|
||||
LotteryUtils.reloadPlayerLottery();
|
||||
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
||||
|
||||
public boolean setupPermissions() {
|
||||
RegisteredServiceProvider<Permission> permissionProvider = getServer()
|
||||
.getServicesManager().getRegistration(
|
||||
net.milkbowl.vault.permission.Permission.class);
|
||||
if (permissionProvider != null) {
|
||||
permission = permissionProvider.getProvider();
|
||||
}
|
||||
return (permission != null);
|
||||
LotteryUtils.setNumbersame(Config.getInstance()
|
||||
.getBoolean("numbersame"));
|
||||
LotteryUtils.setPrice(Config.getInstance().getInt("price"));
|
||||
}
|
||||
|
||||
public boolean setupChat() {
|
||||
@@ -99,4 +92,14 @@ public class LuckLottery extends JavaPlugin {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,15 +31,7 @@ public class LuckLotteryCommand implements CommandExecutor {
|
||||
int price = LotteryUtils.getPrice();
|
||||
if (LuckLottery.economy.hasAccount(p)
|
||||
&& LuckLottery.economy.has(p, price)) {
|
||||
// p.closeInventory();
|
||||
// plugin.getServer().getScheduler()
|
||||
// .runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
InvUtils.openGui(p);
|
||||
// }
|
||||
//
|
||||
// }, 2);
|
||||
} else {
|
||||
ChatUtils.sendMessage(p, ChatColor.GOLD
|
||||
+ "你没有足够的金钱购买彩票,每张彩票" + ChatColor.RED + price
|
||||
@@ -95,9 +87,9 @@ public class LuckLotteryCommand implements CommandExecutor {
|
||||
case "reload":
|
||||
if (PermissionUtils.Check(sender, PermissionUtils.Reload)) {
|
||||
PluginManager pm = plugin.getServer().getPluginManager();
|
||||
ChatUtils.sendMessage(sender, ChatColor.GREEN + "配置文件已重载!");
|
||||
pm.disablePlugin(plugin);
|
||||
pm.enablePlugin(plugin);
|
||||
ChatUtils.sendMessage(sender, ChatColor.GREEN + "配置文件已重载!");
|
||||
}
|
||||
return true;
|
||||
case "help":
|
||||
|
||||
@@ -30,11 +30,6 @@ import com.google.common.io.Files;
|
||||
*/
|
||||
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,19 +48,14 @@ public class FileConfig extends YamlConfiguration {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveToString() {
|
||||
yamlOptions.setIndent(options().indent());
|
||||
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
String header = buildHeader();
|
||||
String dump = yaml.dump(getValues(false));
|
||||
if (dump.equals(BLANK_CONFIG)) {
|
||||
dump = "";
|
||||
}
|
||||
return header + dump;
|
||||
}
|
||||
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");
|
||||
@@ -73,6 +63,7 @@ public class FileConfig extends YamlConfiguration {
|
||||
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);
|
||||
@@ -85,4 +76,17 @@ public class FileConfig extends YamlConfiguration {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveToString() {
|
||||
yamlOptions.setIndent(options().indent());
|
||||
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
String header = buildHeader();
|
||||
String dump = yaml.dump(getValues(false));
|
||||
if (dump.equals(BLANK_CONFIG)) {
|
||||
dump = "";
|
||||
}
|
||||
return header + dump;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user