Commits
md_5 authored 84276e22472
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 | |
434 435 | public final void setNaggable(boolean canNag) { |
435 436 | this.naggable = canNag; |
436 437 | } |
437 438 | |
438 439 | |
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 | |