mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Making the database stuff abstract:
This will make it easier to add support for MongoDB
This commit is contained in:
parent
ed6df3e700
commit
e548cd8158
@ -17,6 +17,7 @@ import com.intellectualcrafters.plot.commands.MainCommand;
|
|||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.database.MySQL;
|
import com.intellectualcrafters.plot.database.MySQL;
|
||||||
import com.intellectualcrafters.plot.database.PlotMeConverter;
|
import com.intellectualcrafters.plot.database.PlotMeConverter;
|
||||||
|
import com.intellectualcrafters.plot.database.SQLManager;
|
||||||
import com.intellectualcrafters.plot.database.SQLite;
|
import com.intellectualcrafters.plot.database.SQLite;
|
||||||
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
||||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||||
@ -572,6 +573,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
|
|
||||||
// Use mysql?
|
// Use mysql?
|
||||||
if (Settings.DB.USE_MYSQL) {
|
if (Settings.DB.USE_MYSQL) {
|
||||||
|
DBFunc.dbManager = new SQLManager();
|
||||||
try {
|
try {
|
||||||
mySQL =
|
mySQL =
|
||||||
new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
|
new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
|
||||||
@ -596,7 +598,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException | SQLException e) {
|
catch (Exception e) {
|
||||||
Logger.add(LogLevel.DANGER, "MySQL connection failed.");
|
Logger.add(LogLevel.DANGER, "MySQL connection failed.");
|
||||||
sendConsoleSenderMessage("&c[Plots] MySQL is not setup correctly. The plugin will disable itself.");
|
sendConsoleSenderMessage("&c[Plots] MySQL is not setup correctly. The plugin will disable itself.");
|
||||||
if (config==null || config.getBoolean("debug")) {
|
if (config==null || config.getBoolean("debug")) {
|
||||||
@ -614,11 +616,12 @@ public class PlotMain extends JavaPlugin {
|
|||||||
// TODO: Implement mongo
|
// TODO: Implement mongo
|
||||||
else
|
else
|
||||||
if (Settings.DB.USE_MONGO) {
|
if (Settings.DB.USE_MONGO) {
|
||||||
|
// DBFunc.dbManager = new MongoManager();
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented");
|
sendConsoleSenderMessage(C.PREFIX.s() + "MongoDB is not yet implemented");
|
||||||
}
|
}
|
||||||
// Use Sqlite :D<3
|
|
||||||
else
|
else
|
||||||
if (Settings.DB.USE_SQLITE) {
|
if (Settings.DB.USE_SQLITE) {
|
||||||
|
DBFunc.dbManager = new SQLManager();
|
||||||
try {
|
try {
|
||||||
connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db").openConnection();
|
connection = new SQLite(this, Settings.DB.SQLITE_DB + ".db").openConnection();
|
||||||
{
|
{
|
||||||
@ -641,7 +644,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException | SQLException e) {
|
catch (Exception e) {
|
||||||
Logger.add(LogLevel.DANGER, "SQLite connection failed");
|
Logger.add(LogLevel.DANGER, "SQLite connection failed");
|
||||||
sendConsoleSenderMessage(C.PREFIX.s()
|
sendConsoleSenderMessage(C.PREFIX.s()
|
||||||
+ "&cFailed to open SQLite connection. The plugin will disable itself.");
|
+ "&cFailed to open SQLite connection. The plugin will disable itself.");
|
||||||
|
@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) IntellectualCrafters - 2014. You are not allowed to distribute
|
||||||
|
* and/or monetize any of our intellectual property. IntellectualCrafters is not
|
||||||
|
* affiliated with Mojang AB. Minecraft is a trademark of Mojang AB.
|
||||||
|
*
|
||||||
|
* >> File = DBFunc.java >> Generated by: Citymonstret at 2014-08-09 01:43
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.database;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.Flag;
|
||||||
|
import com.intellectualcrafters.plot.Plot;
|
||||||
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Citymonstret
|
||||||
|
*/
|
||||||
|
public abstract class AbstractDB {
|
||||||
|
|
||||||
|
// TODO MongoDB @Brandon
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Plot owner
|
||||||
|
*
|
||||||
|
* @param plot
|
||||||
|
* @param uuid
|
||||||
|
*/
|
||||||
|
public abstract void setOwner(final Plot plot, final UUID uuid);
|
||||||
|
|
||||||
|
public abstract void createAllSettingsAndHelpers(ArrayList<Plot> plots);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a plot
|
||||||
|
*
|
||||||
|
* @param plots
|
||||||
|
*/
|
||||||
|
public abstract void createPlots(ArrayList<Plot> plots);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a plot
|
||||||
|
*
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
public abstract void createPlot(Plot plot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create tables
|
||||||
|
*
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public abstract void createTables(String database, boolean add_constraint) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a plot
|
||||||
|
*
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
public abstract void delete(final String world, final Plot plot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create plot settings
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param plot
|
||||||
|
*/
|
||||||
|
public abstract void createPlotSettings(final int id, final Plot plot);
|
||||||
|
|
||||||
|
public abstract int getId(String world, PlotId id2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract HashMap<String, HashMap<PlotId, Plot>> getPlots();
|
||||||
|
|
||||||
|
|
||||||
|
public abstract void setMerged(final String world, final Plot plot, final boolean[] merged);
|
||||||
|
|
||||||
|
public abstract void setFlags(final String world, final Plot plot, final Flag[] flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param alias
|
||||||
|
*/
|
||||||
|
public abstract void setAlias(final String world, final Plot plot, final String alias);
|
||||||
|
|
||||||
|
public abstract void purge(final String world, final PlotId id);
|
||||||
|
|
||||||
|
public abstract void purge(final String world);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param position
|
||||||
|
*/
|
||||||
|
public abstract void setPosition(final String world, final Plot plot, final String position);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract HashMap<String, Object> getSettings(int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public abstract void removeHelper(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public abstract void removeTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public abstract void setHelper(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public abstract void setTrusted(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public abstract void removeDenied(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param plot
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public abstract void setDenied(final String world, final Plot plot, final OfflinePlayer player);
|
||||||
|
|
||||||
|
public abstract double getRatings(final Plot plot);
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user