Browse Source

Memory leak fix

nossr50 4 years ago
parent
commit
bcd260d9c1
3 changed files with 9 additions and 1 deletions
  1. 3 0
      Changelog.txt
  2. 1 1
      pom.xml
  3. 5 0
      src/main/java/com/gmail/nossr50/util/TransientMetadataTools.java

+ 3 - 0
Changelog.txt

@@ -1,3 +1,6 @@
+Version 2.1.159
+    Fixed a memory leak involving renamed mobs
+
 Version 2.1.158
 Version 2.1.158
     Fixed a bug where Lure level 4 and above would break fishing with the new Master Angler
     Fixed a bug where Lure level 4 and above would break fishing with the new Master Angler
     URLs in party/admin chat work again (use https:// in front to make links clickable)
     URLs in party/admin chat work again (use https:// in front to make links clickable)

+ 1 - 1
pom.xml

@@ -2,7 +2,7 @@
     <modelVersion>4.0.0</modelVersion>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.gmail.nossr50.mcMMO</groupId>
     <groupId>com.gmail.nossr50.mcMMO</groupId>
     <artifactId>mcMMO</artifactId>
     <artifactId>mcMMO</artifactId>
-    <version>2.1.158</version>
+    <version>2.1.159-SNAPSHOT</version>
     <name>mcMMO</name>
     <name>mcMMO</name>
     <url>https://github.com/mcMMO-Dev/mcMMO</url>
     <url>https://github.com/mcMMO-Dev/mcMMO</url>
     <scm>
     <scm>

+ 5 - 0
src/main/java/com/gmail/nossr50/util/TransientMetadataTools.java

@@ -4,6 +4,7 @@ import com.gmail.nossr50.mcMMO;
 import org.bukkit.entity.LivingEntity;
 import org.bukkit.entity.LivingEntity;
 
 
 public class TransientMetadataTools {
 public class TransientMetadataTools {
+    public static final String OLD_NAME_METAKEY = "mcMMO_oldName";
     private final mcMMO pluginRef;
     private final mcMMO pluginRef;
 
 
     public TransientMetadataTools(mcMMO pluginRef) {
     public TransientMetadataTools(mcMMO pluginRef) {
@@ -17,6 +18,10 @@ public class TransientMetadataTools {
             livingEntity.removeMetadata(mcMMO.customNameKey, pluginRef);
             livingEntity.removeMetadata(mcMMO.customNameKey, pluginRef);
         }
         }
 
 
+        if(livingEntity.hasMetadata(OLD_NAME_METAKEY)) {
+            livingEntity.removeMetadata(OLD_NAME_METAKEY, pluginRef);
+        }
+
         //Involved in changing mob names to hearts
         //Involved in changing mob names to hearts
         if (livingEntity.hasMetadata(mcMMO.customVisibleKey)) {
         if (livingEntity.hasMetadata(mcMMO.customVisibleKey)) {
             livingEntity.setCustomNameVisible(livingEntity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
             livingEntity.setCustomNameVisible(livingEntity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());