Added AE2 Command back in.

Added /ae2 supporters
Added /ae2 chunklogger
This commit is contained in:
AlgorithmX2
2014-08-22 00:27:46 -05:00
parent 53a78fc950
commit 47eb2c36f3
7 changed files with 230 additions and 0 deletions
+8
View File
@@ -19,6 +19,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.hooks.TickHandler;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.server.AECommand;
import appeng.services.VersionChecker;
import appeng.util.Platform;
@@ -34,6 +35,7 @@ import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
@@ -200,4 +202,10 @@ public class AppEng
WorldSettings.getInstance().init();
}
@EventHandler
public void serverStarting(FMLServerStartingEvent evt)
{
evt.registerServerCommand( new AECommand( evt.getServer() ) );
}
}
+9
View File
@@ -0,0 +1,9 @@
diff a/core/AppEng.java b/core/AppEng.java (rejected hunks)
@@ -34,7 +34,6 @@
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
-import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
+92
View File
@@ -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;
}
}
+24
View File
@@ -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;
}
}
+13
View File
@@ -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);
}
+58
View File
@@ -0,0 +1,58 @@
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.AELog;
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 );
}
}
@SubscribeEvent
public void ChunkLoad(ChunkEvent.Unload unload)
{
if ( !unload.world.isRemote )
{
AELog.info( "Chunk Unloaded: " + unload.getChunk().xPosition + ", " + unload.getChunk().zPosition );
}
}
@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";
}
}
+26
View File
@@ -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";
}
}