Files
src
build.gradle
manifest.kod
README_INTEGRATION.md
Code
22 1,374
src/main/java/com/playerprofilecache/PlayerProfileCache.java
package com.playerprofilecache;
import com.playerprofilecache.api.ProfileCacheAPI;
import com.playerprofilecache.cache.ProfileCacheManager;
import com.playerprofilecache.commands.ProfileCacheCommand;
import com.playerprofilecache.config.ConfigManager;
import com.playerprofilecache.inventory.gui.GUIListener;
import com.playerprofilecache.inventory.gui.GUIManager;
import com.playerprofilecache.listeners.PlayerJoinListener;
import com.playerprofilecache.storage.StorageManager;
import lombok.Getter;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class PlayerProfileCache extends JavaPlugin {
private ConfigManager configManager;
private StorageManager storageManager;
private ProfileCacheManager cacheManager;
private ProfileCacheAPI api;
private GUIManager guiManager;
@Override
public void onEnable() {
this.configManager = new ConfigManager(this);
configManager.loadConfig();
this.storageManager = new StorageManager(this);
this.cacheManager = new ProfileCacheManager(this);
storageManager.loadProfiles();
this.api = new ProfileCacheAPI(cacheManager, this);
getServer().getServicesManager().register(ProfileCacheAPI.class, api, this, ServicePriority.Normal);
this.guiManager = new GUIManager();
getServer().getPluginManager().registerEvents(new GUIListener(guiManager), this);
getCommand("profilecache").setExecutor(new ProfileCacheCommand(this));
getServer().getPluginManager().registerEvents(new PlayerJoinListener(this), this);
cacheManager.startAutoRefresh();
storageManager.startAutoSave();
getLogger().info("PlayerProfileCache enabled! Loaded " + cacheManager.getCacheSize() + " profiles.");
}
@Override
public void onDisable() {
if (cacheManager != null) {
cacheManager.stopAutoRefresh();
}
if (storageManager != null) {
storageManager.stopAutoSave();
storageManager.saveProfiles();
}
getLogger().info("PlayerProfileCache disabled! Saved " + cacheManager.getCacheSize() + " profiles.");
}
}