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 Details

  • Constructor Details

    • Homestead

      public Homestead()
  • Method Details

    • getSnowflake

      public static SnowflakeGenerator getSnowflake()
      Get the snowflake ID generator used for unique region, chunk, and sub-area identifiers.
      Returns:
      the singleton snowflake generator
    • getVersion

      public static String 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:
      true if the build is a snapshot
    • getInstance

      public static Homestead getInstance()
      Get the singleton plugin instance.
      Returns:
      the active Homestead instance, or null if not yet loaded
    • checkSoftwareIfFolia

      public static boolean checkSoftwareIfFolia()
      Detect whether the server software is Folia by checking for the RegionizedServer class at runtime.
      Returns:
      true if Folia classes are present
    • isFolia

      public static boolean isFolia()
      Whether the server is running on Folia.
      Returns:
      true if Folia was detected during startup
    • checkSoftwareIfPaper

      public static boolean checkSoftwareIfPaper()
      Detect whether the server software is Paper by checking for the Configuration class at runtime.
      Returns:
      true if Paper classes are present
    • isPaper

      public static boolean isPaper()
      Whether the server is running on Paper.
      Returns:
      true if Paper was detected during startup
    • callEvent

      public static void callEvent(APIEvent event)
      Fire an APIEvent synchronously and forward it to the Discord webhook if configured.
      Parameters:
      event - the custom event to dispatch
    • 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:
      onEnable in interface org.bukkit.plugin.Plugin
      Overrides:
      onEnable in class org.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:
      onDisable in interface org.bukkit.plugin.Plugin
      Overrides:
      onDisable in class org.bukkit.plugin.java.JavaPlugin
    • registerExternalPlugins

      public void registerExternalPlugins()
      Register external plugin integrations (e.g. PlaceholderAPI).
    • runPlayerTask

      public TaskHandle runPlayerTask(org.bukkit.entity.Player player, Runnable callable)
      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 on
      callable - the task to run
      Returns:
      a handle to the scheduled task
    • runPlayerTaskLater

      public TaskHandle 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.
      Parameters:
      player - the player whose region thread to run on
      callable - the task to run
      delay - 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 on
      callable - the task to run
      delay - ticks to wait before first execution
      period - ticks between executions
      Returns:
      a handle to the scheduled task
    • runSyncTask

      public TaskHandle runSyncTask(Runnable callable)
      Run a task synchronously on the main thread.
      Parameters:
      callable - the task to run
      Returns:
      a handle to the scheduled task
    • runSyncTaskLater

      public TaskHandle runSyncTaskLater(Runnable callable, int delay)
      Run a task synchronously after a delay.
      Parameters:
      callable - the task to run
      delay - the delay, in seconds
      Returns:
      a handle to the scheduled task
    • runSyncTimerTask

      public TaskHandle runSyncTimerTask(Runnable callable, long ticks)
      Run a repeating task synchronously with interval in ticks.
      Parameters:
      callable - the task to run
      ticks - the interval, in ticks
      Returns:
      a handle to the scheduled task
    • runAsyncTask

      public TaskHandle runAsyncTask(Runnable callable)
      Run a task asynchronously.
      Parameters:
      callable - the task to run
      Returns:
      a handle to the scheduled task
    • runAsyncTaskLater

      public TaskHandle runAsyncTaskLater(Runnable callable, int delay)
      Run a task asynchronously after a delay.
      Parameters:
      callable - the task to run
      delay - the delay, in seconds
      Returns:
      a handle to the scheduled task
    • runAsyncTimerTask

      public TaskHandle runAsyncTimerTask(Runnable callable, int interval)
      Run a repeating task asynchronously with interval in seconds.
      Parameters:
      callable - the task to run
      interval - the interval, in seconds
      Returns:
      a handle to the scheduled task
    • runAsyncTimerTask

      public TaskHandle runAsyncTimerTask(Runnable callable, int delay, int interval)
      Run a repeating task asynchronously with a delay and interval in seconds.
      Parameters:
      callable - the task to run
      delay - the delay before first execution, in seconds
      interval - the interval between executions, in seconds
      Returns:
      a handle to the scheduled task
    • runLocationTask

      public TaskHandle runLocationTask(org.bukkit.Location location, Runnable callable)
      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 on
      callable - 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 use
      callable - the task to run
      delay - ticks to wait before first execution
      period - ticks between executions
      Returns:
      a handle to the scheduled task
    • getOfflinePlayersSync

      public List<org.bukkit.OfflinePlayer> 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

      public List<org.bukkit.entity.Player> getOnlinePlayersSync()
      Get a list of all currently online players.
      Returns:
      a snapshot list of online players
    • getOfflinePlayerNamesSync

      public List<String> getOfflinePlayerNamesSync()
      Get the names of all offline players synchronously.
      Returns:
      list of player names, may contain null entries
    • getOnlinePlayerNamesSync

      public List<String> getOnlinePlayerNamesSync()
      Get the names of all currently online players synchronously.
      Returns:
      list of online player names
    • getOfflinePlayerSync

      @Nullable public @Nullable org.bukkit.OfflinePlayer getOfflinePlayerSync(UUID playerId)
      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 null if not found or never played
    • getOfflinePlayerSync

      @Nullable public @Nullable org.bukkit.OfflinePlayer getOfflinePlayerSync(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.
      Parameters:
      playerName - the player name
      Returns:
      the offline player, or null if not found or never played
    • endInstance

      public void endInstance()
      Disable the plugin instance through the server's plugin manager.
    • endInstance

      public void endInstance(Throwable e)
      Log the given throwable and then disable the plugin instance.
      Parameters:
      e - the error that caused the shutdown