EnderContainers

EnderContainers

2.5k Downloads

Error load Backup with DB

microwin7 opened this issue · 26 comments

commented

I have fixed the bug when loading data of enderchests saved with version 2.1.0 of the plugin. Sorry I thought this bug had been fixed earlier! You can download the Jar with the fix here: https://ci.utarwyn.fr/job/EnderContainers

commented

Hello @microwin7, I haven't seen this bug in the past, that's strange. What software and version of database server are you using? I will investigate more to know if there is an incompatibility or something else.

In general I'm not very happy with my backup management system. I should rework on it in the future. Anyway, thank you for the feedback!

commented

MySQL MariaDB

commented

Hello @microwin7,
I have changed the way to replace enderchests when loading a backup. This should now works for you thanks to the latest commit 772129b. Give me a feedback on that!

I have compiled the latest source code with the fix for you: EnderContainers-2.2.0-772129b.zip

commented

@microwin7, have you tested with the fix? Is the problem stills present on your server?

commented

Sorry. I could not check for a long time. Backups work, thanks =)

commented

It’s really strange that sometimes after restarting, I can’t open the chest on the right click, but only with the command

commented
commented

image
spigot 1.8.8
Please check all classes to work with this version, where there is only one hand and there may be some similar problems. Just as I look there is no version manager

commented

Yes sorry about that! As I have already mentioned it in another issue, there is a problem with the method getItemInMainHand(). I will fix it!

commented

I will also try to create a build pipeline for each versions of Minecraft on GitHub to be sure that all classes are compatible with these versions.

commented

wait, I’ll offer a solution in a couple of minutes

commented

check

commented

Need to add to pom version 1.8, I think

commented

I will check that! Thank you for the contribution yep 👍

commented

strange, not working for some reason)
maybe you have a better idea for implementation will be

commented

image
for some reason, it’s called in my code anyway, verification further, not 1.8

commented

https://pastebin.com/GCg7gpxD
replaced .getItemInMainHand () with .getItemInHand () and this is what I got
Error due to PlotSquared

commented

https://pastebin.com/VyhqUjty
I strongly apologize, as it turned out I was not completely convinced of the work, checked on clean (new) databases, and when I put the plug-in on the base now, I got such an error when taking data. Given that I deleted the table for backups in advance, it means an error with existing player inventories

commented

image
Left new
Right old
storage of the same item

commented

Yep I have changed how base64 data strings are stored. I'm now using the "Java traditional way" which is not using break lines in the serialized data. BUT this should not causes any problem because the new class supports both formats for deserialization. Can you send me the input data of the decode method?

See it in action here:

@Override
public String serialize(ConcurrentMap<Integer, ItemStack> items) throws IOException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeInt(items.size());
for (Map.Entry<Integer, ItemStack> entry : items.entrySet()) {
dataOutput.writeInt(entry.getKey());
dataOutput.writeObject(entry.getValue());
}
dataOutput.close();
return Base64.getEncoder().encodeToString(outputStream.toByteArray());
}
/**
* {@inheritDoc}
*/
@Override
public ConcurrentMap<Integer, ItemStack> deserialize(String data) throws IOException {
ConcurrentMap<Integer, ItemStack> items = new ConcurrentHashMap<>();
byte[] bytes = Base64.getDecoder().decode(data.replaceAll("\n", ""));
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
int mapSize = dataInput.readInt();
int pos;
ItemStack item;
for (int i = 0; i < mapSize; i++) {
pos = dataInput.readInt();
try {
item = (ItemStack) dataInput.readObject();
} catch (ClassNotFoundException e) {
throw new IOException("cannot found ItemStack class during deserialization", e);
}
items.put(pos, item);
}
dataInput.close();
return items;
}

commented

image

commented

In the version from March, this was not

commented

https://pastebin.com/GCg7gpxD
replaced .getItemInMainHand () with .getItemInHand () and this is what I got
Error due to PlotSquared

Which version of PlotSquared do you use? The plugin only supports v5+ now. Do you want me to work on the compatibility with another version of PlotSquared?

commented

I have also replaced the method getItemInMainHand() with getItemInHand() to solve your issue with 1.8 version of MC in the commit f0b3e3a.

commented

@microwin7 Are all your problems been solved? If you want me to add support for another version of PlotSquared, please create a new issue. Also I have done some tests with the latest development version and the data loading (items) seems to work fine.