Package com.ranull.graves
Class Graves
java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
com.ranull.graves.Graves
- All Implemented Interfaces:
org.bukkit.command.CommandExecutor
,org.bukkit.command.TabCompleter
,org.bukkit.command.TabExecutor
,org.bukkit.plugin.Plugin
public class Graves
extends org.bukkit.plugin.java.JavaPlugin
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BlockManager
private CacheManager
private Compatibility
private DataManager
private EntityDataManager
private EntityManager
private org.bukkit.configuration.file.FileConfiguration
private GraveManager
private static com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler
private GUIManager
private HologramManager
private ImportManager
private IntegrationManager
private boolean
private boolean
private boolean
private ItemStackManager
private LocationManager
private ParticleManager
private RecipeManager
private VersionManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
backupOutdatedConfigs
(double configVersion) Backs up old configuration files to the "outdated" directory, appending the current config version to their filenames.private void
bakeDefaults
(org.bukkit.configuration.file.FileConfiguration fileConfiguration) Forces default values to be copied and applied in the configuration.private int
compareVersions
(String version1, String version2) Compares two semantic version strings (e.g., "1.16.5" vs. "1.18").private void
Checks for server and version compatibility, and sets the appropriate compatibility handler depending on whether the server supportsBlockData
.void
compatibilityMessage
(String string) Logs a compatibility-related warning message to the console.void
debugMessage
(String string, int level) void
dumpServerInfo
(org.bukkit.command.CommandSender commandSender) Dumps server and plugin-related debug information and provides the result either as a remote URL (via mclogs or hastebin) or saves it locally if upload fails.@NotNull org.bukkit.configuration.file.FileConfiguration
org.bukkit.configuration.ConfigurationSection
Gets a configuration section based on a specific grave.org.bukkit.configuration.ConfigurationSection
Gets a configuration section based on a specific entity.org.bukkit.configuration.ConfigurationSection
Gets a configuration section based on a specific entity and its permission list.org.bukkit.configuration.ConfigurationSection
Resolves the most appropriate configuration section based on entity type and permissions.private org.bukkit.configuration.file.FileConfiguration
getConfigFile
(File file) Loads a YAML file into aFileConfiguration
if valid.private org.bukkit.configuration.file.FileConfiguration
getConfigFiles
(File folder) Recursively loads all valid YAML configuration files from a folder and merges them into one configuration.final File
com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler
final int
final int
getPermissionList
(org.bukkit.entity.Entity entity) Builds a sorted list of permission keys for a given entity (player).Returns the plugin's current release type.final File
final int
boolean
hasGrantedPermission
(String permission, org.bukkit.entity.Player player) Checks if the specified player has been granted the specified permission.boolean
hasGrantedPermission
(String permission, org.bukkit.OfflinePlayer offlinePlayer) Deprecated.This method is deprecated because it is less efficient to check permissions for offline players.void
infoMessage
(String string) Logs an informational message to the console.void
integrationMessage
(String string) Logs an integration message to the console as an info message by default.void
integrationMessage
(String string, String messageType) Logs an integration message to the console with the specified message level.private void
private void
loadResourceDefaults
(org.bukkit.configuration.file.FileConfiguration fileConfiguration, String resource) Loads default values from a resource YAML file into the provided configuration.void
logInvalidGraveSite
(String grave_uuid, org.bukkit.Location affectedGraveLocation, List<String> invalidationReason) Logs information about a grave that has invalid or incomplete data.void
Logs the full stack trace of an exception to the plugin logger.void
void
onEnable()
void
onLoad()
private int
parseVersionPart
(String part) Attempts to parse a version segment to an integer.private void
void
private void
private void
private void
private void
void
reload()
void
private void
void
void
void
testMessage
(String string) Logs a test message to the console.void
private void
Asynchronously checks for plugin updates based on the configured update check setting.private void
Checks the version of the current configuration file and updates it if it is outdated.private void
updateConfigFile
(String fileName, int currentConfigVersion, boolean shouldUpdateConfigVersion) Updates a single configuration file from the plugin's internal resources using ConfigUpdater.void
updateMessage
(String string) Logs an update message to the console.void
warningMessage
(String string) Logs a warning message to the console with a "Warning" prefix.Methods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLogger, getPlugin, getPluginLoader, getProvidingPlugin, getResource, getServer, getTextResource, isEnabled, isNaggable, onCommand, onTabComplete, saveConfig, saveResource, setEnabled, setNaggable, toString
Methods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode
-
Field Details
-
versionManager
-
integrationManager
-
cacheManager
-
dataManager
-
importManager
-
blockManager
-
itemStackManager
-
entityDataManager
-
hologramManager
-
guiManager
-
entityManager
-
recipeManager
-
locationManager
-
graveManager
-
particleManager
-
compatibility
-
fileConfiguration
private org.bukkit.configuration.file.FileConfiguration fileConfiguration -
isDevelopmentBuild
private boolean isDevelopmentBuild -
isOutdatedBuild
private boolean isOutdatedBuild -
isUnknownBuild
private boolean isUnknownBuild -
graveScheduler
private static com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler graveScheduler
-
-
Constructor Details
-
Graves
public Graves()
-
-
Method Details
-
onLoad
public void onLoad()- Specified by:
onLoad
in interfaceorg.bukkit.plugin.Plugin
- Overrides:
onLoad
in classorg.bukkit.plugin.java.JavaPlugin
-
onEnable
public void onEnable()- Specified by:
onEnable
in interfaceorg.bukkit.plugin.Plugin
- Overrides:
onEnable
in classorg.bukkit.plugin.java.JavaPlugin
-
onDisable
public void onDisable()- Specified by:
onDisable
in interfaceorg.bukkit.plugin.Plugin
- Overrides:
onDisable
in classorg.bukkit.plugin.java.JavaPlugin
-
RegisterSoftCrashHandler
private void RegisterSoftCrashHandler() -
runShutdownTasks
private void runShutdownTasks() -
loadLibraries
private void loadLibraries() -
saveDefaultConfig
public void saveDefaultConfig()- Specified by:
saveDefaultConfig
in interfaceorg.bukkit.plugin.Plugin
- Overrides:
saveDefaultConfig
in classorg.bukkit.plugin.java.JavaPlugin
-
reloadConfig
public void reloadConfig()- Specified by:
reloadConfig
in interfaceorg.bukkit.plugin.Plugin
- Overrides:
reloadConfig
in classorg.bukkit.plugin.java.JavaPlugin
-
getConfig
@NotNull public @NotNull org.bukkit.configuration.file.FileConfiguration getConfig()- Specified by:
getConfig
in interfaceorg.bukkit.plugin.Plugin
- Overrides:
getConfig
in classorg.bukkit.plugin.java.JavaPlugin
-
reload
public void reload() -
saveTextFiles
public void saveTextFiles() -
registerMetrics
private void registerMetrics() -
registerMetricsLegacy
private void registerMetricsLegacy() -
registerListeners
public void registerListeners() -
unregisterListeners
public void unregisterListeners() -
registerRecipes
private void registerRecipes() -
registerCommands
private void registerCommands() -
debugMessage
-
warningMessage
Logs a warning message to the console with a "Warning" prefix.- Parameters:
string
- the message to log
-
compatibilityMessage
Logs a compatibility-related warning message to the console.- Parameters:
string
- the message to log
-
infoMessage
Logs an informational message to the console.- Parameters:
string
- the message to log
-
testMessage
Logs a test message to the console. Used for internal/debug purposes.- Parameters:
string
- the message to log
-
updateMessage
Logs an update message to the console.- Parameters:
string
- the message to log
-
integrationMessage
Logs an integration message to the console as an info message by default.- Parameters:
string
- the message to log
-
integrationMessage
Logs an integration message to the console with the specified message level.- Parameters:
string
- the message to logmessageType
- the type of message: "info", "warn", or "severe"
-
updateConfig
private void updateConfig()Checks the version of the current configuration file and updates it if it is outdated. Moves the old configs to an "outdated" directory and replaces them with updated ones from the plugin's resources. -
backupOutdatedConfigs
private void backupOutdatedConfigs(double configVersion) Backs up old configuration files to the "outdated" directory, appending the current config version to their filenames.- Parameters:
configVersion
- the version number of the outdated config files
-
updateConfigFile
private void updateConfigFile(String fileName, int currentConfigVersion, boolean shouldUpdateConfigVersion) Updates a single configuration file from the plugin's internal resources using ConfigUpdater. Optionally sets the config-version field after updating.- Parameters:
fileName
- the name of the config file to updatecurrentConfigVersion
- the current config version to setshouldUpdateConfigVersion
- whether to update the "config-version" field in the file
-
updateChecker
private void updateChecker()Asynchronously checks for plugin updates based on the configured update check setting. Logs messages indicating whether the plugin is outdated, up to date, or a development build. Also handles malformed version formats gracefully. -
compareVersions
Compares two semantic version strings (e.g., "1.16.5" vs. "1.18").Each version string is split by the period (.) character, and each corresponding segment is compared numerically. If one version has more segments than the other, missing or non-numeric segments are treated as 0.
- Parameters:
version1
- the first version string to compareversion2
- the second version string to compare- Returns:
- -1 if
version1
is lower thanversion2
, 1 ifversion1
is higher thanversion2
, 0 if both versions are equal
-
parseVersionPart
Attempts to parse a version segment to an integer. Returns 0 if parsing fails.- Parameters:
part
- the version segment as a string- Returns:
- the parsed integer or 0 if invalid
-
compatibilityChecker
private void compatibilityChecker()Checks for server and version compatibility, and sets the appropriate compatibility handler depending on whether the server supportsBlockData
.Outputs informational messages about potential issues when running on legacy versions, Bukkit, or Mohist servers.
-
dumpServerInfo
public void dumpServerInfo(org.bukkit.command.CommandSender commandSender) Dumps server and plugin-related debug information and provides the result either as a remote URL (via mclogs or hastebin) or saves it locally if upload fails.If the plugin is enabled, the operation is performed asynchronously.
- Parameters:
commandSender
- the sender (e.g., player or console) who will receive the result message.
-
getVersionManager
- Returns:
- the
VersionManager
responsible for handling Minecraft version compatibility.
-
getIntegrationManager
- Returns:
- the
IntegrationManager
that manages third-party plugin integrations.
-
getGraveManager
- Returns:
- the
GraveManager
that handles the creation and management of graves.
-
getHologramManager
- Returns:
- the
HologramManager
for displaying holographic text or elements above graves.
-
getBlockManager
- Returns:
- the
BlockManager
that manages custom block-related functionality.
-
getItemStackManager
- Returns:
- the
ItemStackManager
that handles item serialization and manipulation.
-
getEntityDataManager
- Returns:
- the
EntityDataManager
used for storing and retrieving entity-specific data.
-
getCacheManager
- Returns:
- the
CacheManager
responsible for caching frequently accessed data.
-
getDataManager
- Returns:
- the
DataManager
that manages persistent plugin data and file I/O.
-
getImportManager
- Returns:
- the
ImportManager
used for importing data from other plugins or older formats.
-
getGUIManager
- Returns:
- the
GUIManager
that handles graphical user interfaces shown to players.
-
getRecipeManager
- Returns:
- the
RecipeManager
responsible for managing custom recipes.
-
getLocationManager
- Returns:
- the
LocationManager
that handles location serialization and retrieval.
-
getEntityManager
- Returns:
- the
EntityManager
for managing in-game entities related to graves.
-
getParticleManager
- Returns:
- the
ParticleManager
that manages particle effects used by the plugin.
-
getCompatibility
- Returns:
- the
Compatibility
handler that ensures functionality across Minecraft versions and server platforms.
-
getGravesXScheduler
public com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler getGravesXScheduler()- Returns:
- the
TaskScheduler
used for running asynchronous or scheduled plugin tasks.
-
getPluginReleaseType
Returns the plugin's current release type.- Returns:
- a string indicating whether the build is Development, Outdated, Unknown, or Production.
-
getConfig
Gets a configuration section based on a specific grave.- Parameters:
config
- the config key.grave
- the grave instance.- Returns:
- the matching configuration section, or default if none match.
-
getConfig
public org.bukkit.configuration.ConfigurationSection getConfig(String config, org.bukkit.entity.Entity entity) Gets a configuration section based on a specific entity.- Parameters:
config
- the config key.entity
- the entity.- Returns:
- the matching configuration section, or default if none match.
-
getConfig
public org.bukkit.configuration.ConfigurationSection getConfig(String config, org.bukkit.entity.Entity entity, List<String> permissionList) Gets a configuration section based on a specific entity and its permission list.- Parameters:
config
- the config key.entity
- the entity.permissionList
- the permissions associated with the entity.- Returns:
- the matching configuration section, or default if none match.
-
getConfig
public org.bukkit.configuration.ConfigurationSection getConfig(String config, org.bukkit.entity.EntityType entityType, List<String> permissionList) Resolves the most appropriate configuration section based on entity type and permissions.- Parameters:
config
- the config key.entityType
- the type of entity.permissionList
- a list of permissions to prioritize.- Returns:
- the best matching configuration section.
-
loadResourceDefaults
private void loadResourceDefaults(org.bukkit.configuration.file.FileConfiguration fileConfiguration, String resource) Loads default values from a resource YAML file into the provided configuration.- Parameters:
fileConfiguration
- the configuration to modify.resource
- the internal resource path.
-
bakeDefaults
private void bakeDefaults(org.bukkit.configuration.file.FileConfiguration fileConfiguration) Forces default values to be copied and applied in the configuration.- Parameters:
fileConfiguration
- the configuration to apply defaults to.
-
getPermissionList
Builds a sorted list of permission keys for a given entity (player).- Parameters:
entity
- the entity (usually a Player).- Returns:
- a sorted list of permission keys that match configuration sections.
-
getConfigFiles
Recursively loads all valid YAML configuration files from a folder and merges them into one configuration.- Parameters:
folder
- the folder to scan.- Returns:
- the resulting merged configuration.
-
getConfigFile
Loads a YAML file into aFileConfiguration
if valid.- Parameters:
file
- the file to load.- Returns:
- the configuration or
null
if loading failed.
-
getConfigFolder
- Returns:
- the folder where Graves configuration files are stored.
-
getPluginsFolder
- Returns:
- the parent folder where all plugins are stored.
-
getVersion
- Returns:
- the current version of the Graves plugin from plugin.yml.
-
getLatestVersion
- Returns:
- the latest available version from Spigot update checking.
-
getSpigotID
public final int getSpigotID()- Returns:
- the Spigot plugin resource ID used for update checking.
-
getMetricsID
public final int getMetricsID()- Returns:
- the bStats plugin ID used for usage metrics.
-
getMetricsIDLegacy
public final int getMetricsIDLegacy()- Returns:
- the legacy bStats plugin ID (for previous plugin versions).
-
logStackTrace
Logs the full stack trace of an exception to the plugin logger.- Parameters:
e
- the exception to log.
-
logInvalidGraveSite
public void logInvalidGraveSite(String grave_uuid, org.bukkit.Location affectedGraveLocation, List<String> invalidationReason) Logs information about a grave that has invalid or incomplete data.- Parameters:
grave_uuid
- the UUID of the affected grave.affectedGraveLocation
- the location of the grave.invalidationReason
- reasons the grave is considered invalid.
-
hasGrantedPermission
Checks if the specified player has been granted the specified permission. This method first checks if various permission plugins are available and uses them to check permissions. If no permission plugin is found, it falls back to the default Bukkit permission check. Additionally, this method logs debug messages based on the permission check results for each permission plugin.- Parameters:
permission
- the permission to check forplayer
- the player whose permissions are being checked- Returns:
true
if the player has the specified permission,false
otherwise
-
hasGrantedPermission
@Deprecated public boolean hasGrantedPermission(String permission, org.bukkit.OfflinePlayer offlinePlayer) Deprecated.This method is deprecated because it is less efficient to check permissions for offline players. UsehasGrantedPermission(String, Player)
for online players instead.Checks if the specified offline player has been granted the specified permission. This method first checks if various permission plugins are available and uses them to check permissions. If no permission plugin is found, it falls back to the default Bukkit permission check. Additionally, this method logs debug messages based on the permission check results for each permission plugin.- Parameters:
permission
- the permission to check forofflinePlayer
- the offline player whose permissions are being checked- Returns:
true
if the offline player has the specified permission,false
otherwise
-