Compare commits
2 Commits
master
..
234849e6ab
| Author | SHA1 | Date | |
|---|---|---|---|
| 234849e6ab | |||
| 658780cb3a |
Generated
-10
@@ -1,15 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Kotlin2JsCompilerArguments">
|
|
||||||
<option name="moduleKind" value="plain" />
|
|
||||||
</component>
|
|
||||||
<component name="Kotlin2JvmCompilerArguments">
|
|
||||||
<option name="jvmTarget" value="1.8" />
|
|
||||||
</component>
|
|
||||||
<component name="KotlinCommonCompilerArguments">
|
|
||||||
<option name="apiVersion" value="2.1" />
|
|
||||||
<option name="languageVersion" value="2.1" />
|
|
||||||
</component>
|
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="2.2.20-RC2" />
|
<option name="version" value="2.2.20-RC2" />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
Generated
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="corretto-1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<groupId>main</groupId>
|
<groupId>main</groupId>
|
||||||
<artifactId>vpSecure</artifactId>
|
<artifactId>vpSecure</artifactId>
|
||||||
<name>vpSecure</name>
|
<name>vpSecure</name>
|
||||||
<version>1.0.1</version>
|
<version>1.0</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<jvmTarget>1.8</jvmTarget>
|
<jvmTarget>${java.version}</jvmTarget>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -117,8 +117,8 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
|
<kotlin.version>2.2.20-RC2</kotlin.version>
|
||||||
<java.version>17</java.version>
|
<java.version>17</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<kotlin.version>2.2.20-RC2</kotlin.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>main</groupId>
|
<groupId>main</groupId>
|
||||||
<artifactId>vpSecure</artifactId>
|
<artifactId>vpSecure</artifactId>
|
||||||
<version>1.0.2</version>
|
<version>1.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>vpSecure</name>
|
<name>vpSecure</name>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<jvmTarget>1.8</jvmTarget>
|
<jvmTarget>${java.version}</jvmTarget>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package main.vpSecure
|
package main.vpSecure
|
||||||
|
|
||||||
import org.bukkit.command.Command
|
|
||||||
import org.bukkit.command.CommandExecutor
|
|
||||||
import org.bukkit.command.CommandSender
|
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
import org.bukkit.event.Listener
|
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, CommandExecutor {
|
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
|
||||||
@@ -20,10 +20,7 @@ class VpSecure : JavaPlugin(), Listener, CommandExecutor {
|
|||||||
// Register event listener
|
// Register event listener
|
||||||
server.pluginManager.registerEvents(this, this)
|
server.pluginManager.registerEvents(this, this)
|
||||||
|
|
||||||
// Register command
|
logger.info("VpSecure has been enabled with proxy IP: $PROXYIP")
|
||||||
getCommand("vpsecure")?.setExecutor(this)
|
|
||||||
|
|
||||||
logger.info("VpSecure has been enabled with allowed proxy IPs: $ALLOWED_PROXY_IPS")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDisable() {
|
override fun onDisable() {
|
||||||
@@ -45,34 +42,19 @@ class VpSecure : JavaPlugin(), Listener, CommandExecutor {
|
|||||||
|
|
||||||
// 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"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
|
|
||||||
if (command.name.equals("vpsecure", ignoreCase = true)) {
|
|
||||||
if (args.isNotEmpty() && args[0].equals("reload", ignoreCase = true)) {
|
|
||||||
loadConfig()
|
|
||||||
sender.sendMessage("VpSecure configuration reloaded. Allowed proxy IPs: $ALLOWED_PROXY_IPS")
|
|
||||||
logger.info("VpSecure configuration reloaded by ${sender.name}")
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("Usage: /vpsecure reload")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
allowed_proxy_ips:
|
# VpSecure Configuration
|
||||||
- "127.0.0.1"
|
proxy_ip: "127.0.0.1"
|
||||||
@@ -1,15 +1,6 @@
|
|||||||
name: vpSecure
|
name: vpSecure
|
||||||
version: '1.0.2'
|
version: '1.0'
|
||||||
main: main.vpSecure.VpSecure
|
main: main.vpSecure.VpSecure
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
authors: [ _SAN5_SkeLet0n_ ]
|
authors: [ _SAN5_SkeLet0n_ ]
|
||||||
website: voidproject.del.pw
|
website: voidproject.del.pw
|
||||||
commands:
|
|
||||||
vpsecure:
|
|
||||||
description: VpSecure management commands
|
|
||||||
usage: /vpsecure reload
|
|
||||||
permission: vpsecure.admin
|
|
||||||
permissions:
|
|
||||||
vpsecure.admin:
|
|
||||||
description: Allows reloading VpSecure configuration
|
|
||||||
default: op
|
|
||||||
Reference in New Issue
Block a user