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