Terra (Fabric/Forge/Paper)

Terra (Fabric/Forge/Paper)

74.2k Downloads

[Bug] world file is generated after world is unloaded/removed

JasperJRoth opened this issue ยท 9 comments

commented
  • I have checked that I am on the latest version of Terra.
  • I have searched the github issue tracker for similar issues, including
    closed ones.
  • I have made sure that this is not a bug with another mod or plugin, and it
    is Terra that is causing the issue.
  • I have checked that this is an issue with Terra and not an issue with the
    pack I am using.
  • I have attached a copy of the latest.log file
  • I have filled out and provided all the appropriate information.

Issue Description

Terra creates world files on server shutdown, even if those worlds have been deleted.

Steps to reproduce

  1. Clone the latest version of this repository, a repository I created with a fresh server install that contains the bug.
  2. Have docker installed
  3. Create file named .env in the same directory as the docker-compose.yml file
  4. Place the following text into the .env file
    RCON_PASSWORD=[any password you want to use]
  5. Run docker-compose up -d
  6. Wait until server is Done (14.195s)! For help, type "help"
  7. Run docker exec -i terra-test rcon-cli
  8. Enter the following commands into the console:
    (This creates the world for testing)
    mv create testworld NORMAL -g Terra:MOON_BASIC
    (This deletes the world - there will be no world files after this step)
    mv delete testworld
    (Confirms deletion)
    mv confirm
    (Stops the server - there will be world files after this step)
    stop
  9. Check minecraft-data folder

Expected behavior

If a world has been deleted or unloaded from bukkit, terra should not create further world files.

Actual behavior

After a world has been deleted or unloaded from bukkit, terra creates an additional file. The file created has the following path:
[WorldName]/gaea/chunks.bin

Full stacktrace

No stacktrace is created, there are thread dumps during world creation, but I think this is due to server not responding during world creation.

Additional details

I am using multiverse-core to test this, because I am pretty sure bukkit does not have a built in command to delete world files. I do not think multiverse-core is the issue here, because multiverse-core is able to delete the files. Terra seems to add a file after the world is deleted, before server shutdown

latest.log
.

commented

I should note that manually unloading the world with mv unload testworld before issuing the mv delete testworld command still causes a file to be created after server shutdown.

commented

There are no errors logged to the console during this process. I just tried removing Terra from the installation to see if the bug persisted and it did not, which means that the issue is likely with Terra. Gaea is the name of a library that Terra used to use. It may be relevant that I am running the latest version of the plugin from the spigotmc site, on a 1.17.1 server.

commented

What are all those errors in the console?

Also, afaik Terra doesn't create any files in a directory called gaea. I just ran a grep, and can't find a single reference to it anywhere in the code.

commented

However, we no longer use gaea. No reference to it exists anywhere in the codebase.

commented

public static File getDataFolder(World w) {
File f = new File(((BukkitWorld) w).getWorldFolder(), "gaea");
f.mkdirs();
return f;
}

@SuppressWarnings("unchecked")
public synchronized void saveBlocks(World w) throws IOException {
    File f = new File(getDataFolder(w), "chunks.bin");
    f.createNewFile();
    SerializationUtil.toFile((HashSet<ChunkCoordinate>) needsPop.clone(), f);
}

@SuppressWarnings("unchecked")
public synchronized void loadBlocks(World w) throws IOException, ClassNotFoundException {
    File f = new File(getDataFolder(w), "chunks.bin");
    needsPop.addAll((HashSet<ChunkCoordinate>) SerializationUtil.fromFile(f));
}'

Sorry if this isn't formatted correctly, im currently on my phone. This code seems like it might cause the issue, it's in the latest release, and presumably in the version that is hosted on spigot, but it looks like it isn't in the current 6.0.0 branch on Github. The issue was probably using the latest release instead of the latest version in the repository.

commented

@JasperJRoth which file is this in? Github search cannot find this anywhere.

commented

I found that code in the latest tagged release, as well as similar code in the spigotmc release. I could not find it in the latest repo version.

the path is: platforms/bukkit/src/main/java/com/dfsek/terra/bukkit/population/PopulationManager.java

I tired to make sure that its fixed in the latest repo version, but I had trouble getting it to work.

commented

ah, it seems to be good ol' Population Manager.

I'm unsure why Terra seems to be saving all the chunk data when the plugin is disabled (see here), but AFAIK all the cursed popman code is removed in 6.0.0. I cannot find any class that is similar to what it did.

commented

I hopped on over to the 6.0.0 beta and everything is working fine, thanks for the help!