Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
package appeng.server;
|
||||
|
||||
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) {
|
||||
srv = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "ae2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender)
|
||||
{
|
||||
return "commands.ae2.usage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args)
|
||||
{
|
||||
if ( args.length == 0 )
|
||||
{
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
else if ( "help".equals( args[0] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( args.length > 1 )
|
||||
{
|
||||
Commands c = Commands.valueOf( args[1] );
|
||||
throw new WrongUsageException( c.command.getHelp( srv ) );
|
||||
}
|
||||
}
|
||||
catch (Throwable er)
|
||||
{
|
||||
if ( er instanceof WrongUsageException )
|
||||
throw (WrongUsageException) er;
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
}
|
||||
else if ( "list".equals( args[0] ) )
|
||||
{
|
||||
throw new WrongUsageException( Joiner.on( ", " ).join( Commands.values() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Commands c = Commands.valueOf( args[0] );
|
||||
if ( sender.canCommandSenderUseCommand( c.level, getCommandName() ) )
|
||||
c.command.call( srv, args, sender );
|
||||
else
|
||||
throw new WrongUsageException( "commands.ae2.permissions" );
|
||||
}
|
||||
catch (Throwable er)
|
||||
{
|
||||
if ( er instanceof WrongUsageException )
|
||||
throw (WrongUsageException) er;
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wtf?
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Object arg0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package appeng.server;
|
||||
|
||||
public enum AccessType
|
||||
{
|
||||
/**
|
||||
* allows basic access to manipulate the block via gui, or other.
|
||||
*/
|
||||
BLOCK_ACCESS,
|
||||
|
||||
/**
|
||||
* Can player deposit items into the network.
|
||||
*/
|
||||
NETWORK_DEPOSIT,
|
||||
|
||||
/**
|
||||
* can player withdraw items from the network.
|
||||
*/
|
||||
NETWORK_WITHDRAW,
|
||||
|
||||
/**
|
||||
* can player issue crafting requests?
|
||||
*/
|
||||
NETWORK_CRAFT,
|
||||
|
||||
/**
|
||||
* can player add new blocks to the network.
|
||||
*/
|
||||
NETWORK_BUILD,
|
||||
|
||||
/**
|
||||
* can player manipulate security settings.
|
||||
*/
|
||||
NETWORK_SECURITY
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.server;
|
||||
|
||||
import appeng.server.subcommands.ChunkLogger;
|
||||
import appeng.server.subcommands.Supporters;
|
||||
|
||||
public enum Commands
|
||||
{
|
||||
chunklogger(4, new ChunkLogger()), supporters(0, new Supporters());
|
||||
|
||||
public final int level;
|
||||
public final ISubCommand command;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name();
|
||||
}
|
||||
|
||||
private Commands(int level, ISubCommand w) {
|
||||
this.level = level;
|
||||
command = w;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package appeng.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.items.tools.ToolNetworkTool;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@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 : 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 init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postinit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
throw new RuntimeException( "This is a server..." );
|
||||
}
|
||||
|
||||
@Override
|
||||
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)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAddParticles(Random r)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MovingObjectPosition getMOP()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableRenderMode getRenderMode()
|
||||
{
|
||||
if ( renderModeBased == null )
|
||||
return CableRenderMode.Standard;
|
||||
|
||||
return renderModeForPlayer( renderModeBased );
|
||||
}
|
||||
|
||||
private EntityPlayer renderModeBased;
|
||||
|
||||
@Override
|
||||
public void updateRenderMode(EntityPlayer player)
|
||||
{
|
||||
renderModeBased = player;
|
||||
}
|
||||
|
||||
protected CableRenderMode renderModeForPlayer(EntityPlayer player)
|
||||
{
|
||||
if ( player != null )
|
||||
{
|
||||
for (int x = 0; x < InventoryPlayer.getHotbarSize(); x++)
|
||||
{
|
||||
ItemStack is = player.inventory.getStackInSlot( x );
|
||||
|
||||
if ( is != null && is.getItem() instanceof ToolNetworkTool )
|
||||
{
|
||||
NBTTagCompound c = is.getTagCompound();
|
||||
if ( c != null && c.getBoolean( "hideFacades" ) )
|
||||
return CableRenderMode.CableView;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CableRenderMode.Standard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void triggerUpdates()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void missingCoreMod()
|
||||
{
|
||||
throw new RuntimeException( "Unable to Load Core Mod, please verify that AE2 is properly install in the mods folder, with a .jar extension." );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package appeng.server.subcommands;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.server.ISubCommand;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ChunkLogger implements ISubCommand
|
||||
{
|
||||
|
||||
boolean enabled = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public void ChunkLoad(ChunkEvent.Load load)
|
||||
{
|
||||
if ( !load.world.isRemote )
|
||||
{
|
||||
AELog.info( "Chunk Loaded: " + load.getChunk().xPosition + ", " + load.getChunk().zPosition );
|
||||
displayStack();
|
||||
}
|
||||
}
|
||||
|
||||
private void displayStack()
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.ChunkLoggerTrace ) )
|
||||
{
|
||||
boolean output = false;
|
||||
for (StackTraceElement e : Thread.currentThread().getStackTrace())
|
||||
{
|
||||
if ( output )
|
||||
AELog.info( " " + e.getClassName() + "." + e.getMethodName() + " (" + e.getLineNumber() + ")" );
|
||||
else
|
||||
{
|
||||
output = e.getClassName().contains( "EventBus" ) && e.getMethodName().contains( "post" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void ChunkLoad(ChunkEvent.Unload unload)
|
||||
{
|
||||
if ( !unload.world.isRemote )
|
||||
{
|
||||
AELog.info( "Chunk Unloaded: " + unload.getChunk().xPosition + ", " + unload.getChunk().zPosition );
|
||||
displayStack();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MinecraftServer srv, String[] data, ICommandSender sender)
|
||||
{
|
||||
enabled = !enabled;
|
||||
|
||||
if ( enabled )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
sender.addChatMessage( new ChatComponentTranslation( "commands.ae2.ChunkLoggerOn" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.unregister( this );
|
||||
sender.addChatMessage( new ChatComponentTranslation( "commands.ae2.ChunkLoggerOff" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(MinecraftServer srv)
|
||||
{
|
||||
return "commands.ae2.ChunkLogger";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package appeng.server.subcommands;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import appeng.server.ISubCommand;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
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)
|
||||
{
|
||||
return "commands.ae2.Supporters";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user