mirror of
https://e.coding.net/circlecloud/LuckLottery.git
synced 2025-11-25 21:56:08 +00:00
@@ -24,19 +24,14 @@ public class LuckLottery extends JavaPlugin {
|
|||||||
public static Chat chat = null;
|
public static Chat chat = null;
|
||||||
public static LuckLottery plugin;
|
public static LuckLottery plugin;
|
||||||
|
|
||||||
public void onLoad() {
|
@Override
|
||||||
plugin = this;
|
public void onDisable() {
|
||||||
Config.load(this, "1.2");
|
this.getLogger().info("保存彩票数据中...");
|
||||||
OfflineDate.load(this);
|
this.getLogger().info("保存玩家数据中...");
|
||||||
PlayerDate.load(this);
|
LotteryUtils.saveLottery();
|
||||||
LotteryUtils.reloadPlayerLottery();
|
|
||||||
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
|
||||||
|
|
||||||
LotteryUtils.setNumbersame(Config.getInstance()
|
|
||||||
.getBoolean("numbersame"));
|
|
||||||
LotteryUtils.setPrice(Config.getInstance().getInt("price"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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()) {
|
||||||
@@ -62,20 +57,18 @@ public class LuckLottery extends JavaPlugin {
|
|||||||
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
getCommand("ll").setExecutor(new LuckLotteryCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
@Override
|
||||||
this.getLogger().info("保存彩票数据中...");
|
public void onLoad() {
|
||||||
this.getLogger().info("保存玩家数据中...");
|
plugin = this;
|
||||||
LotteryUtils.saveLottery();
|
Config.load(this, "1.2");
|
||||||
}
|
OfflineDate.load(this);
|
||||||
|
PlayerDate.load(this);
|
||||||
|
LotteryUtils.reloadPlayerLottery();
|
||||||
|
ChatUtils.setPluginname(Config.getMessage("pluginname"));
|
||||||
|
|
||||||
public boolean setupPermissions() {
|
LotteryUtils.setNumbersame(Config.getInstance()
|
||||||
RegisteredServiceProvider<Permission> permissionProvider = getServer()
|
.getBoolean("numbersame"));
|
||||||
.getServicesManager().getRegistration(
|
LotteryUtils.setPrice(Config.getInstance().getInt("price"));
|
||||||
net.milkbowl.vault.permission.Permission.class);
|
|
||||||
if (permissionProvider != null) {
|
|
||||||
permission = permissionProvider.getProvider();
|
|
||||||
}
|
|
||||||
return (permission != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setupChat() {
|
public boolean setupChat() {
|
||||||
@@ -99,4 +92,14 @@ public class LuckLottery extends JavaPlugin {
|
|||||||
return (economy != null);
|
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();
|
int price = LotteryUtils.getPrice();
|
||||||
if (LuckLottery.economy.hasAccount(p)
|
if (LuckLottery.economy.hasAccount(p)
|
||||||
&& LuckLottery.economy.has(p, price)) {
|
&& LuckLottery.economy.has(p, price)) {
|
||||||
// p.closeInventory();
|
|
||||||
// plugin.getServer().getScheduler()
|
|
||||||
// .runTaskLaterAsynchronously(plugin, new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
InvUtils.openGui(p);
|
InvUtils.openGui(p);
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }, 2);
|
|
||||||
} else {
|
} else {
|
||||||
ChatUtils.sendMessage(p, ChatColor.GOLD
|
ChatUtils.sendMessage(p, ChatColor.GOLD
|
||||||
+ "你没有足够的金钱购买彩票,每张彩票" + ChatColor.RED + price
|
+ "你没有足够的金钱购买彩票,每张彩票" + ChatColor.RED + price
|
||||||
@@ -95,9 +87,9 @@ public class LuckLotteryCommand implements CommandExecutor {
|
|||||||
case "reload":
|
case "reload":
|
||||||
if (PermissionUtils.Check(sender, PermissionUtils.Reload)) {
|
if (PermissionUtils.Check(sender, PermissionUtils.Reload)) {
|
||||||
PluginManager pm = plugin.getServer().getPluginManager();
|
PluginManager pm = plugin.getServer().getPluginManager();
|
||||||
|
ChatUtils.sendMessage(sender, ChatColor.GREEN + "配置文件已重载!");
|
||||||
pm.disablePlugin(plugin);
|
pm.disablePlugin(plugin);
|
||||||
pm.enablePlugin(plugin);
|
pm.enablePlugin(plugin);
|
||||||
ChatUtils.sendMessage(sender, ChatColor.GREEN + "配置文件已重载!");
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case "help":
|
case "help":
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ import com.google.common.io.Files;
|
|||||||
*/
|
*/
|
||||||
public class FileConfig extends YamlConfiguration {
|
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) {
|
public static FileConfig init(File file) {
|
||||||
return FileConfig.loadConfiguration(file);
|
return FileConfig.loadConfiguration(file);
|
||||||
}
|
}
|
||||||
@@ -53,19 +48,14 @@ public class FileConfig extends YamlConfiguration {
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||||
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 Representer yamlRepresenter = new YamlRepresenter();
|
||||||
|
|
||||||
|
protected final Yaml yaml = new Yaml(new YamlConstructor(),
|
||||||
|
yamlRepresenter, yamlOptions);
|
||||||
|
|
||||||
|
@Override
|
||||||
public void load(File file) throws FileNotFoundException, IOException,
|
public void load(File file) throws FileNotFoundException, IOException,
|
||||||
InvalidConfigurationException {
|
InvalidConfigurationException {
|
||||||
Validate.notNull(file, "File cannot be null");
|
Validate.notNull(file, "File cannot be null");
|
||||||
@@ -73,6 +63,7 @@ public class FileConfig extends YamlConfiguration {
|
|||||||
load(new InputStreamReader(stream, Charsets.UTF_8));
|
load(new InputStreamReader(stream, Charsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void save(File file) throws IOException {
|
public void save(File file) throws IOException {
|
||||||
Validate.notNull(file, "File cannot be null");
|
Validate.notNull(file, "File cannot be null");
|
||||||
Files.createParentDirs(file);
|
Files.createParentDirs(file);
|
||||||
@@ -85,4 +76,17 @@ public class FileConfig extends YamlConfiguration {
|
|||||||
writer.close();
|
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