Skip to content

Commit

Permalink
feat: add Spartan support
Browse files Browse the repository at this point in the history
  • Loading branch information
CerealAxis committed Jan 13, 2025
1 parent 5b25140 commit 19de52e
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 18 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
compileOnly(files("libs/Matrix_7.12.4.jar"))
compileOnly(files("libs/VulcanAPI.jar"))
compileOnly(files("libs/LightAntiCheat.jar"))
compileOnly(files("libs/SpartanAPI.jar"))
implementation("com.github.MWHunter:GrimAPI:9f5aaef74b")
compileOnly("com.github.Elikill58:Negativity:2.7.1")
//other dependencies
Expand Down
Binary file added libs/SpartanAPI.jar
Binary file not shown.
29 changes: 20 additions & 9 deletions src/main/java/cn/xor7/iseeyou/ISeeYou.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package cn.xor7.iseeyou

import cn.xor7.iseeyou.anticheat.AntiCheatListener
import cn.xor7.iseeyou.anticheat.EventListener
import cn.xor7.iseeyou.anticheat.listeners.*
import cn.xor7.iseeyou.anticheat.suspiciousPhotographers
import cn.xor7.iseeyou.metrics.Metrics
import cn.xor7.iseeyou.updatechecker.CompareVersions
import cn.xor7.iseeyou.updatechecker.UpdateChecker
import cn.xor7.iseeyou.utils.ConfigData
import cn.xor7.iseeyou.utils.InstantReplayManager
import cn.xor7.iseeyou.utils.TomlEx
import cn.xor7.iseeyou.utils.metrics.Metrics
import cn.xor7.iseeyou.utils.updatechecker.CompareVersions
import cn.xor7.iseeyou.utils.updatechecker.UpdateChecker
import dev.jorel.commandapi.CommandAPI
import dev.jorel.commandapi.CommandAPIBukkitConfig
import dev.jorel.commandapi.arguments.ArgumentSuggestions
Expand Down Expand Up @@ -149,6 +153,13 @@ class ISeeYou : JavaPlugin(), CommandExecutor {
Bukkit.getPluginManager().registerEvents(LightAntiCheatListener(), this)
logInfo("注册 LightAntiCheat 监听器...")
}

if (Bukkit.getPluginManager()
.isPluginEnabled("Spartan") && toml!!.data.recordSuspiciousPlayer.enableSpartanIntegration
) {
Bukkit.getPluginManager().registerEvents(SpartanListener(), this)
logInfo("注册 Spartan 监听器...")
}
}

private fun checkForUpdates() {
Expand All @@ -158,14 +169,14 @@ class ISeeYou : JavaPlugin(), CommandExecutor {
val comparisonResult = CompareVersions.compareVersions(currentVersion, latestVersion)
val logMessage = when {
comparisonResult < 0 -> {
"[版本检测] 有新版本可用: $latestVersion\n" +
"[MineBBS] https://www.minebbs.com/resources/iseeyou.7276/updates\n" +
"[Hangar] https://hangar.papermc.io/CerealAxis/ISeeYou/versions\n" +
"[Github] https://github.com/MC-XiaoHei/ISeeYou/releases/"
"有新版本可用: $latestVersion\n" +
"MineBBShttps://www.minebbs.com/resources/iseeyou.7276/updates\n" +
"Hangarhttps://hangar.papermc.io/CerealAxis/ISeeYou/versions\n" +
"Githubhttps://github.com/MC-XiaoHei/ISeeYou/releases/"
}

comparisonResult == 0 -> "[版本检测] 您的插件已经是最新版本!"
else -> "[版本检测] 您可能在使用测试版插件,最新正式版版本为 $latestVersion"
comparisonResult == 0 -> "您的插件已经是最新版本!"
else -> "您可能在使用测试版插件,最新正式版版本为 $latestVersion"
}
logInfo(logMessage)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package cn.xor7.iseeyou.anticheat

import cn.xor7.iseeyou.EventListener
import cn.xor7.iseeyou.instance
import cn.xor7.iseeyou.toml
import org.bukkit.Bukkit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package cn.xor7.iseeyou
package cn.xor7.iseeyou.anticheat

import cn.xor7.iseeyou.utils.InstantReplayManager
import cn.xor7.iseeyou.highSpeedPausedPhotographers
import cn.xor7.iseeyou.photographers
import cn.xor7.iseeyou.toml
import org.bukkit.Bukkit
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cn.xor7.iseeyou.anticheat.listeners

import cn.xor7.iseeyou.anticheat.AntiCheatListener
import org.bukkit.Bukkit
import org.bukkit.event.EventHandler
import me.vagdedes.spartan.api.PlayerViolationEvent
import org.bukkit.event.Listener


class SpartanListener : Listener {
@EventHandler
fun onAlert(e: PlayerViolationEvent) = Bukkit.getPlayer(e.player.uniqueId)
?.let { AntiCheatListener.onAntiCheatAction(it) }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.xor7.iseeyou
package cn.xor7.iseeyou.utils

import org.bukkit.entity.Player

Expand Down Expand Up @@ -70,6 +70,7 @@ data class RecordSuspiciousPlayerConfig(
var enableNegativityIntegration: Boolean = false,
var enableGrimACIntegration: Boolean = false,
var enableLightAntiCheatIntegration: Boolean = false,
var enableSpartanIntegration: Boolean = false,
var recordMinutes: Long = 5,
var recordPath: String = "replay/suspicious/\${name}@\${uuid}",
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cn.xor7.iseeyou
package cn.xor7.iseeyou.utils

import cn.xor7.iseeyou.EventListener.DATE_FORMATTER
import cn.xor7.iseeyou.anticheat.EventListener.DATE_FORMATTER
import cn.xor7.iseeyou.instance
import cn.xor7.iseeyou.toml
import net.jodah.expiringmap.ExpirationPolicy
import net.jodah.expiringmap.ExpiringMap
import org.bukkit.Bukkit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.xor7.iseeyou;
package cn.xor7.iseeyou.utils;

import com.moandjiezana.toml.Toml;
import com.moandjiezana.toml.TomlWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
* Violations will result in a ban of your plugin and account from bStats.
*/
package cn.xor7.iseeyou.metrics;
package cn.xor7.iseeyou.utils.metrics;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.xor7.iseeyou.updatechecker
package cn.xor7.iseeyou.utils.updatechecker

import java.util.logging.Logger
import kotlin.math.max
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.xor7.iseeyou.updatechecker;
package cn.xor7.iseeyou.utils.updatechecker;

import com.google.gson.Gson;
import org.bukkit.Bukkit;
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ dependencies:
load: BEFORE
required: false
LightAntiCheat:
load: BEFORE
required: false
Spartan:
load: BEFORE
required: false

0 comments on commit 19de52e

Please sign in to comment.