All GUI compile errors fixed, switched to excludes over includes in gradle build and lots, LOTS of more fixes.
This commit is contained in:
@@ -19,94 +19,35 @@
|
||||
package appeng.server;
|
||||
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import static net.minecraft.command.Commands.literal;
|
||||
|
||||
|
||||
public final class AECommand extends CommandBase
|
||||
{
|
||||
private final MinecraftServer srv;
|
||||
public final class AECommand {
|
||||
|
||||
public AECommand( final MinecraftServer server )
|
||||
{
|
||||
this.srv = server;
|
||||
}
|
||||
public void register(CommandDispatcher<CommandSource> dispatcher) {
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
LiteralArgumentBuilder<CommandSource> builder = literal("ae2");
|
||||
for (Commands command : Commands.values()) {
|
||||
add(builder, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "ae2";
|
||||
}
|
||||
dispatcher.register(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage( final ICommandSender icommandsender )
|
||||
{
|
||||
return "commands.ae2.usage";
|
||||
}
|
||||
private void add(LiteralArgumentBuilder<net.minecraft.command.CommandSource> builder, Commands subCommand) {
|
||||
|
||||
builder.then(literal(subCommand.name().toLowerCase())
|
||||
.requires(src -> src.hasPermissionLevel(subCommand.level))
|
||||
.executes(ctx -> {
|
||||
subCommand.command.call(ServerLifecycleHooks.getCurrentServer(), new String[0], ctx.getSource());
|
||||
return 1;
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute( final MinecraftServer server, final ICommandSender sender, final String[] args ) throws CommandException
|
||||
{
|
||||
if( args.length == 0 )
|
||||
{
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
else if( "help".equals( args[0] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( args.length > 1 )
|
||||
{
|
||||
final Commands c = Commands.valueOf( args[1] );
|
||||
throw new WrongUsageException( c.command.getHelp( this.srv ) );
|
||||
}
|
||||
}
|
||||
catch( final WrongUsageException wrong )
|
||||
{
|
||||
throw wrong;
|
||||
}
|
||||
catch( final Throwable er )
|
||||
{
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
}
|
||||
else if( "list".equals( args[0] ) )
|
||||
{
|
||||
throw new WrongUsageException( Joiner.on( ", " ).join( Commands.values() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
final Commands c = Commands.valueOf( args[0] );
|
||||
if( sender.canUseCommand( c.level, this.getName() ) )
|
||||
{
|
||||
c.command.call( this.srv, args, sender );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new WrongUsageException( "commands.ae2.permissions" );
|
||||
}
|
||||
}
|
||||
catch( final WrongUsageException wrong )
|
||||
{
|
||||
throw wrong;
|
||||
}
|
||||
catch( final Throwable er )
|
||||
{
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
package appeng.server;
|
||||
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
|
||||
@@ -28,5 +29,5 @@ public interface ISubCommand
|
||||
|
||||
String getHelp( MinecraftServer srv );
|
||||
|
||||
void call( MinecraftServer srv, String[] args, ICommandSender sender );
|
||||
void call( MinecraftServer srv, String[] args, CommandSource sender );
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
package appeng.server.subcommands;
|
||||
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
@@ -37,16 +37,6 @@ public class ChunkLogger implements ISubCommand
|
||||
|
||||
private boolean enabled = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkLoadEvent( final ChunkEvent.Load event )
|
||||
{
|
||||
if( !event.getWorld().isRemote )
|
||||
{
|
||||
AELog.info( "Chunk Loaded: " + event.getChunk().x + ", " + event.getChunk().z );
|
||||
this.displayStack();
|
||||
}
|
||||
}
|
||||
|
||||
private void displayStack()
|
||||
{
|
||||
if( AEConfig.instance().isFeatureEnabled( AEFeature.CHUNK_LOGGER_TRACE ) )
|
||||
@@ -66,12 +56,22 @@ public class ChunkLogger implements ISubCommand
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkLoadEvent( final ChunkEvent.Load event )
|
||||
{
|
||||
if( !event.getWorld().isRemote() )
|
||||
{
|
||||
AELog.info( "Chunk Loaded: " + event.getChunk().getPos().x + ", " + event.getChunk().getPos().z );
|
||||
this.displayStack();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkUnloadEvent( final ChunkEvent.Unload unload )
|
||||
{
|
||||
if( !unload.getWorld().isRemote )
|
||||
if( !unload.getWorld().isRemote() )
|
||||
{
|
||||
AELog.info( "Chunk Unloaded: " + unload.getChunk().x + ", " + unload.getChunk().z );
|
||||
AELog.info( "Chunk Unloaded: " + unload.getChunk().getPos().x + ", " + unload.getChunk().getPos().z );
|
||||
this.displayStack();
|
||||
}
|
||||
}
|
||||
@@ -83,19 +83,19 @@ public class ChunkLogger implements ISubCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call( final MinecraftServer srv, final String[] data, final ICommandSender sender )
|
||||
public void call( final MinecraftServer srv, final String[] data, final CommandSource sender )
|
||||
{
|
||||
this.enabled = !this.enabled;
|
||||
|
||||
if( this.enabled )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
sender.sendMessage( new TranslationTextComponent( "commands.ae2.ChunkLoggerOn" ) );
|
||||
sender.sendFeedback( new TranslationTextComponent( "commands.ae2.ChunkLoggerOn" ), true );
|
||||
}
|
||||
else
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.unregister( this );
|
||||
sender.sendMessage( new TranslationTextComponent( "commands.ae2.ChunkLoggerOff" ) );
|
||||
sender.sendFeedback( new TranslationTextComponent( "commands.ae2.ChunkLoggerOff" ), true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.server.subcommands;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
@@ -38,9 +38,9 @@ public class Supporters implements ISubCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call( final MinecraftServer srv, final String[] data, final ICommandSender sender )
|
||||
public void call( final MinecraftServer srv, final String[] data, final CommandSource sender )
|
||||
{
|
||||
final String[] who = { "Stig Halvorsen", "Josh Ricker", "Jenny \"Othlon\" Sutherland", "Hristo Bogdanov", "BevoLJ" };
|
||||
sender.sendMessage( new StringTextComponent( "Special thanks to " + Joiner.on( ", " ).join( who ) ) );
|
||||
sender.sendFeedback( new StringTextComponent( "Special thanks to " + Joiner.on( ", " ).join( who ) ), true );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user