reformatted all src files (#141)

This commit is contained in:
YoungOnion
2022-09-17 05:08:02 -06:00
committed by GitHub
parent 3328bfcda2
commit 9011273229
1056 changed files with 88127 additions and 110597 deletions
+48 -64
View File
@@ -19,20 +19,15 @@
package appeng.core;
import appeng.api.config.TunnelType;
import appeng.core.api.IIMCProcessor;
import appeng.core.api.imc.*;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import appeng.api.config.TunnelType;
import appeng.core.api.IIMCProcessor;
import appeng.core.api.imc.IMCBlackListSpatial;
import appeng.core.api.imc.IMCGrinder;
import appeng.core.api.imc.IMCMatterCannon;
import appeng.core.api.imc.IMCP2PAttunement;
import appeng.core.api.imc.IMCSpatial;
/**
* Handles the delegation of the corresponding IMC messages to the suitable IMC processors
@@ -41,64 +36,53 @@ import appeng.core.api.imc.IMCSpatial;
* @version rv3 - 10.08.2015
* @since rv1
*/
public class IMCHandler
{
private static final int INITIAL_PROCESSORS_CAPACITY = 20;
public class IMCHandler {
private static final int INITIAL_PROCESSORS_CAPACITY = 20;
/**
* Contains the processors,
*
* is mutable, but write access only by the constructor
*/
private final Map<String, IIMCProcessor> processors;
/**
* Contains the processors,
* <p>
* is mutable, but write access only by the constructor
*/
private final Map<String, IIMCProcessor> processors;
/**
* Initializes the processors
*/
public IMCHandler()
{
this.processors = new HashMap<>( INITIAL_PROCESSORS_CAPACITY );
/**
* Initializes the processors
*/
public IMCHandler() {
this.processors = new HashMap<>(INITIAL_PROCESSORS_CAPACITY);
this.processors.put( "blacklist-block-spatial", new IMCBlackListSpatial() );
this.processors.put( "whitelist-spatial", new IMCSpatial() );
this.processors.put( "add-grindable", new IMCGrinder() );
this.processors.put( "add-mattercannon-ammo", new IMCMatterCannon() );
this.processors.put("blacklist-block-spatial", new IMCBlackListSpatial());
this.processors.put("whitelist-spatial", new IMCSpatial());
this.processors.put("add-grindable", new IMCGrinder());
this.processors.put("add-mattercannon-ammo", new IMCMatterCannon());
for( final TunnelType type : TunnelType.values() )
{
this.processors.put( "add-p2p-attunement-" + type.name().replace( '_', '-' ).toLowerCase( Locale.ENGLISH ), new IMCP2PAttunement() );
}
}
for (final TunnelType type : TunnelType.values()) {
this.processors.put("add-p2p-attunement-" + type.name().replace('_', '-').toLowerCase(Locale.ENGLISH), new IMCP2PAttunement());
}
}
/**
* Tries to find every message matching the internal IMC keys. When found the corresponding handler will process the
* attached message.
*
* @param event Event carrying the identifier and message for the handlers
*/
void handleIMCEvent( final FMLInterModComms.IMCEvent event )
{
for( final FMLInterModComms.IMCMessage message : event.getMessages() )
{
final String key = message.key;
/**
* Tries to find every message matching the internal IMC keys. When found the corresponding handler will process the
* attached message.
*
* @param event Event carrying the identifier and message for the handlers
*/
void handleIMCEvent(final FMLInterModComms.IMCEvent event) {
for (final FMLInterModComms.IMCMessage message : event.getMessages()) {
final String key = message.key;
try
{
final IIMCProcessor handler = this.processors.get( key );
if( handler != null )
{
handler.process( message );
}
else
{
throw new IllegalStateException( "Invalid IMC Called: " + key );
}
}
catch( final Exception t )
{
AELog.warn( "Problem detected when processing IMC " + key + " from " + message.getSender() );
AELog.debug( t );
}
}
}
try {
final IIMCProcessor handler = this.processors.get(key);
if (handler != null) {
handler.process(message);
} else {
throw new IllegalStateException("Invalid IMC Called: " + key);
}
} catch (final Exception t) {
AELog.warn("Problem detected when processing IMC " + key + " from " + message.getSender());
AELog.debug(t);
}
}
}
}