Posted October 7, 20187 yr So I'm working on a mod and I made a command. When I try and execute the command, it says I don't have permission. Here's the class: package com.reprevise.enhanmod.cmds; import java.util.List; import com.reprevise.enhanmod.chat.PluginAnnouncer; 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.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraftforge.client.IClientCommand; public class PunishCMD extends CommandBase { @Override public String getName() { return "punish"; } @Override public String getUsage(ICommandSender sender) { return "/punish <user>"; } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) sender; PluginAnnouncer.sendMessageToMod("Opening GUI..."); } } @Override public boolean checkPermission(MinecraftServer server, ICommandSender sender) { return false; } @Override public boolean isUsernameIndex(String[] args, int index) { return false; } }
October 7, 20187 yr Look at the other methods in the class you're extending (CommandBase). There are methods there regarding permissions you need to override. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
October 7, 20187 yr Author package com.reprevise.enhanmod.cmds; import java.util.List; import com.reprevise.enhanmod.chat.PluginAnnouncer; 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.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraftforge.client.IClientCommand; public class PunishCMD extends CommandBase { @Override public String getName() { return "punish"; } @Override public String getUsage(ICommandSender sender) { return "/punish <user>"; } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) sender; PluginAnnouncer.sendMessageToMod("Opening GUI..."); } } @Override public boolean checkPermission(MinecraftServer server, ICommandSender sender) { return false; } @Override public int getRequiredPermissionLevel() { return 0; } @Override public boolean isUsernameIndex(String[] args, int index) { return false; } } This is my new class, and the only thing I changed was overriding the getRequiredPermissionLevel method which didn't help. I went through the class and there were no other methods that dealt with permissions.
October 7, 20187 yr Author Alright, I fixed the issue. Here's my final class. package com.reprevise.enhanmod.cmds; import com.reprevise.enhanmod.chat.PluginAnnouncer; import net.minecraft.command.CommandBase; import net.minecraft.command.CommandException; import net.minecraft.command.ICommandSender; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; public class PunishThing extends CommandBase { @Override public String getName() { // TODO Auto-generated method stub return "punish"; } @Override public String getUsage(ICommandSender sender) { // TODO Auto-generated method stub return "/punish <user>"; } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) sender; PluginAnnouncer.sendMessageToMod("Opening GUI..."); } } @Override public int getRequiredPermissionLevel() { // TODO Auto-generated method stub return super.getRequiredPermissionLevel(); } @Override public boolean checkPermission(MinecraftServer server, ICommandSender sender) { // TODO Auto-generated method stub return super.checkPermission(server, sender); } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.