WorldGuard

WorldGuard

8M Downloads

WorldGuard.getPlatform() cannot pass null check on PaperMC server.

danny900714 opened this issue ยท 3 comments

commented

Versions
WorldEdit version: 7.2.5

WorldGuard version: 7.0.4

Platform version: Paper 1.16.5-701

Describe the bug
[00:17:42 INFO]: [WorldEdit] Enabling WorldEdit v7.2.5+57d5ac9
[00:17:42 INFO]: WEPIF: Using the Bukkit Permissions API.
[00:17:42 INFO]: Using com.sk89q.worldedit.bukkit.adapter.impl.Spigot_v1_16_R3 as the Bukkit adapter
[00:17:43 WARN]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
[00:17:43 WARN]: The server will make no attempt to authenticate usernames. Beware.
[00:17:43 WARN]: Whilst this makes it possible to use BungeeCord, unless access to your server is properly restricted, it also opens up the ability for hackers to connect with any username they choose.
[00:17:43 WARN]: Please see http://www.spigotmc.org/wiki/firewall-guide/ for further information.
[00:17:43 WARN]: To change this, set "online-mode" to "true" in the server.properties file.
[00:17:43 INFO]: Preparing level "world"
[00:17:43 INFO]: Registering commands with com.sk89q.worldedit.bukkit.BukkitServerInterface
[00:17:44 INFO]: Preparing start region for dimension minecraft:overworld
[00:17:44 INFO]: Loaded 0 spawn chunks for world world
[00:17:44 INFO]: Preparing spawn area: 0%
[00:17:44 INFO]: Time elapsed: 319 ms
[00:17:44 INFO]: Preparing start region for dimension minecraft:the_nether
[00:17:44 INFO]: Loaded 0 spawn chunks for world world_nether
[00:17:44 INFO]: Time elapsed: 109 ms
[00:17:44 INFO]: Preparing start region for dimension minecraft:the_end
[00:17:44 INFO]: Loaded 0 spawn chunks for world world_the_end
[00:17:44 INFO]: Time elapsed: 165 ms
[00:17:44 INFO]: [WorldGuard] Enabling WorldGuard v7.0.4+f7ff984
[00:17:45 INFO]: [WorldGuard] (world) TNT ignition is PERMITTED.
[00:17:45 INFO]: [WorldGuard] (world) Lighters are PERMITTED.
[00:17:45 INFO]: [WorldGuard] (world) Lava fire is PERMITTED.
[00:17:45 INFO]: [WorldGuard] (world) Fire spread is UNRESTRICTED.
[00:17:45 INFO]: [WorldGuard] Loaded configuration for world 'world'
[00:17:45 INFO]: [WorldGuard] (world_nether) TNT ignition is PERMITTED.
[00:17:45 INFO]: [WorldGuard] (world_nether) Lighters are PERMITTED.
[00:17:45 INFO]: [WorldGuard] (world_nether) Lava fire is PERMITTED.
[00:17:45 INFO]: [WorldGuard] (world_nether) Fire spread is UNRESTRICTED.
[00:17:45 INFO]: [WorldGuard] Loaded configuration for world 'world_nether'
[00:17:45 INFO]: [WorldGuard] (world_the_end) TNT ignition is PERMITTED.
[00:17:45 INFO]: [WorldGuard] (world_the_end) Lighters are PERMITTED.
[00:17:45 INFO]: [WorldGuard] (world_the_end) Lava fire is PERMITTED.
[00:17:45 INFO]: [WorldGuard] (world_the_end) Fire spread is UNRESTRICTED.
[00:17:45 INFO]: [WorldGuard] Loaded configuration for world 'world_the_end'
[00:17:45 INFO]: [WorldGuard] Loading region data...
[00:17:45 INFO]: [Lobby] Enabling Lobby v1.0-SNAPSHOT
[00:17:45 ERROR]: Error occurred while enabling Lobby v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:770) ~[patched_1.16.5.jar:git-Paper-701]
at com.sk89q.worldguard.WorldGuard.getPlatform(WorldGuard.java:100) ~[?:?]
at com.webzyno.medicraft.lobby.Lobby.prepareLobbyEnvironment(Lobby.java:61) ~[?:?]
at com.webzyno.medicraft.lobby.Lobby.onEnable(Lobby.java:32) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-701]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:364) ~[patched_1.16.5.jar:git-Paper-701]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.5.jar:git-Paper-701]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) ~[patched_1.16.5.jar:git-Paper-701]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) ~[patched_1.16.5.jar:git-Paper-701]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:591) ~[patched_1.16.5.jar:git-Paper-701]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:281) ~[patched_1.16.5.jar:git-Paper-701]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1066) ~[patched_1.16.5.jar:git-Paper-701]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:290) ~[patched_1.16.5.jar:git-Paper-701]
at java.lang.Thread.run(Thread.java:831) [?:?]

Plugin code:

package com.webzyno.medicraft.lobby;

import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import org.bukkit.plugin.java.JavaPlugin;
import org.slf4j.Logger;

public final class Lobby extends JavaPlugin {

    public final Logger logger = getSLF4JLogger();

    @Override
    public void onEnable() {
        Long startTime = System.currentTimeMillis();

        // configure necessary dependencies and listeners
        RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();

        Long endTime = System.currentTimeMillis();
        logger.info(String.format("Successfully enabled. (took %dms)", endTime - startTime));
    }

    @Override
    public void onDisable() {
        logger.info("Goodbye!");
    }
}

To Reproduce

  1. Just start the server and error will show on the console

Expected behavior

It should correctly get the RegionContainer. But when I dig into the source code of WorldGuard, I found the WorldGuardPlatform in WorldGuard instance is null and cannot pass the null check. Please help me solve the problem.

commented

if this is your plugin, please join discord for help. if it isn't, report it to the developer of that plugin.

in either case this isn't a worldguard bug.

commented

But this is because your API have bug that WorldGuardPlatform cannot be initialized, so WorldGuard cannot successfully invoke getPlatform() method.

commented

WorldGuard itself wouldn't be able to run if that were the case. That's not shown in your log, and the idea that 35k people are currently running a broken version of WorldGuard also seems to dismiss that idea. Again, feel free to ask for help on discord.