From 5fa8f3997fca796aa617445443eed996b0beec7f Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Mon, 6 Aug 2018 15:19:06 +0200 Subject: [PATCH] BREAKING: Renamed a few API classes to a more generic name `BBConfig` to `Config`. `BBDatabase` to `Database`. `BBDbSetup` to `DatabaseSetup`. Sorry @tastybento, hope it won't bother you too much :/ --- src/main/java/world/bentobox/bentobox/BentoBox.java | 13 +++++-------- src/main/java/world/bentobox/bentobox/Settings.java | 2 +- .../configuration/{BBConfig.java => Config.java} | 6 +++--- .../database/{BBDatabase.java => Database.java} | 12 +++++------- .../database/{BBDbSetup.java => DatabaseSetup.java} | 8 ++++---- .../database/flatfile/FlatFileDatabase.java | 4 ++-- .../bentobox/database/mongodb/MongoDBDatabase.java | 4 ++-- .../bentobox/database/mysql/MySQLDatabase.java | 4 ++-- .../bentobox/bentobox/managers/IslandsManager.java | 6 +++--- .../bentobox/bentobox/managers/PlayersManager.java | 12 ++++++------ .../bentobox/managers/PlayersManagerTest.java | 4 ++-- 11 files changed, 35 insertions(+), 40 deletions(-) rename src/main/java/world/bentobox/bentobox/api/configuration/{BBConfig.java => Config.java} (95%) rename src/main/java/world/bentobox/bentobox/database/{BBDatabase.java => Database.java} (92%) rename src/main/java/world/bentobox/bentobox/database/{BBDbSetup.java => DatabaseSetup.java} (88%) diff --git a/src/main/java/world/bentobox/bentobox/BentoBox.java b/src/main/java/world/bentobox/bentobox/BentoBox.java index cc31d521e..fe21db31d 100644 --- a/src/main/java/world/bentobox/bentobox/BentoBox.java +++ b/src/main/java/world/bentobox/bentobox/BentoBox.java @@ -5,13 +5,13 @@ import org.bukkit.World; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; -import world.bentobox.bentobox.api.configuration.BBConfig; +import world.bentobox.bentobox.api.configuration.Config; import world.bentobox.bentobox.api.configuration.WorldSettings; import world.bentobox.bentobox.api.events.BentoBoxReadyEvent; import world.bentobox.bentobox.api.placeholders.PlaceholderHandler; import world.bentobox.bentobox.api.user.Notifier; import world.bentobox.bentobox.commands.BentoBoxCommand; -import world.bentobox.bentobox.database.BBDbSetup; +import world.bentobox.bentobox.database.DatabaseSetup; import world.bentobox.bentobox.listeners.BannedVisitorCommands; import world.bentobox.bentobox.listeners.BlockEndDragon; import world.bentobox.bentobox.listeners.JoinLeaveListener; @@ -78,7 +78,7 @@ public class BentoBox extends JavaPlugin { flagsManager = new FlagsManager(instance); // Load settings from config.yml. This will check if there are any issues with it too. - settings = new BBConfig<>(this, Settings.class).loadConfigObject(""); + settings = new Config<>(this, Settings.class).loadConfigObject(""); // Start Database managers playersManager = new PlayersManager(this); // Check if this plugin is now disabled (due to bad database handling) @@ -142,9 +142,6 @@ public class BentoBox extends JavaPlugin { // Fire plugin ready event Bukkit.getServer().getPluginManager().callEvent(new BentoBoxReadyEvent()); - - - }); } @@ -183,7 +180,7 @@ public class BentoBox extends JavaPlugin { } // Save settings if (settings != null) { - new BBConfig<>(this, Settings.class).saveConfigObject(settings); + new Config<>(this, Settings.class).saveConfigObject(settings); } } @@ -218,7 +215,7 @@ public class BentoBox extends JavaPlugin { @Override public String getValue() { - return BBDbSetup.getDatabase().toString(); + return DatabaseSetup.getDatabase().toString(); } }); } diff --git a/src/main/java/world/bentobox/bentobox/Settings.java b/src/main/java/world/bentobox/bentobox/Settings.java index 016bcb6e4..6203fff8e 100644 --- a/src/main/java/world/bentobox/bentobox/Settings.java +++ b/src/main/java/world/bentobox/bentobox/Settings.java @@ -8,7 +8,7 @@ import java.util.Set; import world.bentobox.bentobox.api.configuration.ConfigComment; import world.bentobox.bentobox.api.configuration.ConfigEntry; import world.bentobox.bentobox.api.configuration.StoreAt; -import world.bentobox.bentobox.database.BBDbSetup.DatabaseType; +import world.bentobox.bentobox.database.DatabaseSetup.DatabaseType; import world.bentobox.bentobox.database.objects.DataObject; /** diff --git a/src/main/java/world/bentobox/bentobox/api/configuration/BBConfig.java b/src/main/java/world/bentobox/bentobox/api/configuration/Config.java similarity index 95% rename from src/main/java/world/bentobox/bentobox/api/configuration/BBConfig.java rename to src/main/java/world/bentobox/bentobox/api/configuration/Config.java index afdd86370..85d514a92 100644 --- a/src/main/java/world/bentobox/bentobox/api/configuration/BBConfig.java +++ b/src/main/java/world/bentobox/bentobox/api/configuration/Config.java @@ -17,17 +17,17 @@ import world.bentobox.bentobox.database.flatfile.FlatFileDatabase; * * @param */ -public class BBConfig { +public class Config { private AbstractDatabaseHandler handler; private Logger logger; - public BBConfig(BentoBox plugin, Class type) { + public Config(BentoBox plugin, Class type) { this.logger = plugin.getLogger(); handler = new FlatFileDatabase().getHandler(type); } - public BBConfig(Addon addon, Class type) { + public Config(Addon addon, Class type) { this.logger = addon.getLogger(); handler = new FlatFileDatabase().getHandler(type); } diff --git a/src/main/java/world/bentobox/bentobox/database/BBDatabase.java b/src/main/java/world/bentobox/bentobox/database/Database.java similarity index 92% rename from src/main/java/world/bentobox/bentobox/database/BBDatabase.java rename to src/main/java/world/bentobox/bentobox/database/Database.java index 78a704a8b..a50e5262b 100644 --- a/src/main/java/world/bentobox/bentobox/database/BBDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/Database.java @@ -15,20 +15,19 @@ import world.bentobox.bentobox.api.addons.Addon; * * @param */ -public class BBDatabase { +public class Database { private AbstractDatabaseHandler handler; private Logger logger; - public BBDatabase(BentoBox plugin, Class type) { + public Database(BentoBox plugin, Class type) { this.logger = plugin.getLogger(); - handler = BBDbSetup.getDatabase().getHandler(type); + handler = DatabaseSetup.getDatabase().getHandler(type); } - public BBDatabase(Addon addon, Class type) { + public Database(Addon addon, Class type) { this.logger = addon.getLogger(); - handler = BBDbSetup.getDatabase().getHandler(type); - + handler = DatabaseSetup.getDatabase().getHandler(type); } /** @@ -106,5 +105,4 @@ public class BBDatabase { handler.close(); } - } \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/database/BBDbSetup.java b/src/main/java/world/bentobox/bentobox/database/DatabaseSetup.java similarity index 88% rename from src/main/java/world/bentobox/bentobox/database/BBDbSetup.java rename to src/main/java/world/bentobox/bentobox/database/DatabaseSetup.java index 6d6813b76..03510c839 100644 --- a/src/main/java/world/bentobox/bentobox/database/BBDbSetup.java +++ b/src/main/java/world/bentobox/bentobox/database/DatabaseSetup.java @@ -5,14 +5,14 @@ import world.bentobox.bentobox.database.flatfile.FlatFileDatabase; import world.bentobox.bentobox.database.mongodb.MongoDBDatabase; import world.bentobox.bentobox.database.mysql.MySQLDatabase; -public abstract class BBDbSetup { +public abstract class DatabaseSetup { /** * Gets the type of database being used. Currently supported options are * FLATFILE and MYSQL. Default is FLATFILE * @return Database type */ - public static BBDbSetup getDatabase(){ + public static DatabaseSetup getDatabase(){ for(DatabaseType type : DatabaseType.values()){ if(type == BentoBox.getInstance().getSettings().getDatabaseType()) { return type.database; @@ -26,9 +26,9 @@ public abstract class BBDbSetup { MYSQL(new MySQLDatabase()), MONGO(new MongoDBDatabase()); - BBDbSetup database; + DatabaseSetup database; - DatabaseType(BBDbSetup database){ + DatabaseType(DatabaseSetup database){ this.database = database; } } diff --git a/src/main/java/world/bentobox/bentobox/database/flatfile/FlatFileDatabase.java b/src/main/java/world/bentobox/bentobox/database/flatfile/FlatFileDatabase.java index 437bb8ecb..0e7f764e0 100644 --- a/src/main/java/world/bentobox/bentobox/database/flatfile/FlatFileDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/flatfile/FlatFileDatabase.java @@ -2,9 +2,9 @@ package world.bentobox.bentobox.database.flatfile; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.database.AbstractDatabaseHandler; -import world.bentobox.bentobox.database.BBDbSetup; +import world.bentobox.bentobox.database.DatabaseSetup; -public class FlatFileDatabase extends BBDbSetup{ +public class FlatFileDatabase extends DatabaseSetup { /** * Get the config diff --git a/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java b/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java index 862bec5a9..3a0900b17 100644 --- a/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java @@ -2,10 +2,10 @@ package world.bentobox.bentobox.database.mongodb; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.database.AbstractDatabaseHandler; -import world.bentobox.bentobox.database.BBDbSetup; +import world.bentobox.bentobox.database.DatabaseSetup; import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl; -public class MongoDBDatabase extends BBDbSetup{ +public class MongoDBDatabase extends DatabaseSetup { @Override public AbstractDatabaseHandler getHandler(Class type) { diff --git a/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java b/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java index e044dc833..d28794a50 100644 --- a/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java @@ -2,10 +2,10 @@ package world.bentobox.bentobox.database.mysql; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.database.AbstractDatabaseHandler; -import world.bentobox.bentobox.database.BBDbSetup; +import world.bentobox.bentobox.database.DatabaseSetup; import world.bentobox.bentobox.database.DatabaseConnectionSettingsImpl; -public class MySQLDatabase extends BBDbSetup{ +public class MySQLDatabase extends DatabaseSetup { /* (non-Javadoc) diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index 101bba34e..8c2a9aeef 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -25,7 +25,7 @@ import org.bukkit.util.Vector; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.user.User; -import world.bentobox.bentobox.database.BBDatabase; +import world.bentobox.bentobox.database.Database; import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.lists.Flags; import world.bentobox.bentobox.managers.island.IslandCache; @@ -50,7 +50,7 @@ public class IslandsManager { */ private Map spawn; - private BBDatabase handler; + private Database handler; /** * The last locations where an island were put. @@ -73,7 +73,7 @@ public class IslandsManager { public IslandsManager(BentoBox plugin){ this.plugin = plugin; // Set up the database handler to store and retrieve Island classes - handler = new BBDatabase<>(plugin, Island.class); + handler = new Database<>(plugin, Island.class); islandCache = new IslandCache(); spawn = new HashMap<>(); last = new HashMap<>(); diff --git a/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java b/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java index 919d89dee..6f874e6d5 100644 --- a/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/PlayersManager.java @@ -14,15 +14,15 @@ import org.bukkit.World; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.user.User; -import world.bentobox.bentobox.database.BBDatabase; +import world.bentobox.bentobox.database.Database; import world.bentobox.bentobox.database.objects.Names; import world.bentobox.bentobox.database.objects.Players; public class PlayersManager { private BentoBox plugin; - private BBDatabase handler; - private BBDatabase names; + private Database handler; + private Database names; private Map playerCache; private Set inTeleport; @@ -37,9 +37,9 @@ public class PlayersManager { public PlayersManager(BentoBox plugin){ this.plugin = plugin; // Set up the database handler to store and retrieve Players classes - handler = new BBDatabase<>(plugin, Players.class); + handler = new Database<>(plugin, Players.class); // Set up the names database - names = new BBDatabase<>(plugin, Names.class); + names = new Database<>(plugin, Names.class); playerCache = new HashMap<>(); inTeleport = new HashSet<>(); } @@ -48,7 +48,7 @@ public class PlayersManager { * Used only for testing. Sets the database to a mock database. * @param handler - handler */ - public void setHandler(BBDatabase handler) { + public void setHandler(Database handler) { this.handler = handler; } diff --git a/src/test/java/world/bentobox/bentobox/managers/PlayersManagerTest.java b/src/test/java/world/bentobox/bentobox/managers/PlayersManagerTest.java index cab1488d9..21de84c2b 100644 --- a/src/test/java/world/bentobox/bentobox/managers/PlayersManagerTest.java +++ b/src/test/java/world/bentobox/bentobox/managers/PlayersManagerTest.java @@ -34,7 +34,7 @@ import org.powermock.reflect.Whitebox; import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.Settings; import world.bentobox.bentobox.api.user.User; -import world.bentobox.bentobox.database.BBDatabase; +import world.bentobox.bentobox.database.Database; import world.bentobox.bentobox.database.objects.Players; import world.bentobox.bentobox.util.Util; @@ -54,7 +54,7 @@ public class PlayersManagerTest { private World nether; private World end; @Mock - private BBDatabase db; + private Database db; /** * @throws java.lang.Exception