fishing_event/src/main/java/com/alttd/fishingevent/FishingEvent.java

64 lines
2.1 KiB
Java
Raw Normal View History

2023-09-10 21:58:50 +00:00
package com.alttd.fishingevent;
import com.alttd.fishingevent.commands.FishCommand;
import com.alttd.fishingevent.config.Config;
import com.alttd.fishingevent.config.Fishes;
import com.alttd.fishingevent.config.Messages;
2023-09-22 00:21:53 +00:00
import com.alttd.fishingevent.config.NPCLocationConfig;
2023-09-10 21:58:50 +00:00
import com.alttd.fishingevent.fish_generator.WaterFishGenerator;
import com.alttd.fishingevent.listeners.CatchFish;
2023-09-21 23:33:21 +00:00
import com.alttd.fishingevent.npc.NPCManager;
2023-09-10 21:58:50 +00:00
import com.alttd.fishingevent.points.PointsManagement;
import com.alttd.fishingevent.util.Logger;
2023-09-22 00:21:53 +00:00
import dev.sergiferry.playernpc.api.NPCLib;
import org.bukkit.Bukkit;
2023-09-10 21:58:50 +00:00
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
public final class FishingEvent extends JavaPlugin {
private Logger logger;
@Override
public void onEnable() {
this.logger = new Logger(getLogger());
2023-09-22 00:21:53 +00:00
if (!loadNPCLib()) {
logger.severe("NPC Lib failed to load, shutting down plugin...");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
2023-09-10 21:58:50 +00:00
registerEvents(getServer().getPluginManager());
//add a way to stop and start the fishing event and a way to stop all fishing (so 3 modes normal, active, disabled)
reloadFishConfigs();
registerCommands();
2023-09-21 23:33:21 +00:00
NPCManager.spawnNPCs(this, logger);
2023-09-10 21:58:50 +00:00
}
2023-09-22 00:21:53 +00:00
private boolean loadNPCLib() {
NPCLib instance = NPCLib.getInstance();
if (instance == null)
return false;
NPCLib.PluginManager pluginManager = instance.registerPlugin(this);
return pluginManager != null;
}
2023-09-10 21:58:50 +00:00
@Override
public void onDisable() {
}
private void registerEvents(@NotNull PluginManager pluginManager) {
pluginManager.registerEvents(new CatchFish(logger, new WaterFishGenerator(Fishes.WATER_FISH.RARITY_FISH_MAP, logger), PointsManagement.getInstance()), this);
}
private void registerCommands() {
new FishCommand(this, logger);
}
public void reloadFishConfigs() {
Config.reload(this, logger);
Fishes.reload(this, logger);
Messages.reload(this, logger);
}
}