Commits

md_5 authored 84276e22472
SPIGOT-1889: Fail fast when plugin attempts to use database when not enabled.
No tags

src/main/java/org/bukkit/plugin/java/JavaPlugin.java

Modified
32 32 import org.bukkit.plugin.PluginLoader;
33 33 import org.bukkit.plugin.PluginLogger;
34 34
35 35 import com.avaje.ebean.EbeanServer;
36 36 import com.avaje.ebean.EbeanServerFactory;
37 37 import com.avaje.ebean.config.DataSourceConfig;
38 38 import com.avaje.ebean.config.ServerConfig;
39 39 import com.avaje.ebeaninternal.api.SpiEbeanServer;
40 40 import com.avaje.ebeaninternal.server.ddl.DdlGenerator;
41 41 import com.google.common.base.Charsets;
42 +import com.google.common.base.Preconditions;
42 43 import com.google.common.io.ByteStreams;
43 44
44 45 /**
45 46 * Represents a Java plugin
46 47 */
47 48 public abstract class JavaPlugin extends PluginBase {
48 49 private boolean isEnabled = false;
49 50 private PluginLoader loader = null;
50 51 private Server server = null;
51 52 private File file = null;
430 431 return naggable;
431 432 }
432 433
433 434 @Override
434 435 public final void setNaggable(boolean canNag) {
435 436 this.naggable = canNag;
436 437 }
437 438
438 439 @Override
439 440 public EbeanServer getDatabase() {
441 + Preconditions.checkState(description.isDatabaseEnabled(), "Plugin does not have database: true in plugin.yml");
442 +
440 443 return ebean;
441 444 }
442 445
443 446 protected void installDDL() {
444 447 SpiEbeanServer serv = (SpiEbeanServer) getDatabase();
445 448 DdlGenerator gen = serv.getDdlGenerator();
446 449
447 450 gen.runScript(false, gen.generateCreateDdl());
448 451 }
449 452

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut