-
-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add server registered/unregistered events (#1386)
* feat: Add server registered/unregistered events * Annotate new API with `@Beta` * Migrate from classes to records * Add null checks * Fix code style indent * Add links in documentation * Fix docs indent --------- Co-authored-by: powercas_gamer <[email protected]>
- Loading branch information
1 parent
44b1e0c
commit 09f687e
Showing
3 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
api/src/main/java/com/velocitypowered/api/event/proxy/server/ServerRegisteredEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2024 Velocity Contributors | ||
* | ||
* The Velocity API is licensed under the terms of the MIT License. For more details, | ||
* reference the LICENSE file in the api top-level directory. | ||
*/ | ||
|
||
package com.velocitypowered.api.event.proxy.server; | ||
|
||
import com.google.common.annotations.Beta; | ||
import com.google.common.base.Preconditions; | ||
import com.velocitypowered.api.proxy.server.RegisteredServer; | ||
import com.velocitypowered.api.proxy.server.ServerInfo; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* This event is fired by the proxy after a backend server is registered to the server map. | ||
* Currently, it may occur when a server is registered dynamically at runtime or when a server is | ||
* replaced due to configuration reload. | ||
* | ||
* @see com.velocitypowered.api.proxy.ProxyServer#registerServer(ServerInfo) | ||
* | ||
* @param registeredServer A {@link RegisteredServer} that has been registered. | ||
* @since 3.3.0 | ||
*/ | ||
@Beta | ||
public record ServerRegisteredEvent(@NotNull RegisteredServer registeredServer) { | ||
public ServerRegisteredEvent { | ||
Preconditions.checkNotNull(registeredServer, "registeredServer"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
api/src/main/java/com/velocitypowered/api/event/proxy/server/ServerUnregisteredEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (C) 2024 Velocity Contributors | ||
* | ||
* The Velocity API is licensed under the terms of the MIT License. For more details, | ||
* reference the LICENSE file in the api top-level directory. | ||
*/ | ||
|
||
package com.velocitypowered.api.event.proxy.server; | ||
|
||
import com.google.common.annotations.Beta; | ||
import com.google.common.base.Preconditions; | ||
import com.velocitypowered.api.proxy.server.RegisteredServer; | ||
import com.velocitypowered.api.proxy.server.ServerInfo; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* This event is fired by the proxy after a backend server is unregistered from the server map. | ||
* Currently, it may occur when a server is unregistered dynamically at runtime | ||
* or when a server is replaced due to configuration reload. | ||
* | ||
* @see com.velocitypowered.api.proxy.ProxyServer#unregisterServer(ServerInfo) | ||
* | ||
* @param unregisteredServer A {@link RegisteredServer} that has been unregistered. | ||
* @since 3.3.0 | ||
*/ | ||
@Beta | ||
public record ServerUnregisteredEvent(@NotNull RegisteredServer unregisteredServer) { | ||
public ServerUnregisteredEvent { | ||
Preconditions.checkNotNull(unregisteredServer, "unregisteredServer"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters