MyCrazyPi

Untitled

Apr 5th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //main class
  2. @EventHandler
  3.     public void init(FMLInitializationEvent event)
  4.     {
  5.         FMLCommonHandler.instance().bus().register(this);
  6.         ClientCommandHandler.instance.registerCommand(new Command());
  7.     }
  8.  
  9. //command shit
  10. package resident;
  11.  
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import java.util.Set;
  15.  
  16. import net.minecraft.client.Minecraft;
  17. import net.minecraft.client.entity.EntityPlayerSP;
  18. import net.minecraft.command.CommandBase;
  19. import net.minecraft.command.CommandException;
  20. import net.minecraft.command.ICommand;
  21. import net.minecraft.command.ICommandSender;
  22. import net.minecraft.entity.player.EntityPlayerMP;
  23. import net.minecraft.event.ClickEvent;
  24. import net.minecraft.server.MinecraftServer;
  25. import net.minecraft.server.management.ServerConfigurationManager;
  26. import net.minecraft.util.BlockPos;
  27. import net.minecraft.util.ChatComponentText;
  28. import net.minecraft.util.EnumChatFormatting;
  29. import net.minecraftforge.common.config.*;
  30.  
  31. public class Command extends CommandBase {
  32.  
  33.     public String getCommandName() { // this is what they type (/autores)
  34.         return "autores";
  35.     }
  36.     public int getRequiredPermissionLevel() // just put this in idk
  37.     {
  38.         return 0;
  39.     }
  40.     public boolean canSenderUseCommand(ICommandSender sender) // also put this in
  41.     {
  42.         return true;
  43.     }
  44.     public String getCommandUsage(ICommandSender sender) { // command usage, say what the arguments are supposed to be like /autores <username>
  45.         // TODO Auto-generated method stub
  46.         return "/autores";
  47.     }
  48.     public void processCommand(ICommandSender sender, String[] args)
  49.     {
  50.         try
  51.         {
  52.             if (args.length == 1)
  53.             {
  54.                 // args[0] is the thing they typed after the command like if they typed /autotip stats args[0] would be "stats". Just detect if args[0] equals something like this:
  55. if (args[0].equalsIgnoreCase("stats") {
  56. System.out.println("stats");
  57. }
  58.        
  59.             }
  60.             else {
  61.                 Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: " + getCommandUsage(sender)));
  62.             }
  63.         }
  64.         catch (Throwable e)
  65.         {
  66.             e.printStackTrace();
  67.         }
  68.        
  69.     }
  70.     }
Add Comment
Please, Sign In to add comment