Some plugin manager error checking and tweaks.

This commit is contained in:
CovertJaguar committed 2014-09-22 20:30:25 -07:00
1 parent 308a1ea027
commit cc5f102d1c
5 files changed
+21 -12

No files matched your search

@@ -11,6 +11,9 @@
package forestry.core.config;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginManager;
import forestry.plugins.PluginManager.Stage;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
@@ -79,6 +82,8 @@ public enum ForestryBlock {
private Block block;
public void registerBlock(Block block, Class<? extends ItemBlock> itemClass, String name) {
if (!EnumSet.of(Stage.PRE_INIT).contains(PluginManager.getStage()))
throw new RuntimeException("Tried to register Block outside of Pre-Init");
this.block = block;
block.setBlockName("for." + name);
Proxies.common.registerBlock(block, itemClass);
@@ -95,8 +100,8 @@ public enum ForestryBlock {
public boolean isBlockEqual(World world, int x, int y, int z) {
return isBlockEqual(world.getBlock(x, y, z));
}
public Item item(){
public Item item() {
return Item.getItemFromBlock(block);
}
@@ -14,6 +14,9 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import forestry.core.proxy.Proxies;
import forestry.plugins.PluginManager;
import forestry.plugins.PluginManager.Stage;
import java.util.EnumSet;
import net.minecraftforge.oredict.OreDictionary;
/**
@@ -248,6 +251,8 @@ public enum ForestryItem {
private Item item;
public void registerItem(Item item, String name) {
if (!EnumSet.of(Stage.PRE_INIT, Stage.INIT).contains(PluginManager.getStage()))
throw new RuntimeException("Tried to register Item outside of Pre-Init or Init");
this.item = item;
item.setUnlocalizedName("for." + name);
Proxies.common.registerItem(item);
@@ -179,32 +179,31 @@ public class PluginManager {
private static void loadPlugin(ForestryPlugin plugin) {
Proxies.log.fine("Loading Plugin: {0}", plugin);
ForestryPlugin nplugin = (ForestryPlugin) plugin;
IGuiHandler guiHandler = nplugin.getGuiHandler();
IGuiHandler guiHandler = plugin.getGuiHandler();
if (guiHandler != null)
guiHandlers.add(guiHandler);
IPacketHandler packetHandler = nplugin.getPacketHandler();
IPacketHandler packetHandler = plugin.getPacketHandler();
if (packetHandler != null)
packetHandlers.add(packetHandler);
IPickupHandler pickupHandler = nplugin.getPickupHandler();
IPickupHandler pickupHandler = plugin.getPickupHandler();
if (pickupHandler != null)
pickupHandlers.add(pickupHandler);
ISaveEventHandler saveHandler = nplugin.getSaveEventHandler();
ISaveEventHandler saveHandler = plugin.getSaveEventHandler();
if (saveHandler != null)
saveEventHandlers.add(saveHandler);
IResupplyHandler resupplyHandler = nplugin.getResupplyHandler();
IResupplyHandler resupplyHandler = plugin.getResupplyHandler();
if (resupplyHandler != null)
resupplyHandlers.add(resupplyHandler);
IOreDictionaryHandler dictionaryHandler = nplugin.getDictionaryHandler();
IOreDictionaryHandler dictionaryHandler = plugin.getDictionaryHandler();
if (dictionaryHandler != null)
dictionaryHandlers.add(dictionaryHandler);
IFuelHandler fuelHandler = nplugin.getFuelHandler();
IFuelHandler fuelHandler = plugin.getFuelHandler();
if (fuelHandler != null)
GameRegistry.registerFuelHandler((fuelHandler));
}