ServerOpList .java

net.minecraft.server.players.ServerOpList (class, 68 lines): members: canBypassPlayerLimit, getKeyForUser, getUserList, createEntry, clear, remove, add.

net.minecraft.server.playersclass68 linesserverextends StoredUserList<NameAndId1.6 KB

API Surface (7)

StoredUserEntry<NameAndId> createEntry(final JsonObject object)
String[] getUserList()
boolean add(final ServerOpListEntry infos)
boolean remove(final NameAndId user)
void clear()
boolean canBypassPlayerLimit(final NameAndId user)
String getKeyForUser(final NameAndId user)

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ServerOpList.java68 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.players;
2
3
import com.google.gson.JsonObject;
4
import java.io.File;
5
import java.util.Objects;
6
import net.minecraft.server.notifications.NotificationService;
7
8
public class ServerOpList extends StoredUserList<NameAndId, ServerOpListEntry> {
9
	public ServerOpList(final File file, final NotificationService notificationService) {
10
		super(file, notificationService);
11
	}
12
13
	@Override
14
	protected StoredUserEntry<NameAndId> createEntry(final JsonObject object) {
15
		return new ServerOpListEntry(object);
16
	}
17
18
	@Override
19
	public String[] getUserList() {
20
		return this.getEntries().stream().map(StoredUserEntry::getUser).filter(Objects::nonNull).map(NameAndId::name).toArray(String[]::new);
21
	}
22
23
	public boolean add(final ServerOpListEntry infos) {
24
		if (super.add(infos)) {
25
			if (infos.getUser() != null) {
26
				this.notificationService.playerOped(infos);
27
			}
28
29
			return true;
30
		} else {
31
			return false;
32
		}
33
	}
34
35
	public boolean remove(final NameAndId user) {
36
		ServerOpListEntry entry = this.get(user);
37
		if (super.remove(user)) {
38
			if (entry != null) {
39
				this.notificationService.playerDeoped(entry);
40
			}
41
42
			return true;
43
		} else {
44
			return false;
45
		}
46
	}
47
48
	@Override
49
	public void clear() {
50
		for (ServerOpListEntry user : this.getEntries()) {
51
			if (user.getUser() != null) {
52
				this.notificationService.playerDeoped(user);
53
			}
54
		}
55
56
		super.clear();
57
	}
58
59
	public boolean canBypassPlayerLimit(final NameAndId user) {
60
		ServerOpListEntry entry = this.get(user);
61
		return entry != null ? entry.getBypassesPlayerLimit() : false;
62
	}
63
64
	protected String getKeyForUser(final NameAndId user) {
65
		return user.id().toString();
66
	}
67
}
68

Decompiled Minecraft 26.3 source of ServerOpList (net/minecraft/server/players/ServerOpList.java) with Mojang official mappings, stored verbatim on the site.