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
2015-01-26 22:26:21 -08:00
*
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 ;
2015-01-26 22:26:21 -08:00
import java.util.EnumSet ;
import java.util.Random ;
import net.minecraft.command.ICommand ;
import net.minecraft.world.World ;
import net.minecraft.world.chunk.IChunkProvider ;
2014-09-20 22:43:13 -07:00
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 ;
2015-01-26 22:26:21 -08:00
2014-05-02 21:31:20 +02:00
import forestry.core.interfaces.IPickupHandler ;
import forestry.core.interfaces.IResupplyHandler ;
import forestry.core.interfaces.ISaveEventHandler ;
2015-05-29 22:25:54 -07:00
import forestry.core.network.IPacketHandler ;
2015-06-13 16:36:46 -07:00
import forestry.core.proxy.Proxies ;
2014-05-02 21:31:20 +02:00
2014-09-20 22:43:13 -07:00
public abstract class ForestryPlugin {
2014-05-02 21:31:20 +02:00
2014-09-20 22:43:13 -07:00
public boolean isAvailable () {
return true ;
2014-05-02 21:31:20 +02:00
}
2014-09-20 22:43:13 -07:00
public String getFailMessage () {
return "" ;
2014-05-02 21:31:20 +02:00
}
2014-09-22 23:20:58 -07:00
public EnumSet < PluginManager . Module > getDependancies () {
return EnumSet . of ( PluginManager . Module . CORE );
2014-09-20 22:43:13 -07:00
}
2015-04-05 14:16:41 -07:00
protected void setupAPI () {
2014-09-20 22:43:13 -07:00
}
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 () {
2014-09-20 22:43:13 -07:00
}
2015-04-05 14:16:41 -07:00
protected void doInit () {
2014-09-20 22:43:13 -07:00
}
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 ;
}
2015-06-13 16:36:46 -07:00
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 );
Proxies . log . warning ( invalidIMCMessageText );
}
2014-05-02 21:31:20 +02:00
public IGuiHandler getGuiHandler () {
return null ;
}
public ISaveEventHandler getSaveEventHandler () {
return null ;
}
2015-01-11 19:33:37 -08:00
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 IPacketHandler getPacketHandler () {
return null ;
}
public IPickupHandler getPickupHandler () {
return null ;
}
public IResupplyHandler getResupplyHandler () {
return null ;
}
public ICommand [] getConsoleCommands () {
return null ;
}
2014-09-20 22:43:13 -07:00
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 () {
}
2014-09-20 22:43:13 -07:00
protected void registerBackpackItems () {
}
2014-05-02 21:31:20 +02:00
2014-09-20 22:43:13 -07:00
protected void registerCrates () {
}
2014-05-02 21:31:20 +02:00
2014-09-20 22:43:13 -07:00
protected void registerRecipes () {
}
2014-05-02 21:31:20 +02:00
2014-09-20 22:43:13 -07:00
@Override
public String toString () {
Plugin info = getClass (). getAnnotation ( Plugin . class );
2015-01-26 22:26:21 -08:00
if ( info == null ) {
2014-09-20 22:43:13 -07:00
return getClass (). getSimpleName ();
2015-01-26 22:26:21 -08:00
}
2014-09-20 22:43:13 -07:00
return info . name () + " Plugin" ;
}
2014-05-02 21:31:20 +02:00
}