chore: unify checkstyle, fix violations, cleanup bin/
This commit is contained in:
parent
438518cef8
commit
987e69a976
16 changed files with 218 additions and 103 deletions
25
.classpath
Normal file
25
.classpath
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="bin/main" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gradle_scope" value="main"/>
|
||||||
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="bin/main" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gradle_scope" value="main"/>
|
||||||
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="bin/test" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gradle_scope" value="test"/>
|
||||||
|
<attribute name="gradle_used_by_scope" value="test"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||||
|
<classpathentry kind="output" path="bin/default"/>
|
||||||
|
</classpath>
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -39,3 +39,6 @@ plugins/Loreport/
|
||||||
|
|
||||||
# Test data
|
# Test data
|
||||||
.jqwik-database
|
.jqwik-database
|
||||||
|
|
||||||
|
# Compiled output
|
||||||
|
bin/
|
||||||
|
|
|
||||||
34
.project
Normal file
34
.project
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>lorep-LoReport</name>
|
||||||
|
<comment>Project LoReport created by Buildship.</comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1783809993368</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
|
</projectDescription>
|
||||||
13
.settings/org.eclipse.buildship.core.prefs
Normal file
13
.settings/org.eclipse.buildship.core.prefs
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
arguments=--init-script /home/loki/.cache/opencode/bin/jdtls/config_linux/org.eclipse.osgi/57/0/.cp/gradle/init/init.gradle
|
||||||
|
auto.sync=false
|
||||||
|
build.scans.enabled=false
|
||||||
|
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||||
|
connection.project.dir=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
gradle.user.home=
|
||||||
|
java.home=/usr/lib/jvm/java-21-openjdk
|
||||||
|
jvm.arguments=
|
||||||
|
offline.mode=false
|
||||||
|
override.workspace.settings=true
|
||||||
|
show.console.view=true
|
||||||
|
show.executions.view=true
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
# Discord Webhook URL для уведомлений
|
|
||||||
webhook-url: ""
|
|
||||||
|
|
||||||
# Настройки базы данных
|
|
||||||
database:
|
|
||||||
# Тип БД: sqlite или postgresql
|
|
||||||
type: "sqlite"
|
|
||||||
|
|
||||||
# Настройки SQLite
|
|
||||||
sqlite:
|
|
||||||
file: "reports.db"
|
|
||||||
|
|
||||||
# Настройки PostgreSQL
|
|
||||||
postgresql:
|
|
||||||
host: "localhost"
|
|
||||||
port: 5432
|
|
||||||
database: "loreport"
|
|
||||||
username: "loreport"
|
|
||||||
password: "password"
|
|
||||||
pool-size: 10
|
|
||||||
|
|
||||||
# Настройки GUI
|
|
||||||
gui:
|
|
||||||
# Количество репортов на странице
|
|
||||||
reports-per-page: 45
|
|
||||||
# Автообновление GUI (в тиках, 20 тиков = 1 секунда)
|
|
||||||
auto-refresh: 100
|
|
||||||
# Показывать головы игроков в GUI
|
|
||||||
show-player-heads: true
|
|
||||||
|
|
||||||
# Ограничения
|
|
||||||
limits:
|
|
||||||
# Максимальная длина причины репорта
|
|
||||||
max-reason-length: 100
|
|
||||||
# Кулдаун между репортами (в секундах)
|
|
||||||
report-cooldown: 30
|
|
||||||
# Максимум репортов на одного игрока от одного отправителя
|
|
||||||
max-reports-per-player: 3
|
|
||||||
|
|
||||||
# Уведомления
|
|
||||||
notifications:
|
|
||||||
# Уведомлять администраторов о новых репортах
|
|
||||||
notify-admins: true
|
|
||||||
# Звук уведомления для администраторов
|
|
||||||
admin-notification-sound: "BLOCK_NOTE_BLOCK_PLING"
|
|
||||||
# Уведомлять игрока о принятии репорта
|
|
||||||
notify-reporter: true
|
|
||||||
|
|
||||||
# Сообщения
|
|
||||||
messages:
|
|
||||||
report-sent: "&aРепорт успешно отправлен!"
|
|
||||||
already-reported: "&cВы уже отправляли репорт на этого игрока!"
|
|
||||||
self-report: "&cВы не можете отправить репорт на себя!"
|
|
||||||
player-not-found: "&cИгрок не найден!"
|
|
||||||
no-permission: "&cУ вас нет прав на эту команду!"
|
|
||||||
usage: "&eИспользование: /report <ник> <причина>"
|
|
||||||
no-reports: "&eУ этого игрока нет репортов."
|
|
||||||
stats-header: "&6=== Статистика репортов: %player% ==="
|
|
||||||
stats-count: "&eВсего репортов: &f%count%"
|
|
||||||
stats-last-online: "&eПоследний онлайн: &f%time%"
|
|
||||||
stats-report-entry: "&7- %reason% &8(%time% назад)"
|
|
||||||
gui-title: "Репорты - Страница %page%"
|
|
||||||
cooldown: "&cПодождите %time% секунд перед следующим репортом!"
|
|
||||||
reason-too-long: "&cПричина слишком длинная! Максимум %max% символов."
|
|
||||||
max-reports-reached: "&cВы уже отправили максимальное количество репортов на этого игрока!"
|
|
||||||
admin-notification: "&6[Loreport] &eНовый репорт от &f%reporter% &eна &f%reported%: &7%reason%"
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
name: Loreport
|
|
||||||
version: ${version}
|
|
||||||
main: dev.loki.lorep.LorepPlugin
|
|
||||||
api-version: '1.19'
|
|
||||||
author: loki5512344
|
|
||||||
description: Modern player report system with Discord integration and GUI
|
|
||||||
website: https://codeberg.org/loki5512344/Loreport
|
|
||||||
|
|
||||||
commands:
|
|
||||||
report:
|
|
||||||
description: Report a player or manage reports
|
|
||||||
usage: /report <player> <reason> | /report gui | /report stats <player>
|
|
||||||
permission: lorep.report
|
|
||||||
aliases: [rep, reports]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
lorep.report:
|
|
||||||
description: Allows players to report other players
|
|
||||||
default: true
|
|
||||||
lorep.admin:
|
|
||||||
description: Allows access to admin commands (gui, stats)
|
|
||||||
default: op
|
|
||||||
lorep.*:
|
|
||||||
description: Gives access to all Loreport permissions
|
|
||||||
default: false
|
|
||||||
children:
|
|
||||||
lorep.report: true
|
|
||||||
lorep.admin: true
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
id("com.gradleup.shadow") version "9.0.0-beta4"
|
id("com.gradleup.shadow") version "9.0.0-beta4"
|
||||||
|
checkstyle
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.loki"
|
group = "dev.loki"
|
||||||
|
|
@ -67,3 +68,18 @@ tasks {
|
||||||
options.release.set(21)
|
options.release.set(21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkstyle {
|
||||||
|
toolVersion = "10.21.4"
|
||||||
|
configFile = file("config/checkstyle/checkstyle.xml")
|
||||||
|
isIgnoreFailures = false
|
||||||
|
maxErrors = 0
|
||||||
|
maxWarnings = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Checkstyle>().configureEach {
|
||||||
|
reports {
|
||||||
|
xml.required.set(true)
|
||||||
|
html.required.set(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
89
config/checkstyle/checkstyle.xml
Normal file
89
config/checkstyle/checkstyle.xml
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||||
|
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
|
<module name="Checker">
|
||||||
|
<property name="charset" value="UTF-8"/>
|
||||||
|
<property name="severity" value="error"/>
|
||||||
|
<property name="fileExtensions" value="java"/>
|
||||||
|
|
||||||
|
<module name="BeforeExecutionExclusionFileFilter">
|
||||||
|
<property name="fileNamePattern" value=".*[\\/]src[\\/]test[\\/].*"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="SuppressWarningsFilter"/>
|
||||||
|
|
||||||
|
<module name="LineLength">
|
||||||
|
<property name="max" value="150"/>
|
||||||
|
<property name="ignorePattern"
|
||||||
|
value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="TreeWalker">
|
||||||
|
<module name="SuppressWarningsHolder"/>
|
||||||
|
|
||||||
|
<module name="MethodLength">
|
||||||
|
<property name="max" value="80"/>
|
||||||
|
<property name="countEmpty" value="false"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="CyclomaticComplexity">
|
||||||
|
<property name="max" value="20"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="ParameterNumber">
|
||||||
|
<property name="max" value="7"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="AvoidStarImport"/>
|
||||||
|
<module name="UnusedImports"/>
|
||||||
|
<module name="RedundantImport"/>
|
||||||
|
|
||||||
|
<module name="PackageName">
|
||||||
|
<property name="format" value="^[a-z]+(\.[a-zA-Z][a-zA-Z0-9]*)*$"/>
|
||||||
|
</module>
|
||||||
|
<module name="TypeName"/>
|
||||||
|
<module name="MethodName"/>
|
||||||
|
<module name="MemberName"/>
|
||||||
|
<module name="ParameterName"/>
|
||||||
|
<module name="LocalVariableName"/>
|
||||||
|
<module name="ConstantName">
|
||||||
|
<property name="format" value="^log$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="NeedBraces"/>
|
||||||
|
<module name="LeftCurly"/>
|
||||||
|
<module name="RightCurly"/>
|
||||||
|
|
||||||
|
<module name="ModifierOrder"/>
|
||||||
|
<module name="RedundantModifier"/>
|
||||||
|
<module name="EmptyStatement"/>
|
||||||
|
<module name="EqualsHashCode"/>
|
||||||
|
<module name="SimplifyBooleanExpression"/>
|
||||||
|
<module name="SimplifyBooleanReturn"/>
|
||||||
|
<module name="StringLiteralEquality"/>
|
||||||
|
<module name="DefaultComesLast"/>
|
||||||
|
<module name="MultipleVariableDeclarations"/>
|
||||||
|
<module name="OneStatementPerLine"/>
|
||||||
|
<module name="FallThrough"/>
|
||||||
|
<module name="HideUtilityClassConstructor"/>
|
||||||
|
<module name="OneTopLevelClass"/>
|
||||||
|
<module name="UpperEll"/>
|
||||||
|
<module name="ArrayTypeStyle"/>
|
||||||
|
<module name="MissingSwitchDefault"/>
|
||||||
|
<module name="OuterTypeFilename"/>
|
||||||
|
|
||||||
|
<module name="EmptyBlock">
|
||||||
|
<property name="option" value="text"/>
|
||||||
|
</module>
|
||||||
|
<module name="EmptyCatchBlock">
|
||||||
|
<property name="exceptionVariableName" value="expected|ignore"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="EqualsAvoidNull"/>
|
||||||
|
<module name="NoFinalizer"/>
|
||||||
|
<module name="NoClone"/>
|
||||||
|
<module name="PackageDeclaration"/>
|
||||||
|
</module>
|
||||||
|
</module>
|
||||||
0
gradlew
vendored
Normal file → Executable file
0
gradlew
vendored
Normal file → Executable file
|
|
@ -138,8 +138,12 @@ public class ReportCommand implements CommandExecutor, TabCompleter {
|
||||||
String input = args[0].toLowerCase();
|
String input = args[0].toLowerCase();
|
||||||
|
|
||||||
if (sender.hasPermission("lorep.admin")) {
|
if (sender.hasPermission("lorep.admin")) {
|
||||||
if ("gui".startsWith(input)) completions.add("gui");
|
if ("gui".startsWith(input)) {
|
||||||
if ("stats".startsWith(input)) completions.add("stats");
|
completions.add("gui");
|
||||||
|
}
|
||||||
|
if ("stats".startsWith(input)) {
|
||||||
|
completions.add("stats");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add online player names
|
// Add online player names
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,11 @@ package dev.loki.lorep.database;
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
package dev.loki.lorep.database;
|
package dev.loki.lorep.database;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class MessageUtil {
|
public class MessageUtil {
|
||||||
|
|
||||||
|
private MessageUtil() {}
|
||||||
|
|
||||||
private static final String PREFIX = "§8[§clorep§8] §r";
|
private static final String PREFIX = "§8[§clorep§8] §r";
|
||||||
|
|
||||||
public static String colorize(String message) {
|
public static String colorize(String message) {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
package dev.loki.lorep.util;
|
package dev.loki.lorep.util;
|
||||||
|
|
||||||
public class PaginationUtil {
|
public class PaginationUtil {
|
||||||
|
|
||||||
|
private PaginationUtil() {}
|
||||||
|
|
||||||
public static int calculateTotalPages(int totalItems, int pageSize) {
|
public static int calculateTotalPages(int totalItems, int pageSize) {
|
||||||
if (pageSize <= 0) {
|
if (pageSize <= 0) {
|
||||||
throw new IllegalArgumentException("pageSize must be positive");
|
throw new IllegalArgumentException("pageSize must be positive");
|
||||||
}
|
}
|
||||||
if (totalItems <= 0) return 1;
|
if (totalItems <= 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return (int) Math.ceil((double) totalItems / pageSize);
|
return (int) Math.ceil((double) totalItems / pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import java.time.Instant;
|
||||||
|
|
||||||
public class TimeUtil {
|
public class TimeUtil {
|
||||||
|
|
||||||
|
private TimeUtil() {}
|
||||||
|
|
||||||
private static final long SECONDS_PER_MINUTE = 60;
|
private static final long SECONDS_PER_MINUTE = 60;
|
||||||
private static final long MINUTES_PER_HOUR = 60;
|
private static final long MINUTES_PER_HOUR = 60;
|
||||||
private static final long HOURS_PER_DAY = 24;
|
private static final long HOURS_PER_DAY = 24;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
package dev.loki.lorep.webhook;
|
package dev.loki.lorep.webhook;
|
||||||
|
|
||||||
import dev.loki.lorep.database.Report;
|
import dev.loki.lorep.database.Report;
|
||||||
import okhttp3.*;
|
import okhttp3.Call;
|
||||||
|
import okhttp3.Callback;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
|
|
@ -81,7 +87,9 @@ public class DiscordWebhook {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String escapeJson(String text) {
|
private String escapeJson(String text) {
|
||||||
if (text == null) return "";
|
if (text == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
return text
|
return text
|
||||||
.replace("\\", "\\\\")
|
.replace("\\", "\\\\")
|
||||||
.replace("\"", "\\\"")
|
.replace("\"", "\\\"")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue