From e6f2d392781558710a109c36cd8359d14c66d019 Mon Sep 17 00:00:00 2001 From: Aikar 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 2493a23..d677731 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1,31 +1,24 @@ 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; @@ -34,12 +27,8 @@ 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; @@ -49,13 +38,7 @@ 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; @@ -76,51 +59,30 @@ 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]; @@ -729,6 +691,14 @@ 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(); -- 2.7.3