├── settings.gradle ├── Images ├── Commands.png ├── Features.png ├── Overview.png ├── Support.png ├── Template.png ├── MinerTrack.png ├── Permissions.png ├── Configuration.png ├── Installation.png ├── Requirements.png └── MinerTrack_64x.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .github ├── ISSUE_TEMPLATE │ ├── Feature_Request_CN.md │ ├── Feature_Request.md │ ├── BUG_Report_CN.md │ ├── bug报告--folia-.md │ ├── BUG_Report.md │ └── bug-report--folia-.md └── workflows │ └── AutoBuild_CI_dev.yml ├── .gitignore ├── .settings ├── org.eclipse.buildship.core.prefs └── org.eclipse.jdt.core.prefs ├── src └── main │ ├── java │ └── link │ │ └── star_dust │ │ └── MinerTrack │ │ ├── FoliaCheck.java │ │ ├── listeners │ │ ├── LogCacheListener.java │ │ └── MiningDetectionExtension.java │ │ ├── Notifier.java │ │ ├── utils │ │ └── LogViewerUtils.java │ │ ├── hooks │ │ ├── CustomJsonWebHook.java │ │ └── DiscordWebHook.java │ │ ├── managers │ │ ├── LanguageManager.java │ │ ├── ConfigManager.java │ │ ├── UpdateManager.java │ │ └── ViolationManager.java │ │ ├── MinerTrack.java │ │ └── commands │ │ └── MinerTrackCommand.java │ └── resources │ ├── plugin.yml │ ├── Translations │ ├── zh_cn.yml │ └── fr.yml │ ├── language.yml │ └── config.yml ├── .classpath ├── .project ├── gradlew.bat ├── README-zh_hans.md ├── README.md ├── gradlew └── LICENSE /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'MinerTrack' 2 | -------------------------------------------------------------------------------- /Images/Commands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/Commands.png -------------------------------------------------------------------------------- /Images/Features.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/Features.png -------------------------------------------------------------------------------- /Images/Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/Overview.png -------------------------------------------------------------------------------- /Images/Support.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/Support.png -------------------------------------------------------------------------------- /Images/Template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/Template.png -------------------------------------------------------------------------------- /Images/MinerTrack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/MinerTrack.png -------------------------------------------------------------------------------- /Images/Permissions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/Permissions.png -------------------------------------------------------------------------------- /Images/Configuration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/Configuration.png -------------------------------------------------------------------------------- /Images/Installation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/Installation.png -------------------------------------------------------------------------------- /Images/Requirements.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/Requirements.png -------------------------------------------------------------------------------- /Images/MinerTrack_64x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/Images/MinerTrack_64x.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/At87668/MinerTrack/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_Request_CN.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 功能请求 3 | about: 为这个插件提出一个想法 4 | title: "请求标题" 5 | labels: "➕Enhancement" 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### 请求标题 11 | 12 | #### 想要的功能 13 | 14 | [描述] 15 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_Request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this plugin. 4 | title: "Request Title" 5 | labels: "➕Enhancement" 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Request Title 11 | 12 | #### Wanted Feature 13 | 14 | [Description] 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle 2 | .gradle/ 3 | !gradle/wrapper/gradle-wrapper.jar 4 | !**/src/main/**/build/ 5 | !**/src/test/**/build/ 6 | build/ 7 | bin/ 8 | 9 | # Wiki 10 | wiki/ 11 | 12 | # VS Code 13 | .vscode/ 14 | *.code-workspace 15 | 16 | # Cache 17 | *.class 18 | 19 | # Script 20 | *.py 21 | 22 | # Changes Log 23 | Updates.md 24 | 25 | # Eclipse 26 | .classpath 27 | .project -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_Report_CN.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: BUG报告 3 | about: 如果你想报告一个BUG, 选择这个 4 | title: "[Minecraft版本] 问题标题" 5 | labels: "❌BUG" 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### [Minecraft版本] 问题标题 11 | 12 | - [x] 已在Paper测试 13 | - [x] 已在仅有此插件的情况下测试 14 | #### 描述 15 | 16 | [描述] 17 | 18 | #### 服务器日志 19 | 20 | [使用类似 [Github Gist](https://gist.github.com/) 或 [PasteBin](https://pastebin.com/) 的平台] 21 | 22 | #### 安装的插件 23 | [使用 "/plugin"获取] 24 | 25 | #### 插件版本 26 | [插件版本] 27 | 28 | #### Minecraft版本 29 | [Minecraft版本] 30 | 31 | #### 服务端类型 32 | [如 Spigot 或 Paper] 33 | 34 | #### 如何复现 35 | 1. 步骤 1 36 | 1. 步骤 2 37 | 1. 步骤 ... 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug报告--folia-.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: BUG报告 (Folia) 3 | about: 如果你想报告一个BUG, 选择这个 4 | title: "[Minecraft版本] 问题标题" 5 | labels: "❌BUG, \U0001F343Folia" 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### [Minecraft版本] 问题标题 11 | 12 | - [x] 已在Folia测试 13 | - [x] 已在仅有此插件的情况下测试 14 | #### 描述 15 | 16 | [描述] 17 | 18 | #### 服务器日志 19 | 20 | [使用类似 [Github Gist](https://gist.github.com/) 或 [PasteBin](https://pastebin.com/) 的平台] 21 | 22 | #### 安装的插件 23 | [使用 "/plugin"获取] 24 | 25 | #### 插件版本 26 | [插件版本] 27 | 28 | #### Minecraft版本 29 | [Minecraft版本] 30 | 31 | #### 服务端类型 32 | [如 Spigot 或 Paper] 33 | 34 | #### 如何复现 35 | 1. 步骤 1 36 | 1. 步骤 2 37 | 1. 步骤 ... 38 | -------------------------------------------------------------------------------- /.settings/org.eclipse.buildship.core.prefs: -------------------------------------------------------------------------------- 1 | arguments=--init-script C\:\\Users\\Administrator\\AppData\\Roaming\\Code\\User\\globalStorage\\redhat.java\\1.50.0\\config_win\\org.eclipse.osgi\\58\\0\\.cp\\gradle\\init\\init.gradle --init-script C\:\\Users\\Administrator\\AppData\\Roaming\\Code\\User\\globalStorage\\redhat.java\\1.50.0\\config_win\\org.eclipse.osgi\\58\\0\\.cp\\gradle\\protobuf\\init.gradle 2 | auto.sync=false 3 | build.scans.enabled=false 4 | connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) 5 | connection.project.dir= 6 | eclipse.preferences.version=1 7 | gradle.user.home= 8 | java.home=C\:/Program Files/Java/zulu17.46.19-ca-jdk17.0.9-win_x64 9 | jvm.arguments= 10 | offline.mode=false 11 | override.workspace.settings=true 12 | show.console.view=true 13 | show.executions.view=true 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_Report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: BUG Report 3 | about: If you want to report a bug, select this. 4 | title: "[Minecraft Version] Issue Title" 5 | labels: "❌BUG" 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### [Minecraft Version] Issue Title 11 | 12 | - [x] Tested on Paper 13 | - [x] Tested with this plugin only 14 | #### Description 15 | 16 | [Description] 17 | 18 | #### Server Log 19 | 20 | [Using [Github Gist](https://gist.github.com/) or [PasteBin](https://pastebin.com/) like.] 21 | 22 | #### Installed Plugins 23 | [Use "/plugin" to get.] 24 | 25 | #### Plugin Version 26 | [Plugin's version.] 27 | 28 | #### Minecraft Version 29 | [Minecraft's version.] 30 | 31 | #### Server Software 32 | [Server software name like Spigot or Paper.] 33 | 34 | #### How to reproduce 35 | 1. Step 1 36 | 1. Step 2 37 | 1. Step ... 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report--folia-.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: BUG Report (Folia) 3 | about: If you want to report a bug, select this. 4 | title: "[Minecraft Version] Issue Title" 5 | labels: "❌BUG, \U0001F343Folia" 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### [Minecraft Version] Issue Title 11 | 12 | - [x] Tested on Folia 13 | - [x] Tested with this plugin only 14 | #### Description 15 | 16 | [Description] 17 | 18 | #### Server Log 19 | 20 | [Using [Github Gist](https://gist.github.com/) or [PasteBin](https://pastebin.com/) like.] 21 | 22 | #### Installed Plugins 23 | [Use "/plugin" to get.] 24 | 25 | #### Plugin Version 26 | [Plugin's version.] 27 | 28 | #### Minecraft Version 29 | [Minecraft's version.] 30 | 31 | #### Server Software 32 | [Server software name like Spigot or Paper.] 33 | 34 | #### How to reproduce 35 | 1. Step 1 36 | 1. Step 2 37 | 1. Step ... 38 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/FoliaCheck.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/FoliaCheck.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack; 13 | 14 | public class FoliaCheck { 15 | private static Boolean isFolia = null; 16 | 17 | public static boolean isFolia() { 18 | if (isFolia == null) { 19 | try { 20 | Class.forName("io.papermc.paper.threadedregions.scheduler.RegionScheduler"); 21 | isFolia = true; 22 | } catch (ClassNotFoundException e) { 23 | isFolia = false; 24 | } 25 | } 26 | return isFolia; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PlayerDataRollback 4 | Project PlayerDataRollback created by Buildship. 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.buildship.core.gradleprojectbuilder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.buildship.core.gradleprojectnature 22 | 23 | 24 | 25 | 1739358334330 26 | 27 | 30 28 | 29 | org.eclipse.core.resources.regexFilterMatcher 30 | node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/listeners/LogCacheListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/listeners/LogCacheListener.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack.listeners; 13 | 14 | import org.bukkit.event.EventHandler; 15 | import org.bukkit.event.Listener; 16 | import org.bukkit.event.player.PlayerQuitEvent; 17 | import org.bukkit.entity.Player; 18 | import link.star_dust.MinerTrack.commands.MinerTrackCommand; 19 | 20 | public class LogCacheListener implements Listener { 21 | private final MinerTrackCommand command; 22 | 23 | public LogCacheListener(MinerTrackCommand command) { 24 | this.command = command; 25 | } 26 | 27 | @EventHandler 28 | public void onPlayerQuit(PlayerQuitEvent event) { 29 | Player player = event.getPlayer(); 30 | command.clearLogCache(player); 31 | } 32 | } -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=ignore 3 | org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore 4 | org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull 5 | org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=javax.annotation.ParametersAreNonnullByDefault 6 | org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.Nullable 7 | org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled 8 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 9 | org.eclipse.jdt.core.compiler.compliance=17 10 | org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning 11 | org.eclipse.jdt.core.compiler.problem.nullReference=warning 12 | org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning 13 | org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore 14 | org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning 15 | org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled 16 | org.eclipse.jdt.core.compiler.source=17 17 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/Notifier.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/Notifier.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack; 13 | 14 | import link.star_dust.MinerTrack.managers.LanguageManager; 15 | 16 | import java.util.Arrays; 17 | 18 | import org.bukkit.Bukkit; 19 | import org.bukkit.ChatColor; 20 | import org.bukkit.command.Command; 21 | import org.bukkit.command.CommandSender; 22 | import org.bukkit.entity.Player; 23 | 24 | public class Notifier { 25 | private final MinerTrack plugin; 26 | private final LanguageManager lang; 27 | 28 | public Notifier(MinerTrack plugin) { 29 | this.plugin = plugin; 30 | this.lang = plugin.getLanguageManager(); 31 | } 32 | 33 | public void kickPlayer(Player player, String reason) { 34 | player.kickPlayer(reason); 35 | } 36 | 37 | 38 | public void sendNotifyMessage(String messageContent) { 39 | // Define prefixes and add color codes 40 | String prefix = ChatColor.translateAlternateColorCodes('&', "&8[&9&lMiner&c&lTrack&8]&r "); 41 | String formattedMessage = prefix + ChatColor.translateAlternateColorCodes('&', messageContent); 42 | 43 | // Send message to players with permissions 44 | for (Player player : Bukkit.getOnlinePlayers()) { 45 | if (player.hasPermission("minertrack.notify")) { 46 | player.sendMessage(formattedMessage); 47 | } 48 | } 49 | 50 | // Send message to console 51 | Bukkit.getConsoleSender().sendMessage(formattedMessage); 52 | } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: MinerTrack 2 | version: 1.9.0-beta 3 | main: link.star_dust.MinerTrack.MinerTrack 4 | authors: [Author87668] 5 | contributors: [Author87668, Zhang12334] 6 | website: https://modrinth.com/plugin/minertrack 7 | api-version: 1.18 8 | folia-supported: true 9 | default-permission: false 10 | description: The Advanced Anti-Xray that you need, have you ever dreamed of a powerful anti-xray? 11 | commands: 12 | minertrack: 13 | description: Plugin's main command 14 | aliases: [mt, mtrack] 15 | usage: "/minertrack " 16 | permission: minertrack.use 17 | permissions: 18 | minertrack.use: 19 | description: Permission to access the root command "/mtrack" 20 | default: op 21 | minertrack.check: 22 | description: Allow player to use /mtrack check 23 | default: op 24 | minertrack.kick: 25 | description: Allow player to use /mtrack kick 26 | default: op 27 | minertrack.help: 28 | description: Allow player to use /mtrack help 29 | default: op 30 | minertrack.reset: 31 | description: Allow player to use /mtrack reset 32 | default: op 33 | minertrack.sendnotify: 34 | description: Allow player to use /mtrack notify 35 | default: op 36 | minertrack.verbose: 37 | description: Allow player to use /mtrack verbose 38 | default: op 39 | minertrack.reload: 40 | description: Allow player to use /mtrack reload 41 | default: op 42 | minertrack.bypass: 43 | description: Bypass the X-Ray detection 44 | default: op 45 | minertrack.notify: 46 | description: Receive notify information and verbose information 47 | default: op 48 | minertrack.checkupdate: 49 | description: Allow player to receive update information and use /mtrack update 50 | default: op 51 | minertrack.logs: 52 | description: Allow player to use /mtrack logs 53 | default: op 54 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/utils/LogViewerUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/utils/LogViewerUtils.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack.utils; 13 | 14 | import org.bukkit.command.CommandSender; 15 | import java.io.File; 16 | import java.io.IOException; 17 | import java.nio.charset.StandardCharsets; 18 | import java.nio.file.Files; 19 | import java.util.List; 20 | import java.util.Map; 21 | import java.util.concurrent.ConcurrentHashMap; 22 | 23 | public class LogViewerUtils { 24 | public static class LogCache { 25 | public String logName; 26 | public List lines; 27 | public int totalPages; 28 | public int currentPage; 29 | public LogCache(String logName, List lines, int totalPages, int currentPage) { 30 | this.logName = logName; 31 | this.lines = lines; 32 | this.totalPages = totalPages; 33 | this.currentPage = currentPage; 34 | } 35 | } 36 | 37 | private static final Map logCacheMap = new ConcurrentHashMap<>(); 38 | 39 | public static LogCache getCache(CommandSender sender) { 40 | return logCacheMap.get(sender); 41 | } 42 | public static void putCache(CommandSender sender, LogCache cache) { 43 | logCacheMap.put(sender, cache); 44 | } 45 | public static void clearCache(CommandSender sender) { 46 | logCacheMap.remove(sender); 47 | } 48 | 49 | public static List readLogFile(File logFile) throws IOException { 50 | return Files.readAllLines(logFile.toPath(), StandardCharsets.UTF_8); 51 | } 52 | 53 | public static int getTotalPages(int totalLines, int perPage) { 54 | return (int) Math.ceil((double) totalLines / perPage); 55 | } 56 | 57 | public static int[] getPageRange(int totalLines, int page, int perPage) { 58 | int start = (page - 1) * perPage; 59 | int end = Math.min(start + perPage, totalLines); 60 | return new int[]{start, end}; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /.github/workflows/AutoBuild_CI_dev.yml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | # This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time 6 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle 7 | 8 | name: MinerTrack Dev Build CI 9 | 10 | on: 11 | push: 12 | branches: [ "dev" ] 13 | pull_request: 14 | branches: [ "dev" ] 15 | 16 | jobs: 17 | build: 18 | 19 | runs-on: ubuntu-latest 20 | permissions: 21 | contents: read 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | - name: Set up JDK 17 26 | uses: actions/setup-java@v4 27 | with: 28 | java-version: '17' 29 | distribution: 'temurin' 30 | 31 | # Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. 32 | # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md 33 | - name: Setup Gradle 34 | uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 35 | 36 | - name: Build with Gradle Wrapper 37 | run: ./gradlew shadowJar 38 | 39 | - name: 'Upload Artifact' 40 | uses: actions/upload-artifact@v4 41 | with: 42 | name: MinerTrack-dev-${{ github.sha }} 43 | path: ./build/libs/*.jar 44 | retention-days: 90 45 | 46 | #- name: Coveralls Check 47 | # uses: coverallsapp/github-action@v2 48 | 49 | # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). 50 | # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. 51 | # 52 | # - name: Setup Gradle 53 | # uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 54 | # with: 55 | # gradle-version: '8.9' 56 | # 57 | # - name: Build with Gradle 8.9 58 | # run: gradle build 59 | 60 | # dependency-submission: 61 | # 62 | # runs-on: ubuntu-latest 63 | # permissions: 64 | # contents: write 65 | # 66 | # steps: 67 | # - uses: actions/checkout@v4 68 | # - name: Set up JDK 17 69 | # uses: actions/setup-java@v4 70 | # with: 71 | # java-version: '17' 72 | # distribution: 'temurin' 73 | # 74 | # # Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. 75 | # # See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md 76 | # - name: Generate and submit dependency graph 77 | # uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 78 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/hooks/CustomJsonWebHook.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/hooks/CustomJsonWebHook.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668, Zhang12334 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | 13 | package link.star_dust.MinerTrack.hooks; 14 | 15 | import link.star_dust.MinerTrack.MinerTrack; 16 | import org.apache.hc.client5.http.classic.methods.HttpPost; 17 | import org.apache.hc.core5.http.io.entity.StringEntity; 18 | import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; 19 | import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; 20 | import org.apache.hc.client5.http.impl.classic.HttpClients; 21 | import org.bukkit.Bukkit; 22 | 23 | import java.time.LocalDateTime; 24 | import java.time.format.DateTimeFormatter; 25 | import java.util.Map; 26 | import java.nio.charset.StandardCharsets; 27 | 28 | public class CustomJsonWebHook { 29 | private final MinerTrack plugin; 30 | private final String webHookUrl; 31 | private final String jsonFormat; 32 | 33 | public CustomJsonWebHook(MinerTrack plugin, String webHookUrl, String jsonFormat) { 34 | this.plugin = plugin; 35 | this.webHookUrl = webHookUrl; 36 | this.jsonFormat = jsonFormat; 37 | } 38 | 39 | public void sendMessage(Map placeholders) { 40 | Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { 41 | try (CloseableHttpClient httpClient = HttpClients.createDefault()) { 42 | HttpPost post = new HttpPost(webHookUrl); 43 | post.setHeader("Content-Type", "application/json; charset=UTF-8"); 44 | 45 | // Add timestamp 46 | placeholders.put("timestamp", LocalDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME)); 47 | 48 | // Replace holders 49 | String jsonPayload = jsonFormat; 50 | for (Map.Entry entry : placeholders.entrySet()) { 51 | jsonPayload = jsonPayload.replace("%" + entry.getKey() + "%", entry.getValue()); 52 | } 53 | 54 | // Debug: log webhook URL and payload preview 55 | //plugin.getLogger().info("[CustomJsonWebHook] Sending to URL: " + webHookUrl + " payload: " + jsonPayload); 56 | 57 | post.setEntity(new StringEntity(jsonPayload, StandardCharsets.UTF_8)); 58 | 59 | try (CloseableHttpResponse response = httpClient.execute(post)) { 60 | int statusCode = response.getCode(); 61 | if (statusCode != 200 && statusCode != 204) { 62 | plugin.getLogger().warning("Failed to send custom JSON webhook, Response Code: " + statusCode); 63 | } 64 | } 65 | 66 | } catch (Exception e) { 67 | plugin.getLogger().severe("Error while sending custom JSON webhook: " + e.getMessage()); 68 | e.printStackTrace(); 69 | } 70 | }); 71 | } 72 | } -------------------------------------------------------------------------------- /src/main/resources/Translations/zh_cn.yml: -------------------------------------------------------------------------------- 1 | #### MinerTrack Config - language.yml ################################################## 2 | # 3 | # 你好! 欢迎使用 MinerTrack anti-xray。这是 language.yml 文件, 4 | # 用于定义 anti-xray 插件显示的语言内容。你可以在这里自定义插件显示的所有消息。 5 | # 6 | # 有用的链接: 7 | # 获取更新: https://modrinth.com/plugin/minertrack 8 | # 查看源码: https://github.com/At87668/MinerTrack 9 | # 提交问题: https://github.com/At87668/MinerTrack/issues 10 | # 提交合并请求: https://github.com/At87668/MinerTrack/pulls 11 | # 查阅 Wiki: https://minertrack.pages.dev/wiki/ 12 | # 加入 Discord: https://discord.gg/MzTea2W9cb 13 | # 14 | # 不管怎样,感谢你使用 MinerTrack anti-xray!❤ 15 | # 16 | ##################################################################################### 17 | 18 | # 在此定义消息前缀 19 | prefix: '&8[&9&lMiner&c&lTrack&8]&r ' 20 | 21 | # 定义当玩家因使用 X-Ray 被踢出时的公告消息 22 | # 占位符: %player% %reason% 23 | kick-format: '&b%player% &7因涉嫌使用 X-Ray 被踢出服务器! &8(%reason%)' 24 | 25 | # 定义详细模式(verbose)消息格式 26 | # 占位符: %player% %vl% %add_vl% %block_type% %count% %vein_count% %world% %pos_x% %pos_y% %pos_z% 27 | verbose-format: '&7%player% 未通过 &fX-Ray &7检测 &7违规等级: %vl%&b(+%add_vl%) &7方块: &6%block_type%&ex%count%&7(矿脉&ax%vein_count%&7)&7 世界: %world% 位置: X%pos_x% Y%pos_y% Z%pos_z%' 28 | 29 | # 定义日志格式 30 | # 占位符: %year% %month% %day% %hour% %minute% %second% %player% %vl% %add_vl% %block_type% %count% %vein_count% %world% %pos_x% %pos_y% %pos_z% 31 | log-format: '%year%-%month%-%day% %hour%:%minute%:%second% | %player% 未通过 X-Ray 检测 违规等级: %vl%(+%add_vl%) 方块: %block_type%x%count%(矿脉x%vein_count%) 世界: %world% 位置: X%pos_x% Y%pos_y% Z%pos_z%' 32 | 33 | # 当玩家被踢出时,是否广播消息? 34 | kick-broadcast: true 35 | 36 | help: 37 | - "&8----[&9&lMiner&c&lTrack &6帮助&8]-----------" 38 | - "" 39 | - "&f/mtrack notify <消息> &7- 向工作人员发送警报" 40 | - "&f/mtrack verbose &7- 开启详细模式,当玩家违规等级上升时,向启用该模式的工作人员发送通知" 41 | - "&f/mtrack check <玩家> &7- 查看玩家的违规历史记录" 42 | - "&f/mtrack reset <玩家> &7- 重置玩家的违规记录" 43 | - "&f/mtrack help &7- 显示插件帮助信息" 44 | - "&f/mtrack update &7- 检查更新" 45 | - "&f/mtrack kick <玩家> <原因> &7- 以指定原因踢出玩家" 46 | - "&f/mtrack logs <日志文件名.log> &7- 查看 MinerTrack 日志文件" 47 | 48 | no-permission: "&c你没有权限使用此命令。" 49 | 50 | usage-notify: "&c用法: /mtrack notify <消息>" 51 | usage-check: "&c用法: /mtrack check <玩家>" 52 | usage-reset: "&c用法: /mtrack reset <玩家>" 53 | usage-kick: "&c用法: /mtrack kick <玩家> <原因>" 54 | usage-logs: "&c用法: /mtrack logs <日志文件名.log>" 55 | 56 | # 占位符: {player} 57 | reset-success: "&a成功重置 {player} 的违规记录。" 58 | 59 | # 占位符: {player} {level} 60 | violation-level: "&e{player} 的违规等级为 {level}。" 61 | 62 | # 占位符: {player} 63 | player-not-found: "&c未找到玩家 {player}。" 64 | 65 | config-reloaded: "&a配置与语言文件已成功重载。" 66 | 67 | unknown-command: "&c未知子命令。使用 /mtrack help 查看命令列表。" 68 | 69 | verbose-enable: "&7详细模式已&a启用&7!" 70 | verbose-disable: "&7详细模式已&c禁用&7!" 71 | 72 | # 日志查看器每页显示行数 73 | log-viewer-lines-per-page: 10 74 | log-viewer-header: "&7---- &9&lMiner&c&lTrack &b日志 &7({current_page}/{max_page}) ----" 75 | log-viewer-logs-color: "&7" 76 | log-viewer-not-found: "&c未找到日志文件 {log_file}。" 77 | log-viewer-not-log-file: "&c只能查看日志文件。" 78 | log-viewer-cant-read: "&c读取日志失败。" 79 | log-viewer-page-invalid: "&c页码超出范围 (1 - {max_page})。" 80 | log-viewer-page-nan: "&c页码必须为数字" 81 | log-viewer-next-page: "&6使用 &a/mtrack logs page {next_page} &6查看下一页。" 82 | log-viewer-empty: "&7无日志条目可显示。" 83 | 84 | # 占位符: %latest_version% 85 | update: 86 | alpha-available: '&c新 Alpha 版本 %latest_version% 现已可用!' 87 | beta-available: '&e新 Beta 版本 %latest_version% 现已可用!' 88 | stable-available: '&a新稳定版本 %latest_version% 现已可用!' 89 | using-latest: '&2你正在使用最新版本。' 90 | check-failed: '&c检查更新失败。' -------------------------------------------------------------------------------- /src/main/resources/language.yml: -------------------------------------------------------------------------------- 1 | #### MinerTrack Config - language.yml ################################################## 2 | # 3 | # Hi, welcome to use MinerTrack anti-xray, this is language.yml, which is used 4 | # to define the display language of anti-xray. Here you can define what message 5 | # the anti-xray displays. 6 | # 7 | # Useful Links: 8 | # Get Update: https://modrinth.com/plugin/minertrack 9 | # View Source: https://github.com/At87668/MinerTrack 10 | # Report Issue: https://github.com/At87668/MinerTrack/issues 11 | # Pull Requset: https://github.com/At87668/MinerTrack/pulls 12 | # Visit Wiki: https://minertrack.pages.dev/wiki/ 13 | # Join Discord: https://discord.gg/MzTea2W9cb 14 | # 15 | # Anyway, thanks for using MinerTrack anti-xray! ❤ 16 | # 17 | ##################################################################################### 18 | 19 | # You can define the message prefix here 20 | prefix: '&8[&9&lMiner&c&lTrack&8]&r ' 21 | 22 | # Define the announcement message after the player is kicked out by anti-xraying 23 | # Placeholders: %player% %reason% 24 | kick-format: '&b%player% &7kicked out of the server for allegedly using X-Ray! &8(%reason%)' 25 | 26 | # Define the verbose message format 27 | # Placeholders: %player% %vl% %add_vl% %block_type% %count% %vein_count% %world% %pos_x% %pos_y% %pos_z% 28 | verbose-format: '&7%player% failed &fX-Ray &7check &7VL:%vl%&b(+%add_vl%) &7Block:&6%block_type%&ex%count%&7(Vein&ax%vein_count%&7) &7World: %world% Pos: X%pos_x% Y%pos_y% Z%pos_z%' 29 | 30 | # Define the log format 31 | # Placeholders: %year% %month% %day% %hour% %minute% %second% %player% %vl% %add_vl% %block_type% %count% %vein_count% %world% %pos_x% %pos_y% %pos_z% 32 | log-format: '%year%-%month%-%day% %hour%:%minute%:%second% | %player% failed X-Ray check VL:%vl%(+%add_vl%) Block:%block_type%x%count%(Veinx%vein_count%) World: %world% Pos: X%pos_x% Y%pos_y% Z%pos_z%' 33 | 34 | # Should MinerTrack broadcast a message when a player is kicked? 35 | kick-broadcast: true 36 | 37 | help: 38 | - "&8----[&9&lMiner&c&lTrack &6Help&8]-----------" 39 | - "" 40 | - "&f/mtrack notify &7- Send alerts to staff" 41 | - "&f/mtrack verbose &7- Turn on Detailed Mode, and send a notification to the staff who have Detailed Mode enabled whenever the player's VL increases" 42 | - "&f/mtrack check &7- Check player's history of violations" 43 | - "&f/mtrack reset &7- Reset player's violation record" 44 | - "&f/mtrack help &7- Get plugin's help" 45 | - "&f/mtrack update &7- Check update" 46 | - "&f/mtrack kick &7- Kick the player with a specified reason" 47 | - "&f/mtrack logs &7- View a MinerTrack log file" 48 | 49 | no-permission: "&cYou do not have permission to use this command." 50 | 51 | usage-notify: "&cUsage: /mtrack notify " 52 | usage-check: "&cUsage: /mtrack check " 53 | usage-reset: "&cUsage: /mtrack reset " 54 | usage-kick: "&cUsage: /mtrack kick " 55 | usage-logs: "&cUsage: /mtrack logs " 56 | 57 | # Placeholders: {player} 58 | reset-success: "&aSuccessfully reset {player}'s violation record." 59 | 60 | # Placeholders: {player} {level} 61 | violation-level: "&e{player}'s violation level is {level}." 62 | 63 | # Placeholders: {player} 64 | player-not-found: "&cPlayer {player} not found." 65 | 66 | config-reloaded: "&aConfiguration and Language reloaded successfully." 67 | 68 | unknown-command: "&cUnknown subcommand. Use /mtrack help for a list of commands." 69 | 70 | verbose-enable: "&7Verbose Mode &aEnabled&7!" 71 | verbose-disable: "&7Verbose Mode &cDisabled&7!" 72 | 73 | # Placeholders: {current_page} {max_page} {log_file} {next_page} 74 | log-viewer-lines-per-page: 10 75 | log-viewer-header: "&7---- &9&lMiner&c&lTrack &bLogs &7({current_page}/{max_page}) ----" 76 | log-viewer-logs-color: "&7" 77 | log-viewer-not-found: "&cLog file {log_file} not found." 78 | log-viewer-not-log-file: "&cOnly can view log file." 79 | log-viewer-cant-read: "&cFailed to read logs." 80 | log-viewer-page-invalid: "&cPage number out of range (1 - {max_page})" 81 | log-viewer-page-nan: "&cPage number must be a number" 82 | log-viewer-next-page: "&6Use &a/mtrack logs page {next_page} &6to view next page." 83 | log-viewer-empty: "&7No log entries to display." 84 | 85 | # Placeholders: %latest_version% 86 | update: 87 | alpha-available: '&cNew alpha version %latest_version% now available!' 88 | beta-available: '&eNew beta version %latest_version% now available!' 89 | stable-available: '&aNew stable version %latest_version% now available!' 90 | using-latest: '&2You are using the latest version.' 91 | check-failed: '&cFailed to check for updates.' -------------------------------------------------------------------------------- /src/main/resources/Translations/fr.yml: -------------------------------------------------------------------------------- 1 | # ### MinerTrack Config - language.yml ################################################## 2 | # 3 | # Bonjour et bienvenue sur MinerTrack anti-xray, ceci est le fichier language.yml, 4 | # utilisé pour définir la langue d’affichage de l’anti-xray. Ici, vous pouvez définir 5 | # les messages que l’anti-xray affichera. 6 | # 7 | # Liens utiles : 8 | # Obtenir les mises à jour : https://modrinth.com/plugin/minertrack 9 | # Voir le code source : https://github.com/At87668/MinerTrack 10 | # Signaler un problème : https://github.com/At87668/MinerTrack/issues 11 | # Pull Request : https://github.com/At87668/MinerTrack/pulls 12 | # Consulter le Wiki : https://minertrack.pages.dev/wiki/ 13 | # Rejoindre le Discord : https://discord.gg/MzTea2W9cb 14 | # 15 | # Quoi qu’il en soit, merci d’utiliser MinerTrack anti-xray ! ❤ 16 | # 17 | # #################################################################################### 18 | 19 | # Vous pouvez définir ici le préfixe des messages 20 | prefix: '&8[&9&lMiner&c&lTrack&8]&r ' 21 | 22 | # Message d’annonce après qu’un joueur a été expulsé pour usage suspect de X-Ray 23 | # Placeholders : %player% %reason% 24 | kick-format: '&b%player% &7a été expulsé du serveur pour utilisation suspecte de X-Ray ! &8(%reason%)' 25 | 26 | # Format du message détaillé (verbose) 27 | # Placeholders : %player% %vl% %add_vl% %block_type% %count% %vein_count% %world% %pos_x% %pos_y% %pos_z% 28 | verbose-format: '&7%player% a échoué au &fcontrôle X-Ray &7VL:%vl%&b(+%add_vl%) &7Bloc:&6%block_type%&ex%count%&7(Veine&ax%vein_count%&7) 29 | &7Monde : %world% Pos : X%pos_x% Y%pos_y% Z%pos_z%' 30 | 31 | # Format des logs 32 | # Placeholders : %year% %month% %day% %hour% %minute% %second% %player% %vl% %add_vl% %block_type% %count% %vein_count% %world% %pos_x% %pos_y% %pos_z% 33 | log-format: '%year%-%month%-%day% %hour%:%minute%:%second% | %player% a échoué au contrôle X-Ray 34 | VL:%vl%(+%add_vl%) Bloc:%block_type%x%count%(Veinex%vein_count%) Monde : %world% 35 | Pos : X%pos_x% Y%pos_y% Z%pos_z%' 36 | 37 | # MinerTrack doit-il diffuser un message lorsqu’un joueur est expulsé ? 38 | kick-broadcast: true 39 | 40 | help: 41 | - '&8----[&9&lMiner&c&lTrack &6Aide&8]-----------' 42 | - '' 43 | - '&f/mtrack notify &7- Envoyer une alerte au staff' 44 | - '&f/mtrack verbose &7- Activer le mode détaillé et envoyer une notification au staff 45 | ayant le mode détaillé activé à chaque augmentation du VL d’un joueur' 46 | - '&f/mtrack check &7- Consulter l’historique des infractions d’un joueur' 47 | - '&f/mtrack reset &7- Réinitialiser les infractions d’un joueur' 48 | - '&f/mtrack help &7- Afficher l’aide du plugin' 49 | - '&f/mtrack update &7- Vérifier les mises à jour' 50 | - '&f/mtrack kick &7- Expulser un joueur avec une raison spécifiée' 51 | - '&f/mtrack logs &7- Consulter un fichier de logs MinerTrack' 52 | 53 | no-permission: '&cVous n’avez pas la permission d’utiliser cette commande.' 54 | 55 | usage-notify: '&cUtilisation : /mtrack notify ' 56 | usage-check: '&cUtilisation : /mtrack check ' 57 | usage-reset: '&cUtilisation : /mtrack reset ' 58 | usage-kick: '&cUtilisation : /mtrack kick ' 59 | usage-logs: '&cUtilisation : /mtrack logs ' 60 | 61 | # Placeholders : {player} 62 | reset-success: '&aLe niveau d’infraction de {player} a été réinitialisé avec succès.' 63 | 64 | # Placeholders : {player} {level} 65 | violation-level: '&eLe niveau d’infraction de {player} est de {level}.' 66 | 67 | # Placeholders : {player} 68 | player-not-found: '&cJoueur {player} introuvable.' 69 | 70 | config-reloaded: '&aConfiguration et langue rechargées avec succès.' 71 | 72 | unknown-command: '&cSous-commande inconnue. Utilisez /mtrack help pour la liste des commandes.' 73 | 74 | verbose-enable: '&7Mode Verbose &aActivé&7!' 75 | verbose-disable: '&7Mode Verbose &cDésactivé&7!' 76 | 77 | # Placeholders : {current_page} {max_page} {log_file} {next_page} 78 | log-viewer-lines-per-page: 10 79 | log-viewer-header: '&7---- &9&lMiner&c&lTrack &bLogs &7({current_page}/{max_page}) 80 | ----' 81 | log-viewer-logs-color: '&7' 82 | log-viewer-not-found: '&cFichier de log {log_file} introuvable.' 83 | log-viewer-not-log-file: '&cSeuls les fichiers de logs peuvent être consultés.' 84 | log-viewer-cant-read: '&cImpossible de lire les logs.' 85 | log-viewer-page-invalid: '&cNuméro de page hors limites (1 - {max_page})' 86 | log-viewer-page-nan: '&cLe numéro de page doit être un nombre' 87 | log-viewer-next-page: '&6Utilisez &a/mtrack logs page {next_page} &6pour voir la page suivante.' 88 | log-viewer-empty: '&7Aucune entrée de log à afficher.' 89 | 90 | # Placeholders : %latest_version% 91 | update: 92 | alpha-available: '&cUne nouvelle version alpha %latest_version% est disponible !' 93 | beta-available: '&eUne nouvelle version bêta %latest_version% est disponible !' 94 | stable-available: '&aUne nouvelle version stable %latest_version% est disponible !' 95 | using-latest: '&2Vous utilisez la dernière version.' 96 | check-failed: '&cÉchec de la vérification des mises à jour.' 97 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/listeners/MiningDetectionExtension.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/listeners/MiningDetectionExtension.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | 13 | package link.star_dust.MinerTrack.listeners; 14 | 15 | import org.bukkit.Bukkit; 16 | import org.bukkit.Location; 17 | import org.bukkit.Material; 18 | import org.bukkit.World; 19 | import org.bukkit.block.Block; 20 | import org.bukkit.entity.Player; 21 | import org.bukkit.event.EventHandler; 22 | import org.bukkit.event.Listener; 23 | import org.bukkit.event.block.BlockBreakEvent; 24 | 25 | import link.star_dust.MinerTrack.MinerTrack; 26 | 27 | import java.util.*; 28 | 29 | public class MiningDetectionExtension implements Listener { 30 | 31 | private final Map> miningHistory = new HashMap<>(); 32 | private final Map playerSuspicionMap = new HashMap<>(); 33 | private final MinerTrack plugin; 34 | 35 | public MiningDetectionExtension(MinerTrack plugin) { 36 | this.plugin = plugin; 37 | } 38 | 39 | public void register() { 40 | Bukkit.getPluginManager().registerEvents(this, plugin); 41 | //plugin.getLogger().info("ExtensionLoader > MiningDetectionExtension loaded!"); 42 | } 43 | 44 | private static class MiningFeature { 45 | int airBlocks; 46 | int solidBlocks; 47 | 48 | MiningFeature(int airBlocks, int solidBlocks) { 49 | this.airBlocks = airBlocks; 50 | this.solidBlocks = solidBlocks; 51 | } 52 | } 53 | 54 | @EventHandler 55 | public void onBlockBreak(BlockBreakEvent event) { 56 | Player player = event.getPlayer(); 57 | Block block = event.getBlock(); 58 | 59 | analyzeMiningPattern(player, block); 60 | } 61 | 62 | private void analyzeMiningPattern(Player player, Block block) { 63 | World world = block.getWorld(); 64 | if (world == null) return; 65 | 66 | Location location = block.getLocation(); 67 | int airBlocks = 0, solidBlocks = 0; 68 | 69 | // Analyze surrounding blocks 70 | for (int x = -1; x <= 1; x++) { 71 | for (int y = -1; y <= 1; y++) { 72 | for (int z = -1; z <= 1; z++) { 73 | if (x == 0 && y == 0 && z == 0) continue; // Ignore center block 74 | Block nearby = world.getBlockAt(location.clone().add(x, y, z)); 75 | if (nearby.getType() == Material.AIR && nearby.getType() == Material.CAVE_AIR) { 76 | airBlocks++; 77 | } else if (nearby.getType().isSolid()) { 78 | solidBlocks++; 79 | } 80 | } 81 | } 82 | } 83 | 84 | // Preserve mine features 85 | UUID playerId = player.getUniqueId(); 86 | MiningFeature currentFeature = new MiningFeature(airBlocks, solidBlocks); 87 | miningHistory.computeIfAbsent(playerId, k -> new ArrayList<>()).add(currentFeature); 88 | 89 | // keep window size of history to 5 90 | List history = miningHistory.get(playerId); 91 | if (history.size() > 5) { 92 | history.remove(0); 93 | } 94 | 95 | // Calculate historical feature averages 96 | int totalAir = 0, totalSolid = 0; 97 | for (MiningFeature feature : history) { 98 | totalAir += feature.airBlocks; 99 | totalSolid += feature.solidBlocks; 100 | } 101 | int averageAir = totalAir / history.size(); 102 | int averageSolid = totalSolid / history.size(); 103 | 104 | // Adjust suspicious values based on feature trends 105 | int suspicionLevel = playerSuspicionMap.getOrDefault(playerId, 0); 106 | if (averageSolid >= 7 && averageAir <= 1) { 107 | // road 108 | suspicionLevel += 5; 109 | } else if (averageAir >= 6) { 110 | // cave 111 | suspicionLevel -= 5; 112 | } else { 113 | // normal 114 | suspicionLevel += 1; 115 | } 116 | 117 | // update suspicious values 118 | playerSuspicionMap.put(playerId, suspicionLevel); 119 | 120 | // Output debug info 121 | plugin.getLogger().info(player.getName() + " -> Air: " + averageAir + ", Solid: " + averageSolid + ", Suspicion: " + suspicionLevel); 122 | } 123 | 124 | // Interface to obtain suspicious values 125 | public int getSuspicionLevel(UUID playerId) { 126 | return playerSuspicionMap.getOrDefault(playerId, 0); 127 | } 128 | 129 | public int getSuspicionLevel(Player player) { 130 | UUID playerID = Bukkit.getOfflinePlayer(player.getName()).getUniqueId(); 131 | return getSuspicionLevel(playerID); 132 | } 133 | 134 | public void resetSuspicionLevel(Player player) { 135 | UUID playerID = Bukkit.getOfflinePlayer(player.getName()).getUniqueId(); 136 | playerSuspicionMap.put(playerID, 0); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/hooks/DiscordWebHook.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/hooks/DiscordWebHook.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668, Zhang12334 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack.hooks; 13 | 14 | import com.google.gson.Gson; 15 | import com.google.gson.annotations.SerializedName; 16 | import link.star_dust.MinerTrack.MinerTrack; 17 | 18 | import javax.net.ssl.*; 19 | import java.security.cert.X509Certificate; 20 | import java.nio.charset.StandardCharsets; 21 | 22 | import org.apache.hc.client5.http.classic.methods.HttpPost; 23 | import org.apache.hc.core5.http.io.entity.StringEntity; 24 | import org.apache.hc.core5.http.ContentType; 25 | import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; 26 | import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; 27 | import org.apache.hc.client5.http.impl.classic.HttpClients; 28 | import org.bukkit.Bukkit; 29 | import link.star_dust.MinerTrack.FoliaCheck; 30 | 31 | public class DiscordWebHook { 32 | 33 | private final MinerTrack plugin; 34 | private final String webHookUrl; 35 | private final Gson gson = new Gson(); 36 | 37 | public DiscordWebHook(MinerTrack plugin, String webHookUrl) { 38 | this.plugin = plugin; 39 | this.webHookUrl = webHookUrl; 40 | } 41 | 42 | /** 43 | * Sends a simple text message to the Discord WebHook. 44 | * 45 | * @param content The message content to send. 46 | */ 47 | public void sendMessage(String content) { 48 | send(new Payload(content)); 49 | } 50 | 51 | /** 52 | * Sends an embed message to the Discord WebHook. 53 | * 54 | * @param embed The embed payload to send. 55 | */ 56 | public void sendEmbed(Embed embed) { 57 | send(new Payload(embed)); 58 | } 59 | 60 | /** 61 | * Sends a payload to the Discord WebHook asynchronously. 62 | * 63 | * @param payload The payload to send. 64 | */ 65 | private void send(Payload payload) { 66 | Runnable task = () -> { 67 | try (CloseableHttpClient httpClient = HttpClients.createDefault()) { 68 | HttpPost post = new HttpPost(webHookUrl); 69 | post.setHeader("Content-Type", "application/json; charset=UTF-8"); 70 | 71 | String jsonPayload = gson.toJson(payload); 72 | // Debug: log webhook URL and payload preview 73 | //plugin.getLogger().info("[DiscordWebHook] Sending to URL: " + webHookUrl + " payload: " + jsonPayload); 74 | StringEntity entity = new StringEntity(jsonPayload, ContentType.APPLICATION_JSON.withCharset(StandardCharsets.UTF_8)); 75 | post.setEntity(entity); 76 | 77 | try (CloseableHttpResponse response = httpClient.execute(post)) { 78 | int statusCode = response.getCode(); 79 | if (statusCode != 200 && statusCode != 204) { 80 | plugin.getLogger().warning("Failed to send message to Discord WebHook. Response Code: " + statusCode); 81 | } 82 | } 83 | 84 | } catch (Exception e) { 85 | plugin.getLogger().severe("Error while sending message to Discord WebHook: " + e.getMessage()); 86 | e.printStackTrace(); 87 | } 88 | }; 89 | 90 | // On Folia the Bukkit async scheduler may throw UnsupportedOperationException when 91 | // called from certain region threads, so use a plain thread instead. Fall back to 92 | // Bukkit async scheduling on non-Folia servers for compatibility. 93 | if (FoliaCheck.isFolia()) { 94 | Thread t = new Thread(task, "MinerTrack-DiscordWebHook"); 95 | t.setDaemon(true); 96 | t.start(); 97 | } else { 98 | Bukkit.getScheduler().runTaskAsynchronously(plugin, task); 99 | } 100 | } 101 | 102 | /** 103 | * Represents the payload structure for a WebHook message. 104 | */ 105 | public static class Payload { 106 | @SerializedName("content") 107 | private final String content; 108 | 109 | @SerializedName("embeds") 110 | private final Embed[] embeds; 111 | 112 | public Payload(String content) { 113 | this.content = content; 114 | this.embeds = null; 115 | } 116 | 117 | public Payload(Embed embed) { 118 | this.content = null; 119 | this.embeds = new Embed[]{embed}; 120 | } 121 | } 122 | 123 | /** 124 | * Represents an embed structure for Discord messages. 125 | */ 126 | public static class Embed { 127 | @SerializedName("title") 128 | private final String title; 129 | 130 | @SerializedName("description") 131 | private final String description; 132 | 133 | @SerializedName("color") 134 | private final int color; 135 | 136 | public Embed(String title, String description, int color) { 137 | this.title = title; 138 | this.description = description; 139 | this.color = color; 140 | } 141 | } 142 | } 143 | 144 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/managers/LanguageManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/managers/LanguageManager.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack.managers; 13 | 14 | import org.bukkit.ChatColor; 15 | import org.bukkit.configuration.InvalidConfigurationException; 16 | import org.bukkit.configuration.file.YamlConfiguration; 17 | import org.jetbrains.annotations.NotNull; 18 | 19 | import link.star_dust.MinerTrack.MinerTrack; 20 | 21 | import java.io.File; 22 | import java.io.IOException; 23 | import java.io.InputStream; 24 | import java.io.InputStreamReader; 25 | import java.util.List; 26 | import java.util.stream.Collectors; 27 | 28 | public class LanguageManager { 29 | private final MinerTrack plugin; 30 | private YamlConfiguration languageConfig; 31 | private final File languageFile; 32 | private static LanguageManager instance; 33 | 34 | public LanguageManager(MinerTrack plugin) { 35 | this.plugin = plugin; 36 | this.languageFile = new File(plugin.getDataFolder(), "language.yml"); 37 | loadLanguageFile(); 38 | } 39 | 40 | public void loadLanguageFile() { 41 | // Save default language file if it doesn't exist 42 | if (!languageFile.exists()) { 43 | plugin.saveResource("language.yml", false); 44 | } 45 | 46 | // Load the language file 47 | languageConfig = YamlConfiguration.loadConfiguration(languageFile); 48 | 49 | // Load defaults from the resource file using InputStreamReader 50 | try (InputStream defaultStream = plugin.getResource("language.yml")) { 51 | if (defaultStream != null) { 52 | YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream)); 53 | languageConfig.setDefaults(defaultConfig); 54 | languageConfig.options().copyDefaults(true); 55 | } 56 | } catch (IOException e) { 57 | plugin.getLogger().severe("Could not load default language configuration: " + e.getMessage()); 58 | } 59 | 60 | // Save only the custom values back to file 61 | saveCustomLanguageFile(); 62 | } 63 | 64 | public static LanguageManager getInstance(MinerTrack plugin) { 65 | if (instance == null) { 66 | instance = new LanguageManager(plugin); 67 | } 68 | return instance; 69 | } 70 | 71 | public void reloadLanguage() { 72 | reloadLanguageFile(); 73 | } 74 | 75 | public String getKickMessage(String playerName) { 76 | return applyColors(getMessage("kick-format").replace("%player%", playerName)); 77 | } 78 | 79 | public String getPrefix() { 80 | return applyColors(getMessage("prefix")); 81 | } 82 | 83 | public List getHelpMessages() { 84 | List helpMessages = languageConfig.getStringList("help"); 85 | return helpMessages.stream().map(this::applyColors).collect(Collectors.toList()); 86 | } 87 | 88 | public String getPrefixedMessage(String key) { 89 | return getPrefix() + " " + applyColors(getMessage(key)); 90 | } 91 | 92 | public String getMessage(String path) { 93 | return languageConfig.getString(path); 94 | } 95 | 96 | public String getColoredMessage(String path) { 97 | return applyColors(languageConfig.getString(path)); 98 | } 99 | 100 | public String applyColors(String message) { 101 | return ChatColor.translateAlternateColorCodes('&', message); 102 | } 103 | 104 | public String getLogFormat() { 105 | return getMessage("log-format"); 106 | } 107 | 108 | public boolean isKickBroadcastEnabled() { 109 | return languageConfig.getBoolean("kick-broadcast", true); 110 | } 111 | 112 | public String logNotFound(String log_name) { 113 | return applyColors(getMessage("log-not-found").replace("{log_file}", log_name)); 114 | } 115 | 116 | public int getLogViewerLinesPerPage() { 117 | return languageConfig.getInt("log-viewer-lines-per-page", 10); 118 | } 119 | 120 | // Save only custom values 121 | private void saveCustomLanguageFile() { 122 | try { 123 | languageConfig.save(languageFile); 124 | } catch (IOException e) { 125 | plugin.getLogger().severe("Could not save custom language configuration to " + languageFile.getName() + ": " + e.getMessage()); 126 | } 127 | } 128 | 129 | // Reload the language file 130 | public void reloadLanguageFile() { 131 | try { 132 | languageConfig.load(languageFile); 133 | } catch (IOException | InvalidConfigurationException e) { 134 | plugin.getLogger().severe("Could not reload language configuration: " + e.getMessage()); 135 | } 136 | } 137 | 138 | public String getPrefixedMessageWithDefault(String key, String defaultMessage) { 139 | String message = getMessage(key); 140 | 141 | if (message == null || message.isEmpty()) { 142 | message = defaultMessage; 143 | } 144 | 145 | return applyColors(getPrefix() + message); 146 | } 147 | } -------------------------------------------------------------------------------- /README-zh_hans.md: -------------------------------------------------------------------------------- 1 | ![MinerTrack Anti-XRay](./Images/MinerTrack.png) 2 | 3 | ## MinerTrack Anti-XRay 4 | 5 | [![Modrinth Downloads](https://img.shields.io/modrinth/dt/minertrack?style=flat&label=Modrinth%20Downloads&color=%234bd965)](https://modrinth.com/plugin/minertrack) [![SpigotMC Downloads](https://img.shields.io/spiget/downloads/120562?label=SpigotMC%20Downloads&color=yellow)](https://www.spigotmc.org/resources/120562/) [![Hangar Downloads](https://img.shields.io/hangar/dt/MinerTrack?label=Hangar%20Downloads&color=blue)](https://hangar.papermc.io/Author87668/MinerTrack) [![CurseForge Downloads](https://img.shields.io/curseforge/dt/1159157?label=CurseForge%20Downloads&color=orange)](https://www.curseforge.com/minecraft/bukkit-plugins/minertrack) 6 | 7 | [![Dev Build CI](https://img.shields.io/github/actions/workflow/status/At87668/MinerTrack/AutoBuild_CI_dev.yml?style=flat&label=Dev%20Build%20CI)](https://github.com/At87668/MinerTrack/actions/workflows/AutoBuild_CI_dev.yml) [![Latest Version](https://img.shields.io/github/release/At87668/MinerTrack.svg?style=flat&label=Latest%20Version)](https://gitHub.com/At87668/MinerTrack/releases/) [![GitHub issues](https://img.shields.io/github/issues/At87668/MinerTrack.svg?style=flat&label=Github%20Issue)](https://gitHub.com/At87668/MinerTrack/issues/) [![GitHub latest commit](https://img.shields.io/github/last-commit/At87668/MinerTrack?style=flat&label=Last%20Commit)](https://gitHub.com/At87668/MinerTrack/commit/) [![GPLv3 license](https://img.shields.io/badge/License-GPLv3-blue.svg?style=flat&label=Open%20Source%20License)](https://github.com/At87668/MinerTrack/blob/main/LICENSE) 8 | 9 | ![Support Versiopn](https://img.shields.io/badge/Support_Version-1.21.x_%7C_1.20.x_%7C_1.19.x_%7C_1.18.x-&?color=069F00) 10 | 11 | [![Support Server](https://img.shields.io/discord/1302190990639235122.svg?label=Discord&logo=Discord&colorB=7289da&style=for-the-badge)](https://discord.gg/MzTea2W9cb) 12 | 13 | [English](./README.md) | [简体中文](./README-zh_hans.md) 14 | 15 | ![Image](./Images/Overview.png) 16 | 17 | **MinerTrack** 是一款全新的反矿透插件,它使用挖矿行为分析而不是隐藏矿石的反矿透方式 18 | 19 | *本插件的工作方式?* 20 | 21 | 为了更精准的判断矿透行为, MinerTrack 使用了 **多维度数据** 进行分析, 例如挖掘矿石稀有度、玩家一段时间内挖矿数量、玩家前往矿石的路径 22 | 23 | *那么, 玩家还能使用矿透进行作弊吗?* 24 | 25 | 能, 但并不完全, 使用矿透的玩家面临着两个选择: 26 | 1. 开着矿透, 但挖掘与正常玩家相同数量的矿石 27 | 2. 卸载矿透, 不然被抓 28 | 29 | *为什么要选择 MinerTrack?* 30 | 31 | 与 Paper 的 Anti-Xray 和 Orebfuscator 相比: 32 | - MinerTrack 更为轻量 33 | - 使用算法检测, 更加先进 34 | - 可以检测 Xray 使用者,如何处理由你决定 35 | 36 | 与其他的反矿透插件相比: 37 | - 更新迅速, 支持最新游戏版本 38 | - 已在 20 人在线服务器中测试,几乎没有误判(默认配置) 39 | - 完全免费 40 | 41 | 看看用户们怎么说: 42 | 43 |
44 | 评价 45 | 46 | ![Assessment 1](https://cdn.modrinth.com/data/O3VQnhG2/images/732fb5912dc2ae4049631d1acd2e71acb5a58227.png) 47 | 48 | ![Assessment 2](https://cdn.modrinth.com/data/O3VQnhG2/images/8c9ccc951e5baf6a4181154f499a0fab30749a74.png) 49 | 50 | ![Assessment 3](https://cdn.modrinth.com/data/O3VQnhG2/images/edde401191d2d235c48995b962c89461e0ad97c6.png) 51 |
52 | 53 | ![Image](./Images/Features.png) 54 | 55 | * 检测使用 Xray 的玩家 56 | * 当玩家违规等级达到阈值时自动处理 57 | * 当玩家行为正常时自动降低违规等级 58 | * 分析玩家挖矿路径判断是否使用 Xray 59 | * 玩家在洞穴中正常挖矿不会被误判 60 | * 高度可配置的检测配置文件 61 | 62 | --- 63 | 64 | ![Image](./Images/Commands.png) 65 | 66 | * `/mtrack notify <消息>` - 向管理发送通知 67 | * `/mtrack verbose` - 开启详细模式,玩家违规等级变动时提示管理 68 | * `/mtrack check <玩家>` - 查看某个玩家的违规记录 69 | * `/mtrack reset <玩家>` - 重置某个玩家的违规记录 70 | * `/mtrack help` - 查看插件帮助 71 | * `/mtrack kick <玩家> <理由>` - 踢出玩家并说明原因 72 | * `/mtrack reload` - 重新加载插件配置 73 | * `/mtrack update` - 检查插件更新 74 | * `/mtrack logs <日志名.log>` - 查看 MinerTrack 生成的日志文件 75 | 76 | --- 77 | 78 | ![Image](./Images/Permissions.png) 79 | 80 | * `minertrack.bypass` - 绕过 Xray 检测 81 | * `minertrack.notify` - 接收警告与详细信息 82 | * `minertrack.checkupdate` - 接收更新信息并使用 `/mtrack update` 83 | * `minertrack.use` - 使用 `/mtrack` 根命令 84 | * `minertrack.check` - 使用 `/mtrack check` 85 | * `minertrack.kick` - 使用 `/mtrack kick` 86 | * `minertrack.logs` - 使用 `/mtrack logs` 87 | * `minertrack.help` - 使用 `/mtrack help` 88 | * `minertrack.reset` - 使用 `/mtrack reset` 89 | * `minertrack.sendnotify` - 使用 `/mtrack notify` 90 | * `minertrack.verbose` - 使用 `/mtrack verbose` 91 | * `minertrack.reload` - 使用 `/mtrack reload` 92 | 93 | --- 94 | 95 | ![Image](./Images/Installation.png) 96 | 97 | 1. 从 SpigotMC 下载最新版 **MinerTrack** 98 | 2. 把 `.jar` 文件放入 `plugins` 文件夹 99 | 3. 重启服务器生成配置文件与相关数据 100 | 101 | --- 102 | 103 | ![Image](./Images/Requirements.png) 104 | 105 | * Java 17 或更高版本 106 | * 仅支持 Paper、Purpur、Folia 或兼容分支(支持 1.18 及以上)*请注意, 本插件不支持 Spigot!* 107 | 108 | --- 109 | 110 | ![Image](./Images/Support.png) 111 | 112 | 如果你遇到任何问题,或者有建议功能,可以通过 SpigotMC 联系我们,或在 GitHub 提交 issue 113 | 114 | --- 115 | 116 | * **查看源码**: [https://github.com/At87668/MinerTrack](https://github.com/At87668/MinerTrack) 117 | * **提交问题**: [https://github.com/At87668/MinerTrack/issues](https://github.com/At87668/MinerTrack/issues) 118 | * **提交Pull Request**: [https://github.com/At87668/MinerTrack/pulls](https://github.com/At87668/MinerTrack/pulls) 119 | * **访问 Wiki**: [https://minertrack.pages.dev/wiki/](https://minertrack.pages.dev/wiki/) 120 | * **加入 Discord**: [https://discord.gg/MzTea2W9cb](https://discord.gg/MzTea2W9cb) 121 | 122 | [![bStats](https://bstats.org/signatures/bukkit/MinerTrack.svg)](https://bstats.org/plugin/bukkit/MinerTrack/23790) 123 | 124 | --- 125 | 126 | ### *如果您想要支持我的工作, 可以订阅我的 [Patreon](https://www.patreon.com/Author87668/join) 会员资格.* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![MinerTrack Anti-XRay](./Images/MinerTrack.png) 2 | 3 | ## MinerTrack Anti-XRay 4 | 5 | [![Modrinth Downloads](https://img.shields.io/modrinth/dt/minertrack?style=flat&label=Modrinth%20Downloads&color=%234bd965)](https://modrinth.com/plugin/minertrack) [![SpigotMC Downloads](https://img.shields.io/spiget/downloads/120562?label=SpigotMC%20Downloads&color=yellow)](https://www.spigotmc.org/resources/120562/) [![Hangar Downloads](https://img.shields.io/hangar/dt/MinerTrack?label=Hangar%20Downloads&color=blue)](https://hangar.papermc.io/Author87668/MinerTrack) [![CurseForge Downloads](https://img.shields.io/curseforge/dt/1159157?label=CurseForge%20Downloads&color=orange)](https://www.curseforge.com/minecraft/bukkit-plugins/minertrack) 6 | 7 | [![Dev Build CI](https://img.shields.io/github/actions/workflow/status/At87668/MinerTrack/AutoBuild_CI_dev.yml?style=flat&label=Dev%20Build%20CI)](https://github.com/At87668/MinerTrack/actions/workflows/AutoBuild_CI_dev.yml) [![Latest Version](https://img.shields.io/github/release/At87668/MinerTrack.svg?style=flat&label=Latest%20Version)](https://gitHub.com/At87668/MinerTrack/releases/) [![GitHub issues](https://img.shields.io/github/issues/At87668/MinerTrack.svg?style=flat&label=Github%20Issue)](https://gitHub.com/At87668/MinerTrack/issues/) [![GitHub latest commit](https://img.shields.io/github/last-commit/At87668/MinerTrack?style=flat&label=Last%20Commit)](https://gitHub.com/At87668/MinerTrack/commit/) [![GPLv3 license](https://img.shields.io/badge/License-GPLv3-blue.svg?style=flat&label=Open%20Source%20License)](https://github.com/At87668/MinerTrack/blob/main/LICENSE) 8 | 9 | ![Support Versiopn](https://img.shields.io/badge/Support_Version-1.21.x_%7C_1.20.x_%7C_1.19.x_%7C_1.18.x-&?color=069F00) 10 | 11 | [![Support Server](https://img.shields.io/discord/1302190990639235122.svg?label=Discord&logo=Discord&colorB=7289da&style=for-the-badge)](https://discord.gg/MzTea2W9cb) 12 | 13 | [English](./README.md) | [简体中文](./README-zh_hans.md) 14 | 15 | ![Image](./Images/Overview.png) 16 | 17 | **MinerTrack** is a plugin that will really help you catch those naughty players using Xray on your server in a **different way** from other Anti-Xray plugins. This plugin doesn't hide ores, as hiding ores requires a lot of resources. 18 | 19 | *So how does it work?* 20 | 21 | To catch Xray, MinerTrack uses an **advanced algorithm** that combines **several factors** like ore scarcity, the amount of ores mined in a certain period, the player’s path to ores, and many other aspects. 22 | 23 | *But can't people still use Xray?* 24 | 25 | Yes and no. Indeed, a player using Xray has two options: 26 | 1. Keep using Xray but behave like a normal player to avoid being caught. They can't get more ores than a normal player or they’ll be caught by MinerTrack. 27 | 2. Uninstall their Xray or be caught. 28 | 29 | *Why choose MinerTrack over other AntiXray options?* 30 | 31 | Compared to Paper Anti-XRay and Orebfuscator: 32 | - MinerTrack is lightweight. 33 | - MinerTrack's engine is innovative. 34 | - MinerTrack detects Xray users, leaving it to you to decide on sanctions. 35 | 36 | Compared to other AntiXray solutions: 37 | - MinerTrack supports the latest Minecraft version. 38 | 39 | - MinerTrack has been tested on servers with about 20 simultaneous players, with very few false positives (*default config*). 40 | 41 | - MinerTrack is free. 42 | 43 | Look what users have to say: 44 | 45 |
46 | Assessments 47 | 48 | ![Assessment 1](https://cdn.modrinth.com/data/O3VQnhG2/images/732fb5912dc2ae4049631d1acd2e71acb5a58227.png) 49 | 50 | ![Assessment 2](https://cdn.modrinth.com/data/O3VQnhG2/images/8c9ccc951e5baf6a4181154f499a0fab30749a74.png) 51 | 52 | ![Assessment 3](https://cdn.modrinth.com/data/O3VQnhG2/images/edde401191d2d235c48995b962c89461e0ad97c6.png) 53 |
54 | 55 | ![Image](./Images/Features.png) 56 | 57 | - Detect XRayer 58 | - Automatically handle cases when a player's X-Ray violation level reaches a threshold 59 | - Automatically reduce the violation level when the player's behavior normalizes 60 | - Analyze player mining paths to detect X-Ray usage 61 | - When the player is mining in a cave, they will not be detected incorrectly 62 | - Highly configurable profiles 63 | 64 | ![Image](./Images/Commands.png) 65 | 66 | - `/mtrack notify ` - Send alerts to staff 67 | - `/mtrack verbose` - Enable Detailed Mode and notify staff with it enabled whenever a player’s violation level increases 68 | - `/mtrack check ` - Check a player’s violation history 69 | - `/mtrack reset ` - Reset a player's violation record 70 | - `/mtrack help` - Get plugin help 71 | - `/mtrack kick ` - Kick a player with a specific reason 72 | - `/mtrack reload` - Reload the plugin’s configuration 73 | - `/mtrack update` - Check for plugin updates 74 | - `/mtrack logs ` - View a MinerTrack log file 75 | 76 | ![Image](./Images/Permissions.png) 77 | 78 | - `minertrack.bypass` - Bypass X-Ray detection 79 | - `minertrack.notify` - Receive notifications and verbose information 80 | - `minertrack.checkupdate` - Receive update information and use `/mtrack update` 81 | - `minertrack.use` - Access the root command `/mtrack` 82 | - `minertrack.check` - Use `/mtrack check` 83 | - `minertrack.kick` - Use `/mtrack kick` 84 | - `minertrack.logs` - Use `/mtrack logs` 85 | - `minertrack.help` - Use `/mtrack help` 86 | - `minertrack.reset` - Use `/mtrack reset` 87 | - `minertrack.sendnotify` - Use `/mtrack notify` 88 | - `minertrack.verbose` - Use `/mtrack verbose` 89 | - `minertrack.reload` - Use `/mtrack reload` 90 | 91 | ![Image](./Images/Installation.png) 92 | 93 | 1. Download the latest version of **MinerTrack** from SpigotMC. 94 | 2. Place the .jar file into the plugins folder. 95 | 3. Restart the server to generate the configuration and necessary files. 96 | 97 | ![Image](./Images/Requirements.png) 98 | 99 | - Java 17 or higher 100 | - Paper, Purpur, Folia or compatible forks (1.18 or newer) *Not Spigot!* 101 | 102 | ![Image](./Images/Support.png) 103 | 104 | If you encounter any issues or have suggestions for new features, feel free to reach out via Discord or open an issue on the plugin’s GitHub repository. 105 | 106 | 107 | 108 | **View Source: https://github.com/At87668/MinerTrack** 109 | 110 | **Report Issue: https://github.com/At87668/MinerTrack/issues** 111 | 112 | **Pull Requset: https://github.com/At87668/MinerTrack/pulls** 113 | 114 | **Visit Wiki: https://minertrack.pages.dev/wiki/** 115 | 116 | **Join Discord: https://discord.gg/MzTea2W9cb** 117 | 118 | 119 | 120 | [![bStats](https://bstats.org/signatures/bukkit/MinerTrack.svg)](https://bstats.org/plugin/bukkit/MinerTrack/23790) 121 | 122 | --- 123 | 124 | ### *If you want to support my work, you can subscribe my [Patreon](https://www.patreon.com/Author87668/join) membership.* 125 | -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | #### MinerTrack Anti-Xray Configuration - config.yml ############################## 2 | # 3 | # Welcome to MinerTrack anti-xray configuration file. 4 | # This file defines global settings specifically optimized for anti-xray detection. 5 | # 6 | # Useful Links: 7 | # Get Update: https://modrinth.com/plugin/minertrack 8 | # View Source: https://github.com/At87668/MinerTrack 9 | # Report Issue: https://github.com/At87668/MinerTrack/issues 10 | # Pull Requset: https://github.com/At87668/MinerTrack/pulls 11 | # Visit Wiki: https://minertrack.pages.dev/wiki/ 12 | # Join Discord: https://discord.gg/MzTea2W9cb 13 | # 14 | ################################################################################## 15 | 16 | # Check for updates on startup (recommended for latest optimizations). 17 | check_update: true 18 | # Available options: stable/beta/alpha. Using the pre-release version will receive updates from more stable versions. 19 | check_update_channel: "stable" 20 | 21 | # Visual effect when a player is kicked using /minertrack kick (default: true) 22 | kick_strike_lightning: true 23 | 24 | # Log Violations (default: true) 25 | # Logs all detections in /plugins/MinerTrack/logs for easier monitoring. 26 | log_file: true 27 | 28 | # Auto-delete outdated logs after specified days (-1 to disable auto-deletion) 29 | delete_time: 30 30 | 31 | # Deny Bypass Permission - force checks on all players, including Operators. 32 | disable_bypass_permission: false 33 | 34 | # Discord WebHook 35 | # Placeholders: %player% %player_uuid% %player_vl% %ore_type% %ore_count% %mined_veins% %pos_x% %pos_y% %pos_z% %timestamp% 36 | DiscordWebHook: 37 | enable: false 38 | WebHookURL: '' 39 | vl-required: 4 # If a player's violation level is greater than this value, an alert is sent. 40 | vl-add-message: 41 | color: 0xFF5733 42 | title: "X-Ray Alert" 43 | text: 44 | - 'Player Name: %player%' 45 | - 'Player UUID: %player_uuid%' 46 | - 'Player Violation Level: %player_vl%' 47 | - '' 48 | - 'Mining Ore: %ore_type%x%ore_count%' 49 | - 'Mined Veins: %mined_veins%' 50 | - '' 51 | - 'Pos: %pos_x% %pos_y% %pos_z%' 52 | # If the custom Json format below is enabled, this Json body format will be used to send to the WebHookURL configured above 53 | custom-json: 54 | enable: false 55 | format: | 56 | { 57 | "title": "X-Ray Alert", 58 | "data": { 59 | "player": { 60 | "name": "%player%", 61 | "uuid": "%player_uuid%", 62 | "violation_level": %player_vl% 63 | }, 64 | "mining": { 65 | "ore_type": "%ore_type%", 66 | "ore_count": %ore_count%, 67 | "mined_veins": %mined_veins% 68 | }, 69 | "location": { 70 | "x": %pos_x%, 71 | "y": %pos_y%, 72 | "z": %pos_z% 73 | }, 74 | "timestamp": "%timestamp%" 75 | } 76 | } 77 | 78 | ############################################################################################################################# 79 | ## ## This plugin in order to capture XRayer quickly, might generate false positives for players who are lucky! ## 80 | ## Warn ## Be careful not to set the VL threshold too low! ## 81 | ## ## Don't detect for common ores either, you should only detect for rare ores! ## 82 | ############################################################################################################################# 83 | 84 | ############################################################################################################################# 85 | ## ## Default configuration may be slow on the first check-out. ## 86 | ## Info ## It will be more accurate afterwards, ## 87 | ## ## Therefore, it is recommended to adjust the configuration to suit your needs. ## 88 | ############################################################################################################################# 89 | 90 | xray: 91 | enable: true # Enable X-ray detection 92 | 93 | # At what height should I start detecting X-Ray? 94 | # Worlds that are not listed do not have XRay detection. 95 | worlds: 96 | world: 97 | enable: true 98 | max-height: 32 99 | world_nether: 100 | enable: true 101 | max-height: 128 102 | world_the_end: 103 | enable: false 104 | all_unnamed_world: 105 | enable: false 106 | 107 | # The type of ore a player has to mine before being able to be checked 108 | # List of allowed materials: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html 109 | rare-ores: 110 | - ANCIENT_DEBRIS 111 | - EMERALD_ORE 112 | - DEEPSLATE_EMERALD_ORE 113 | - DIAMOND_ORE 114 | - DEEPSLATE_DIAMOND_ORE 115 | 116 | # Mined length record limit (Unit: block) 117 | max_path_length: 500 118 | 119 | # Path record is reset after the player VL is 0 {n} minutes. 120 | trace_remove: 15 121 | 122 | max_vein_distance: 5 # When two veins are close together, VL is not increased. 123 | 124 | # VL is increased as the player digs the number of veins 125 | veinCountThreshold: 2 126 | 127 | # Small vein detection size 128 | # If a vein contains <= this number of blocks, the plugin uses a more sensitive 129 | # comparison strategy (cluster overlap/min distance) to decide whether it's a new vein. 130 | # Default: 4 131 | small_vein_detection_size: 4 132 | 133 | path-detection: 134 | turn-count-threshold: 10 # Maximum number of turns threshold 135 | branch-count-threshold: 6 # Maximum number of branches 136 | y-change-threshold: 4 # Maximum Y-axis change threshold 137 | y-change-threshold-add-required: 3 # If y pos transformation exceeds this value, the threshold is increased 138 | 139 | # Natural Detection 140 | natural-detection: 141 | enable: true 142 | 143 | # Satisfying the conditions will think they are in a natural. 144 | cave: 145 | air-threshold: 14 # When the number of air blocks reaches several, the player is considered to be in a cave? 146 | CaveAirMultiplier: 5 # If cave air is found, regarded as how many ordinary air? 147 | detection-range: 3 # 3 = 7x7x7, 2 = 5x5x5 148 | check_skip_vl: true # VL add of whether or not to skip natural behavior 149 | 150 | # Prevents players from manually creating air to bypass detection. 151 | air-monitor: 152 | enable: true # Enable or disable 153 | min-path-length: 10 # Minimum digging path required to perform this detection. 154 | air-ratio-threshold: 0.3 # Air percentage threshold (e.g., 0.3 for 30%). 155 | violation-increase: 1 # The value of the increase in rating after each triggered violation. 156 | violation-threshold: 5 # The number of ratings reached should be flagged as suspicion of deliberate creation of artificial air. 157 | remove-time: 20 # How long to remove this record once (in minutes) 158 | sea: 159 | check-running-water: false # Should we check running water? 160 | water-threshold: 14 161 | detection-range: 3 162 | check_skip_vl: true 163 | lava-sea: 164 | lava-threshold: 14 165 | detection-range: 3 166 | check_skip_vl: true 167 | 168 | # Violation level decay settings (Unit: minute) 169 | decay: 170 | interval: 3 # The interval between decay tasks (in minutes) 171 | amount: 1 # The value of each linear falloff 172 | use_factor: false # Whether to enable nonlinear attenuation 173 | factor: 0.9 # Nonlinear decay scale (only works when use_factor=true) 174 | 175 | # Commands executed at specified violation thresholds 176 | commands: 177 | 2: 'minertrack notify &f%player% &7triggered &fX-Ray &7detection [&cVL: 2&7]' 178 | 4: 'minertrack notify &f%player% &7triggered &fX-Ray &7detection [&cVL: 4&7]' 179 | 5: 180 | - 'minertrack kick %player% X-Ray' 181 | - 'minertrack notify &f%player% &7was kicked for &fX-Ray' -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Stop when "xargs" is not available. 209 | if ! command -v xargs >/dev/null 2>&1 210 | then 211 | die "xargs is not available" 212 | fi 213 | 214 | # Use "xargs" to parse quoted args. 215 | # 216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 217 | # 218 | # In Bash we could simply go: 219 | # 220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 221 | # set -- "${ARGS[@]}" "$@" 222 | # 223 | # but POSIX shell has neither arrays nor command substitution, so instead we 224 | # post-process each arg (as a line of input to sed) to backslash-escape any 225 | # character that might be a shell metacharacter, then use eval to reverse 226 | # that process (while maintaining the separation between arguments), and wrap 227 | # the whole thing up as a single "set" statement. 228 | # 229 | # This will of course break if any of these variables contains a newline or 230 | # an unmatched quote. 231 | # 232 | 233 | eval "set -- $( 234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 235 | xargs -n1 | 236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 237 | tr '\n' ' ' 238 | )" '"$@"' 239 | 240 | exec "$JAVACMD" "$@" 241 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/MinerTrack.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/MinerTrack.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack; 13 | 14 | import java.io.BufferedReader; 15 | import java.io.IOException; 16 | import java.io.InputStreamReader; 17 | import java.net.HttpURLConnection; 18 | import java.net.URL; 19 | import java.util.Arrays; 20 | import java.util.HashSet; 21 | import java.util.Set; 22 | import java.util.UUID; 23 | import java.util.regex.Matcher; 24 | import java.util.regex.Pattern; 25 | 26 | import org.bstats.bukkit.Metrics; 27 | import org.bukkit.Bukkit; 28 | import org.bukkit.ChatColor; 29 | import org.bukkit.command.Command; 30 | import org.bukkit.command.CommandSender; 31 | import org.bukkit.command.ConsoleCommandSender; 32 | import org.bukkit.entity.Player; 33 | import org.bukkit.event.EventHandler; 34 | import org.bukkit.event.player.PlayerJoinEvent; 35 | import org.bukkit.event.server.ServerLoadEvent; 36 | import org.bukkit.plugin.java.JavaPlugin; 37 | import org.bukkit.event.Listener; 38 | import org.json.JSONObject; 39 | 40 | import link.star_dust.MinerTrack.managers.ConfigManager; 41 | import link.star_dust.MinerTrack.managers.LanguageManager; 42 | import link.star_dust.MinerTrack.managers.UpdateManager; 43 | import link.star_dust.MinerTrack.managers.ViolationManager; 44 | import net.md_5.bungee.api.chat.BaseComponent; 45 | import link.star_dust.MinerTrack.listeners.MiningDetectionExtension; 46 | import link.star_dust.MinerTrack.listeners.MiningListener; 47 | import link.star_dust.MinerTrack.listeners.LogCacheListener; 48 | import link.star_dust.MinerTrack.commands.MinerTrackCommand; 49 | 50 | public class MinerTrack extends JavaPlugin implements Listener { 51 | private ConfigManager configManager; 52 | private LanguageManager languageManager; 53 | private ViolationManager violationManager; 54 | private Notifier notifier; 55 | private final Set verbosePlayers = new HashSet<>(); 56 | private boolean verboseConsole = false; 57 | private UpdateManager updateManager; 58 | private String ColoredVersion; 59 | public MiningDetectionExtension miningDetectionExtension; 60 | private MinerTrackCommand minerTrackCommand; 61 | // Keep a reference to the listener so other managers can request per-player cleanup 62 | private MiningListener miningListener; 63 | 64 | @Override 65 | public void onEnable() { 66 | saveDefaultConfig(); 67 | configManager = new ConfigManager(this); 68 | languageManager = new LanguageManager(this); 69 | violationManager = new ViolationManager(this); 70 | notifier = new Notifier(this); 71 | updateManager = new UpdateManager(this); 72 | //miningDetectionExtension = new MiningDetectionExtension(this); 73 | //miningDetectionExtension.register(); 74 | 75 | int pluginId = 23790; 76 | new Metrics(this, pluginId); 77 | 78 | registerCommands(); 79 | registerListeners(); 80 | getCommand("minertrack").setExecutor(new MinerTrackCommand(this)); 81 | 82 | if (getConfigManager().updateCheck()) { 83 | boolean isHasNewerVersion = updateManager.isHasNewerVersion(); 84 | 85 | if(isHasNewerVersion) { 86 | ColoredVersion = "&cv" + getDescription().getVersion(); 87 | } else { 88 | ColoredVersion = "&av" + getDescription().getVersion(); 89 | } 90 | } else { 91 | ColoredVersion = "&av" + getDescription().getVersion(); 92 | } 93 | 94 | getServer().getConsoleSender().sendMessage(applyColors("&8----[&9&lMiner&c&lTrack " + ColoredVersion + " &8]-----------")); 95 | getServer().getConsoleSender().sendMessage(applyColors("&9&lMiner&c&lTrack &4&oAnti-XRay &aEnabled!")); 96 | getServer().getConsoleSender().sendMessage(applyColors("")); 97 | getServer().getConsoleSender().sendMessage(applyColors("&7Authors: Author87668")); 98 | getServer().getConsoleSender().sendMessage(applyColors("&7Original Author: Author87668")); 99 | getServer().getConsoleSender().sendMessage(applyColors("&7Contributors: Author87668, Zhang12334")); 100 | getServer().getConsoleSender().sendMessage(applyColors("")); 101 | getServer().getConsoleSender().sendMessage(applyColors("&a&oThanks for your use!")); 102 | getServer().getConsoleSender().sendMessage(applyColors("&8-----------------------------------------")); 103 | 104 | /*if (getConfigManager().updateCheck()) { 105 | checkForUpdates(null); 106 | } else { 107 | return; 108 | }*/ 109 | } 110 | 111 | @EventHandler 112 | public void onServerLoad(ServerLoadEvent event) { 113 | if (getConfigManager().updateCheck()) { 114 | getLogger().info("Server has finished loading. Checking for updates..."); 115 | checkForUpdates(null); 116 | } else { 117 | return; 118 | } 119 | } 120 | 121 | public String applyColors(String message) { 122 | return ChatColor.translateAlternateColorCodes('&', message); 123 | } 124 | 125 | private void registerCommands() { 126 | minerTrackCommand = new MinerTrackCommand(this); 127 | getCommand("mtrack").setExecutor(minerTrackCommand); 128 | getCommand("mtrack").setTabCompleter(minerTrackCommand); 129 | } 130 | 131 | private void registerListeners() { 132 | Bukkit.getPluginManager().registerEvents(this, this); 133 | miningListener = new MiningListener(this); 134 | Bukkit.getPluginManager().registerEvents(miningListener, this); 135 | Bukkit.getPluginManager().registerEvents(new LogCacheListener(minerTrackCommand), this); 136 | } 137 | 138 | public MiningListener getMiningListener() { 139 | return miningListener; 140 | } 141 | 142 | public ConfigManager getConfigManager() { 143 | return configManager; 144 | } 145 | 146 | public LanguageManager getLanguageManager() { 147 | return languageManager; 148 | } 149 | 150 | public Notifier getNotifier() { 151 | return notifier; 152 | } 153 | 154 | public ViolationManager getViolationManager() { 155 | return violationManager; 156 | } 157 | 158 | public Set getVerbosePlayers() { 159 | return verbosePlayers; 160 | } 161 | 162 | public boolean isVerboseConsoleEnabled() { 163 | return verboseConsole; 164 | } 165 | 166 | public void toggleVerboseMode(CommandSender sender) { 167 | String enableMessage = getLanguageManager().getPrefixedMessage("verbose-enable"); 168 | String disableMessage = getLanguageManager().getPrefixedMessage("verbose-disable"); 169 | 170 | if (sender instanceof Player) { 171 | Player player = (Player) sender; 172 | UUID playerId = player.getUniqueId(); 173 | 174 | if (verbosePlayers.contains(playerId)) { 175 | verbosePlayers.remove(playerId); 176 | player.sendMessage(disableMessage); 177 | } else { 178 | verbosePlayers.add(playerId); 179 | player.sendMessage(enableMessage); 180 | } 181 | } else if (sender instanceof ConsoleCommandSender) { 182 | verboseConsole = !verboseConsole; 183 | 184 | if (verboseConsole) { 185 | sender.sendMessage(enableMessage); 186 | } else { 187 | sender.sendMessage(disableMessage); 188 | } 189 | } 190 | } 191 | 192 | 193 | @EventHandler 194 | public void onPlayerJoin(PlayerJoinEvent event) { 195 | if (!configManager.updateCheck()) { 196 | return; 197 | } 198 | 199 | Player player = event.getPlayer(); 200 | 201 | if (player.hasPermission("minertrack.checkupdate") && updateManager.isHasNewerVersion()) { 202 | BaseComponent[] updateComponent = updateManager.getUpdateMessageComponent(); 203 | if (updateComponent != null) { 204 | player.spigot().sendMessage(updateComponent); 205 | } // Call UpdateManager for player-specific check 206 | //updateManager.checkForUpdates(player); 207 | } 208 | } 209 | 210 | public void checkForUpdates(CommandSender sender) { 211 | updateManager.checkForUpdates(sender); 212 | } 213 | 214 | @Override 215 | public void onDisable() { 216 | getServer().getConsoleSender().sendMessage(applyColors("&8----[&9&lMiner&c&lTrack " + ColoredVersion + " &8]-----------")); 217 | getServer().getConsoleSender().sendMessage(applyColors("&9&lMiner&c&lTrack &4&oAnti-XRay &cDisabled!")); 218 | getServer().getConsoleSender().sendMessage(applyColors("")); 219 | getServer().getConsoleSender().sendMessage(applyColors("&7Authors: Author87668")); 220 | getServer().getConsoleSender().sendMessage(applyColors("&7Original Author: Author87668")); 221 | getServer().getConsoleSender().sendMessage(applyColors("&7Contributors: Author87668, Zhang12334")); 222 | getServer().getConsoleSender().sendMessage(applyColors("")); 223 | getServer().getConsoleSender().sendMessage(applyColors("&a&oGood bye!")); 224 | getServer().getConsoleSender().sendMessage(applyColors("&8-----------------------------------------")); 225 | } 226 | } -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/managers/ConfigManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/managers/ConfigManager.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack.managers; 13 | 14 | import org.bukkit.configuration.ConfigurationSection; 15 | import org.bukkit.configuration.InvalidConfigurationException; 16 | import org.bukkit.configuration.file.FileConfiguration; 17 | import org.bukkit.configuration.file.YamlConfiguration; 18 | import org.jetbrains.annotations.Nullable; 19 | 20 | import link.star_dust.MinerTrack.MinerTrack; 21 | 22 | import java.io.*; 23 | import java.util.List; 24 | import java.util.Set; 25 | 26 | public class ConfigManager { 27 | private final MinerTrack plugin; 28 | private final File configFile; 29 | private final FileConfiguration config; 30 | 31 | public ConfigManager(MinerTrack plugin) { 32 | this.plugin = plugin; 33 | this.configFile = new File(plugin.getDataFolder(), "config.yml"); 34 | 35 | // Load existing config 36 | this.config = YamlConfiguration.loadConfiguration(configFile); 37 | 38 | // Load defaults and merge only missing keys 39 | try (InputStream defaultStream = plugin.getResource("config.yml")) { 40 | if (defaultStream != null) { 41 | YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream)); 42 | mergeConfigurations(config, defaultConfig, ""); // Recursive merge 43 | saveConfig(); // Save back merged configuration 44 | } 45 | } catch (IOException e) { 46 | plugin.getLogger().severe("Error loading default configuration: " + e.getMessage()); 47 | } 48 | } 49 | 50 | /** 51 | * Recursively merges default configuration into the current configuration. 52 | * 53 | * @param currentConfig The current configuration to merge into. 54 | * @param defaultConfig The default configuration to merge from. 55 | */ 56 | private void mergeConfigurations(ConfigurationSection currentConfig, ConfigurationSection defaultConfig, String currentPath) { 57 | Set whitelistKeys = Set.of( 58 | "check_update", 59 | "check_update_channel", 60 | "kick_strike_lightning", 61 | "log_file", 62 | "delete_time", 63 | "disable_bypass_permission", 64 | "DiscordWebHook", 65 | "DiscordWebHook.enable", 66 | "DiscordWebHook.WebHookURL", 67 | "DiscordWebHook.vl-required", 68 | "DiscordWebHook.vl-add-message", 69 | "DiscordWebHook.vl-add-message.color", 70 | "DiscordWebHook.vl-add-message.title", 71 | "DiscordWebHook.vl-add-message.text", 72 | "xray", 73 | "xray.enable", 74 | "xray.worlds", 75 | "xray.worlds.world", 76 | "xray.worlds.all_unnamed_world", 77 | "xray.worlds.all_unnamed_world.enable", 78 | "xray.rare-ores", 79 | "xray.max_path_length", 80 | "xray.trace_remove", 81 | "xray.max_vein_distance", 82 | "xray.veinCountThreshold", 83 | "xray.path-detection", 84 | "xray.path-detection.turn-count-threshold", 85 | "xray.path-detection.branch-count-threshold", 86 | "xray.path-detection.y-change-threshold", 87 | "xray.path-detection.y-change-threshold-add-required", 88 | "xray.natural-detection", 89 | "xray.natural-detection.enable", 90 | "xray.natural-detection.cave", 91 | "xray.natural-detection.cave.air-threshold", 92 | "xray.natural-detection.cave.CaveAirMultiplier", 93 | "xray.natural-detection.cave.detection-range", 94 | "xray.natural-detection.cave.check_skip_vl", 95 | "xray.natural-detection.cave.air-monitor", 96 | "xray.natural-detection.cave.air-monitor.enable", 97 | "xray.natural-detection.cave.air-monitor.min-path-length", 98 | "xray.natural-detection.cave.air-monitor.air-ratio-threshold", 99 | "xray.natural-detection.cave.air-monitor.violation-increase", 100 | "xray.natural-detection.cave.air-monitor.violation-threshold", 101 | "xray.natural-detection.cave.air-monitor.remove-time", 102 | "xray.natural-detection.sea", 103 | "xray.natural-detection.sea.check-running-water", 104 | "xray.natural-detection.sea.water-threshold", 105 | "xray.natural-detection.sea.detection-range", 106 | "xray.natural-detection.sea.check_skip_vl", 107 | "xray.natural-detection.lava-sea", 108 | "xray.natural-detection.lava-sea.lava-threshold", 109 | "xray.natural-detection.lava-sea.detection-range", 110 | "xray.natural-detection.lava-sea.check_skip_vl", 111 | "xray.small_vein_detection_size", 112 | "xray.decay", 113 | "xray.decay.interval", 114 | "xray.decay.amount", 115 | "xray.decay.use_factor", 116 | "xray.decay.factor", 117 | "explosion", 118 | "explosion.entity-explode-check", 119 | "explosion.explosion_retention_time", 120 | "explosion.base_vl_rate", 121 | "explosion.suspicious_hit_rate", 122 | "commands" 123 | ); 124 | 125 | for (String key : defaultConfig.getKeys(false)) { 126 | String fullKeyPath = (currentPath.isEmpty() ? "" : currentPath + ".") + key; 127 | if (!whitelistKeys.contains(fullKeyPath)) { 128 | continue; // Skip keys not in the whitelist 129 | } 130 | 131 | if (currentConfig.contains(key)) { 132 | Object currentValue = currentConfig.get(key); 133 | Object defaultValue = defaultConfig.get(key); 134 | 135 | // Recurse for nested sections 136 | if (currentValue instanceof ConfigurationSection && defaultValue instanceof ConfigurationSection) { 137 | mergeConfigurations( 138 | (ConfigurationSection) currentValue, 139 | (ConfigurationSection) defaultValue, 140 | fullKeyPath 141 | ); 142 | } 143 | } else { 144 | // Add missing key 145 | currentConfig.set(key, defaultConfig.get(key)); 146 | } 147 | } 148 | } 149 | 150 | 151 | /** 152 | * Saves the current configuration back to the file while preserving structure. 153 | */ 154 | public void saveConfig() { 155 | try { 156 | config.save(configFile); 157 | } catch (IOException e) { 158 | plugin.getLogger().severe("Could not save configuration to " + configFile.getName() + ": " + e.getMessage()); 159 | } 160 | } 161 | 162 | /** 163 | * Reloads the configuration from the file. 164 | */ 165 | public void reloadConfig() { 166 | try { 167 | config.load(configFile); 168 | } catch (IOException | InvalidConfigurationException e) { 169 | plugin.getLogger().severe("Error reloading configuration: " + e.getMessage()); 170 | } 171 | } 172 | 173 | // Add your getter methods here, for example: 174 | public boolean isDenyBypassPermissionEnabled() { 175 | return config.getBoolean("disable_bypass_permission", false); 176 | } 177 | 178 | public boolean isKickStrikeLightning() { 179 | return config.getBoolean("xray.kick-strike-lightning", true); 180 | } 181 | 182 | public List getRareOres() { 183 | return config.getStringList("xray.rare-ores"); 184 | } 185 | 186 | public int getVeinCountThreshold() { 187 | return config.getInt("xray.veinCountThreshold", 3); 188 | } 189 | 190 | public int getTurnCountThreshold() { 191 | return config.getInt("xray.path-detection.turn-count-threshold", 10); 192 | } 193 | 194 | public int getBranchCountThreshold() { 195 | return config.getInt("xray.path-detection.branch-count-threshold", 6); 196 | } 197 | 198 | public int getYChangeThreshold() { 199 | return config.getInt("xray.path-detection.y-change-threshold", 4); 200 | } 201 | 202 | public int getWorldMaxHeight(String worldName) { 203 | ConfigurationSection xraySection = config.getConfigurationSection("xray.worlds"); 204 | if (xraySection == null || !xraySection.isConfigurationSection(worldName)) { 205 | //plugin.getLogger().warning("Max height configuration for world " + worldName + " not found. Defaulting to no height limit."); 206 | return config.getInt("xray.worlds.all_unnamed_world.max-height", -1); 207 | } 208 | return xraySection.getInt(worldName + ".max-height", -1); 209 | } 210 | 211 | public boolean isWorldDetectionEnabled(String worldName) { 212 | ConfigurationSection worldsSection = config.getConfigurationSection("xray.worlds"); 213 | if (worldsSection == null || !worldsSection.isConfigurationSection(worldName)) { 214 | return config.getBoolean("xray.worlds.all_unnamed_world.enable", false); 215 | } 216 | return worldsSection.getBoolean(worldName + ".enable", false); 217 | } 218 | 219 | public boolean DisableBypass() { 220 | return config.getBoolean("disable_bypass_permission", false); 221 | } 222 | 223 | public String getCommandForThreshold(int threshold) { 224 | ConfigurationSection commandsSection = config.getConfigurationSection("xray.commands"); 225 | if (commandsSection != null && commandsSection.contains(String.valueOf(threshold))) { 226 | return commandsSection.getString(String.valueOf(threshold)); 227 | } 228 | return null; 229 | } 230 | 231 | public int getMaxVeinDistance() { 232 | return config.getInt("xray.max_vein_distance", 5); 233 | } 234 | 235 | public int getSmallVeinSize() { 236 | return config.getInt("xray.small_vein_detection_size", 4); 237 | } 238 | 239 | public boolean getNaturalEnable() { 240 | return config.getBoolean("xray.natural-detection.enable", true); 241 | } 242 | 243 | public int getCaveBypassAirThreshold() { 244 | return config.getInt("xray.natural-detection.cave.air-threshold", 14); 245 | } 246 | 247 | public int getCaveAirMultiplier() { 248 | return config.getInt("xray.natural-detection.cave.CaveAirMultiplier", 5); 249 | } 250 | 251 | public int getCaveDetectionRange() { 252 | return config.getInt("xray.natural-detection.cave.detection-range", 3); 253 | } 254 | 255 | public boolean isCaveSkipVL() { 256 | return config.getBoolean("xray.natural-detection.cave.check_skip_vl", true); 257 | } 258 | 259 | public boolean isRunningWaterCheckEnabled() { 260 | return config.getBoolean("xray.natural-detection.sea.check-running-water", false); 261 | } 262 | 263 | public int getWaterThreshold() { 264 | return config.getInt("xray.natural-detection.sea.water-threshold", 14); 265 | } 266 | 267 | public int getWaterDetectionRange() { 268 | return config.getInt("xray.natural-detection.sea.detection-range", 3); 269 | } 270 | 271 | public boolean isSeaSkipVL() { 272 | return config.getBoolean("xray.natural-detection.sea.check_skip_vl", true); 273 | } 274 | 275 | public int getLavaThreshold() { 276 | return config.getInt("xray.natural-detection.lava-sea.lava-threshold", 14); 277 | } 278 | 279 | public int getLavaDetectionRange() { 280 | return config.getInt("xray.natural-detection.lava-sea.detection-range", 3); 281 | } 282 | 283 | public boolean isLavaSeaSkipVL() { 284 | return config.getBoolean("xray.natural-detection.lava-sea.check_skip_vl", true); 285 | } 286 | 287 | public int traceBackLength() { 288 | return config.getInt("xray.trace_back_length", 10); 289 | } 290 | 291 | public boolean updateCheck() { 292 | return config.getBoolean("check_update", true); 293 | } 294 | 295 | public String updateCheckChannel() { 296 | return config.getString("check_update_channel", "stable"); 297 | } 298 | 299 | public int getSuspicionThreshold() { 300 | return config.getInt("xray.mine.suspicionThreshold", 100); 301 | } 302 | 303 | public String WebHookURL() { 304 | return config.getString("DiscordWebHook.WebHookURL"); 305 | } 306 | 307 | public boolean WebHookEnable() { 308 | return config.getBoolean("DiscordWebHook.enable", false); 309 | } 310 | 311 | public int WebHookColor() { 312 | return config.getInt("DiscordWebHook.vl-add-message.color", 0xFF5733); 313 | } 314 | 315 | public String WebHookTitle() { 316 | return config.getString("DiscordWebHook.vl-add-message.title"); 317 | } 318 | 319 | public List WebHookText() { 320 | return config.getStringList("DiscordWebHook.vl-add-message.text"); 321 | } 322 | 323 | public int WebHookVLRequired() { 324 | return config.getInt("DiscordWebHook.vl-required"); 325 | } 326 | 327 | public boolean isCustomJsonEnabled() { 328 | return config.getBoolean("DiscordWebHook.custom-json.enable", false); 329 | } 330 | 331 | public String getCustomJsonFormat() { 332 | return config.getString("DiscordWebHook.custom-json.format", ""); 333 | } 334 | 335 | public int getYPosChangeThresholdAddRequired() { 336 | return config.getInt("xray.path-detection.y-change-threshold-add-required", 3); 337 | } 338 | 339 | public int AirMonitorVLT() { 340 | return plugin.getConfig().getInt("xray.natural-detection.cave.air-monitor.violation-threshold", 5); 341 | } 342 | } 343 | 344 | 345 | 346 | -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/managers/UpdateManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/managers/UpdateManager.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack.managers; 13 | 14 | import link.star_dust.MinerTrack.MinerTrack; 15 | import net.md_5.bungee.api.chat.BaseComponent; 16 | import net.md_5.bungee.api.chat.ClickEvent; 17 | import net.md_5.bungee.api.chat.HoverEvent; 18 | import net.md_5.bungee.api.chat.TextComponent; 19 | import org.bukkit.Bukkit; 20 | import org.bukkit.command.CommandSender; 21 | import org.bukkit.entity.Player; 22 | import org.json.JSONArray; 23 | import org.json.JSONObject; 24 | 25 | import java.io.BufferedReader; 26 | import java.io.IOException; 27 | import java.io.InputStreamReader; 28 | import java.net.HttpURLConnection; 29 | import java.net.URL; 30 | 31 | public class UpdateManager { 32 | private final MinerTrack plugin; 33 | private String latestVersion; 34 | private final String currentVersion; 35 | private String downloadUrl; 36 | 37 | public UpdateManager(MinerTrack plugin) { 38 | this.plugin = plugin; 39 | this.currentVersion = plugin.getDescription().getVersion(); 40 | 41 | if (plugin.getConfigManager().updateCheck()) { 42 | fetchLatestVersionFromModrinth(); 43 | } else { 44 | this.latestVersion = null; 45 | } 46 | } 47 | 48 | public void checkForUpdates(CommandSender sender) { 49 | fetchLatestVersionFromModrinth(); 50 | 51 | if (latestVersion == null) { 52 | String errorMessage = plugin.getLanguageManager().getPrefixedMessageWithDefault( 53 | "update.check-failed", 54 | "&cFailed to check for updates." 55 | ); 56 | sendMessage(sender, errorMessage); 57 | return; 58 | } 59 | 60 | if (shouldConsiderAsUpdate(latestVersion, currentVersion)) { 61 | sendUpdateMessage(sender, latestVersion); 62 | } else { 63 | String upToDateMessage = plugin.getLanguageManager().getPrefixedMessageWithDefault( 64 | "update.using-latest", 65 | "&2You are using the latest version." 66 | ); 67 | sendMessage(sender, upToDateMessage); 68 | } 69 | } 70 | 71 | private void fetchLatestVersionFromModrinth() { 72 | try { 73 | URL url = new URL("https://api.modrinth.com/v2/project/minertrack/version"); 74 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 75 | conn.setRequestMethod("GET"); 76 | conn.setRequestProperty("User-Agent", "MinerTrack Update Checker"); 77 | conn.setConnectTimeout(5000); 78 | conn.setReadTimeout(5000); 79 | 80 | BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); 81 | StringBuilder response = new StringBuilder(); 82 | String line; 83 | 84 | while ((line = reader.readLine()) != null) { 85 | response.append(line); 86 | } 87 | reader.close(); 88 | 89 | JSONArray versions = new JSONArray(response.toString()); 90 | if (versions.length() > 0) { 91 | JSONObject latest = versions.getJSONObject(0); 92 | this.latestVersion = latest.getString("version_number"); 93 | this.downloadUrl = "https://modrinth.com/plugin/minertrack/version/" + this.latestVersion; 94 | } else { 95 | plugin.getLogger().warning("No versions found on Modrinth."); 96 | this.latestVersion = null; 97 | this.downloadUrl = null; 98 | } 99 | 100 | } catch (IOException | org.json.JSONException e) { 101 | plugin.getLogger().warning("Failed to check for updates from Modrinth: " + e.getMessage()); 102 | this.latestVersion = null; 103 | this.downloadUrl = null; 104 | } 105 | } 106 | 107 | private boolean shouldConsiderAsUpdate(String latestVersion, String currentVersion) { 108 | if (latestVersion == null || currentVersion == null) { 109 | return false; 110 | } 111 | 112 | String channel = plugin.getConfigManager().updateCheckChannel().toLowerCase(); 113 | Version latest = parseVersion(latestVersion); 114 | Version current = parseVersion(currentVersion); 115 | 116 | int mainCompare = compareVersionNumbers(latest.mainParts, current.mainParts); 117 | if (mainCompare < 0) { 118 | return false; 119 | } 120 | if (mainCompare > 0) { 121 | return isVersionAllowedByChannel(latest, channel); 122 | } 123 | 124 | if (latest.preReleaseTag == null && current.preReleaseTag == null) { 125 | return false; 126 | } 127 | 128 | if (latest.preReleaseTag == null && current.preReleaseTag != null) { 129 | return isVersionAllowedByChannel(latest, channel); 130 | } 131 | 132 | if (latest.preReleaseTag != null) { 133 | if (latest.isNewerPreReleaseThan(current)) { 134 | return isVersionAllowedByChannel(latest, channel); 135 | } 136 | } 137 | 138 | return false; 139 | } 140 | 141 | private boolean isVersionAllowedByChannel(Version version, String channel) { 142 | if (version.preReleaseTag == null) { 143 | return true; 144 | } 145 | 146 | String tag = version.preReleaseTag.toLowerCase(); 147 | if ("alpha".equals(channel)) { 148 | return true; 149 | } else if ("beta".equals(channel)) { 150 | return tag.startsWith("beta"); 151 | } else { // stable or unknown 152 | return false; 153 | } 154 | } 155 | 156 | private static class Version { 157 | final int[] mainParts; 158 | final String preReleaseTag; 159 | 160 | Version(int[] mainParts, String preReleaseTag) { 161 | this.mainParts = mainParts; 162 | this.preReleaseTag = preReleaseTag; 163 | } 164 | 165 | boolean isNewerPreReleaseThan(Version other) { 166 | boolean thisStable = this.preReleaseTag == null; 167 | boolean otherStable = other.preReleaseTag == null; 168 | 169 | if (thisStable && !otherStable) return true; 170 | if (!thisStable && otherStable) return false; 171 | if (thisStable && otherStable) return false; 172 | 173 | return comparePreRelease(this.preReleaseTag, other.preReleaseTag) > 0; 174 | } 175 | } 176 | 177 | private Version parseVersion(String versionStr) { 178 | versionStr = versionStr.replaceFirst("^v", ""); 179 | String[] parts = versionStr.split("-", 2); 180 | String main = parts[0]; 181 | String pre = parts.length > 1 ? parts[1] : null; 182 | 183 | String[] mainSplit = main.split("\\."); 184 | int[] mainParts = new int[mainSplit.length]; 185 | for (int i = 0; i < mainSplit.length; i++) { 186 | mainParts[i] = parsePositiveInt(mainSplit[i], 0); 187 | } 188 | 189 | return new Version(mainParts, pre); 190 | } 191 | 192 | private int compareVersionNumbers(int[] a, int[] b) { 193 | int len = Math.max(a.length, b.length); 194 | for (int i = 0; i < len; i++) { 195 | int va = i < a.length ? a[i] : 0; 196 | int vb = i < b.length ? b[i] : 0; 197 | if (va != vb) { 198 | return Integer.compare(va, vb); 199 | } 200 | } 201 | return 0; 202 | } 203 | 204 | private static int comparePreRelease(String a, String b) { 205 | if (a == null && b == null) return 0; 206 | if (a == null) return 1; 207 | if (b == null) return -1; 208 | 209 | String aLower = a.toLowerCase(); 210 | String bLower = b.toLowerCase(); 211 | 212 | boolean aIsAlpha = aLower.startsWith("alpha"); 213 | boolean aIsBeta = aLower.startsWith("beta"); 214 | boolean bIsAlpha = bLower.startsWith("alpha"); 215 | boolean bIsBeta = bLower.startsWith("beta"); 216 | 217 | if (aIsBeta && bIsAlpha) return 1; 218 | if (aIsAlpha && bIsBeta) return -1; 219 | if ((aIsBeta || aIsAlpha) != (bIsBeta || bIsAlpha)) { 220 | return a.compareTo(b); // fallback 221 | } 222 | 223 | int numA = extractNumericSuffix(a); 224 | int numB = extractNumericSuffix(b); 225 | if (numA != numB) { 226 | return Integer.compare(numA, numB); 227 | } 228 | return a.compareTo(b); // fallback 229 | } 230 | 231 | private static int extractNumericSuffix(String tag) { 232 | String[] parts = tag.split("[^0-9]+"); 233 | for (int i = parts.length - 1; i >= 0; i--) { 234 | if (!parts[i].isEmpty()) { 235 | try { 236 | return Integer.parseInt(parts[i]); 237 | } catch (NumberFormatException ignored) {} 238 | } 239 | } 240 | return 0; 241 | } 242 | 243 | private static int parsePositiveInt(String str, int defaultValue) { 244 | try { 245 | int val = Integer.parseInt(str.trim()); 246 | return val >= 0 ? val : defaultValue; 247 | } catch (NumberFormatException e) { 248 | return defaultValue; 249 | } 250 | } 251 | 252 | public boolean isHasNewerVersion() { 253 | return latestVersion != null && shouldConsiderAsUpdate(latestVersion, currentVersion); 254 | } 255 | 256 | public BaseComponent[] getUpdateMessageComponent() { 257 | if (latestVersion == null || !shouldConsiderAsUpdate(latestVersion, currentVersion)) { 258 | return null; 259 | } 260 | 261 | String messageKey; 262 | if (latestVersion.contains("-beta")) { 263 | messageKey = "update.beta-available"; 264 | } else if (latestVersion.contains("-alpha")) { 265 | messageKey = "update.alpha-available"; 266 | } else { 267 | messageKey = "update.stable-available"; 268 | } 269 | 270 | String defaultMessage; 271 | if (latestVersion.contains("-beta")) { 272 | defaultMessage = "&eNew beta version %latest_version% now available!"; 273 | } else if (latestVersion.contains("-alpha")) { 274 | defaultMessage = "&cNew alpha version %latest_version% now available!"; 275 | } else { 276 | defaultMessage = "&aNew stable version %latest_version% now available!"; 277 | } 278 | 279 | String baseMessage = plugin.getLanguageManager().getPrefixedMessageWithDefault(messageKey, defaultMessage) 280 | .replace("%latest_version%", latestVersion); 281 | 282 | TextComponent component = new TextComponent(plugin.getLanguageManager().applyColors(baseMessage)); 283 | if (downloadUrl != null) { 284 | component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, downloadUrl)); 285 | component.setHoverEvent(new HoverEvent( 286 | HoverEvent.Action.SHOW_TEXT, 287 | new BaseComponent[] { 288 | new TextComponent(plugin.getLanguageManager().applyColors("&f" + latestVersion + ": " + downloadUrl)) 289 | } 290 | )); 291 | } 292 | 293 | return new BaseComponent[]{component}; 294 | } 295 | 296 | private void sendMessage(CommandSender sender, String message) { 297 | String coloredMessage = plugin.getLanguageManager().applyColors(message); 298 | if (sender != null) { 299 | sender.sendMessage(coloredMessage); 300 | } else { 301 | Bukkit.getConsoleSender().sendMessage(coloredMessage); 302 | } 303 | } 304 | 305 | private void sendUpdateMessage(CommandSender sender, String latestVersion) { 306 | String messageKey; 307 | if (latestVersion.contains("-beta")) { 308 | messageKey = "update.beta-available"; 309 | } else if (latestVersion.contains("-alpha")) { 310 | messageKey = "update.alpha-available"; 311 | } else { 312 | messageKey = "update.stable-available"; 313 | } 314 | 315 | String defaultMessage; 316 | if (latestVersion.contains("-beta")) { 317 | defaultMessage = "&eNew beta version %latest_version% now available!"; 318 | } else if (latestVersion.contains("-alpha")) { 319 | defaultMessage = "&cNew alpha version %latest_version% now available!"; 320 | } else { 321 | defaultMessage = "&aNew stable version %latest_version% now available!"; 322 | } 323 | 324 | String baseMessage = plugin.getLanguageManager().getPrefixedMessageWithDefault(messageKey, defaultMessage) 325 | .replace("%latest_version%", latestVersion); 326 | 327 | TextComponent component = new TextComponent(plugin.getLanguageManager().applyColors(baseMessage)); 328 | if (downloadUrl != null) { 329 | component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, downloadUrl)); 330 | component.setHoverEvent(new HoverEvent( 331 | HoverEvent.Action.SHOW_TEXT, 332 | new TextComponent[] { 333 | new TextComponent(plugin.getLanguageManager().applyColors("&f" + latestVersion + ": " + downloadUrl)) 334 | } 335 | )); 336 | } 337 | 338 | if (sender instanceof Player) { 339 | ((Player) sender).spigot().sendMessage(component); 340 | } else { 341 | Bukkit.getConsoleSender().sendMessage(plugin.getLanguageManager().applyColors(baseMessage)); 342 | } 343 | } 344 | } -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/commands/MinerTrackCommand.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/commands/MinerTrackCommand.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack.commands; 13 | 14 | import link.star_dust.MinerTrack.FoliaCheck; 15 | import link.star_dust.MinerTrack.MinerTrack; 16 | import link.star_dust.MinerTrack.managers.LanguageManager; 17 | import link.star_dust.MinerTrack.utils.LogViewerUtils; 18 | 19 | import org.bukkit.Bukkit; 20 | import org.bukkit.command.Command; 21 | import org.bukkit.command.CommandExecutor; 22 | import org.bukkit.command.CommandSender; 23 | import org.bukkit.command.TabCompleter; 24 | import org.bukkit.command.ConsoleCommandSender; 25 | import org.bukkit.entity.Player; 26 | 27 | import io.papermc.paper.threadedregions.scheduler.RegionScheduler; 28 | 29 | import java.io.File; 30 | import java.io.IOException; 31 | import java.nio.charset.StandardCharsets; 32 | import java.nio.file.Files; 33 | import java.util.ArrayList; 34 | import java.util.Arrays; 35 | import java.util.Comparator; 36 | import java.util.List; 37 | import java.util.Map; 38 | import java.util.concurrent.ConcurrentHashMap; 39 | 40 | public class MinerTrackCommand implements CommandExecutor, TabCompleter { 41 | private final MinerTrack plugin; 42 | 43 | public MinerTrackCommand(MinerTrack plugin) { 44 | this.plugin = plugin; 45 | } 46 | 47 | @SuppressWarnings("deprecation") 48 | @Override 49 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { 50 | if (!(sender instanceof Player) || sender instanceof ConsoleCommandSender) { 51 | // pass 52 | } else if (!sender.hasPermission("minertrack.use")) { 53 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 54 | return true; 55 | } 56 | 57 | if (args.length == 0 || args[0].equalsIgnoreCase("help")) { 58 | if (!sender.hasPermission("minertrack.help")) { 59 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 60 | return true; 61 | } 62 | List helpMessages = plugin.getLanguageManager().getHelpMessages(); 63 | for (String message : helpMessages) { 64 | sender.sendMessage(plugin.getLanguageManager().applyColors(message)); 65 | } 66 | return true; 67 | } 68 | 69 | switch (args[0].toLowerCase()) { 70 | case "notify": 71 | if (!sender.hasPermission("minertrack.sendnotify")) { 72 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 73 | return true; 74 | } 75 | if (args.length < 2) { 76 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("usage-notify")); 77 | return true; 78 | } 79 | String messageContent = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); 80 | plugin.getNotifier().sendNotifyMessage(messageContent); 81 | break; 82 | 83 | case "verbose": 84 | if (!sender.hasPermission("minertrack.verbose")) { 85 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 86 | return true; 87 | } 88 | plugin.toggleVerboseMode(sender); 89 | break; 90 | 91 | case "check": 92 | if (!sender.hasPermission("minertrack.check")) { 93 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 94 | return true; 95 | } 96 | if (args.length < 2) { 97 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("usage-check")); 98 | return true; 99 | } 100 | Player target = plugin.getServer().getPlayer(args[1]); 101 | if (target != null) { 102 | int violationLevel = plugin.getViolationManager().getViolationLevel(target); 103 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("violation-level") 104 | .replace("{player}", target.getName()) 105 | .replace("{level}", String.valueOf(violationLevel))); 106 | } else { 107 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("player-not-found") 108 | .replace("{player}", args[1])); 109 | } 110 | break; 111 | 112 | case "reset": 113 | if (!sender.hasPermission("minertrack.reset")) { 114 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 115 | return true; 116 | } 117 | if (args.length < 2) { 118 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("usage-reset")); 119 | return true; 120 | } 121 | Player targetToReset = plugin.getServer().getPlayer(args[1]); 122 | if (targetToReset != null) { 123 | plugin.getViolationManager().resetViolationLevel(targetToReset); 124 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("reset-success") 125 | .replace("{player}", args[1])); 126 | } else { 127 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("player-not-found") 128 | .replace("{player}", args[1])); 129 | } 130 | break; 131 | 132 | case "kick": 133 | if (!sender.hasPermission("minertrack.kick")) { 134 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 135 | return true; 136 | } 137 | if (args.length < 3) { 138 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("usage-kick")); 139 | return true; 140 | } 141 | 142 | Player playerToKick = plugin.getServer().getPlayer(args[1]); 143 | if (playerToKick != null) { 144 | String reason = String.join(" ", Arrays.copyOfRange(args, 2, args.length)); 145 | 146 | if (plugin.getConfigManager().isKickStrikeLightning()) { 147 | if (FoliaCheck.isFolia()) { 148 | // Use Folia's region-based scheduler to execute the task safely 149 | Bukkit.getRegionScheduler().execute(plugin, playerToKick.getLocation(), () -> { 150 | try { 151 | playerToKick.getWorld().strikeLightningEffect(playerToKick.getLocation()); 152 | } catch (Exception e) { 153 | plugin.getLogger().severe("Failed to strike lightning effect on Folia: " + e.getMessage()); 154 | e.printStackTrace(); // Log the full stack trace for debugging 155 | } 156 | }); 157 | } else { 158 | // Non-Folia servers can execute the task directly 159 | try { 160 | playerToKick.getWorld().strikeLightningEffect(playerToKick.getLocation()); 161 | } catch (Exception e) { 162 | plugin.getLogger().severe("Failed to strike lightning effect: " + e.getMessage()); 163 | e.printStackTrace(); // Log the full stack trace for debugging 164 | } 165 | } 166 | } 167 | 168 | if (plugin.getLanguageManager().isKickBroadcastEnabled()) { 169 | String kickMessage = plugin.getLanguageManager().getPrefixedMessage("kick-format") 170 | .replace("%player%", playerToKick.getName()) 171 | .replace("%reason%", reason); 172 | plugin.getServer().broadcastMessage(kickMessage); 173 | } 174 | 175 | plugin.getNotifier().kickPlayer(playerToKick, reason); 176 | 177 | } else { 178 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("player-not-found") 179 | .replace("{player}", args[1])); 180 | } 181 | break; 182 | 183 | case "reload": 184 | if (!sender.hasPermission("minertrack.reload")) { 185 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 186 | return true; 187 | } 188 | plugin.getConfigManager().reloadConfig(); 189 | plugin.getLanguageManager().loadLanguageFile(); 190 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("config-reloaded")); 191 | break; 192 | 193 | case "update": 194 | if (!sender.hasPermission("minertrack.checkupdate")) { 195 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 196 | return true; 197 | } 198 | plugin.checkForUpdates(sender); 199 | break; 200 | 201 | case "logs": 202 | if (!sender.hasPermission("minertrack.logs")) { 203 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("no-permission")); 204 | return true; 205 | } 206 | if (args.length == 2) { 207 | String logName = args[1]; 208 | if (!logName.endsWith(".log")) { 209 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("log-viewer-not-log-file")); 210 | return true; 211 | } 212 | File logDir = new File(plugin.getDataFolder(), "logs"); 213 | File logFile = new File(logDir, logName); 214 | if (!logFile.exists() || !logFile.isFile()) { 215 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("log-viewer-not-found").replace("{log_file}", logName)); 216 | return true; 217 | } 218 | try { 219 | List lines = LogViewerUtils.readLogFile(logFile); 220 | List reversedLines = new ArrayList<>(lines); 221 | java.util.Collections.reverse(reversedLines); 222 | int perPage = plugin.getLanguageManager().getLogViewerLinesPerPage(); 223 | int totalPages = LogViewerUtils.getTotalPages(reversedLines.size(), perPage); 224 | int page = 1; 225 | LogViewerUtils.LogCache cache = new LogViewerUtils.LogCache(logName, reversedLines, totalPages, page); 226 | LogViewerUtils.putCache(sender, cache); 227 | sendLogPage(sender, cache, perPage); 228 | } catch (IOException e) { 229 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("log-viewer-cant-read")); 230 | } 231 | return true; 232 | } else if (args.length == 3 && args[1].equalsIgnoreCase("page")) { 233 | LogViewerUtils.LogCache cache = LogViewerUtils.getCache(sender); 234 | if (cache == null) { 235 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("usage-logs")); 236 | return true; 237 | } 238 | int page; 239 | try { 240 | page = Integer.parseInt(args[2]); 241 | } catch (NumberFormatException ex) { 242 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("log-viewer-page-nan")); 243 | return true; 244 | } 245 | if (page < 1 || page > cache.totalPages) { 246 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("log-viewer-page-invalid").replace("{max_page}", String.valueOf(cache.totalPages))); 247 | return true; 248 | } 249 | cache.currentPage = page; 250 | sendLogPage(sender, cache, plugin.getLanguageManager().getLogViewerLinesPerPage()); 251 | return true; 252 | } 253 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("usage-logs")); 254 | break; 255 | 256 | default: 257 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("unknown-command")); 258 | break; 259 | } 260 | return true; 261 | } 262 | 263 | private void sendLogPage(CommandSender sender, LogViewerUtils.LogCache cache, int perPage) { 264 | int totalLines = cache.lines.size(); 265 | int page = cache.currentPage; 266 | int totalPages = cache.totalPages; 267 | int[] range = LogViewerUtils.getPageRange(totalLines, page, perPage); 268 | int start = range[0]; 269 | int end = range[1]; 270 | String header = plugin.getLanguageManager().getColoredMessage("log-viewer-header") 271 | .replace("{current_page}", String.valueOf(page)) 272 | .replace("{max_page}", String.valueOf(totalPages)) 273 | .replace("{log_file}", cache.logName); 274 | sender.sendMessage(header); 275 | if (start >= end) { 276 | sender.sendMessage(plugin.getLanguageManager().getPrefixedMessage("log-viewer-empty")); 277 | return; 278 | } 279 | for (int i = start; i < end; i++) { 280 | sender.sendMessage(plugin.getLanguageManager().getColoredMessage("log-viewer-logs-color") + cache.lines.get(i)); 281 | } 282 | 283 | if (page < totalPages) { 284 | sender.sendMessage(""); 285 | sender.sendMessage(plugin.getLanguageManager().getColoredMessage("log-viewer-next-page").replace("{next_page}", String.valueOf(page + 1))); 286 | } 287 | } 288 | 289 | @Override 290 | public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { 291 | List completions = new ArrayList<>(); 292 | if (args.length == 1) { 293 | completions.addAll(Arrays.asList("help", "notify", "verbose", "check", "reset", "kick", "reload", "update", "logs")); 294 | } else if (args.length == 2) { 295 | if (args[0].equalsIgnoreCase("check") || args[0].equalsIgnoreCase("reset") || args[0].equalsIgnoreCase("kick")) { 296 | for (Player player : plugin.getServer().getOnlinePlayers()) { 297 | completions.add(player.getName()); 298 | } 299 | } else if (args[0].equalsIgnoreCase("logs")) { 300 | File logDir = new File(plugin.getDataFolder(), "logs"); 301 | File[] files = logDir.listFiles((dir, name) -> name.endsWith(".log")); 302 | if (files != null) { 303 | Arrays.sort(files, Comparator.comparing(File::getName).reversed()); 304 | int max = Math.min(10, files.length); 305 | for (int i = 0; i < max; i++) { 306 | completions.add(files[i].getName()); 307 | } 308 | } 309 | } 310 | } 311 | 312 | return completions; 313 | } 314 | 315 | public void clearLogCache(CommandSender sender) { 316 | LogViewerUtils.clearCache(sender); 317 | } 318 | } -------------------------------------------------------------------------------- /src/main/java/link/star_dust/MinerTrack/managers/ViolationManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * DON'T REMOVE THIS 3 | * 4 | * /MinerTrack/src/main/java/link/star_dust/MinerTrack/managers/ViolationManager.java 5 | * 6 | * MinerTrack Source Code - Public under GPLv3 license 7 | * Original Author: Author87668 8 | * Contributors: Author87668 9 | * 10 | * DON'T REMOVE THIS 11 | **/ 12 | package link.star_dust.MinerTrack.managers; 13 | 14 | import link.star_dust.MinerTrack.FoliaCheck; 15 | import link.star_dust.MinerTrack.MinerTrack; 16 | import link.star_dust.MinerTrack.listeners.MiningListener; 17 | import link.star_dust.MinerTrack.hooks.DiscordWebHook; 18 | import link.star_dust.MinerTrack.hooks.CustomJsonWebHook; 19 | 20 | import org.bukkit.Bukkit; 21 | import org.bukkit.Location; 22 | import org.bukkit.entity.Player; 23 | import org.bukkit.plugin.Plugin; 24 | 25 | import java.io.File; 26 | import java.io.FileWriter; 27 | import java.io.IOException; 28 | import java.text.SimpleDateFormat; 29 | import java.time.LocalDate; 30 | import java.time.LocalDateTime; 31 | import java.time.format.DateTimeFormatter; 32 | import java.time.temporal.ChronoField; 33 | import java.util.ArrayList; 34 | import java.util.HashMap; 35 | import java.util.HashSet; 36 | import java.util.List; 37 | import java.util.Locale; 38 | import java.util.Map; 39 | import java.util.UUID; 40 | import org.bukkit.scheduler.BukkitRunnable; 41 | import org.bukkit.scheduler.BukkitTask; 42 | import java.util.function.Consumer; 43 | 44 | import io.papermc.paper.threadedregions.scheduler.RegionScheduler; 45 | import io.papermc.paper.threadedregions.scheduler.ScheduledTask; 46 | 47 | public class ViolationManager { 48 | private final MinerTrack plugin; 49 | private final static Map violationLevels = new HashMap<>(); 50 | private final Map vlZeroTimestamp = new HashMap<>(); 51 | private final Map vlChangedTimestamp = new HashMap<>(); 52 | private final Map vlDecayTasks = new HashMap<>(); 53 | 54 | private String currentLogFileName; 55 | 56 | public ViolationManager(MinerTrack plugin) { 57 | this.plugin = plugin; 58 | this.currentLogFileName = generateLogFileName(); 59 | int interval = 20 * 60; // Scheduling interval (unit: tick) 60 | 61 | if (FoliaCheck.isFolia()) { 62 | try { 63 | Class schedulerClass = Class.forName("org.bukkit.Bukkit"); 64 | Object scheduler = schedulerClass.getMethod("getGlobalRegionScheduler").invoke(null); 65 | scheduler.getClass().getMethod("runAtFixedRate", 66 | Plugin.class, 67 | Class.forName("java.util.function.Consumer"), 68 | long.class, 69 | long.class 70 | ).invoke(scheduler, plugin, (Consumer) task -> { 71 | try { 72 | if (!plugin.isEnabled()) { 73 | task.getClass().getMethod("cancel").invoke(task); 74 | return; 75 | } 76 | processVLDecayTasks(); 77 | } catch (Exception e) { 78 | e.printStackTrace(); 79 | } 80 | }, interval, interval); 81 | } catch (Exception e) { 82 | e.printStackTrace(); 83 | } 84 | } else { 85 | new BukkitRunnable() { 86 | @Override 87 | public void run() { 88 | if (!plugin.isEnabled()) { 89 | cancel(); 90 | return; 91 | } 92 | processVLDecayTasks(); 93 | } 94 | }.runTaskTimer(plugin, interval, interval); 95 | } 96 | } 97 | 98 | private String generateLogFileName() { 99 | LocalDate date = LocalDate.now(); 100 | String formattedDate = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); 101 | 102 | File logDir = new File(plugin.getDataFolder(), "logs"); 103 | if (!logDir.exists() && !logDir.mkdirs()) { 104 | Bukkit.getLogger().warning("Could not create logs directory for MinerTrack."); 105 | } 106 | 107 | int index = 1; 108 | File logFile; 109 | 110 | do { 111 | logFile = new File(logDir, String.format("%s-%d%s.log", formattedDate, index, getOrdinalSuffix(index))); 112 | index++; 113 | } while (logFile.exists()); 114 | 115 | return logFile.getName(); 116 | } 117 | 118 | private String getLogFileName() { 119 | if (currentLogFileName == null) { 120 | currentLogFileName = generateLogFileName(); 121 | } 122 | return currentLogFileName; 123 | } 124 | 125 | private String getOrdinalSuffix(int index) { 126 | if (index >= 11 && index <= 13) return "th"; 127 | switch (index % 10) { 128 | case 1: return "st"; 129 | case 2: return "nd"; 130 | case 3: return "rd"; 131 | default: return "th"; 132 | } 133 | } 134 | 135 | private void logViolation(Player player, int vl, int addVl, String blockType, int count, int vein, Location location) { 136 | if (!plugin.getConfig().getBoolean("log_file")) return; 137 | 138 | String logFormat = plugin.getLanguageManager().getLogFormat(); 139 | String worldName = location.getWorld() != null ? location.getWorld().getName() : "unknown"; 140 | 141 | LocalDateTime now = LocalDateTime.now(); 142 | String year = String.valueOf(now.getYear()); 143 | String month = String.format("%02d", now.getMonthValue()); 144 | String day = String.format("%02d", now.getDayOfMonth()); 145 | String hour = String.format("%02d", now.getHour()); 146 | String minute = String.format("%02d", now.getMinute()); 147 | String second = String.format("%02d", now.getSecond()); 148 | 149 | String formattedMessage = logFormat 150 | .replace("%year%", year) 151 | .replace("%month%", month) 152 | .replace("%day%", day) 153 | .replace("%hour%", hour) 154 | .replace("%minute%", minute) 155 | .replace("%second%", second) 156 | .replace("%player%", player.getName()) 157 | .replace("%vl%", String.valueOf(vl)) 158 | .replace("%add_vl%", String.valueOf(addVl)) 159 | .replace("%block_type%", blockType) 160 | .replace("%count%", String.valueOf(count)) 161 | .replace("%vein_count%", String.valueOf(vein)) 162 | .replace("%world%", worldName) 163 | .replace("%pos_x%", String.valueOf(location.getBlockX())) 164 | .replace("%pos_y%", String.valueOf(location.getBlockY())) 165 | .replace("%pos_z%", String.valueOf(location.getBlockZ())); 166 | 167 | String fileName = getLogFileName(); 168 | File logDir = new File(plugin.getDataFolder(), "logs"); 169 | File logFile = new File(logDir, fileName); 170 | 171 | try (FileWriter writer = new FileWriter(logFile, true)) { 172 | writer.write(formattedMessage + "\n"); 173 | } catch (IOException e) { 174 | e.printStackTrace(); 175 | } 176 | } 177 | 178 | private void logCommand(String command) { 179 | if (!plugin.getConfig().getBoolean("log_file")) return; 180 | 181 | String fileName = getLogFileName(); 182 | File logDir = new File(plugin.getDataFolder(), "logs"); 183 | File logFile = new File(logDir, fileName); 184 | 185 | try (FileWriter writer = new FileWriter(logFile, true)) { 186 | writer.write("Excuted Command: " + command + "\n"); 187 | } catch (IOException e) { 188 | e.printStackTrace(); 189 | } 190 | } 191 | 192 | public static int getViolationLevel(UUID uuid) { 193 | return violationLevels.getOrDefault(uuid, 0); 194 | } 195 | 196 | public int getViolationLevel(Player player) { 197 | return violationLevels.getOrDefault(player.getUniqueId(), 0); 198 | } 199 | 200 | public void increaseViolationLevel(Player player, int increment, String blockType, int count, int vein, Location location) { 201 | long now = System.currentTimeMillis(); 202 | UUID playerId = player.getUniqueId(); 203 | 204 | vlZeroTimestamp.remove(playerId); 205 | 206 | vlChangedTimestamp.put(playerId, now); 207 | 208 | if (vlDecayTasks.containsKey(playerId)) { 209 | cancelVLDecayTask(playerId); 210 | vlDecayTasks.remove(playerId); 211 | } 212 | 213 | scheduleVLDecayTask(player); 214 | 215 | int oldLevel = getViolationLevel(playerId); 216 | int newLevel = oldLevel + increment; 217 | violationLevels.put(playerId, newLevel); 218 | 219 | // 处理 VL 增加后的其他逻辑,覆盖所有从 oldLevel+1 到 newLevel 的阈值 220 | if (plugin.getConfig().isConfigurationSection("xray.commands")) { 221 | for (String key : plugin.getConfig().getConfigurationSection("xray.commands").getKeys(false)) { 222 | int threshold = Integer.parseInt(key); 223 | if (threshold > oldLevel && threshold <= newLevel) { 224 | Object raw = plugin.getConfig().get("xray.commands." + key); 225 | 226 | List commandsToRun = new ArrayList<>(); 227 | 228 | if (raw instanceof List) { 229 | for (Object o : (List) raw) { 230 | if (o != null) commandsToRun.add(String.valueOf(o)); 231 | } 232 | } else if (raw != null) { 233 | commandsToRun.add(String.valueOf(raw)); 234 | } 235 | 236 | for (String commandTemplate : commandsToRun) { 237 | if (commandTemplate == null || commandTemplate.trim().isEmpty()) continue; 238 | String command = commandTemplate.replace("%player%", player.getName()); 239 | 240 | if (FoliaCheck.isFolia()) { 241 | RegionScheduler regionScheduler = Bukkit.getRegionScheduler(); 242 | regionScheduler.run(plugin, location, scheduledTask -> { 243 | Bukkit.getGlobalRegionScheduler().execute(plugin, () -> { 244 | Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); 245 | logCommand(command); 246 | }); 247 | }); 248 | } else { 249 | Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); 250 | logCommand(command); 251 | } 252 | } 253 | } 254 | } 255 | } 256 | 257 | if (newLevel >= 1) { 258 | String verboseFormat = plugin.getLanguageManager().getPrefixedMessage("verbose-format"); 259 | String worldName = location.getWorld() != null ? location.getWorld().getName() : "unknown"; 260 | 261 | String formattedMessage = verboseFormat 262 | .replace("%player%", player.getName()) 263 | .replace("%vl%", String.valueOf(newLevel)) 264 | .replace("%add_vl%", String.valueOf(increment)) 265 | .replace("%block_type%", blockType) 266 | .replace("%count%", String.valueOf(count)) 267 | .replace("%vein_count%", String.valueOf(vein)) 268 | .replace("%world%", worldName) 269 | .replace("%pos_x%", String.valueOf(location.getBlockX())) 270 | .replace("%pos_y%", String.valueOf(location.getBlockY())) 271 | .replace("%pos_z%", String.valueOf(location.getBlockZ())); 272 | 273 | for (UUID uuid : plugin.getVerbosePlayers()) { 274 | Player verbosePlayer = Bukkit.getPlayer(uuid); 275 | if (verbosePlayer != null && verbosePlayer.hasPermission("minertrack.verbose")) { 276 | verbosePlayer.sendMessage(formattedMessage); 277 | } 278 | } 279 | 280 | if (plugin.isVerboseConsoleEnabled()) { 281 | Bukkit.getConsoleSender().sendMessage(formattedMessage); 282 | } 283 | 284 | logViolation(player, newLevel, increment, blockType, count, vein, location); 285 | 286 | if (plugin.getConfigManager().WebHookEnable() && newLevel >= plugin.getConfigManager().WebHookVLRequired()) { 287 | WebHook(playerId, blockType, vein, count, location); 288 | } 289 | } 290 | } 291 | 292 | public void processVLDecayTasks() { 293 | long now = System.currentTimeMillis(); 294 | 295 | for (UUID playerId : new HashSet<>(violationLevels.keySet())) { 296 | int currentVL = violationLevels.getOrDefault(playerId, 0); 297 | 298 | if (currentVL > 0) { 299 | long decayIntervalMillis = plugin.getConfig().getInt("xray.decay.interval", 3) * 60 * 1000L; 300 | Long lastChangedTime = vlChangedTimestamp.get(playerId); 301 | if (lastChangedTime != null && now - lastChangedTime > decayIntervalMillis) { 302 | int decayAmount = plugin.getConfig().getInt("xray.decay.amount", 1); 303 | double decayFactor = plugin.getConfig().getDouble("xray.decay.factor", 0.9); 304 | boolean useFactor = plugin.getConfig().getBoolean("xray.decay.use_factor", false); 305 | 306 | // 选择线性或非线性衰减 307 | int newVL = useFactor 308 | ? (int) Math.ceil(currentVL * decayFactor) 309 | : Math.max(0, currentVL - decayAmount); 310 | 311 | violationLevels.put(playerId, newVL); 312 | vlChangedTimestamp.put(playerId, now); 313 | 314 | // 如果 VL 归零,记录时间戳 315 | if (newVL == 0) { 316 | vlZeroTimestamp.put(playerId, now); 317 | //plugin.getLogger().info("VL=0 timestamp recorded for player: " + playerId); 318 | } 319 | } 320 | } else { 321 | // VL 已经为 0,无需处理 322 | vlZeroTimestamp.putIfAbsent(playerId, now); 323 | } 324 | } 325 | } 326 | 327 | private void scheduleVLDecayTask(Player player) { 328 | UUID playerId = player.getUniqueId(); 329 | 330 | // 如果任务已存在,则跳过 331 | if (vlDecayTasks.containsKey(playerId)) { 332 | return; 333 | } 334 | 335 | // 初始化 VL 和时间戳 336 | violationLevels.putIfAbsent(playerId, 0); 337 | vlZeroTimestamp.putIfAbsent(playerId, System.currentTimeMillis()); 338 | 339 | // 添加到任务集合中 340 | vlDecayTasks.put(playerId, playerId); 341 | } 342 | 343 | private void cancelVLDecayTask(UUID playerId) { 344 | /*if (vlDecayTasks.remove(playerId) != null) { 345 | plugin.getLogger().info("VL decay task canceled for player: " + playerId); 346 | }*/ 347 | vlDecayTasks.remove(playerId); 348 | } 349 | 350 | private void WebHook(UUID playerId, String oreType, int minedVeins, int ore_count, Location location) { 351 | Player player = Bukkit.getPlayer(playerId); 352 | if (player == null) { 353 | return; // 如果玩家离线则跳过 354 | } 355 | 356 | // 获取 WebHook 配置项 357 | String webHookURL = plugin.getConfigManager().WebHookURL(); 358 | // Debug: log which URL will be used for this webhook invocation 359 | //plugin.getLogger().info("[Webhook] ViolationManager will use WebHookURL = " + webHookURL); 360 | 361 | // 如果启用了自定义JSON格式 362 | if (plugin.getConfigManager().isCustomJsonEnabled()) { 363 | Map placeholders = new HashMap<>(); 364 | placeholders.put("player", player.getName()); 365 | placeholders.put("player_uuid", player.getUniqueId().toString()); 366 | placeholders.put("player_vl", String.valueOf(getViolationLevel(player))); 367 | placeholders.put("ore_type", oreType); 368 | placeholders.put("mined_veins", String.valueOf(minedVeins)); 369 | placeholders.put("ore_count", String.valueOf(ore_count)); 370 | placeholders.put("pos_x", String.valueOf(location.getBlockX())); 371 | placeholders.put("pos_y", String.valueOf(location.getBlockY())); 372 | placeholders.put("pos_z", String.valueOf(location.getBlockZ())); 373 | 374 | CustomJsonWebHook customWebHook = new CustomJsonWebHook(plugin, webHookURL, plugin.getConfigManager().getCustomJsonFormat()); 375 | customWebHook.sendMessage(placeholders); 376 | return; 377 | } 378 | 379 | // 原有的Discord WebHook逻辑 380 | String title = plugin.getConfigManager().WebHookTitle(); 381 | List textTemplate = plugin.getConfigManager().WebHookText(); 382 | int color = plugin.getConfigManager().WebHookColor(); 383 | 384 | // 替换占位符 385 | List formattedText = new ArrayList<>(); 386 | for (String line : textTemplate) { 387 | formattedText.add( 388 | line.replace("%player%", player.getName()) 389 | .replace("%player_uuid%", player.getUniqueId().toString()) 390 | .replace("%player_vl%", String.valueOf(getViolationLevel(player))) 391 | .replace("%ore_type%", oreType) 392 | .replace("%mined_veins%", String.valueOf(minedVeins)) 393 | .replace("%ore_count%", String.valueOf(ore_count)) 394 | .replace("%pos_x%", String.valueOf(location.getBlockX())) 395 | .replace("%pos_y%", String.valueOf(location.getBlockY())) 396 | .replace("%pos_z%", String.valueOf(location.getBlockZ())) 397 | ); 398 | } 399 | 400 | // 转换为多行字符串 401 | String description = String.join("\n", formattedText); 402 | 403 | // 创建并发送嵌入消息 404 | DiscordWebHook discordWebHook = new DiscordWebHook(plugin, webHookURL); 405 | DiscordWebHook.Embed embed = new DiscordWebHook.Embed( 406 | title, 407 | description, 408 | color 409 | ); 410 | discordWebHook.sendEmbed(embed); 411 | } 412 | 413 | 414 | public void resetViolationLevel(Player player) { 415 | UUID playerId = player.getUniqueId(); 416 | violationLevels.remove(playerId); 417 | 418 | // Also clear tracking data related to this player if the listener is available 419 | try { 420 | MiningListener listener = plugin.getMiningListener(); 421 | if (listener != null) { 422 | listener.checkAndResetPaths(playerId); 423 | } 424 | } catch (Exception ignored) { 425 | // If mining listener isn't available or something goes wrong, we still 426 | // removed the VL; ignore here to avoid crashing. 427 | } 428 | } 429 | } 430 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS --------------------------------------------------------------------------------