mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Part 1 of removing some bad design patterns
This commit is contained in:
parent
1c9e5ba542
commit
6504e06b5f
@ -39,7 +39,6 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
|
||||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -54,33 +53,32 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class mcMMO extends JavaPlugin {
|
public class mcMMO extends JavaPlugin {
|
||||||
public static mcMMO p;
|
|
||||||
// Jar Stuff
|
// Jar Stuff
|
||||||
public static File mcMMOFile;
|
private File mcMMOFile;
|
||||||
/* Managers */
|
/* Managers */
|
||||||
private static ChunkManager placeStore;
|
private ChunkManager placeStore;
|
||||||
private static ConfigManager configManager;
|
private ConfigManager configManager;
|
||||||
private static DynamicSettingsManager dynamicSettingsManager;
|
private DynamicSettingsManager dynamicSettingsManager;
|
||||||
private static DatabaseManager databaseManager;
|
private DatabaseManager databaseManager;
|
||||||
private static FormulaManager formulaManager;
|
private FormulaManager formulaManager;
|
||||||
private static MaterialMapStore materialMapStore;
|
private MaterialMapStore materialMapStore;
|
||||||
private static PlayerLevelUtils playerLevelUtils;
|
private PlayerLevelUtils playerLevelUtils;
|
||||||
private static NotificationManager notificationManager;
|
private NotificationManager notificationManager;
|
||||||
private static CommandRegistrationManager commandRegistrationManager;
|
private CommandRegistrationManager commandRegistrationManager;
|
||||||
private static NBTManager nbtManager;
|
private NBTManager nbtManager;
|
||||||
private static WorldGuardManager worldGuardManager;
|
private WorldGuardManager worldGuardManager;
|
||||||
|
|
||||||
/* File Paths */
|
/* File Paths */
|
||||||
private static String mainDirectory;
|
private String mainDirectory;
|
||||||
private static String localesDirectory;
|
private String localesDirectory;
|
||||||
private static String flatFileDirectory;
|
private String flatFileDirectory;
|
||||||
private static String usersFile;
|
private String usersFile;
|
||||||
private static String modDirectory;
|
private String modDirectory;
|
||||||
|
|
||||||
/* Plugin Checks */
|
/* Plugin Checks */
|
||||||
private static boolean healthBarPluginEnabled;
|
private boolean healthBarPluginEnabled;
|
||||||
// API checks
|
// API checks
|
||||||
private static boolean serverAPIOutdated = false;
|
private boolean serverAPIOutdated = false;
|
||||||
// XP Event Check
|
// XP Event Check
|
||||||
private boolean xpEventEnabled;
|
private boolean xpEventEnabled;
|
||||||
/**
|
/**
|
||||||
@ -89,13 +87,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
try {
|
try {
|
||||||
p = this;
|
|
||||||
getLogger().setFilter(new LogFilter(this));
|
getLogger().setFilter(new LogFilter(this));
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
/*getLogger().info(Bukkit.getBukkitVersion());
|
|
||||||
getLogger().info(Bukkit.getVersion());*/
|
|
||||||
|
|
||||||
MetadataConstants.metadataValue = new FixedMetadataValue(this, true);
|
MetadataConstants.metadataValue = new FixedMetadataValue(this, true);
|
||||||
|
|
||||||
PluginManager pluginManager = getServer().getPluginManager();
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
@ -253,7 +246,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
debug("Was disabled."); // How informative!
|
debug("Was disabled."); // How informative!
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerLevelUtils getPlayerLevelUtils() {
|
public PlayerLevelUtils getPlayerLevelUtils() {
|
||||||
return playerLevelUtils;
|
return playerLevelUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,52 +281,52 @@ public class mcMMO extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MaterialMapStore getMaterialMapStore() {
|
public MaterialMapStore getMaterialMapStore() {
|
||||||
return materialMapStore;
|
return materialMapStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getMainDirectory() {
|
public String getMainDirectory() {
|
||||||
return mainDirectory;
|
return mainDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFlatFileDirectory() {
|
public String getFlatFileDirectory() {
|
||||||
return flatFileDirectory;
|
return flatFileDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUsersFilePath() {
|
public String getUsersFilePath() {
|
||||||
return usersFile;
|
return usersFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getModDirectory() {
|
public String getModDirectory() {
|
||||||
return modDirectory;
|
return modDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FormulaManager getFormulaManager() {
|
public FormulaManager getFormulaManager() {
|
||||||
return formulaManager;
|
return formulaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChunkManager getPlaceStore() {
|
public ChunkManager getPlaceStore() {
|
||||||
return placeStore;
|
return placeStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RepairableManager getRepairableManager() {
|
public RepairableManager getRepairableManager() {
|
||||||
return dynamicSettingsManager.getRepairableManager();
|
return dynamicSettingsManager.getRepairableManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SalvageableManager getSalvageableManager() {
|
public SalvageableManager getSalvageableManager() {
|
||||||
return dynamicSettingsManager.getSalvageableManager();
|
return dynamicSettingsManager.getSalvageableManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DatabaseManager getDatabaseManager() {
|
public DatabaseManager getDatabaseManager() {
|
||||||
return databaseManager;
|
return databaseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NBTManager getNbtManager() {
|
public NBTManager getNbtManager() {
|
||||||
return nbtManager;
|
return nbtManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void setDatabaseManager(DatabaseManager newDatabaseManager) {
|
public void setDatabaseManager(DatabaseManager newDatabaseManager) {
|
||||||
databaseManager = newDatabaseManager;
|
databaseManager = newDatabaseManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +335,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return settings for MySQL from the users config
|
* @return settings for MySQL from the users config
|
||||||
*/
|
*/
|
||||||
public static ConfigSectionMySQL getMySQLConfigSettings() {
|
public ConfigSectionMySQL getMySQLConfigSettings() {
|
||||||
return configManager.getConfigDatabase().getConfigSectionMySQL();
|
return configManager.getConfigDatabase().getConfigSectionMySQL();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +344,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return settings for Player Leveling from the users config
|
* @return settings for Player Leveling from the users config
|
||||||
*/
|
*/
|
||||||
public static ConfigLeveling getPlayerLevelingSettings() {
|
public ConfigLeveling getPlayerLevelingSettings() {
|
||||||
return configManager.getConfigLeveling();
|
return configManager.getConfigLeveling();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,7 +353,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return settings for Database cleaning from the users config
|
* @return settings for Database cleaning from the users config
|
||||||
*/
|
*/
|
||||||
public static ConfigSectionCleaning getDatabaseCleaningSettings() {
|
public ConfigSectionCleaning getDatabaseCleaningSettings() {
|
||||||
return configManager.getConfigDatabase().getConfigSectionCleaning();
|
return configManager.getConfigDatabase().getConfigSectionCleaning();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +362,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return settings for the Party XP sharing from the users config
|
* @return settings for the Party XP sharing from the users config
|
||||||
*/
|
*/
|
||||||
public static ConfigSectionPartyExperienceSharing getPartyXPShareSettings() {
|
public ConfigSectionPartyExperienceSharing getPartyXPShareSettings() {
|
||||||
return configManager.getConfigParty().getPartyXP().getPartyExperienceSharing();
|
return configManager.getConfigParty().getPartyXP().getPartyExperienceSharing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +371,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return settings for the Party Leveling from the users config
|
* @return settings for the Party Leveling from the users config
|
||||||
*/
|
*/
|
||||||
public static ConfigSectionPartyLevel getPartyLevelSettings() {
|
public ConfigSectionPartyLevel getPartyLevelSettings() {
|
||||||
return configManager.getConfigParty().getPartyXP().getPartyLevel();
|
return configManager.getConfigParty().getPartyXP().getPartyLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,15 +380,11 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return settings for Scoreboards from the users config
|
* @return settings for Scoreboards from the users config
|
||||||
*/
|
*/
|
||||||
public static ConfigScoreboard getScoreboardSettings() {
|
public ConfigScoreboard getScoreboardSettings() {
|
||||||
return configManager.getConfigScoreboard();
|
return configManager.getConfigScoreboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static HolidayManager getHolidayManager() {
|
public boolean isHealthBarPluginEnabled() {
|
||||||
return holidayManager;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static boolean isHealthBarPluginEnabled() {
|
|
||||||
return healthBarPluginEnabled;
|
return healthBarPluginEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,11 +395,11 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return true if retro mode is enabled
|
* @return true if retro mode is enabled
|
||||||
*/
|
*/
|
||||||
public static boolean isRetroModeEnabled() {
|
public boolean isRetroModeEnabled() {
|
||||||
return configManager.isRetroMode();
|
return configManager.isRetroMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigManager getConfigManager() {
|
public ConfigManager getConfigManager() {
|
||||||
return configManager;
|
return configManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,7 +408,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* @return the override locale directory
|
* @return the override locale directory
|
||||||
*/
|
*/
|
||||||
public static String getLocalesDirectory() {
|
public String getLocalesDirectory() {
|
||||||
return localesDirectory;
|
return localesDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,14 +421,6 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return xpEventEnabled;
|
return xpEventEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static ModManager getModManager() {
|
|
||||||
return modManager;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*public static UpgradeManager getUpgradeManager() {
|
|
||||||
return upgradeManager;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the xpEventEnabled boolean
|
* Sets the xpEventEnabled boolean
|
||||||
*
|
*
|
||||||
@ -494,12 +475,11 @@ public class mcMMO extends JavaPlugin {
|
|||||||
localesDirectoryPath.mkdirs();
|
localesDirectoryPath.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Effectively this reloads mcMMO, making it go through the disabled, load, and enable step
|
||||||
|
* Used with the new mcmmo-reload command
|
||||||
|
*/
|
||||||
public void reload() {
|
public void reload() {
|
||||||
// loadConfigFiles();
|
|
||||||
// registerDynamicSettings(); //Do this after config
|
|
||||||
//
|
|
||||||
// databaseManager = DatabaseManagerFactory.getDatabaseManager();
|
|
||||||
|
|
||||||
onDisable();
|
onDisable();
|
||||||
onLoad();
|
onLoad();
|
||||||
onEnable();
|
onEnable();
|
||||||
@ -535,13 +515,13 @@ public class mcMMO extends JavaPlugin {
|
|||||||
* Acrobatics skills
|
* Acrobatics skills
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (mcMMO.getConfigManager().getConfigCoreSkills().isAcrobaticsEnabled()) {
|
if (configManager.getConfigCoreSkills().isAcrobaticsEnabled()) {
|
||||||
InteractionManager.initMaps(); //Init maps
|
InteractionManager.initMaps(); //Init maps
|
||||||
|
|
||||||
System.out.println("[mcMMO]" + " enabling Acrobatics Skills");
|
System.out.println("[mcMMO]" + " enabling Acrobatics Skills");
|
||||||
|
|
||||||
//TODO: Should do this differently
|
//TODO: Should do this differently
|
||||||
if (mcMMO.getConfigManager().getConfigCoreSkills().isRollEnabled()) {
|
if (configManager.getConfigCoreSkills().isRollEnabled()) {
|
||||||
InteractionManager.registerSubSkill(new Roll());
|
InteractionManager.registerSubSkill(new Roll());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -549,7 +529,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
private void registerCustomRecipes() {
|
private void registerCustomRecipes() {
|
||||||
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||||
if (mcMMO.getConfigManager().getConfigItems().isChimaeraWingEnabled()) {
|
if (configManager.getConfigItems().isChimaeraWingEnabled()) {
|
||||||
Recipe recipe = ChimaeraWing.getChimaeraWingRecipe();
|
Recipe recipe = ChimaeraWing.getChimaeraWingRecipe();
|
||||||
|
|
||||||
if(!SkillUtils.hasRecipeBeenRegistered(recipe))
|
if(!SkillUtils.hasRecipeBeenRegistered(recipe))
|
||||||
@ -603,7 +583,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DynamicSettingsManager getDynamicSettingsManager() {
|
public DynamicSettingsManager getDynamicSettingsManager() {
|
||||||
return dynamicSettingsManager;
|
return dynamicSettingsManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,11 +593,11 @@ public class mcMMO extends JavaPlugin {
|
|||||||
CRAFTBUKKIT
|
CRAFTBUKKIT
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NotificationManager getNotificationManager() {
|
public NotificationManager getNotificationManager() {
|
||||||
return notificationManager;
|
return notificationManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldGuardManager getWorldGuardManager() {
|
public WorldGuardManager getWorldGuardManager() {
|
||||||
return worldGuardManager;
|
return worldGuardManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public final class CommandRegistrationManager {
|
public final class CommandRegistrationManager {
|
||||||
private mcMMO pluginRef;
|
private mcMMO pluginRef;
|
||||||
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
private String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||||
|
|
||||||
public CommandRegistrationManager(mcMMO pluginRef) {
|
public CommandRegistrationManager(mcMMO pluginRef) {
|
||||||
this.pluginRef = pluginRef;
|
this.pluginRef = pluginRef;
|
||||||
|
Loading…
Reference in New Issue
Block a user