Class Homestead
java.lang.Object
org.bukkit.plugin.PluginBase
org.bukkit.plugin.java.JavaPlugin
me.tayebyassine.homestead.Homestead
- All Implemented Interfaces:
io.papermc.paper.plugin.lifecycle.event.LifecycleEventOwner, net.kyori.adventure.key.Namespaced, org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor, org.bukkit.plugin.Plugin
public class Homestead
extends org.bukkit.plugin.java.JavaPlugin
Entry point of Homestead plugin.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic RegionBanCachestatic RegionChunkCachestatic Databasestatic RegionInviteCachestatic LevelsCachestatic RegionLogCachestatic RegionMemberCachestatic PositionIndexedChunkCachestatic RegionRateCachestatic RegionCachestatic RegionIndexedChunkCachestatic SubAreasCachestatic Vaultstatic WarsCache -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidFire anAPIEventsynchronously and forward it to the Discord webhook if configured.static booleanDetect whether the server software is Folia by checking for theRegionizedServerclass at runtime.static booleanDetect whether the server software is Paper by checking for theConfigurationclass at runtime.voidDisable the plugin instance through the server's plugin manager.voidLog the given throwable and then disable the plugin instance.static HomesteadGet the singleton plugin instance.Get the names of all offline players synchronously.List<org.bukkit.OfflinePlayer> Get a list of all offline players (including those who have never logged in).@Nullable org.bukkit.OfflinePlayergetOfflinePlayerSync(String playerName) Look up an offline player by name, using a safe method that checks online players, the cached player list, and a full scan.@Nullable org.bukkit.OfflinePlayergetOfflinePlayerSync(UUID playerId) Look up an offline player by UUID, using a safe method that checks online players first, then the offline cache.Get the names of all currently online players synchronously.List<org.bukkit.entity.Player> Get a list of all currently online players.static SnowflakeGeneratorGet the snowflake ID generator used for unique region, chunk, and sub-area identifiers.static StringGet the current plugin version string.static booleanisFolia()Whether the server is running on Folia.static booleanisPaper()Whether the server is running on Paper.static booleanWhether this build is a snapshot (pre-release) version.voidCalled when the plugin is disabled by the server.voidonEnable()Called when the plugin is enabled by the server.voidRegister external plugin integrations (e.g.runAsyncTask(Runnable callable) Run a task asynchronously.runAsyncTaskLater(Runnable callable, int delay) Run a task asynchronously after a delay.runAsyncTimerTask(Runnable callable, int interval) Run a repeating task asynchronously with interval in seconds.runAsyncTimerTask(Runnable callable, int delay, int interval) Run a repeating task asynchronously with a delay and interval in seconds.runLocationTask(org.bukkit.Location location, Runnable callable) Run a task on the region thread that owns the given location.runLocationTaskTimer(org.bukkit.Location location, Runnable callable, long delay, long period) Run a repeating task on the region thread that owns the given location.runPlayerTask(org.bukkit.entity.Player player, Runnable callable) Run a task on the region thread that owns the given player.runPlayerTaskLater(org.bukkit.entity.Player player, Runnable callable, int delay) Run a task on the region thread that owns the given player after a delay.runPlayerTaskTimer(org.bukkit.entity.Player player, Runnable callable, long delay, long period) Run a repeating task on the region thread that owns the given player.runSyncTask(Runnable callable) Run a task synchronously on the main thread.runSyncTaskLater(Runnable callable, int delay) Run a task synchronously after a delay.runSyncTimerTask(Runnable callable, long ticks) Run a repeating task synchronously with interval in ticks.Methods inherited from class org.bukkit.plugin.java.JavaPlugin
getClassLoader, getCommand, getConfig, getDataFolder, getDefaultBiomeProvider, getDefaultWorldGenerator, getDescription, getFile, getLifecycleManager, getLogger, getPlugin, getPluginLoader, getPluginMeta, getProvidingPlugin, getResource, getServer, getTextResource, init, init, isEnabled, isNaggable, onCommand, onLoad, onTabComplete, registerCommand, registerCommand, registerCommand, registerCommand, reloadConfig, saveConfig, saveDefaultConfig, saveResource, setEnabled, setNaggable, toStringMethods inherited from class org.bukkit.plugin.PluginBase
equals, getName, hashCode, namespaceMethods inherited from interface org.bukkit.plugin.Plugin
getComponentLogger, getDataPath, getLog4JLogger, getSLF4JLogger
-
Field Details
-
REGION_CACHE
-
MEMBER_CACHE
-
BAN_CACHE
-
CHUNK_CACHE
-
REGION_INDEXED_CHUNK_CACHE
-
POSITION_INDEXED_CHUNK_CACHE
-
INVITE_CACHE
-
LOG_CACHE
-
RATE_CACHE
-
WAR_CACHE
-
SUBAREA_CACHE
-
LEVEL_CACHE
-
database
-
VAULT
-
-
Constructor Details
-
Homestead
public Homestead()
-
-
Method Details
-
getSnowflake
Get the snowflake ID generator used for unique region, chunk, and sub-area identifiers.- Returns:
- the singleton snowflake generator
-
getVersion
Get the current plugin version string.- Returns:
- the version identifier
-
isSnapshot
public static boolean isSnapshot()Whether this build is a snapshot (pre-release) version.- Returns:
trueif the build is a snapshot
-
getInstance
Get the singleton plugin instance.- Returns:
- the active Homestead instance, or
nullif not yet loaded
-
checkSoftwareIfFolia
public static boolean checkSoftwareIfFolia()Detect whether the server software is Folia by checking for theRegionizedServerclass at runtime.- Returns:
trueif Folia classes are present
-
isFolia
public static boolean isFolia()Whether the server is running on Folia.- Returns:
trueif Folia was detected during startup
-
checkSoftwareIfPaper
public static boolean checkSoftwareIfPaper()Detect whether the server software is Paper by checking for theConfigurationclass at runtime.- Returns:
trueif Paper classes are present
-
isPaper
public static boolean isPaper()Whether the server is running on Paper.- Returns:
trueif Paper was detected during startup
-
callEvent
-
onEnable
public void onEnable()Called when the plugin is enabled by the server.Initialises caches, database, Vault hooks, event listeners, Brigadier commands, metrics, Discord integration, and all recurring background tasks.
- Specified by:
onEnablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onEnablein classorg.bukkit.plugin.java.JavaPlugin
-
onDisable
public void onDisable()Called when the plugin is disabled by the server.Closes the database connection, cancels running tasks, persists region storage, and clears all in-memory caches.
- Specified by:
onDisablein interfaceorg.bukkit.plugin.Plugin- Overrides:
onDisablein classorg.bukkit.plugin.java.JavaPlugin
-
registerExternalPlugins
public void registerExternalPlugins()Register external plugin integrations (e.g. PlaceholderAPI). -
runPlayerTask
Run a task on the region thread that owns the given player.Use this instead of
runSyncTask(Runnable)whenever the task involves world/chunk/location access triggered by a player action (e.g. inventory clicks).- Parameters:
player- the player whose region thread to run oncallable- the task to run- Returns:
- a handle to the scheduled task
-
runPlayerTaskLater
Run a task on the region thread that owns the given player after a delay.- Parameters:
player- the player whose region thread to run oncallable- the task to rundelay- the delay, in seconds- Returns:
- a handle to the scheduled task
-
runPlayerTaskTimer
public TaskHandle runPlayerTaskTimer(org.bukkit.entity.Player player, Runnable callable, long delay, long period) Run a repeating task on the region thread that owns the given player.- Parameters:
player- the player whose region thread to run oncallable- the task to rundelay- ticks to wait before first executionperiod- ticks between executions- Returns:
- a handle to the scheduled task
-
runSyncTask
Run a task synchronously on the main thread.- Parameters:
callable- the task to run- Returns:
- a handle to the scheduled task
-
runSyncTaskLater
Run a task synchronously after a delay.- Parameters:
callable- the task to rundelay- the delay, in seconds- Returns:
- a handle to the scheduled task
-
runSyncTimerTask
Run a repeating task synchronously with interval in ticks.- Parameters:
callable- the task to runticks- the interval, in ticks- Returns:
- a handle to the scheduled task
-
runAsyncTask
Run a task asynchronously.- Parameters:
callable- the task to run- Returns:
- a handle to the scheduled task
-
runAsyncTaskLater
Run a task asynchronously after a delay.- Parameters:
callable- the task to rundelay- the delay, in seconds- Returns:
- a handle to the scheduled task
-
runAsyncTimerTask
Run a repeating task asynchronously with interval in seconds.- Parameters:
callable- the task to runinterval- the interval, in seconds- Returns:
- a handle to the scheduled task
-
runAsyncTimerTask
Run a repeating task asynchronously with a delay and interval in seconds.- Parameters:
callable- the task to rundelay- the delay before first execution, in secondsinterval- the interval between executions, in seconds- Returns:
- a handle to the scheduled task
-
runLocationTask
Run a task on the region thread that owns the given location.Use this for any event or operation tied to a specific world location.
- Parameters:
location- the location whose owning region thread to run oncallable- the task to run- Returns:
- a handle to the scheduled task
-
runLocationTaskTimer
public TaskHandle runLocationTaskTimer(org.bukkit.Location location, Runnable callable, long delay, long period) Run a repeating task on the region thread that owns the given location.- Parameters:
location- the location to determine which region thread to usecallable- the task to rundelay- ticks to wait before first executionperiod- ticks between executions- Returns:
- a handle to the scheduled task
-
getOfflinePlayersSync
Get a list of all offline players (including those who have never logged in).- Returns:
- an unmodifiable view of all known offline players
-
getOnlinePlayersSync
Get a list of all currently online players.- Returns:
- a snapshot list of online players
-
getOfflinePlayerNamesSync
-
getOnlinePlayerNamesSync
-
getOfflinePlayerSync
Look up an offline player by UUID, using a safe method that checks online players first, then the offline cache.- Parameters:
playerId- the player UUID- Returns:
- the offline player, or
nullif not found or never played
-
getOfflinePlayerSync
Look up an offline player by name, using a safe method that checks online players, the cached player list, and a full scan.- Parameters:
playerName- the player name- Returns:
- the offline player, or
nullif not found or never played
-
endInstance
public void endInstance()Disable the plugin instance through the server's plugin manager. -
endInstance
Log the given throwable and then disable the plugin instance.- Parameters:
e- the error that caused the shutdown
-