Advertisement
Guest User

Untitled

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