-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for VanishBridge. Raised the target Java version from 1…
…1 to 17.
- Loading branch information
Showing
5 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
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
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
41 changes: 41 additions & 0 deletions
41
src/main/java/voruti/velocityplayerlistquery/hook/VanishBridgeHook.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,41 @@ | ||
package voruti.velocityplayerlistquery.hook; | ||
|
||
import com.google.inject.Inject; | ||
import com.velocitypowered.api.proxy.Player; | ||
import com.velocitypowered.api.proxy.ProxyServer; | ||
import dev.loapu.vanishbridge.api.model.VanishBridgePlayer; | ||
import lombok.AccessLevel; | ||
import lombok.experimental.FieldDefaults; | ||
import dev.loapu.vanishbridge.api.VanishBridgeProvider; | ||
|
||
import javax.inject.Singleton; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
@Singleton | ||
@FieldDefaults(level = AccessLevel.PRIVATE) | ||
public class VanishBridgeHook { | ||
@Inject | ||
ProxyServer server; | ||
|
||
public boolean hooked() { | ||
return server.getPluginManager().isLoaded("vanishbridge"); | ||
} | ||
|
||
public Collection<Player> unvanishedPlayers() { | ||
var allPlayers = server.getAllPlayers(); | ||
Collection<Player> unvanishedPlayers = new ArrayList<>(); | ||
var vanishedPlayers = VanishBridgeProvider.get().vanishedPlayers(); | ||
allPlayers.forEach(player -> { | ||
if (vanishedPlayers.stream().noneMatch(vanishedPlayer -> vanishedPlayer.uuid().equals(player.getUniqueId()))) { | ||
unvanishedPlayers.add(player); | ||
} | ||
}); | ||
|
||
return unvanishedPlayers; | ||
} | ||
|
||
public int unvanishedPlayerCount() { | ||
return unvanishedPlayers().size(); | ||
} | ||
} |
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
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