mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-12-28 17:48:22 +01:00
Code cleanup
This commit is contained in:
parent
7c1db6199e
commit
86ced09103
@ -35,7 +35,7 @@
|
||||
|
||||
public class Files extends Database
|
||||
{
|
||||
protected static final String EXT = ".backpack", EXT_REGEX = "\\.backpack";
|
||||
public static final String EXT = ".backpack", EXT_REGEX = "\\.backpack", FOLDER_NAME = "backpacks";
|
||||
|
||||
private final File saveFolder;
|
||||
|
||||
@ -43,7 +43,7 @@ public Files(Minepacks plugin)
|
||||
{
|
||||
super(plugin);
|
||||
maxAge *= 24 * 3600000L;
|
||||
saveFolder = new File(this.plugin.getDataFolder(), "backpacks");
|
||||
saveFolder = new File(this.plugin.getDataFolder(), FOLDER_NAME);
|
||||
if(!saveFolder.exists())
|
||||
{
|
||||
if(!saveFolder.mkdirs())
|
||||
|
@ -55,12 +55,6 @@ public byte[] serialize(Inventory inv)
|
||||
return serializer.serialize(inv.getContents());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public ItemStack[] deserialize(byte[] data)
|
||||
{
|
||||
return deserialize(data, usedSerializer);
|
||||
}
|
||||
|
||||
public ItemStack[] deserialize(byte[] data, int usedSerializer)
|
||||
{
|
||||
if(data == null) return null;
|
||||
|
@ -18,6 +18,7 @@
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit.Database.Migration;
|
||||
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Database;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Files;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.SQL;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||
import at.pcgamingfreaks.Reflection;
|
||||
@ -43,11 +44,8 @@ protected SQLtoFilesMigration(@NotNull Minepacks plugin, @NotNull Database oldDb
|
||||
super(plugin, oldDb);
|
||||
@Language("SQL") String query = "SELECT " + (plugin.getConfiguration().getUseUUIDs() ? "{FieldUUID}" : "{FieldName}") + ",{FieldBPITS},{FieldBPVersion} FROM {TablePlayers} INNER JOIN {TableBackpacks} ON {FieldPlayerID}={FieldBPOwner};";
|
||||
sqlQuery = (String) Reflection.getMethod(SQL.class, "replacePlaceholders", String.class).invoke(plugin.getDatabase(), query);
|
||||
saveFolder = new File(this.plugin.getDataFolder(), "backpacks");
|
||||
if(!saveFolder.exists() && !saveFolder.mkdirs())
|
||||
{
|
||||
plugin.getLogger().warning("Failed to create save folder (" + saveFolder.getAbsolutePath() + ").");
|
||||
}
|
||||
saveFolder = new File(this.plugin.getDataFolder(), Files.FOLDER_NAME);
|
||||
if(!saveFolder.exists() && !saveFolder.mkdirs()) plugin.getLogger().warning("Failed to create save folder (" + saveFolder.getAbsolutePath() + ").");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,7 +56,7 @@ protected SQLtoFilesMigration(@NotNull Minepacks plugin, @NotNull Database oldDb
|
||||
{
|
||||
while(rs.next())
|
||||
{
|
||||
try(FileOutputStream fos = new FileOutputStream(new File(saveFolder, rs.getString(1) + ".backpack")))
|
||||
try(FileOutputStream fos = new FileOutputStream(new File(saveFolder, rs.getString(1) + Files.EXT)))
|
||||
{
|
||||
fos.write(rs.getInt(3));
|
||||
fos.write(rs.getBytes(2));
|
||||
|
Loading…
Reference in New Issue
Block a user