Add example of config as well

This commit is contained in:
AzureDoom
2026-06-08 09:28:46 -04:00
parent 314ff77855
commit f0f2476f06
2 changed files with 38 additions and 1 deletions

View File

@@ -3,20 +3,32 @@ package dev.hytalemodding;
import com.hypixel.hytale.server.core.event.events.player.PlayerReadyEvent;
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
import com.hypixel.hytale.server.core.util.Config;
import dev.hytalemodding.commands.ExampleCommand;
import dev.hytalemodding.config.ExampleConfig;
import dev.hytalemodding.events.ExampleEvent;
import javax.annotation.Nonnull;
public class ExamplePlugin extends JavaPlugin {
private static Config<ExampleConfig> config = null;
public ExamplePlugin(@Nonnull JavaPluginInit init) {
super(init);
config = this.withConfig("example_config", ExampleConfig.CODEC);
}
@Override
protected void setup() {
config.save();
this.getCommandRegistry().registerCommand(new ExampleCommand("example", "An example command"));
this.getEventRegistry().registerGlobal(PlayerReadyEvent.class, ExampleEvent::onPlayerReady);
if (getConfig().get().isEnabledWelcomeMessage()) {
this.getEventRegistry().registerGlobal(PlayerReadyEvent.class, ExampleEvent::onPlayerReady);
}
}
public static Config<ExampleConfig> getConfig() {
return config;
}
}