This code is part of a Spigot plugin for Minecraft designed to detect and manage VPN connections among players. Here's a detailed description of its functionality:
Overview
The plugin,
AntiVPN, includes utility functions to perform API requests that check if a player is using a VPN based on their IP address. It has a listener to trigger these checks when a player joins the server.
Key Components
- FetchAPIUtils Class:
- Responsible for making API requests to proxycheck.io to verify if a given IP address is associated with a VPN.
- The method makeAPIRequest(String ip, String playerName):
- Checks if the anti-VPN feature is active and logs settings.
- It verifies if the player's IP is in a whitelist (allowVPNIPS), in which case it logs the detection and exits.
- If the IP is not allowed, it sends a GET request to the proxy check API.
- It processes the API response to determine if the connection is a VPN. If so, it logs the event and issues a kick command to the player, replacing placeholders in the kick message.
- JoinListener Class:
- Implements the Listener interface to respond to player join events.
- In the onJoin(PlayerJoinEvent e) method, it retrieves the joining player's IP address and name, and invokes the makeAPIRequest method to check for VPN usage.
Configuration Options
- The plugin reads settings from its configuration:
- active: A boolean to enable or disable the VPN check.
- logger: Controls whether log messages are displayed.
- KickMessage: Custom message sent to players detected using a VPN.
- KickCommand: Command issued to kick players, with placeholders for player name and kick message.
- allowVPNIPS: A list of IP addresses that are exempt from VPN checks.
Usage
When a player joins the server:
- Their IP is checked against the allowed list.
- If not on the list, an API request is made to determine if the IP is a VPN.
- If a VPN is detected, the player is kicked with a specified message.
Conclusion
The
AntiVPN plugin enhances server security by identifying and managing VPN usage among players, providing server administrators with tools to maintain a fair gaming environment.