diff --git a/Plan/dependency-reduced-pom.xml b/Plan/dependency-reduced-pom.xml index c9091699d..550b82daf 100644 --- a/Plan/dependency-reduced-pom.xml +++ b/Plan/dependency-reduced-pom.xml @@ -115,6 +115,10 @@ paper-repo https://repo.destroystokyo.com/repository/maven-public/ + + sponge-repo + https://repo.spongepowered.org/maven + @@ -247,12 +251,80 @@ bungeecord-chat net.md-5 - - guava - com.google.guava - + + guava + com.google.guava + + + org.spongepowered + spongeapi + 7.0.0 + provided + + + error_prone_annotations + com.google.errorprone + + + guice + com.google.inject + + + caffeine + com.github.ben-manes.caffeine + + + guava + com.github.ben-manes.caffeine + + + plugin-meta + org.spongepowered + + + configurate-hocon + ninja.leaping.configurate + + + configurate-gson + ninja.leaping.configurate + + + configurate-yaml + ninja.leaping.configurate + + + flow-math + com.flowpowered + + + flow-noise + com.flowpowered + + + asm + org.ow2.asm + + + slf4j-api + org.slf4j + + + jsr305 + com.google.code.findbugs + + + gson + com.google.code.gson + + + guava + com.google.guava + + + org.mockito mockito-core diff --git a/Plan/pom.xml b/Plan/pom.xml index 64275bd3e..978f562bc 100644 --- a/Plan/pom.xml +++ b/Plan/pom.xml @@ -19,6 +19,10 @@ paper-repo https://repo.destroystokyo.com/repository/maven-public/ + + sponge-repo + https://repo.spongepowered.org/maven + @@ -62,6 +66,14 @@ jar provided + + + org.spongepowered + spongeapi + 7.0.0 + jar + provided + org.apache.commons diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java index 428930c45..0c32cafba 100644 --- a/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java +++ b/Plan/src/main/java/com/djrapitops/plan/PlanPlugin.java @@ -20,6 +20,7 @@ public interface PlanPlugin extends IPlugin { static PlanPlugin getInstance() { boolean bukkitAvailable = Check.isBukkitAvailable(); boolean bungeeAvailable = Check.isBungeeAvailable(); + boolean spongeAvailable = Check.isSpongeAvailable(); if (bukkitAvailable) { try { Plan instance = Plan.getInstance(); @@ -38,6 +39,15 @@ public interface PlanPlugin extends IPlugin { } catch (IllegalStateException ignored) { } } + if (spongeAvailable) { + try { + PlanSponge instance = PlanSponge.getInstance(); + if (instance != null) { + return instance; + } + } catch (IllegalStateException ignored) { + } + } throw new IllegalAccessError("Plugin instance not available"); } diff --git a/Plan/src/main/java/com/djrapitops/plan/PlanSponge.java b/Plan/src/main/java/com/djrapitops/plan/PlanSponge.java new file mode 100644 index 000000000..364a669cc --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/PlanSponge.java @@ -0,0 +1,143 @@ +package com.djrapitops.plan; + +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.SpongeSystem; +import com.djrapitops.plan.system.settings.locale.Locale; +import com.djrapitops.plan.system.settings.locale.Msg; +import com.djrapitops.plan.system.settings.theme.PlanColorScheme; +import com.djrapitops.plugin.SpongePlugin; +import com.djrapitops.plugin.StaticHolder; +import com.djrapitops.plugin.api.Benchmark; +import com.djrapitops.plugin.api.utility.log.DebugLog; +import com.djrapitops.plugin.api.utility.log.Log; +import com.djrapitops.plugin.settings.ColorScheme; +import com.google.inject.Inject; +import org.slf4j.Logger; +import org.spongepowered.api.config.ConfigDir; +import org.spongepowered.api.event.Listener; +import org.spongepowered.api.event.game.state.GameStartedServerEvent; +import org.spongepowered.api.event.game.state.GameStoppingServerEvent; +import org.spongepowered.api.plugin.Plugin; + +import java.io.File; +import java.io.InputStream; + +@Plugin(id = "plan", name = "Plan", version = "4.2.0") +public class PlanSponge extends SpongePlugin implements PlanPlugin { + + @Inject + private Logger logger; + + @Inject + @ConfigDir(sharedRoot = false) + private File dataFolder; + private SpongeSystem system; + + @Listener + public void onServerStart(GameStartedServerEvent event) { + onEnable(); + } + + @Listener + public void onServerStop(GameStoppingServerEvent event) { + onDisable(); + } + + public static PlanSponge getInstance() { + return (PlanSponge) StaticHolder.getInstance(PlanSponge.class); + } + + @Override + public void onEnable() { + super.onEnable(); + system = new SpongeSystem(this); + try { + system.enable(); + } catch (AbstractMethodError e) { + Log.error("Plugin ran into AbstractMethodError - Server restart is required. Likely cause is updating the jar without a restart."); + } catch (EnableException e) { + Log.error("----------------------------------------"); + Log.error("Error: " + e.getMessage()); + Log.error("----------------------------------------"); + Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload"); + onDisable(); + } catch (Exception e) { + Log.toLog(this.getClass().getSimpleName() + "-v" + getVersion(), e); + Log.error("Plugin Failed to Initialize Correctly. If this issue is caused by config settings you can use /plan reload"); + Log.error("This error should be reported at https://github.com/Rsl1122/Plan-PlayerAnalytics/issues"); + onDisable(); + } + } + + @Override + public void onDisable() { + if (system != null) { + system.disable(); + } + + Log.info(Locale.get(Msg.DISABLED).toString()); + Benchmark.pluginDisabled(PlanSponge.class); + DebugLog.pluginDisabled(PlanSponge.class); + } + + @Override + public InputStream getResource(String resource) { + return getClass().getResourceAsStream("/" + resource); + } + + @Override + public ColorScheme getColorScheme() { + return PlanColorScheme.create(); + } + + + @Override + public void onReload() { + + } + + @Override + public boolean isReloading() { + return false; + } + + @Override + public void log(String level, String msg) { + switch (level.toUpperCase()) { + case "INFO_COLOR": + case "INFO": + case "I": + logger.info(msg); + break; + case "W": + case "WARN": + case "WARNING": + logger.warn(msg); + break; + case "E": + case "ERR": + case "ERROR": + case "SEVERE": + logger.error(msg); + break; + default: + logger.info(msg); + break; + } + + } + + @Override + public File getDataFolder() { + return dataFolder; + } + + @Override + public String getVersion() { + return "4.2.0"; + } + + public SpongeSystem getSystem() { + return system; + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java index a249a3bc3..8a2798048 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java +++ b/Plan/src/main/java/com/djrapitops/plan/ShutdownHook.java @@ -14,7 +14,6 @@ import com.djrapitops.plan.system.cache.DataCache; import com.djrapitops.plan.system.cache.SessionCache; import com.djrapitops.plan.system.database.databases.Database; import com.djrapitops.plan.utilities.MiscUtils; -import com.djrapitops.plugin.StaticHolder; import com.djrapitops.plugin.api.utility.log.Log; import java.util.Map; @@ -70,7 +69,6 @@ public class ShutdownHook extends Thread { Log.toLog(this.getClass(), e); } } - StaticHolder.unRegister(Plan.class); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java b/Plan/src/main/java/com/djrapitops/plan/api/ServerAPI.java similarity index 61% rename from Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java rename to Plan/src/main/java/com/djrapitops/plan/api/ServerAPI.java index eb90022fa..1abe22bfd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/BukkitAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/ServerAPI.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.api; import com.djrapitops.plan.data.plugin.PluginData; -import com.djrapitops.plan.system.BukkitSystem; +import com.djrapitops.plan.system.ServerSystem; import com.djrapitops.plan.system.database.databases.operation.FetchOperations; import java.util.UUID; @@ -15,26 +15,26 @@ import java.util.UUID; * * @author Rsl1122 */ -public class BukkitAPI extends CommonAPI { +public class ServerAPI extends CommonAPI { - private final BukkitSystem bukkitSystem; + private final ServerSystem serverSystem; - public BukkitAPI(BukkitSystem bukkitSystem) { - this.bukkitSystem = bukkitSystem; + public ServerAPI(ServerSystem serverSystem) { + this.serverSystem = serverSystem; } @Override public void addPluginDataSource(PluginData pluginData) { - bukkitSystem.getHookHandler().addPluginDataSource(pluginData); + serverSystem.getHookHandler().addPluginDataSource(pluginData); } @Override public String getPlayerName(UUID uuid) { - return bukkitSystem.getCacheSystem().getDataCache().getName(uuid); + return serverSystem.getCacheSystem().getDataCache().getName(uuid); } @Override public FetchOperations fetchFromPlanDB() { - return bukkitSystem.getDatabaseSystem().getActiveDatabase().fetch(); + return serverSystem.getDatabaseSystem().getActiveDatabase().fetch(); } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java index af1f624e3..81a802a80 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/BukkitSystem.java @@ -6,7 +6,7 @@ package com.djrapitops.plan.system; import com.djrapitops.plan.Plan; import com.djrapitops.plan.ShutdownHook; -import com.djrapitops.plan.api.BukkitAPI; +import com.djrapitops.plan.api.ServerAPI; import com.djrapitops.plan.api.exceptions.EnableException; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.system.database.BukkitDBSystem; @@ -27,7 +27,7 @@ import com.djrapitops.plugin.api.utility.log.Log; * * @author Rsl1122 */ -public class BukkitSystem extends PlanSystem { +public class BukkitSystem extends PlanSystem implements ServerSystem { public BukkitSystem(Plan plugin) { testSystem = this; @@ -45,7 +45,7 @@ public class BukkitSystem extends PlanSystem { serverInfo = new BukkitServerInfo(plugin); hookHandler = new HookHandler(); - planAPI = new BukkitAPI(this); + planAPI = new ServerAPI(this); StaticHolder.saveInstance(ShutdownHook.class, plugin.getClass()); new ShutdownHook().register(); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java index 994942db5..d2a42788e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/PlanSystem.java @@ -63,12 +63,15 @@ public abstract class PlanSystem implements SubSystem { public static PlanSystem getInstance() { boolean bukkitAvailable = Check.isBukkitAvailable(); boolean bungeeAvailable = Check.isBungeeAvailable(); + boolean spongeAvailable = Check.isSpongeAvailable(); if (bukkitAvailable && bungeeAvailable) { return testSystem; } else if (bungeeAvailable) { return BungeeSystem.getInstance(); } else if (bukkitAvailable) { return BukkitSystem.getInstance(); + } else if (spongeAvailable) { + return SpongeSystem.getInstance(); } throw new IllegalAccessError("PlanSystem is not available on this platform."); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/ServerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/ServerSystem.java new file mode 100644 index 000000000..92829fb0a --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/ServerSystem.java @@ -0,0 +1,14 @@ +package com.djrapitops.plan.system; + +import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.plan.system.cache.CacheSystem; +import com.djrapitops.plan.system.database.DBSystem; + +public interface ServerSystem { + + HookHandler getHookHandler(); + + CacheSystem getCacheSystem(); + + DBSystem getDatabaseSystem(); +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/SpongeSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/SpongeSystem.java new file mode 100644 index 000000000..90169df5c --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/SpongeSystem.java @@ -0,0 +1,63 @@ +/* + * Licence is provided in the jar as license.yml also here: + * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml + */ +package com.djrapitops.plan.system; + +import com.djrapitops.plan.PlanSponge; +import com.djrapitops.plan.ShutdownHook; +import com.djrapitops.plan.api.ServerAPI; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.data.plugin.HookHandler; +import com.djrapitops.plan.system.database.BukkitDBSystem; +import com.djrapitops.plan.system.file.FileSystem; +import com.djrapitops.plan.system.info.BukkitInfoSystem; +import com.djrapitops.plan.system.info.server.SpongeServerInfo; +import com.djrapitops.plan.system.listeners.SpongeListenerSystem; +import com.djrapitops.plan.system.settings.PlanErrorManager; +import com.djrapitops.plan.system.settings.config.BukkitConfigSystem; +import com.djrapitops.plan.system.settings.network.NetworkSettings; +import com.djrapitops.plan.system.tasks.SpongeTaskSystem; +import com.djrapitops.plan.system.update.VersionCheckSystem; +import com.djrapitops.plugin.StaticHolder; +import com.djrapitops.plugin.api.utility.log.Log; + +/** + * Represents PlanSystem for PlanSponge. + * + * @author Rsl1122 + */ +public class SpongeSystem extends PlanSystem implements ServerSystem { + + public SpongeSystem(PlanSponge plugin) { + testSystem = this; + + Log.setErrorManager(new PlanErrorManager()); + + versionCheckSystem = new VersionCheckSystem(plugin.getVersion()); + fileSystem = new FileSystem(plugin); + configSystem = new BukkitConfigSystem(); + databaseSystem = new BukkitDBSystem(); + listenerSystem = new SpongeListenerSystem(); + taskSystem = new SpongeTaskSystem(); + + infoSystem = new BukkitInfoSystem(); + serverInfo = new SpongeServerInfo(); + + hookHandler = new HookHandler(); + planAPI = new ServerAPI(this); + + StaticHolder.saveInstance(ShutdownHook.class, plugin.getClass()); + new ShutdownHook().register(); + } + + public static SpongeSystem getInstance() { + return PlanSponge.getInstance().getSystem(); + } + + @Override + public void enable() throws EnableException { + super.enable(); + NetworkSettings.loadSettingsFromDB(); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfo.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfo.java index 7bcaa5d46..ec40a54c4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfo.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/BukkitServerInfo.java @@ -29,6 +29,9 @@ public class BukkitServerInfo extends ServerInfo { private ServerInfoFile serverInfoFile; private Database database; + BukkitServerInfo() { + } + public BukkitServerInfo(Plan plugin) { serverProperties = new ServerProperties(plugin.getServer()); } diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java index ad62df6a3..321a427c8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/ServerProperties.java @@ -3,6 +3,7 @@ package com.djrapitops.plan.system.info.server; import com.djrapitops.plan.system.settings.Settings; import net.md_5.bungee.api.ProxyServer; import org.bukkit.Server; +import org.spongepowered.api.Game; /** * Class responsible for holding server variable values that do not change @@ -49,6 +50,22 @@ public class ServerProperties { onlinePlayers = server::getOnlineCount; } + public ServerProperties(Game game) { + if (game == null) { + throw new IllegalStateException("Game did not inject."); + } + version = game.getPlatform().getMinecraftVersion().getName(); + ip = () -> game.getServer().getBoundAddress().get().getAddress().getHostAddress(); + name = "Sponge"; + port = game.getServer().getBoundAddress().get().getPort(); + implVersion = version; + + id = game.getServer().getMotd().toPlain(); + + maxPlayers = game.getServer().getMaxPlayers(); + onlinePlayers = () -> game.getServer().getOnlinePlayers().size(); + } + /** * Ip string in server.properties. * diff --git a/Plan/src/main/java/com/djrapitops/plan/system/info/server/SpongeServerInfo.java b/Plan/src/main/java/com/djrapitops/plan/system/info/server/SpongeServerInfo.java new file mode 100644 index 000000000..650cd88ab --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/info/server/SpongeServerInfo.java @@ -0,0 +1,10 @@ +package com.djrapitops.plan.system.info.server; + +import org.spongepowered.api.Sponge; + +public class SpongeServerInfo extends BukkitServerInfo { + + public SpongeServerInfo() { + serverProperties = new ServerProperties(Sponge.getGame()); + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/listeners/SpongeListenerSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/listeners/SpongeListenerSystem.java new file mode 100644 index 000000000..793df78a4 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/listeners/SpongeListenerSystem.java @@ -0,0 +1,14 @@ +package com.djrapitops.plan.system.listeners; + +public class SpongeListenerSystem extends ListenerSystem { + + @Override + protected void registerListeners() { + + } + + @Override + protected void unregisterListeners() { + + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/tasks/SpongeTaskSystem.java b/Plan/src/main/java/com/djrapitops/plan/system/tasks/SpongeTaskSystem.java new file mode 100644 index 000000000..f6f9832f1 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/tasks/SpongeTaskSystem.java @@ -0,0 +1,9 @@ +package com.djrapitops.plan.system.tasks; + +public class SpongeTaskSystem extends TaskSystem { + + @Override + public void enable() { + + } +} diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java index 2e7b7ee2b..1b9e2a5b5 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java @@ -27,7 +27,6 @@ public class AnalysisPageResponse extends Response { } catch (NoServersException | ConnectionFailException e) { ResponseCache.cacheResponse(PageId.SERVER.of(serverUUID), () -> new NotFoundResponse(e.getMessage())); } catch (WebException e) { - // TODO Exception handling Log.toLog(AnalysisPageResponse.class.getName(), e); } }); diff --git a/Plan/src/test/java/com/djrapitops/plan/system/SpongeSystemTest.java b/Plan/src/test/java/com/djrapitops/plan/system/SpongeSystemTest.java new file mode 100644 index 000000000..c9fc27926 --- /dev/null +++ b/Plan/src/test/java/com/djrapitops/plan/system/SpongeSystemTest.java @@ -0,0 +1,60 @@ +/* + * Licence is provided in the jar as license.yml also here: + * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml + */ +package com.djrapitops.plan.system; + +import com.djrapitops.plan.PlanSponge; +import com.djrapitops.plan.api.exceptions.EnableException; +import com.djrapitops.plan.system.settings.Settings; +import org.junit.*; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.Teardown; +import utilities.mocks.SpongeMockUtil; + +/** + * Test for BukkitSystem. + * + * @author Rsl1122 + */ +@RunWith(MockitoJUnitRunner.Silent.class) +public class SpongeSystemTest { + + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + private static PlanSponge planMock; + private SpongeSystem spongeSystem; + + @BeforeClass + public static void setUpClass() throws Exception { + SpongeMockUtil mockUtil = SpongeMockUtil.setUp() + .withDataFolder(temporaryFolder.getRoot()) + .withLogging() + .withResourceFetchingFromJar(); + planMock = mockUtil.getPlanMock(); + } + + @Before + public void setUp() { + Teardown.resetSettingsTempValues(); + } + + @After + public void tearDown() { + if (spongeSystem != null) { + spongeSystem.disable(); + } + Teardown.resetSettingsTempValues(); + } + + @Test + @Ignore("Sponge mock required") + public void testEnable() throws EnableException { + Settings.WEBSERVER_PORT.setTemporaryValue(9000); + + spongeSystem = new SpongeSystem(planMock); + spongeSystem.enable(); + } +} \ No newline at end of file diff --git a/Plan/src/test/java/utilities/mocks/SpongeMockUtil.java b/Plan/src/test/java/utilities/mocks/SpongeMockUtil.java new file mode 100644 index 000000000..af97d0555 --- /dev/null +++ b/Plan/src/test/java/utilities/mocks/SpongeMockUtil.java @@ -0,0 +1,73 @@ +/* + * Licence is provided in the jar as license.yml also here: + * https://github.com/Rsl1122/Plan-PlayerAnalytics/blob/master/Plan/src/main/resources/license.yml + */ +package utilities.mocks; + +import com.djrapitops.plan.PlanSponge; +import com.djrapitops.plugin.StaticHolder; +import com.djrapitops.plugin.task.RunnableFactory; +import com.djrapitops.plugin.task.ThreadRunnable; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import utilities.Teardown; + +import java.io.File; + +import static org.mockito.Mockito.*; + +/** + * Mocking Utility for Sponge version of Plan. + * + * @author Rsl1122 + */ +public class SpongeMockUtil extends MockUtil { + + private PlanSponge planMock; + + private SpongeMockUtil() { + } + + public static SpongeMockUtil setUp() { + RunnableFactory.activateTestMode(); + Teardown.resetSettingsTempValues(); + return new SpongeMockUtil().mockPlugin(); + } + + private SpongeMockUtil mockPlugin() { + planMock = Mockito.mock(PlanSponge.class); + super.planMock = planMock; + StaticHolder.register(PlanSponge.class, planMock); + StaticHolder.register(planMock); + + StaticHolder.saveInstance(MockitoJUnitRunner.class, PlanSponge.class); + StaticHolder.saveInstance(ThreadRunnable.class, PlanSponge.class); + + doReturn("4.2.0").when(planMock).getVersion(); + doCallRealMethod().when(planMock).getColorScheme(); + + return this; + } + + public SpongeMockUtil withDataFolder(File tempFolder) { + when(planMock.getDataFolder()).thenReturn(tempFolder); + return this; + } + + public SpongeMockUtil withLogging() { + doNothing().when(planMock).log(Mockito.anyString(), Mockito.anyString()); +// TestLogger testLogger = new TestLogger(); +// doReturn(testLogger).when(planMock).(); + return this; + } + + + public SpongeMockUtil withResourceFetchingFromJar() throws Exception { + withPluginFiles(); + return this; + } + + public PlanSponge getPlanMock() { + return planMock; + } +} \ No newline at end of file