Folia
Folia copied to clipboard
Problem with location (world) when initializing
Expected behavior
Bukkit.getWorld() is supposed to return a World object
Observed/Actual behavior
On server init Bukkit.getWorld returns null
Steps/models to reproduce
On init try to get Bukkit.getWorld, or just plugin#getConfig#getLocation and World always equals null
` Location location = new Location(Bukkit.getWorld("world"), x, y, z, yaw, pitch);
System.out.println(location); `
[10:22:19 INFO]: Location{world=null,x=-16.5,y=71.1,z=28.5,pitch=270.0,yaw=1.0}
Plugin and Datapack List
Plugins :
- Chunky, DecentHolograms, Essentials, LifeStealFolia, LuckPerms, NoCheatPlus, Vault, ViaBackwards, ViaVersion, WorldEdit, WorldGuard (Also tested with only my plugin LifeStealFolia)
No datapacks
Folia version
[10:27:40 INFO]: Checking version, please wait... [10:27:40 INFO]: This server is running Folia version git-Folia-"ca3b7ad" (MC: 1.19.4) (Implementing API version 1.19.4-R0.1-SNAPSHOT) (Git: ca3b7ad) You are running the latest version
Other
No response
Where on server init are you doing that? We need minimal reproduction code, as 99% chance you're causing stuff to be initialized before the worlds are loaded
when starting the plugin, I take the locations from the config and put them in the hashmap, I don't know how it looks with other devs, but I've always done it on paper, do you have an idea how to replace it, or is there any ServerFullyLoadedEvent that I can use instead
Here's code, obviously i changed world to null due to this
`public RandomTeleport() {
for (String key : yamlData.getConfig().getConfigurationSection("tp").getKeys(false)) {
double x = yamlData.getConfig().getDouble("tp." + key + ".x");
double y = yamlData.getConfig().getDouble("tp." + key + ".y");
double z = yamlData.getConfig().getDouble("tp." + key + ".z");
float pitch = yamlData.getConfig().getLong("tp." + key + ".pitch");
float yaw = yamlData.getConfig().getLong("tp." + key + ".yaw");
locMap.put(Integer.parseInt(key), new Location(null, x, y, z, pitch, yaw));
}
}`
I don't see anything wrong with the initialization order, as worlds are loaded before onEnable is called from what I can tell.
With only a vague reference to "server init" I don't think I can look into this, as I can't test that locally.