3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00
Paper/nms-patches/ExpiringMap.patch

52 Zeilen
1.6 KiB
Diff

2018-11-04 01:40:15 +01:00
--- a/net/minecraft/server/ExpiringMap.java
+++ b/net/minecraft/server/ExpiringMap.java
@@ -4,8 +4,10 @@
import it.unimi.dsi.fastutil.longs.Long2LongMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2LongMap.Entry;
+import it.unimi.dsi.fastutil.objects.ObjectCollection;
import it.unimi.dsi.fastutil.objects.ObjectIterator;
import java.util.Map;
+import java.util.function.LongFunction;
public class ExpiringMap<T> extends Long2ObjectOpenHashMap<T> {
2018-12-25 22:00:00 +01:00
@@ -21,10 +23,17 @@
2018-12-13 01:00:00 +01:00
long j = SystemUtils.getMonotonicMillis();
2018-11-04 01:40:15 +01:00
this.b.put(i, j);
+ // CraftBukkit start
2018-12-25 22:00:00 +01:00
+ cleanup();
2018-11-04 01:40:15 +01:00
+ }
+
+ public void cleanup() {
2018-12-13 01:00:00 +01:00
+ long j = SystemUtils.getMonotonicMillis();
2018-12-25 22:00:00 +01:00
+ // CraftBukkit end
ObjectIterator objectiterator = this.b.long2LongEntrySet().iterator();
2018-11-04 01:40:15 +01:00
while (objectiterator.hasNext()) {
- Entry entry = (Entry) objectiterator.next();
+ Long2LongMap.Entry entry = (Long2LongMap.Entry) objectiterator.next(); // CraftBukkit - decompile error
2018-12-25 22:00:00 +01:00
T t0 = super.get(entry.getLongKey());
2018-11-04 01:40:15 +01:00
if (j - entry.getLongValue() <= (long) this.a) {
@@ -69,4 +78,18 @@
public T remove(Object object) {
throw new RuntimeException("Not implemented");
}
+
+ // CraftBukkit start
+ @Override
+ public T computeIfAbsent(long l, LongFunction<? extends T> lf) {
2018-12-13 01:00:00 +01:00
+ this.b.put(l, SystemUtils.getMonotonicMillis());
2018-11-04 01:40:15 +01:00
+ return super.computeIfAbsent(l, lf);
+ }
+
+ @Override
+ public ObjectCollection<T> values() {
+ cleanup();
+ return super.values();
+ }
2018-12-25 22:00:00 +01:00
+ // CraftBukkit end
2018-11-04 01:40:15 +01:00
}