Files
ForestryMC/src/main/java/forestry/plugins/ForestryPlugin.java
T

140 lines
3.3 KiB
Java
Raw Normal View History

2014-05-02 21:31:20 +02:00
/*******************************************************************************
2014-08-07 08:29:25 +02:00
* Copyright (c) 2011-2014 SirSengir.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
2014-08-07 02:56:58 -07:00
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
2014-08-07 08:29:25 +02:00
* Various Contributors including, but not limited to:
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
2014-05-02 21:31:20 +02:00
******************************************************************************/
package forestry.plugins;
import java.util.EnumSet;
import java.util.Random;
import net.minecraft.command.ICommand;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import cpw.mods.fml.common.IFuelHandler;
2014-05-02 21:31:20 +02:00
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.network.IGuiHandler;
import forestry.core.IPickupHandler;
import forestry.core.IResupplyHandler;
import forestry.core.ISaveEventHandler;
import forestry.core.utils.Log;
2014-05-02 21:31:20 +02:00
public abstract class ForestryPlugin {
2014-05-02 21:31:20 +02:00
public boolean isAvailable() {
return true;
2014-05-02 21:31:20 +02:00
}
public String getFailMessage() {
return "";
2014-05-02 21:31:20 +02:00
}
public EnumSet<PluginManager.Module> getDependancies() {
return EnumSet.of(PluginManager.Module.CORE);
}
2015-04-05 14:16:41 -07:00
protected void setupAPI() {
}
2015-04-05 14:16:41 -07:00
protected void disabledSetupAPI() {
2015-03-22 17:41:35 -07:00
}
2015-04-05 14:16:41 -07:00
protected void preInit() {
}
2015-04-05 14:16:41 -07:00
protected void doInit() {
}
2015-04-05 14:16:41 -07:00
protected void postInit() {
2014-05-02 21:31:20 +02:00
}
public boolean processIMCMessage(IMCMessage message) {
return false;
}
protected static String getInvalidIMCMessageText(IMCMessage message) {
final Object messageValue;
if (message.isItemStackMessage()) {
messageValue = message.getItemStackValue().toString();
} else if (message.isNBTMessage()) {
messageValue = message.getNBTValue();
} else if (message.isStringMessage()) {
messageValue = message.getStringValue();
} else {
messageValue = "";
}
return String.format("Received an invalid '%s' request '%s' from mod '%s'. Please contact the author and report this issue.", message.key, messageValue, message.getSender());
}
protected static void logInvalidIMCMessage(IMCMessage message) {
String invalidIMCMessageText = getInvalidIMCMessageText(message);
Log.warning(invalidIMCMessageText);
}
2014-05-02 21:31:20 +02:00
public IGuiHandler getGuiHandler() {
return null;
}
public ISaveEventHandler getSaveEventHandler() {
return null;
}
public void populateChunk(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGeneratedZ) {
}
public void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ) {
2014-05-02 21:31:20 +02:00
}
public void registerPacketHandlers() {
2014-05-02 21:31:20 +02:00
}
public IPickupHandler getPickupHandler() {
return null;
}
public IResupplyHandler getResupplyHandler() {
return null;
}
public ICommand[] getConsoleCommands() {
return null;
}
public IFuelHandler getFuelHandler() {
return null;
}
protected void registerItems() {
}
2014-05-02 21:31:20 +02:00
2015-04-05 14:16:41 -07:00
protected void registerTriggers() {
}
protected void registerBackpackItems() {
}
2014-05-02 21:31:20 +02:00
protected void registerCrates() {
}
2014-05-02 21:31:20 +02:00
protected void registerRecipes() {
}
2014-05-02 21:31:20 +02:00
@Override
public String toString() {
Plugin info = getClass().getAnnotation(Plugin.class);
if (info == null) {
return getClass().getSimpleName();
}
return info.name() + " Plugin";
}
2014-05-02 21:31:20 +02:00
}