I'm trying to register a custom flag. For first time it works fine, but when I start the plugin again, WorldGuard crashes. What is the problem? Code (Java): @Override public void onLoad() { instance = this; // ... // Init WG flag FlagRegistry registry = WorldGuardPlugin.inst().getFlagRegistry(); try { StringFlag flag = new StringFlag("spawn-control-group"); registry.register(flag); GROUP_FLAG = flag; } catch (FlagConflictException e) { Flag<?> existing = registry.get("spawn-control-group"); if (existing instanceof StringFlag) { GROUP_FLAG = (StringFlag) existing; } else { printInConsole("Какие-то плагины конфликтуют с флагом %s","spawn-control-group"); // some Russian text } } } Spoiler: console log [18:21:08] [Server thread/ERROR]: Error occurred while enabling WorldGuard v6.2.2-SNAPSHOT;8eeab68 (Is it up to date?) com.sk89q.worldguard.protection.flags.registry.FlagConflictException: A flag already exists by the name spawn-control-group at com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry.forceRegister(SimpleFlagRegistry.java:84) ~[?:?] at com.sk89q.worldguard.protection.flags.registry.SimpleFlagRegistry.unmarshal(SimpleFlagRegistry.java:145) ~[?:?] at com.sk89q.worldguard.protection.managers.storage.file.YamlRegionFile.setFlags(YamlRegionFile.java:288) ~[?:?] at com.sk89q.worldguard.protection.managers.storage.file.YamlRegionFile.loadAll(YamlRegionFile.java:158) ~[?:?] at com.sk89q.worldguard.protection.managers.RegionManager.load(RegionManager.java:101) ~[?:?] at com.sk89q.worldguard.protection.managers.RegionContainerImpl.createAndLoad(RegionContainerImpl.java:129) ~[?:?] at com.sk89q.worldguard.protection.managers.RegionContainerImpl.load(RegionContainerImpl.java:106) ~[?:?] at com.sk89q.worldguard.bukkit.RegionContainer.load(RegionContainer.java:193) ~[?:?] at com.sk89q.worldguard.bukkit.RegionContainer.loadWorlds(RegionContainer.java:157) ~[?:?] at com.sk89q.worldguard.bukkit.RegionContainer.initialize(RegionContainer.java:93) ~[?:?] at com.sk89q.worldguard.bukkit.WorldGuardPlugin.onEnable(WorldGuardPlugin.java:203) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [spigot-1.12.2.jar:git-Spigot-dcd1643-e60fc34] at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]
Did you make sure you set your instance to null on onDisable()? It could cause some problems otherwise.
Ah right, well the line "A flag already exists by the name spawn-control-group" explains a lot, I didn't see that before. I'm guessing you're trying to set the flag again, while WorldGuard already has it. I don't exactly know how WorldGuard goes about things. But it probably stores the flags you set, and automatically loads them.
I execute register method for the flag once on onLoad. I think it crashes because FlagConflictException extends RuntimeException and can't be cathed. So, is there another way to initialize a WG flag?
Hah, I've renamed my flag to spawn-control and it works. @Twoaster thanx for helping. UPD.: I've discussed it on EngineHub chanell. They expained that "-group" flags are reserved by WorldGuard and can't be registered by other plugins.