Jump to content

[1.7.10] How to make commands registered in a mod accessible to regular players?


凡越 孟

Recommended Posts

I've tried overriding the getRequiredPermissionLevel() method to return 0, but only operators are still able to use this command.

The code is as follows:

public class CommandTest extends CommandBase {

public String getCommandName() { return "test"; }

public String getCommandUsage(ICommandSender p_71518_1_) { return null; }

 public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { p_71515_1_.addChatMessage(new ChatComponentText("abc")); }

 public int getRequiredPermissionLevel(){ return 0; } }

 

public class start {

 public static final String MODID = "register"; public static final String VERSION = "1.0";

@EventHandler public void init(FMLInitializationEvent event) { }

@EventHandler public void serverStarting(FMLServerStartingEvent event) { event.registerServerCommand(new CommandTest()); } }

 

thanks to everybody

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.



×
×
  • Create New...

Important Information

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