even even even more work

This commit is contained in:
MiniDigger | Martin
2020-06-25 16:09:55 +02:00
parent 4aa7955818
commit e943ece469
125 changed files with 857 additions and 3512 deletions

View File

@@ -28,24 +28,47 @@ diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/ne
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/JsonList.java
+++ b/src/main/java/net/minecraft/server/JsonList.java
@@ -0,0 +0,0 @@ public class JsonList<K, V extends JsonListEntry<K>> {
@@ -0,0 +0,0 @@ import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.ParameterizedType; // Paper
+import java.lang.reflect.Type; // Paper
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Iterator;
@@ -0,0 +0,0 @@ public abstract class JsonList<K, V extends JsonListEntry<K>> {
protected static final Logger LOGGER = LogManager.getLogger();
protected final Gson b;
private static final Gson b = (new GsonBuilder()).setPrettyPrinting().create();
private final File c;
- private final Map<String, V> d = Maps.newHashMap();
+ // Paper - replace HashMap is ConcurrentHashMap
+ private final Map<String, V> d = Maps.newConcurrentMap(); private final Map<String, V> getBackingMap() { return this.d; } // Paper - OBFHELPER
private boolean e = true;
private static final ParameterizedType f = new ParameterizedType() {
public Type[] getActualTypeArguments() {
@@ -0,0 +0,0 @@ public class JsonList<K, V extends JsonListEntry<K>> {
+ private boolean e = true;
+ private static final ParameterizedType f = new ParameterizedType() {
+ public Type[] getActualTypeArguments() {
+ return new Type[]{JsonListEntry.class};
+ }
+
+ public Type getRawType() {
+ return List.class;
+ }
+
+ public Type getOwnerType() {
+ return null;
+ }
+ };
public JsonList(File file) {
this.c = file;
@@ -0,0 +0,0 @@ public abstract class JsonList<K, V extends JsonListEntry<K>> {
@Nullable
public V get(K k0) {
- this.h();
- this.g();
- return (V) this.d.get(this.a(k0)); // CraftBukkit - fix decompile error
+ // Paper start
+ // this.h();
+ // this.g();
+ // return (V) this.d.get(this.a(k0)); // CraftBukkit - fix decompile error
+ return (V) this.getBackingMap().computeIfPresent(this.getMappingKey(k0), (k, v) -> {
+ return v.hasExpired() ? null : v;
@@ -54,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
public void remove(K k0) {
@@ -0,0 +0,0 @@ public class JsonList<K, V extends JsonListEntry<K>> {
@@ -0,0 +0,0 @@ public abstract class JsonList<K, V extends JsonListEntry<K>> {
// CraftBukkit end
public boolean isEmpty() {
@@ -67,18 +90,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected String a(K k0) {
return k0.toString();
}
@@ -0,0 +0,0 @@ public class JsonList<K, V extends JsonListEntry<K>> {
@@ -0,0 +0,0 @@ public abstract class JsonList<K, V extends JsonListEntry<K>> {
return this.d.containsKey(this.a(k0));
}
+ private void removeStaleEntries() { h(); } // Paper - OBFHELPER
private void h() {
+ private void removeStaleEntries() { g(); } // Paper - OBFHELPER
private void g() {
- List<K> list = Lists.newArrayList();
+ /*List<K> list = Lists.newArrayList();
Iterator iterator = this.d.values().iterator();
while (iterator.hasNext()) {
@@ -0,0 +0,0 @@ public class JsonList<K, V extends JsonListEntry<K>> {
@@ -0,0 +0,0 @@ public abstract class JsonList<K, V extends JsonListEntry<K>> {
K k0 = (K) iterator.next(); // CraftBukkit - decompile error
this.d.remove(this.a(k0));
@@ -89,22 +112,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
}
protected JsonListEntry<K> a(JsonObject jsonobject) {
@@ -0,0 +0,0 @@ public class JsonList<K, V extends JsonListEntry<K>> {
protected abstract JsonListEntry<K> a(JsonObject jsonobject);
@@ -0,0 +0,0 @@ public abstract class JsonList<K, V extends JsonListEntry<K>> {
}
public void save() throws IOException {
+ this.removeStaleEntries(); // Paper - remove expired values before saving
Collection<V> collection = this.d.values();
String s = this.b.toJson(collection);
BufferedWriter bufferedwriter = null;
JsonArray jsonarray = new JsonArray();
this.d.values().stream().map((jsonlistentry) -> {
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -0,0 +0,0 @@ public abstract class PlayerList {
} else if (!this.isWhitelisted(gameprofile, event)) { // Paper
chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted", new Object[0]);
} else if (!this.isWhitelisted(gameprofile)) {
chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted");
//event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot // Paper - moved to isWhitelisted
- } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) {
+ } else if (getIPBans().isBanned(socketaddress) && getIPBans().get(socketaddress) != null && !getIPBans().get(socketaddress).hasExpired()) { // Paper - fix NPE with temp ip bans