Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

}

 

  • 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.

  • 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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.