Class Network
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.network.Network
An abstract Network class to manage networks in a stateful way
- Author:
- meiamsome
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Network
(NetworkManager manager, org.bukkit.Location regulator) This constructs a newNetwork
at the givenLocation
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addLocationToNetwork
(org.bukkit.Location l) This method adds the givenLocation
to thisNetwork
.abstract NetworkComponent
classifyLocation
(org.bukkit.Location l) This method assigns the givenLocation
a type ofNetworkComponent
for classification.boolean
connectsTo
(org.bukkit.Location l) This method checks whether the givenLocation
is part of thisNetwork
.void
display()
This method runs the network visualizer which displays aParticle
on everyLocation
that thisNetwork
is connected to.abstract int
getRange()
This method returns the range of theNetwork
.org.bukkit.Location
This returns theLocation
of the regulator block for thisNetwork
int
getSize()
This returns the size of thisNetwork
.void
markDirty
(org.bukkit.Location l) This method marks the givenLocation
as dirty and adds it to aQueue
to handle this update.abstract void
onClassificationChange
(org.bukkit.Location l, NetworkComponent from, NetworkComponent to) This method is called whenever aLocation
in thisNetwork
changes its classification.void
tick()
This method updates thisNetwork
and serves as the starting point for any running operations.
-
Field Details
-
regulator
protected org.bukkit.Location regulatorTheLocation
of the regulator of thisNetwork
. -
connectedLocations
-
regulatorNodes
-
connectorNodes
-
terminusNodes
-
-
Constructor Details
-
Network
This constructs a newNetwork
at the givenLocation
.- Parameters:
manager
- TheNetworkManager
instanceregulator
- TheLocation
marking the regulator of thisNetwork
.
-
-
Method Details
-
getRange
public abstract int getRange()This method returns the range of theNetwork
. The range determines how far theNetwork
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
This method assigns the givenLocation
a type ofNetworkComponent
for classification.- Parameters:
l
- TheLocation
to classify- Returns:
- The assigned type of
NetworkComponent
for thisLocation
-
onClassificationChange
public abstract void onClassificationChange(org.bukkit.Location l, NetworkComponent from, NetworkComponent to) This method is called whenever aLocation
in thisNetwork
changes its classification.- Parameters:
l
- TheLocation
that is changing its classificationfrom
- TheNetworkComponent
thisLocation
was previously classified asto
- TheNetworkComponent
thisLocation
is changing to
-
getSize
public int getSize()This returns the size of thisNetwork
. It is equivalent to the amount ofLocations
connected to thisNetwork
.- Returns:
- The size of this
Network
-
addLocationToNetwork
protected void addLocationToNetwork(@Nonnull org.bukkit.Location l) This method adds the givenLocation
to thisNetwork
.- Parameters:
l
- TheLocation
to add
-
markDirty
public void markDirty(@Nonnull org.bukkit.Location l) This method marks the givenLocation
as dirty and adds it to aQueue
to handle this update.- Parameters:
l
- TheLocation
to update
-
connectsTo
public boolean connectsTo(@Nonnull org.bukkit.Location l) This method checks whether the givenLocation
is part of thisNetwork
.- Parameters:
l
- TheLocation
to check for- Returns:
- Whether the given
Location
is part of thisNetwork
-
display
public void display()This method runs the network visualizer which displays aParticle
on everyLocation
that thisNetwork
is connected to. -
getRegulator
@Nonnull public org.bukkit.Location getRegulator()This returns theLocation
of the regulator block for thisNetwork
- Returns:
- The
Location
of our regulator
-
tick
public void tick()This method updates thisNetwork
and serves as the starting point for any running operations.
-