mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
[WIP] Start breakout of mcmmo plugin
This commit starts work on the seperation of mcmmo and platform logic, there is still a fair amount of work to go before this will compile, down the line (potentially much further), bukkit logic will be stripped out of -core
This commit is contained in:
parent
1fbcf698c6
commit
eee09d8d76
@ -0,0 +1,4 @@
|
||||
package com.gmail.nossr50.mcmmo.api;
|
||||
|
||||
public interface McMMOApi {
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.gmail.nossr50.mcmmo.api.platform;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public interface PlatformProvider {
|
||||
|
||||
Logger getLogger();
|
||||
|
||||
void tearDown();
|
||||
}
|
44
mcmmo-bukkit/build.gradle.kts
Normal file
44
mcmmo-bukkit/build.gradle.kts
Normal file
@ -0,0 +1,44 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
id("com.github.johnrengelman.shadow") version "5.1.0"
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependencies {
|
||||
include(dependency("org.bstats:bstats-bukkit"))
|
||||
exclude(dependency("org.spigotmc:spigot"))
|
||||
}
|
||||
relocate("org.apache.commons.logging", "com.gmail.nossr50.commons.logging")
|
||||
relocate("org.apache.juli", "com.gmail.nossr50.database.tomcat.juli")
|
||||
relocate("org.apache.tomcat", "com.gmail.nossr50.database.tomcat")
|
||||
relocate("org.bstats", "com.gmail.nossr50.metrics.bstat")
|
||||
}
|
||||
|
||||
processResources {
|
||||
filter<ReplaceTokens>("tokens" to mapOf("project.version" to project.version))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
api(project(":mcmmo-api"))
|
||||
implementation(project(":mcmmo-core"))
|
||||
|
||||
api("org.apache.tomcat:tomcat-jdbc:7.0.52")
|
||||
implementation("org.jetbrains:annotations:17.0.0")
|
||||
implementation("org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1")
|
||||
implementation("org.bstats:bstats-bukkit:1.4")
|
||||
implementation("org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT")
|
||||
implementation("com.sk89q.worldguard:worldguard-legacy:7.0.0-SNAPSHOT")
|
||||
testImplementation("junit:junit:4.10")
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
package com.gmail.nossr50.mcmmo.bukkit;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.mcmmo.api.platform.PlatformProvider;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class BukkitBoostrap extends JavaPlugin implements PlatformProvider {
|
||||
|
||||
private mcMMO core = new mcMMO(this);
|
||||
|
||||
@Override
|
||||
public @NotNull Logger getLogger() {
|
||||
return super.getLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() {
|
||||
core.debug("Canceling all tasks...");
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
core.debug("Unregister all events...");
|
||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||
}
|
||||
}
|
@ -16,6 +16,8 @@ import com.gmail.nossr50.database.DatabaseManagerFactory;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
|
||||
import com.gmail.nossr50.listeners.*;
|
||||
import com.gmail.nossr50.locale.LocaleManager;
|
||||
import com.gmail.nossr50.mcmmo.api.McMMOApi;
|
||||
import com.gmail.nossr50.mcmmo.api.platform.PlatformProvider;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||
import com.gmail.nossr50.runnables.backups.CleanBackupFilesTask;
|
||||
@ -65,8 +67,9 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
public class mcMMO implements McMMOApi {
|
||||
/* Managers */
|
||||
private ChunkManager placeStore;
|
||||
private ConfigManager configManager;
|
||||
@ -123,18 +126,23 @@ public class mcMMO extends JavaPlugin {
|
||||
// XP Event Check
|
||||
private boolean xpEventEnabled;
|
||||
|
||||
private PlatformProvider platformProvider;
|
||||
|
||||
public mcMMO(PlatformProvider platformProvider) {
|
||||
this.platformProvider = platformProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Things to be run when the plugin is enabled.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
getLogger().setFilter(new LogFilter(this));
|
||||
platformProvider.getLogger().setFilter(new LogFilter(this));
|
||||
|
||||
//TODO: Disgusting...
|
||||
MetadataConstants.metadataValue = new FixedMetadataValue(this, true);
|
||||
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
PluginManager pluginManager = platformProvider.getServer().getPluginManager();
|
||||
healthBarPluginEnabled = pluginManager.getPlugin("HealthBar") != null;
|
||||
|
||||
//Init Permission Tools
|
||||
@ -299,7 +307,6 @@ public class mcMMO extends JavaPlugin {
|
||||
perkUtils = new PerkUtils(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
if(getServer().getPluginManager().getPlugin("WorldGuard") != null) {
|
||||
@ -316,7 +323,6 @@ public class mcMMO extends JavaPlugin {
|
||||
/**
|
||||
* Things to be run when the plugin is disabled.
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
try {
|
||||
userManager.saveAll(); // Make sure to save player information if the server shuts down
|
||||
@ -333,10 +339,7 @@ public class mcMMO extends JavaPlugin {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
debug("Canceling all tasks...");
|
||||
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
||||
debug("Unregister all events...");
|
||||
HandlerList.unregisterAll(this); // Cancel event registrations
|
||||
platformProvider.tearDown();
|
||||
|
||||
if (getConfigManager().getConfigAutomatedBackups().isZipBackupsEnabled()) {
|
||||
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
@ -568,6 +571,10 @@ public class mcMMO extends JavaPlugin {
|
||||
getLogger().info("[Debug] " + message);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Logger getLogger() {
|
||||
return platformProvider.getLogger();
|
||||
}
|
||||
/**
|
||||
* Setup the various storage file paths
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
rootProject.name= 'mcMMO'
|
||||
include 'mcmmo-core'
|
||||
include 'mcmmo-api'
|
||||
|
||||
include 'mcmmo-bukkit'
|
||||
|
Loading…
Reference in New Issue
Block a user