From 0cbb61647fc7d76cc92b9be739470cab37f0c935 Mon Sep 17 00:00:00 2001 From: j502647092 Date: Wed, 20 May 2015 23:50:06 +0800 Subject: [PATCH 1/3] remove depended... Signed-off-by: j502647092 --- .../LuckLottery/runnable/LotteryReward.java | 40 ------------------- src/plugin.yml | 4 +- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/src/cn/citycraft/LuckLottery/runnable/LotteryReward.java b/src/cn/citycraft/LuckLottery/runnable/LotteryReward.java index 8529989..dba9b13 100644 --- a/src/cn/citycraft/LuckLottery/runnable/LotteryReward.java +++ b/src/cn/citycraft/LuckLottery/runnable/LotteryReward.java @@ -56,46 +56,6 @@ public class LotteryReward implements Runnable { case 15: winprices = 5000; break; - // case 0: - // case 1: - // winprices = 0; - // break; - // case 2: - // winprices = 500; - // break; - // case 3: - // winprices = 1000; - // break; - // case 4: - // winprices = 3000; - // break; - // case 5: - // winprices = 5000; - // break; - // case 6: - // winprices = 10000; - // break; - // case 10: - // winprices = 0; - // break; - // case 11: - // winprices = 500; - // break; - // case 12: - // winprices = 1000; - // break; - // case 13: - // winprices = 3000; - // break; - // case 14: - // winprices = 5000; - // break; - // case 15: - // winprices = 10000; - // break; - // case 16: - // winprices = 50000; - // break; default: } if (winprices > 0) { diff --git a/src/plugin.yml b/src/plugin.yml index 918d323..b2cd97b 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,8 +1,8 @@ name: LuckLottery main: cn.citycraft.LuckLottery.LuckLottery author: 喵♂呜 -version: 0.0.1 -depended: [BVLib,Vault] +version: 0.0.3 +depended: [Vault] commands: lucklottery: aliases: [ll] \ No newline at end of file From 5b32f28d08d748b57e12ab3387bbd065e32ea6ec Mon Sep 17 00:00:00 2001 From: j502647092 Date: Sat, 1 Aug 2015 23:31:38 +0800 Subject: [PATCH 2/3] add @Overraide flags... Signed-off-by: j502647092 --- src/cn/citycraft/LuckLottery/LuckLottery.java | 60 +++++++++---------- .../LuckLottery/config/FileConfig.java | 55 ++++++++--------- 2 files changed, 58 insertions(+), 57 deletions(-) diff --git a/src/cn/citycraft/LuckLottery/LuckLottery.java b/src/cn/citycraft/LuckLottery/LuckLottery.java index 51d1fad..3de96db 100644 --- a/src/cn/citycraft/LuckLottery/LuckLottery.java +++ b/src/cn/citycraft/LuckLottery/LuckLottery.java @@ -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 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 chatProvider = getServer() - .getServicesManager().getRegistration( - net.milkbowl.vault.chat.Chat.class); + RegisteredServiceProvider 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 economyProvider = getServer() - .getServicesManager().getRegistration( - net.milkbowl.vault.economy.Economy.class); + RegisteredServiceProvider economyProvider = getServer().getServicesManager() + .getRegistration(net.milkbowl.vault.economy.Economy.class); if (economyProvider != null) { economy = economyProvider.getProvider(); } return (economy != null); } + public boolean setupPermissions() { + RegisteredServiceProvider permissionProvider = getServer().getServicesManager() + .getRegistration(net.milkbowl.vault.permission.Permission.class); + if (permissionProvider != null) { + permission = permissionProvider.getProvider(); + } + return (permission != null); + } + } diff --git a/src/cn/citycraft/LuckLottery/config/FileConfig.java b/src/cn/citycraft/LuckLottery/config/FileConfig.java index 6f341e7..10194ed 100644 --- a/src/cn/citycraft/LuckLottery/config/FileConfig.java +++ b/src/cn/citycraft/LuckLottery/config/FileConfig.java @@ -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(); - } - } } From 7a45268dfd6996382c3ee2b9a5703da79f741094 Mon Sep 17 00:00:00 2001 From: j502647092 Date: Sat, 1 Aug 2015 23:39:03 +0800 Subject: [PATCH 3/3] updata .gitignore... Signed-off-by: j502647092 --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 10c6caa..dc550f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +/.settings +.classpath + # netbeans /nbproject