diff --git a/pom.xml b/pom.xml index 11d7cd2..e5bcf5c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 nu.nerd ModReq - 1.7 + 1.8 jar ModReq Moderator Request Sytem @@ -33,7 +33,7 @@ org.bukkit bukkit - 1.8.8-R0.1-SNAPSHOT + 1.12-R0.1-SNAPSHOT jar compile @@ -42,6 +42,11 @@ bukkit-migration-tools 0.1 + + nu.nerd + BukkitEbean + 1.0.0 + @@ -102,8 +107,15 @@ org.gestern:bukkit-migration-tools:jar:* + nu.nerd:BukkitEbean:jar:* + + + nu.nerd.BukkitEbean + nu.nerd.modreq.BukkitEbean + + diff --git a/src/nu/nerd/modreq/ModReq.java b/src/nu/nerd/modreq/ModReq.java index 6cf0739..84a2bd5 100755 --- a/src/nu/nerd/modreq/ModReq.java +++ b/src/nu/nerd/modreq/ModReq.java @@ -1,5 +1,6 @@ package nu.nerd.modreq; +import com.avaje.ebean.EbeanServer; import com.avaje.ebean.SqlRow; import java.io.File; @@ -22,6 +23,8 @@ import javax.persistence.PersistenceException; +import nu.nerd.BukkitEbean.EbeanBuilder; +import nu.nerd.BukkitEbean.EbeanHelper; import nu.nerd.modreq.database.Note; import nu.nerd.modreq.database.NoteTable; import nu.nerd.modreq.database.Request; @@ -61,6 +64,7 @@ public class ModReq extends JavaPlugin { Map claimedIds = new HashMap(); File claimsFile; + EbeanServer db; RequestTable reqTable; NoteTable noteTable; @@ -90,11 +94,12 @@ public void onDisable() { public boolean setupDatabase() { try { - getDatabase().find(Request.class).findRowCount(); - getDatabase().find(Note.class).findRowCount(); + db = new EbeanBuilder(this).setClasses(getDatabaseClasses()).build(); + db.find(Request.class).findRowCount(); + db.find(Note.class).findRowCount(); } catch (PersistenceException ex) { getLogger().log(Level.INFO, "First run, initializing database."); - installDDL(); + EbeanHelper.installDDL(db); return true; } @@ -113,7 +118,7 @@ public void resetDatabase() { Set unknownNames = new HashSet(); getLogger().log(Level.INFO, "Executing remove ddl"); - removeDDL(); + EbeanHelper.removeDDL(db); if (setupDatabase()) { getLogger().log(Level.INFO, "Schema created, converting " + rowRequests.size() + " requests and " + rowNotes.size() + " notes"); @@ -268,7 +273,6 @@ public void resetDatabase() { getLogger().log(Level.INFO, "Done"); } - @Override public ArrayList> getDatabaseClasses() { ArrayList> list = new ArrayList>(); list.add(Request.class); @@ -276,6 +280,10 @@ public ArrayList> getDatabaseClasses() { return list; } + public EbeanServer getDatabase() { + return db; + } + @Override public boolean onCommand(CommandSender sender, Command command, String name, String[] args) { String senderName = ChatColor.stripColor(sender.getName()); @@ -800,7 +808,6 @@ private void mrUpgrade() { BukkitScheduler scheduler = Bukkit.getServer().getScheduler(); scheduler.scheduleSyncDelayedTask(this, new Runnable() { - @Override public void run() { resetDatabase(); }