65 lines
2.2 KiB
Java
65 lines
2.2 KiB
Java
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;
|
|
import com.alttd.fishingevent.config.NPCLocationConfig;
|
|
import com.alttd.fishingevent.fish_generator.WaterFishGenerator;
|
|
import com.alttd.fishingevent.listeners.CatchFish;
|
|
import com.alttd.fishingevent.npc.NPCManager;
|
|
import com.alttd.fishingevent.points.PointsManagement;
|
|
import com.alttd.fishingevent.util.Logger;
|
|
import dev.sergiferry.playernpc.api.NPCLib;
|
|
import org.bukkit.Bukkit;
|
|
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());
|
|
if (!loadNPCLib()) {
|
|
logger.severe("NPC Lib failed to load, shutting down plugin...");
|
|
Bukkit.getPluginManager().disablePlugin(this);
|
|
return;
|
|
}
|
|
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();
|
|
NPCManager.spawnNPCs(this, logger);
|
|
}
|
|
|
|
private boolean loadNPCLib() {
|
|
NPCLib instance = NPCLib.getInstance();
|
|
if (instance == null)
|
|
return false;
|
|
NPCLib.PluginManager pluginManager = instance.registerPlugin(this);
|
|
return pluginManager != null;
|
|
}
|
|
|
|
@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);
|
|
NPCLocationConfig.reload(this, logger);
|
|
}
|
|
}
|