From 158afaffebbb477b548795728de001dce724e50c Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 14 May 2017 12:00:00 +1000 Subject: [PATCH] Remove Ebean ORM By: md_5 --- paper-api/pom.xml | 6 -- .../src/main/java/org/bukkit/Bukkit.java | 11 ---- .../src/main/java/org/bukkit/Server.java | 9 --- .../main/java/org/bukkit/plugin/Plugin.java | 23 ------- .../bukkit/plugin/PluginDescriptionFile.java | 33 ---------- .../org/bukkit/plugin/java/JavaPlugin.java | 64 ------------------- .../java/org/bukkit/plugin/TestPlugin.java | 6 -- 7 files changed, 152 deletions(-) diff --git a/paper-api/pom.xml b/paper-api/pom.xml index 46af3f170d..7b9c6a5f96 100644 --- a/paper-api/pom.xml +++ b/paper-api/pom.xml @@ -72,12 +72,6 @@ 2.2.4 compile - - org.avaje - ebean - 2.8.1 - compile - org.yaml snakeyaml diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index cadbbcad00..75b0a9a4b2 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -40,7 +40,6 @@ import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scoreboard.ScoreboardManager; import org.bukkit.util.CachedServerIcon; -import com.avaje.ebean.config.ServerConfig; import com.google.common.collect.ImmutableList; import org.bukkit.generator.ChunkGenerator; @@ -589,16 +588,6 @@ public final class Bukkit { return server.dispatchCommand(sender, commandLine); } - /** - * Populates a given {@link ServerConfig} with values attributes to this - * server. - * - * @param config the server config to populate - */ - public static void configureDbConfig(ServerConfig config) { - server.configureDbConfig(config); - } - /** * Adds a recipe to the crafting manager. * diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index 4c03a9971a..9468c4a678 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -41,7 +41,6 @@ import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scoreboard.ScoreboardManager; import org.bukkit.util.CachedServerIcon; -import com.avaje.ebean.config.ServerConfig; import com.google.common.collect.ImmutableList; import org.bukkit.generator.ChunkGenerator; @@ -485,14 +484,6 @@ public interface Server extends PluginMessageRecipient { */ public boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException; - /** - * Populates a given {@link ServerConfig} with values attributes to this - * server. - * - * @param config the server config to populate - */ - public void configureDbConfig(ServerConfig config); - /** * Adds a recipe to the crafting manager. * diff --git a/paper-api/src/main/java/org/bukkit/plugin/Plugin.java b/paper-api/src/main/java/org/bukkit/plugin/Plugin.java index 4357b13110..c4e22c6228 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/Plugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/Plugin.java @@ -9,8 +9,6 @@ import org.bukkit.command.TabExecutor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.generator.ChunkGenerator; -import com.avaje.ebean.EbeanServer; - /** * Represents a Plugin *

@@ -139,27 +137,6 @@ public interface Plugin extends TabExecutor { */ public void setNaggable(boolean canNag); - /** - * Gets the {@link EbeanServer} tied to this plugin. This will only be - * available if enabled in the {@link - * PluginDescriptionFile#isDatabaseEnabled()} - *

- * For more information on the use of - * Avaje Ebeans ORM, see Avaje Ebeans - * Documentation - *

- * For an example using Ebeans ORM, see Bukkit's Homebukkit Plugin - * - * - * @return ebean server instance or null if not enabled - * @deprecated all EBean related methods will be removed with Minecraft 1.12 - * - see https://www.spigotmc.org/threads/194144/ - */ - @Deprecated - public EbeanServer getDatabase(); - /** * Gets a {@link ChunkGenerator} for use in a default world, as specified * in the server configuration diff --git a/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java index b93569f3dd..afd2012366 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/paper-api/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java @@ -221,7 +221,6 @@ public final class PluginDescriptionFile { private List authors = null; private String website = null; private String prefix = null; - private boolean database = false; private PluginLoadOrder order = PluginLoadOrder.POSTWORLD; private List permissions = null; private Map lazyPermissions = null; @@ -427,25 +426,6 @@ public final class PluginDescriptionFile { return website; } - /** - * Gives if the plugin uses a database. - *

    - *
  • Using a database is non-trivial. - *
  • Valid values include true and false - *
- *

- * In the plugin.yml, this entry is named database. - *

- * Example: - *

database: false
- * - * @return if this plugin requires a database - * @see Plugin#getDatabase() - */ - public boolean isDatabaseEnabled() { - return database; - } - /** * Gives a list of other plugins that the plugin requires. *
    @@ -873,10 +853,6 @@ public final class PluginDescriptionFile { return classLoaderOf; } - public void setDatabaseEnabled(boolean database) { - this.database = database; - } - /** * Saves this PluginDescriptionFile to the given writer * @@ -956,14 +932,6 @@ public final class PluginDescriptionFile { softDepend = makePluginNameList(map, "softdepend"); loadBefore = makePluginNameList(map, "loadbefore"); - if (map.get("database") != null) { - try { - database = (Boolean) map.get("database"); - } catch (ClassCastException ex) { - throw new InvalidDescriptionException(ex, "database is of wrong type"); - } - } - if (map.get("website") != null) { website = map.get("website").toString(); } @@ -1061,7 +1029,6 @@ public final class PluginDescriptionFile { map.put("name", name); map.put("main", main); map.put("version", version); - map.put("database", database); map.put("order", order.toString()); map.put("default-permission", defaultPerm.toString()); diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index bcb8a67997..16b1eb3728 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -32,12 +32,6 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.PluginLogger; -import com.avaje.ebean.EbeanServer; -import com.avaje.ebean.EbeanServerFactory; -import com.avaje.ebean.config.DataSourceConfig; -import com.avaje.ebean.config.ServerConfig; -import com.avaje.ebeaninternal.api.SpiEbeanServer; -import com.avaje.ebeaninternal.server.ddl.DdlGenerator; import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.io.ByteStreams; @@ -54,7 +48,6 @@ public abstract class JavaPlugin extends PluginBase { private File dataFolder = null; private ClassLoader classLoader = null; private boolean naggable = true; - private EbeanServer ebean = null; private FileConfiguration newConfig = null; private File configFile = null; private PluginLogger logger = null; @@ -285,42 +278,6 @@ public abstract class JavaPlugin extends PluginBase { this.classLoader = classLoader; this.configFile = new File(dataFolder, "config.yml"); this.logger = new PluginLogger(this); - - if (description.isDatabaseEnabled()) { - ServerConfig db = new ServerConfig(); - - db.setDefaultServer(false); - db.setRegister(false); - db.setClasses(getDatabaseClasses()); - db.setName(description.getName()); - server.configureDbConfig(db); - - DataSourceConfig ds = db.getDataSourceConfig(); - - ds.setUrl(replaceDatabaseString(ds.getUrl())); - dataFolder.mkdirs(); - - ClassLoader previous = Thread.currentThread().getContextClassLoader(); - - Thread.currentThread().setContextClassLoader(classLoader); - ebean = EbeanServerFactory.create(db); - Thread.currentThread().setContextClassLoader(previous); - } - } - - /** - * Provides a list of all classes that should be persisted in the database - * - * @return List of Classes that are Ebeans - */ - public List> getDatabaseClasses() { - return new ArrayList>(); - } - - private String replaceDatabaseString(String input) { - input = input.replaceAll("\\{DIR\\}", dataFolder.getPath().replaceAll("\\\\", "/") + "/"); - input = input.replaceAll("\\{NAME\\}", description.getName().replaceAll("[^\\w_-]", "")); - return input; } /** @@ -386,27 +343,6 @@ public abstract class JavaPlugin extends PluginBase { this.naggable = canNag; } - @Override - public EbeanServer getDatabase() { - Preconditions.checkState(description.isDatabaseEnabled(), "Plugin does not have database: true in plugin.yml"); - - return ebean; - } - - protected void installDDL() { - SpiEbeanServer serv = (SpiEbeanServer) getDatabase(); - DdlGenerator gen = serv.getDdlGenerator(); - - gen.runScript(false, gen.generateCreateDdl()); - } - - protected void removeDDL() { - SpiEbeanServer serv = (SpiEbeanServer) getDatabase(); - DdlGenerator gen = serv.getDdlGenerator(); - - gen.runScript(true, gen.generateDropDdl()); - } - @Override public final Logger getLogger() { return logger; diff --git a/paper-api/src/test/java/org/bukkit/plugin/TestPlugin.java b/paper-api/src/test/java/org/bukkit/plugin/TestPlugin.java index 7e098925cd..f85e5f1755 100644 --- a/paper-api/src/test/java/org/bukkit/plugin/TestPlugin.java +++ b/paper-api/src/test/java/org/bukkit/plugin/TestPlugin.java @@ -10,8 +10,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.generator.ChunkGenerator; -import com.avaje.ebean.EbeanServer; - public class TestPlugin extends PluginBase { private boolean enabled = true; @@ -93,10 +91,6 @@ public class TestPlugin extends PluginBase { throw new UnsupportedOperationException("Not supported."); } - public EbeanServer getDatabase() { - throw new UnsupportedOperationException("Not supported."); - } - public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { throw new UnsupportedOperationException("Not supported."); }