Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //main class
- @EventHandler
- public void init(FMLInitializationEvent event)
- {
- FMLCommonHandler.instance().bus().register(this);
- ClientCommandHandler.instance.registerCommand(new Command());
- }
- //command shit
- package resident;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Set;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.entity.EntityPlayerSP;
- import net.minecraft.command.CommandBase;
- import net.minecraft.command.CommandException;
- import net.minecraft.command.ICommand;
- import net.minecraft.command.ICommandSender;
- import net.minecraft.entity.player.EntityPlayerMP;
- import net.minecraft.event.ClickEvent;
- import net.minecraft.server.MinecraftServer;
- import net.minecraft.server.management.ServerConfigurationManager;
- import net.minecraft.util.BlockPos;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraftforge.common.config.*;
- public class Command extends CommandBase {
- public String getCommandName() { // this is what they type (/autores)
- return "autores";
- }
- public int getRequiredPermissionLevel() // just put this in idk
- {
- return 0;
- }
- public boolean canSenderUseCommand(ICommandSender sender) // also put this in
- {
- return true;
- }
- public String getCommandUsage(ICommandSender sender) { // command usage, say what the arguments are supposed to be like /autores <username>
- // TODO Auto-generated method stub
- return "/autores";
- }
- public void processCommand(ICommandSender sender, String[] args)
- {
- try
- {
- if (args.length == 1)
- {
- // 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:
- if (args[0].equalsIgnoreCase("stats") {
- System.out.println("stats");
- }
- }
- else {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Usage: " + getCommandUsage(sender)));
- }
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment