Files
src
pom.xml
README.md
Code
21 1,572
src/main/java/com/kodari/fermentcraft/FermentCraftPlugin.java
package com.kodari.fermentcraft;
import com.kodari.fermentcraft.barrel.BarrelManager;
import com.kodari.fermentcraft.command.FermentCommand;
import com.kodari.fermentcraft.config.ConfigurationManager;
import com.kodari.fermentcraft.gui.FermentationMenu;
import com.kodari.fermentcraft.gui.GUIListener;
import com.kodari.fermentcraft.gui.GUIManager;
import com.kodari.fermentcraft.listener.BarrelListener;
import com.kodari.fermentcraft.recipe.RecipeRegistry;
import com.kodari.fermentcraft.service.ItemFactory;
import com.kodari.fermentcraft.service.MessageService;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class FermentCraftPlugin extends JavaPlugin {
private ConfigurationManager configurationManager;
private ItemFactory itemFactory;
private MessageService messages;
private RecipeRegistry recipeRegistry;
private BarrelManager barrelManager;
private GUIManager guiManager;
@Override
public void onEnable() {
this.configurationManager = new ConfigurationManager(this);
this.itemFactory = new ItemFactory(this.configurationManager);
this.messages = new MessageService(this.configurationManager);
this.recipeRegistry = new RecipeRegistry(this, this.configurationManager, this.itemFactory);
this.recipeRegistry.load();
this.barrelManager = new BarrelManager(this, this.recipeRegistry, this.itemFactory, this.messages);
this.barrelManager.load();
this.guiManager = new GUIManager();
FermentCommand fermentCommand = new FermentCommand(this);
getCommand("ferment").setExecutor(fermentCommand);
getCommand("ferment").setTabCompleter(fermentCommand);
getServer().getPluginManager().registerEvents(new GUIListener(this.guiManager), this);
getServer().getPluginManager().registerEvents(new BarrelListener(this.barrelManager), this);
}
@Override
public void onDisable() {
if (this.barrelManager != null) {
this.barrelManager.save();
}
}
public void openRecipeBook(Player player, int page) {
if (this.recipeRegistry.getRecipes().isEmpty()) {
this.messages.send(player, "no-recipes");
return;
}
this.guiManager.openGUI(new FermentationMenu(this, page), player);
}
public void reloadPluginConfiguration() {
this.configurationManager.reload();
this.recipeRegistry.load();
}
public ConfigurationManager getConfigurationManager() {
return this.configurationManager;
}
public ItemFactory getItemFactory() {
return this.itemFactory;
}
public MessageService getMessages() {
return this.messages;
}
public RecipeRegistry getRecipeRegistry() {
return this.recipeRegistry;
}
public BarrelManager getBarrelManager() {
return this.barrelManager;
}
}