mirror of
https://e.coding.net/circlecloud/RealBackpacks.git
synced 2025-11-24 21:36:12 +00:00
@@ -28,13 +28,10 @@ public class MainCommand implements CommandExecutor {
|
||||
|
||||
private boolean exist = false;
|
||||
|
||||
private String[] helps = new String[] {
|
||||
"§6====== 真实背包插件 By:喵♂呜 ======",
|
||||
"§4* §a查看可购买列表 §7/rb list ",
|
||||
"§4* §a购买背包 §7/rb buy <背包名称> ",
|
||||
private String[] helps = new String[] { "§6====== 真实背包插件 By:喵♂呜 ======",
|
||||
"§4* §a查看可购买列表 §7/rb list ", "§4* §a购买背包 §7/rb buy <背包名称> ",
|
||||
"§4* §a给玩家指定背包 §7/rb give <玩家名称> <背包名称>",
|
||||
"§4* §a查看玩家指定背包 §7/rb view <玩家名称> <背包名称>",
|
||||
"§4* §a数据转移至MySQL §7/rb filetomysql" };
|
||||
"§4* §a查看玩家指定背包 §7/rb view <玩家名称> <背包名称>", "§4* §a数据转移至MySQL §7/rb filetomysql" };
|
||||
|
||||
public MainCommand(final RealBackpacks plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -42,8 +39,7 @@ public class MainCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd,
|
||||
final String label, final String[] args) {
|
||||
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
|
||||
if (cmd.getName().equalsIgnoreCase("rb")) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(helps);
|
||||
@@ -51,9 +47,8 @@ public class MainCommand implements CommandExecutor {
|
||||
if (args.length >= 1) {
|
||||
final String command = args[0];
|
||||
if (command.equalsIgnoreCase("reload")) {
|
||||
if (plugin.isUsingPerms()
|
||||
&& !sender.hasPermission("rb.reload")) {
|
||||
sender.sendMessage(ChatColor.RED + "没有足够的权限购买");
|
||||
if (plugin.isUsingPerms() && !sender.hasPermission("rb.reload")) {
|
||||
sender.sendMessage(ChatColor.RED + "你没有此命令的权限!");
|
||||
return false;
|
||||
}
|
||||
final Long first = System.currentTimeMillis();
|
||||
@@ -61,17 +56,12 @@ public class MainCommand implements CommandExecutor {
|
||||
plugin.setupLists();
|
||||
plugin.getServer().resetRecipes();
|
||||
plugin.setup();
|
||||
sender.sendMessage(ChatColor.GRAY + "配置文件重载.");
|
||||
sender.sendMessage(ChatColor.GRAY + "用时 "
|
||||
+ ChatColor.YELLOW
|
||||
+ (System.currentTimeMillis() - first) + "毫秒"
|
||||
+ ChatColor.GRAY + ".");
|
||||
sender.sendMessage(ChatColor.GRAY + "配置文件重载完毕 用时 " + ChatColor.YELLOW
|
||||
+ (System.currentTimeMillis() - first) + "毫秒" + ChatColor.GRAY + ".");
|
||||
return true;
|
||||
} else if (command.equalsIgnoreCase("buy")
|
||||
|| command.equalsIgnoreCase("purchase")) {
|
||||
} else if (command.equalsIgnoreCase("buy") || command.equalsIgnoreCase("purchase")) {
|
||||
if (!plugin.isUsingVault()) {
|
||||
sender.sendMessage(ChatColor.RED
|
||||
+ "当前命令无法使用,因为没有安装经济插件.");
|
||||
sender.sendMessage(ChatColor.RED + "当前命令无法使用,因为没有安装经济插件.");
|
||||
return false;
|
||||
}
|
||||
if (!(sender instanceof Player)) {
|
||||
@@ -79,8 +69,8 @@ public class MainCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
if (!(args.length == 2)) {
|
||||
sender.sendMessage(ChatColor.RED + "命令错误. 正确命令:"
|
||||
+ ChatColor.GRAY + " /rb buy <backpack>");
|
||||
sender.sendMessage(ChatColor.RED + "命令错误. 正确命令:" + ChatColor.GRAY
|
||||
+ " /rb buy <backpack>");
|
||||
return false;
|
||||
}
|
||||
String backpack = null;
|
||||
@@ -89,37 +79,33 @@ public class MainCommand implements CommandExecutor {
|
||||
sender.sendMessage("背包不存在.");
|
||||
return false;
|
||||
}
|
||||
if (plugin.isUsingPerms()
|
||||
&& !sender.hasPermission("rb." + backpack + ".buy")) {
|
||||
if (plugin.isUsingPerms() && !sender.hasPermission("rb." + backpack + ".buy")) {
|
||||
sender.sendMessage("没有购买的权限.");
|
||||
return false;
|
||||
}
|
||||
if (plugin.backpackData.get(backpack).get(13) != null
|
||||
&& !plugin.backpackData.get(backpack).get(13)
|
||||
.equals("true")) {
|
||||
&& !plugin.backpackData.get(backpack).get(13).equals("true")) {
|
||||
sender.sendMessage("不能被购买.");
|
||||
return false;
|
||||
}
|
||||
final double price = Double.parseDouble(plugin.backpackData
|
||||
.get(backpack).get(14));
|
||||
final double price = Double.parseDouble(plugin.backpackData.get(backpack).get(
|
||||
14));
|
||||
if (RealBackpacks.econ.getBalance(sender.getName()) < price) {
|
||||
sender.sendMessage(ChatColor.RED + "你没有足够的钱购买这个背包.");
|
||||
return false;
|
||||
}
|
||||
final Player p = (Player) sender;
|
||||
final Inventory inv = p.getInventory();
|
||||
final ItemStack backpackItem = plugin.backpackItems
|
||||
.get(backpack);
|
||||
final ItemStack backpackItem = plugin.backpackItems.get(backpack);
|
||||
if (inv.firstEmpty() != -1) {
|
||||
RealBackpacks.econ.withdrawPlayer(p.getName(), price);
|
||||
if (plugin.backpackData.get(backpack).get(18) != null
|
||||
&& plugin.backpackData.get(backpack).get(18)
|
||||
.equalsIgnoreCase("true")) {
|
||||
.equalsIgnoreCase("true")) {
|
||||
if (RealBackpacks.globalGlow
|
||||
&& plugin.backpackData.get(backpack)
|
||||
.get(17) != null
|
||||
&& plugin.backpackData.get(backpack)
|
||||
.get(17).equalsIgnoreCase("true")) {
|
||||
&& plugin.backpackData.get(backpack).get(17) != null
|
||||
&& plugin.backpackData.get(backpack).get(17)
|
||||
.equalsIgnoreCase("true")) {
|
||||
inv.setItem(inv.firstEmpty(),
|
||||
RealBackpacks.NMS.addGlow(backpackItem));
|
||||
} else {
|
||||
@@ -127,102 +113,79 @@ public class MainCommand implements CommandExecutor {
|
||||
}
|
||||
} else {
|
||||
if (RealBackpacks.globalGlow
|
||||
&& plugin.backpackData.get(backpack)
|
||||
.get(17) != null
|
||||
&& plugin.backpackData.get(backpack)
|
||||
.get(17).equalsIgnoreCase("true")) {
|
||||
inv.addItem(RealBackpacks.NMS
|
||||
.addGlow(backpackItem));
|
||||
&& plugin.backpackData.get(backpack).get(17) != null
|
||||
&& plugin.backpackData.get(backpack).get(17)
|
||||
.equalsIgnoreCase("true")) {
|
||||
inv.addItem(RealBackpacks.NMS.addGlow(backpackItem));
|
||||
} else {
|
||||
inv.addItem(backpackItem);
|
||||
}
|
||||
}
|
||||
p.updateInventory();
|
||||
sender.sendMessage(ChatColor.GREEN + "你花费了 "
|
||||
+ ChatColor.GOLD + price + ChatColor.GREEN
|
||||
+ " 购买了背包: " + ChatColor.GOLD + backpack);
|
||||
sender.sendMessage(ChatColor.GREEN + "你花费了 " + ChatColor.GOLD + price
|
||||
+ ChatColor.GREEN + " 购买了背包: " + ChatColor.GOLD + backpack);
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "你的背包是空的.");
|
||||
return false;
|
||||
}
|
||||
} else if (command.equalsIgnoreCase("list")) {
|
||||
if (plugin.isUsingPerms()
|
||||
&& !sender.hasPermission("rb.list")) {
|
||||
if (plugin.isUsingPerms() && !sender.hasPermission("rb.list")) {
|
||||
sender.sendMessage(ChatColor.RED + "你没有此命令的权限!");
|
||||
return false;
|
||||
}
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + " 名称 "
|
||||
+ ChatColor.GOLD + "|" + ChatColor.AQUA + " 大小 "
|
||||
+ ChatColor.GOLD + "|" + ChatColor.GREEN + " 价格 ");
|
||||
sender.sendMessage(ChatColor.GOLD
|
||||
+ "-----------------------------------");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + " 名称 " + ChatColor.GOLD + "|"
|
||||
+ ChatColor.AQUA + " 大小 " + ChatColor.GOLD + "|" + ChatColor.GREEN
|
||||
+ " 价格 ");
|
||||
sender.sendMessage(ChatColor.GOLD + "-----------------------------------");
|
||||
if (plugin.isUsingPerms()) {
|
||||
for (final String backpack : plugin.backpacks) {
|
||||
final boolean hasPerm = sender.hasPermission("rb."
|
||||
+ backpack + ".buy");
|
||||
final List<String> key = plugin.backpackData
|
||||
.get(backpack);
|
||||
if (plugin.backpackData.get(backpack).get(13)
|
||||
.equalsIgnoreCase("true")
|
||||
final boolean hasPerm = sender.hasPermission("rb." + backpack + ".buy");
|
||||
final List<String> key = plugin.backpackData.get(backpack);
|
||||
if (plugin.backpackData.get(backpack).get(13).equalsIgnoreCase("true")
|
||||
&& hasPerm) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE
|
||||
+ backpack + ChatColor.GOLD + " | "
|
||||
+ ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | "
|
||||
+ ChatColor.GREEN
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + backpack
|
||||
+ ChatColor.GOLD + " | " + ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | " + ChatColor.GREEN
|
||||
+ Double.parseDouble(key.get(14)));
|
||||
} else if (plugin.backpackData.get(backpack)
|
||||
.get(13) != null
|
||||
&& !plugin.backpackData.get(backpack)
|
||||
.get(13).equalsIgnoreCase("true")
|
||||
&& hasPerm) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE
|
||||
+ backpack + ChatColor.GOLD + " | "
|
||||
+ ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | "
|
||||
+ ChatColor.RED + "不能购买");
|
||||
} else if (plugin.backpackData.get(backpack).get(13) != null
|
||||
&& !plugin.backpackData.get(backpack).get(13)
|
||||
.equalsIgnoreCase("true") && hasPerm) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + backpack
|
||||
+ ChatColor.GOLD + " | " + ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | " + ChatColor.RED + "不能购买");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE
|
||||
+ backpack + ChatColor.GOLD + " | "
|
||||
+ ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | "
|
||||
+ ChatColor.RED + "没有足够的权限购买");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + backpack
|
||||
+ ChatColor.GOLD + " | " + ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | " + ChatColor.RED + "没有足够的权限购买");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (final String backpack : plugin.backpacks) {
|
||||
final List<String> key = plugin.backpackData
|
||||
.get(backpack);
|
||||
final List<String> key = plugin.backpackData.get(backpack);
|
||||
if (plugin.backpackData.get(backpack).get(13) != null
|
||||
&& plugin.backpackData.get(backpack)
|
||||
.get(13).equalsIgnoreCase("true")) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE
|
||||
+ backpack + ChatColor.GOLD + " | "
|
||||
+ ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | "
|
||||
+ ChatColor.GREEN
|
||||
&& plugin.backpackData.get(backpack).get(13)
|
||||
.equalsIgnoreCase("true")) {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + backpack
|
||||
+ ChatColor.GOLD + " | " + ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | " + ChatColor.GREEN
|
||||
+ Double.parseDouble(key.get(14)));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE
|
||||
+ backpack + ChatColor.GOLD + " | "
|
||||
+ ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | "
|
||||
+ ChatColor.RED + "不能购买");
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + backpack
|
||||
+ ChatColor.GOLD + " | " + ChatColor.AQUA + key.get(0)
|
||||
+ ChatColor.GOLD + " | " + ChatColor.RED + "不能购买");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (command.equalsIgnoreCase("give")) {
|
||||
if (!(args.length == 3)) {
|
||||
sender.sendMessage(ChatColor.RED + "错误的命令. 正确方式:"
|
||||
+ ChatColor.GRAY + " /rb give <玩家> <背包名称>");
|
||||
sender.sendMessage(ChatColor.RED + "错误的命令. 正确方式:" + ChatColor.GRAY
|
||||
+ " /rb give <玩家> <背包名称>");
|
||||
return false;
|
||||
}
|
||||
String backpack = null;
|
||||
backpack = RBUtil.stringToBackpack(args[2]);
|
||||
if (plugin.isUsingPerms()
|
||||
&& !sender
|
||||
.hasPermission("rb." + backpack + ".give")) {
|
||||
if (plugin.isUsingPerms() && !sender.hasPermission("rb." + backpack + ".give")) {
|
||||
sender.sendMessage(ChatColor.RED + "没有足够的权限");
|
||||
return false;
|
||||
}
|
||||
@@ -236,17 +199,15 @@ public class MainCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
final Inventory inv = other.getInventory();
|
||||
final ItemStack backpackItem = plugin.backpackItems
|
||||
.get(backpack);
|
||||
final ItemStack backpackItem = plugin.backpackItems.get(backpack);
|
||||
if (inv.firstEmpty() != -1) {
|
||||
if (plugin.backpackData.get(backpack).get(18) != null
|
||||
&& plugin.backpackData.get(backpack).get(18)
|
||||
.equalsIgnoreCase("true")) {
|
||||
.equalsIgnoreCase("true")) {
|
||||
if (RealBackpacks.globalGlow
|
||||
&& plugin.backpackData.get(backpack)
|
||||
.get(17) != null
|
||||
&& plugin.backpackData.get(backpack)
|
||||
.get(17).equalsIgnoreCase("true")) {
|
||||
&& plugin.backpackData.get(backpack).get(17) != null
|
||||
&& plugin.backpackData.get(backpack).get(17)
|
||||
.equalsIgnoreCase("true")) {
|
||||
inv.setItem(inv.firstEmpty(),
|
||||
RealBackpacks.NMS.addGlow(backpackItem));
|
||||
} else {
|
||||
@@ -254,146 +215,108 @@ public class MainCommand implements CommandExecutor {
|
||||
}
|
||||
} else {
|
||||
if (RealBackpacks.globalGlow
|
||||
&& plugin.backpackData.get(backpack)
|
||||
.get(17) != null
|
||||
&& plugin.backpackData.get(backpack)
|
||||
.get(17).equalsIgnoreCase("true")) {
|
||||
inv.addItem(RealBackpacks.NMS
|
||||
.addGlow(backpackItem));
|
||||
&& plugin.backpackData.get(backpack).get(17) != null
|
||||
&& plugin.backpackData.get(backpack).get(17)
|
||||
.equalsIgnoreCase("true")) {
|
||||
inv.addItem(RealBackpacks.NMS.addGlow(backpackItem));
|
||||
} else {
|
||||
inv.addItem(backpackItem);
|
||||
}
|
||||
}
|
||||
other.updateInventory();
|
||||
sender.sendMessage(ChatColor.GREEN + "你把背包 "
|
||||
+ ChatColor.GOLD + backpack + ChatColor.GREEN
|
||||
+ " 发送给了 " + ChatColor.GOLD + other.getName());
|
||||
sender.sendMessage(ChatColor.GREEN + "你把背包 " + ChatColor.GOLD + backpack
|
||||
+ ChatColor.GREEN + " 发送给了 " + ChatColor.GOLD + other.getName());
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + other.getName()
|
||||
+ "的背包已经满了");
|
||||
sender.sendMessage(ChatColor.RED + other.getName() + "的背包已经满了");
|
||||
return false;
|
||||
}
|
||||
} else if (command.equalsIgnoreCase("filetomysql")) {
|
||||
if (plugin.isUsingPerms()
|
||||
&& !sender.hasPermission("rb.filetomysql")) {
|
||||
if (plugin.isUsingPerms() && !sender.hasPermission("rb.filetomysql"))
|
||||
return false;
|
||||
}
|
||||
plugin.getServer().getScheduler()
|
||||
.runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!MysqlFunctions
|
||||
.checkIfTableExists("rb_data")) {
|
||||
MysqlFunctions.createTables();
|
||||
exist = false;
|
||||
} else {
|
||||
exist = true;
|
||||
}
|
||||
try {
|
||||
final Connection conn = DriverManager
|
||||
.getConnection(plugin.getUrl(),
|
||||
plugin.getUser(),
|
||||
plugin.getPass());
|
||||
final File dir = new File(plugin
|
||||
.getDataFolder()
|
||||
+ File.separator + "userdata");
|
||||
int i = 0, times = 0;
|
||||
final int files = dir.listFiles().length;
|
||||
for (final File child : dir.listFiles()) {
|
||||
final String player = child
|
||||
.getName().replace(".yml",
|
||||
"");
|
||||
final FileConfig config = PlayerConfig
|
||||
.getInstance(plugin, player);
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!MysqlFunctions.checkIfTableExists("rb_data")) {
|
||||
MysqlFunctions.createTables();
|
||||
exist = false;
|
||||
} else {
|
||||
exist = true;
|
||||
}
|
||||
try {
|
||||
final Connection conn = DriverManager.getConnection(
|
||||
plugin.getUrl(), plugin.getUser(), plugin.getPass());
|
||||
final File dir = new File(plugin.getDataFolder() + File.separator
|
||||
+ "userdata");
|
||||
int i = 0,times = 0;
|
||||
final int files = dir.listFiles().length;
|
||||
for (final File child : dir.listFiles()) {
|
||||
final String player = child.getName().replace(".yml", "");
|
||||
final FileConfig config = PlayerConfig.getInstance(plugin,
|
||||
player);
|
||||
|
||||
i++;
|
||||
PreparedStatement statement = null;
|
||||
PreparedStatement state = null;
|
||||
for (final String backpack : config
|
||||
.getConfigurationSection("")
|
||||
.getKeys(false)) {
|
||||
if (exist) {
|
||||
statement = conn
|
||||
.prepareStatement("SELECT EXISTS(SELECT 1 FROM rb_data WHERE player = ? AND backpack = ? LIMIT 1);");
|
||||
statement.setString(1,
|
||||
player);
|
||||
statement.setString(2,
|
||||
backpack);
|
||||
final ResultSet res = statement
|
||||
.executeQuery();
|
||||
if (res.next()) {
|
||||
if (res.getInt(1) == 1) {
|
||||
state = conn
|
||||
.prepareStatement("UPDATE rb_data SET player=?, backpack=?, inventory=? WHERE player=? AND backpack=?;");
|
||||
state.setString(1,
|
||||
player);
|
||||
state.setString(2,
|
||||
backpack);
|
||||
state.setString(
|
||||
3,
|
||||
Serialization
|
||||
.listToString(config
|
||||
.getStringList(backpack
|
||||
+ ".Inventory")));
|
||||
state.setString(4,
|
||||
player);
|
||||
state.setString(5,
|
||||
backpack);
|
||||
} else {
|
||||
state = conn
|
||||
.prepareStatement("INSERT INTO rb_data (player, backpack, inventory) VALUES(?, ?, ?);");
|
||||
state.setString(1,
|
||||
player);
|
||||
state.setString(2,
|
||||
backpack);
|
||||
state.setString(
|
||||
3,
|
||||
Serialization
|
||||
.listToString(config
|
||||
.getStringList(backpack
|
||||
+ ".Inventory")));
|
||||
}
|
||||
}
|
||||
i++;
|
||||
PreparedStatement statement = null;
|
||||
PreparedStatement state = null;
|
||||
for (final String backpack : config.getConfigurationSection("")
|
||||
.getKeys(false)) {
|
||||
if (exist) {
|
||||
statement = conn
|
||||
.prepareStatement("SELECT EXISTS(SELECT 1 FROM rb_data WHERE player = ? AND backpack = ? LIMIT 1);");
|
||||
statement.setString(1, player);
|
||||
statement.setString(2, backpack);
|
||||
final ResultSet res = statement.executeQuery();
|
||||
if (res.next()) {
|
||||
if (res.getInt(1) == 1) {
|
||||
state = conn
|
||||
.prepareStatement("UPDATE rb_data SET player=?, backpack=?, inventory=? WHERE player=? AND backpack=?;");
|
||||
state.setString(1, player);
|
||||
state.setString(2, backpack);
|
||||
state.setString(3, Serialization
|
||||
.listToString(config
|
||||
.getStringList(backpack
|
||||
+ ".Inventory")));
|
||||
state.setString(4, player);
|
||||
state.setString(5, backpack);
|
||||
} else {
|
||||
state = conn
|
||||
.prepareStatement("INSERT INTO rb_data (player, backpack, inventory) VALUES(?, ?, ?);");
|
||||
state.setString(1, player);
|
||||
state.setString(2, backpack);
|
||||
state.setString(
|
||||
3,
|
||||
Serialization
|
||||
.listToString(config
|
||||
.getStringList(backpack
|
||||
+ ".Inventory")));
|
||||
state.setString(3, Serialization
|
||||
.listToString(config
|
||||
.getStringList(backpack
|
||||
+ ".Inventory")));
|
||||
}
|
||||
state.executeUpdate();
|
||||
state.close();
|
||||
}
|
||||
if (i == 50) {
|
||||
i = 0;
|
||||
times++;
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE
|
||||
+ ""
|
||||
+ times
|
||||
* 50
|
||||
+ "/"
|
||||
+ files
|
||||
+ " files have been transferred.");
|
||||
}
|
||||
} else {
|
||||
state = conn
|
||||
.prepareStatement("INSERT INTO rb_data (player, backpack, inventory) VALUES(?, ?, ?);");
|
||||
state.setString(1, player);
|
||||
state.setString(2, backpack);
|
||||
state.setString(3, Serialization.listToString(config
|
||||
.getStringList(backpack + ".Inventory")));
|
||||
}
|
||||
conn.close();
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE
|
||||
+ "数据转换完成.");
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
state.executeUpdate();
|
||||
state.close();
|
||||
}
|
||||
if (i == 50) {
|
||||
i = 0;
|
||||
times++;
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "" + times * 50
|
||||
+ "/" + files + " files have been transferred.");
|
||||
}
|
||||
}
|
||||
});
|
||||
conn.close();
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "数据转换完成.");
|
||||
} catch (final SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (command.equalsIgnoreCase("view")) {
|
||||
if (!(args.length == 3)) {
|
||||
sender.sendMessage(ChatColor.RED + "命令错误. 正确命令:"
|
||||
+ ChatColor.GRAY
|
||||
sender.sendMessage(ChatColor.RED + "命令错误. 正确命令:" + ChatColor.GRAY
|
||||
+ " /rb view <player> <backpack>");
|
||||
return false;
|
||||
}
|
||||
@@ -401,11 +324,9 @@ public class MainCommand implements CommandExecutor {
|
||||
backpack = RBUtil.stringToBackpack(args[2]);
|
||||
boolean fullview = false;
|
||||
boolean restrictedview = false;
|
||||
if (plugin.isUsingPerms()
|
||||
&& sender.hasPermission("rb.fullview")) {
|
||||
if (plugin.isUsingPerms() && sender.hasPermission("rb.fullview")) {
|
||||
fullview = true;
|
||||
} else if (plugin.isUsingPerms()
|
||||
&& sender.hasPermission("rb.restrictedview")) {
|
||||
} else if (plugin.isUsingPerms() && sender.hasPermission("rb.restrictedview")) {
|
||||
restrictedview = true;
|
||||
}
|
||||
if (plugin.isUsingPerms() && !fullview && !restrictedview) {
|
||||
@@ -423,8 +344,8 @@ public class MainCommand implements CommandExecutor {
|
||||
if (!plugin.isUsingMysql()) {
|
||||
boolean fileExists = false;
|
||||
String fullName = null;
|
||||
final File dir = new File(plugin.getDataFolder()
|
||||
+ File.separator + "userdata");
|
||||
final File dir = new File(plugin.getDataFolder() + File.separator
|
||||
+ "userdata");
|
||||
for (final File f : dir.listFiles()) {
|
||||
final String fileName = f.getName();
|
||||
fullName = fileName.replace(".yml", "");
|
||||
@@ -435,25 +356,20 @@ public class MainCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
if (!fileExists) {
|
||||
sender.sendMessage(ChatColor.RED
|
||||
+ "这货从来没打开过背包,所以是空的,2333.");
|
||||
sender.sendMessage(ChatColor.RED + "这货从来没打开过背包,所以是空的,2333.");
|
||||
return false;
|
||||
}
|
||||
final FileConfig config = PlayerConfig
|
||||
.getInstance(plugin, fullName);
|
||||
final FileConfig config = PlayerConfig.getInstance(plugin, fullName);
|
||||
if (config.getStringList(backpack + ".Inventory") == null) {
|
||||
inv = plugin.getServer().createInventory(
|
||||
p,
|
||||
Integer.parseInt(key.get(0)),
|
||||
ChatColor.translateAlternateColorCodes('&',
|
||||
fullName + "'s " + backpack
|
||||
+ " data"));
|
||||
ChatColor.translateAlternateColorCodes('&', fullName + "'s "
|
||||
+ backpack + " data"));
|
||||
} else {
|
||||
inv = Serialization.toInventory(
|
||||
config.getStringList(backpack
|
||||
+ ".Inventory"), fullName + "'s "
|
||||
+ backpack + " data",
|
||||
Integer.parseInt(key.get(0)));
|
||||
config.getStringList(backpack + ".Inventory"), fullName + "'s "
|
||||
+ backpack + " data", Integer.parseInt(key.get(0)));
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
@@ -462,8 +378,7 @@ public class MainCommand implements CommandExecutor {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
if (inv == null) {
|
||||
sender.sendMessage(ChatColor.RED
|
||||
+ "这货从来没打开过背包,所以是空的,2333.");
|
||||
sender.sendMessage(ChatColor.RED + "这货从来没打开过背包,所以是空的,2333.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -472,8 +387,7 @@ public class MainCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
if (fullview || !plugin.isUsingPerms()) {
|
||||
plugin.adminFullView.put(sender.getName(), backpack
|
||||
+ ":" + name);
|
||||
plugin.adminFullView.put(sender.getName(), backpack + ":" + name);
|
||||
} else {
|
||||
plugin.adminRestrictedView.add(sender.getName());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
Data:
|
||||
#数据保存方式 [flatfile|MySQL]
|
||||
FileSystem: flatfile
|
||||
#MySQL数据库配置 只有当FileSystem配置为MySQL时有效
|
||||
MySQL:
|
||||
database: minecraft
|
||||
username: root
|
||||
@@ -7,34 +9,52 @@ Data:
|
||||
ip: localhost
|
||||
port: 3306
|
||||
Config:
|
||||
#是否使用权限系统
|
||||
usePermissions: true
|
||||
#多背包配置模式 average平均模式 add添加模式
|
||||
MultipleBackpacksInInventory:
|
||||
average: false
|
||||
add: true
|
||||
#背包自定义配置
|
||||
Backpacks:
|
||||
#背包名称
|
||||
Bp-18:
|
||||
#背包大小
|
||||
Size: 18
|
||||
addGlow: true
|
||||
#如何打开背包 [right_click|left_click]
|
||||
OpenWith: right_click
|
||||
#能否购买
|
||||
Purchasable: true
|
||||
#背包价格
|
||||
Price: 2000
|
||||
#是否启用合成
|
||||
UseRecipe: true
|
||||
#覆盖
|
||||
Override: '0'
|
||||
#合成表
|
||||
Recipe:
|
||||
- 334,334,334
|
||||
- 334,54,334
|
||||
- 334,334,334
|
||||
#背包详情
|
||||
BackpackItem:
|
||||
#背包ID
|
||||
id: 334
|
||||
#背包名称
|
||||
name: "&a背包-18"
|
||||
#背包Lore
|
||||
lore:
|
||||
- "&5一个随身携带的背包."
|
||||
- "&b有&d18&b个格子的物品可存放."
|
||||
- "&3移动速度下降5%."
|
||||
- "&6背包掉落或丢失,再次购买即可,物品不丢失."
|
||||
- "&c每种背包仅需购买一次,多个不叠加."
|
||||
#是否开启白名单(开启后只有白名单的物品可以放入)
|
||||
UseWhitelist: false
|
||||
#白名单列表
|
||||
ItemWhitelist: []
|
||||
#黑名单列表(请填写所有背包的名称,防止背包放到背包内!)
|
||||
ItemBlacklist:
|
||||
- Bp-18
|
||||
- Bp-27
|
||||
@@ -42,15 +62,25 @@ Backpacks:
|
||||
- Bp-45
|
||||
- Bp-54
|
||||
- 276:all
|
||||
#死亡后处理
|
||||
onDeath:
|
||||
#掉落背包物品
|
||||
dropContents: false
|
||||
#摧毁背包物品
|
||||
destroyContents: false
|
||||
#掉落背包(当服务器开启物品掉落保护时)
|
||||
dropBackpack: false
|
||||
#保留背包(当服务器关闭物品掉落保护时)
|
||||
keepBackpack: false
|
||||
#修改行走速度
|
||||
WalkSpeedFeature:
|
||||
#是否启用
|
||||
enabled: true
|
||||
#行走速度控制(0.2为正常速度)
|
||||
walkingSpeed: 0.19
|
||||
#饥饿系统控制
|
||||
IncreasedHungerFeature:
|
||||
#是否开启
|
||||
enabled: true
|
||||
extraHungerBarsToDeplete: 1
|
||||
hungerBarsToSubtractWhenEating: 0
|
||||
|
||||
Reference in New Issue
Block a user