mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-04 17:00:18 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bd9c51962
|
||
|
|
b3d2ba55d1
|
||
|
|
d1d36fa75a | ||
|
|
8b4cca3bc9 | ||
|
|
c92e752c33 | ||
|
|
5fd3b45fb6 | ||
|
|
8ad167e00e | ||
|
|
f203a5d878 | ||
|
|
27039be7e1 | ||
|
|
751044b085 | ||
|
|
0d4a0e6e37 | ||
|
|
9826b1f2b7 | ||
|
|
786ce322ab | ||
|
|
9a8f722b50 | ||
|
|
bbfd821fde | ||
|
|
0ee698ce4b | ||
|
|
0eeee292c8 | ||
|
|
ae5e3976e7 | ||
|
|
d94ddaf26a | ||
|
|
84104be626 | ||
|
|
548c9278db | ||
|
|
5255161106 | ||
|
|
f21ba94070 | ||
|
|
b4515d69c3 | ||
|
|
ddf431a5d6 | ||
|
|
9dda0b8477 | ||
|
|
becd6cd9fa | ||
|
|
92c6b59224 | ||
|
|
520934ead7 |
No files matched your search
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
+41
-24
@@ -1,29 +1,46 @@
|
||||
# Maven
|
||||
/target/
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# IntelliJ IDEA
|
||||
/.idea/
|
||||
*.iml
|
||||
*.iws
|
||||
*.ipr
|
||||
|
||||
# Eclipse
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings/
|
||||
|
||||
# VS Code
|
||||
/.vscode/
|
||||
|
||||
# Local environment and logs
|
||||
.env
|
||||
.env.*
|
||||
# Log file
|
||||
*.log
|
||||
*.tmp
|
||||
|
||||
# OS files
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
# macOS system files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Maven Shade Plugin
|
||||
dependency-reduced-pom.xml
|
||||
# gradle build output files
|
||||
build/
|
||||
.gradle/
|
||||
|
||||
# eclipse project files
|
||||
.settings/
|
||||
.project
|
||||
.classpath
|
||||
.checkstyle
|
||||
bin/
|
||||
|
||||
# IntelliJ files
|
||||
.idea/
|
||||
.kotlin
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
out/
|
||||
@@ -0,0 +1,140 @@
|
||||
/* ------------------------------ Plugins ------------------------------ */
|
||||
plugins {
|
||||
id("java") // Import Java plugin.
|
||||
id("java-library") // Import Java Library plugin.
|
||||
id("com.diffplug.spotless") version "8.1.0" // Import Spotless plugin.
|
||||
id("com.gradleup.shadow") version "8.3.9" // Import Shadow plugin.
|
||||
id("checkstyle") // Import Checkstyle plugin.
|
||||
eclipse
|
||||
}
|
||||
|
||||
/* --------------------------- JDK / Kotlin ---------------------------- */
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
|
||||
toolchain { // Select Java toolchain.
|
||||
languageVersion.set(JavaLanguageVersion.of(17)) // Use JDK 17.
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------- Metadata ------------------------------ */
|
||||
group = "de.rayzs.pat" // Declare bundle identifier.
|
||||
|
||||
version = "2.3.2" // Declare plugin version (will be in .jar).
|
||||
|
||||
val apiVersion = "1.13" // Declare minecraft server target version.
|
||||
|
||||
/* ----------------------------- Resources ----------------------------- */
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
exclude("**/*.txt") // Exclude text files from the jar (matches the original Maven build).
|
||||
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
|
||||
}
|
||||
|
||||
/* ---------------------------- Repos ---------------------------------- */
|
||||
repositories {
|
||||
mavenCentral() // Import the Maven Central Maven Repository.
|
||||
gradlePluginPortal() // Import the Gradle Plugin Portal Maven Repository.
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") } // Spigot.
|
||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } // Sonatype (BungeeCord).
|
||||
maven { url = uri("https://repo.papermc.io/repository/maven-public/") } // PaperMC.
|
||||
maven { url = uri("https://jitpack.io") } // JitPack.
|
||||
maven { url = uri("https://repo.velocitypowered.com/snapshots/") } // Velocity.
|
||||
maven { url = uri("https://libraries.minecraft.net/") } // Minecraft Libraries.
|
||||
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") } // PlaceholderAPI.
|
||||
maven { url = uri("https://repo.viaversion.com") } // ViaVersion.
|
||||
maven { url = uri("https://repo.william278.net/velocity") } // William278 (Velocity).
|
||||
maven { url = uri("https://repo.william278.net/papiproxybridge") } // William278 (PAPIProxyBridge).
|
||||
mavenLocal() // Import the local Maven Repository.
|
||||
}
|
||||
|
||||
/* ---------------------- Java project deps ---------------------------- */
|
||||
dependencies {
|
||||
// Platform / API dependencies (provided at runtime, not shaded).
|
||||
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
|
||||
compileOnly("org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT")
|
||||
compileOnly("io.netty:netty-all:4.2.0.Final")
|
||||
compileOnly("net.md-5:bungeecord-api:1.21-R0.5-SNAPSHOT")
|
||||
compileOnly("net.md-5:bungeecord-protocol:1.16-R0.4")
|
||||
compileOnly("com.mojang:authlib:4.0.43")
|
||||
compileOnly("com.github.ElgarL:groupmanager:3.2")
|
||||
compileOnly("com.mojang:brigadier:1.1.8")
|
||||
compileOnly("com.mojang:datafixerupper:6.0.8")
|
||||
compileOnly("com.mojang:logging:1.1.1")
|
||||
compileOnly("org.apache.maven:maven-resolver-provider:3.8.5")
|
||||
compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3")
|
||||
compileOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3")
|
||||
compileOnly("org.apache.logging.log4j:log4j-core:2.18.0")
|
||||
compileOnly("io.github.waterfallmc:waterfall-api:1.20-R0.3-SNAPSHOT")
|
||||
compileOnly("net.william278:papiproxybridge:1.4")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
|
||||
compileOnly("com.velocitypowered:velocity-proxy:3.3.0-SNAPSHOT") {
|
||||
exclude(group = "com.velocitypowered", module = "velocity-proxy-log4j2-plugin")
|
||||
}
|
||||
compileOnly("org.sonatype.sisu:sisu-guice:2.1.7")
|
||||
compileOnly("org.spongepowered:configurate-hocon:4.1.2")
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
compileOnly("net.luckperms:api:5.5")
|
||||
compileOnly("com.viaversion:viaversion-api:5.7.0-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.17-R0.1-SNAPSHOT")
|
||||
|
||||
// Generate velocity-plugin.json from the @Plugin annotation.
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
|
||||
|
||||
// Adventure (shaded into the jar).
|
||||
implementation("net.kyori:adventure-text-minimessage:4.26.1")
|
||||
implementation("net.kyori:adventure-api:4.26.1")
|
||||
implementation("net.kyori:adventure-platform-api:4.4.1")
|
||||
implementation("net.kyori:adventure-platform-bungeecord:4.4.1")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.4.1")
|
||||
}
|
||||
|
||||
/* ---------------------- Reproducible jars ---------------------------- */
|
||||
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
|
||||
isPreserveFileTimestamps = false
|
||||
isReproducibleFileOrder = true
|
||||
}
|
||||
|
||||
/* ----------------------------- Shadow -------------------------------- */
|
||||
tasks.shadowJar {
|
||||
archiveFileName.set("ProAntiTab.jar") // Match the original Maven finalName.
|
||||
relocate("net.kyori", "de.rayzs.pat.libs.kyori") // Isolate shaded Adventure from the server's bundled copy.
|
||||
}
|
||||
|
||||
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
|
||||
|
||||
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) } // Build depends on spotless and shadow.
|
||||
|
||||
/* --------------------------- Javac opts ------------------------------- */
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-parameters") // Enable reflection for java code.
|
||||
options.isFork = true // Run javac in its own process.
|
||||
options.compilerArgs.add("-Xlint:deprecation") // Trigger deprecation warning messages.
|
||||
options.encoding = "UTF-8" // Use UTF-8 file encoding.
|
||||
}
|
||||
|
||||
/* ----------------------------- Auto Formatting ------------------------ */
|
||||
spotless {
|
||||
java {
|
||||
eclipse().configFile("config/formatter/eclipse-java-formatter.xml") // Eclipse java formatting.
|
||||
leadingTabsToSpaces() // Convert leftover leading tabs to spaces.
|
||||
removeUnusedImports() // Remove imports that aren't being called.
|
||||
}
|
||||
kotlinGradle {
|
||||
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
|
||||
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.18.1" // Declare checkstyle version to use.
|
||||
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
|
||||
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
|
||||
isShowViolations = true // Show the violations in any IDE with the checkstyle plugin.
|
||||
}
|
||||
|
||||
tasks.named("compileJava") {
|
||||
dependsOn("spotlessApply") // Run spotless before compiling with the JDK.
|
||||
}
|
||||
|
||||
tasks.named("spotlessCheck") {
|
||||
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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">
|
||||
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="FinalLocalVariable"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="Indentation">
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\borg\.junit\.jupiter\.api\.Assertions\.fail\s*\(\s*"Not yet implemented"\s*\)\s*;"/>
|
||||
<property name="message" value="Remove placeholder fail() and implement the test."/>
|
||||
<property name="ignoreCase" value="true"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="(?<!\w)fail\s*\(\s*"Not yet implemented"\s*\)\s*;"/>
|
||||
<property name="message" value="Remove placeholder fail() and implement the test."/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,404 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<profiles version="23">
|
||||
<profile kind="CodeFormatterProfile" name="TrueOG Network Formatting" version="23">
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_not_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case_after_arrow" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_arrows_in_switch_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow" value="20"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
</profile>
|
||||
</profiles>
|
||||
Vendored
BIN
Binary file not shown.
+7
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,220 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>2.5.1</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.helpch.at/releases/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>velocity</id>
|
||||
<url>https://repo.velocitypowered.com/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>minecraft-libraries</id>
|
||||
<name>Minecraft Libraries</name>
|
||||
<url>https://libraries.minecraft.net/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>viaversion-repo</id>
|
||||
<url>https://repo.viaversion.com</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>william278-velocity</id>
|
||||
<name>William278</name>
|
||||
<url>https://repo.william278.net/velocity</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>william278-papiproxybridge</id>
|
||||
<name>William278</name>
|
||||
<url>https://repo.william278.net/papiproxybridge</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>central-snapshots</id>
|
||||
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>AlessioDP</id>
|
||||
<url>https://repo.alessiodp.com/releases/</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.21.11-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.waterfallmc</groupId>
|
||||
<artifactId>waterfall-api</artifactId>
|
||||
<version>1.20-R0.3-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-proxy</artifactId>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-proxy-log4j2-plugin</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bungeecord</artifactId>
|
||||
<version>4.4.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.4.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||
<version>5.2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.2.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.11.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- PLUGIN COMPATIBILITIES -->
|
||||
|
||||
|
||||
<!-- Permission plugins -->
|
||||
|
||||
<dependency>
|
||||
<groupId>net.luckperms</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>5.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.ElgarL</groupId>
|
||||
<artifactId>groupmanager</artifactId>
|
||||
<version>3.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- PAPI -->
|
||||
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.william278</groupId>
|
||||
<artifactId>papiproxybridge</artifactId>
|
||||
<version>1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Extras -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>5.7.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1 @@
|
||||
rootProject.name = "ProAntiTab"
|
||||
@@ -0,0 +1,56 @@
|
||||
package de.rayzs.pat.api.brand;
|
||||
|
||||
import de.rayzs.pat.api.brand.impl.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
public class CustomServerBrand {
|
||||
|
||||
public static final String CHANNEL_NAME = Reflection.isBefore(1, 13) ? "MC|Brand" : "minecraft:brand";
|
||||
private static final ServerBrand SERVER_BRAND = Reflection.isVelocityServer() ? new VelocityServerBrand()
|
||||
: Reflection.isProxyServer() ? new BungeeServerBrand() : new BukkitServerBrand();
|
||||
|
||||
public static void initialize() {
|
||||
|
||||
refreshTask();
|
||||
|
||||
}
|
||||
|
||||
public static void refreshTask() {
|
||||
|
||||
SERVER_BRAND.initializeTask();
|
||||
|
||||
}
|
||||
|
||||
public static void preparePlayer(Object playerObj) {
|
||||
|
||||
SERVER_BRAND.preparePlayer(playerObj);
|
||||
|
||||
}
|
||||
|
||||
public static void sendBrandToPlayer(Object playerObj) {
|
||||
|
||||
SERVER_BRAND.send(playerObj);
|
||||
|
||||
}
|
||||
|
||||
public static PacketUtils.BrandManipulate createBrandPacket(Object playerObj) {
|
||||
|
||||
return SERVER_BRAND.createPacket(playerObj);
|
||||
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
|
||||
return Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isBrandTag(String tag) {
|
||||
|
||||
return tag.equals("MC|Brand") || tag.equals("minecraft:brand");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+2
-4
@@ -1,14 +1,12 @@
|
||||
package de.rayzs.pat.plugin.system.serverbrand;
|
||||
package de.rayzs.pat.api.brand;
|
||||
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
|
||||
public interface ServerBrand {
|
||||
|
||||
void initializeTask();
|
||||
|
||||
void preparePlayer(Object playerObj);
|
||||
void send(Object playerObj);
|
||||
|
||||
PacketUtils.BrandManipulate createPacket(Object playerObj);
|
||||
void initializeTask();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package de.rayzs.pat.api.brand.impl;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.brand.ServerBrand;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
|
||||
import io.netty.channel.Channel;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.lang.reflect.*;
|
||||
import org.bukkit.*;
|
||||
import java.util.*;
|
||||
|
||||
public class BukkitServerBrand implements ServerBrand {
|
||||
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
private static PATSchedulerTask TASK;
|
||||
private static boolean INITIALIZED = false, NO_PREP_CHANNELS = false;
|
||||
private static Class<?> brandPayloadClass, clientBoundCustomPacketPayloadPacketClass,
|
||||
customPacketPayloadPacketClass;
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
|
||||
if (Reflection.isWeird()) {
|
||||
|
||||
NO_PREP_CHANNELS = Reflection.isAtLeast(1, 21, 7);
|
||||
|
||||
if (brandPayloadClass == null)
|
||||
brandPayloadClass = Reflection.getClass("net.minecraft.network.protocol.common.custom.BrandPayload");
|
||||
|
||||
if (clientBoundCustomPacketPayloadPacketClass == null)
|
||||
clientBoundCustomPacketPayloadPacketClass = Reflection
|
||||
.getClass("net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket");
|
||||
|
||||
if (customPacketPayloadPacketClass == null)
|
||||
customPacketPayloadPacketClass = Reflection
|
||||
.getClass("net.minecraft.network.protocol.common.custom.CustomPacketPayload");
|
||||
|
||||
}
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(this::preparePlayer);
|
||||
if (!INITIALIZED)
|
||||
try {
|
||||
|
||||
Method method = Reflection.getMethodsByParameterAndName(SERVER.getMessenger(), "addToOutgoing",
|
||||
Plugin.class, String.class).get(0);
|
||||
Reflection.invokeMethode(method, SERVER.getMessenger(), BukkitLoader.getPlugin(),
|
||||
CustomServerBrand.CHANNEL_NAME);
|
||||
SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(),
|
||||
CustomServerBrand.CHANNEL_NAME);
|
||||
INITIALIZED = true;
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
if (TASK != null && TASK.isActive()) {
|
||||
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED)
|
||||
return;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0) + "§r";
|
||||
|
||||
PATScheduler.createAsyncScheduler(() -> {
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(this::send);
|
||||
|
||||
}, 1, 1);
|
||||
|
||||
} else {
|
||||
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = PATScheduler.createAsyncScheduler(() -> {
|
||||
|
||||
if (animationState
|
||||
.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get()) + "§r";
|
||||
Bukkit.getOnlinePlayers().forEach(this::send);
|
||||
|
||||
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Object playerObj) {
|
||||
|
||||
if (!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED)
|
||||
return;
|
||||
Player player = (Player) playerObj;
|
||||
|
||||
if (NO_PREP_CHANNELS) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Field channelsField = Reflection.getFieldByName(player.getClass(), "channels");
|
||||
Set<String> channels = (Set<String>) channelsField.get(player);
|
||||
channels.add(CustomServerBrand.CHANNEL_NAME);
|
||||
Reflection.closeAccess(channelsField);
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object playerObj) {
|
||||
|
||||
if (!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED)
|
||||
return;
|
||||
Player player = (Player) playerObj;
|
||||
String playerName = player.getName(), displayName = player.getDisplayName(),
|
||||
worldName = player.getWorld().getName(), customBrand = BRAND.replace("%player%", playerName)
|
||||
.replace("%displayname%", displayName).replace("%world%", worldName);
|
||||
|
||||
if (!Reflection.isWeird()) {
|
||||
|
||||
PacketUtils.BrandManipulate serverBrand = new PacketUtils.BrandManipulate(
|
||||
MessageTranslator.replaceMessage(player, customBrand));
|
||||
player.sendPluginMessage(BukkitLoader.getPlugin(), CustomServerBrand.CHANNEL_NAME, serverBrand.getBytes());
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Channel channel = BukkitPacketAnalyzer.INJECTED_PLAYERS.get(player.getUniqueId());
|
||||
if (channel == null)
|
||||
return;
|
||||
|
||||
Object brandPayloadObj = brandPayloadClass.getDeclaredConstructor(String.class)
|
||||
.newInstance(MessageTranslator.replaceMessage(player, customBrand)),
|
||||
customPacketPayloadPacket = clientBoundCustomPacketPayloadPacketClass
|
||||
.getDeclaredConstructor(customPacketPayloadPacketClass).newInstance(brandPayloadObj);
|
||||
|
||||
channel.pipeline().writeAndFlush(customPacketPayloadPacket);
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package de.rayzs.pat.api.brand.impl;
|
||||
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.brand.ServerBrand;
|
||||
import net.md_5.bungee.api.connection.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BungeeServerBrand implements ServerBrand {
|
||||
|
||||
private static final ProxyServer SERVER = BungeeLoader.getPlugin().getProxy();
|
||||
private static ScheduledTask TASK;
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
|
||||
public BungeeServerBrand() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
|
||||
if (TASK != null)
|
||||
TASK.cancel();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED)
|
||||
return;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
|
||||
BRAND = MessageTranslator
|
||||
.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0)) + "§r";
|
||||
SERVER.getPlayers().forEach(this::send);
|
||||
|
||||
} else {
|
||||
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = SERVER.getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
|
||||
if (animationState
|
||||
.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = MessageTranslator.replaceMessage(
|
||||
Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get()))
|
||||
+ "§r";
|
||||
SERVER.getPlayers().forEach(this::send);
|
||||
|
||||
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY, TimeUnit.MILLISECONDS);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Object playerObj) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object playerObj) {
|
||||
|
||||
if (!(playerObj instanceof ProxiedPlayer) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED)
|
||||
return;
|
||||
ProxiedPlayer player = (ProxiedPlayer) playerObj;
|
||||
|
||||
String serverName = "", playerName = player.getName(), customBrand;
|
||||
Server server = player.getServer();
|
||||
if (server != null)
|
||||
serverName = server.getInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName);
|
||||
|
||||
PacketUtils.BrandManipulate serverBrand = new PacketUtils.BrandManipulate(customBrand);
|
||||
String brand = player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13
|
||||
? "minecraft:brand"
|
||||
: "MC|Brand";
|
||||
player.sendData(brand, serverBrand.getBytes());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
|
||||
if (!(playerObj instanceof ProxiedPlayer) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED)
|
||||
return null;
|
||||
ProxiedPlayer player = (ProxiedPlayer) playerObj;
|
||||
|
||||
String serverName = "", playerName = player.getName(), customBrand;
|
||||
Server server = player.getServer();
|
||||
if (server != null)
|
||||
serverName = server.getInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName);
|
||||
|
||||
return new PacketUtils.BrandManipulate(customBrand);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package de.rayzs.pat.api.brand.impl;
|
||||
|
||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.brand.ServerBrand;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.lang.reflect.Method;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.Optional;
|
||||
|
||||
public class VelocityServerBrand implements ServerBrand {
|
||||
|
||||
private static final ProxyServer SERVER = VelocityLoader.getServer();
|
||||
private static Class<?> pluginMessagePacketClass, minecraftConnectionClass, connectedPlayerConnectionClass;
|
||||
private static Method connectionMethod;
|
||||
private static ScheduledTask TASK;
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
|
||||
if (TASK != null)
|
||||
TASK.cancel();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED)
|
||||
return;
|
||||
|
||||
if (pluginMessagePacketClass == null)
|
||||
pluginMessagePacketClass = Reflection
|
||||
.getClass("com.velocitypowered.proxy.protocol.packet.PluginMessagePacket");
|
||||
|
||||
if (minecraftConnectionClass == null)
|
||||
minecraftConnectionClass = Reflection.getClass("com.velocitypowered.proxy.connection.MinecraftConnection");
|
||||
|
||||
if (connectedPlayerConnectionClass == null)
|
||||
connectedPlayerConnectionClass = Reflection
|
||||
.getClass("com.velocitypowered.proxy.connection.client.ConnectedPlayer");
|
||||
|
||||
if (connectionMethod == null)
|
||||
connectionMethod = Reflection.getMethodByName(connectedPlayerConnectionClass, "getConnection");
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
|
||||
BRAND = MessageTranslator
|
||||
.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0)) + "§r";
|
||||
SERVER.getAllPlayers().forEach(this::send);
|
||||
|
||||
} else {
|
||||
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = SERVER.getScheduler().buildTask(VelocityLoader.getInstance(), () -> {
|
||||
|
||||
if (animationState
|
||||
.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = MessageTranslator.replaceMessage(
|
||||
Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get()))
|
||||
+ "§r";
|
||||
SERVER.getAllPlayers().forEach(this::send);
|
||||
|
||||
}).repeat(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY, TimeUnit.MILLISECONDS).schedule();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Object playerObj) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object playerObj) {
|
||||
|
||||
if (!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED)
|
||||
return;
|
||||
|
||||
try {
|
||||
|
||||
Player player = (Player) playerObj;
|
||||
Object connectedPlayerObj = connectedPlayerConnectionClass.cast(player),
|
||||
minecraftConnectionObj = connectionMethod.invoke(connectedPlayerObj);
|
||||
|
||||
String serverName = "", playerName = player.getUsername(), customBrand;
|
||||
Optional<ServerConnection> serverConnection = player.getCurrentServer();
|
||||
if (serverConnection.isPresent())
|
||||
serverName = serverConnection.get().getServerInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName).replace("%ping%",
|
||||
String.valueOf(player.getPing()));
|
||||
|
||||
PacketUtils.BrandManipulate serverBrand = new PacketUtils.BrandManipulate(customBrand, false);
|
||||
String brand = player.getProtocolVersion().getProtocol() >= ProtocolConstants.MINECRAFT_1_13
|
||||
? "minecraft:brand"
|
||||
: "MC|Brand";
|
||||
Object pluginMessagePacket = pluginMessagePacketClass.getConstructor(String.class, ByteBuf.class)
|
||||
.newInstance(brand, serverBrand.getByteBuf());
|
||||
Reflection.getMethodsByParameterAndName(minecraftConnectionObj, "write", Object.class).get(0)
|
||||
.invoke(minecraftConnectionObj, pluginMessagePacket);
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
|
||||
if (!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED)
|
||||
return null;
|
||||
|
||||
try {
|
||||
|
||||
Player player = (Player) playerObj;
|
||||
|
||||
String serverName = "", playerName = player.getUsername(), customBrand;
|
||||
Optional<ServerConnection> serverConnection = player.getCurrentServer();
|
||||
|
||||
if (serverConnection.isPresent())
|
||||
serverName = serverConnection.get().getServerInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName).replace("%ping%",
|
||||
String.valueOf(player.getPing()));
|
||||
|
||||
return new PacketUtils.BrandManipulate(customBrand, false);
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+15
-2
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.plugin.command.commands;
|
||||
package de.rayzs.pat.api.command;
|
||||
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
@@ -10,38 +10,51 @@ public abstract class ProCommand {
|
||||
private final String name;
|
||||
private final List<String> aliases;
|
||||
|
||||
protected boolean proxyOnly = false, serverCommand = false;
|
||||
protected boolean proxyOnly = false, serverCommand = false;
|
||||
|
||||
public ProCommand(String name, String... aliases) {
|
||||
|
||||
this.name = name.toLowerCase();
|
||||
this.aliases = aliases != null && !aliases[0].isBlank() ? Arrays.asList(aliases) : new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
return name;
|
||||
|
||||
}
|
||||
|
||||
public boolean isProxyOnly() {
|
||||
|
||||
return proxyOnly;
|
||||
|
||||
}
|
||||
|
||||
public boolean isServerCommand() {
|
||||
|
||||
return serverCommand;
|
||||
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
|
||||
return aliases;
|
||||
|
||||
}
|
||||
|
||||
public boolean isCommand(String label) {
|
||||
|
||||
String commandName = StringUtils.getFirstArg(label);
|
||||
|
||||
if (name.equalsIgnoreCase(commandName))
|
||||
return true;
|
||||
|
||||
return !aliases.isEmpty() && aliases.stream().anyMatch(commandName::equalsIgnoreCase);
|
||||
|
||||
}
|
||||
|
||||
public abstract boolean execute(CommandSender sender, String[] args);
|
||||
public abstract List<String> tabComplete(CommandSender sender, String[] args);
|
||||
|
||||
}
|
||||
+48
-43
@@ -1,128 +1,133 @@
|
||||
package de.rayzs.pat.plugin.system.communication;
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.scheduler.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BackendUpdater {
|
||||
|
||||
/**
|
||||
*
|
||||
* I wasn't sure how to call this class, but this class is mainly only
|
||||
* for managing whether PAT is still connected to the proxy or not.
|
||||
* It sends a keep-alive packet and if it doesn't get a response once
|
||||
* the next iteration of the scheduler starts, it will consider itself
|
||||
* 'desynchronized' and sends an IdentityRequest packet to the proxy instead,
|
||||
* restarting the whole process until it gets into a stable connection once more.
|
||||
*
|
||||
*/
|
||||
private BackendUpdater() {
|
||||
|
||||
public static BackendUpdater instance;
|
||||
|
||||
public static void initialize() {
|
||||
if (instance != null) {
|
||||
Logger.warning("BackendUpdater already initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
instance = new BackendUpdater();
|
||||
}
|
||||
|
||||
public static BackendUpdater get() {
|
||||
return instance;
|
||||
}
|
||||
private static PATSchedulerTask TASK;
|
||||
private static boolean CONNECTED = false, WAITING = false;
|
||||
|
||||
private static final long SCHEDULER_PERIOD_TIME = 20 * 10;
|
||||
|
||||
private BackendUpdater() {}
|
||||
public static void handle() {
|
||||
|
||||
|
||||
private PATSchedulerTask TASK;
|
||||
private boolean CONNECTED = false,
|
||||
WAITING = false;
|
||||
|
||||
private final long SCHEDULER_PERIOD_TIME = 20 * 10;
|
||||
|
||||
public void handle() {
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (isRunning() || !canRun()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
start();
|
||||
|
||||
}
|
||||
|
||||
public void restart() {
|
||||
public static void restart() {
|
||||
|
||||
stop();
|
||||
handle();
|
||||
|
||||
}
|
||||
|
||||
public void receivedKeepAlivePacket() {
|
||||
public static void receivedKeepAlivePacket() {
|
||||
|
||||
WAITING = false;
|
||||
CONNECTED = true;
|
||||
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
public static boolean isConnected() {
|
||||
|
||||
return CONNECTED;
|
||||
|
||||
}
|
||||
|
||||
private void start() {
|
||||
if (isRunning()) return;
|
||||
private static void start() {
|
||||
|
||||
if (isRunning())
|
||||
return;
|
||||
|
||||
TASK = PATScheduler.createScheduler(() -> {
|
||||
|
||||
if (!canRun()) {
|
||||
|
||||
stop();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (CONNECTED) {
|
||||
|
||||
if (WAITING) {
|
||||
|
||||
disconnect();
|
||||
|
||||
Communicator.Backend2Proxy.sendIdentityRequest();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
WAITING = true;
|
||||
|
||||
Communicator.Backend2Proxy.sendKeepAliveRequest();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Communicator.Backend2Proxy.sendIdentityRequest();
|
||||
|
||||
}, 20, SCHEDULER_PERIOD_TIME);
|
||||
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
public static void stop() {
|
||||
|
||||
disconnect();
|
||||
|
||||
if (isRunning()) {
|
||||
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void disconnect() {
|
||||
private static void disconnect() {
|
||||
|
||||
CONNECTED = false;
|
||||
WAITING = false;
|
||||
|
||||
}
|
||||
|
||||
private boolean isRunning() {
|
||||
private static boolean isRunning() {
|
||||
|
||||
return TASK != null && TASK.isActive();
|
||||
|
||||
}
|
||||
|
||||
private boolean canRun() {
|
||||
private static boolean canRun() {
|
||||
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
final int onlinePlayerSize = Bukkit.getOnlinePlayers().size();
|
||||
return onlinePlayerSize >= 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+5
-2
@@ -1,9 +1,12 @@
|
||||
package de.rayzs.pat.plugin.system.communication.pmc;
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
|
||||
public interface PluginMessageClient {
|
||||
public interface Client {
|
||||
|
||||
String CHANNEL_NAME = "pat:channel";
|
||||
|
||||
void reload();
|
||||
void send(CommunicationPackets.PATPacket packet);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,439 @@
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.client.impl.BungeeClientInfo;
|
||||
import de.rayzs.pat.api.communication.client.impl.VelocityClientInfo;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
public class Communicator {
|
||||
|
||||
private static Communicator instance = null;
|
||||
|
||||
public static void initialize(final Client client) {
|
||||
|
||||
if (instance != null) {
|
||||
|
||||
Logger.warning("Communicator instance is already initialized!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
instance = new Communicator(client);
|
||||
|
||||
}
|
||||
|
||||
public static Communicator get() {
|
||||
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
public static class Backend2Proxy {
|
||||
|
||||
private Backend2Proxy() {
|
||||
|
||||
}
|
||||
|
||||
public static void sendIdentityRequest() {
|
||||
|
||||
get().send2Proxy(new CommunicationPackets.Backend2Proxy.IdentityRequestPacket(get().getId()));
|
||||
|
||||
}
|
||||
|
||||
public static void sendKeepAliveRequest() {
|
||||
|
||||
get().send2Proxy(new CommunicationPackets.Backend2Proxy.KeepAlivePacket());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Proxy2Backend {
|
||||
|
||||
private Proxy2Backend() {
|
||||
|
||||
}
|
||||
|
||||
// Update commands for all players
|
||||
public static void sendUpdateCommand() {
|
||||
|
||||
get().send2AllClients(new CommunicationPackets.Proxy2Backend.UpdatePacket(null));
|
||||
|
||||
}
|
||||
|
||||
// Update commands for a certain player.
|
||||
public static void sendUpdateCommand(UUID playerId, String serverName) {
|
||||
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null)
|
||||
return;
|
||||
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.UpdatePacket(playerId));
|
||||
|
||||
}
|
||||
|
||||
public static void sendDataSync() {
|
||||
|
||||
Communicator.get().lastSync = System.currentTimeMillis();
|
||||
|
||||
Communicator.get().send2AllClients(Communicator.get().constructDataSyncPacket());
|
||||
|
||||
}
|
||||
|
||||
// Sync data for one server
|
||||
public static void sendDataSync(String serverName) {
|
||||
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null)
|
||||
return;
|
||||
|
||||
clientInfo.send(Communicator.get().constructDataSyncPacket());
|
||||
|
||||
}
|
||||
|
||||
// Sync data for all registered clients.
|
||||
public static void sendConsoleMessage(String serverName, String message) {
|
||||
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null)
|
||||
return;
|
||||
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.ConsoleMessagePacket(message));
|
||||
|
||||
}
|
||||
|
||||
public static void sendExecutePlayerCommand(String serverName, UUID playerId, String command) {
|
||||
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null)
|
||||
return;
|
||||
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.ExecutePlayerCommandPacket(playerId, command));
|
||||
|
||||
}
|
||||
|
||||
public static void sendExecuteConsoleCommand(String serverName, String command) {
|
||||
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null)
|
||||
return;
|
||||
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.ExecuteConsoleCommandPacket(command));
|
||||
|
||||
}
|
||||
|
||||
public static void sendNotification(UUID playerId, String serverName, String command) {
|
||||
|
||||
if (!Storage.ConfigSections.Settings.FORWARD_CONSOLE_NOTIFICATIONS.ENABLED) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final ClientInfo clientInfo = get().clients.get(serverName);
|
||||
if (clientInfo == null)
|
||||
return;
|
||||
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.NotificationPacket(playerId, command));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final Client client;
|
||||
private final UUID id = UUID.randomUUID();
|
||||
|
||||
// Server name, ClientInfo
|
||||
private final Map<String, ClientInfo> clients = new HashMap<>();
|
||||
private final ExpireCache<String, ClientInfo> pendingClients = new ExpireCache<>(2, TimeUnit.SECONDS);
|
||||
|
||||
private long lastReceivedKeepAliveResponse = System.currentTimeMillis();
|
||||
private long lastSync = System.currentTimeMillis();
|
||||
|
||||
private Communicator(final Client client) {
|
||||
|
||||
this.client = client;
|
||||
|
||||
}
|
||||
|
||||
// BACKEND -> PROXY
|
||||
public void handleB2PPacket(String serverName, CommunicationPackets.PATPacket incomingPacket) {
|
||||
|
||||
if (!incomingPacket.tokenMatches(Storage.TOKEN)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.KeepAlivePacket packet) {
|
||||
|
||||
final ClientInfo clientInfo = clients.get(serverName);
|
||||
if (clientInfo == null)
|
||||
return;
|
||||
|
||||
clientInfo.updateKeepAliveTime();
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.IdentityRequestPacket packet) {
|
||||
|
||||
final ClientInfo registeredClientInfo = clients.get(serverName);
|
||||
|
||||
final boolean exist = registeredClientInfo != null;
|
||||
final boolean same = exist && registeredClientInfo.getId().equals(packet.serverId());
|
||||
|
||||
if (!same) {
|
||||
|
||||
final ClientInfo clientInfo = Reflection.isVelocityServer()
|
||||
? new VelocityClientInfo(packet.serverId(), serverName)
|
||||
: new BungeeClientInfo(packet.serverId(), serverName);
|
||||
|
||||
pendingClients.put(serverName, clientInfo);
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.IdentityPacket(packet.serverId(), serverName));
|
||||
|
||||
} else {
|
||||
|
||||
registeredClientInfo.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
|
||||
registeredClientInfo
|
||||
.send(new CommunicationPackets.Proxy2Backend.IdentityPacket(packet.serverId(), serverName));
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.IdentityResponsePacket packet) {
|
||||
|
||||
final ClientInfo clientInfo = pendingClients.get(serverName);
|
||||
|
||||
if (clientInfo != null && clientInfo.getId().equals(packet.serverId())) {
|
||||
|
||||
clientInfo.setId(packet.serverId());
|
||||
|
||||
pendingClients.remove(serverName);
|
||||
clients.put(serverName, clientInfo);
|
||||
|
||||
clientInfo.send(new CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket());
|
||||
clientInfo.send(constructDataSyncPacket());
|
||||
|
||||
clientInfo.updateSyncTime();
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Backend2Proxy.DataSyncReceivedPacket packet) {
|
||||
|
||||
final ClientInfo clientInfo = clients.get(serverName);
|
||||
if (clientInfo == null)
|
||||
return;
|
||||
|
||||
clientInfo.updateSyncTime();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// PROXY -> BACKEND
|
||||
public void handleP2BPacket(CommunicationPackets.PATPacket incomingPacket) {
|
||||
|
||||
if (!incomingPacket.tokenMatches(Storage.TOKEN)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.KeepAliveResponsePacket packet) {
|
||||
|
||||
lastReceivedKeepAliveResponse = System.currentTimeMillis();
|
||||
BackendUpdater.receivedKeepAlivePacket();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.IdentityPacket packet) {
|
||||
|
||||
Storage.SERVER_NAME = packet.serverName();
|
||||
|
||||
send2Proxy(new CommunicationPackets.Backend2Proxy.IdentityResponsePacket(id));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.DataSyncPacket packet) {
|
||||
|
||||
lastSync = System.currentTimeMillis();
|
||||
|
||||
send2Proxy(new CommunicationPackets.Backend2Proxy.DataSyncReceivedPacket());
|
||||
BukkitLoader.handleDataSyncPacket(packet);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.UpdatePacket packet) {
|
||||
|
||||
BukkitLoader.handleUpdateCommandsPacket(packet);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.NotificationPacket packet) {
|
||||
|
||||
BukkitLoader.handleNotificationPacket(packet);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.ConsoleMessagePacket packet) {
|
||||
|
||||
BukkitLoader.handleConsoleMessagePacket(packet);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.ExecutePlayerCommandPacket packet) {
|
||||
|
||||
BukkitLoader.handlePlayerExecuteCommandPacket(packet);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (incomingPacket instanceof CommunicationPackets.Proxy2Backend.ExecuteConsoleCommandPacket packet) {
|
||||
|
||||
BukkitLoader.handleConsoleExecuteCommandPacket(packet);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void send2Proxy(CommunicationPackets.PATPacket packet) {
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
|
||||
Logger.warning("Cannot send B2P packet as proxy!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
client.send(packet);
|
||||
|
||||
}
|
||||
|
||||
private void send2Client(ClientInfo clientInfo, CommunicationPackets.PATPacket packet) {
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
|
||||
Logger.warning("Cannot send P2B packet as backend!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (clientInfo == null || Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
clientInfo.send(packet);
|
||||
|
||||
}
|
||||
|
||||
private void send2AllClients(CommunicationPackets.PATPacket packet) {
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
|
||||
Logger.warning("Cannot send P2B packet as backend!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
getClients().forEach(clientInfo -> {
|
||||
|
||||
clientInfo.send(packet);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private CommunicationPackets.Proxy2Backend.DataSyncPacket constructDataSyncPacket() {
|
||||
|
||||
return new CommunicationPackets.Proxy2Backend.DataSyncPacket(
|
||||
new CommunicationPackets.Proxy2Backend.DataSyncPacket.Messages(
|
||||
Storage.ConfigSections.Messages.PREFIX.PREFIX),
|
||||
new CommunicationPackets.Proxy2Backend.DataSyncPacket.AutoLowerCase(
|
||||
Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.ENABLED),
|
||||
new CommunicationPackets.Proxy2Backend.DataSyncPacket.UnknownCommand(
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED,
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE));
|
||||
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
|
||||
this.client.reload();
|
||||
|
||||
}
|
||||
|
||||
public UUID getClientId(String serverName) {
|
||||
|
||||
final ClientInfo clientInfo = clients.get(serverName);
|
||||
if (clientInfo == null)
|
||||
return null;
|
||||
|
||||
return clientInfo.getId();
|
||||
|
||||
}
|
||||
|
||||
public boolean hasConnectedClients() {
|
||||
|
||||
return !clients.isEmpty();
|
||||
|
||||
}
|
||||
|
||||
public Set<ClientInfo> getClients() {
|
||||
|
||||
return new HashSet<>(clients.values());
|
||||
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
public long getLastReceivedKeepAliveResponse() {
|
||||
|
||||
return lastReceivedKeepAliveResponse;
|
||||
|
||||
}
|
||||
|
||||
public long getLastSync() {
|
||||
|
||||
return lastSync;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+35
-5
@@ -1,54 +1,84 @@
|
||||
package de.rayzs.pat.plugin.system.communication.client;
|
||||
package de.rayzs.pat.api.communication.client;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.TimeConverter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class Client {
|
||||
public abstract class ClientInfo {
|
||||
|
||||
private UUID id;
|
||||
private String serverName;
|
||||
|
||||
private long syncTime = System.currentTimeMillis(),
|
||||
keepAliveTime = System.currentTimeMillis();
|
||||
private long syncTime = System.currentTimeMillis(), keepAliveTime = System.currentTimeMillis();
|
||||
|
||||
public ClientInfo(UUID id) {
|
||||
|
||||
this.id = id;
|
||||
|
||||
}
|
||||
|
||||
public ClientInfo(UUID id, String name) {
|
||||
|
||||
public Client(UUID id, String name) {
|
||||
this.id = id;
|
||||
this.serverName = name;
|
||||
|
||||
}
|
||||
|
||||
public abstract void send(CommunicationPackets.PATPacket packet);
|
||||
|
||||
public void setServerName(String name) {
|
||||
|
||||
this.serverName = name;
|
||||
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
|
||||
this.id = id;
|
||||
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
|
||||
return serverName;
|
||||
|
||||
}
|
||||
|
||||
public void updateSyncTime() {
|
||||
|
||||
syncTime = System.currentTimeMillis();
|
||||
|
||||
}
|
||||
|
||||
public void updateKeepAliveTime() {
|
||||
|
||||
keepAliveTime = System.currentTimeMillis();
|
||||
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
|
||||
return System.currentTimeMillis() - keepAliveTime > 5000;
|
||||
|
||||
}
|
||||
|
||||
public String getFormattedSyncTime() {
|
||||
|
||||
return TimeConverter.calcAndGetTime(syncTime);
|
||||
|
||||
}
|
||||
|
||||
public String getFormattedLastReceivedKeepAlivePacketTime() {
|
||||
|
||||
return TimeConverter.calcAndGetTime(keepAliveTime);
|
||||
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
|
||||
return id;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+23
-9
@@ -1,32 +1,46 @@
|
||||
package de.rayzs.pat.plugin.system.communication.client.impl;
|
||||
package de.rayzs.pat.api.communication.client.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.client.Client;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.PluginMessageClient;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.Client;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BungeeClient extends Client {
|
||||
public class BungeeClientInfo extends ClientInfo {
|
||||
|
||||
public BungeeClientInfo(UUID id) {
|
||||
|
||||
super(id);
|
||||
|
||||
}
|
||||
|
||||
public BungeeClientInfo(UUID id, String name) {
|
||||
|
||||
public BungeeClient(UUID id, String name) {
|
||||
super(id, name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(CommunicationPackets.PATPacket packet) {
|
||||
|
||||
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet, getId());
|
||||
|
||||
if (preparedPacket == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final ServerInfo serverInfo = ProxyServer.getInstance().getServerInfo(getServerName());
|
||||
|
||||
if (serverInfo != null) {
|
||||
serverInfo.sendData(PluginMessageClient.CHANNEL_NAME, preparedPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serverInfo.sendData(Client.CHANNEL_NAME, preparedPacket);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+21
-6
@@ -1,32 +1,47 @@
|
||||
package de.rayzs.pat.plugin.system.communication.client.impl;
|
||||
package de.rayzs.pat.api.communication.client.impl;
|
||||
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.plugin.system.communication.client.Client;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.impl.VelocityPluginMessageClient;
|
||||
import de.rayzs.pat.api.communication.impl.VelocityClient;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VelocityClient extends Client {
|
||||
public class VelocityClientInfo extends ClientInfo {
|
||||
|
||||
public VelocityClientInfo(UUID id) {
|
||||
|
||||
super(id);
|
||||
|
||||
}
|
||||
|
||||
public VelocityClientInfo(UUID id, String name) {
|
||||
|
||||
public VelocityClient(UUID id, String name) {
|
||||
super(id, name);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(CommunicationPackets.PATPacket packet) {
|
||||
|
||||
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet, getId());
|
||||
|
||||
if (preparedPacket == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Optional<RegisteredServer> optServer = VelocityLoader.getServer().getServer(getServerName());
|
||||
|
||||
optServer.ifPresent(registeredServer -> {
|
||||
registeredServer.sendPluginMessage(VelocityPluginMessageClient.getIdentifier(), preparedPacket);
|
||||
|
||||
registeredServer.sendPluginMessage(VelocityClient.getIdentifier(), preparedPacket);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+56
-22
@@ -1,108 +1,142 @@
|
||||
package de.rayzs.pat.plugin.system.communication.pmc.impl;
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.PluginMessageClient;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class BukkitPluginMessageClient implements PluginMessageClient, PluginMessageListener {
|
||||
public class BukkitClient implements Client, PluginMessageListener {
|
||||
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private boolean registered = false;
|
||||
|
||||
public BukkitPluginMessageClient() {
|
||||
public BukkitClient() {
|
||||
|
||||
reload();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
register();
|
||||
} else {
|
||||
unregister();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
|
||||
if (registered) {
|
||||
|
||||
unregister();
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!registered) {
|
||||
|
||||
register();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void register() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
SERVER.getMessenger().registerIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
|
||||
SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
|
||||
|
||||
}
|
||||
|
||||
private void unregister() {
|
||||
|
||||
if (!registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = false;
|
||||
|
||||
SERVER.getMessenger().unregisterIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
|
||||
SERVER.getMessenger().unregisterOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(CommunicationPackets.PATPacket packet) {
|
||||
|
||||
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet);
|
||||
|
||||
if (preparedPacket == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Player carrier = selectCarrier();
|
||||
if (carrier == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
PATScheduler.execute(() -> {
|
||||
|
||||
if (!carrier.isOnline()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
carrier.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, preparedPacket);
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}, carrier);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
|
||||
|
||||
if (!channel.equals(CHANNEL_NAME)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final Object packetObj = CommunicationPackets.readPacket(bytes);
|
||||
|
||||
if (!CommunicationPackets.isP2BPacket(packetObj)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
PATScheduler.createScheduler(() -> Communicator.get().handleP2BPacket((CommunicationPackets.PATPacket) packetObj));
|
||||
PATScheduler.createScheduler(
|
||||
() -> Communicator.get().handleP2BPacket((CommunicationPackets.PATPacket) packetObj));
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Player selectCarrier() {
|
||||
|
||||
final Iterator<? extends Player> iterator = SERVER.getOnlinePlayers().iterator();
|
||||
return iterator.hasNext() ? iterator.next() : null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+35
-42
@@ -1,7 +1,5 @@
|
||||
package de.rayzs.pat.plugin.system.communication.pmc.impl;
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.PluginMessageClient;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
@@ -10,101 +8,96 @@ import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BungeePluginMessageClient implements PluginMessageClient, Listener {
|
||||
public class BungeeClient implements Client, Listener {
|
||||
|
||||
private boolean registered;
|
||||
private static final ProxyServer SERVER = ProxyServer.getInstance();
|
||||
|
||||
public BungeeClient() {
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
SERVER.registerChannel(CHANNEL_NAME);
|
||||
SERVER.getPluginManager().registerListener(BungeeLoader.getPlugin(), this);
|
||||
|
||||
public BungeePluginMessageClient() {
|
||||
reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.ENABLED) {
|
||||
register();
|
||||
} else {
|
||||
unregister();
|
||||
}
|
||||
}
|
||||
|
||||
private void register() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
ProxyServer.getInstance().registerChannel(CHANNEL_NAME);
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(BungeeLoader.getPlugin(), this);
|
||||
}
|
||||
|
||||
private void unregister() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
ProxyServer.getInstance().unregisterChannel(CHANNEL_NAME);
|
||||
ProxyServer.getInstance().getPluginManager().unregisterListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(CommunicationPackets.PATPacket packet) {
|
||||
|
||||
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet);
|
||||
|
||||
if (preparedPacket == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (ServerInfo serverInfo : ProxyServer.getInstance().getServers().values()) {
|
||||
|
||||
try {
|
||||
|
||||
serverInfo.sendData(CHANNEL_NAME, preparedPacket);
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQueryReceive(PluginMessageEvent event) {
|
||||
|
||||
if (!event.getTag().equalsIgnoreCase(CHANNEL_NAME)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Private channel: never forward matching traffic between a player and backend.
|
||||
event.setCancelled(true);
|
||||
|
||||
if (!(event.getSender() instanceof Server server)) {
|
||||
return;
|
||||
}
|
||||
final Server server = (Server) event.getSender();
|
||||
final String serverName = server.getInfo().getName();
|
||||
final UUID clientId = Communicator.get().getClientId(serverName);
|
||||
|
||||
if (!CommunicationPackets.isInitialPacket(event.getData()) && clientId == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Object packetObj = CommunicationPackets.readPacket(event.getData(), clientId);
|
||||
if (!CommunicationPackets.isB2PPacket(packetObj)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Communicator.get().handleB2PPacket(serverName, (CommunicationPackets.PATPacket) packetObj);
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
|
||||
throwable.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+36
-45
@@ -1,103 +1,91 @@
|
||||
package de.rayzs.pat.plugin.system.communication.pmc.impl;
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.PluginMessageClient;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VelocityPluginMessageClient implements PluginMessageClient {
|
||||
public class VelocityClient implements Client {
|
||||
|
||||
private static final ProxyServer SERVER = VelocityLoader.getServer();
|
||||
private static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from(CHANNEL_NAME);
|
||||
private boolean registered = false;
|
||||
|
||||
public VelocityPluginMessageClient() {
|
||||
reload();
|
||||
public VelocityClient() {
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
SERVER.getChannelRegistrar().register(IDENTIFIER);
|
||||
SERVER.getEventManager().register(VelocityLoader.getInstance(), this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.ENABLED) {
|
||||
register();
|
||||
} else {
|
||||
unregister();
|
||||
}
|
||||
}
|
||||
|
||||
private void register() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
VelocityLoader.getServer().getChannelRegistrar().register(IDENTIFIER);
|
||||
VelocityLoader.getServer().getEventManager().register(VelocityLoader.getInstance(), this);
|
||||
}
|
||||
|
||||
private void unregister() {
|
||||
if (registered) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
registered = true;
|
||||
|
||||
VelocityLoader.getServer().getChannelRegistrar().unregister(IDENTIFIER);
|
||||
VelocityLoader.getServer().getEventManager().unregisterListener(VelocityLoader.getInstance(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(CommunicationPackets.PATPacket packet) {
|
||||
|
||||
final byte[] preparedPacket = CommunicationPackets.preparePacket(packet);
|
||||
|
||||
if (preparedPacket == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (RegisteredServer registeredServer : VelocityLoader.getServer().getAllServers()) {
|
||||
for (RegisteredServer registeredServer : SERVER.getAllServers()) {
|
||||
|
||||
try {
|
||||
|
||||
registeredServer.sendPluginMessage(IDENTIFIER, preparedPacket);
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onQueryReceive(PluginMessageEvent event) {
|
||||
if (!IDENTIFIER.equals(event.getIdentifier())) {
|
||||
|
||||
if (event.getIdentifier() != IDENTIFIER) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// This is a private proxy/backend channel. Mark it handled before inspecting
|
||||
// the source so player-originated messages are never forwarded downstream.
|
||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||
|
||||
if (!(event.getSource() instanceof ServerConnection server)) {
|
||||
return;
|
||||
}
|
||||
final ServerConnection server = (ServerConnection) event.getSource();
|
||||
final String serverName = server.getServerInfo().getName();
|
||||
final UUID clientId = Communicator.get().getClientId(serverName);
|
||||
|
||||
if (!CommunicationPackets.isInitialPacket(event.getData()) && clientId == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Object packetObj = CommunicationPackets.readPacket(event.getData(), clientId);
|
||||
|
||||
if (!CommunicationPackets.isB2PPacket(packetObj)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Communicator.get().handleB2PPacket(serverName, (CommunicationPackets.PATPacket) packetObj);
|
||||
@@ -105,6 +93,9 @@ public class VelocityPluginMessageClient implements PluginMessageClient {
|
||||
}
|
||||
|
||||
public static MinecraftChannelIdentifier getIdentifier() {
|
||||
|
||||
return IDENTIFIER;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +1,34 @@
|
||||
package de.rayzs.pat.api.event;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class PATEvent<T> {
|
||||
|
||||
private final CommandSender player;
|
||||
private final Object senderObj;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PATEvent(CommandSender player) {
|
||||
this.player = player;
|
||||
public PATEvent(Object senderObj) {
|
||||
|
||||
this.senderObj = senderObj;
|
||||
|
||||
}
|
||||
|
||||
public abstract void handle(T t);
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
|
||||
this.cancelled = cancelled;
|
||||
|
||||
}
|
||||
public CommandSender getPlayer() {
|
||||
return player;
|
||||
|
||||
public Object getSenderObj() {
|
||||
|
||||
return senderObj;
|
||||
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
|
||||
return cancelled;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package de.rayzs.pat.api.event;
|
||||
|
||||
import de.rayzs.pat.api.event.events.*;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -10,183 +9,303 @@ public class PATEventHandler {
|
||||
|
||||
private static List<PATEvent> EVENTS = new ArrayList<>();
|
||||
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(player, command, blocked, notify);
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked,
|
||||
boolean notify)
|
||||
{
|
||||
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked, notify);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof ExecuteCommandEvent executeCommandEvent) {
|
||||
|
||||
if (patEvent instanceof ExecuteCommandEvent) {
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = (ExecuteCommandEvent) patEvent;
|
||||
executeCommandEvent.handle(event);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(CommandSender player, HashSet<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(player, suggestions);
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(Object senderObj, List<String> suggestions) {
|
||||
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(senderObj, suggestions);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof FilteredSuggestionEvent filteredSuggestionEvent) {
|
||||
filteredSuggestionEvent.handle(event);
|
||||
|
||||
if (patEvent instanceof FilteredSuggestionEvent) {
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestion = (FilteredSuggestionEvent) patEvent;
|
||||
filteredSuggestion.handle(event);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(CommandSender player, String cursor, List<String> completion) {
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(player, cursor, completion);
|
||||
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(Object senderObj, String cursor,
|
||||
List<String> completion)
|
||||
{
|
||||
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(senderObj, cursor, completion);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof FilteredTabCompletionEvent filteredTabCompletionEvent) {
|
||||
filteredTabCompletionEvent.handle(event);
|
||||
|
||||
if (patEvent instanceof FilteredTabCompletionEvent) {
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletion = (FilteredTabCompletionEvent) patEvent;
|
||||
filteredTabCompletion.handle(event);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(CommandSender player, ServerPlayersChangeEvent.Type type) {
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(player, type);
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(Object senderObj,
|
||||
ServerPlayersChangeEvent.Type type)
|
||||
{
|
||||
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(senderObj, type);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof ServerPlayersChangeEvent serverPlayersChangeEvent) {
|
||||
|
||||
if (patEvent instanceof ServerPlayersChangeEvent) {
|
||||
|
||||
ServerPlayersChangeEvent serverPlayersChangeEvent = (ServerPlayersChangeEvent) patEvent;
|
||||
serverPlayersChangeEvent.handle(event);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
public static UpdatePluginEvent callUpdatePluginEvents() {
|
||||
|
||||
UpdatePluginEvent event = EmptyEvent.createEmptyUpdatePluginEvent();
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof UpdatePluginEvent updatePluginEvent) {
|
||||
|
||||
if (patEvent instanceof UpdatePluginEvent) {
|
||||
|
||||
UpdatePluginEvent updatePluginEvent = (UpdatePluginEvent) patEvent;
|
||||
updatePluginEvent.handle(event);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(CommandSender player, HashSet<String> commands, boolean serverBased) {
|
||||
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(player, commands, serverBased);
|
||||
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(Object playerObj, List<String> commands,
|
||||
boolean serverBased)
|
||||
{
|
||||
|
||||
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(playerObj, commands,
|
||||
serverBased);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof UpdatePlayerCommandsEvent updatePlayerCommandsEvent) {
|
||||
|
||||
if (patEvent instanceof UpdatePlayerCommandsEvent) {
|
||||
|
||||
UpdatePlayerCommandsEvent updatePlayerCommandsEvent = (UpdatePlayerCommandsEvent) patEvent;
|
||||
updatePlayerCommandsEvent.handle(event);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket,
|
||||
String serverName)
|
||||
{
|
||||
|
||||
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(dataSyncPacket, serverName);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof SentSyncEvent sentSyncEvent) {
|
||||
|
||||
if (patEvent instanceof SentSyncEvent) {
|
||||
|
||||
SentSyncEvent sentSyncEvent = (SentSyncEvent) patEvent;
|
||||
sentSyncEvent.handle(event);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
public static ReceiveSyncEvent callReceiveSyncEvents(
|
||||
CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket)
|
||||
{
|
||||
|
||||
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(dataSyncPacket);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if (patEvent instanceof ReceiveSyncEvent receiveSyncEvent) {
|
||||
receiveSyncEvent.handle(event);
|
||||
|
||||
if (patEvent instanceof ReceiveSyncEvent) {
|
||||
|
||||
ReceiveSyncEvent proxySyncEvent = (ReceiveSyncEvent) patEvent;
|
||||
proxySyncEvent.handle(event);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return event;
|
||||
|
||||
}
|
||||
|
||||
public static void register(PATEvent event) {
|
||||
|
||||
EVENTS.add(event);
|
||||
|
||||
}
|
||||
|
||||
public static void unregister(PATEvent event) {
|
||||
|
||||
EVENTS.remove(event);
|
||||
|
||||
}
|
||||
|
||||
public static class EmptyEvent {
|
||||
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(CommandSender player, ServerPlayersChangeEvent.Type type) {
|
||||
return new ServerPlayersChangeEvent(player, type) {
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(Object senderObj,
|
||||
ServerPlayersChangeEvent.Type type)
|
||||
{
|
||||
|
||||
return new ServerPlayersChangeEvent(senderObj, type) {
|
||||
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
public static SentSyncEvent createEmptySentSyncEvent(
|
||||
CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName)
|
||||
{
|
||||
|
||||
return new SentSyncEvent(null, dataSyncPacket, serverName) {
|
||||
|
||||
@Override
|
||||
public void handle(SentSyncEvent event) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static ReceiveSyncEvent createEmptyReceiveSyncEvent(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
public static ReceiveSyncEvent createEmptyReceiveSyncEvent(
|
||||
CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket)
|
||||
{
|
||||
|
||||
return new ReceiveSyncEvent(null, dataSyncPacket) {
|
||||
|
||||
@Override
|
||||
public void handle(ReceiveSyncEvent event) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent createEmptyUpdatePlayerCommandsEvent(CommandSender player, HashSet<String> commands, boolean serverBased) {
|
||||
return new UpdatePlayerCommandsEvent(player, commands, serverBased) {
|
||||
public static UpdatePlayerCommandsEvent createEmptyUpdatePlayerCommandsEvent(Object playerObj,
|
||||
List<String> commands, boolean serverBased)
|
||||
{
|
||||
|
||||
return new UpdatePlayerCommandsEvent(playerObj, commands, serverBased) {
|
||||
|
||||
@Override
|
||||
public void handle(UpdatePlayerCommandsEvent event) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static UpdatePluginEvent createEmptyUpdatePluginEvent() {
|
||||
|
||||
return new UpdatePluginEvent(null) {
|
||||
|
||||
@Override
|
||||
public void handle(UpdatePluginEvent event) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
return new ExecuteCommandEvent(player, command, blocked, notify) {
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(Object senderObj, String command,
|
||||
boolean blocked, boolean notify)
|
||||
{
|
||||
|
||||
return new ExecuteCommandEvent(senderObj, command, blocked, notify) {
|
||||
|
||||
@Override
|
||||
public void handle(ExecuteCommandEvent event) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(CommandSender player, HashSet<String> suggestions) {
|
||||
return new FilteredSuggestionEvent(player, suggestions) {
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(Object senderObj,
|
||||
List<String> suggestions)
|
||||
{
|
||||
|
||||
return new FilteredSuggestionEvent(senderObj, suggestions) {
|
||||
|
||||
@Override
|
||||
public void handle(FilteredSuggestionEvent event) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent createEmptyFilteredTabCompletion(CommandSender player, String cursor, List<String> completion) {
|
||||
return new FilteredTabCompletionEvent(player, cursor, completion) {
|
||||
public static FilteredTabCompletionEvent createEmptyFilteredTabCompletion(Object senderObj, String cursor,
|
||||
List<String> completion)
|
||||
{
|
||||
|
||||
return new FilteredTabCompletionEvent(senderObj, cursor, completion) {
|
||||
|
||||
@Override
|
||||
public void handle(FilteredTabCompletionEvent event) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent> {
|
||||
|
||||
@@ -9,38 +8,51 @@ public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent>
|
||||
private boolean blocked, notify;
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
super(null);
|
||||
|
||||
super(null);
|
||||
this.blocked = false;
|
||||
this.notify = false;
|
||||
this.command = null;
|
||||
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
super(player);
|
||||
public ExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
|
||||
super(senderObj);
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
this.notify = notify;
|
||||
|
||||
}
|
||||
|
||||
public void setDoesNotify(boolean notify) {
|
||||
|
||||
this.notify = notify;
|
||||
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
|
||||
return command;
|
||||
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
|
||||
return blocked;
|
||||
|
||||
}
|
||||
|
||||
public boolean doesNotify() {
|
||||
|
||||
return notify;
|
||||
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
|
||||
this.blocked = blocked;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +1,36 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class FilteredSuggestionEvent extends PATEvent<FilteredSuggestionEvent> {
|
||||
|
||||
private HashSet<String> suggestions;
|
||||
private List<String> suggestions;
|
||||
|
||||
public FilteredSuggestionEvent() {
|
||||
|
||||
super(null);
|
||||
this.suggestions = null;
|
||||
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(CommandSender player, HashSet<String> suggestions) {
|
||||
super(player);
|
||||
public FilteredSuggestionEvent(Object senderObj, List<String> suggestions) {
|
||||
|
||||
super(senderObj);
|
||||
this.suggestions = suggestions;
|
||||
|
||||
}
|
||||
|
||||
public HashSet<String> getSuggestions() {
|
||||
public List<String> getSuggestions() {
|
||||
|
||||
return suggestions;
|
||||
|
||||
}
|
||||
|
||||
public void setSuggestions(HashSet<String> suggestions) {
|
||||
public void setSuggestions(List<String> suggestions) {
|
||||
|
||||
this.suggestions = suggestions;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class FilteredTabCompletionEvent extends PATEvent<FilteredTabCompletionEvent> {
|
||||
@@ -11,30 +9,39 @@ public abstract class FilteredTabCompletionEvent extends PATEvent<FilteredTabCom
|
||||
private List<String> completion;
|
||||
|
||||
public FilteredTabCompletionEvent() {
|
||||
super(null);
|
||||
|
||||
super(null);
|
||||
this.cursor = null;
|
||||
this.completion = null;
|
||||
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(CommandSender player, String cursor, List<String> completion) {
|
||||
super(player);
|
||||
public FilteredTabCompletionEvent(Object senderObj, String cursor, List<String> completion) {
|
||||
|
||||
super(senderObj);
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
|
||||
}
|
||||
|
||||
public abstract void handle(FilteredTabCompletionEvent event);
|
||||
|
||||
public String getCursor() {
|
||||
|
||||
return cursor;
|
||||
|
||||
}
|
||||
|
||||
public List<String> getCompletion() {
|
||||
|
||||
return completion;
|
||||
|
||||
}
|
||||
|
||||
public void setCompletion(List<String> completion) {
|
||||
|
||||
this.completion = completion;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,24 +2,29 @@ package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class ReceiveSyncEvent extends PATEvent<ReceiveSyncEvent> {
|
||||
|
||||
private final CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket;
|
||||
|
||||
public ReceiveSyncEvent() {
|
||||
|
||||
super(null);
|
||||
this.dataSyncPacket = null;
|
||||
|
||||
}
|
||||
|
||||
public ReceiveSyncEvent(CommandSender player, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
super(player);
|
||||
public ReceiveSyncEvent(Object senderObj, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
|
||||
super(senderObj);
|
||||
this.dataSyncPacket = dataSyncPacket;
|
||||
|
||||
}
|
||||
|
||||
public CommunicationPackets.Proxy2Backend.DataSyncPacket getDataSyncPacket() {
|
||||
|
||||
return dataSyncPacket;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
|
||||
|
||||
@@ -10,24 +9,33 @@ public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
|
||||
private final String serverName;
|
||||
|
||||
public SentSyncEvent() {
|
||||
super(null);
|
||||
|
||||
super(null);
|
||||
this.dataSyncPacket = null;
|
||||
this.serverName = null;
|
||||
|
||||
}
|
||||
|
||||
public SentSyncEvent(CommandSender player, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
super(player);
|
||||
public SentSyncEvent(Object senderObj, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket,
|
||||
String serverName)
|
||||
{
|
||||
|
||||
super(senderObj);
|
||||
this.dataSyncPacket = dataSyncPacket;
|
||||
this.serverName = serverName;
|
||||
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
|
||||
return serverName;
|
||||
|
||||
}
|
||||
|
||||
public CommunicationPackets.Proxy2Backend.DataSyncPacket getDataSyncPacket() {
|
||||
|
||||
return dataSyncPacket;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,27 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class ServerPlayersChangeEvent extends PATEvent<ServerPlayersChangeEvent> {
|
||||
|
||||
private final Type type;
|
||||
|
||||
public ServerPlayersChangeEvent(CommandSender player, Type type) {
|
||||
super(player);
|
||||
public ServerPlayersChangeEvent(Object senderObj, Type type) {
|
||||
|
||||
super(senderObj);
|
||||
this.type = type;
|
||||
|
||||
}
|
||||
|
||||
public ServerPlayersChangeEvent() {
|
||||
|
||||
super(null);
|
||||
this.type = Type.UNKNOWN;
|
||||
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
JOINED, LEFT, UNKNOWN
|
||||
}
|
||||
|
||||
public enum Type { JOINED, LEFT, UNKNOWN }
|
||||
}
|
||||
@@ -1,31 +1,37 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class UpdatePlayerCommandsEvent extends PATEvent<UpdatePlayerCommandsEvent> {
|
||||
|
||||
private HashSet<String> commands;
|
||||
private List<String> commands;
|
||||
private boolean serverBased;
|
||||
|
||||
public UpdatePlayerCommandsEvent() {
|
||||
|
||||
super(null);;
|
||||
|
||||
}
|
||||
|
||||
public UpdatePlayerCommandsEvent(CommandSender player, HashSet<String> commands, boolean serverBased) {
|
||||
super(player);
|
||||
public UpdatePlayerCommandsEvent(Object senderObj, List<String> commands, boolean serverBased) {
|
||||
|
||||
super(senderObj);
|
||||
this.commands = commands;
|
||||
this.serverBased = serverBased;
|
||||
|
||||
}
|
||||
|
||||
public HashSet<String> getCommands() {
|
||||
public List<String> getCommands() {
|
||||
|
||||
return commands;
|
||||
|
||||
}
|
||||
|
||||
public boolean isServerBased() {
|
||||
|
||||
return serverBased;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,19 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class UpdatePluginEvent extends PATEvent<UpdatePluginEvent> {
|
||||
|
||||
public UpdatePluginEvent() {
|
||||
|
||||
super(null);;
|
||||
|
||||
}
|
||||
|
||||
public UpdatePluginEvent(CommandSender player) {
|
||||
super(player);
|
||||
public UpdatePluginEvent(Object senderObj) {
|
||||
|
||||
super(senderObj);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public abstract class ExecuteCommandEvent extends Event implements Cancellable {
|
||||
|
||||
private final String command;
|
||||
private boolean blocked;
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
|
||||
this.blocked = false;
|
||||
this.command = null;
|
||||
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(Player player, String command, boolean blocked) {
|
||||
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
|
||||
return command;
|
||||
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
|
||||
return blocked;
|
||||
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
|
||||
this.blocked = blocked;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
return blocked;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
|
||||
this.blocked = cancel;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredSuggestionEvent extends Event {
|
||||
|
||||
private List<String> suggestions;
|
||||
|
||||
public FilteredSuggestionEvent() {
|
||||
|
||||
this.suggestions = null;
|
||||
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(Player player, List<String> suggestions) {
|
||||
|
||||
this.suggestions = suggestions;
|
||||
|
||||
}
|
||||
|
||||
public List<String> getSuggestions() {
|
||||
|
||||
return suggestions;
|
||||
|
||||
}
|
||||
|
||||
public void setSuggestions(List<String> suggestions) {
|
||||
|
||||
this.suggestions = suggestions;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredTabCompletionEvent extends Event {
|
||||
|
||||
private String cursor;
|
||||
private List<String> completion;
|
||||
|
||||
public FilteredTabCompletionEvent() {
|
||||
|
||||
this.cursor = null;
|
||||
this.completion = null;
|
||||
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(Player player, String cursor, List<String> completion) {
|
||||
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
|
||||
}
|
||||
|
||||
public abstract void handle(FilteredTabCompletionEvent event);
|
||||
|
||||
public String getCursor() {
|
||||
|
||||
return cursor;
|
||||
|
||||
}
|
||||
|
||||
public List<String> getCompletion() {
|
||||
|
||||
return completion;
|
||||
|
||||
}
|
||||
|
||||
public void setCompletion(List<String> completion) {
|
||||
|
||||
this.completion = completion;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
package de.rayzs.pat.api.netty.bukkit;
|
||||
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.netty.bukkit.handlers.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
import io.netty.channel.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import java.util.*;
|
||||
|
||||
public class BukkitPacketAnalyzer {
|
||||
|
||||
public static final ConcurrentHashMap<UUID, Channel> INJECTED_PLAYERS = new ConcurrentHashMap<>();
|
||||
private static final ExpireCache<UUID, Object> SENT_PACKET = new ExpireCache<>(2, TimeUnit.SECONDS);
|
||||
|
||||
private static final String HANDLER_NAME = "pat-bukkit-handler", PIPELINE_NAME = "packet_handler";
|
||||
|
||||
private static final BukkitPacketHandler PACKET_HANDLER = Reflection.isAtLeast(1, 16) ? new ModernPacketHandler()
|
||||
: new LegacyPacketHandler();
|
||||
private static final BukkitPacketHandler COMMANDS_NODE_HANDLER = new ModernCommandsNodeHandler();
|
||||
|
||||
private static final HashMap<Player, String> PLAYER_INPUT_CACHE = new HashMap<>();
|
||||
|
||||
public static void injectAll() {
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(BukkitPacketAnalyzer::inject);
|
||||
|
||||
}
|
||||
|
||||
public static void uninjectAll() {
|
||||
|
||||
BukkitPacketAnalyzer.INJECTED_PLAYERS.keySet().forEach(BukkitPacketAnalyzer::uninject);
|
||||
BukkitPacketAnalyzer.INJECTED_PLAYERS.clear();
|
||||
|
||||
}
|
||||
|
||||
public static void sendPacket(UUID uuid, Object object) {
|
||||
|
||||
Channel channel = INJECTED_PLAYERS.get(uuid);
|
||||
|
||||
if (channel == null)
|
||||
return;
|
||||
|
||||
SENT_PACKET.put(uuid, object);
|
||||
channel.pipeline().writeAndFlush(object);
|
||||
|
||||
}
|
||||
|
||||
public static boolean inject(Player player) {
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return true;
|
||||
|
||||
try {
|
||||
|
||||
Channel channel = Reflection.getPlayerChannel(player);
|
||||
|
||||
if (channel == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (channel.pipeline().names().contains(BukkitPacketAnalyzer.HANDLER_NAME))
|
||||
uninject(channel);
|
||||
|
||||
channel.pipeline().addBefore(BukkitPacketAnalyzer.PIPELINE_NAME, BukkitPacketAnalyzer.HANDLER_NAME,
|
||||
new PacketDecoder(player));
|
||||
BukkitPacketAnalyzer.INJECTED_PLAYERS.put(player.getUniqueId(), channel);
|
||||
|
||||
} catch (IndexOutOfBoundsException indexOutOfBoundsException) {
|
||||
|
||||
Reflection.toggleInjectionMethod();
|
||||
boolean success = inject(player);
|
||||
|
||||
if (!success) {
|
||||
|
||||
Logger.warning(
|
||||
"Both injection methods failed! Please report this back to me on my Discord! (https://www.rayzs.de/discord)");
|
||||
|
||||
}
|
||||
|
||||
return success;
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static void uninject(UUID uuid) {
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
return;
|
||||
|
||||
if (BukkitPacketAnalyzer.INJECTED_PLAYERS.containsKey(uuid)) {
|
||||
|
||||
Channel channel = BukkitPacketAnalyzer.INJECTED_PLAYERS.get(uuid);
|
||||
uninject(channel);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void uninject(Channel channel) {
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
|
||||
if (channel != null) {
|
||||
|
||||
channel.eventLoop().submit(() -> {
|
||||
|
||||
ChannelPipeline pipeline = channel.pipeline();
|
||||
|
||||
if (pipeline.names().contains(BukkitPacketAnalyzer.HANDLER_NAME))
|
||||
pipeline.remove(BukkitPacketAnalyzer.HANDLER_NAME);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getPlayerInput(Player player) {
|
||||
|
||||
String input = PLAYER_INPUT_CACHE.get(player);
|
||||
PLAYER_INPUT_CACHE.remove(player);
|
||||
return input;
|
||||
|
||||
}
|
||||
|
||||
public static void insertPlayerInput(Player player, String text) {
|
||||
|
||||
PLAYER_INPUT_CACHE.put(player, text);
|
||||
|
||||
}
|
||||
|
||||
private static class PacketDecoder extends ChannelDuplexHandler {
|
||||
|
||||
private final Player player;
|
||||
private final CommandSender sender;
|
||||
|
||||
private PacketDecoder(Player player) {
|
||||
|
||||
this.player = player;
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext channel, Object packetObj) {
|
||||
|
||||
try {
|
||||
|
||||
if (packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (!packetName.equals("PacketPlayInTabComplete")
|
||||
&& !packetName.equals("ServerboundCommandSuggestionPacket"))
|
||||
{
|
||||
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(sender)) {
|
||||
|
||||
if (!PACKET_HANDLER.handleIncomingPacket(player, sender, packetObj))
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
super.channelRead(channel, packetObj);
|
||||
|
||||
} catch (Throwable exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext channel, Object packetObj, ChannelPromise promise) {
|
||||
|
||||
try {
|
||||
|
||||
if (packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final String packetName = packetObj.getClass().getSimpleName();
|
||||
final boolean isCommandsPacket = packetName.equals("ClientboundCommandsPacket");
|
||||
final boolean isTabCompletePacket = packetName.equals("PacketPlayOutTabComplete")
|
||||
|| packetName.equals("ClientboundCommandSuggestionsPacket");
|
||||
|
||||
if (!isCommandsPacket && !isTabCompletePacket || PermissionUtil.hasBypassPermission(sender)) {
|
||||
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (isCommandsPacket) {
|
||||
|
||||
COMMANDS_NODE_HANDLER.handleOutgoingPacket(player, sender, packetObj);
|
||||
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
Object sentPacketObj = SENT_PACKET.get(uuid);
|
||||
|
||||
if (sentPacketObj != null) {
|
||||
|
||||
if (sentPacketObj == packetObj) {
|
||||
|
||||
SENT_PACKET.remove(uuid);
|
||||
super.write(channel, sentPacketObj, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!PACKET_HANDLER.handleOutgoingPacket(player, sender, packetObj))
|
||||
return;
|
||||
|
||||
super.write(channel, packetObj, promise);
|
||||
|
||||
} catch (Throwable exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package de.rayzs.pat.api.netty.bukkit;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface BukkitPacketHandler {
|
||||
|
||||
boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception;
|
||||
boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception;
|
||||
|
||||
}
|
||||
+55
-36
@@ -1,11 +1,10 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers;
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
@@ -14,8 +13,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -23,68 +22,78 @@ import de.rayzs.pat.utils.Reflection;
|
||||
public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean handleIncomingPacket(
|
||||
final Player player,
|
||||
final CommandSender sender,
|
||||
final Object packetObj,
|
||||
final boolean isOperator
|
||||
) throws Exception {
|
||||
Field stringField = Reflection.getFirstFieldByType(packetObj.getClass(), "String", Reflection.SearchOption.ENDS);
|
||||
if(stringField == null) {
|
||||
public boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
|
||||
Field stringField = Reflection.getFirstFieldByType(packetObj.getClass(), "String",
|
||||
Reflection.SearchOption.ENDS);
|
||||
if (stringField == null) {
|
||||
|
||||
Logger.warning("Failed PacketAnalyze process! (#1)");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
String text = (String) stringField.get(packetObj);
|
||||
BukkitPacketAnalyzer.insertPlayerInput(player, text);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOutgoingPacket(
|
||||
final Player player,
|
||||
final CommandSender sender,
|
||||
final Object packetObj,
|
||||
final boolean isOperator
|
||||
) throws Exception {
|
||||
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
|
||||
final String rawInput = BukkitPacketAnalyzer.getPlayerInput(player);
|
||||
|
||||
if(rawInput == null) {
|
||||
if (rawInput == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender, isOperator);
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
String input = rawInput;
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
if (!input.startsWith("/")) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
input = input.substring(1);
|
||||
|
||||
final boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender, isOperator);
|
||||
final boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender);
|
||||
final boolean spaces = input.contains(" ");
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(input) && !doesBypassNamespace) {
|
||||
|
||||
cancelsBeforeHand = true;
|
||||
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand && !input.isEmpty()) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.getFirstArg(input), isOperator);
|
||||
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.getFirstArg(input));
|
||||
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand) {
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
|
||||
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(input)
|
||||
|| Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(input);
|
||||
|
||||
}
|
||||
|
||||
for (Field field : Reflection.getFields(packetObj)) {
|
||||
|
||||
field.setAccessible(true);
|
||||
Object result = field.get(packetObj);
|
||||
|
||||
if (!(result instanceof String[])) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
String[] tR = (String[]) result;
|
||||
@@ -93,47 +102,57 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
if (spaces) {
|
||||
|
||||
if (cancelsBeforeHand) {
|
||||
|
||||
suggestions.clear();
|
||||
field.set(packetObj, suggestions.toArray(new String[0]));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
final List<String> tmpSuggestionsList = new ArrayList<>(suggestions);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(
|
||||
sender,
|
||||
rawInput,
|
||||
SubArgument.get().getTabCompleteHandler().handleTabCompletion(
|
||||
sender,
|
||||
rawInput,
|
||||
tmpSuggestionsList
|
||||
)
|
||||
);
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler
|
||||
.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, new ArrayList<>(suggestions));
|
||||
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
|
||||
suggestions.clear();
|
||||
|
||||
} else {
|
||||
|
||||
suggestions.removeIf(s -> !filteredTabCompletionEvent.getCompletion().contains(s));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
suggestions.removeIf(s -> {
|
||||
|
||||
String cpy = s;
|
||||
if (cpy.startsWith("/")) {
|
||||
|
||||
cpy = cpy.substring(1);
|
||||
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(cpy) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(cpy)) {
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(cpy)
|
||||
|| Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(cpy))
|
||||
{
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, cpy, isOperator);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, cpy);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
field.set(packetObj, suggestions.toArray(new String[0]));
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.node.BukkitCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ModernCommandsNodeHandler implements BukkitPacketHandler {
|
||||
|
||||
public boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
|
||||
// Ignored
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
|
||||
final BukkitCommandNodeHelper helper = new BukkitCommandNodeHelper(packetObj);
|
||||
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+137
-71
@@ -1,11 +1,10 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.bukkit.handlers;
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
@@ -17,13 +16,13 @@ import com.mojang.brigadier.suggestion.Suggestions;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.message.MessageHelper;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
|
||||
public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
@@ -31,188 +30,225 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
private static boolean modifiable = true;
|
||||
|
||||
@Override
|
||||
public boolean handleIncomingPacket(
|
||||
final Player player,
|
||||
final CommandSender sender,
|
||||
final Object packetObj,
|
||||
final boolean isOperator
|
||||
) throws Exception {
|
||||
Field stringField = Reflection.getFirstFieldByType(packetObj.getClass(), "String", Reflection.SearchOption.ENDS);
|
||||
public boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
|
||||
Field stringField = Reflection.getFirstFieldByType(packetObj.getClass(), "String",
|
||||
Reflection.SearchOption.ENDS);
|
||||
|
||||
if (stringField == null) {
|
||||
|
||||
Logger.warning("Failed PacketAnalyze process! (#1)");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
String text = (String) stringField.get(packetObj);
|
||||
if (!text.isBlank() && text.charAt(0) != '/') text = '/' + text;
|
||||
if (!text.isBlank() && text.charAt(0) != '/')
|
||||
text = '/' + text;
|
||||
|
||||
if (Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(text)) {
|
||||
MessageHelper.sendMessage(
|
||||
CommandSender.from(Bukkit.getConsoleSender()),
|
||||
Storage.ConfigSections.Settings.PATCH_EXPLOITS.ALERT_MESSAGE.get().replace("%player%", player.getName())
|
||||
);
|
||||
|
||||
PATScheduler.createScheduler(() ->
|
||||
player.kickPlayer(
|
||||
StringUtils.replace(Storage.ConfigSections.Settings.PATCH_EXPLOITS.KICK_MESSAGE.get(), "&", "§")
|
||||
)
|
||||
);
|
||||
MessageTranslator.send(Bukkit.getConsoleSender(),
|
||||
Storage.ConfigSections.Settings.PATCH_EXPLOITS.ALERT_MESSAGE.get().replace("%player%",
|
||||
player.getName()));
|
||||
|
||||
PATScheduler.createScheduler(() -> player.kickPlayer(
|
||||
StringUtils.replace(Storage.ConfigSections.Settings.PATCH_EXPLOITS.KICK_MESSAGE.get(), "&", "§")));
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
BukkitPacketAnalyzer.insertPlayerInput(player, text);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOutgoingPacket(
|
||||
final Player player,
|
||||
final CommandSender sender,
|
||||
final Object packetObj,
|
||||
final boolean isOperator
|
||||
) throws Exception {
|
||||
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
|
||||
Object suggestionObj;
|
||||
String rawInput = BukkitPacketAnalyzer.getPlayerInput(player), input = rawInput;
|
||||
|
||||
if(input == null) {
|
||||
if (input == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
final boolean is121Packet = packetObj.getClass().getSimpleName().equals("ClientboundCommandSuggestionsPacket");
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender, isOperator);
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
boolean is121Packet = packetObj.getClass().getSimpleName().equals("ClientboundCommandSuggestionsPacket"),
|
||||
cancelsBeforeHand = false;
|
||||
|
||||
int spaces = 0;
|
||||
if(input.startsWith("/") || is121Packet) {
|
||||
input = input.substring(1);
|
||||
if (input.startsWith("/") || is121Packet) {
|
||||
|
||||
input = input.replace("/", "");
|
||||
if (input.contains(" ")) {
|
||||
|
||||
String[] split = input.split(" ");
|
||||
spaces = split.length;
|
||||
if (spaces > 0) input = split[0];
|
||||
if (spaces > 0)
|
||||
input = split[0];
|
||||
|
||||
}
|
||||
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, input, isOperator);
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, input);
|
||||
|
||||
if (!cancelsBeforeHand)
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input);
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input)
|
||||
|| Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input);
|
||||
|
||||
}
|
||||
|
||||
if (is121Packet || Reflection.isFoliaServer() && packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")) {
|
||||
try {
|
||||
Field suggestionsField = Reflection.getFieldsByTypeNormal(packetObj.getClass(), "List", Reflection.SearchOption.ENDS).get(0);
|
||||
List<?> suggestionsTmp = (List<?>) suggestionsField.get(packetObj),
|
||||
suggestions = new ArrayList<>(suggestionsTmp);
|
||||
if (is121Packet || Reflection.isFoliaServer()
|
||||
&& packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete"))
|
||||
{
|
||||
|
||||
List<Field> intFields = Reflection.getFieldsByTypeNormal(packetObj.getClass(), "int", Reflection.SearchOption.ENDS);
|
||||
int id = (int) intFields.get(0).get(packetObj),
|
||||
start = (int) intFields.get(1).get(packetObj),
|
||||
try {
|
||||
|
||||
Field suggestionsField = Reflection
|
||||
.getFieldsByTypeNormal(packetObj.getClass(), "List", Reflection.SearchOption.ENDS).get(0);
|
||||
List<?> suggestionsTmp = (List<?>) suggestionsField.get(packetObj),
|
||||
suggestions = new ArrayList<>(suggestionsTmp);
|
||||
|
||||
List<Field> intFields = Reflection.getFieldsByTypeNormal(packetObj.getClass(), "int",
|
||||
Reflection.SearchOption.ENDS);
|
||||
int id = (int) intFields.get(0).get(packetObj), start = (int) intFields.get(1).get(packetObj),
|
||||
length = (int) intFields.get(2).get(packetObj);
|
||||
|
||||
Class<?> clientboundCommandSuggestionsPacketClass = Class.forName("net.minecraft.network.protocol.game." + (packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete") ? "PacketPlayOutTabComplete" : "ClientboundCommandSuggestionsPacket"));
|
||||
Class<?> clientboundCommandSuggestionsPacketClass = Class.forName("net.minecraft.network.protocol.game."
|
||||
+ (packetObj.getClass().getSimpleName().equals("PacketPlayOutTabComplete")
|
||||
? "PacketPlayOutTabComplete"
|
||||
: "ClientboundCommandSuggestionsPacket"));
|
||||
if ((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird())
|
||||
return false;
|
||||
|
||||
if (spaces >= 1 && cancelsBeforeHand) {
|
||||
|
||||
suggestions.clear();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (spaces == 0) {
|
||||
|
||||
suggestions.removeIf(suggestion -> {
|
||||
|
||||
String command = getSuggestionFromEntry(suggestion);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, isOperator);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command);
|
||||
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
for (Object suggestion : suggestions)
|
||||
suggestionsAsString.add(getSuggestionFromEntry(suggestion));
|
||||
|
||||
suggestionsAsString = SubArgument.get().getTabCompleteHandler().handleTabCompletion(sender, rawInput, suggestionsAsString);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(sender, rawInput, suggestionsAsString);
|
||||
if (filteredTabCompletionEvent.isCancelled()) suggestions.clear();
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler
|
||||
.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
if (filteredTabCompletionEvent.isCancelled())
|
||||
suggestions.clear();
|
||||
|
||||
for (int i = 0; i < suggestions.size(); i++) {
|
||||
|
||||
Object csO = suggestions.get(i);
|
||||
|
||||
String suggestionAsString = getSuggestionFromEntry(csO);
|
||||
if (!filteredTabCompletionEvent.getCompletion().contains(suggestionAsString))
|
||||
suggestions.remove(csO);
|
||||
|
||||
}
|
||||
|
||||
suggestions.removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion().contains(getSuggestionFromEntry(suggestion)));
|
||||
suggestions.removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion()
|
||||
.contains(getSuggestionFromEntry(suggestion)));
|
||||
|
||||
}
|
||||
|
||||
if(!suggestions.isEmpty()) {
|
||||
if (!suggestions.isEmpty()) {
|
||||
|
||||
Object clientboundCommandSuggestionsPacketObj = clientboundCommandSuggestionsPacketClass
|
||||
.getConstructor(int.class, int.class, int.class, List.class)
|
||||
.newInstance(id, start, length, suggestions);
|
||||
|
||||
BukkitPacketAnalyzer.sendPacket(player.getUniqueId(), clientboundCommandSuggestionsPacketObj);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
|
||||
throwable.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return !cancelsBeforeHand;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (Reflection.isBefore(1, 17)) {
|
||||
Field suggestionsField = Reflection.getFieldsByType(packetObj.getClass(), "Suggestions", Reflection.SearchOption.ENDS).get(0);
|
||||
if (suggestionsField == null) return false;
|
||||
suggestionObj = suggestionsField.get(packetObj);
|
||||
} else {
|
||||
List<Method> methods = Reflection.getMethodsByReturnType(packetObj.getClass(), "Suggestions", Reflection.SearchOption.ENDS);
|
||||
|
||||
if (methods.isEmpty()) return false;
|
||||
Field suggestionsField = Reflection
|
||||
.getFieldsByType(packetObj.getClass(), "Suggestions", Reflection.SearchOption.ENDS).get(0);
|
||||
if (suggestionsField == null)
|
||||
return false;
|
||||
suggestionObj = suggestionsField.get(packetObj);
|
||||
|
||||
} else {
|
||||
|
||||
List<Method> methods = Reflection.getMethodsByReturnType(packetObj.getClass(), "Suggestions",
|
||||
Reflection.SearchOption.ENDS);
|
||||
|
||||
if (methods.isEmpty())
|
||||
return false;
|
||||
Method suggestionsMethod = methods.get(0);
|
||||
|
||||
if (suggestionsMethod == null)
|
||||
return false;
|
||||
|
||||
suggestionObj = suggestionsMethod.invoke(packetObj);
|
||||
|
||||
}
|
||||
|
||||
Suggestions suggestions = (Suggestions) suggestionObj;
|
||||
|
||||
if((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird()) {
|
||||
if ((input.isEmpty() || cancelsBeforeHand) && Reflection.isWeird()) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if(spaces >= 1 && cancelsBeforeHand) {
|
||||
if (spaces >= 1 && cancelsBeforeHand) {
|
||||
|
||||
suggestions.getList().clear();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if(spaces == 0) {
|
||||
if (spaces == 0) {
|
||||
|
||||
suggestions.getList().removeIf(suggestion -> {
|
||||
|
||||
String command = suggestion.getText();
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, isOperator);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command);
|
||||
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
for (Suggestion suggestion : suggestions.getList())
|
||||
suggestionsAsString.add(suggestion.getText());
|
||||
|
||||
suggestionsAsString = SubArgument.get().getTabCompleteHandler().handleTabCompletion(sender, rawInput, suggestionsAsString);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(sender, rawInput, suggestionsAsString);
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler
|
||||
.callFilteredTabCompletionEvents(player.getUniqueId(), rawInput, suggestionsAsString);
|
||||
|
||||
if (modifiable) {
|
||||
|
||||
@@ -221,42 +257,60 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
if (filteredTabCompletionEvent.isCancelled())
|
||||
suggestions.getList().clear();
|
||||
else
|
||||
suggestions.getList().removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion().contains(suggestion.getText()));
|
||||
suggestions.getList().removeIf(suggestion -> !filteredTabCompletionEvent.getCompletion()
|
||||
.contains(suggestion.getText()));
|
||||
|
||||
return !suggestions.getList().isEmpty();
|
||||
|
||||
} catch (UnsupportedOperationException exception) {
|
||||
|
||||
modifiable = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return handleUnmodifiableTabCompletion(player, packetObj, suggestions, filteredTabCompletionEvent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean handleUnmodifiableTabCompletion(Player player, Object packetObj, Suggestions suggestions, FilteredTabCompletionEvent filteredTabCompletionEvent) {
|
||||
private boolean handleUnmodifiableTabCompletion(Player player, Object packetObj, Suggestions suggestions,
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent)
|
||||
{
|
||||
|
||||
List<Suggestion> filteredSuggestionsList = new ArrayList<>();
|
||||
|
||||
if (!filteredTabCompletionEvent.isCancelled())
|
||||
for (Suggestion suggestion : suggestions.getList()) {
|
||||
|
||||
if (filteredTabCompletionEvent.getCompletion().contains(suggestion.getText())) {
|
||||
|
||||
filteredSuggestionsList.add(suggestion);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Suggestions filteredSuggestions = new Suggestions(suggestions.getRange(), filteredSuggestionsList);
|
||||
|
||||
try {
|
||||
|
||||
int val = -1;
|
||||
|
||||
Method method = Reflection.getMethodByName(packetObj.getClass(), "e");
|
||||
if (method != null) {
|
||||
|
||||
val = (int) method.invoke(packetObj);
|
||||
|
||||
}
|
||||
|
||||
if (val == -1) {
|
||||
|
||||
Logger.warning("Failed to read packet input!");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
Object packet = Reflection.getConstructor(packetObj.getClass(), int.class, Suggestions.class)
|
||||
@@ -265,25 +319,37 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
BukkitPacketAnalyzer.sendPacket(player.getUniqueId(), packet);
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private String getSuggestionFromEntry(Object suggestionObj) {
|
||||
|
||||
try {
|
||||
List<Field> fields = Reflection.getFieldsByTypeNormal(suggestionObj.getClass(), "String", Reflection.SearchOption.ENDS);
|
||||
if(fields.isEmpty()) return "";
|
||||
|
||||
List<Field> fields = Reflection.getFieldsByTypeNormal(suggestionObj.getClass(), "String",
|
||||
Reflection.SearchOption.ENDS);
|
||||
if (fields.isEmpty())
|
||||
return "";
|
||||
|
||||
Field field = fields.get(0);
|
||||
String result = (String) field.get(suggestionObj);
|
||||
field.setAccessible(false);
|
||||
return result;
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
|
||||
throwable.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+200
-73
@@ -1,20 +1,18 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.proxy;
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
@@ -23,6 +21,7 @@ import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
@@ -45,40 +44,56 @@ public class BungeePacketAnalyzer {
|
||||
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
|
||||
|
||||
private static Class<?> channelWrapperClass, serverConnectionClass;
|
||||
|
||||
private static List<String> PROXY_COMMANDS;
|
||||
|
||||
static {
|
||||
|
||||
ProxyCommandNodeHelper.setDefaultSuggestionProvider(Commands.SuggestionRegistry.ASK_SERVER);
|
||||
loadProxyCommands();
|
||||
|
||||
}
|
||||
|
||||
public static void loadProxyCommands() {
|
||||
|
||||
PROXY_COMMANDS = ProxyServer.getInstance().getPluginManager().getCommands().stream().map(entry -> {
|
||||
|
||||
String key = entry.getKey();
|
||||
return key.startsWith("/") ? key.substring(1) : key;
|
||||
|
||||
}).toList();
|
||||
|
||||
}
|
||||
|
||||
public static void injectAll() {
|
||||
|
||||
ProxyServer.getInstance().getPlayers().forEach(BungeePacketAnalyzer::inject);
|
||||
|
||||
}
|
||||
|
||||
public static void uninjectAll() {
|
||||
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.keySet().forEach(BungeePacketAnalyzer::uninject);
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.clear();
|
||||
|
||||
}
|
||||
|
||||
public static void setPluginCommands() {
|
||||
if(!PLUGIN_COMMANDS.isEmpty()) return;
|
||||
ProxyServer.getInstance().getPluginManager().getCommands().stream().filter(entry -> !PLUGIN_COMMANDS.contains(entry.getKey())).forEach(entry -> PLUGIN_COMMANDS.add(entry.getKey()));
|
||||
|
||||
if (!PLUGIN_COMMANDS.isEmpty())
|
||||
return;
|
||||
ProxyServer.getInstance().getPluginManager().getCommands().stream()
|
||||
.filter(entry -> !PLUGIN_COMMANDS.contains(entry.getKey()))
|
||||
.forEach(entry -> PLUGIN_COMMANDS.add(entry.getKey()));
|
||||
|
||||
}
|
||||
|
||||
public static boolean inject(ProxiedPlayer player) {
|
||||
|
||||
if(channelWrapperClass == null)
|
||||
if (channelWrapperClass == null)
|
||||
channelWrapperClass = Reflection.getClass("net.md_5.bungee.netty.ChannelWrapper");
|
||||
|
||||
if(serverConnectionClass == null)
|
||||
if (serverConnectionClass == null)
|
||||
serverConnectionClass = Reflection.getClass("net.md_5.bungee.ServerConnection");
|
||||
|
||||
Object channelWrapperObj;
|
||||
@@ -86,13 +101,17 @@ public class BungeePacketAnalyzer {
|
||||
Channel channel;
|
||||
|
||||
try {
|
||||
|
||||
channelField = Reflection.getFieldByName(serverConnectionClass, "ch");
|
||||
channelWrapperObj = channelField.get(player.getServer());
|
||||
channel = (Channel) Reflection.getFieldsByType(channelWrapperClass, "Channel", Reflection.SearchOption.ENDS).get(0).get(channelWrapperObj);
|
||||
channel = (Channel) Reflection.getFieldsByType(channelWrapperClass, "Channel", Reflection.SearchOption.ENDS)
|
||||
.get(0).get(channelWrapperObj);
|
||||
|
||||
if (channel == null) {
|
||||
|
||||
if(channel == null) {
|
||||
Logger.warning("Failed to inject " + player.getName() + "! Channel is null.");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
channelField.setAccessible(false);
|
||||
@@ -100,12 +119,16 @@ public class BungeePacketAnalyzer {
|
||||
if (channel.pipeline().names().contains(BungeePacketAnalyzer.HANDLER_NAME))
|
||||
uninject(player);
|
||||
|
||||
channel.pipeline().addAfter(BungeePacketAnalyzer.PIPELINE_NAME, BungeePacketAnalyzer.HANDLER_NAME, new PacketDecoder(player));
|
||||
channel.pipeline().addAfter(BungeePacketAnalyzer.PIPELINE_NAME, BungeePacketAnalyzer.HANDLER_NAME,
|
||||
new PacketDecoder(player));
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -113,75 +136,102 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static void uninject(ProxiedPlayer player) {
|
||||
|
||||
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player.getUniqueId());
|
||||
BungeePacketAnalyzer.PLAYER_MODIFIED.remove(player);
|
||||
|
||||
if(BungeePacketAnalyzer.INJECTED_PLAYERS.containsKey(player)) {
|
||||
if (BungeePacketAnalyzer.INJECTED_PLAYERS.containsKey(player)) {
|
||||
|
||||
Channel channel = BungeePacketAnalyzer.INJECTED_PLAYERS.get(player);
|
||||
if(channel != null) {
|
||||
if (channel != null) {
|
||||
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.remove(player);
|
||||
channel.eventLoop().submit(() -> {
|
||||
|
||||
ChannelPipeline pipeline = channel.pipeline();
|
||||
|
||||
if (pipeline.names().contains(BungeePacketAnalyzer.HANDLER_NAME))
|
||||
pipeline.remove(BungeePacketAnalyzer.HANDLER_NAME);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void setPlayerInput(ProxiedPlayer player, String input) {
|
||||
|
||||
PLAYER_INPUT_CACHE.putIgnoreIfContains(player.getUniqueId(), input);
|
||||
|
||||
}
|
||||
|
||||
public static String getPlayerInput(ProxiedPlayer player) {
|
||||
|
||||
String input = PLAYER_INPUT_CACHE.get(player.getUniqueId());
|
||||
PLAYER_INPUT_CACHE.remove(player.getUniqueId());
|
||||
return input;
|
||||
|
||||
}
|
||||
|
||||
private static void modifyCommands(ProxiedPlayer player, CommandSender sender, Commands commands) {
|
||||
|
||||
String serverName = sender.getServerName();
|
||||
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(sender, false) || Storage.Blacklist.isDisabledServer(serverName);
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(sender)
|
||||
|| Storage.Blacklist.isDisabledServer(serverName);
|
||||
|
||||
final ProxyCommandNodeHelper helper = new ProxyCommandNodeHelper<CommandNode>(commands.getRoot());
|
||||
final List<String> commandsAsString = new ArrayList<>(PROXY_COMMANDS);
|
||||
ProxyCommandNodeHelper helper = new ProxyCommandNodeHelper<CommandNode>(commands.getRoot());
|
||||
|
||||
List<String> commandsAsString = new ArrayList<>(PROXY_COMMANDS);
|
||||
commandsAsString.addAll(helper.getChildrenNames());
|
||||
|
||||
final List<Group> groups = ignore
|
||||
? Collections.emptyList()
|
||||
: GroupManager.getPlayerGroups(sender, false);
|
||||
|
||||
HashSet<String> playerCommands = new HashSet<>();
|
||||
List<String> playerCommands = new ArrayList<>();
|
||||
|
||||
if (!ignore) {
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
|
||||
cache.put(serverName, new CommandsCache());
|
||||
|
||||
}
|
||||
|
||||
final CommandsCache commandsCache = cache.get(serverName);
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
final HashSet<String> tmpPlayerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName, false);
|
||||
final List<String> tmpPlayerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups,
|
||||
serverName);
|
||||
|
||||
if (commands.getRoot().getChildren().size() != 0) {
|
||||
|
||||
helper.removeIf(str -> !tmpPlayerCommands.contains(str));
|
||||
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines()
|
||||
.forEach(input -> helper.add(input, false));
|
||||
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines()
|
||||
.forEach(input -> helper.add(input, false));
|
||||
|
||||
}
|
||||
|
||||
playerCommands = tmpPlayerCommands;
|
||||
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Command> command : ProxyServer.getInstance().getPluginManager().getCommands()) {
|
||||
@@ -193,64 +243,76 @@ public class BungeePacketAnalyzer {
|
||||
continue;
|
||||
|
||||
if (!command.getValue().hasPermission(player)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
String commandName = command.getKey();
|
||||
commandName = commandName.startsWith("/") ? commandName.substring(1) : commandName;
|
||||
|
||||
if (!ignore) {
|
||||
boolean tabablePluginCommand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(commandName);
|
||||
boolean tabableVersionCommand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(commandName);
|
||||
|
||||
boolean tabablePluginCommand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN
|
||||
.isTabCompletable(commandName);
|
||||
boolean tabableVersionCommand = Storage.ConfigSections.Settings.CUSTOM_VERSION
|
||||
.isTabCompletable(commandName);
|
||||
|
||||
if (!tabablePluginCommand && !tabableVersionCommand && !playerCommands.contains(commandName)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CommandNode dummy = ProxyCommandNodeHelper.createDummyCommandNode(command.getKey());
|
||||
commands.getRoot().addChild(dummy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (String command : PROXY_COMMANDS) {
|
||||
if (ignore || playerCommands.contains(command)) {
|
||||
helper.add(command, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.TAB_COMPLETION_FOR_NOT_EXISTING_COMMANDS.ENABLED) {
|
||||
for (Group group : groups) {
|
||||
for (String groupCommands : group.getAllCommands(serverName)) {
|
||||
helper.add(groupCommands, true);
|
||||
}
|
||||
if (ignore || playerCommands.contains(command)) {
|
||||
|
||||
helper.add(command, true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!ignore) {
|
||||
SubArgument.get().getCommandNodeHandler().handleCommandNode(helper, SubArgument.get().getPlayerArgument(sender));
|
||||
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void sendCommandsPacket() {
|
||||
|
||||
if (!Communicator.get().hasConnectedClients()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||
|
||||
if (player.getPendingConnection().getVersion() < 754)
|
||||
continue;
|
||||
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
RootCommandNode root = new RootCommandNode();
|
||||
Commands packet = new Commands(root);
|
||||
|
||||
modifyCommands(player, sender, packet);
|
||||
player.unsafe().sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class PacketDecoder extends MessageToMessageDecoder<PacketWrapper> {
|
||||
|
||||
@@ -258,57 +320,122 @@ public class BungeePacketAnalyzer {
|
||||
private final CommandSender sender;
|
||||
|
||||
private PacketDecoder(ProxiedPlayer player) {
|
||||
|
||||
this.player = player;
|
||||
this.sender = CommandSender.from(player);
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext channelHandlerContext, PacketWrapper wrapper, List<Object> list) {
|
||||
|
||||
if (wrapper.packet == null) {
|
||||
|
||||
list.add(wrapper);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (wrapper.packet instanceof PluginMessage) {
|
||||
|
||||
PluginMessage pluginMessage = (PluginMessage) wrapper.packet;
|
||||
|
||||
if (CustomServerBrand.get().isEnabled() && CustomServerBrand.get().isBrandTag(pluginMessage.getTag())) {
|
||||
if (CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessage.getTag()))
|
||||
return;
|
||||
} else if (Storage.ConfigSections.Settings.HIDE_PLUGIN_CHANNELS.ENABLED) {
|
||||
final String channelId = pluginMessage.getTag();
|
||||
|
||||
if (Storage.ConfigSections.Settings.HIDE_PLUGIN_CHANNELS.isRegisterChannel(channelId)) {
|
||||
final String dataStr = new String(pluginMessage.getData(), StandardCharsets.UTF_8);
|
||||
final String[] channels = dataStr.split("\u0000");
|
||||
} else if (wrapper.packet instanceof Commands) {
|
||||
|
||||
final List<String> filteredChannels = new ArrayList<>(Arrays.asList(channels));
|
||||
final AtomicBoolean changedAnything = new AtomicBoolean(false);
|
||||
|
||||
filteredChannels.removeIf(channel -> {
|
||||
if (!Storage.ConfigSections.Settings.HIDE_PLUGIN_CHANNELS.WHITELISTED_CHANNELS.getLines().contains(channel)) {
|
||||
changedAnything.set(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (changedAnything.get()) {
|
||||
pluginMessage.setData(String.join("\u0000", filteredChannels).getBytes());
|
||||
player.unsafe().sendPacket(pluginMessage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (wrapper.packet instanceof Commands response) {
|
||||
Commands response = (Commands) wrapper.packet;
|
||||
modifyCommands(player, sender, response);
|
||||
player.unsafe().sendPacket(response);
|
||||
|
||||
player.unsafe().sendPacket(response);
|
||||
return;
|
||||
|
||||
/*
|
||||
* } else if (wrapper.packet instanceof TabCompleteResponse) {
|
||||
* TabCompleteResponse response = (TabCompleteResponse) wrapper.packet; String
|
||||
* serverName = player.getServer().getInfo().getName();
|
||||
*
|
||||
* System.out.println("damn");
|
||||
*
|
||||
* if (!Storage.Blacklist.isDisabledServer(serverName) &&
|
||||
* player.getPendingConnection().getVersion() < 754) { if
|
||||
* (!PermissionUtil.hasBypassPermission(player)) {
|
||||
*
|
||||
* System.out.println("Further!"); System.out.println("Got: " +
|
||||
* PLAYER_INPUT_CACHE.get(player.getUniqueId()));
|
||||
*
|
||||
* if (!PLAYER_INPUT_CACHE.contains(player.getUniqueId())) return;
|
||||
*
|
||||
* boolean cancelsBeforeHand = false;
|
||||
*
|
||||
* String rawPlayerInput = PLAYER_INPUT_CACHE.get(player.getUniqueId()); int
|
||||
* spaces = rawPlayerInput.contains(" ") ? rawPlayerInput.split(" ").length : 0;
|
||||
*
|
||||
* String playerInput = StringUtils.getFirstArg(rawPlayerInput), server =
|
||||
* player.getServer().getInfo().getName();
|
||||
*
|
||||
* System.out.println("NETTY -> " + playerInput);
|
||||
*
|
||||
* if (!playerInput.equals("/")) { cancelsBeforeHand =
|
||||
* !Storage.Blacklist.canPlayerAccessTab(player,
|
||||
* StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
*
|
||||
* if (!cancelsBeforeHand) cancelsBeforeHand =
|
||||
* !Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.
|
||||
* replaceFirst(playerInput, "/", "")) ||
|
||||
* Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.
|
||||
* replaceFirst(playerInput, "/", "")); }
|
||||
*
|
||||
* final String cursor = playerInput;
|
||||
*
|
||||
* if (cursor.startsWith("/")) { if (spaces == 0) { List<String> suggestions =
|
||||
* new ArrayList<>(response.getCommands());
|
||||
*
|
||||
* if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
* setPluginCommands();
|
||||
*
|
||||
* Storage.Blacklist.getServerBlacklists(server).forEach(blacklist ->
|
||||
* blacklist.getCommands().stream().filter(command -> !suggestions.contains("/"
|
||||
* + command)).forEach(command -> { if
|
||||
* (BungeePacketAnalyzer.PLUGIN_COMMANDS.contains(command)) suggestions.add("/"
|
||||
* + command); }));
|
||||
*
|
||||
* BungeePacketAnalyzer.PLUGIN_COMMANDS.stream().filter(command ->
|
||||
* !suggestions.contains(command)).forEach(command -> { if
|
||||
* (command.startsWith("/")) command = StringUtils.replaceFirst(command, "/",
|
||||
* "");
|
||||
*
|
||||
* if (Storage.Blacklist.canPlayerAccessTab(player, command, server)) {
|
||||
* suggestions.add("/" + command); } });
|
||||
*
|
||||
* suggestions.stream().filter(suggestion -> suggestion.startsWith(cursor) &&
|
||||
* !response.getCommands().contains(suggestion)).forEach(command ->
|
||||
* response.getCommands().add(command));
|
||||
*
|
||||
* } else { BungeePacketAnalyzer.PLUGIN_COMMANDS.stream().filter(command ->
|
||||
* !suggestions.contains(command)).forEach(suggestions::add);
|
||||
*
|
||||
* suggestions.removeIf(command -> { if (command.startsWith("/")) command =
|
||||
* StringUtils.replaceFirst(command, "/", "");
|
||||
*
|
||||
* return !Storage.Blacklist.canPlayerAccessTab(player, command, server); });
|
||||
*
|
||||
* response.getCommands().clear(); suggestions.forEach(command ->
|
||||
* response.getCommands().add(command)); }
|
||||
*
|
||||
* if (response.getCommands().isEmpty()) return;
|
||||
*
|
||||
* } else { if (cancelsBeforeHand) return; }
|
||||
*
|
||||
* player.unsafe().sendPacket(new TabCompleteResponse(response.getCommands()));
|
||||
* } } }
|
||||
*/
|
||||
}
|
||||
|
||||
list.add(wrapper);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+283
-147
@@ -1,38 +1,38 @@
|
||||
package de.rayzs.pat.plugin.packetanalyzer.proxy;
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.*;
|
||||
import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteRequestPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.TabCompleteResponsePacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.chat.session.UnsignedPlayerCommandPacket;
|
||||
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.plugin.listeners.velocity.VelocityBlockCommandListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.message.MessageHelper;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -42,26 +42,38 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class VelocityPacketAnalyzer {
|
||||
|
||||
private static boolean FAILED = false;
|
||||
|
||||
static {
|
||||
|
||||
try {
|
||||
|
||||
final String name = "minecraft:ask_server";
|
||||
|
||||
final Object availableCommandsPacket = AvailableCommandsPacket.class.newInstance();
|
||||
final Class<?> packetInstanceObjClass = availableCommandsPacket.getClass();
|
||||
|
||||
for (Class<?> clazz : packetInstanceObjClass.getClasses()) {
|
||||
|
||||
if (clazz.getSimpleName().equals("ProtocolSuggestionProvider")) {
|
||||
|
||||
final Object suggestionProviderObj = clazz.getConstructor(String.class).newInstance(name);
|
||||
final SuggestionProvider<?> suggestionProvider = (SuggestionProvider<?>) suggestionProviderObj;
|
||||
|
||||
ProxyCommandNodeHelper.setDefaultSuggestionProvider(suggestionProvider);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
exception.printStackTrace();
|
||||
FAILED = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final ConcurrentHashMap<Player, Channel> INJECTED_PLAYERS = new ConcurrentHashMap<>();
|
||||
@@ -72,218 +84,220 @@ public class VelocityPacketAnalyzer {
|
||||
private static Class<?> minecraftConnectionClass, connectedPlayerConnectionClass, signedChatCommandPacketClass;
|
||||
|
||||
public static void injectAll() {
|
||||
|
||||
VelocityLoader.getServer().getAllPlayers().forEach(VelocityPacketAnalyzer::inject);
|
||||
|
||||
}
|
||||
|
||||
public static void uninjectAll() {
|
||||
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.keySet().forEach(VelocityPacketAnalyzer::uninject);
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.clear();
|
||||
|
||||
}
|
||||
|
||||
public static boolean isInjected(Player player) {
|
||||
|
||||
return INJECTED_PLAYERS.containsKey(player);
|
||||
|
||||
}
|
||||
|
||||
public static boolean inject(Player player) {
|
||||
|
||||
if (connectedPlayerConnectionClass == null) {
|
||||
connectedPlayerConnectionClass = Reflection.getClass("com.velocitypowered.proxy.connection.client.ConnectedPlayer");
|
||||
}
|
||||
if (connectedPlayerConnectionClass == null)
|
||||
connectedPlayerConnectionClass = Reflection
|
||||
.getClass("com.velocitypowered.proxy.connection.client.ConnectedPlayer");
|
||||
|
||||
if (minecraftConnectionClass == null) {
|
||||
if (minecraftConnectionClass == null)
|
||||
minecraftConnectionClass = Reflection.getClass("com.velocitypowered.proxy.connection.MinecraftConnection");
|
||||
}
|
||||
|
||||
Channel channel;
|
||||
|
||||
try {
|
||||
final Object connectedPlayerObj = connectedPlayerConnectionClass.cast(player);
|
||||
final Object minecraftConnectionObj = Reflection.getMethodsByName(connectedPlayerConnectionClass, "getConnection")
|
||||
.get(0).invoke(connectedPlayerObj);
|
||||
|
||||
Object connectedPlayerObj = connectedPlayerConnectionClass.cast(player), minecraftConnectionObj = Reflection
|
||||
.getMethodsByName(connectedPlayerConnectionClass, "getConnection").get(0)
|
||||
.invoke(connectedPlayerObj);
|
||||
|
||||
final Channel channel = (Channel) Reflection.getMethodsByName(minecraftConnectionClass, "getChannel").get(0).invoke(minecraftConnectionObj);
|
||||
channel = (Channel) Reflection.getMethodsByName(minecraftConnectionClass, "getChannel").get(0)
|
||||
.invoke(minecraftConnectionObj);
|
||||
|
||||
if (channel == null) {
|
||||
|
||||
Logger.warning("Failed to inject " + player.getUsername() + "! Channel is null.");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if (channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME)) {
|
||||
if (channel.pipeline().names().contains(VelocityPacketAnalyzer.PIPELINE_NAME))
|
||||
uninject(player);
|
||||
}
|
||||
|
||||
|
||||
channel.pipeline().addBefore(
|
||||
VelocityPacketAnalyzer.HANDLER_NAME,
|
||||
VelocityPacketAnalyzer.PIPELINE_NAME,
|
||||
new PacketDecoder(player)
|
||||
);
|
||||
|
||||
channel.pipeline().addBefore(VelocityPacketAnalyzer.HANDLER_NAME, VelocityPacketAnalyzer.PIPELINE_NAME,
|
||||
new PacketDecoder(player));
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
|
||||
|
||||
} catch (NoSuchElementException noSuchElementException) {
|
||||
Logger.warning("Failed to find 'handler' inside player pipeline! (name=" + player.getUsername() + ", uuid=" + player.getUniqueId() + ", version=" + player.getProtocolVersion() + ", brand=" + player.getClientBrand() + " )");
|
||||
} catch (NoSuchElementException e) {
|
||||
|
||||
Logger.warning("Failed to find 'handler' inside player pipeline! (name=" + player.getUsername() + ", uuid="
|
||||
+ player.getUniqueId() + ", version=" + player.getProtocolVersion() + ", brand="
|
||||
+ player.getClientBrand() + " )");
|
||||
return false;
|
||||
|
||||
} catch (Exception exception) {
|
||||
|
||||
if (!Storage.ConfigSections.Settings.INJECTION_FAILED.SUPPRESS_EXCEPTIONS) {
|
||||
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static void uninject(Player player) {
|
||||
|
||||
VelocityPacketAnalyzer.PLAYER_INPUT_CACHE.remove(player);
|
||||
|
||||
final Channel channel = VelocityPacketAnalyzer.INJECTED_PLAYERS.get(player);
|
||||
if (VelocityPacketAnalyzer.INJECTED_PLAYERS.containsKey(player)) {
|
||||
|
||||
Channel channel = VelocityPacketAnalyzer.INJECTED_PLAYERS.get(player);
|
||||
if (channel != null) {
|
||||
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.remove(player);
|
||||
channel.eventLoop().submit(() -> {
|
||||
|
||||
ChannelPipeline pipeline = channel.pipeline();
|
||||
if (pipeline.names().contains(VelocityPacketAnalyzer.PIPELINE_NAME))
|
||||
pipeline.remove(VelocityPacketAnalyzer.PIPELINE_NAME);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (channel == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
VelocityPacketAnalyzer.INJECTED_PLAYERS.remove(player);
|
||||
|
||||
channel.eventLoop().submit(() -> {
|
||||
final ChannelPipeline pipeline = channel.pipeline();
|
||||
|
||||
if (pipeline.names().contains(VelocityPacketAnalyzer.PIPELINE_NAME)) {
|
||||
pipeline.remove(VelocityPacketAnalyzer.PIPELINE_NAME);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static String getPlayerInput(Player player) {
|
||||
|
||||
String input = PLAYER_INPUT_CACHE.get(player);
|
||||
PLAYER_INPUT_CACHE.remove(player);
|
||||
return input;
|
||||
|
||||
}
|
||||
|
||||
public static void insertPlayerInput(Player player, String text) {
|
||||
|
||||
PLAYER_INPUT_CACHE.put(player, text.toLowerCase());
|
||||
|
||||
}
|
||||
|
||||
private static void modifyCommands(Player player, CommandSender sender, AvailableCommandsPacket commands) {
|
||||
|
||||
if (commands.getRootNode().getChildren().size() == 1
|
||||
&& player.getProtocolVersion().getProtocol() > 340
|
||||
if (commands.getRootNode().getChildren().size() == 1 && player.getProtocolVersion().getProtocol() > 340
|
||||
&& commands.getRootNode().getChild("args") != null
|
||||
&& commands.getRootNode().getChild("args").getChildren().isEmpty()) {
|
||||
&& commands.getRootNode().getChild("args").getChildren().isEmpty())
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
String serverName = sender.getServerName();
|
||||
|
||||
final String serverName = sender.getServerName();
|
||||
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(sender, false) || Storage.Blacklist.isDisabledServer(serverName);
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(sender)
|
||||
|| Storage.Blacklist.isDisabledServer(serverName);
|
||||
final ProxyCommandNodeHelper<CommandSource> helper = new ProxyCommandNodeHelper<>(commands.getRootNode());
|
||||
|
||||
final List<String> commandsAsString = new ArrayList<>();
|
||||
commandsAsString.addAll(helper.getChildrenNames());
|
||||
|
||||
if (ignore) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender, false);
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
|
||||
cache.put(serverName, new CommandsCache());
|
||||
|
||||
}
|
||||
|
||||
final CommandsCache commandsCache = cache.get(serverName);
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
final HashSet<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName, false);
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups,
|
||||
serverName);
|
||||
helper.removeIf(str -> {
|
||||
|
||||
if (str.equals("args")) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return !playerCommands.contains(str);
|
||||
|
||||
});
|
||||
|
||||
if (Storage.ConfigSections.Settings.TAB_COMPLETION_FOR_NOT_EXISTING_COMMANDS.ENABLED) {
|
||||
for (Group group : groups) {
|
||||
for (String groupServerName : group.getBlacklistServerNames(serverName)) {
|
||||
if (Storage.isServer(groupServerName, serverName)) {
|
||||
for (String groupCommands : group.getAllCommands(groupServerName)) {
|
||||
helper.add(groupCommands, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines()
|
||||
.forEach(input -> helper.add(input, false));
|
||||
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines()
|
||||
.forEach(input -> helper.add(input, false));
|
||||
|
||||
}
|
||||
|
||||
SubArgument.get().getCommandNodeHandler().handleCommandNode(helper, SubArgument.get().getPlayerArgument(sender));
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
|
||||
}
|
||||
|
||||
private static void handlePluginMessageChannelsPacket(final PluginMessagePacket packet) {
|
||||
final String channelId = packet.getChannel();
|
||||
|
||||
if (Storage.ConfigSections.Settings.HIDE_PLUGIN_CHANNELS.isRegisterChannel(channelId)) {
|
||||
final ByteBuf buf = packet.content();
|
||||
final byte[] data = new byte[buf.readableBytes()];
|
||||
buf.getBytes(buf.readerIndex(), data);
|
||||
|
||||
final String dataStr = new String(data, StandardCharsets.UTF_8);
|
||||
final String[] channels = dataStr.split("\u0000");
|
||||
|
||||
final List<String> filteredChannels = new ArrayList<>(Arrays.asList(channels));
|
||||
final AtomicBoolean changedAnything = new AtomicBoolean(false);
|
||||
|
||||
filteredChannels.removeIf(channel -> {
|
||||
if (!Storage.ConfigSections.Settings.HIDE_PLUGIN_CHANNELS.WHITELISTED_CHANNELS.getLines().contains(channel)) {
|
||||
changedAnything.set(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (changedAnything.get()) {
|
||||
final ByteBuf newBuf = Unpooled.wrappedBuffer(String.join("\u0000", filteredChannels).getBytes());
|
||||
packet.replace(newBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class PacketDecoder extends ChannelDuplexHandler {
|
||||
|
||||
private final Player player;
|
||||
private final CommandSender sender;
|
||||
|
||||
private PacketDecoder(Player player) {
|
||||
|
||||
this.player = player;
|
||||
this.sender = CommandSender.from(player);
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (!(msg instanceof MinecraftPacket packet)) {
|
||||
|
||||
if (!(msg instanceof MinecraftPacket)) {
|
||||
|
||||
super.channelRead(ctx, msg);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
MinecraftPacket packet = (MinecraftPacket) msg;
|
||||
|
||||
if (packet.getClass().getSimpleName().equals("SignedChatCommand")) {
|
||||
|
||||
try {
|
||||
if (signedChatCommandPacketClass == null) {
|
||||
signedChatCommandPacketClass = Class.forName("com.velocitypowered.proxy.crypto.SignedChatCommand");
|
||||
}
|
||||
|
||||
if (signedChatCommandPacketClass == null)
|
||||
signedChatCommandPacketClass = Class
|
||||
.forName("com.velocitypowered.proxy.crypto.SignedChatCommand");
|
||||
|
||||
Object signedChatCommandPacket = signedChatCommandPacketClass.cast(packet);
|
||||
Field commandField = signedChatCommandPacket.getClass().getField("command");
|
||||
@@ -293,50 +307,70 @@ public class VelocityPacketAnalyzer {
|
||||
return;
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (packet instanceof PluginMessagePacket pluginMessagePacket && Storage.ConfigSections.Settings.HIDE_PLUGIN_CHANNELS.ENABLED) {
|
||||
handlePluginMessageChannelsPacket(pluginMessagePacket);
|
||||
exception.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (packet instanceof UnsignedPlayerCommandPacket unsignedPlayerCommandPacket) {
|
||||
if (!VelocityBlockCommandListener.handleCommand(player, unsignedPlayerCommandPacket.getCommand()).getResult().isAllowed())
|
||||
|
||||
if (!VelocityBlockCommandListener.handleCommand(player, unsignedPlayerCommandPacket.getCommand())
|
||||
.getResult().isAllowed())
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (packet instanceof TabCompleteRequestPacket request) {
|
||||
|
||||
if (request.getCommand() != null) {
|
||||
|
||||
if (Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(request.getCommand())) {
|
||||
MessageHelper.sendMessage(CommandSender.from(VelocityLoader.getServer().getConsoleCommandSource()), Storage.ConfigSections.Settings.PATCH_EXPLOITS.ALERT_MESSAGE.get().replace("%player%", player.getUsername()));
|
||||
player.disconnect(LegacyComponentSerializer.legacyAmpersand().deserialize(Storage.ConfigSections.Settings.PATCH_EXPLOITS.KICK_MESSAGE.get()));
|
||||
|
||||
MessageTranslator.send(VelocityLoader.getServer().getConsoleCommandSource(),
|
||||
Storage.ConfigSections.Settings.PATCH_EXPLOITS.ALERT_MESSAGE.get().replace("%player%",
|
||||
player.getUsername()));
|
||||
player.disconnect(LegacyComponentSerializer.legacyAmpersand()
|
||||
.deserialize(Storage.ConfigSections.Settings.PATCH_EXPLOITS.KICK_MESSAGE.get()));
|
||||
|
||||
} else {
|
||||
|
||||
insertPlayerInput(player, request.getCommand());
|
||||
super.channelRead(ctx, msg);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} else super.channelRead(ctx, msg);
|
||||
|
||||
} else
|
||||
super.channelRead(ctx, msg);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
|
||||
if (!(msg instanceof MinecraftPacket)) {
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
MinecraftPacket packet = (MinecraftPacket) msg;
|
||||
|
||||
if (packet instanceof PluginMessagePacket pluginMessagePacket) {
|
||||
if (CustomServerBrand.get().isEnabled() && CustomServerBrand.get().isBrandTag(pluginMessagePacket.getChannel()) && !player.getCurrentServer().isPresent()) {
|
||||
final PacketUtils.BrandManipulate brandManipulatePacket = CustomServerBrand.get().createBrandPacket(player);
|
||||
|
||||
super.write(ctx, new PluginMessagePacket(pluginMessagePacket.getChannel(), brandManipulatePacket.getByteBuf()), promise);
|
||||
if (CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessagePacket.getChannel())
|
||||
&& !player.getCurrentServer().isPresent())
|
||||
{
|
||||
|
||||
PacketUtils.BrandManipulate brandManipulatePacket = CustomServerBrand.createBrandPacket(player);
|
||||
super.write(ctx, new PluginMessagePacket(pluginMessagePacket.getChannel(),
|
||||
brandManipulatePacket.getByteBuf()), promise);
|
||||
return;
|
||||
} else if (Storage.ConfigSections.Settings.HIDE_PLUGIN_CHANNELS.ENABLED) {
|
||||
handlePluginMessageChannelsPacket(pluginMessagePacket);
|
||||
|
||||
}
|
||||
|
||||
} else if (packet instanceof TabCompleteResponsePacket response) {
|
||||
@@ -344,95 +378,197 @@ public class VelocityPacketAnalyzer {
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(sender, false) && player.getCurrentServer().isPresent()) {
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender, false);
|
||||
if (!PermissionUtil.hasBypassPermission(sender) && player.getCurrentServer().isPresent()) {
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
String playerInput = getPlayerInput(player), rawPlayerInput = playerInput, server = player.getCurrentServer().get().getServerInfo().getName();
|
||||
String playerInput = getPlayerInput(player), rawPlayerInput = playerInput,
|
||||
server = player.getCurrentServer().get().getServerInfo().getName();
|
||||
int spaces = 0;
|
||||
|
||||
if (playerInput.contains(" ")) {
|
||||
|
||||
String[] split = playerInput.split(" ");
|
||||
spaces = split.length;
|
||||
if (spaces > 0) playerInput = split[0];
|
||||
if (spaces > 0)
|
||||
playerInput = split[0];
|
||||
|
||||
}
|
||||
|
||||
if (!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.replaceFirst(playerInput, "/", ""), server, false);
|
||||
|
||||
if (!cancelsBeforeHand) {
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups,
|
||||
StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
|
||||
if (!cancelsBeforeHand)
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION
|
||||
.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""))
|
||||
|| Storage.ConfigSections.Settings.CUSTOM_PLUGIN
|
||||
.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
|
||||
}
|
||||
|
||||
final String cursor = playerInput;
|
||||
|
||||
if (!cursor.startsWith("/") && spaces < 2 && player.getProtocolVersion().getProtocol() >= 754) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (cursor.startsWith("/")) {
|
||||
|
||||
if (spaces == 0) {
|
||||
response.getOffers().removeIf(offer -> {
|
||||
String command = offer.getText();
|
||||
if (command.startsWith("/")) command = StringUtils.replaceFirst(command, "/", "");
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command)) {
|
||||
response.getOffers().removeIf(offer -> {
|
||||
|
||||
String command = offer.getText();
|
||||
if (command.startsWith("/"))
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command)
|
||||
|| Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command))
|
||||
{
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, player.getCurrentServer().get().getServerInfo().getName(), false);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command,
|
||||
player.getCurrentServer().get().getServerInfo().getName());
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
if (cancelsBeforeHand) {
|
||||
if (cancelsBeforeHand)
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> suggestionsAsString = new ArrayList<>();
|
||||
List<String> suggestionsAsString = new ArrayList<>();
|
||||
|
||||
response.getOffers().forEach(offer -> suggestionsAsString.add(offer.getText()));
|
||||
|
||||
final FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(
|
||||
sender,
|
||||
rawPlayerInput,
|
||||
SubArgument.get().getTabCompleteHandler().handleTabCompletion(
|
||||
sender,
|
||||
rawPlayerInput,
|
||||
suggestionsAsString
|
||||
)
|
||||
);
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler
|
||||
.callFilteredTabCompletionEvents(player.getUniqueId(), rawPlayerInput,
|
||||
suggestionsAsString);
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
response.getOffers().removeIf(offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
|
||||
response.getOffers().removeIf(
|
||||
offer -> !filteredTabCompletionEvent.getCompletion().contains(offer.getText()));
|
||||
|
||||
if (response.getOffers().isEmpty()) {
|
||||
if (response.getOffers().isEmpty())
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (packet instanceof AvailableCommandsPacket commands) {
|
||||
|
||||
if (player.getCurrentServer().isPresent()) {
|
||||
modifyCommands(player, sender, commands);
|
||||
super.write(ctx, msg, promise);
|
||||
|
||||
return;
|
||||
if (!FAILED) {
|
||||
|
||||
modifyCommands(player, sender, commands);
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
if (!commands.getRootNode().getChildren().isEmpty()) {
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName))
|
||||
cache.put(serverName, new CommandsCache());
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
|
||||
List<String> commandsAsString = new ArrayList<>();
|
||||
commands.getRootNode().getChildren().stream()
|
||||
.filter(command -> command != null && command.getName() != null)
|
||||
.forEach(command -> commandsAsString.add(command.getName()));
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player))
|
||||
return;
|
||||
|
||||
final boolean newer = player.getProtocolVersion().getProtocol() > 340;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender,
|
||||
groups, serverName);
|
||||
|
||||
if (commands.getRootNode().getChildren().size() == 1 && newer
|
||||
&& commands.getRootNode().getChild("args") != null
|
||||
&& commands.getRootNode().getChild("args").getChildren().isEmpty())
|
||||
{
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
commands.getRootNode().getChildren().removeIf(command -> {
|
||||
|
||||
if (command == null || command.getName() == null)
|
||||
return true;
|
||||
|
||||
if (command.getName().equals("args"))
|
||||
return false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName())
|
||||
|| Storage.ConfigSections.Settings.CUSTOM_VERSION
|
||||
.isTabCompletable(command.getName()))
|
||||
{
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return !playerCommands.contains(command.getName());
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
super.write(ctx, msg, promise);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -9,31 +9,47 @@ public abstract class StorageTemplate implements Serializable {
|
||||
private final ConfigurationBuilder configuration;
|
||||
|
||||
public StorageTemplate(ConfigurationBuilder configuration, String navigatePath) {
|
||||
|
||||
this.navigatePath = navigatePath;
|
||||
this.configuration = configuration;
|
||||
this.load();
|
||||
|
||||
}
|
||||
|
||||
public StorageTemplate setIfEmpty(String target, Object obj) {
|
||||
|
||||
configuration.getOrSet(target, obj);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public StorageTemplate set(String target, Object obj) {
|
||||
|
||||
configuration.setAndSave(target, obj);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public Object get(String target, Object obj) {
|
||||
|
||||
configuration.getOrSet(target, obj);
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public ConfigurationBuilder getConfig() {
|
||||
|
||||
return configuration;
|
||||
|
||||
}
|
||||
|
||||
public String getNavigatePath() {
|
||||
|
||||
return navigatePath;
|
||||
|
||||
}
|
||||
public String getNavigatePath() { return navigatePath; }
|
||||
|
||||
public abstract void save();
|
||||
public abstract void load();
|
||||
|
||||
}
|
||||
@@ -6,31 +6,44 @@ import de.rayzs.pat.api.storage.Storage;
|
||||
public class BlacklistCreator {
|
||||
|
||||
public static GeneralBlacklist createGeneralBlacklist() {
|
||||
|
||||
return new GeneralBlacklist("commands");
|
||||
|
||||
}
|
||||
|
||||
public static GeneralBlacklist createGeneralBlacklist(String server) {
|
||||
|
||||
return new GeneralBlacklist("servers." + server + ".commands");
|
||||
|
||||
}
|
||||
|
||||
public static GroupBlacklist createGroupBlacklist(String group) {
|
||||
|
||||
return new GroupBlacklist(group, "commands");
|
||||
|
||||
}
|
||||
|
||||
public static GroupBlacklist createGroupBlacklist(String group, String server, boolean ignoreExist) {
|
||||
|
||||
if (!exist(group, server) && !ignoreExist)
|
||||
return null;
|
||||
|
||||
return new GroupBlacklist(group, "servers." + server + ".commands");
|
||||
|
||||
}
|
||||
|
||||
public static boolean exist(String server) {
|
||||
|
||||
Object obj = Storage.Blacklist.getBlacklist().getConfig().get("global.servers." + server);
|
||||
return obj != null;
|
||||
|
||||
}
|
||||
|
||||
public static boolean exist(String group, String server) {
|
||||
|
||||
Object obj = Storage.Blacklist.getBlacklist().getConfig().get("groups." + group + ".servers." + server);
|
||||
return obj != null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,55 +6,80 @@ import java.util.List;
|
||||
|
||||
public class GeneralBlacklist extends BlacklistStorage {
|
||||
|
||||
public GeneralBlacklist(String navigatePath) { super("global." + navigatePath); }
|
||||
public GeneralBlacklist(String navigatePath) {
|
||||
|
||||
super("global." + navigatePath);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommands() {
|
||||
|
||||
return super.getCommands();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlacklistStorage add(String command) {
|
||||
|
||||
return super.add(command);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlacklistStorage remove(String command) {
|
||||
|
||||
return super.remove(command);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlacklistStorage clear() {
|
||||
|
||||
return super.clear();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageTemplate setIfEmpty(String target, Object obj) {
|
||||
|
||||
return super.setIfEmpty(target, obj);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageTemplate set(String target, Object obj) {
|
||||
|
||||
return super.set(target, obj);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setList(List<String> commands) {
|
||||
|
||||
super.setList(commands);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String target, Object obj) {
|
||||
|
||||
return super.get(target, obj);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
super.save();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,36 +5,51 @@ import de.rayzs.pat.api.storage.storages.IgnoredServersStorage;
|
||||
public class GeneralIgnoredServers extends IgnoredServersStorage {
|
||||
|
||||
public GeneralIgnoredServers() {
|
||||
|
||||
super("global.ignored-servers");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IgnoredServersStorage add(String server) {
|
||||
|
||||
return super.add(server);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IgnoredServersStorage remove(String server) {
|
||||
|
||||
return super.remove(server);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListed(String server) {
|
||||
|
||||
return super.isListed(server);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListEmpty() {
|
||||
|
||||
return super.isListEmpty();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
super.save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,53 +6,80 @@ import java.util.List;
|
||||
|
||||
public class GroupBlacklist extends BlacklistStorage {
|
||||
|
||||
public GroupBlacklist(String group, String navigatePath) { super("groups." + group + "." + navigatePath); }
|
||||
public GroupBlacklist(String group, String navigatePath) {
|
||||
|
||||
super("groups." + group + "." + navigatePath);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommands() {
|
||||
|
||||
return super.getCommands();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlacklistStorage add(String command) {
|
||||
|
||||
return super.add(command);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlacklistStorage remove(String command) { return super.remove(command); }
|
||||
public BlacklistStorage remove(String command) {
|
||||
|
||||
return super.remove(command);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlacklistStorage clear() {
|
||||
|
||||
return super.clear();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageTemplate setIfEmpty(String target, Object obj) {
|
||||
|
||||
return super.setIfEmpty(target, obj);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageTemplate set(String target, Object obj) {
|
||||
|
||||
return super.set(target, obj);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setList(List<String> commands) {
|
||||
|
||||
super.setList(commands);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(String target, Object obj) {
|
||||
|
||||
return super.get(target, obj);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
super.save();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,36 +16,56 @@ public class BlacklistSection extends ConfigStorage {
|
||||
public String REMOVE_SERVER_SUCCESS, REMOVE_SERVER_FAILED;
|
||||
|
||||
public BlacklistSection() {
|
||||
|
||||
super("blacklist");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
CLEAR = new ConfigSectionHelper<String>(this, "clear", "&aList has been cleared!").getOrSet();
|
||||
CLEAR_CONFIRM = new ConfigSectionHelper<String>(this, "clear-confirmation", "&4Warning! &7This command will &cclear the entire list&7! &7Repeat the &esame command &7to confirm this action.").getOrSet();
|
||||
CLEAR_CONFIRM = new ConfigSectionHelper<String>(this, "clear-confirmation",
|
||||
"&4Warning! &7This command will &cclear the entire list&7! &7Repeat the &esame command &7to confirm this action.")
|
||||
.getOrSet();
|
||||
|
||||
LIST_MESSAGE = new ConfigSectionHelper<String>(this, "list.message", "&7Listed commands (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_MESSAGE = new ConfigSectionHelper<String>(this, "list.message",
|
||||
"&7Listed commands (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_SPLITTER = new ConfigSectionHelper<String>(this, "list.splitter", "&7, &f").getOrSet();
|
||||
|
||||
ADD_SUCCESS = new ConfigSectionHelper<String>(this, "add.success", "&aSuccessfully added %command% into the list!").getOrSet();
|
||||
ADD_FAILED = new ConfigSectionHelper<String>(this, "add.failed", "&c%command% is already in the list!").getOrSet();
|
||||
ADD_SUCCESS = new ConfigSectionHelper<String>(this, "add.success",
|
||||
"&aSuccessfully added %command% into the list!").getOrSet();
|
||||
ADD_FAILED = new ConfigSectionHelper<String>(this, "add.failed", "&c%command% is already in the list!")
|
||||
.getOrSet();
|
||||
|
||||
REMOVE_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success", "&aSuccessfully removed %command% from the list!").getOrSet();
|
||||
REMOVE_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success",
|
||||
"&aSuccessfully removed %command% from the list!").getOrSet();
|
||||
REMOVE_FAILED = new ConfigSectionHelper<String>(this, "remove.failed", "&c%command% is not listed!").getOrSet();
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
if (!Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
CLEAR_SERVER = new ConfigSectionHelper<String>(this, "clear-server", "&aList has been cleared!").getOrSet();
|
||||
CLEAR_SERVER_CONFIRM = new ConfigSectionHelper<String>(this, "clear-confirmation-server", "&4Warning! &7This command will &cclear the entire list of this server&7! &7Repeat the &esame command &7to confirm this action.").getOrSet();
|
||||
CLEAR_SERVER_NOT_FOUND = new ConfigSectionHelper<String>(this, "clear-server-not-found", "&cThe server %server% does not have any commands!").getOrSet();
|
||||
CLEAR_SERVER_CONFIRM = new ConfigSectionHelper<String>(this, "clear-confirmation-server",
|
||||
"&4Warning! &7This command will &cclear the entire list of this server&7! &7Repeat the &esame command &7to confirm this action.")
|
||||
.getOrSet();
|
||||
CLEAR_SERVER_NOT_FOUND = new ConfigSectionHelper<String>(this, "clear-server-not-found",
|
||||
"&cThe server %server% does not have any commands!").getOrSet();
|
||||
|
||||
LIST_SERVER_MESSAGE = new ConfigSectionHelper<String>(this, "list.message-server", "&7Listed commands of %server% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_SERVER_MESSAGE = new ConfigSectionHelper<String>(this, "list.message-server",
|
||||
"&7Listed commands of %server% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_SERVER_SPLITTER = new ConfigSectionHelper<String>(this, "list.splitter-server", "&7, &f").getOrSet();
|
||||
|
||||
ADD_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "add.success-server", "&aSuccessfully added %command% into the list of %server%!").getOrSet();
|
||||
ADD_SERVER_FAILED = new ConfigSectionHelper<String>(this, "add.failed-server", "&c%command% is already in the list of %server%!").getOrSet();
|
||||
ADD_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "add.success-server",
|
||||
"&aSuccessfully added %command% into the list of %server%!").getOrSet();
|
||||
ADD_SERVER_FAILED = new ConfigSectionHelper<String>(this, "add.failed-server",
|
||||
"&c%command% is already in the list of %server%!").getOrSet();
|
||||
|
||||
REMOVE_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success-server",
|
||||
"&aSuccessfully removed %command% from the list of %server%!").getOrSet();
|
||||
REMOVE_SERVER_FAILED = new ConfigSectionHelper<String>(this, "remove.failed-server",
|
||||
"&c%command% is not the list of %server%!").getOrSet();
|
||||
|
||||
REMOVE_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success-server", "&aSuccessfully removed %command% from the list of %server%!").getOrSet();
|
||||
REMOVE_SERVER_FAILED = new ConfigSectionHelper<String>(this, "remove.failed-server", "&c%command% is not the list of %server%!").getOrSet();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,12 +8,18 @@ public class CommandFailedSection extends ConfigStorage {
|
||||
public String MESSAGE;
|
||||
|
||||
public CommandFailedSection() {
|
||||
|
||||
super("command-failed");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
MESSAGE = new ConfigSectionHelper<String>(this, null, "&cFailed to execute this command! Use \"/pat\" to see all available commands.").getOrSet();
|
||||
MESSAGE = new ConfigSectionHelper<String>(this, null,
|
||||
"&cFailed to execute this command! Use \"/pat\" to see all available commands.").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,17 +9,23 @@ public class ConvertSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public ConvertSection() {
|
||||
|
||||
super("convert");
|
||||
|
||||
}
|
||||
|
||||
public String INVALID_CONVERTER, SUCCESS;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
INVALID_CONVERTER = new ConfigSectionHelper<String>(this, "converter-not-found", "&cConverter or necessary files could not be found!").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!").getOrSet();
|
||||
INVALID_CONVERTER = new ConfigSectionHelper<String>(this, "converter-not-found",
|
||||
"&cConverter or necessary files could not be found!").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success",
|
||||
"&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,22 +10,31 @@ public class ExtractSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public ExtractSection() {
|
||||
|
||||
super("extract");
|
||||
|
||||
}
|
||||
|
||||
public String USAGE, PLUGIN_NOT_FOUND, SUCCESS;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
USAGE = new ConfigSectionHelper<String>(this, "usage", "&7Usage: &f/pat extract (plugin) <option> &7or &f(group) <option>").getOrSet();
|
||||
PLUGIN_NOT_FOUND = new ConfigSectionHelper<String>(this, "plugin-not-found", "&cPlugin %plugin% not found!").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully extracted &e%amount% &anew commands from %plugin%!").getOrSet();
|
||||
USAGE = new ConfigSectionHelper<String>(this, "usage",
|
||||
"&7Usage: &f/pat extract (plugin) <option> &7or &f(group) <option>").getOrSet();
|
||||
PLUGIN_NOT_FOUND = new ConfigSectionHelper<String>(this, "plugin-not-found", "&cPlugin %plugin% not found!")
|
||||
.getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success",
|
||||
"&aSuccessfully extracted &e%amount% &anew commands from %plugin%!").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,8 @@ import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
public class GroupSection extends ConfigStorage {
|
||||
|
||||
public String CREATE, ALREADY_EXIST, DOES_NOT_EXIST, DELETE, DELETE_CONFIRM, CREATE_SERVER, ALREADY_SERVER_EXIST, DOES_NOT_EXIST_SERVER, DELETE_SERVER, DELETE_SERVER_CONFIRM;
|
||||
public String CREATE, ALREADY_EXIST, DOES_NOT_EXIST, DELETE, DELETE_CONFIRM, CREATE_SERVER, ALREADY_SERVER_EXIST,
|
||||
DOES_NOT_EXIST_SERVER, DELETE_SERVER, DELETE_SERVER_CONFIRM;
|
||||
public String CLEAR, CLEAR_CONFIRM, CLEAR_SERVER, CLEAR_SERVER_CONFIRM;
|
||||
public String PRIORITY_SUCCESS, PRIORITY_FAILED;
|
||||
|
||||
@@ -21,62 +22,99 @@ public class GroupSection extends ConfigStorage {
|
||||
public String REMOVE_SERVER_SUCCESS, REMOVE_SERVER_FAILED;
|
||||
|
||||
public GroupSection() {
|
||||
|
||||
super("group");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
CREATE = new ConfigSectionHelper<String>(this, "create", "&aGroup %group% has been created!").getOrSet();
|
||||
ALREADY_EXIST = new ConfigSectionHelper<String>(this, "already-exist", "&cGroup %group% already exist!").getOrSet();
|
||||
DOES_NOT_EXIST = new ConfigSectionHelper<String>(this, "does-not-exist", "&cGroup %group% does not exist!").getOrSet();
|
||||
ALREADY_EXIST = new ConfigSectionHelper<String>(this, "already-exist", "&cGroup %group% already exist!")
|
||||
.getOrSet();
|
||||
DOES_NOT_EXIST = new ConfigSectionHelper<String>(this, "does-not-exist", "&cGroup %group% does not exist!")
|
||||
.getOrSet();
|
||||
DELETE = new ConfigSectionHelper<String>(this, "delete", "&cGroup %group% has been deleted!").getOrSet();
|
||||
DELETE_CONFIRM = new ConfigSectionHelper<String>(this, "delete-confirmation", "&4Warning! &7This command will &cdelete the group with the whole list&7 of this group! &7Repeat the &esame command &7to confirm this action.").getOrSet();
|
||||
DELETE_CONFIRM = new ConfigSectionHelper<String>(this, "delete-confirmation",
|
||||
"&4Warning! &7This command will &cdelete the group with the whole list&7 of this group! &7Repeat the &esame command &7to confirm this action.")
|
||||
.getOrSet();
|
||||
|
||||
CLEAR = new ConfigSectionHelper<String>(this, "clear", "&aList of group %group% has been cleared!").getOrSet();
|
||||
CLEAR_CONFIRM = new ConfigSectionHelper<String>(this, "clear-confirmation", "&4Warning! &7This command will &cclear the entire list&7 of this group! &7Repeat the &esame command &7to confirm this action.").getOrSet();
|
||||
CLEAR_CONFIRM = new ConfigSectionHelper<String>(this, "clear-confirmation",
|
||||
"&4Warning! &7This command will &cclear the entire list&7 of this group! &7Repeat the &esame command &7to confirm this action.")
|
||||
.getOrSet();
|
||||
|
||||
PRIORITY_SUCCESS = new ConfigSectionHelper<String>(this, "priority.success", "&aSuccessfully set the priority of group &e%group% &ato &e%priority%&a!").getOrSet();
|
||||
PRIORITY_FAILED = new ConfigSectionHelper<String>(this, "priority.failed", "&cInvalid priority! Please choose a number which is greater than 0.").getOrSet();
|
||||
PRIORITY_SUCCESS = new ConfigSectionHelper<String>(this, "priority.success",
|
||||
"&aSuccessfully set the priority of group &e%group% &ato &e%priority%&a!").getOrSet();
|
||||
PRIORITY_FAILED = new ConfigSectionHelper<String>(this, "priority.failed",
|
||||
"&cInvalid priority! Please choose a number which is greater than 0.").getOrSet();
|
||||
|
||||
LIST_MESSAGE = new ConfigSectionHelper<String>(this, "list.message", "&7Listed commands of group %group% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_MESSAGE = new ConfigSectionHelper<String>(this, "list.message",
|
||||
"&7Listed commands of group %group% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_SPLITTER = new ConfigSectionHelper<String>(this, "list.splitter", "&7, &f").getOrSet();
|
||||
|
||||
LIST_PRIORITY_MESSAGE = new ConfigSectionHelper<String>(this, "list-priorities.message", "&7List of all group priorities (&f%size%&7)&8: &f%groups%").getOrSet();
|
||||
LIST_PRIORITY_MESSAGE = new ConfigSectionHelper<String>(this, "list-priorities.message",
|
||||
"&7List of all group priorities (&f%size%&7)&8: &f%groups%").getOrSet();
|
||||
LIST_PRIORITY_SPLITTER = new ConfigSectionHelper<String>(this, "list-priorities.splitter", "\\n").getOrSet();
|
||||
LIST_PRIORITY_GROUPS = new ConfigSectionHelper<String>(this, "list-priorities.group", "&8- &e%priority%&8: &e%group%").getOrSet();
|
||||
LIST_PRIORITY_GROUPS = new ConfigSectionHelper<String>(this, "list-priorities.group",
|
||||
"&8- &e%priority%&8: &e%group%").getOrSet();
|
||||
|
||||
LIST_GROUP_MESSAGE = new ConfigSectionHelper<String>(this, "list-groups.message", "&7All groups (&f%size%&7)&8: &f%groups%").getOrSet();
|
||||
LIST_GROUP_MESSAGE = new ConfigSectionHelper<String>(this, "list-groups.message",
|
||||
"&7All groups (&f%size%&7)&8: &f%groups%").getOrSet();
|
||||
LIST_GROUP_SPLITTER = new ConfigSectionHelper<String>(this, "list-groups.splitter", "&7, &f").getOrSet();
|
||||
|
||||
ADD_SUCCESS = new ConfigSectionHelper<String>(this, "add.success", "&aSuccessfully added %command% into the list of group %group%!").getOrSet();
|
||||
ADD_FAILED = new ConfigSectionHelper<String>(this, "add.failed", "&c%command% is already in the list of group %group%!").getOrSet();
|
||||
ADD_SUCCESS = new ConfigSectionHelper<String>(this, "add.success",
|
||||
"&aSuccessfully added %command% into the list of group %group%!").getOrSet();
|
||||
ADD_FAILED = new ConfigSectionHelper<String>(this, "add.failed",
|
||||
"&c%command% is already in the list of group %group%!").getOrSet();
|
||||
|
||||
REMOVE_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success", "&aSuccessfully removed %command% from the list of group %group%!").getOrSet();
|
||||
REMOVE_FAILED = new ConfigSectionHelper<String>(this, "remove.failed", "&c%command% is not listed in the group %group%!").getOrSet();
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
REMOVE_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success",
|
||||
"&aSuccessfully removed %command% from the list of group %group%!").getOrSet();
|
||||
REMOVE_FAILED = new ConfigSectionHelper<String>(this, "remove.failed",
|
||||
"&c%command% is not listed in the group %group%!").getOrSet();
|
||||
if (!Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
CREATE_SERVER = new ConfigSectionHelper<String>(this, "create-server", "&aGroup %group% for %server% has been created!").getOrSet();
|
||||
ALREADY_SERVER_EXIST = new ConfigSectionHelper<String>(this, "already-exist-server", "&cGroup %group% for %server% already exist!").getOrSet();
|
||||
DOES_NOT_EXIST_SERVER = new ConfigSectionHelper<String>(this, "does-not-exist-server", "&cGroup %group% of %server% does not exist!").getOrSet();
|
||||
DELETE_SERVER = new ConfigSectionHelper<String>(this, "delete-server", "&cGroup %group% of %server% has been deleted!").getOrSet();
|
||||
DELETE_SERVER_CONFIRM = new ConfigSectionHelper<String>(this, "delete-confirmation-server", "&4Warning! &7This command will &cdelete the group of the server %server% with the whole list&7 of this group! &7Repeat the &esame command &7to confirm this action.").getOrSet();
|
||||
CREATE_SERVER = new ConfigSectionHelper<String>(this, "create-server",
|
||||
"&aGroup %group% for %server% has been created!").getOrSet();
|
||||
ALREADY_SERVER_EXIST = new ConfigSectionHelper<String>(this, "already-exist-server",
|
||||
"&cGroup %group% for %server% already exist!").getOrSet();
|
||||
DOES_NOT_EXIST_SERVER = new ConfigSectionHelper<String>(this, "does-not-exist-server",
|
||||
"&cGroup %group% of %server% does not exist!").getOrSet();
|
||||
DELETE_SERVER = new ConfigSectionHelper<String>(this, "delete-server",
|
||||
"&cGroup %group% of %server% has been deleted!").getOrSet();
|
||||
DELETE_SERVER_CONFIRM = new ConfigSectionHelper<String>(this, "delete-confirmation-server",
|
||||
"&4Warning! &7This command will &cdelete the group of the server %server% with the whole list&7 of this group! &7Repeat the &esame command &7to confirm this action.")
|
||||
.getOrSet();
|
||||
|
||||
CLEAR_SERVER = new ConfigSectionHelper<String>(this, "clear-server", "&aList of group %group% from %server% has been cleared!").getOrSet();
|
||||
CLEAR_SERVER_CONFIRM = new ConfigSectionHelper<String>(this, "clear-confirmation-server", "&4Warning! &7This command will &cclear the entire list&7 of this group for %server%! &7Repeat the &esame command &7to confirm this action.").getOrSet();
|
||||
CLEAR_SERVER = new ConfigSectionHelper<String>(this, "clear-server",
|
||||
"&aList of group %group% from %server% has been cleared!").getOrSet();
|
||||
CLEAR_SERVER_CONFIRM = new ConfigSectionHelper<String>(this, "clear-confirmation-server",
|
||||
"&4Warning! &7This command will &cclear the entire list&7 of this group for %server%! &7Repeat the &esame command &7to confirm this action.")
|
||||
.getOrSet();
|
||||
|
||||
LIST_SERVER_MESSAGE = new ConfigSectionHelper<String>(this, "list.message-server", "&7Listed commands of group %group% from %server% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_SERVER_MESSAGE = new ConfigSectionHelper<String>(this, "list.message-server",
|
||||
"&7Listed commands of group %group% from %server% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_SERVER_SPLITTER = new ConfigSectionHelper<String>(this, "list.splitter-server", "&7, &f").getOrSet();
|
||||
|
||||
LIST_GROUP_SERVER_MESSAGE = new ConfigSectionHelper<String>(this, "list-groups.message-server", "&7All groups from %server% (&f%size%&7)&8: &f%groups%").getOrSet();
|
||||
LIST_GROUP_SERVER_SPLITTER = new ConfigSectionHelper<String>(this, "list-groups.splitter-server", "&7, &f").getOrSet();
|
||||
LIST_GROUP_SERVER_MESSAGE = new ConfigSectionHelper<String>(this, "list-groups.message-server",
|
||||
"&7All groups from %server% (&f%size%&7)&8: &f%groups%").getOrSet();
|
||||
LIST_GROUP_SERVER_SPLITTER = new ConfigSectionHelper<String>(this, "list-groups.splitter-server", "&7, &f")
|
||||
.getOrSet();
|
||||
|
||||
ADD_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "add.success-server", "&aSuccessfully added %command% into the list of group %group% for %server%!").getOrSet();
|
||||
ADD_SERVER_FAILED = new ConfigSectionHelper<String>(this, "add.failed-server", "&c%command% is already in the list of group %group% of %server%!").getOrSet();
|
||||
ADD_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "add.success-server",
|
||||
"&aSuccessfully added %command% into the list of group %group% for %server%!").getOrSet();
|
||||
ADD_SERVER_FAILED = new ConfigSectionHelper<String>(this, "add.failed-server",
|
||||
"&c%command% is already in the list of group %group% of %server%!").getOrSet();
|
||||
|
||||
REMOVE_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success-server", "&aSuccessfully removed %command% from the list of group %group% from %server%!").getOrSet();
|
||||
REMOVE_SERVER_FAILED = new ConfigSectionHelper<String>(this, "remove.failed-server", "&c%command% is not listed in the group %group% of %server%!").getOrSet();
|
||||
REMOVE_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success-server",
|
||||
"&aSuccessfully removed %command% from the list of group %group% from %server%!").getOrSet();
|
||||
REMOVE_SERVER_FAILED = new ConfigSectionHelper<String>(this, "remove.failed-server",
|
||||
"&c%command% is not listed in the group %group% of %server%!").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,56 +10,44 @@ public class HelpSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public HelpSection() {
|
||||
|
||||
super("help");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
MESSAGE = new MultipleMessagesHelper(this, null, Reflection.isProxyServer() ?
|
||||
Arrays.asList(
|
||||
"&7Available commands are: &f/%label%&7..."
|
||||
, "&7Format: &8<optional> (required)"
|
||||
, "&f reload &7to reload the plugin"
|
||||
, "&f notify &7to get alerted"
|
||||
, "&f info &7to get a few information"
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f extract (plugin) &7to extract all plugin commands"
|
||||
, "&f convert (plugin) &7converts into a PAT storage.yml"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
, "&f list &8(optional: group) &7to see all listed commands"
|
||||
, "&f listgroups &7List all groups"
|
||||
, "&f listpriorities &7to list all group priorities"
|
||||
, "&f add/rem (command) &8<group> &7to manage the list"
|
||||
, "&f clear &8<group> &7to clear the list")
|
||||
:
|
||||
Arrays.asList(
|
||||
"&7Available commands are: &f/%label%&7..."
|
||||
, "&7Format: &8<optional> (required)"
|
||||
, "&f reload &7to reload the plugin"
|
||||
, "&f notify &7to get alerted"
|
||||
, "&f info &7to get a few information"
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f extract (plugin) &7to extract all plugin commands"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
, "&f list &8<group> &7to see all listed commands"
|
||||
, "&f listgroups &8<server> &7List all groups"
|
||||
, "&f listpriorities &7to list all group priorities"
|
||||
, "&f add/rem (command) &8<group> &7to manage the list"
|
||||
, "&f clear &8<group> &7to clear the list"
|
||||
, "&7 For a specific server:"
|
||||
, "&f serv list (server) &8<group>"
|
||||
, "&f serv add/rem (server) (command) &8<group>"
|
||||
, "&f serv clear (server) &8<group>"
|
||||
));
|
||||
MESSAGE = new MultipleMessagesHelper(this, null, Reflection.isProxyServer() ? Arrays.asList(
|
||||
"&7Available commands are: &f/%label%&7...", "&7Format: &8<optional> (required)",
|
||||
"&f reload &7to reload the plugin", "&f notify &7to get alerted",
|
||||
"&f info &7to get a few information", "&f postdebug &7to post the PAT logs",
|
||||
"&f update <player> &7to update player(s) permissions",
|
||||
"&f perms <player> &7to check a player's permissions",
|
||||
"&f extract (plugin) &7to extract all plugin commands",
|
||||
"&f convert (plugin) &7converts into a PAT storage.yml", "&f creategroup (group) &7Create a group",
|
||||
"&f deletegroup (group) &7Delete a group", "&f setpriority (group) (priority) &7to set the priority",
|
||||
"&f list &8(optional: group) &7to see all listed commands", "&f listgroups &7List all groups",
|
||||
"&f listpriorities &7to list all group priorities",
|
||||
"&f add/rem (command) &8<group> &7to manage the list", "&f clear &8<group> &7to clear the list")
|
||||
: Arrays.asList("&7Available commands are: &f/%label%&7...", "&7Format: &8<optional> (required)",
|
||||
"&f reload &7to reload the plugin", "&f notify &7to get alerted",
|
||||
"&f info &7to get a few information", "&f postdebug &7to post the PAT logs",
|
||||
"&f update <player> &7to update player(s) permissions",
|
||||
"&f perms <player> &7to check a player's permissions",
|
||||
"&f extract (plugin) &7to extract all plugin commands",
|
||||
"&f creategroup (group) &7Create a group", "&f deletegroup (group) &7Delete a group",
|
||||
"&f setpriority (group) (priority) &7to set the priority",
|
||||
"&f list &8<group> &7to see all listed commands",
|
||||
"&f listgroups &8<server> &7List all groups",
|
||||
"&f listpriorities &7to list all group priorities",
|
||||
"&f add/rem (command) &8<group> &7to manage the list",
|
||||
"&f clear &8<group> &7to clear the list", "&7 For a specific server:",
|
||||
"&f serv list (server) &8<group>", "&f serv add/rem (server) (command) &8<group>",
|
||||
"&f serv clear (server) &8<group>"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,33 +11,36 @@ public class InfoSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public InfoSection() {
|
||||
|
||||
super("info");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
VERSION_UPDATED = new ConfigSectionHelper<String>(this, "version.updated", "&aLatest version").getOrSet();
|
||||
VERSION_OUTDATED = new ConfigSectionHelper<String>(this, "version.outdated", "&cOutdated (%newest_version%)").getOrSet();
|
||||
VERSION_OUTDATED = new ConfigSectionHelper<String>(this, "version.outdated", "&cOutdated (%newest_version%)")
|
||||
.getOrSet();
|
||||
SYNC_TIME = new ConfigSectionHelper<String>(this, "proxy-sync.time", "&e%time%").getOrSet();
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
SYNC_WAITING = new ConfigSectionHelper<String>(this, "proxy-sync.waiting", "&cWaiting to establish connection...").getOrSet();
|
||||
|
||||
SYNC_WAITING = new ConfigSectionHelper<String>(this, "proxy-sync.waiting",
|
||||
"&cWaiting to establish connection...").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
SYNC_DISABLED = new ConfigSectionHelper<String>(this, "proxy-sync.disabled", "&cDisabled").getOrSet();
|
||||
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message",
|
||||
Arrays.asList(
|
||||
"&7Necessary information about &fPAT&8:"
|
||||
, "&7 Version: &e%current_version%"
|
||||
, "&7 Status: %version_status%"
|
||||
, "&7 Last sync with proxy: &e%sync_time%"
|
||||
, "&7 Last received alive packet: %last_alive_response%"
|
||||
, "&7 Proxy sync-token: &e%token%"
|
||||
, "&7 Proxy-received server name: &e%sync_server_name%"
|
||||
)
|
||||
);
|
||||
Arrays.asList("&7Necessary information about &fPAT&8:", "&7 Version: &e%current_version%",
|
||||
"&7 Status: %version_status%", "&7 Last sync with proxy: &e%sync_time%",
|
||||
"&7 Last received alive packet: %last_alive_response%", "&7 Proxy sync-token: &e%token%",
|
||||
"&7 Proxy-received server name: &e%sync_server_name%"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,12 +8,19 @@ public class NoPermissionSection extends ConfigStorage {
|
||||
public String MESSAGE;
|
||||
|
||||
public NoPermissionSection() {
|
||||
|
||||
super("no-permissions");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
MESSAGE = new ConfigSectionHelper<String>(this, null, "&cYou are not allowed to execute this command! Missing permission: &4proantitab.%permission%").getOrSet();
|
||||
MESSAGE = new ConfigSectionHelper<String>(this, null,
|
||||
"&cYou are not allowed to execute this command! Missing permission: &4proantitab.%permission%")
|
||||
.getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,14 +11,22 @@ public class NotificationSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper ALERT;
|
||||
|
||||
public NotificationSection() {
|
||||
|
||||
super("notification");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<String>(this, "enabled", "&aEnabled notifications").getOrSet();
|
||||
DISABLED = new ConfigSectionHelper<String>(this, "disabled", "&cDisabled notifications").getOrSet();
|
||||
ALERT = new MultipleMessagesHelper(this, "alert", Collections.singletonList("&8[&4ALERT&8] &c%player% &8(&7" + (Reflection.isProxyServer() ? "server: &e%server%" : "world: &e%world%") + "&8) &ctried to execute the following blocked command: &4%command%"));
|
||||
ALERT = new MultipleMessagesHelper(this, "alert",
|
||||
Collections.singletonList("&8[&4ALERT&8] &c%player% &8(&7"
|
||||
+ (Reflection.isProxyServer() ? "server: &e%server%" : "world: &e%world%")
|
||||
+ "&8) &ctried to execute the following blocked command: &4%command%"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,13 +9,20 @@ public class OnlyForProxySection extends ConfigStorage {
|
||||
public String MESSAGE;
|
||||
|
||||
public OnlyForProxySection() {
|
||||
|
||||
super("only-for-proxy");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
if(Reflection.isProxyServer()) return;
|
||||
MESSAGE = new ConfigSectionHelper<String>(this, null, "&cThis command works on Bungeecord/Velocity servers only!").getOrSet();
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
MESSAGE = new ConfigSectionHelper<String>(this, null,
|
||||
"&cThis command works on Bungeecord/Velocity servers only!").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,14 +8,22 @@ public class PermsCheckSection extends ConfigStorage {
|
||||
public String MESSAGE, PLAYER_MISSING, PLAYER_NOT_ONLINE;
|
||||
|
||||
public PermsCheckSection() {
|
||||
|
||||
super("perms-check");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
MESSAGE = new ConfigSectionHelper<String>(this, "message", "&7All of &e%player%'s &7PAT-related permission: &e%permissions%").getOrSet();
|
||||
PLAYER_MISSING = new ConfigSectionHelper<String>(this, "player-is-missing", "&cPlease specify the player whose permission you want to check.").getOrSet();
|
||||
PLAYER_NOT_ONLINE = new ConfigSectionHelper<String>(this, "player-not-online", "&c%player% is not online!").getOrSet();
|
||||
MESSAGE = new ConfigSectionHelper<String>(this, "message",
|
||||
"&7All of &e%player%'s &7PAT-related permission: &e%permissions%").getOrSet();
|
||||
PLAYER_MISSING = new ConfigSectionHelper<String>(this, "player-is-missing",
|
||||
"&cPlease specify the player whose permission you want to check.").getOrSet();
|
||||
PLAYER_NOT_ONLINE = new ConfigSectionHelper<String>(this, "player-not-online", "&c%player% is not online!")
|
||||
.getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,13 +8,20 @@ public class PostDebugSection extends ConfigStorage {
|
||||
public String SUCCESS, FAILED;
|
||||
|
||||
public PostDebugSection() {
|
||||
|
||||
super("post-debug");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully uploaded debug logs: &e%link% &8(<click:open_url:%link%><gray>CLICK</click>&8)").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success",
|
||||
"&aSuccessfully uploaded debug logs: &e%link% &8(<click:open_url:%link%><gray>CLICK</click>&8)")
|
||||
.getOrSet();
|
||||
FAILED = new ConfigSectionHelper<String>(this, "failed", "&cFailed to upload debug logs!").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,12 +8,17 @@ public class PrefixSection extends ConfigStorage {
|
||||
public String PREFIX;
|
||||
|
||||
public PrefixSection() {
|
||||
|
||||
super("prefix");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
PREFIX = new ConfigSectionHelper<String>(this, null, "&8[&4ProAntiTab&8]").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,13 +8,19 @@ public class ReloadSection extends ConfigStorage {
|
||||
public String LOADING, DONE;
|
||||
|
||||
public ReloadSection() {
|
||||
|
||||
super("reload");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
LOADING = new ConfigSectionHelper<String>(this, "loading", "&eReloading all configuration files...").getOrSet();
|
||||
DONE = new ConfigSectionHelper<String>(this, "done", "&aSuccessfully reloaded all configuration files!").getOrSet();
|
||||
DONE = new ConfigSectionHelper<String>(this, "done", "&aSuccessfully reloaded all configuration files!")
|
||||
.getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,21 +10,31 @@ public class ServerListSection extends ConfigStorage {
|
||||
public String LIST_SERVER_MESSAGE, LIST_SERVER_SPLITTER, LIST_GROUP_MESSAGE, LIST_GROUP_SPLITTER;
|
||||
|
||||
public ServerListSection() {
|
||||
|
||||
super("server-list");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
if (!Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
SERVER_DOES_NOT_EXIST = new ConfigSectionHelper<String>(this, "server-not-found", "&cThe server %server% does not have any commands!").getOrSet();
|
||||
GROUP_DOES_NOT_EXIST = new ConfigSectionHelper<String>(this, "group-does-not-exist", "&cGroup %group% does not exist for %server%!").getOrSet();
|
||||
SERVER_DOES_NOT_EXIST = new ConfigSectionHelper<String>(this, "server-not-found",
|
||||
"&cThe server %server% does not have any commands!").getOrSet();
|
||||
GROUP_DOES_NOT_EXIST = new ConfigSectionHelper<String>(this, "group-does-not-exist",
|
||||
"&cGroup %group% does not exist for %server%!").getOrSet();
|
||||
|
||||
LIST_SERVER_MESSAGE = new ConfigSectionHelper<String>(this, "list.server.message", "&7Listed commands of %server% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_SERVER_MESSAGE = new ConfigSectionHelper<String>(this, "list.server.message",
|
||||
"&7Listed commands of %server% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_SERVER_SPLITTER = new ConfigSectionHelper<String>(this, "list.server.splitter", "&7, &f").getOrSet();
|
||||
|
||||
LIST_GROUP_MESSAGE = new ConfigSectionHelper<String>(this, "list.group.message", "&7Listed commands of %group% from %server% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_GROUP_MESSAGE = new ConfigSectionHelper<String>(this, "list.group.message",
|
||||
"&7Listed commands of %group% from %server% (&f%size%&7)&8: &f%commands%").getOrSet();
|
||||
LIST_GROUP_SPLITTER = new ConfigSectionHelper<String>(this, "list.group.splitter", "&7, &f").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,24 +12,31 @@ public class StatsSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper STATISTIC;
|
||||
|
||||
public StatsSection() {
|
||||
|
||||
super("stats");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
NO_SERVER = new ConfigSectionHelper<String>(this, "no-server", "&cNone!").getOrSet();
|
||||
SPLITTER = new ConfigSectionHelper<String>(this, "message.splitter", "&7, ").getOrSet();
|
||||
SERVER = new ConfigSectionHelper<String>(this, "message.server", "&f%servername% &8(&a%last_alive_response% &8/ &2%updated%&8)").getOrSet();
|
||||
STATISTIC = new MultipleMessagesHelper(this, "message.statistic", Arrays.asList(
|
||||
"&7Format: &eserver (last alive packet / last sync packet)",
|
||||
"&7Last sync sent to &f%server_count% &7server(s) &e%last_sync_time% &7ago:",
|
||||
"&7Sent to servers: &f%servers%"
|
||||
));
|
||||
SERVER = new ConfigSectionHelper<String>(this, "message.server",
|
||||
"&f%servername% &8(&a%last_alive_response% &8/ &2%updated%&8)").getOrSet();
|
||||
STATISTIC = new MultipleMessagesHelper(this, "message.statistic",
|
||||
Arrays.asList("&7Format: &eserver (last alive packet / last sync packet)",
|
||||
"&7Last sync sent to &f%server_count% &7server(s) &e%last_sync_time% &7ago:",
|
||||
"&7Sent to servers: &f%servers%"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+9
-2
@@ -8,14 +8,21 @@ public class UpdatePermissionsSection extends ConfigStorage {
|
||||
public String UPDATE_ALL, UPDATE_SPECIFIC, PLAYER_NOT_ONLINE;
|
||||
|
||||
public UpdatePermissionsSection() {
|
||||
|
||||
super("update-permissions");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
UPDATE_ALL = new ConfigSectionHelper<String>(this, "all-players", "&aUpdated permissions!").getOrSet();
|
||||
UPDATE_SPECIFIC = new ConfigSectionHelper<String>(this, "specific-player", "&aUpdated %target%'s permissions!").getOrSet();
|
||||
PLAYER_NOT_ONLINE = new ConfigSectionHelper<String>(this, "player-not-online", "&c%target% is not online!").getOrSet();
|
||||
UPDATE_SPECIFIC = new ConfigSectionHelper<String>(this, "specific-player", "&aUpdated %target%'s permissions!")
|
||||
.getOrSet();
|
||||
PLAYER_NOT_ONLINE = new ConfigSectionHelper<String>(this, "player-not-online", "&c%target% is not online!")
|
||||
.getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -8,12 +8,17 @@ public class AllowGroupOverrulingSection extends ConfigStorage {
|
||||
public boolean ENABLED;
|
||||
|
||||
public AllowGroupOverrulingSection() {
|
||||
|
||||
super("allow-group-overruling");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+9
-2
@@ -1,7 +1,6 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
@@ -10,19 +9,27 @@ public class AutoLowercaseCommandsSection extends ConfigStorage {
|
||||
public boolean ENABLED;
|
||||
|
||||
public AutoLowercaseCommandsSection() {
|
||||
|
||||
super("auto-lowercase-commands");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED) return false;
|
||||
|
||||
if (!ENABLED)
|
||||
return false;
|
||||
|
||||
return !StringUtils.isLowercased(command);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+5
-3
@@ -2,21 +2,23 @@ package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class BaseCommandCaseSensitiveSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public BaseCommandCaseSensitiveSection() {
|
||||
|
||||
super("base-command-case-sensitive");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, true).getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+16
-4
@@ -3,7 +3,6 @@ package de.rayzs.pat.api.storage.config.settings;
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
@@ -11,29 +10,42 @@ public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
public boolean ENABLED, ALWAYS_BLOCK_COMMAND;
|
||||
|
||||
public BlockNamespaceCommandsSection() {
|
||||
|
||||
super("block-namespace-commands");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
ALWAYS_BLOCK_COMMAND = new ConfigSectionHelper<Boolean>(this, "always-block-command", true).getOrSet();
|
||||
|
||||
}
|
||||
|
||||
public boolean doesAlwaysBlock(String command) {
|
||||
|
||||
return ALWAYS_BLOCK_COMMAND && isCommand(command);
|
||||
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
|
||||
if (!ENABLED) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return StringUtils.getFirstArg(command).indexOf(':') != -1;
|
||||
return StringUtils.getFirstArg(command).contains(":");
|
||||
|
||||
}
|
||||
|
||||
public boolean doesBypass(final CommandSender sender, final boolean isOperator) {
|
||||
return !ENABLED || PermissionUtil.hasPermission(sender, "namespace", isOperator);
|
||||
public boolean doesBypass(CommandSender sender) {
|
||||
|
||||
return !ENABLED || sender.hasPermission("namespace");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public class BlockSlashCommandsSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public BlockSlashCommandsSection() {
|
||||
|
||||
super("block-slash-commands");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", false).getOrSet();
|
||||
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
|
||||
if (!ENABLED) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return StringUtils.getFirstArg(command).contains("/");
|
||||
|
||||
}
|
||||
|
||||
public boolean doesBypass(CommandSender sender) {
|
||||
|
||||
return !ENABLED || PermissionUtil.hasPermission(sender, "slash");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,14 +10,21 @@ public class CancelCommandSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper BASE_COMMAND_RESPONSE, SUB_COMMAND_RESPONSE;
|
||||
|
||||
public CancelCommandSection() {
|
||||
|
||||
super("cancel-blocked-commands");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
BASE_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "base-command-message", Collections.singletonList("&cThe command %command% is blocked!"));
|
||||
SUB_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "sub-command-message", Collections.singletonList("&cThis sub-argument is blocked!"));
|
||||
BASE_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "base-command-message",
|
||||
Collections.singletonList("&cThe command %command% is blocked!"));
|
||||
SUB_COMMAND_RESPONSE = new MultipleMessagesHelper(this, "sub-command-message",
|
||||
Collections.singletonList("&cThis sub-argument is blocked!"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,28 +11,23 @@ public class CustomBrandSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper BRANDS;
|
||||
|
||||
public CustomBrandSection() {
|
||||
|
||||
super("custom-server-brand");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", false).getOrSet();
|
||||
REPEAT_DELAY = new ConfigSectionHelper<Integer>(this, "repeat-delay", 3).getOrSet();
|
||||
BRANDS = new MultipleMessagesHelper(this, "brands", Arrays.asList(
|
||||
"&f&lP&froAntiTab |",
|
||||
"&fP&lr&foAntiTab /",
|
||||
"&fPr&lo&fAntiTab -",
|
||||
"&fPro&lA&fntiTab |",
|
||||
"&fProA&ln&ftiTab \\",
|
||||
"&fProAn<&fiTab |",
|
||||
"&fProAnt&li&fTab /",
|
||||
"&fProAnti&lT&fab -",
|
||||
"&fProAnti&lT&fab \\",
|
||||
"&fProAntiT&la&fb |",
|
||||
"&fProAntiTa&lb&f /",
|
||||
"&fProAntiTab -",
|
||||
"&fProAntiTab \\"
|
||||
));
|
||||
BRANDS = new MultipleMessagesHelper(this, "brands",
|
||||
Arrays.asList("&f&lP&froAntiTab |", "&fP&lr&foAntiTab /", "&fPr&lo&fAntiTab -", "&fPro&lA&fntiTab |",
|
||||
"&fProA&ln&ftiTab \\", "&fProAn<&fiTab |", "&fProAnt&li&fTab /", "&fProAnti&lT&fab -",
|
||||
"&fProAnti&lT&fab \\", "&fProAntiT&la&fb |", "&fProAntiTa&lb&f /", "&fProAntiTab -",
|
||||
"&fProAntiTab \\"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,34 +11,46 @@ public class CustomPluginsSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper MESSAGE, COMMANDS;
|
||||
|
||||
public CustomPluginsSection() {
|
||||
|
||||
super("custom-plugins");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper<Boolean>(this, "always-tab-completable", false).getOrSet();
|
||||
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("pl", "plugins"));
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fPlugins (0):"));
|
||||
|
||||
}
|
||||
|
||||
public boolean isTabCompletable(String command) {
|
||||
|
||||
if (!isCommand(command))
|
||||
return false;
|
||||
|
||||
return ALWAYS_TAB_COMPLETABLE;
|
||||
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED) return false;
|
||||
|
||||
if (!ENABLED)
|
||||
return false;
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
for (String currentCommand : COMMANDS.getLines()) {
|
||||
|
||||
if (currentCommand.equalsIgnoreCase(command))
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+18
-12
@@ -10,7 +10,7 @@ import java.util.Arrays;
|
||||
|
||||
public class CustomProtocolPingSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED, ALWAYS_SHOW, HIDE_PLAYERS, USE_EXTEND_AS_MAX_COUNT, USE_CUSTOM_PLAYERLIST, USE_CENTER_VARIABLE;
|
||||
public boolean ENABLED, ALWAYS_SHOW, HIDE_PLAYERS, USE_EXTEND_AS_MAX_COUNT, USE_CUSTOM_PLAYERLIST;
|
||||
public String PROTOCOL;
|
||||
|
||||
public MultipleMessagesHelper PLAYERLIST;
|
||||
@@ -18,37 +18,43 @@ public class CustomProtocolPingSection extends ConfigStorage {
|
||||
public int EXTEND_COUNT;
|
||||
|
||||
public CustomProtocolPingSection() {
|
||||
|
||||
super("custom-protocol-ping");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
if (!Reflection.isProxyServer() && (!Reflection.isPaper() || Reflection.isBefore(1, 12)))
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
ALWAYS_SHOW = new ConfigSectionHelper<Boolean>(this, "always-show", Reflection.isProxyServer() || Reflection.isPaper()).getOrSet();
|
||||
ALWAYS_SHOW = new ConfigSectionHelper<Boolean>(this, "always-show",
|
||||
Reflection.isProxyServer() || Reflection.isPaper()).getOrSet();
|
||||
USE_EXTEND_AS_MAX_COUNT = new ConfigSectionHelper<Boolean>(this, "use-as-maxplayers", false).getOrSet();
|
||||
PROTOCOL = new ConfigSectionHelper<String>(this, "protocol", "&f&lProAntiTab &7(&a%online%&7/&c%max%&7)").getOrSet();
|
||||
PROTOCOL = new ConfigSectionHelper<String>(this, "protocol", "&f&lProAntiTab &7(&a%online%&7/&c%max%&7)")
|
||||
.getOrSet();
|
||||
EXTEND_COUNT = new ConfigSectionHelper<Integer>(this, "extend-online-count", 1).getOrSet();
|
||||
|
||||
HIDE_PLAYERS = new ConfigSectionHelper<Boolean>(this, "hide-players", true).getOrSet();
|
||||
|
||||
USE_CUSTOM_PLAYERLIST = new ConfigSectionHelper<Boolean>(this, "custom-playerlist.enabled", false).getOrSet();
|
||||
PLAYERLIST = new MultipleMessagesHelper(this, "custom-playerlist.list", Arrays.asList(
|
||||
"&8> &7Online players: &f%online%&7/&c%max%",
|
||||
"&8> &7Using &fProAntiTab"
|
||||
));
|
||||
|
||||
USE_CENTER_VARIABLE = PLAYERLIST.getLines().stream().anyMatch(l -> l.startsWith("%center%"));
|
||||
|
||||
PLAYERLIST = new MultipleMessagesHelper(this, "custom-playerlist.list",
|
||||
Arrays.asList("&8> &7Online players: &f%online%&7/&c%max%", "&8> &7Using &fProAntiTab"));
|
||||
|
||||
if (HIDE_PLAYERS && USE_CUSTOM_PLAYERLIST) {
|
||||
Logger.warning("You can't use both 'hide-players' and 'custom-playerlist' at the same time! (Section: custom-protocol-ping)");
|
||||
|
||||
Logger.warning(
|
||||
"You can't use both 'hide-players' and 'custom-playerlist' at the same time! (Section: custom-protocol-ping)");
|
||||
Logger.warning("You gotta choose what feature from those two you want to use.");
|
||||
Logger.warning("In order to avoid any problems, the 'custom-playerlist' feature has been temporarily disabled.");
|
||||
Logger.warning(
|
||||
"In order to avoid any problems, the 'custom-playerlist' feature has been temporarily disabled.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+8
-9
@@ -1,7 +1,6 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.configuration.helper.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import java.util.Collections;
|
||||
@@ -12,22 +11,22 @@ public class CustomUnknownCommandSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public CustomUnknownCommandSection() {
|
||||
|
||||
super("custom-unknown-command");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&cThis command does not exist!"));
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message",
|
||||
Collections.singletonList("&cThis command does not exist!"));
|
||||
|
||||
|
||||
if (ENABLED && Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
Logger.warning("It's not recommended to use the 'custom-unknown-command' feature when you are already using ProAntiTab in WHITELIST mode! Since in this mode, all commands except the once you specifically allow, are blocked anyway. So instead, change the 'blocked' message to your desired message. It has the same effect.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,33 +11,48 @@ public class CustomVersionSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper MESSAGE, COMMANDS;
|
||||
|
||||
public CustomVersionSection() {
|
||||
|
||||
super("custom-version");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
ALWAYS_TAB_COMPLETABLE = new ConfigSectionHelper<Boolean>(this, "always-tab-completable", false).getOrSet();
|
||||
COMMANDS = new MultipleMessagesHelper(this, "commands", Arrays.asList("icanhasbukkit", "about", "ver", "version"));
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message", Collections.singletonList("&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)"));
|
||||
COMMANDS = new MultipleMessagesHelper(this, "commands",
|
||||
Arrays.asList("icanhasbukkit", "about", "ver", "version"));
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message",
|
||||
Collections.singletonList("&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)"));
|
||||
|
||||
}
|
||||
|
||||
public boolean isTabCompletable(String command) {
|
||||
|
||||
if (!isCommand(command))
|
||||
return false;
|
||||
|
||||
return ALWAYS_TAB_COMPLETABLE;
|
||||
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED) return false;
|
||||
|
||||
if (!ENABLED)
|
||||
return false;
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
for (String currentCommand : COMMANDS.getLines()) {
|
||||
|
||||
if (currentCommand.equalsIgnoreCase(command))
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,21 +6,23 @@ import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class DisableSyncSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public boolean DISABLED;
|
||||
|
||||
public DisableSyncSection() {
|
||||
|
||||
super("disable-sync");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
if (!Reflection.isProxyServer())
|
||||
return;
|
||||
}
|
||||
DISABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
|
||||
}
|
||||
+7
-1
@@ -9,14 +9,20 @@ public class ForwardConsoleNotificationAlertsSection extends ConfigStorage {
|
||||
public boolean ENABLED;
|
||||
|
||||
public ForwardConsoleNotificationAlertsSection() {
|
||||
|
||||
super("forward-console-notification-alerts");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
if (!Reflection.isProxyServer())
|
||||
return;
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class ForwardLuckPermsChangesSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED = false;
|
||||
|
||||
public ForwardLuckPermsChangesSection() {
|
||||
super("auto-forward-luckperms-changes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
if (Reflection.isProxyServer()) return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -14,13 +14,17 @@ public class HandleThroughProxySection extends ConfigStorage {
|
||||
public String TOKEN;
|
||||
|
||||
public HandleThroughProxySection() {
|
||||
|
||||
super("handle-through-proxy");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
if (Reflection.isProxyServer()) return;
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", false).getOrSet();
|
||||
TOKEN = new ConfigSectionHelper<String>(this, "token", "insert-token-of-proxy-here").getOrSet();
|
||||
@@ -29,5 +33,7 @@ public class HandleThroughProxySection extends ConfigStorage {
|
||||
|
||||
LOAD_FROM_ENV = new ConfigSectionHelper<Boolean>(this, "load-from-env.enabled", false).getOrSet();
|
||||
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", "PAT_TOKEN").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class HidePluginChannelsSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public MultipleMessagesHelper WHITELISTED_CHANNELS;
|
||||
|
||||
private final HashSet<String> REGISTER_CHANNELS = new HashSet<>(
|
||||
Arrays.asList("register", "unregister", "minecraft:register", "minecraft:unregister")
|
||||
);
|
||||
|
||||
public HidePluginChannelsSection() {
|
||||
super("plugin-channels-hider");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", false).getOrSet();
|
||||
WHITELISTED_CHANNELS = new MultipleMessagesHelper(this, "whitelisted-channels", Arrays.asList(
|
||||
"minecraft:brand",
|
||||
"bungeecord:main",
|
||||
"velocity:main"
|
||||
));
|
||||
}
|
||||
|
||||
public boolean isRegisterChannel(final String channelId) {
|
||||
return REGISTER_CHANNELS.contains(channelId);
|
||||
}
|
||||
}
|
||||
@@ -9,15 +9,22 @@ public class InjectionFailedSection extends ConfigStorage {
|
||||
public String KICK_MESSAGE, CONSOLE_MESSAGE;
|
||||
|
||||
public InjectionFailedSection() {
|
||||
|
||||
super("injection-failed");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "kick-on-failure", true).getOrSet();
|
||||
SUPPRESS_EXCEPTIONS = new ConfigSectionHelper<Boolean>(this, "suppress-exceptions", false).getOrSet();
|
||||
KICK_MESSAGE = new ConfigSectionHelper<String>(this, "kick-message", "&cInjection process failed! Please reconnect.").getOrSet();
|
||||
CONSOLE_MESSAGE = new ConfigSectionHelper<String>(this, "console-message", "&cInjection process failed! (%player%)").getOrSet();
|
||||
KICK_MESSAGE = new ConfigSectionHelper<String>(this, "kick-message",
|
||||
"&cInjection process failed! Please reconnect.").getOrSet();
|
||||
CONSOLE_MESSAGE = new ConfigSectionHelper<String>(this, "console-message",
|
||||
"&cInjection process failed! (%player%)").getOrSet();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package de.rayzs.pat.api.storage.config.settings;
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.*;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import java.util.Collections;
|
||||
|
||||
public class PatchExploitSection extends ConfigStorage {
|
||||
|
||||
@@ -11,22 +10,30 @@ public class PatchExploitSection extends ConfigStorage {
|
||||
public ConfigSectionHelper<String> ALERT_MESSAGE, KICK_MESSAGE;
|
||||
|
||||
public PatchExploitSection() {
|
||||
|
||||
super("patch-exploits");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
ALERT_MESSAGE = new ConfigSectionHelper<>(this, "alert-message", "%prefix% &4%player% &ctried to crash/lag the server.");
|
||||
ALERT_MESSAGE = new ConfigSectionHelper<>(this, "alert-message",
|
||||
"%prefix% &4%player% &ctried to crash/lag the server.");
|
||||
KICK_MESSAGE = new ConfigSectionHelper(this, "kick-message", "&cFailed to read packet! Please reconnect.");
|
||||
|
||||
}
|
||||
|
||||
public boolean isMalicious(String text) {
|
||||
if(!ENABLED) return false;
|
||||
|
||||
return text.length() > 256
|
||||
|| text.contains("nbt")
|
||||
if (!ENABLED)
|
||||
return false;
|
||||
|
||||
return text.length() > 256 || text.contains("nbt")
|
||||
&& (StringUtils.countMatches('[', text) > 15 || StringUtils.countMatches('{', text) > 25);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class TabCompletionForNotExistingCommandsSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public TabCompletionForNotExistingCommandsSection() {
|
||||
super("tab-completion-for-not-existing-commands");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
if (!Reflection.isProxyServer()) return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
+5
@@ -8,12 +8,17 @@ public class TurnBlacklistToWhitelistSection extends ConfigStorage {
|
||||
public boolean ENABLED;
|
||||
|
||||
public TurnBlacklistToWhitelistSection() {
|
||||
|
||||
super("turn-blacklist-to-whitelist");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -9,16 +9,21 @@ public class UpdateGroupsPerServerSection extends ConfigStorage {
|
||||
public boolean ENABLED = false;
|
||||
|
||||
public UpdateGroupsPerServerSection() {
|
||||
|
||||
super("update-groups-per-server");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
if (!Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -9,16 +9,21 @@ public class UpdateGroupsPerWorldSection extends ConfigStorage {
|
||||
public boolean ENABLED;
|
||||
|
||||
public UpdateGroupsPerWorldSection() {
|
||||
|
||||
super("update-groups-per-world");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,20 +11,26 @@ public class UpdateSection extends ConfigStorage {
|
||||
public MultipleMessagesHelper OUTDATED, UPDATED;
|
||||
|
||||
public UpdateSection() {
|
||||
|
||||
super("updater");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
PERIOD = new ConfigSectionHelper<Integer>(this, "period", 10000).getOrSet();
|
||||
AUTO_UPDATE_CONFIG = new ConfigSectionHelper<Boolean>(this, "auto-update-config", true).getOrSet();
|
||||
UPDATED = new MultipleMessagesHelper(this, "updated", Collections.singletonList("&aYou are using the newest version! ^^"));
|
||||
OUTDATED = new MultipleMessagesHelper(this, "outdated", Arrays.asList(
|
||||
"&8[&4ProAntiTab&8] &cThere is a new version available! (%newest_version%)",
|
||||
"&8[&4ProAntiTab&8] &cYou are still using the %current_version%.",
|
||||
"&8[&4ProAntiTab&8] &cGet the newest version here:",
|
||||
"&8[&4ProAntiTab&8] &ehttps://www.rayzs.de/products/proantitab/page"));
|
||||
UPDATED = new MultipleMessagesHelper(this, "updated",
|
||||
Collections.singletonList("&aYou are using the newest version! ^^"));
|
||||
OUTDATED = new MultipleMessagesHelper(this, "outdated",
|
||||
Arrays.asList("&8[&4ProAntiTab&8] &cThere is a new version available! (%newest_version%)",
|
||||
"&8[&4ProAntiTab&8] &cYou are still using the %current_version%.",
|
||||
"&8[&4ProAntiTab&8] &cGet the newest version here:",
|
||||
"&8[&4ProAntiTab&8] &ehttps://www.rayzs.de/products/proantitab/page"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+10
-1
@@ -8,18 +8,27 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class ListCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListCommandsPlaceholder() { super("list_commands"); }
|
||||
public ListCommandsPlaceholder() {
|
||||
|
||||
super("list_commands");
|
||||
|
||||
}
|
||||
|
||||
public String SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
|
||||
return StringUtils.getStringList(Storage.Blacklist.getBlacklist().getCommands(), SPLITTER);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
SPLITTER = new ConfigSectionHelper<String>(this, "splitter", "&7, &e").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+10
-1
@@ -8,18 +8,27 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class ListReversedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListReversedCommandsPlaceholder() { super("list_reversed_commands"); }
|
||||
public ListReversedCommandsPlaceholder() {
|
||||
|
||||
super("list_reversed_commands");
|
||||
|
||||
}
|
||||
|
||||
public String SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
|
||||
return StringUtils.getReversedStringList(Storage.Blacklist.getBlacklist().getCommands(), SPLITTER);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
SPLITTER = new ConfigSectionHelper<String>(this, "splitter", "&7, &e").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+10
-1
@@ -6,15 +6,24 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class ListSizeCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListSizeCommandsPlaceholder() { super("list_size_commands"); }
|
||||
public ListSizeCommandsPlaceholder() {
|
||||
|
||||
super("list_size_commands");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
|
||||
return String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+10
-1
@@ -8,18 +8,27 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class ListSortedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListSortedCommandsPlaceholder() { super("list_sorted_commands"); }
|
||||
public ListSortedCommandsPlaceholder() {
|
||||
|
||||
super("list_sorted_commands");
|
||||
|
||||
}
|
||||
|
||||
public String SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
|
||||
return StringUtils.getSortedStringList(Storage.Blacklist.getBlacklist().getCommands(), SPLITTER);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
SPLITTER = new ConfigSectionHelper<String>(this, "splitter", "&7, &e").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+13
-4
@@ -1,29 +1,38 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListGroupCommandsPlaceholder() { super("list_commands_group_"); }
|
||||
public ListGroupCommandsPlaceholder() {
|
||||
|
||||
super("list_commands_group_");
|
||||
|
||||
}
|
||||
|
||||
public String SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
if (group == null)
|
||||
return null;
|
||||
|
||||
return StringUtils.getStringList(group.getCommands(), SPLITTER);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
SPLITTER = new ConfigSectionHelper<String>(this, "splitter", "&7, &e").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+13
-4
@@ -1,29 +1,38 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupReversedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListGroupReversedCommandsPlaceholder() { super("list_reversed_commands_group_"); }
|
||||
public ListGroupReversedCommandsPlaceholder() {
|
||||
|
||||
super("list_reversed_commands_group_");
|
||||
|
||||
}
|
||||
|
||||
public String SPLITTER;
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
if (group == null)
|
||||
return null;
|
||||
|
||||
return StringUtils.getReversedStringList(group.getCommands(), SPLITTER);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
SPLITTER = new ConfigSectionHelper<String>(this, "splitter", "&7, &e").getOrSet();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+13
-4
@@ -1,23 +1,32 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupSizeCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
public ListGroupSizeCommandsPlaceholder() { super("list_size_commands_group_"); }
|
||||
public ListGroupSizeCommandsPlaceholder() {
|
||||
|
||||
super("list_size_commands_group_");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(Player player, String param) {
|
||||
|
||||
Group group = GroupManager.getGroupByName(param);
|
||||
if(group == null) return null;
|
||||
if (group == null)
|
||||
return null;
|
||||
return String.valueOf(group.getCommands().size());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
super.load();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 281 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user