mirror of
https://github.com/exituser/Brewery.git
synced 2026-09-17 06:38:56 +00:00
Store the item loaders on the plugin instance
This commit is contained in:
@@ -9,8 +9,7 @@ import com.dre.brewery.integration.ChestShopListener;
|
||||
import com.dre.brewery.integration.IntegrationListener;
|
||||
import com.dre.brewery.integration.barrel.LogBlockBarrel;
|
||||
import com.dre.brewery.listeners.*;
|
||||
import com.dre.brewery.recipe.BCauldronRecipe;
|
||||
import com.dre.brewery.recipe.BRecipe;
|
||||
import com.dre.brewery.recipe.*;
|
||||
import com.dre.brewery.utility.BUtil;
|
||||
import com.dre.brewery.utility.LegacyUtil;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
@@ -28,6 +27,7 @@ import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class P extends JavaPlugin {
|
||||
public static P p;
|
||||
@@ -47,6 +47,9 @@ public class P extends JavaPlugin {
|
||||
public WorldListener worldListener;
|
||||
public IntegrationListener integrationListener;
|
||||
|
||||
// Registrations
|
||||
public Map<String, Function<ItemLoader, Ingredient>> ingredientLoaders = new HashMap<>();
|
||||
|
||||
// Language
|
||||
public String language;
|
||||
public LanguageReader languageReader;
|
||||
@@ -95,6 +98,13 @@ public class P extends JavaPlugin {
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
// Register Item Loaders
|
||||
CustomItem.registerItemLoader(this);
|
||||
SimpleItem.registerItemLoader(this);
|
||||
PluginItem.registerItemLoader(this);
|
||||
|
||||
// Read data files
|
||||
BData.readData();
|
||||
|
||||
// Setup Metrics
|
||||
@@ -240,6 +250,28 @@ public class P extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For loading ingredients from ItemMeta.
|
||||
* <p>Register a Static function that takes an ItemLoader, containing a DataInputStream.
|
||||
* <p>Using the Stream it constructs a corresponding Ingredient for the chosen SaveID
|
||||
*
|
||||
* @param saveID The SaveID should be a small identifier like "AB"
|
||||
* @param loadFct The Static Function that loads the Item, i.e.
|
||||
* public static AItem loadFrom(ItemLoader loader)
|
||||
*/
|
||||
public void registerForItemLoader(String saveID, Function<ItemLoader, Ingredient> loadFct) {
|
||||
ingredientLoaders.put(saveID, loadFct);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister the ItemLoader
|
||||
*
|
||||
* @param saveID the chosen SaveID
|
||||
*/
|
||||
public void unRegisterItemLoader(String saveID) {
|
||||
ingredientLoaders.remove(saveID);
|
||||
}
|
||||
|
||||
public static P getInstance() {
|
||||
return p;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user