Replace OfflinePlayer#getLastPlayed
Currently OfflinePlayer#getLastPlayed could more accurately be described as "OfflinePlayer#getLastTimeTheirDataWasSaved". The API doc says it should return the last time the server "witnessed" the player, whilst also saying it should return the last time they logged in. The current implementation does neither. Given this interesting contradiction in the API documentation and the current defacto implementation, I've elected to deprecate (with no intent to remove) and replace it with two new methods, clearly named and documented as to their purpose.
This commit is contained in:
@@ -90,11 +90,12 @@
|
||||
this.server = server;
|
||||
this.registries = registryManager;
|
||||
this.maxPlayers = maxPlayers;
|
||||
@@ -148,27 +181,37 @@
|
||||
@@ -148,27 +181,38 @@
|
||||
}
|
||||
|
||||
public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie clientData) {
|
||||
+ player.isRealPlayer = true; // Paper
|
||||
+ player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed
|
||||
GameProfile gameprofile = player.getGameProfile();
|
||||
GameProfileCache usercache = this.server.getProfileCache();
|
||||
- Optional optional;
|
||||
@@ -133,7 +134,7 @@
|
||||
ServerLevel worldserver = this.server.getLevel(resourcekey);
|
||||
ServerLevel worldserver1;
|
||||
|
||||
@@ -182,10 +225,27 @@
|
||||
@@ -182,10 +226,27 @@
|
||||
player.setServerLevel(worldserver1);
|
||||
String s1 = connection.getLoggableAddress(this.server.logIPs());
|
||||
|
||||
@@ -163,7 +164,7 @@
|
||||
ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, clientData);
|
||||
|
||||
connection.setupInboundProtocol(GameProtocols.SERVERBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.server.registryAccess())), playerconnection);
|
||||
@@ -194,7 +254,9 @@
|
||||
@@ -194,7 +255,9 @@
|
||||
boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO);
|
||||
boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING);
|
||||
|
||||
@@ -174,7 +175,7 @@
|
||||
playerconnection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
|
||||
playerconnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities()));
|
||||
playerconnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected));
|
||||
@@ -213,8 +275,10 @@
|
||||
@@ -213,8 +276,10 @@
|
||||
} else {
|
||||
ichatmutablecomponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), s);
|
||||
}
|
||||
@@ -186,7 +187,7 @@
|
||||
playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
||||
ServerStatus serverping = this.server.getStatus();
|
||||
|
||||
@@ -222,17 +286,77 @@
|
||||
@@ -222,17 +287,77 @@
|
||||
player.sendServerStatus(serverping);
|
||||
}
|
||||
|
||||
@@ -268,7 +269,7 @@
|
||||
}
|
||||
|
||||
public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) {
|
||||
@@ -269,30 +393,31 @@
|
||||
@@ -269,30 +394,31 @@
|
||||
}
|
||||
|
||||
public void addWorldborderListener(ServerLevel world) {
|
||||
@@ -305,7 +306,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -319,14 +444,15 @@
|
||||
@@ -319,14 +445,15 @@
|
||||
}
|
||||
|
||||
protected void save(ServerPlayer player) {
|
||||
@@ -323,7 +324,7 @@
|
||||
|
||||
if (advancementdataplayer != null) {
|
||||
advancementdataplayer.save();
|
||||
@@ -334,95 +460,186 @@
|
||||
@@ -334,95 +461,186 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -548,7 +549,7 @@
|
||||
|
||||
if (entityplayer1 != null) {
|
||||
set.add(entityplayer1);
|
||||
@@ -431,30 +648,50 @@
|
||||
@@ -431,30 +649,50 @@
|
||||
Iterator iterator1 = set.iterator();
|
||||
|
||||
while (iterator1.hasNext()) {
|
||||
@@ -612,7 +613,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
String s = (String) iterator.next();
|
||||
@@ -462,41 +699,88 @@
|
||||
@@ -462,41 +700,88 @@
|
||||
entityplayer1.addTag(s);
|
||||
}
|
||||
|
||||
@@ -709,7 +710,7 @@
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
@@ -516,15 +800,32 @@
|
||||
@@ -516,15 +801,32 @@
|
||||
}
|
||||
|
||||
public void sendPlayerPermissionLevel(ServerPlayer player) {
|
||||
@@ -744,7 +745,7 @@
|
||||
this.sendAllPlayerInfoIn = 0;
|
||||
}
|
||||
|
||||
@@ -541,6 +842,25 @@
|
||||
@@ -541,6 +843,25 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -770,7 +771,7 @@
|
||||
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
|
||||
Iterator iterator = this.players.iterator();
|
||||
|
||||
@@ -554,7 +874,7 @@
|
||||
@@ -554,7 +875,7 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -779,7 +780,7 @@
|
||||
PlayerTeam scoreboardteam = source.getTeam();
|
||||
|
||||
if (scoreboardteam != null) {
|
||||
@@ -573,7 +893,7 @@
|
||||
@@ -573,7 +894,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -788,7 +789,7 @@
|
||||
PlayerTeam scoreboardteam = source.getTeam();
|
||||
|
||||
if (scoreboardteam == null) {
|
||||
@@ -619,7 +939,7 @@
|
||||
@@ -619,7 +940,7 @@
|
||||
}
|
||||
|
||||
public void deop(GameProfile profile) {
|
||||
@@ -797,7 +798,7 @@
|
||||
ServerPlayer entityplayer = this.getPlayer(profile.getId());
|
||||
|
||||
if (entityplayer != null) {
|
||||
@@ -643,36 +963,51 @@
|
||||
@@ -643,11 +964,30 @@
|
||||
player.connection.send(new ClientboundEntityEventPacket(player, b0));
|
||||
}
|
||||
|
||||
@@ -809,12 +810,12 @@
|
||||
- return !this.doWhiteList || this.ops.contains(profile) || this.whitelist.contains(profile);
|
||||
+ // Paper start - ProfileWhitelistVerifyEvent
|
||||
+ return this.isWhiteListed(profile, null);
|
||||
}
|
||||
+ }
|
||||
+ public boolean isWhiteListed(GameProfile gameprofile, @Nullable org.bukkit.event.player.PlayerLoginEvent loginEvent) {
|
||||
+ boolean isOp = this.ops.contains(gameprofile);
|
||||
+ boolean isWhitelisted = !this.doWhiteList || isOp || this.whitelist.contains(gameprofile);
|
||||
+ final com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent event;
|
||||
|
||||
+
|
||||
+ final net.kyori.adventure.text.Component configuredMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.whitelistMessage);
|
||||
+ event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile), this.doWhiteList, isWhitelisted, isOp, configuredMessage);
|
||||
+ event.callEvent();
|
||||
@@ -826,12 +827,11 @@
|
||||
+ }
|
||||
+ return true;
|
||||
+ // Paper end - ProfileWhitelistVerifyEvent
|
||||
+ }
|
||||
+
|
||||
public boolean isOp(GameProfile profile) {
|
||||
return this.ops.contains(profile) || this.server.isSingleplayerOwner(profile) && this.server.getWorldData().isAllowCommands() || this.allowCommandsForAllPlayers;
|
||||
}
|
||||
|
||||
public boolean isOp(GameProfile profile) {
|
||||
@@ -656,23 +996,19 @@
|
||||
|
||||
@Nullable
|
||||
public ServerPlayer getPlayerByName(String name) {
|
||||
- int i = this.players.size();
|
||||
@@ -862,7 +862,7 @@
|
||||
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
|
||||
double d4 = x - entityplayer.getX();
|
||||
double d5 = y - entityplayer.getY();
|
||||
@@ -687,10 +1022,12 @@
|
||||
@@ -687,10 +1023,12 @@
|
||||
}
|
||||
|
||||
public void saveAll() {
|
||||
@@ -875,7 +875,7 @@
|
||||
}
|
||||
|
||||
public UserWhiteList getWhiteList() {
|
||||
@@ -712,15 +1049,19 @@
|
||||
@@ -712,15 +1050,19 @@
|
||||
public void reloadWhiteList() {}
|
||||
|
||||
public void sendLevelInfo(ServerPlayer player, ServerLevel world) {
|
||||
@@ -899,7 +899,7 @@
|
||||
}
|
||||
|
||||
player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F));
|
||||
@@ -729,8 +1070,16 @@
|
||||
@@ -729,8 +1071,16 @@
|
||||
|
||||
public void sendAllPlayerInfo(ServerPlayer player) {
|
||||
player.inventoryMenu.sendAllDataToRemote();
|
||||
@@ -917,7 +917,7 @@
|
||||
}
|
||||
|
||||
public int getPlayerCount() {
|
||||
@@ -786,11 +1135,35 @@
|
||||
@@ -786,11 +1136,35 @@
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
@@ -955,7 +955,7 @@
|
||||
|
||||
public void broadcastSystemMessage(Component message, boolean overlay) {
|
||||
this.broadcastSystemMessage(message, (entityplayer) -> {
|
||||
@@ -819,24 +1192,43 @@
|
||||
@@ -819,24 +1193,43 @@
|
||||
}
|
||||
|
||||
public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound params) {
|
||||
@@ -1002,7 +1002,7 @@
|
||||
}
|
||||
|
||||
if (flag1 && sender != null) {
|
||||
@@ -845,20 +1237,27 @@
|
||||
@@ -845,20 +1238,27 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -1035,7 +1035,7 @@
|
||||
Path path = file2.toPath();
|
||||
|
||||
if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) {
|
||||
@@ -867,7 +1266,7 @@
|
||||
@@ -867,7 +1267,7 @@
|
||||
}
|
||||
|
||||
serverstatisticmanager = new ServerStatsCounter(this.server, file1);
|
||||
@@ -1044,7 +1044,7 @@
|
||||
}
|
||||
|
||||
return serverstatisticmanager;
|
||||
@@ -875,13 +1274,13 @@
|
||||
@@ -875,13 +1275,13 @@
|
||||
|
||||
public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) {
|
||||
UUID uuid = player.getUUID();
|
||||
@@ -1060,7 +1060,7 @@
|
||||
}
|
||||
|
||||
advancementdataplayer.setPlayer(player);
|
||||
@@ -932,15 +1331,28 @@
|
||||
@@ -932,15 +1332,28 @@
|
||||
}
|
||||
|
||||
public void reloadResources() {
|
||||
|
||||
Reference in New Issue
Block a user