mirror of
https://e.coding.net/circlecloud/RealBackpacks.git
synced 2024-12-04 03:49:07 +00:00
fix playerdate can't show Chinese...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
11a8b85427
commit
bb976ea43c
@ -1,6 +1,5 @@
|
||||
package cn.citycraft.plugins;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -107,12 +106,7 @@ public class RealBackpacks extends JavaPlugin {
|
||||
getLogger().info("Vault found, economy features enabled.");
|
||||
}
|
||||
setupLists();
|
||||
final File userdata = new File(getDataFolder() + File.separator
|
||||
+ "userdata");
|
||||
setup();
|
||||
if (!userdata.exists()) {
|
||||
userdata.mkdirs();
|
||||
}
|
||||
if (isEnabled()) {
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new PlayerListener(this), this);
|
||||
|
@ -57,7 +57,6 @@ public class EntityListener implements Listener {
|
||||
setlevel = pLevel;
|
||||
}
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
p.setFoodLevel(setlevel);
|
||||
}
|
||||
|
@ -1,13 +1,9 @@
|
||||
package cn.citycraft.plugins.listeners;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -18,6 +14,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import cn.citycraft.Utils.config.PlayerConfig;
|
||||
import cn.citycraft.plugins.RealBackpacks;
|
||||
import cn.citycraft.plugins.util.MysqlFunctions;
|
||||
import cn.citycraft.plugins.util.RBUtil;
|
||||
@ -53,21 +50,8 @@ public class InventoryListener implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
final File file = new File(plugin
|
||||
.getDataFolder()
|
||||
+ File.separator
|
||||
+ "userdata"
|
||||
+ File.separator
|
||||
+ name
|
||||
+ ".yml");
|
||||
final FileConfiguration config = YamlConfiguration
|
||||
.loadConfiguration(file);
|
||||
config.set(backpack + ".Inventory", invString);
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
PlayerConfig.getInstance(plugin, name).set(backpack + ".Inventory", invString);
|
||||
PlayerConfig.save();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -85,22 +69,9 @@ public class InventoryListener implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
final List<String> invString = Serialization
|
||||
.toString(inv);
|
||||
final File file = new File(plugin
|
||||
.getDataFolder()
|
||||
+ File.separator
|
||||
+ "userdata"
|
||||
+ File.separator
|
||||
+ split[1] + ".yml");
|
||||
final FileConfiguration config = YamlConfiguration
|
||||
.loadConfiguration(file);
|
||||
config.set(split[0] + ".Inventory", invString);
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
PlayerConfig.getInstance(plugin, split[1]).
|
||||
set(split[0] + ".Inventory", invString);
|
||||
PlayerConfig.save();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,15 +1,11 @@
|
||||
package cn.citycraft.plugins.listeners;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -23,6 +19,8 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.Utils.config.FileConfig;
|
||||
import cn.citycraft.Utils.config.PlayerConfig;
|
||||
import cn.citycraft.plugins.RealBackpacks;
|
||||
import cn.citycraft.plugins.util.MysqlFunctions;
|
||||
import cn.citycraft.plugins.util.RBUtil;
|
||||
@ -96,15 +94,7 @@ public class PlayerListener implements Listener {
|
||||
inv = plugin.getServer().createInventory(p, Integer.parseInt(key.get(0)), ChatColor.translateAlternateColorCodes('&', key.get(3)));
|
||||
}
|
||||
} else {
|
||||
final File file = new File(plugin.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (final IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
final FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
FileConfig config = PlayerConfig.getInstance(plugin, name);
|
||||
if (!config.isSet(backpack + ".Inventory")) {
|
||||
inv = plugin.getServer().createInventory(p, Integer.parseInt(key.get(0)), ChatColor.translateAlternateColorCodes('&', key.get(3)));
|
||||
} else {
|
||||
@ -210,11 +200,7 @@ public class PlayerListener implements Listener {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
final File file = new File(plugin.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||
if (!file.exists()) {
|
||||
continue;
|
||||
}
|
||||
final FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
FileConfig config = PlayerConfig.getInstance(plugin, name);
|
||||
if (config.getStringList(backpack + ".Inventory") == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ public class MysqlFunctions {
|
||||
|
||||
public static boolean checkIfTableExists(final String table) {
|
||||
try {
|
||||
//final Connection conn = DriverManager.getConnection(plugin.getUrl(), plugin.getUser(), plugin.getPass());
|
||||
String url = plugin.getUrl()+"?"
|
||||
+ "user=" + plugin.getUser() + "&password=" + plugin.getPass() + "&useUnicode=true&characterEncoding=utf-8";
|
||||
final Connection conn = DriverManager.getConnection(url);
|
||||
|
@ -1,16 +1,13 @@
|
||||
package cn.citycraft.plugins.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.Utils.config.PlayerConfig;
|
||||
import cn.citycraft.plugins.RealBackpacks;
|
||||
|
||||
public class RBUtil {
|
||||
@ -28,14 +25,8 @@ public class RBUtil {
|
||||
if (plugin.isUsingMysql()) {
|
||||
MysqlFunctions.delete(name, backpack);
|
||||
} else {
|
||||
final File file = new File(plugin.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||
final FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||
config.set(backpack + ".Inventory", null);
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (final IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
PlayerConfig.getInstance(plugin, name).set(backpack + ".Inventory", null);
|
||||
PlayerConfig.save();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user