java.lang.Object
io.github.thebusybiscuit.slimefun4.api.network.Network
Direct Known Subclasses:
CargoNet, EnergyNet

public abstract class Network extends Object
An abstract Network class to manage networks in a stateful way
Author:
meiamsome
See Also:
  • Field Details

    • regulator

      protected org.bukkit.Location regulator
      The Location of the regulator of this Network.
    • connectedLocations

      protected final Set<org.bukkit.Location> connectedLocations
    • regulatorNodes

      protected final Set<org.bukkit.Location> regulatorNodes
    • connectorNodes

      protected final Set<org.bukkit.Location> connectorNodes
    • terminusNodes

      protected final Set<org.bukkit.Location> terminusNodes
  • Constructor Details

    • Network

      protected Network(@Nonnull NetworkManager manager, @Nonnull org.bukkit.Location regulator)
      This constructs a new Network at the given Location.
      Parameters:
      manager - The NetworkManager instance
      regulator - The Location marking the regulator of this Network.
  • Method Details

    • getRange

      public abstract int getRange()
      This method returns the range of the Network. The range determines how far the Network will search for nearby nodes from any given node. It basically translates to the maximum distance between nodes.
      Returns:
      the range of this Network
    • classifyLocation

      @Nullable public abstract NetworkComponent classifyLocation(@Nonnull org.bukkit.Location l)
      This method assigns the given Location a type of NetworkComponent for classification.
      Parameters:
      l - The Location to classify
      Returns:
      The assigned type of NetworkComponent for this Location
    • onClassificationChange

      public abstract void onClassificationChange(org.bukkit.Location l, NetworkComponent from, NetworkComponent to)
      This method is called whenever a Location in this Network changes its classification.
      Parameters:
      l - The Location that is changing its classification
      from - The NetworkComponent this Location was previously classified as
      to - The NetworkComponent this Location is changing to
    • getSize

      public int getSize()
      This returns the size of this Network. It is equivalent to the amount of Locations connected to this Network.
      Returns:
      The size of this Network
    • addLocationToNetwork

      protected void addLocationToNetwork(@Nonnull org.bukkit.Location l)
      This method adds the given Location to this Network.
      Parameters:
      l - The Location to add
    • markDirty

      public void markDirty(@Nonnull org.bukkit.Location l)
      This method marks the given Location as dirty and adds it to a Queue to handle this update.
      Parameters:
      l - The Location to update
    • connectsTo

      public boolean connectsTo(@Nonnull org.bukkit.Location l)
      This method checks whether the given Location is part of this Network.
      Parameters:
      l - The Location to check for
      Returns:
      Whether the given Location is part of this Network
    • display

      public void display()
      This method runs the network visualizer which displays a Particle on every Location that this Network is connected to.
    • getRegulator

      @Nonnull public org.bukkit.Location getRegulator()
      This returns the Location of the regulator block for this Network
      Returns:
      The Location of our regulator
    • tick

      public void tick()
      This method updates this Network and serves as the starting point for any running operations.