Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commands that the player is not supposed to have access to show up #815

Closed
lightyisreal opened this issue Oct 8, 2023 · 2 comments · Fixed by #816
Closed

Commands that the player is not supposed to have access to show up #815

lightyisreal opened this issue Oct 8, 2023 · 2 comments · Fixed by #816

Comments

@lightyisreal
Copy link
Contributor

Image showing the issue
This issue started after dragonfly got updated to support version 1.20.30. I don't know if this is a gophertunnel specific issue, but I don't think it is. Commands that have an additional / or commands like mute, op are not supposed to show up to the normal player without operator privileges.

@Flonja
Copy link
Contributor

Flonja commented Oct 8, 2023

Do you have a simple code example that reproduces this problem?

@lightyisreal
Copy link
Contributor Author

Do you have a simple code example that reproduces this problem?

// Ban is a command that revokes a player's access to the server.
type Ban struct {
	Target []cmd.Target              `cmd:"target"`
	Reason cmd.Optional[cmd.Varargs] `cmd:"reason"`
}

func (Ban) Allow(src cmd.Source) bool {
	/*
		if p, ok := src.(*player.Player); ok {
				p, ok := user.Lookup(p)
				if ok {
					return p.Operator()
				}
			} else {
				_, isConsole := src.(*console.Source)
				return isConsole
			}
			return false
	*/
	return elevatedAllower(src)
}

func (b Ban) Run(src cmd.Source, output *cmd.Output) {
	for _, t := range b.Target {
		if p, ok := t.(*player.Player); ok {
			u, ok := user.Lookup(p)
			if ok {
				reason, ok := b.Reason.Load()
				if ok || string(reason) != "" {
					u.BanReason(string(reason))
				} else {
					u.Ban()
				}
				output.Printf("Banned %v from the server.", p.Name())
			}
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants