mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-02 11:22:01 +01:00
SPIGOT-7589 Fix NullPointerException when bans expire
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
64cd2b148a
commit
95d69a6375
@ -1,11 +1,6 @@
|
|||||||
--- a/net/minecraft/server/players/JsonList.java
|
--- a/net/minecraft/server/players/JsonList.java
|
||||||
+++ b/net/minecraft/server/players/JsonList.java
|
+++ b/net/minecraft/server/players/JsonList.java
|
||||||
@@ -1,3 +1,4 @@
|
@@ -54,7 +54,7 @@
|
||||||
+// mc-dev import
|
|
||||||
package net.minecraft.server.players;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
@@ -54,7 +55,7 @@
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public V get(K k0) {
|
public V get(K k0) {
|
||||||
this.removeExpired();
|
this.removeExpired();
|
||||||
@ -14,6 +9,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void remove(K k0) {
|
public void remove(K k0) {
|
||||||
|
@@ -85,6 +85,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean contains(K k0) {
|
||||||
|
+ this.removeExpired(); // CraftBukkit - SPIGOT-7589: Consistently remove expired entries to mirror .get(...)
|
||||||
|
return this.map.containsKey(this.getKeyForUser(k0));
|
||||||
|
}
|
||||||
|
|
||||||
@@ -93,7 +94,7 @@
|
@@ -93,7 +94,7 @@
|
||||||
Iterator iterator = this.map.values().iterator();
|
Iterator iterator = this.map.values().iterator();
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -411,18 +526,66 @@
|
@@ -411,17 +526,65 @@
|
||||||
|
|
||||||
if (entityplayer1 == entityplayer) {
|
if (entityplayer1 == entityplayer) {
|
||||||
this.playersByUUID.remove(uuid);
|
this.playersByUUID.remove(uuid);
|
||||||
@ -363,7 +363,6 @@
|
|||||||
+ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile) {
|
+ public EntityPlayer canPlayerLogin(LoginListener loginlistener, GameProfile gameprofile) {
|
||||||
IChatMutableComponent ichatmutablecomponent;
|
IChatMutableComponent ichatmutablecomponent;
|
||||||
|
|
||||||
- if (this.bans.isBanned(gameprofile)) {
|
|
||||||
+ // Moved from processLogin
|
+ // Moved from processLogin
|
||||||
+ UUID uuid = gameprofile.getId();
|
+ UUID uuid = gameprofile.getId();
|
||||||
+ List<EntityPlayer> list = Lists.newArrayList();
|
+ List<EntityPlayer> list = Lists.newArrayList();
|
||||||
@ -394,11 +393,10 @@
|
|||||||
+ Player player = entity.getBukkitEntity();
|
+ Player player = entity.getBukkitEntity();
|
||||||
+ PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
|
+ PlayerLoginEvent event = new PlayerLoginEvent(player, loginlistener.connection.hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
|
||||||
+
|
+
|
||||||
+ if (getBans().isBanned(gameprofile) && !getBans().get(gameprofile).hasExpired()) {
|
if (this.bans.isBanned(gameprofile)) {
|
||||||
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
|
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.bans.get(gameprofile);
|
||||||
|
|
||||||
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned.reason", gameprofilebanentry.getReason());
|
@@ -430,9 +593,11 @@
|
||||||
@@ -430,10 +593,12 @@
|
|
||||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
|
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned.expiration", PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,13 +405,11 @@
|
|||||||
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent));
|
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(ichatmutablecomponent));
|
||||||
} else if (!this.isWhiteListed(gameprofile)) {
|
} else if (!this.isWhiteListed(gameprofile)) {
|
||||||
- return IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
|
- return IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
|
||||||
- } else if (this.ipBans.isBanned(socketaddress)) {
|
|
||||||
+ ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
|
+ ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.not_whitelisted");
|
||||||
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(ichatmutablecomponent));
|
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(ichatmutablecomponent));
|
||||||
+ } else if (getIpBans().isBanned(socketaddress) && !getIpBans().get(socketaddress).hasExpired()) {
|
} else if (this.ipBans.isBanned(socketaddress)) {
|
||||||
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
|
IpBanEntry ipbanentry = this.ipBans.get(socketaddress);
|
||||||
|
|
||||||
ichatmutablecomponent = IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.reason", ipbanentry.getReason());
|
|
||||||
@@ -441,17 +606,32 @@
|
@@ -441,17 +606,32 @@
|
||||||
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
|
ichatmutablecomponent.append((IChatBaseComponent) IChatBaseComponent.translatable("multiplayer.disconnect.banned_ip.expiration", PlayerList.BAN_DATE_FORMAT.format(ipbanentry.getExpires())));
|
||||||
}
|
}
|
||||||
@ -604,7 +600,7 @@
|
|||||||
+ for (MobEffect mobEffect : entityplayer.getActiveEffects()) {
|
+ for (MobEffect mobEffect : entityplayer.getActiveEffects()) {
|
||||||
+ entityplayer.connection.send(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect));
|
+ entityplayer.connection.send(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect));
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ // Fire advancement trigger
|
+ // Fire advancement trigger
|
||||||
+ entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle());
|
+ entityplayer.triggerDimensionChangeTriggers(((CraftWorld) fromWorld).getHandle());
|
||||||
+
|
+
|
||||||
@ -613,7 +609,7 @@
|
|||||||
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld);
|
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld);
|
||||||
+ server.server.getPluginManager().callEvent(event);
|
+ server.server.getPluginManager().callEvent(event);
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ // Save player file again if they were disconnected
|
+ // Save player file again if they were disconnected
|
||||||
+ if (entityplayer.connection.isDisconnected()) {
|
+ if (entityplayer.connection.isDisconnected()) {
|
||||||
+ this.save(entityplayer);
|
+ this.save(entityplayer);
|
||||||
|
Loading…
Reference in New Issue
Block a user