geforkt von Mirrors/Paper
Remove Ebean ORM
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
88d1d8bf69
Commit
158afaffeb
@ -72,12 +72,6 @@
|
|||||||
<version>2.2.4</version>
|
<version>2.2.4</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.avaje</groupId>
|
|
||||||
<artifactId>ebean</artifactId>
|
|
||||||
<version>2.8.1</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
@ -40,7 +40,6 @@ import org.bukkit.scheduler.BukkitScheduler;
|
|||||||
import org.bukkit.scoreboard.ScoreboardManager;
|
import org.bukkit.scoreboard.ScoreboardManager;
|
||||||
import org.bukkit.util.CachedServerIcon;
|
import org.bukkit.util.CachedServerIcon;
|
||||||
|
|
||||||
import com.avaje.ebean.config.ServerConfig;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
@ -589,16 +588,6 @@ public final class Bukkit {
|
|||||||
return server.dispatchCommand(sender, commandLine);
|
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.
|
* Adds a recipe to the crafting manager.
|
||||||
*
|
*
|
||||||
|
@ -41,7 +41,6 @@ import org.bukkit.scheduler.BukkitScheduler;
|
|||||||
import org.bukkit.scoreboard.ScoreboardManager;
|
import org.bukkit.scoreboard.ScoreboardManager;
|
||||||
import org.bukkit.util.CachedServerIcon;
|
import org.bukkit.util.CachedServerIcon;
|
||||||
|
|
||||||
import com.avaje.ebean.config.ServerConfig;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
@ -485,14 +484,6 @@ public interface Server extends PluginMessageRecipient {
|
|||||||
*/
|
*/
|
||||||
public boolean dispatchCommand(CommandSender sender, String commandLine) throws CommandException;
|
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.
|
* Adds a recipe to the crafting manager.
|
||||||
*
|
*
|
||||||
|
@ -9,8 +9,6 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.avaje.ebean.EbeanServer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Plugin
|
* Represents a Plugin
|
||||||
* <p>
|
* <p>
|
||||||
@ -139,27 +137,6 @@ public interface Plugin extends TabExecutor {
|
|||||||
*/
|
*/
|
||||||
public void setNaggable(boolean canNag);
|
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()}
|
|
||||||
* <p>
|
|
||||||
* <i>For more information on the use of <a href="http://www.avaje.org/">
|
|
||||||
* Avaje Ebeans ORM</a>, see <a
|
|
||||||
* href="http://www.avaje.org/ebean/documentation.html">Avaje Ebeans
|
|
||||||
* Documentation</a></i>
|
|
||||||
* <p>
|
|
||||||
* <i>For an example using Ebeans ORM, see <a
|
|
||||||
* href="https://github.com/Bukkit/HomeBukkit">Bukkit's Homebukkit Plugin
|
|
||||||
* </a></i>
|
|
||||||
*
|
|
||||||
* @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
|
* Gets a {@link ChunkGenerator} for use in a default world, as specified
|
||||||
* in the server configuration
|
* in the server configuration
|
||||||
|
@ -221,7 +221,6 @@ public final class PluginDescriptionFile {
|
|||||||
private List<String> authors = null;
|
private List<String> authors = null;
|
||||||
private String website = null;
|
private String website = null;
|
||||||
private String prefix = null;
|
private String prefix = null;
|
||||||
private boolean database = false;
|
|
||||||
private PluginLoadOrder order = PluginLoadOrder.POSTWORLD;
|
private PluginLoadOrder order = PluginLoadOrder.POSTWORLD;
|
||||||
private List<Permission> permissions = null;
|
private List<Permission> permissions = null;
|
||||||
private Map<?, ?> lazyPermissions = null;
|
private Map<?, ?> lazyPermissions = null;
|
||||||
@ -427,25 +426,6 @@ public final class PluginDescriptionFile {
|
|||||||
return website;
|
return website;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gives if the plugin uses a database.
|
|
||||||
* <ul>
|
|
||||||
* <li>Using a database is non-trivial.
|
|
||||||
* <li>Valid values include <code>true</code> and <code>false</code>
|
|
||||||
* </ul>
|
|
||||||
* <p>
|
|
||||||
* In the plugin.yml, this entry is named <code>database</code>.
|
|
||||||
* <p>
|
|
||||||
* Example:
|
|
||||||
* <blockquote><pre>database: false</pre></blockquote>
|
|
||||||
*
|
|
||||||
* @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.
|
* Gives a list of other plugins that the plugin requires.
|
||||||
* <ul>
|
* <ul>
|
||||||
@ -873,10 +853,6 @@ public final class PluginDescriptionFile {
|
|||||||
return classLoaderOf;
|
return classLoaderOf;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDatabaseEnabled(boolean database) {
|
|
||||||
this.database = database;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves this PluginDescriptionFile to the given writer
|
* Saves this PluginDescriptionFile to the given writer
|
||||||
*
|
*
|
||||||
@ -956,14 +932,6 @@ public final class PluginDescriptionFile {
|
|||||||
softDepend = makePluginNameList(map, "softdepend");
|
softDepend = makePluginNameList(map, "softdepend");
|
||||||
loadBefore = makePluginNameList(map, "loadbefore");
|
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) {
|
if (map.get("website") != null) {
|
||||||
website = map.get("website").toString();
|
website = map.get("website").toString();
|
||||||
}
|
}
|
||||||
@ -1061,7 +1029,6 @@ public final class PluginDescriptionFile {
|
|||||||
map.put("name", name);
|
map.put("name", name);
|
||||||
map.put("main", main);
|
map.put("main", main);
|
||||||
map.put("version", version);
|
map.put("version", version);
|
||||||
map.put("database", database);
|
|
||||||
map.put("order", order.toString());
|
map.put("order", order.toString());
|
||||||
map.put("default-permission", defaultPerm.toString());
|
map.put("default-permission", defaultPerm.toString());
|
||||||
|
|
||||||
|
@ -32,12 +32,6 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
import org.bukkit.plugin.PluginLoader;
|
import org.bukkit.plugin.PluginLoader;
|
||||||
import org.bukkit.plugin.PluginLogger;
|
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.Charsets;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
@ -54,7 +48,6 @@ public abstract class JavaPlugin extends PluginBase {
|
|||||||
private File dataFolder = null;
|
private File dataFolder = null;
|
||||||
private ClassLoader classLoader = null;
|
private ClassLoader classLoader = null;
|
||||||
private boolean naggable = true;
|
private boolean naggable = true;
|
||||||
private EbeanServer ebean = null;
|
|
||||||
private FileConfiguration newConfig = null;
|
private FileConfiguration newConfig = null;
|
||||||
private File configFile = null;
|
private File configFile = null;
|
||||||
private PluginLogger logger = null;
|
private PluginLogger logger = null;
|
||||||
@ -285,42 +278,6 @@ public abstract class JavaPlugin extends PluginBase {
|
|||||||
this.classLoader = classLoader;
|
this.classLoader = classLoader;
|
||||||
this.configFile = new File(dataFolder, "config.yml");
|
this.configFile = new File(dataFolder, "config.yml");
|
||||||
this.logger = new PluginLogger(this);
|
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<Class<?>> getDatabaseClasses() {
|
|
||||||
return new ArrayList<Class<?>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
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
|
@Override
|
||||||
public final Logger getLogger() {
|
public final Logger getLogger() {
|
||||||
return logger;
|
return logger;
|
||||||
|
@ -10,8 +10,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.avaje.ebean.EbeanServer;
|
|
||||||
|
|
||||||
public class TestPlugin extends PluginBase {
|
public class TestPlugin extends PluginBase {
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
|
|
||||||
@ -93,10 +91,6 @@ public class TestPlugin extends PluginBase {
|
|||||||
throw new UnsupportedOperationException("Not supported.");
|
throw new UnsupportedOperationException("Not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public EbeanServer getDatabase() {
|
|
||||||
throw new UnsupportedOperationException("Not supported.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||||
throw new UnsupportedOperationException("Not supported.");
|
throw new UnsupportedOperationException("Not supported.");
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren