Compare commits
No commits in common. "master" and "v1.0.0" have entirely different histories.
@ -5,10 +5,13 @@ import org.bukkit.event.Listener
|
|||||||
import org.bukkit.event.player.PlayerLoginEvent
|
import org.bukkit.event.player.PlayerLoginEvent
|
||||||
import org.bukkit.plugin.java.JavaPlugin
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.io.OutputStream
|
||||||
|
|
||||||
class VpSecure : JavaPlugin(), Listener {
|
class VpSecure : JavaPlugin(), Listener {
|
||||||
|
|
||||||
private var ALLOWED_PROXY_IPS: List<String> = listOf("127.0.0.1")
|
public var PROXYIP: String? = "1.1.1.1"
|
||||||
|
|
||||||
override fun onEnable() {
|
override fun onEnable() {
|
||||||
// Load configuration
|
// Load configuration
|
||||||
@ -17,7 +20,7 @@ class VpSecure : JavaPlugin(), Listener {
|
|||||||
// Register event listener
|
// Register event listener
|
||||||
server.pluginManager.registerEvents(this, this)
|
server.pluginManager.registerEvents(this, this)
|
||||||
|
|
||||||
logger.info("VpSecure has been enabled with allowed proxy IPs: $ALLOWED_PROXY_IPS")
|
logger.info("VpSecure has been enabled with proxy IP: $PROXYIP")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDisable() {
|
override fun onDisable() {
|
||||||
@ -39,15 +42,15 @@ class VpSecure : JavaPlugin(), Listener {
|
|||||||
|
|
||||||
// Load the configuration
|
// Load the configuration
|
||||||
val config = org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(configFile)
|
val config = org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(configFile)
|
||||||
ALLOWED_PROXY_IPS = config.getStringList("allowed_proxy_ips")
|
PROXYIP = config.getString("proxy_ip", "1.1.1.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onPlayerLogin(event: PlayerLoginEvent) {
|
fun onPlayerLogin(event: PlayerLoginEvent) {
|
||||||
val ip = event.realAddress.toString().replace("/", "")
|
val ip = event.realAddress.toString().replace("/", "")
|
||||||
|
|
||||||
// Check if player's IP matches any of the configured proxy IPs
|
// Check if player's IP matches the configured proxy IP
|
||||||
if (ip !in ALLOWED_PROXY_IPS) {
|
if (ip != PROXYIP) {
|
||||||
event.disallow(
|
event.disallow(
|
||||||
PlayerLoginEvent.Result.KICK_OTHER,
|
PlayerLoginEvent.Result.KICK_OTHER,
|
||||||
"Подключение с этого айпи запрещено: ${ip}. Если это ошибка - напишите по контактам voidproject.del.pw"
|
"Подключение с этого айпи запрещено: ${ip}. Если это ошибка - напишите по контактам voidproject.del.pw"
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
allowed_proxy_ips:
|
# VpSecure Configuration
|
||||||
- "127.0.0.1"
|
proxy_ip: "127.0.0.1"
|
Loading…
Reference in New Issue
Block a user