Jump to content

[1.7.10] [Solved] How to check if Player is OP?


jamiemac262

Recommended Posts

I have a few commands on my mod that i don't want regular players using. Until i work out how to set permissions (or build a permission manager if i have to) i want to restrict these commands to OP, while letting players use other commands.

 

it's worth noting that i have one command with several functions based on the first argument (/wallet set..... /wallet pay... etc)

 

so at the start of each command that i want to restrict. i need to check if the player is OP. Can someone tell me how to do this please?

 

 

don't you just hate being a Nooby modder? At the stage where tutorials aren't spoon feeding you through to releasing a mod, leaving you to ask many, many questions that seem to have simple answers?

Link to comment
Share on other sites

MinecraftServer.getServer().getConfigurationManager().getOppedPlayers().getGameProfileFromName(player.getName()) != null

 

Alos this:

MinecraftServer.getServer().isSinglePlayer()

 

For SP you will want to give full perm, ay?

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

MinecraftServer.getServer().getConfigurationManager().getOppedPlayers().getGameProfileFromName(player.getName()) != null

 

Alos this:

MinecraftServer.getServer().isSinglePlayer()

 

For SP you will want to give full perm, ay?

 

"getOppedPlayers()" apparently isn't a method 0.o thoughts?

Link to comment
Share on other sites

FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().canSendCommands((<ENTITYPLAYERMP>).getGameProfile())

 

That should work on servers and in the case of single player, respect if cheats are enabled.

This is the same on 1.7.10 and 1.8

 

"canSendCommands()" apaprently doesn't exist either :/

Link to comment
Share on other sites

Update your mappings then, in your build.gradle put

mappings = "stable_12"

in the

minecraft {
  // Stuff
}

section.

 

Then re-setupDecompWorkspace

 

okay, i'll do this now. could you explain what this does? (so i know when it might be necessary for future ref.)

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.