Skip to content

Add API for operator permission levels and bypassesPlayerLimit - #14193

Open
Mickey42302 wants to merge 10 commits into
PaperMC:mainfrom
Mickey42302:operator-api
Open

Mickey42302 wants to merge 10 commits into
PaperMC:mainfrom
Mickey42302:operator-api

Conversation

@Mickey42302

Copy link
Copy Markdown
Contributor

In light of the response I received to my pull request which adds the more advanced operator management commands, I've been working on converting the code to the plugin API.

This is what I have so far. Is this version of the code what Paper is looking for, or are more changes needed?

I apologise in advance if there are any errors/oversights. I am very new at contributing to the API instead of the server. I've also been having seizures again.

@Mickey42302
Mickey42302 requested a review from a team as a code owner August 16, 2026 23:14
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Aug 16, 2026

@Warriorrrr Warriorrrr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your branch is currently also failing to build due to missing imports

*
* @return the permission level, or 0 if the player is not an operator or entry is missing
*/
int getOpLevel();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The @Range annotation can be used here to further indicate it only returning 0 through 4

* @param level the level to set (must be between 0 and 4)
* @throws IllegalArgumentException if level is outside the 0–4 range
*/
void setOpLevel(int level);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here regarding the range annotation

@Override
public boolean bypassesPlayerLimit() {
ServerOpList opList = MinecraftServer.getServer().getPlayerList().getOps();
NameAndId nameAndId = new NameAndId(this.getUniqueId(), this.getName() != null ? this.getName() : "");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All spots in this PR that create a new NameAndId can be by the nameAndId field (see isOp, setOp). Sometimes the nameAndId in the field does get created with an empty name, but that doesn't seem like a problem here.

Comment thread paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java Outdated
Comment on lines +643 to +655
PermissionLevel permLevel = PermissionLevel.byId(level);
ServerOpListEntry newEntry = new ServerOpListEntry(
nameAndId,
LevelBasedPermissionSet.forLevel(permLevel),
bypassesLimit
);

opList.add(newEntry);

ServerPlayer serverPlayer = server.getPlayerList().getPlayer(this.getUniqueId());
if (serverPlayer != null) {
server.getPlayerList().sendPlayerPermissionLevel(serverPlayer);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be replaced by PlayerList#op

@Mickey42302

Copy link
Copy Markdown
Contributor Author

Is this better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Changes required

Development

Successfully merging this pull request may close these issues.

2 participants