Package de.sprax2013.betterchairs
Class ChairManager
- java.lang.Object
-
- de.sprax2013.betterchairs.ChairManager
-
public class ChairManager extends Object
This class should be instantiated as soon as possible insideJavaPlugin.onEnable()
to ensure that other classes relying on it work as intended
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ChairManager(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull ChairNMS chairNMS)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
create(org.bukkit.entity.Player player, org.bukkit.block.Block block)
Check if a chair can be spawned and call an Event.
If the event doesn't get cancelled, the player should then be able to sit.
IgnoreshasChairsDisabled(Player)
void
destroy(Chair chair, boolean teleportPlayer)
Callsdestroy(Chair, boolean, boolean)
withsameTickTeleport = false
void
destroy(Chair chair, boolean teleportPlayer, boolean sameTickTeleport)
int
destroyAll(boolean teleportPlayer)
int
destroyAll(boolean teleportPlayer, boolean sameTickTeleport)
@Nullable Chair
getChair(@NotNull org.bukkit.block.Block b)
@Nullable Chair
getChair(@NotNull org.bukkit.entity.ArmorStand armorStand)
@Nullable Chair
getChair(@NotNull org.bukkit.entity.Player p)
static @Nullable ChairManager
getInstance()
May be null if BetterChairs is not enabledstatic @NotNull Logger
getLogger()
Returns BetterChair's logger or the global one, whengetPlugin()
isnull
.static @Nullable org.bukkit.plugin.java.JavaPlugin
getPlugin()
May be null if BetterChairs is not enabledboolean
hasChairsDisabled(org.bukkit.entity.Player player)
boolean
isChair(@NotNull org.bukkit.entity.ArmorStand armorStand)
This does not yet guarantee thatgetChair(ArmorStand)
is notnull
This may return true for ArmorStand not yet spawned and thus not yet aChair
that is readyboolean
isOccupied(@NotNull org.bukkit.block.Block b)
void
setChairsDisabled(org.bukkit.entity.Player player, boolean areDisabled)
-
-
-
Field Detail
-
plugin
protected static org.bukkit.plugin.java.JavaPlugin plugin
-
instance
protected static ChairManager instance
-
chairNMS
protected final ChairNMS chairNMS
-
disabled
protected final List<org.bukkit.entity.Player> disabled
-
-
Constructor Detail
-
ChairManager
protected ChairManager(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull @NotNull ChairNMS chairNMS)
-
-
Method Detail
-
create
public boolean create(org.bukkit.entity.Player player, org.bukkit.block.Block block)
Check if a chair can be spawned and call an Event.
If the event doesn't get cancelled, the player should then be able to sit.
IgnoreshasChairsDisabled(Player)
- Parameters:
player
- The player that should sitblock
- The block the player should sit on- Returns:
- true if player is now sitting on a chair, false otherwise
-
destroy
public void destroy(Chair chair, boolean teleportPlayer)
Callsdestroy(Chair, boolean, boolean)
withsameTickTeleport = false
- Parameters:
chair
- TheChair
that should be destroyedteleportPlayer
- true, when called without anPlayerTeleportEvent
being fired afterwards (e.g.EntityDismountEvent
does)- See Also:
destroy(Chair, boolean, boolean)
-
destroy
public void destroy(Chair chair, boolean teleportPlayer, boolean sameTickTeleport)
- Parameters:
chair
- TheChair
that should be destroyedteleportPlayer
- true, when called without anPlayerTeleportEvent
being fired afterwards (e.g.EntityDismountEvent
does)sameTickTeleport
- For compatibility reasons the player is teleported on the next server tick. This may not be possible in some situations
-
destroyAll
public int destroyAll(boolean teleportPlayer)
-
destroyAll
public int destroyAll(boolean teleportPlayer, boolean sameTickTeleport)
-
isOccupied
public boolean isOccupied(@NotNull @NotNull org.bukkit.block.Block b)
- Parameters:
b
- The block to check- Returns:
- true if a player is sitting on it, false otherwise
-
getChair
@Nullable public @Nullable Chair getChair(@NotNull @NotNull org.bukkit.entity.Player p)
-
getChair
@Nullable public @Nullable Chair getChair(@NotNull @NotNull org.bukkit.block.Block b)
-
getChair
@Nullable public @Nullable Chair getChair(@NotNull @NotNull org.bukkit.entity.ArmorStand armorStand)
-
isChair
public boolean isChair(@NotNull @NotNull org.bukkit.entity.ArmorStand armorStand)
This does not yet guarantee thatgetChair(ArmorStand)
is notnull
This may return true for ArmorStand not yet spawned and thus not yet aChair
that is ready- Parameters:
armorStand
- TheArmorStand
to check- Returns:
- true if the
ArmorStand
is used or may be used asChair
-
hasChairsDisabled
public boolean hasChairsDisabled(org.bukkit.entity.Player player)
-
setChairsDisabled
public void setChairsDisabled(org.bukkit.entity.Player player, boolean areDisabled)
-
getLogger
@NotNull public static @NotNull Logger getLogger()
Returns BetterChair's logger or the global one, whengetPlugin()
isnull
.- Returns:
- The plugin's
Logger
or the global one, never null
-
getInstance
@Nullable public static @Nullable ChairManager getInstance()
May be null if BetterChairs is not enabled- Returns:
- The
ChairManager
instance created by BetterChairs, or null
-
getPlugin
@Nullable public static @Nullable org.bukkit.plugin.java.JavaPlugin getPlugin()
May be null if BetterChairs is not enabled- Returns:
- The
JavaPlugin
instance representing BetterChairs, or null
-
-