mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 20:07:41 +01:00
Update from upstream SpigotMC
Upstream Merge (Bukkit + CraftBukkit) SpigotMC/Spigot@da20125dab Plug WorldMap Memory Leak SpigotMC/Spigot@da20125dab
This commit is contained in:
parent
367c4b9ec2
commit
c42e01a8b4
2
Bukkit
2
Bukkit
@ -1 +1 @@
|
||||
Subproject commit d3ab9468c3aed2a06c280bf6c9cea5108c736dcc
|
||||
Subproject commit 8d5b4c1e9acc499377da0d807e7ca2245d5c3bdf
|
@ -1 +1 @@
|
||||
Subproject commit a04b586418538c428d0e464df3e2a1f3b06889fd
|
||||
Subproject commit 0b2ed13a5d24fd9620f8b03c1bf888e3eccd715e
|
@ -2558,6 +2558,197 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ this.a((PacketPlayOutListener) packetlistener);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/PersistentCollection.java b/src/main/java/net/minecraft/server/PersistentCollection.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/PersistentCollection.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package net.minecraft.server;
|
||||
+
|
||||
+import java.io.DataInputStream;
|
||||
+import java.io.DataOutput;
|
||||
+import java.io.DataOutputStream;
|
||||
+import java.io.File;
|
||||
+import java.io.FileInputStream;
|
||||
+import java.io.FileOutputStream;
|
||||
+import java.io.InputStream;
|
||||
+import java.io.OutputStream;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Iterator;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+
|
||||
+public class PersistentCollection {
|
||||
+
|
||||
+ private IDataManager a;
|
||||
+ private Map b = new HashMap();
|
||||
+ private List c = new ArrayList();
|
||||
+ private Map d = new HashMap();
|
||||
+
|
||||
+ public PersistentCollection(IDataManager idatamanager) {
|
||||
+ this.a = idatamanager;
|
||||
+ this.b();
|
||||
+ }
|
||||
+
|
||||
+ public PersistentBase get(Class oclass, String s) {
|
||||
+ PersistentBase persistentbase = (PersistentBase) this.b.get(s);
|
||||
+
|
||||
+ if (persistentbase != null) {
|
||||
+ return persistentbase;
|
||||
+ } else {
|
||||
+ if (this.a != null) {
|
||||
+ try {
|
||||
+ File file1 = this.a.getDataFile(s);
|
||||
+
|
||||
+ if (file1 != null && file1.exists()) {
|
||||
+ try {
|
||||
+ persistentbase = (PersistentBase) oclass.getConstructor(new Class[] { String.class}).newInstance(new Object[] { s});
|
||||
+ } catch (Exception exception) {
|
||||
+ throw new RuntimeException("Failed to instantiate " + oclass.toString(), exception);
|
||||
+ }
|
||||
+
|
||||
+ FileInputStream fileinputstream = new FileInputStream(file1);
|
||||
+ NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a((InputStream) fileinputstream);
|
||||
+
|
||||
+ fileinputstream.close();
|
||||
+ persistentbase.a(nbttagcompound.getCompound("data"));
|
||||
+ }
|
||||
+ } catch (Exception exception1) {
|
||||
+ exception1.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (persistentbase != null) {
|
||||
+ this.b.put(s, persistentbase);
|
||||
+ this.c.add(persistentbase);
|
||||
+ }
|
||||
+
|
||||
+ return persistentbase;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void a(String s, PersistentBase persistentbase) {
|
||||
+ if (persistentbase == null) {
|
||||
+ throw new RuntimeException("Can\'t set null data");
|
||||
+ } else {
|
||||
+ if (this.b.containsKey(s)) {
|
||||
+ this.c.remove(this.b.remove(s));
|
||||
+ }
|
||||
+
|
||||
+ this.b.put(s, persistentbase);
|
||||
+ this.c.add(persistentbase);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void a() {
|
||||
+ for (int i = 0; i < this.c.size(); ++i) {
|
||||
+ PersistentBase persistentbase = (PersistentBase) this.c.get(i);
|
||||
+
|
||||
+ if (persistentbase.d()) {
|
||||
+ this.a(persistentbase);
|
||||
+ persistentbase.a(false);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void a(PersistentBase persistentbase) {
|
||||
+ if (this.a != null) {
|
||||
+ try {
|
||||
+ File file1 = this.a.getDataFile(persistentbase.id);
|
||||
+
|
||||
+ if (file1 != null) {
|
||||
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
+
|
||||
+ persistentbase.b(nbttagcompound);
|
||||
+ NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
+
|
||||
+ nbttagcompound1.set("data", nbttagcompound);
|
||||
+ FileOutputStream fileoutputstream = new FileOutputStream(file1);
|
||||
+
|
||||
+ NBTCompressedStreamTools.a(nbttagcompound1, (OutputStream) fileoutputstream);
|
||||
+ fileoutputstream.close();
|
||||
+ }
|
||||
+ } catch (Exception exception) {
|
||||
+ exception.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void b() {
|
||||
+ try {
|
||||
+ this.d.clear();
|
||||
+ if (this.a == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ File file1 = this.a.getDataFile("idcounts");
|
||||
+
|
||||
+ if (file1 != null && file1.exists()) {
|
||||
+ DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
|
||||
+ NBTTagCompound nbttagcompound = NBTCompressedStreamTools.a(datainputstream);
|
||||
+
|
||||
+ datainputstream.close();
|
||||
+ Iterator iterator = nbttagcompound.c().iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ String s = (String) iterator.next();
|
||||
+ NBTBase nbtbase = nbttagcompound.get(s);
|
||||
+
|
||||
+ if (nbtbase instanceof NBTTagShort) {
|
||||
+ NBTTagShort nbttagshort = (NBTTagShort) nbtbase;
|
||||
+ short short1 = nbttagshort.e();
|
||||
+
|
||||
+ this.d.put(s, Short.valueOf(short1));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (Exception exception) {
|
||||
+ exception.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public int a(String s) {
|
||||
+ Short oshort = (Short) this.d.get(s);
|
||||
+
|
||||
+ if (oshort == null) {
|
||||
+ oshort = Short.valueOf((short) 0);
|
||||
+ } else {
|
||||
+ oshort = Short.valueOf((short) (oshort.shortValue() + 1));
|
||||
+ }
|
||||
+
|
||||
+ this.d.put(s, oshort);
|
||||
+ if (this.a == null) {
|
||||
+ return oshort.shortValue();
|
||||
+ } else {
|
||||
+ try {
|
||||
+ File file1 = this.a.getDataFile("idcounts");
|
||||
+
|
||||
+ if (file1 != null) {
|
||||
+ NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
+ Iterator iterator = this.d.keySet().iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ String s1 = (String) iterator.next();
|
||||
+ short short1 = ((Short) this.d.get(s1)).shortValue();
|
||||
+
|
||||
+ nbttagcompound.setShort(s1, short1);
|
||||
+ }
|
||||
+
|
||||
+ DataOutputStream dataoutputstream = new DataOutputStream(new FileOutputStream(file1));
|
||||
+
|
||||
+ NBTCompressedStreamTools.a(nbttagcompound, (DataOutput) dataoutputstream);
|
||||
+ dataoutputstream.close();
|
||||
+ }
|
||||
+ } catch (Exception exception) {
|
||||
+ exception.printStackTrace();
|
||||
+ }
|
||||
+
|
||||
+ return oshort.shortValue();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
|
@ -8,13 +8,40 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -0,0 +0,0 @@ public class CraftEventFactory {
|
||||
*/
|
||||
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, ItemStack itemstack) {
|
||||
if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
|
||||
- throw new AssertionError(String.format("%s performing %s with %s", who, action, itemstack));
|
||||
+ throw new IllegalArgumentException(String.format("%s performing %s with %s", who, action, itemstack)); // Spigot
|
||||
}
|
||||
return callPlayerInteractEvent(who, action, 0, 256, 0, 0, itemstack);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class CraftEventFactory {
|
||||
if (source == DamageSource.CACTUS) {
|
||||
cause = DamageCause.CONTACT;
|
||||
} else {
|
||||
- throw new AssertionError(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.translationIndex));
|
||||
+ throw new RuntimeException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.translationIndex)); // Spigot
|
||||
}
|
||||
EntityDamageEvent event = callEvent(new EntityDamageByBlockEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions));
|
||||
if (!event.isCancelled()) {
|
||||
@@ -0,0 +0,0 @@ public class CraftEventFactory {
|
||||
} else if (source == DamageSource.FALL) {
|
||||
cause = DamageCause.FALL;
|
||||
} else {
|
||||
- throw new RuntimeException("Unhandled entity damage");
|
||||
+ throw new RuntimeException("Unhandled entity damage from " + damager.getHandle().getName()); // Spigot - Add damager
|
||||
- throw new AssertionError(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.translationIndex));
|
||||
+ throw new RuntimeException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.translationIndex)); // Spigot
|
||||
}
|
||||
EntityDamageEvent event = callEvent(new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions));
|
||||
if (!event.isCancelled()) {
|
||||
@@ -0,0 +0,0 @@ public class CraftEventFactory {
|
||||
return callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions);
|
||||
}
|
||||
|
||||
- throw new AssertionError(String.format("Unhandled damage of %s from %s", entity, source.translationIndex));
|
||||
+ throw new RuntimeException(String.format("Unhandled damage of %s from %s", entity, source.translationIndex)); // Spigot
|
||||
}
|
||||
|
||||
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
|
||||
--
|
61
CraftBukkit-Patches/0172-Plug-WorldMap-Memory-Leak.patch
Normal file
61
CraftBukkit-Patches/0172-Plug-WorldMap-Memory-Leak.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <git@md-5.net>
|
||||
Date: Fri, 8 Aug 2014 19:57:03 +1000
|
||||
Subject: [PATCH] Plug WorldMap Memory Leak
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PersistentCollection.java b/src/main/java/net/minecraft/server/PersistentCollection.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/PersistentCollection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PersistentCollection.java
|
||||
@@ -0,0 +0,0 @@ public class PersistentCollection {
|
||||
|
||||
private IDataManager a;
|
||||
private Map b = new HashMap();
|
||||
- private List c = new ArrayList();
|
||||
+ public List c = new ArrayList(); // Spigot
|
||||
private Map d = new HashMap();
|
||||
|
||||
public PersistentCollection(IDataManager idatamanager) {
|
||||
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/World.java
|
||||
+++ b/src/main/java/net/minecraft/server/World.java
|
||||
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
|
||||
entity.die();
|
||||
if (entity instanceof EntityHuman) {
|
||||
this.players.remove(entity);
|
||||
+ // Spigot start
|
||||
+ for ( Object o : worldMaps.c )
|
||||
+ {
|
||||
+ if ( o instanceof WorldMap )
|
||||
+ {
|
||||
+ WorldMap map = (WorldMap) o;
|
||||
+ map.i.remove( entity );
|
||||
+ for ( Iterator<WorldMapHumanTracker> iter = (Iterator<WorldMapHumanTracker>) map.f.iterator(); iter.hasNext(); )
|
||||
+ {
|
||||
+ if ( iter.next().trackee == entity )
|
||||
+ {
|
||||
+ iter.remove();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Spigot end
|
||||
this.everyoneSleeping();
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/WorldMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/WorldMap.java
|
||||
@@ -0,0 +0,0 @@ public class WorldMap extends PersistentBase {
|
||||
public byte scale;
|
||||
public byte[] colors = new byte[16384];
|
||||
public List f = new ArrayList();
|
||||
- private Map i = new HashMap();
|
||||
+ public Map i = new HashMap(); // Spigot
|
||||
public Map decorations = new LinkedHashMap();
|
||||
|
||||
// CraftBukkit start
|
||||
--
|
Loading…
Reference in New Issue
Block a user