Package fr.multimc.api.spigot.games
Class GameInstance
java.lang.Object
fr.multimc.api.spigot.games.GameInstance
- All Implemented Interfaces:
 org.bukkit.event.Listener
- Direct Known Subclasses:
 SampleGameInstance
- 
Constructor Summary
ConstructorsConstructorDescriptionGameInstance(@NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull GamesManager gamesManager, @NotNull GameSettings settings, @NotNull org.bukkit.Location instanceLocation, @NotNull List<MmcTeam> mmcTeams, int instanceId)  - 
Method Summary
Modifier and TypeMethodDescriptionstatic voidPast the gameSchematic for the instance (can be called for pre-allocation too)voidbroadcast(net.kyori.adventure.text.Component message) Broadcast a message to all players in the instancevoidcancel()List<org.bukkit.entity.Entity>intorg.bukkit.Locationorg.bukkit.plugin.PluginintgetTeams()voidinit(boolean isPreAllocated) Initialize game instancebooleanbooleanisPlayerOnInstance(@NotNull MmcPlayer mmcPlayer) Check if the player is on this instancebooleanbooleanisSpectatorOnInstance(@NotNull MmcPlayer spectator) Check if the spectator is on this instancevoidonPlayerDisconnect(@NotNull MmcPlayer mmcPlayer) Called when a player disconnect from the servervoidonPlayerReconnect(@NotNull MmcPlayer mmcPlayer) Called to reconnect a disconnected playervoidonSpectatorJoin(@NotNull MmcPlayer spectator) Called when a spectator spectate this gamevoidonSpectatorLeave(@NotNull MmcPlayer spectator) Called when a spectator stop spectating this gamevoidrestart()Restart game instancevoidsetPlayerSpawn(@NotNull MmcPlayer mmcPlayer, @Nullable org.bukkit.Location location) Asynchronously set a player spawnvoidsetRemainingTime(int remainingTime) voidstart()Start game instancevoidstop()Default instance stop (players will return to the lobby)voidteleportPlayer(@NotNull MmcPlayer mmcPlayer, @Nullable org.bukkit.Location location) Asynchronously teleport a player to a locationvoidTeleport all players to their spawnvoidteleportPlayerToSpawn(@NotNull MmcPlayer player) Teleport a player to his spawnvoidtick()Method called every tick delay defined in InstanceSettingsprotected voidupdateState(@NotNull GameState state) Called to update instance state for InstanceManager 
- 
Constructor Details
- 
GameInstance
public GameInstance(@NotNull @NotNull org.bukkit.plugin.java.JavaPlugin plugin, @NotNull @NotNull GamesManager gamesManager, @NotNull @NotNull GameSettings settings, @NotNull @NotNull org.bukkit.Location instanceLocation, @NotNull @NotNull List<MmcTeam> mmcTeams, int instanceId)  
 - 
 - 
Method Details
- 
allocate
public static void allocate(@NotNull @NotNull Schematic schematic, @NotNull @NotNull org.bukkit.Location location) Past the gameSchematic for the instance (can be called for pre-allocation too)- Parameters:
 schematic- Schematic to pastelocation- Location to paste the gameSchematic
 - 
init
public void init(boolean isPreAllocated) Initialize game instance- Parameters:
 isPreAllocated- If the gameSchematic is already pasted
 - 
start
public void start()Start game instance - 
stop
public void stop()Default instance stop (players will return to the lobby) - 
restart
public void restart()Restart game instance - 
tick
public void tick()Method called every tick delay defined in InstanceSettings - 
cancel
- Throws:
 IllegalStateException
 - 
isCancelled
public boolean isCancelled() - 
teleportPlayer
public void teleportPlayer(@NotNull @NotNull MmcPlayer mmcPlayer, @Nullable @Nullable org.bukkit.Location location) Asynchronously teleport a player to a location- Parameters:
 mmcPlayer- Player to teleportlocation- Target location
 - 
teleportPlayersToSpawn
public void teleportPlayersToSpawn()Teleport all players to their spawn - 
teleportPlayerToSpawn
Teleport a player to his spawn- Parameters:
 player-MmcPlayerto teleport
 - 
setPlayerSpawn
public void setPlayerSpawn(@NotNull @NotNull MmcPlayer mmcPlayer, @Nullable @Nullable org.bukkit.Location location) Asynchronously set a player spawn- Parameters:
 mmcPlayer- Player to set spawnlocation- Target location
 - 
broadcast
public void broadcast(@Nonnull net.kyori.adventure.text.Component message) Broadcast a message to all players in the instance- Parameters:
 message- Message to broadcast
 - 
onPlayerReconnect
Called to reconnect a disconnected player- Parameters:
 mmcPlayer- Player to reconnect
 - 
onPlayerDisconnect
Called when a player disconnect from the server - 
updateState
Called to update instance state for InstanceManager- Parameters:
 state- New InstanceState
 - 
onSpectatorJoin
Called when a spectator spectate this game- Parameters:
 spectator- MmcPlayer instance of the spectator
 - 
onSpectatorLeave
Called when a spectator stop spectating this game- Parameters:
 spectator- MmcPlayer instance of the spectator
 - 
isPlayerOnInstance
Check if the player is on this instance- Parameters:
 mmcPlayer- Target player- Returns:
 - True if the player is on this instance
 
 - 
isSpectatorOnInstance
Check if the spectator is on this instance- Parameters:
 spectator- Target spectator- Returns:
 - True if the spectator is on this instance
 
 - 
getPlugin
public org.bukkit.plugin.Plugin getPlugin() - 
getSpectators
 - 
getLogger
 - 
getInstanceSettings
 - 
getInstanceLocation
public org.bukkit.Location getInstanceLocation() - 
getTeams
 - 
getInstanceId
public int getInstanceId() - 
getInstanceEntities
 - 
getRemainingTime
public int getRemainingTime() - 
isRunning
public boolean isRunning() - 
getPlayers
 - 
getInstanceState
 - 
getPlayerSpawns
 - 
getInstanceStateUpdates
 - 
setRemainingTime
public void setRemainingTime(int remainingTime)  
 -