mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-15 14:13:56 +01:00
Remove, not invalidate, Metadata on reload
Objects loaded over different class loaders are not the same. Nasty dragons lie here. Also clean up the previous patch to no longer butcher imports.
This commit is contained in:
parent
7d7810721e
commit
88ef71592b
3 changed files with 67 additions and 168 deletions
|
@ -0,0 +1,39 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 16 Jul 2013 21:26:50 -0400
|
||||
Subject: [PATCH] Add MetadataStoreBase.removeAll(Plugin)
|
||||
|
||||
So that on reload, metadata will be cleared
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
|
||||
+++ b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java
|
||||
@@ -0,0 +0,0 @@ public abstract class MetadataStoreBase<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
+ * Removes all metadata in the metadata store that originates from the
|
||||
+ * given plugin.
|
||||
+ *
|
||||
+ * @param owningPlugin the plugin requesting the invalidation.
|
||||
+ * @throws IllegalArgumentException If plugin is null
|
||||
+ */
|
||||
+ public void removeAll(Plugin owningPlugin) {
|
||||
+ Validate.notNull(owningPlugin, "Plugin cannot be null");
|
||||
+ for (Iterator<Map<Plugin, MetadataValue>> iterator = metadataMap.values().iterator(); iterator.hasNext(); ) {
|
||||
+ Map<Plugin, MetadataValue> values = iterator.next();
|
||||
+ if (values.containsKey(owningPlugin)) {
|
||||
+ values.remove(owningPlugin);
|
||||
+ }
|
||||
+ if (values.isEmpty()) {
|
||||
+ iterator.remove();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
* Creates a unique name for the object receiving metadata by combining
|
||||
* unique data from the subject with a metadataKey.
|
||||
* <p>
|
||||
--
|
|
@ -1,168 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 18 Mar 2016 13:50:14 -0400
|
||||
Subject: [PATCH] Invalidate Metadata on reload
|
||||
|
||||
Metadata is not meant to persist reload as things break badly with non primitive types
|
||||
This will invalidate metadata on reload so it does not crash everything if a plugin uses it.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
-import java.awt.image.BufferedImage;
|
||||
-import java.io.File;
|
||||
-import java.io.FileInputStream;
|
||||
-import java.io.FileNotFoundException;
|
||||
-import java.io.IOException;
|
||||
-import java.io.InputStreamReader;
|
||||
-import java.util.ArrayList;
|
||||
-import java.util.Arrays;
|
||||
-import java.util.Collections;
|
||||
-import java.util.HashSet;
|
||||
-import java.util.Iterator;
|
||||
-import java.util.LinkedHashMap;
|
||||
-import java.util.LinkedHashSet;
|
||||
-import java.util.List;
|
||||
-import java.util.Map;
|
||||
-import java.util.Set;
|
||||
-import java.util.UUID;
|
||||
-import java.util.logging.Level;
|
||||
-import java.util.logging.Logger;
|
||||
-import java.util.regex.Pattern;
|
||||
-
|
||||
-import javax.imageio.ImageIO;
|
||||
-
|
||||
+import com.avaje.ebean.config.DataSourceConfig;
|
||||
+import com.avaje.ebean.config.ServerConfig;
|
||||
+import com.avaje.ebean.config.dbplatform.SQLitePlatform;
|
||||
+import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation;
|
||||
+import com.google.common.base.Charsets;
|
||||
+import com.google.common.base.Function;
|
||||
+import com.google.common.collect.ImmutableList;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import com.google.common.collect.MapMaker;
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
+import io.netty.buffer.ByteBuf;
|
||||
+import io.netty.buffer.ByteBufOutputStream;
|
||||
+import io.netty.buffer.Unpooled;
|
||||
+import io.netty.handler.codec.base64.Base64;
|
||||
+import jline.console.ConsoleReader;
|
||||
+import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.minecraft.server.*;
|
||||
-
|
||||
import net.minecraft.server.WorldType;
|
||||
+import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Warning.WarningState;
|
||||
import org.bukkit.World;
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarFlag;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
-import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.*;
|
||||
import org.bukkit.command.CommandException;
|
||||
-import org.bukkit.command.CommandSender;
|
||||
-import org.bukkit.command.ConsoleCommandSender;
|
||||
-import org.bukkit.command.PluginCommand;
|
||||
-import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.generator.CraftChunkData;
|
||||
import org.bukkit.craftbukkit.help.SimpleHelpMap;
|
||||
-import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe;
|
||||
-import org.bukkit.craftbukkit.inventory.CraftInventoryCustom;
|
||||
-import org.bukkit.craftbukkit.inventory.CraftItemFactory;
|
||||
-import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
-import org.bukkit.craftbukkit.inventory.CraftShapedRecipe;
|
||||
-import org.bukkit.craftbukkit.inventory.CraftShapelessRecipe;
|
||||
-import org.bukkit.craftbukkit.inventory.RecipeIterator;
|
||||
+import org.bukkit.craftbukkit.inventory.*;
|
||||
import org.bukkit.craftbukkit.map.CraftMapView;
|
||||
import org.bukkit.craftbukkit.metadata.EntityMetadataStore;
|
||||
import org.bukkit.craftbukkit.metadata.PlayerMetadataStore;
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.help.HelpMap;
|
||||
-import org.bukkit.inventory.FurnaceRecipe;
|
||||
+import org.bukkit.inventory.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
-import org.bukkit.inventory.Inventory;
|
||||
-import org.bukkit.inventory.InventoryHolder;
|
||||
-import org.bukkit.inventory.Recipe;
|
||||
-import org.bukkit.inventory.ShapedRecipe;
|
||||
-import org.bukkit.inventory.ShapelessRecipe;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
-import org.bukkit.plugin.Plugin;
|
||||
-import org.bukkit.plugin.PluginLoadOrder;
|
||||
-import org.bukkit.plugin.PluginManager;
|
||||
-import org.bukkit.plugin.ServicesManager;
|
||||
-import org.bukkit.plugin.SimplePluginManager;
|
||||
-import org.bukkit.plugin.SimpleServicesManager;
|
||||
+import org.bukkit.plugin.*;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
import org.bukkit.plugin.messaging.Messenger;
|
||||
+import org.bukkit.plugin.messaging.StandardMessenger;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
-import org.bukkit.plugin.messaging.StandardMessenger;
|
||||
import org.bukkit.scheduler.BukkitWorker;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.bukkit.util.permissions.DefaultPermissions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.error.MarkedYAMLException;
|
||||
-import org.apache.commons.lang.Validate;
|
||||
|
||||
-import com.avaje.ebean.config.DataSourceConfig;
|
||||
-import com.avaje.ebean.config.ServerConfig;
|
||||
-import com.avaje.ebean.config.dbplatform.SQLitePlatform;
|
||||
-import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation;
|
||||
-import com.google.common.base.Charsets;
|
||||
-import com.google.common.base.Function;
|
||||
-import com.google.common.collect.ImmutableList;
|
||||
-import com.google.common.collect.Lists;
|
||||
-import com.google.common.collect.MapMaker;
|
||||
-import com.mojang.authlib.GameProfile;
|
||||
-
|
||||
-import io.netty.buffer.ByteBuf;
|
||||
-import io.netty.buffer.ByteBufOutputStream;
|
||||
-import io.netty.buffer.Unpooled;
|
||||
-import io.netty.handler.codec.base64.Base64;
|
||||
-import jline.console.ConsoleReader;
|
||||
-import net.md_5.bungee.api.chat.BaseComponent;
|
||||
+import javax.imageio.ImageIO;
|
||||
+import java.awt.image.BufferedImage;
|
||||
+import java.io.*;
|
||||
+import java.util.*;
|
||||
+import java.util.logging.Level;
|
||||
+import java.util.logging.Logger;
|
||||
+import java.util.regex.Pattern;
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
private static final Player[] EMPTY_PLAYER_ARRAY = new Player[0];
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
world.paperConfig.init(); // Paper
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ for (Plugin plugin : pluginManager.getPlugins()) {
|
||||
+ entityMetadata.invalidateAll(plugin);
|
||||
+ worldMetadata.invalidateAll(plugin);
|
||||
+ playerMetadata.invalidateAll(plugin);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
pluginManager.clearPlugins();
|
||||
commandMap.clearCommands();
|
||||
resetRecipes();
|
||||
--
|
28
Spigot-Server-Patches/Remove-Metadata-on-reload.patch
Normal file
28
Spigot-Server-Patches/Remove-Metadata-on-reload.patch
Normal file
|
@ -0,0 +1,28 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 18 Mar 2016 13:50:14 -0400
|
||||
Subject: [PATCH] Remove Metadata on reload
|
||||
|
||||
Metadata is not meant to persist reload as things break badly with non primitive types
|
||||
This will remove metadata on reload so it does not crash everything if a plugin uses it.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -0,0 +0,0 @@ public final class CraftServer implements Server {
|
||||
world.paperConfig.init(); // Paper
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ for (Plugin plugin : pluginManager.getPlugins()) {
|
||||
+ entityMetadata.removeAll(plugin);
|
||||
+ worldMetadata.removeAll(plugin);
|
||||
+ playerMetadata.removeAll(plugin);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
pluginManager.clearPlugins();
|
||||
commandMap.clearCommands();
|
||||
resetRecipes();
|
||||
--
|
Loading…
Reference in a new issue