mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2024-11-14 10:45:23 +01:00
Bugfix for not saved backpack
This commit is contained in:
parent
995a6cf362
commit
761c25f0fc
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>MinePacks</artifactId>
|
||||
<version>1.4.3</version>
|
||||
<version>1.5</version>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>in-project</id>
|
||||
|
@ -346,15 +346,12 @@ public void SaveBackpack(Backpack backpack)
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
ps = GetConnection().prepareStatement(Query_InsertBP, Statement.RETURN_GENERATED_KEYS);
|
||||
ps = GetConnection().prepareStatement(Query_InsertBP);
|
||||
ps.setInt(1, backpack.getID());
|
||||
ps.setBytes(2, itsSerializer.Serialize(backpack.getBackpack()));
|
||||
ps.setInt(3, itsSerializer.getUsedVersion());
|
||||
ps.executeUpdate();
|
||||
rs = ps.getGeneratedKeys();
|
||||
backpack.setID(rs.getInt(1));
|
||||
ps.execute();
|
||||
ps.close();
|
||||
rs.close();
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -214,15 +214,12 @@ public void SaveBackpack(Backpack backpack)
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
ps = GetConnection().prepareStatement("INSERT INTO `" + Table_Backpacks + "` (`owner`, `itemstacks`, `version`) VALUES (?,?,?);", Statement.RETURN_GENERATED_KEYS);
|
||||
ps = GetConnection().prepareStatement("INSERT INTO `" + Table_Backpacks + "` (`owner`, `itemstacks`, `version`) VALUES (?,?,?);");
|
||||
ps.setInt(1, backpack.getID());
|
||||
ps.setBytes(2, itsSerializer.Serialize(backpack.getBackpack()));
|
||||
ps.setInt(3, itsSerializer.getUsedVersion());
|
||||
ps.executeUpdate();
|
||||
rs = ps.getGeneratedKeys();
|
||||
backpack.setID(rs.getInt(1));
|
||||
ps.execute();
|
||||
ps.close();
|
||||
rs.close();
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -6,13 +6,14 @@
|
||||
|
||||
public class ItemStackSerializer
|
||||
{
|
||||
Base serializer;
|
||||
Base serializer, base;
|
||||
int usedVersion = 1;
|
||||
|
||||
public ItemStackSerializer()
|
||||
{
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
String[] version = name.substring(name.lastIndexOf('.') + 2).split("_");
|
||||
base = new Base();
|
||||
try
|
||||
{
|
||||
if(version[0].equals("1"))
|
||||
@ -34,7 +35,7 @@ else if(version[2].equals("R2"))
|
||||
if(serializer == null)
|
||||
{
|
||||
usedVersion = 0;
|
||||
serializer = new Base();
|
||||
serializer = base;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +53,7 @@ public ItemStack[] Deserialize(byte[] data, int version)
|
||||
{
|
||||
if(version == 0)
|
||||
{
|
||||
(new Base()).toItemStack(data);
|
||||
base.toItemStack(data);
|
||||
}
|
||||
return serializer.toItemStack(data);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user