Basic reformat, hit once, hope never again
This commit is contained in:
@@ -18,22 +18,40 @@
|
||||
|
||||
package appeng.server;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
|
||||
public class AECommand extends CommandBase
|
||||
{
|
||||
|
||||
final MinecraftServer srv;
|
||||
|
||||
public AECommand(MinecraftServer server) {
|
||||
public AECommand( MinecraftServer server )
|
||||
{
|
||||
this.srv = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* wtf?
|
||||
*/
|
||||
@Override
|
||||
public int compareTo( Object arg0 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
@@ -41,44 +59,38 @@ public class AECommand extends CommandBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender)
|
||||
public String getCommandUsage( ICommandSender icommandsender )
|
||||
{
|
||||
return "commands.ae2.usage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
public void processCommand( ICommandSender sender, String[] args )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args)
|
||||
{
|
||||
if ( args.length == 0 )
|
||||
if( args.length == 0 )
|
||||
{
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
else if ( "help".equals( args[0] ) )
|
||||
else if( "help".equals( args[0] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( args.length > 1 )
|
||||
if( args.length > 1 )
|
||||
{
|
||||
Commands c = Commands.valueOf( args[1] );
|
||||
throw new WrongUsageException( c.command.getHelp( this.srv ) );
|
||||
}
|
||||
}
|
||||
catch ( WrongUsageException wrong )
|
||||
catch( WrongUsageException wrong )
|
||||
{
|
||||
throw wrong;
|
||||
}
|
||||
catch (Throwable er)
|
||||
catch( Throwable er )
|
||||
{
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
}
|
||||
else if ( "list".equals( args[0] ) )
|
||||
else if( "list".equals( args[0] ) )
|
||||
{
|
||||
throw new WrongUsageException( Joiner.on( ", " ).join( Commands.values() ) );
|
||||
}
|
||||
@@ -87,28 +99,19 @@ public class AECommand extends CommandBase
|
||||
try
|
||||
{
|
||||
Commands c = Commands.valueOf( args[0] );
|
||||
if ( sender.canCommandSenderUseCommand( c.level, this.getCommandName() ) )
|
||||
if( sender.canCommandSenderUseCommand( c.level, this.getCommandName() ) )
|
||||
c.command.call( this.srv, args, sender );
|
||||
else
|
||||
throw new WrongUsageException( "commands.ae2.permissions" );
|
||||
}
|
||||
catch ( WrongUsageException wrong )
|
||||
catch( WrongUsageException wrong )
|
||||
{
|
||||
throw wrong;
|
||||
}
|
||||
catch (Throwable er)
|
||||
catch( Throwable er )
|
||||
{
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wtf?
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Object arg0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.server;
|
||||
|
||||
|
||||
public enum AccessType
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -18,25 +18,28 @@
|
||||
|
||||
package appeng.server;
|
||||
|
||||
|
||||
import appeng.server.subcommands.ChunkLogger;
|
||||
import appeng.server.subcommands.Supporters;
|
||||
|
||||
|
||||
public enum Commands
|
||||
{
|
||||
Chunklogger(4, new ChunkLogger()), supporters(0, new Supporters());
|
||||
Chunklogger( 4, new ChunkLogger() ), supporters( 0, new Supporters() );
|
||||
|
||||
public final int level;
|
||||
public final ISubCommand command;
|
||||
|
||||
Commands( int level, ISubCommand w )
|
||||
{
|
||||
this.level = level;
|
||||
this.command = w;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name();
|
||||
}
|
||||
|
||||
Commands( int level, ISubCommand w ) {
|
||||
this.level = level;
|
||||
this.command = w;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,14 +18,15 @@
|
||||
|
||||
package appeng.server;
|
||||
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
|
||||
public interface ISubCommand
|
||||
{
|
||||
|
||||
String getHelp(MinecraftServer srv);
|
||||
|
||||
void call(MinecraftServer srv, String[] args, ICommandSender sender);
|
||||
String getHelp( MinecraftServer srv );
|
||||
|
||||
void call( MinecraftServer srv, String[] args, ICommandSender sender );
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.server;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -42,52 +43,11 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ServerHelper extends CommonHelper
|
||||
{
|
||||
|
||||
@Override
|
||||
public void doRenderItem(ItemStack sis, World tile)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntityPlayer> getPlayers()
|
||||
{
|
||||
if ( !Platform.isClient() )
|
||||
{
|
||||
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
|
||||
if ( server != null )
|
||||
return server.getConfigurationManager().playerEntityList;
|
||||
}
|
||||
|
||||
return new ArrayList<EntityPlayer>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToAllNearExcept(EntityPlayer p, double x, double y, double z, double dist, World w, AppEngPacket packet)
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
for (EntityPlayer o : this.getPlayers())
|
||||
{
|
||||
EntityPlayerMP entityplayermp = (EntityPlayerMP) o;
|
||||
|
||||
if ( entityplayermp != p && entityplayermp.worldObj == w )
|
||||
{
|
||||
double dX = x - entityplayermp.posX;
|
||||
double dY = y - entityplayermp.posY;
|
||||
double dZ = z - entityplayermp.posZ;
|
||||
|
||||
if ( dX * dX + dY * dY + dZ * dZ < dist * dist )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( packet, entityplayermp );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private EntityPlayer renderModeBased;
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
@@ -95,12 +55,6 @@ public class ServerHelper extends CommonHelper
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
@@ -108,19 +62,57 @@ public class ServerHelper extends CommonHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTileEntitySpecialRenderer(Class tile, AEBaseBlock blk)
|
||||
public void bindTileEntitySpecialRenderer( Class tile, AEBaseBlock blk )
|
||||
{
|
||||
throw new RuntimeException( "This is a server..." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnEffect(EffectType type, World worldObj, double posX, double posY, double posZ, Object o)
|
||||
public List<EntityPlayer> getPlayers()
|
||||
{
|
||||
if( !Platform.isClient() )
|
||||
{
|
||||
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
|
||||
if( server != null )
|
||||
return server.getConfigurationManager().playerEntityList;
|
||||
}
|
||||
|
||||
return new ArrayList<EntityPlayer>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendToAllNearExcept( EntityPlayer p, double x, double y, double z, double dist, World w, AppEngPacket packet )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
return;
|
||||
|
||||
for( EntityPlayer o : this.getPlayers() )
|
||||
{
|
||||
EntityPlayerMP entityplayermp = (EntityPlayerMP) o;
|
||||
|
||||
if( entityplayermp != p && entityplayermp.worldObj == w )
|
||||
{
|
||||
double dX = x - entityplayermp.posX;
|
||||
double dY = y - entityplayermp.posY;
|
||||
double dZ = z - entityplayermp.posZ;
|
||||
|
||||
if( dX * dX + dY * dY + dZ * dZ < dist * dist )
|
||||
{
|
||||
NetworkHandler.instance.sendTo( packet, entityplayermp );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnEffect( EffectType type, World worldObj, double posX, double posY, double posZ, Object o )
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAddParticles(Random r)
|
||||
public boolean shouldAddParticles( Random r )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -131,35 +123,39 @@ public class ServerHelper extends CommonHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRenderItem( ItemStack sis, World tile )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableRenderMode getRenderMode()
|
||||
{
|
||||
if ( this.renderModeBased == null )
|
||||
if( this.renderModeBased == null )
|
||||
return CableRenderMode.Standard;
|
||||
|
||||
return this.renderModeForPlayer( this.renderModeBased );
|
||||
}
|
||||
|
||||
private EntityPlayer renderModeBased;
|
||||
|
||||
@Override
|
||||
public void updateRenderMode(EntityPlayer player)
|
||||
protected CableRenderMode renderModeForPlayer( EntityPlayer player )
|
||||
{
|
||||
this.renderModeBased = player;
|
||||
}
|
||||
|
||||
protected CableRenderMode renderModeForPlayer(EntityPlayer player)
|
||||
{
|
||||
if ( player != null )
|
||||
if( player != null )
|
||||
{
|
||||
for (int x = 0; x < InventoryPlayer.getHotbarSize(); x++)
|
||||
for( int x = 0; x < InventoryPlayer.getHotbarSize(); x++ )
|
||||
{
|
||||
ItemStack is = player.inventory.getStackInSlot( x );
|
||||
|
||||
if ( is != null && is.getItem() instanceof ToolNetworkTool )
|
||||
if( is != null && is.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
NBTTagCompound c = is.getTagCompound();
|
||||
if ( c != null && c.getBoolean( "hideFacades" ) )
|
||||
if( c != null && c.getBoolean( "hideFacades" ) )
|
||||
return CableRenderMode.CableView;
|
||||
}
|
||||
}
|
||||
@@ -174,6 +170,12 @@ public class ServerHelper extends CommonHelper
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRenderMode( EntityPlayer player )
|
||||
{
|
||||
this.renderModeBased = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void missingCoreMod()
|
||||
{
|
||||
|
||||
@@ -32,15 +32,16 @@ import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.server.ISubCommand;
|
||||
|
||||
|
||||
public class ChunkLogger implements ISubCommand
|
||||
{
|
||||
|
||||
boolean enabled = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public void ChunkLoad(ChunkEvent.Load load)
|
||||
public void ChunkLoad( ChunkEvent.Load load )
|
||||
{
|
||||
if ( !load.world.isRemote )
|
||||
if( !load.world.isRemote )
|
||||
{
|
||||
AELog.info( "Chunk Loaded: " + load.getChunk().xPosition + ", " + load.getChunk().zPosition );
|
||||
this.displayStack();
|
||||
@@ -49,12 +50,12 @@ public class ChunkLogger implements ISubCommand
|
||||
|
||||
private void displayStack()
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChunkLoggerTrace ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.ChunkLoggerTrace ) )
|
||||
{
|
||||
boolean output = false;
|
||||
for (StackTraceElement e : Thread.currentThread().getStackTrace())
|
||||
for( StackTraceElement e : Thread.currentThread().getStackTrace() )
|
||||
{
|
||||
if ( output )
|
||||
if( output )
|
||||
AELog.info( " " + e.getClassName() + '.' + e.getMethodName() + " (" + e.getLineNumber() + ')' );
|
||||
else
|
||||
{
|
||||
@@ -65,9 +66,9 @@ public class ChunkLogger implements ISubCommand
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void ChunkLoad(ChunkEvent.Unload unload)
|
||||
public void ChunkLoad( ChunkEvent.Unload unload )
|
||||
{
|
||||
if ( !unload.world.isRemote )
|
||||
if( !unload.world.isRemote )
|
||||
{
|
||||
AELog.info( "Chunk Unloaded: " + unload.getChunk().xPosition + ", " + unload.getChunk().zPosition );
|
||||
this.displayStack();
|
||||
@@ -75,11 +76,17 @@ public class ChunkLogger implements ISubCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MinecraftServer srv, String[] data, ICommandSender sender)
|
||||
public String getHelp( MinecraftServer srv )
|
||||
{
|
||||
return "commands.ae2.ChunkLogger";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call( MinecraftServer srv, String[] data, ICommandSender sender )
|
||||
{
|
||||
this.enabled = !this.enabled;
|
||||
|
||||
if ( this.enabled )
|
||||
if( this.enabled )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
sender.addChatMessage( new ChatComponentTranslation( "commands.ae2.ChunkLoggerOn" ) );
|
||||
@@ -90,11 +97,4 @@ public class ChunkLogger implements ISubCommand
|
||||
sender.addChatMessage( new ChatComponentTranslation( "commands.ae2.ChunkLoggerOff" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(MinecraftServer srv)
|
||||
{
|
||||
return "commands.ae2.ChunkLogger";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,28 +18,29 @@
|
||||
|
||||
package appeng.server.subcommands;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import appeng.server.ISubCommand;
|
||||
|
||||
|
||||
public class Supporters implements ISubCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public void call(MinecraftServer srv, String[] data, ICommandSender sender)
|
||||
{
|
||||
String[] who = { "Stig Halvorsen", "Josh Ricker", "Jenny \"Othlon\" Sutherland", "Hristo Bogdanov", "BevoLJ" };
|
||||
sender.addChatMessage( new ChatComponentText( "Special thanks to " + Joiner.on( ", " ).join( who ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(MinecraftServer srv)
|
||||
public String getHelp( MinecraftServer srv )
|
||||
{
|
||||
return "commands.ae2.Supporters";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call( MinecraftServer srv, String[] data, ICommandSender sender )
|
||||
{
|
||||
String[] who = { "Stig Halvorsen", "Josh Ricker", "Jenny \"Othlon\" Sutherland", "Hristo Bogdanov", "BevoLJ" };
|
||||
sender.addChatMessage( new ChatComponentText( "Special thanks to " + Joiner.on( ", " ).join( who ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user