Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support world unloading #476

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ object Versions {
}

object Allay {
const val api = "1cb3bb69c6"
const val api = "0114e0b290"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.dfsek.terra.allay;

import org.allaymc.api.eventbus.EventHandler;
import org.allaymc.api.eventbus.event.world.WorldUnloadEvent;
import org.allaymc.api.plugin.Plugin;
import org.allaymc.api.registry.Registries;
import org.allaymc.api.server.Server;

import com.dfsek.terra.allay.generator.AllayGeneratorWrapper;
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;


/**
* @author daoge_cmd
*/
Expand Down Expand Up @@ -46,6 +50,11 @@ public void onLoad() {
pluginLogger.info("Terra started");
}

@Override
public void onEnable() {
Server.getInstance().getEventBus().registerListener(this);
}

@Override
public boolean isReloadable() {
return true;
Expand All @@ -59,4 +68,9 @@ public void reload() {
pluginLogger.error("Terra failed to reload.");
}
}

@EventHandler
private void onWorldUnload(WorldUnloadEvent event) {
AllayPlatform.GENERATOR_WRAPPERS.removeIf(wrapper -> wrapper.getAllayWorldGenerator().getDimension().getWorld() == event.getWorld());
}
}
Loading