Jump to content

No permission for command


BenPlaysMC

Recommended Posts

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;
	}

}

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);
	}

}

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.