1
0
mirror of https://e.coding.net/circlecloud/RealBackpacks.git synced 2024-12-04 03:49:07 +00:00

update to use BVLib...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-05-14 08:34:03 +08:00
parent 98b244f452
commit 661b79fa52
3 changed files with 99 additions and 45 deletions

View File

@ -11,7 +11,6 @@ import net.milkbowl.vault.economy.Economy;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -19,6 +18,7 @@ import org.bukkit.material.MaterialData;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import cn.citycraft.plugins.config.Config;
import cn.citycraft.plugins.listeners.CraftListener; import cn.citycraft.plugins.listeners.CraftListener;
import cn.citycraft.plugins.listeners.EntityListener; import cn.citycraft.plugins.listeners.EntityListener;
import cn.citycraft.plugins.listeners.InventoryListener; import cn.citycraft.plugins.listeners.InventoryListener;
@ -28,12 +28,6 @@ import cn.citycraft.plugins.util.RBUtil;
public class RealBackpacks extends JavaPlugin { public class RealBackpacks extends JavaPlugin {
@Override
public FileConfiguration getConfig() {
// TODO 自动生成的方法存根
return super.getConfig();
}
public static RBInterface NMS; public static RBInterface NMS;
public static Economy econ = null; public static Economy econ = null;
@ -87,7 +81,6 @@ public class RealBackpacks extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
final String p = getServer().getClass().getPackage().getName(); final String p = getServer().getClass().getPackage().getName();
final String version = p.substring(p.lastIndexOf('.') + 1); final String version = p.substring(p.lastIndexOf('.') + 1);
String classname = getClass().getPackage().getName() + ".versions." String classname = getClass().getPackage().getName() + ".versions."
@ -105,7 +98,6 @@ public class RealBackpacks extends JavaPlugin {
} }
if (isEnabled()) { if (isEnabled()) {
saveDefaultConfig();
MysqlFunctions.setMysqlFunc(this); MysqlFunctions.setMysqlFunc(this);
RBUtil.setRBUtil(this); RBUtil.setRBUtil(this);
if (!setupEconomy()) { if (!setupEconomy()) {
@ -114,7 +106,6 @@ public class RealBackpacks extends JavaPlugin {
} else { } else {
getLogger().info("Vault found, economy features enabled."); getLogger().info("Vault found, economy features enabled.");
} }
reloadConfig();
setupLists(); setupLists();
final File userdata = new File(getDataFolder() + File.separator final File userdata = new File(getDataFolder() + File.separator
+ "userdata"); + "userdata");
@ -134,17 +125,33 @@ public class RealBackpacks extends JavaPlugin {
getCommand("rb").setExecutor(new MainCommand(this)); getCommand("rb").setExecutor(new MainCommand(this));
getServer().getScheduler().runTaskTimer(this, getServer().getScheduler().runTaskTimer(this,
new WalkSpeedRunnable(this), 20, 20); new WalkSpeedRunnable(this), 20, 20);
getLogger().info("Realistic Backpacks has been enabled."); getLogger().info("真实背包已加载 By: 喵♂呜.");
} }
} }
} }
@Override @Override
public void onDisable() { public FileConfiguration getConfig() {
econ = null; if(Config.getInstance()==null){
HandlerList.unregisterAll(this); Config.load(this);
getServer().getPluginManager().disablePlugin(this); }
getLogger().info("Realistic Backpacks has been disabled."); return Config.getInstance();
}
/* Javadoc
* @see org.bukkit.plugin.java.JavaPlugin#saveConfig()
*/
@Override
public void saveConfig() {
Config.save();
}
/* Javadoc
* @see org.bukkit.plugin.java.JavaPlugin#reloadConfig()
*/
@Override
public void reloadConfig() {
Config.load(this);
} }
private boolean setupEconomy() { private boolean setupEconomy() {

View File

@ -0,0 +1,47 @@
package cn.citycraft.plugins.config;
import java.io.File;
import java.io.IOException;
import org.bukkit.plugin.Plugin;
import cn.citycraft.Utils.config.ConfigLoader;
import cn.citycraft.Utils.config.FileConfig;
public class Config extends ConfigLoader {
private static String CONFIG_NAME = "config.yml";
private static FileConfig instance;
private static File file;
public Config(Plugin p) {
super(p, CONFIG_NAME);
file = new File(p.getDataFolder(), CONFIG_NAME);
instance = super.getInstance();
}
public static void load(Plugin p) {
new Config(p);
}
public static FileConfig getInstance() {
return instance;
}
public static String getMessage(String path) {
String message = instance.getString(path).replaceAll("&", "§");
return message;
}
public static String[] getStringArray(String path) {
return instance.getStringList(path).toArray(new String[0]);
}
public static void save(){
try {
instance.save(file);
} catch (IOException e) {
saveError(file);
e.printStackTrace();
}
}
}

View File

@ -26,13 +26,13 @@ Backpacks:
- 334,334,334 - 334,334,334
BackpackItem: BackpackItem:
id: 334 id: 334
name: "&a背包-18" name: "&a背包-18"
lore: lore:
- "&5一个随身携带的背包." - "&5一个随身携带的背包."
- "&b有&d18&b个格子的物品可存放." - "&b有&d18&b个格子的物品可存放."
- "&3移动速度下降5%." - "&3移动速度下降5%."
- "&6背包掉落或丢失再次购买即可物品不丢失." - "&6背包掉落或丢失再次购买即可物品不丢失."
- "&c每种背包仅需购买一次多个不叠加." - "&c每种背包仅需购买一次多个不叠加."
UseWhitelist: false UseWhitelist: false
ItemWhitelist: [] ItemWhitelist: []
ItemBlacklist: ItemBlacklist:
@ -68,13 +68,13 @@ Backpacks:
- 334,334,334 - 334,334,334
BackpackItem: BackpackItem:
id: 334 id: 334
name: "&a背包-27" name: "&a背包-27"
lore: lore:
- "&5一个随身携带的背包." - "&5一个随身携带的背包."
- "&b有&d27&b个格子的物品可存放." - "&b有&d27&b个格子的物品可存放."
- "&3移动速度下降10%." - "&3移动速度下降10%."
- "&6背包掉落或丢失再次购买即可物品不丢失." - "&6背包掉落或丢失再次购买即可物品不丢失."
- "&c每种背包仅需购买一次多个不叠加." - "&c每种背包仅需购买一次多个不叠加."
UseWhitelist: false UseWhitelist: false
ItemWhitelist: [] ItemWhitelist: []
ItemBlacklist: ItemBlacklist:
@ -110,13 +110,13 @@ Backpacks:
- 334,334,334 - 334,334,334
BackpackItem: BackpackItem:
id: 334 id: 334
name: "&a背包-36" name: "&a背包-36"
lore: lore:
- "&5一个随身携带的背包." - "&5一个随身携带的背包."
- "&b有&d36&b个格子的物品可存放." - "&b有&d36&b个格子的物品可存放."
- "&3移动速度下降15%." - "&3移动速度下降15%."
- "&6背包掉落或丢失再次购买即可物品不丢失." - "&6背包掉落或丢失再次购买即可物品不丢失."
- "&c每种背包仅需购买一次多个不叠加." - "&c每种背包仅需购买一次多个不叠加."
UseWhitelist: false UseWhitelist: false
ItemWhitelist: [] ItemWhitelist: []
ItemBlacklist: ItemBlacklist:
@ -152,13 +152,13 @@ Backpacks:
- 334,334,334 - 334,334,334
BackpackItem: BackpackItem:
id: 334 id: 334
name: "&a背包-45" name: "&a背包-45"
lore: lore:
- "&5一个随身携带的背包." - "&5一个随身携带的背包."
- "&b有&d45&b个格子的物品可存放." - "&b有&d45&b个格子的物品可存放."
- "&3移动速度下降20%." - "&3移动速度下降20%."
- "&6背包掉落或丢失再次购买即可物品不丢失." - "&6背包掉落或丢失再次购买即可物品不丢失."
- "&c每种背包仅需购买一次多个不叠加." - "&c每种背包仅需购买一次多个不叠加."
UseWhitelist: false UseWhitelist: false
ItemWhitelist: [] ItemWhitelist: []
ItemBlacklist: ItemBlacklist:
@ -194,12 +194,12 @@ Backpacks:
- 334,334,334 - 334,334,334
BackpackItem: BackpackItem:
id: 334 id: 334
name: "&a背包-54" name: "&a背包-54"
lore: lore:
- "&5一个随身携带的背包." - "&5一个随身携带的背包."
- "&b有&d54&b个格子的物品可存放." - "&b有&d54&b个格子的物品可存放."
- "&6背包掉落或丢失再次购买即可物品不丢失." - "&6背包掉落或丢失再次购买即可物品不丢失."
- "&c每种背包仅需购买一次多个不叠加." - "&c每种背包仅需购买一次多个不叠加."
UseWhitelist: false UseWhitelist: false
ItemWhitelist: [] ItemWhitelist: []
ItemBlacklist: ItemBlacklist: