PlatformManager to manage the platform adapters

This commit is contained in:
nossr50 2019-10-30 14:38:02 -07:00
parent bf94073935
commit fdb900ec5d
4 changed files with 44 additions and 8 deletions

View File

@ -0,0 +1,34 @@
package com.gmail.nossr50.core;
import com.gmail.nossr50.core.adapters.NMS_114.BukkitPlatformAdapter;
import com.gmail.nossr50.core.adapters.PlatformAdapter;
import com.gmail.nossr50.mcMMO;
public class PlatformManager {
private PlatformAdapter platformAdapter;
private mcMMO pluginRef;
public PlatformManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;
initAdapters();
}
/**
* Initialize the adapters based on the current platform
*/
private void initAdapters() {
pluginRef.getLogger().info("Initializing platform adapters...");
//Determine which platform we are on and load the correct adapter
//For now this will be hardcoded for testing purposes
platformAdapter = new BukkitPlatformAdapter();
}
/**
* Get the current platform adapter implementation
* @return the current platform adapter
*/
public PlatformAdapter getPlatformAdapter() {
return platformAdapter;
}
}

View File

@ -1,10 +1,9 @@
package com.gmail.nossr50.core.adapters.NMS_114;
import com.gmail.nossr50.core.adapters.NBTAdapter;
import com.gmail.nossr50.core.nbt.*;
import com.gmail.nossr50.core.nbt.NBTBase;
import com.gmail.nossr50.core.nbt.NBTList;
import com.gmail.nossr50.core.nbt.NBTCompound;
import com.gmail.nossr50.core.nbt.*;
import net.minecraft.server.v1_14_R1.*;
public class BukkitNBTAdapter implements NBTAdapter {

View File

@ -1,10 +1,6 @@
package com.gmail.nossr50.core.adapters.NMS_114;
import com.gmail.nossr50.core.adapters.NBTAdapter;
import com.gmail.nossr50.core.adapters.PlatformAdapter;
import com.gmail.nossr50.core.nbt.NBTBase;
import com.gmail.nossr50.core.nbt.NBTByte;
import net.minecraft.server.v1_14_R1.NBTTagByte;
public class BukkitPlatformAdapter extends PlatformAdapter {
@ -12,6 +8,4 @@ public class BukkitPlatformAdapter extends PlatformAdapter {
super(new BukkitNBTAdapter());
}
}

View File

@ -11,6 +11,7 @@ import com.gmail.nossr50.config.scoreboard.ConfigScoreboard;
import com.gmail.nossr50.core.DynamicSettingsManager;
import com.gmail.nossr50.core.MaterialMapStore;
import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.core.PlatformManager;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
@ -86,6 +87,7 @@ public class mcMMO extends JavaPlugin {
private ScoreboardManager scoreboardManager;
private SoundManager soundManager;
private HardcoreManager hardcoreManager;
private PlatformManager platformManager;
/* Not-Managers but my naming scheme sucks */
private DatabaseManagerFactory databaseManagerFactory;
@ -132,6 +134,9 @@ public class mcMMO extends JavaPlugin {
try {
getLogger().setFilter(new LogFilter(this));
//Init PlatformManager
platformManager = new PlatformManager(this);
//TODO: Disgusting...
MetadataConstants.metadataValue = new FixedMetadataValue(this, true);
@ -862,4 +867,8 @@ public class mcMMO extends JavaPlugin {
public NBTManager getNbtManager() {
return nbtManager;
}
public PlatformManager getPlatformManager() {
return platformManager;
}
}