DedicatedPlayerList .java

net.minecraft.server.dedicated.DedicatedPlayerList (class, 114 lines): members: reloadWhiteList, isWhiteListed, canBypassPlayerLimit, getServer, LOGGER.

net.minecraft.server.dedicatedclass114 linesserverextends PlayerList2.7 KB

API Surface (4)

void reloadWhiteList()
boolean isWhiteListed(final NameAndId nameAndId)
DedicatedServer getServer()
boolean canBypassPlayerLimit(final NameAndId nameAndId)

Fields & Constants (1)

LOGGER

String literals (8)

"Failed to save ip banlist: "
"Failed to save user banlist: "
"Failed to load ip banlist: "
"Failed to load user banlist: "
"Failed to load operators list: "
"Failed to save operators list: "
"Failed to load white-list: "
"Failed to save white-list: "

Code Graph: Dependencies (6)

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

Full Source

DedicatedPlayerList.java114 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.server.dedicated;
2
3
import com.mojang.logging.LogUtils;
4
import java.io.IOException;
5
import net.minecraft.core.LayeredRegistryAccess;
6
import net.minecraft.server.RegistryLayer;
7
import net.minecraft.server.players.NameAndId;
8
import net.minecraft.server.players.PlayerList;
9
import net.minecraft.world.level.storage.PlayerDataStorage;
10
import org.slf4j.Logger;
11
12
public class DedicatedPlayerList extends PlayerList {
13
	private static final Logger LOGGER = LogUtils.getLogger();
14
15
	public DedicatedPlayerList(final DedicatedServer server, final LayeredRegistryAccess<RegistryLayer> registries, final PlayerDataStorage playerDataStorage) {
16
		super(server, registries, playerDataStorage, server.notificationManager());
17
		this.setViewDistance(server.viewDistance());
18
		this.setSimulationDistance(server.simulationDistance());
19
		this.loadUserBanList();
20
		this.saveUserBanList();
21
		this.loadIpBanList();
22
		this.saveIpBanList();
23
		this.loadOps();
24
		this.loadWhiteList();
25
		this.saveOps();
26
		if (!this.getWhiteList().getFile().exists()) {
27
			this.saveWhiteList();
28
		}
29
	}
30
31
	@Override
32
	public void reloadWhiteList() {
33
		this.loadWhiteList();
34
	}
35
36
	private void saveIpBanList() {
37
		try {
38
			this.getIpBans().save();
39
		} catch (IOException e) {
40
			LOGGER.warn("Failed to save ip banlist: ", e);
41
		}
42
	}
43
44
	private void saveUserBanList() {
45
		try {
46
			this.getBans().save();
47
		} catch (IOException e) {
48
			LOGGER.warn("Failed to save user banlist: ", e);
49
		}
50
	}
51
52
	private void loadIpBanList() {
53
		try {
54
			this.getIpBans().load();
55
		} catch (IOException e) {
56
			LOGGER.warn("Failed to load ip banlist: ", e);
57
		}
58
	}
59
60
	private void loadUserBanList() {
61
		try {
62
			this.getBans().load();
63
		} catch (IOException e) {
64
			LOGGER.warn("Failed to load user banlist: ", e);
65
		}
66
	}
67
68
	private void loadOps() {
69
		try {
70
			this.getOps().load();
71
		} catch (Exception e) {
72
			LOGGER.warn("Failed to load operators list: ", e);
73
		}
74
	}
75
76
	private void saveOps() {
77
		try {
78
			this.getOps().save();
79
		} catch (Exception e) {
80
			LOGGER.warn("Failed to save operators list: ", e);
81
		}
82
	}
83
84
	private void loadWhiteList() {
85
		try {
86
			this.getWhiteList().load();
87
		} catch (Exception e) {
88
			LOGGER.warn("Failed to load white-list: ", e);
89
		}
90
	}
91
92
	private void saveWhiteList() {
93
		try {
94
			this.getWhiteList().save();
95
		} catch (Exception e) {
96
			LOGGER.warn("Failed to save white-list: ", e);
97
		}
98
	}
99
100
	@Override
101
	public boolean isWhiteListed(final NameAndId nameAndId) {
102
		return !this.isUsingWhitelist() || this.isOp(nameAndId) || this.getWhiteList().isWhiteListed(nameAndId);
103
	}
104
105
	public DedicatedServer getServer() {
106
		return (DedicatedServer)super.getServer();
107
	}
108
109
	@Override
110
	public boolean canBypassPlayerLimit(final NameAndId nameAndId) {
111
		return this.getOps().canBypassPlayerLimit(nameAndId);
112
	}
113
}
114

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