DiamondBank-OG API
This commit is contained in:
1 parent
5ae17b8437
commit
7e4b1c1d84
48 files changed
+2200
-927
No files matched your search
@@ -38,6 +38,7 @@ build/
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
bin/
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[submodule "libs/DiamondBank-OG"]
|
||||
path = libs/DiamondBank-OG
|
||||
url = https://github.com/true-og/DiamondBank-OG
|
||||
[submodule "libs/Utilities-OG"]
|
||||
path = libs/Utilities-OG
|
||||
url = https://github.com/true-og/Utilities-OG
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Fetch all submodule content.
|
||||
git submodule update --force --recursive --init
|
||||
+73
-30
@@ -1,17 +1,20 @@
|
||||
/* This is free and unencumbered software released into the public domain */
|
||||
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
|
||||
/* ------------------------------ Plugins ------------------------------ */
|
||||
plugins {
|
||||
id("java") // Import Java plugin.
|
||||
id("java-library") // Import Java Library plugin.
|
||||
id("com.diffplug.spotless") version "7.0.4" // Import Spotless plugin.
|
||||
id("com.gradleup.shadow") version "8.3.8" // Import Shadow 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 // Import Eclipse plugin.
|
||||
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
|
||||
}
|
||||
|
||||
extra["kotlinAttribute"] = Attribute.of("kotlin-tag", Boolean::class.javaObjectType)
|
||||
|
||||
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
|
||||
|
||||
/* --------------------------- JDK / Kotlin ---------------------------- */
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
|
||||
@@ -24,26 +27,27 @@ java {
|
||||
kotlin { jvmToolchain(17) }
|
||||
|
||||
/* ----------------------------- Metadata ------------------------------ */
|
||||
group = "com.tcoded"
|
||||
version = "1.4.17"
|
||||
group = "com.tcoded" // Declare bundle identifier.
|
||||
|
||||
val apiVersion = "1.19"
|
||||
version = "1.4.17" // Declare plugin version (will be in .jar).
|
||||
|
||||
val apiVersion = "1.19" // Declare minecraft server target version.
|
||||
|
||||
/* ----------------------------- Resources ----------------------------- */
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
val props = mapOf("version" to version, "apiVersion" to apiVersion)
|
||||
inputs.properties(props)
|
||||
inputs.properties(props) // Indicates to rerun if version changes.
|
||||
filesMatching("plugin.yml") { expand(props) }
|
||||
from("LICENSE") { into("/") }
|
||||
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
|
||||
}
|
||||
|
||||
/* ---------------------------- Repos ---------------------------------- */
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
maven { url = uri("https://repo.purpurmc.org/snapshots") }
|
||||
mavenCentral() // Import the Maven Central Maven Repository.
|
||||
gradlePluginPortal() // Import the Gradle Plugin Portal Maven Repository.
|
||||
maven { url = uri("https://repo.purpurmc.org/snapshots") } // Import the PurpurMC Maven Repository.
|
||||
maven { url = uri("file://${System.getProperty("user.home")}/.m2/repository") }
|
||||
System.getProperty("SELF_MAVEN_LOCAL_REPO")?.let {
|
||||
System.getProperty("SELF_MAVEN_LOCAL_REPO")?.let { // TrueOG Bootstrap mavenLocal().
|
||||
val dir = file(it)
|
||||
if (dir.isDirectory) {
|
||||
println("Using SELF_MAVEN_LOCAL_REPO at: $it")
|
||||
@@ -64,45 +68,84 @@ repositories {
|
||||
|
||||
/* ---------------------- Java project deps ---------------------------- */
|
||||
dependencies {
|
||||
compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
|
||||
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare Purpur API version to be packaged.
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
compileOnly("com.github.CraptiCraft-Development:ClansLite-API:1.4.4")
|
||||
compileOnly("com.cortezromeo.clansplus:clansplus-plugin:2.8")
|
||||
implementation("com.github.TechnicallyCoded:FoliaLib:0.4.3")
|
||||
implementation("com.github.lightlibs:LegacyColorCodeParser:1.0.0")
|
||||
compileOnly("net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.15.2")
|
||||
compileOnly("com.github.SaberLLC:Saber-Factions:4.1.4-STABLE")
|
||||
compileOnly("com.palmergames.bukkit.towny:towny:0.100.0.0")
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG Java API (from source).
|
||||
compileOnlyApi(project(":libs:DiamondBank-OG")) {
|
||||
attributes { attribute(kotlinAttribute, true) }
|
||||
} // Import TrueOG network DiamondBank-OG Kotlin API (from source).
|
||||
}
|
||||
|
||||
apply(from = "eclipse.gradle.kts") // Import eclipse classpath support script.
|
||||
|
||||
/* ---------------------- Reproducible jars ---------------------------- */
|
||||
tasks.withType<AbstractArchiveTask>().configureEach {
|
||||
tasks.withType<AbstractArchiveTask>().configureEach { // Ensure reproducible .jars
|
||||
isPreserveFileTimestamps = false
|
||||
isReproducibleFileOrder = true
|
||||
}
|
||||
|
||||
/* ----------------------------- Shadow -------------------------------- */
|
||||
tasks.shadowJar {
|
||||
archiveBaseName.set("PlayerBounties-OG")
|
||||
archiveClassifier.set("")
|
||||
exclude("io.github.miniplaceholders.*") // Exclude the MiniPlaceholders package from being shadowed.
|
||||
isEnableRelocation = true
|
||||
relocationPrefix = "${project.group}.shadow"
|
||||
archiveClassifier.set("") // Use empty string instead of null.
|
||||
minimize()
|
||||
relocate("com.tcoded.folialib", "net.trueog.playerbountiesog.lib.folialib")
|
||||
relocate("org.bstats", "net.trueog.playerbountiesog.lib.bstats")
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
archiveBaseName.set("PlayerBounties-OG")
|
||||
archiveClassifier.set("part")
|
||||
}
|
||||
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
|
||||
|
||||
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) }
|
||||
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) } // Build depends on spotless and shadow.
|
||||
|
||||
/* --------------------------- Javac opts ------------------------------- */
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-parameters")
|
||||
options.isFork = true
|
||||
options.compilerArgs.add("-Xlint:deprecation")
|
||||
options.encoding = "UTF-8"
|
||||
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.
|
||||
}
|
||||
|
||||
/* ------------------------------ Eclipse SHIM ------------------------- */
|
||||
|
||||
// This can't be put in eclipse.gradle.kts because Gradle is weird.
|
||||
subprojects {
|
||||
apply(plugin = "java-library")
|
||||
apply(plugin = "eclipse")
|
||||
eclipse.project.name = "${project.name}-${rootProject.name}"
|
||||
tasks.withType<Jar>().configureEach { archiveBaseName.set("${project.name}-${rootProject.name}") }
|
||||
}
|
||||
@@ -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>
|
||||
@@ -0,0 +1,151 @@
|
||||
/* This is free and unencumbered software released into the public domain */
|
||||
|
||||
import org.gradle.plugins.ide.eclipse.model.EclipseModel
|
||||
import java.nio.file.Files
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.transform.OutputKeys
|
||||
import javax.xml.transform.TransformerFactory
|
||||
import javax.xml.transform.dom.DOMSource
|
||||
import javax.xml.transform.stream.StreamResult
|
||||
|
||||
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
|
||||
|
||||
val kotlinPluginProjects = configurations
|
||||
.getByName("compileClasspath")
|
||||
.allDependencies
|
||||
.filterIsInstance<ProjectDependency>()
|
||||
.filter { it -> it.attributes.getAttribute(kotlinAttribute) != null }
|
||||
.map { it.path }
|
||||
kotlinPluginProjects.forEach { evaluationDependsOn(it) }
|
||||
|
||||
val ideLibs: Configuration by
|
||||
configurations.creating {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
}
|
||||
|
||||
configure<EclipseModel> {
|
||||
project {
|
||||
name = "PlayerBounties-OG-Plugin"
|
||||
}
|
||||
classpath {
|
||||
plusConfigurations.add(ideLibs)
|
||||
}
|
||||
}
|
||||
|
||||
val ideLibDir = layout.buildDirectory.dir("ide-libs")
|
||||
val hashRegex = Regex("-[0-9a-fA-F]{10}(?=\\.jar$)") // Black magic.
|
||||
|
||||
val copyTasks = mutableListOf<TaskProvider<Copy>>()
|
||||
|
||||
kotlinPluginProjects.forEach { path ->
|
||||
val sub = project(path)
|
||||
val shadowJarProv = sub.tasks.named("shadowJar")
|
||||
val copyTask =
|
||||
tasks.register<Copy>("ideCopy${sub.name.replaceFirstChar(Char::titlecase)}") {
|
||||
dependsOn(shadowJarProv)
|
||||
from(shadowJarProv)
|
||||
into(ideLibDir)
|
||||
rename { it.replace(hashRegex, "") } // Remove git commit hash from jarfile.
|
||||
}
|
||||
copyTasks += copyTask
|
||||
}
|
||||
|
||||
/* Ensure the jars exist before .classpath is generated */
|
||||
tasks.named("eclipseClasspath").configure { dependsOn(copyTasks) }
|
||||
|
||||
/* Supply those jars to the ideLibs configuration (after evaluation) */
|
||||
afterEvaluate { dependencies { add("ideLibs", fileTree(ideLibDir) { include("*.jar") }) } }
|
||||
|
||||
val injectIdeLibs =
|
||||
tasks.register("injectIdeLibs") {
|
||||
dependsOn("eclipse") // run after all eclipse files are generated
|
||||
doLast {
|
||||
val cpFile = file(".classpath")
|
||||
if (!cpFile.exists()) return@doLast
|
||||
|
||||
val jars = fileTree(ideLibDir.get()) { include("*.jar") }.files.sortedBy { it.name }
|
||||
if (jars.isEmpty()) return@doLast
|
||||
|
||||
// Parse DOM
|
||||
val dbf = DocumentBuilderFactory.newInstance()
|
||||
val doc = dbf.newDocumentBuilder().parse(cpFile)
|
||||
val root = doc.documentElement
|
||||
|
||||
// Helper to see if an entry already exists
|
||||
fun exists(path: String): Boolean =
|
||||
root.getElementsByTagName("classpathentry").let { list ->
|
||||
(0 until list.length).any { i ->
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue
|
||||
kind == "lib" && p == path
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any entry that points to ide-libs dir (folder or jars) to avoid dupes
|
||||
val toRemove = mutableListOf<org.w3c.dom.Node>()
|
||||
val list = root.getElementsByTagName("classpathentry")
|
||||
val dirPath = ideLibDir.get().asFile.absolutePath
|
||||
for (i in 0 until list.length) {
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue ?: ""
|
||||
if (kind == "lib" && (p == dirPath || p.startsWith("$dirPath/"))) {
|
||||
toRemove += n
|
||||
}
|
||||
}
|
||||
toRemove.forEach { root.removeChild(it) }
|
||||
|
||||
// Append our jar entries LAST
|
||||
jars.forEach { f ->
|
||||
val abs = f.absolutePath
|
||||
if (!exists(abs)) {
|
||||
val entry = doc.createElement("classpathentry")
|
||||
entry.setAttribute("kind", "lib")
|
||||
entry.setAttribute("path", abs)
|
||||
root.appendChild(entry)
|
||||
}
|
||||
}
|
||||
|
||||
// Write back pretty
|
||||
val tf =
|
||||
TransformerFactory.newInstance().newTransformer().apply {
|
||||
setOutputProperty(OutputKeys.INDENT, "yes")
|
||||
setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1")
|
||||
setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no")
|
||||
setOutputProperty(OutputKeys.ENCODING, "UTF-8")
|
||||
}
|
||||
Files.newBufferedWriter(cpFile.toPath()).use { w -> tf.transform(DOMSource(doc), StreamResult(w)) }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("eclipse").configure { finalizedBy(injectIdeLibs) }
|
||||
|
||||
val eclipseModel = extensions.getByType<EclipseModel>()
|
||||
|
||||
fun Project.addResolvableEclipseConfigs() {
|
||||
val jarAttr =
|
||||
objects.named(org.gradle.api.attributes.LibraryElements::class, org.gradle.api.attributes.LibraryElements.JAR)
|
||||
val apiAttr = objects.named(org.gradle.api.attributes.Usage::class, org.gradle.api.attributes.Usage.JAVA_API)
|
||||
|
||||
val compileOnlyRes =
|
||||
configurations.create("eclipseCompileOnly") {
|
||||
extendsFrom(configurations.getByName("compileOnly"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
val compileOnlyApiRes =
|
||||
configurations.create("eclipseCompileOnlyApi") {
|
||||
extendsFrom(configurations.getByName("compileOnlyApi"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
eclipseModel.classpath.plusConfigurations.addAll(listOf(compileOnlyRes, compileOnlyApiRes))
|
||||
}
|
||||
|
||||
addResolvableEclipseConfigs()
|
||||
Submodule
+1
Submodule libs/DiamondBank-OG added at b57a37a5db.
Submodule
+1
Submodule libs/Utilities-OG added at 3705eafbc3.
@@ -1 +1,13 @@
|
||||
rootProject.name = "PlayerBounties-OG"
|
||||
|
||||
ProcessBuilder("sh", "bootstrap.sh").directory(rootDir).inheritIO().start().let {
|
||||
if (it.waitFor() != 0) throw GradleException("bootstrap.sh failed")
|
||||
}
|
||||
|
||||
file("libs")
|
||||
.listFiles()
|
||||
?.filter { it.isDirectory && !it.name.startsWith(".") }
|
||||
?.forEach { dir ->
|
||||
include(":libs:${dir.name}")
|
||||
project(":libs:${dir.name}").projectDir = dir
|
||||
}
|
||||
@@ -0,0 +1,311 @@
|
||||
package com.tcoded.playerbountiesplus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.tcoded.playerbountiesplus.command.BountyCommand;
|
||||
import com.tcoded.playerbountiesplus.command.PlayerBountiesPlusAdminCmd;
|
||||
import com.tcoded.playerbountiesplus.hook.currency.DiamondBankOGHook;
|
||||
import com.tcoded.playerbountiesplus.hook.currency.EconomyHook;
|
||||
import com.tcoded.playerbountiesplus.hook.placeholder.PlaceholderHook;
|
||||
import com.tcoded.playerbountiesplus.hook.team.TeamHook;
|
||||
import com.tcoded.playerbountiesplus.listener.DeathListener;
|
||||
import com.tcoded.playerbountiesplus.listener.GuiListener;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import com.tcoded.playerbountiesplus.util.LangUtil;
|
||||
|
||||
import net.trueog.diamondbankog.DiamondBankAPIJava;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public final class PlayerBountiesOG extends JavaPlugin {
|
||||
|
||||
// Instance
|
||||
private static PlayerBountiesOG instance;
|
||||
|
||||
public static PlayerBountiesOG getInstance() {
|
||||
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
|
||||
return "&7[&cPlayerBounties&f-&4OG&7] ";
|
||||
|
||||
}
|
||||
|
||||
// Utilities.
|
||||
private LangUtil langUtil;
|
||||
|
||||
// Managers
|
||||
private BountyDataManager bountyDataManager;
|
||||
|
||||
// Hooks
|
||||
private EconomyHook ecoHook;
|
||||
private TeamHook teamHook;
|
||||
private PlaceholderHook placeholderHook;
|
||||
|
||||
// DiamondBank-OG Economy
|
||||
private static DiamondBankAPIJava diamondBankAPI;
|
||||
|
||||
public PlayerBountiesOG() {
|
||||
|
||||
instance = this;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
// Config
|
||||
saveDefaultConfig();
|
||||
|
||||
// Initialize the DiamondBank-OG API.
|
||||
final RegisteredServiceProvider<DiamondBankAPIJava> provider = getServer().getServicesManager()
|
||||
.getRegistration(DiamondBankAPIJava.class);
|
||||
|
||||
// If the DiamondBank-OG API failed to initialize, do this...
|
||||
if (provider == null) {
|
||||
|
||||
// Tell Bukkit to disable this plugin, and inform the console.
|
||||
disableSelf("DiamondBank-OG API is null – disabling " + getPluginMeta().getName() + "!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Assign the active instance of DiamondBank-OG to the API handler.
|
||||
diamondBankAPI = provider.getProvider();
|
||||
|
||||
// Utils
|
||||
this.reloadLang();
|
||||
|
||||
// Managers
|
||||
this.bountyDataManager = new BountyDataManager(this);
|
||||
this.bountyDataManager.init();
|
||||
|
||||
// Economy Hooks
|
||||
registerDefaultEcoHooks();
|
||||
if (!applyEcoHookRegistration()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Team Hooks
|
||||
this.teamHook = TeamHook.findTeamHook(this);
|
||||
if (this.teamHook == null) {
|
||||
|
||||
getLogger().warning(
|
||||
"There is no supported team/clan/party plugin on the server! Feel free to request support for the plugin you use on GitHub or Discord!");
|
||||
|
||||
}
|
||||
|
||||
// Placeholder Hooks
|
||||
this.placeholderHook = PlaceholderHook.findPlaceholderHook(this);
|
||||
this.placeholderHook.enable();
|
||||
|
||||
// Commands
|
||||
final PluginCommand bountyCmd = this.getCommand("bounty");
|
||||
if (bountyCmd != null) {
|
||||
|
||||
final BountyCommand bountyExec = new BountyCommand(this);
|
||||
bountyCmd.setExecutor(bountyExec);
|
||||
bountyCmd.setTabCompleter(bountyExec);
|
||||
|
||||
}
|
||||
|
||||
final PluginCommand adminCmd = this.getCommand("playerbountiesplusadmin");
|
||||
if (adminCmd != null) {
|
||||
|
||||
final PlayerBountiesPlusAdminCmd adminExec = new PlayerBountiesPlusAdminCmd(this);
|
||||
adminCmd.setExecutor(adminExec);
|
||||
adminCmd.setTabCompleter(adminExec);
|
||||
|
||||
}
|
||||
|
||||
// Listeners
|
||||
this.getServer().getPluginManager().registerEvents(new DeathListener(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new GuiListener(), this);
|
||||
|
||||
final List<Plugin> plugins = ImmutableList.copyOf(this.getServer().getPluginManager().getPlugins());
|
||||
findPluginWithQuery(plugins, "team");
|
||||
findPluginWithQuery(plugins, "teams");
|
||||
findPluginWithQuery(plugins, "clan");
|
||||
findPluginWithQuery(plugins, "clans");
|
||||
findPluginWithQuery(plugins, "party", "voteparty");
|
||||
findPluginWithQuery(plugins, "parties");
|
||||
findPluginWithQuery(plugins, "guild");
|
||||
findPluginWithQuery(plugins, "guilds");
|
||||
|
||||
}
|
||||
|
||||
public void reloadLang() {
|
||||
|
||||
this.langUtil = new LangUtil(this, this.getConfig().getString("lang", "en_us").toLowerCase());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
this.placeholderHook.disable();
|
||||
|
||||
}
|
||||
|
||||
public EconomyHook getEcoHook() {
|
||||
|
||||
return this.ecoHook;
|
||||
|
||||
}
|
||||
|
||||
public TeamHook getTeamHook() {
|
||||
|
||||
return teamHook;
|
||||
|
||||
}
|
||||
|
||||
public PlaceholderHook getPlaceholderHook() {
|
||||
|
||||
return placeholderHook;
|
||||
|
||||
}
|
||||
|
||||
public BountyDataManager getBountyDataManager() {
|
||||
|
||||
return bountyDataManager;
|
||||
|
||||
}
|
||||
|
||||
public LangUtil getLang() {
|
||||
|
||||
return this.langUtil;
|
||||
|
||||
}
|
||||
|
||||
// Utils
|
||||
|
||||
private static void findPluginWithQuery(List<Plugin> plugins, String pluginNameQuery, String... excludeStrings) {
|
||||
|
||||
final String firstPluginFound = plugins.stream().filter(p -> {
|
||||
|
||||
final String lowerName = p.getName().toLowerCase();
|
||||
// If the plugin name doesn't contain the query, skip
|
||||
if (!lowerName.contains(pluginNameQuery)) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// If the plugin name contains any of the exclude strings, skip
|
||||
for (String excludeString : excludeStrings) {
|
||||
|
||||
if (lowerName.contains(excludeString)) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}).findFirst().map(p -> {
|
||||
|
||||
final List<String> authors = p.getPluginMeta().getAuthors();
|
||||
return p.getName() + " (" + (authors.isEmpty() ? "N/A" : authors.get(0)) + ")";
|
||||
|
||||
}).orElse(null);
|
||||
|
||||
if (firstPluginFound == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void registerDefaultEcoHooks() {
|
||||
|
||||
final ServicesManager servicesManager = getServer().getServicesManager();
|
||||
|
||||
// Unregister old eco hooks
|
||||
servicesManager.unregisterAll(this);
|
||||
|
||||
// Register vault economy hook
|
||||
final DiamondBankOGHook diamondBankOGHook = new DiamondBankOGHook(getInstance(), diamondBankAPI);
|
||||
final boolean ecoPresent = diamondBankOGHook.init();
|
||||
|
||||
// Register or fallback
|
||||
if (ecoPresent) {
|
||||
|
||||
servicesManager.register(EconomyHook.class, diamondBankOGHook, this, ServicePriority.Low);
|
||||
|
||||
} else {
|
||||
|
||||
PlayerBountiesOG.disableSelf("DiamondBank-OG plugin not found, cannot proceed without it!");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean applyEcoHookRegistration() {
|
||||
|
||||
// Get economy hook
|
||||
final ServicesManager servicesManager = getServer().getServicesManager();
|
||||
final RegisteredServiceProvider<EconomyHook> ecoHookProvider = servicesManager
|
||||
.getRegistration(EconomyHook.class);
|
||||
if (ecoHookProvider == null) {
|
||||
|
||||
getLogger().severe("No economy hook is present! Aborting startup!");
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
final String hookName = ecoHookProvider.getProvider().getClass().getSimpleName();
|
||||
final String hookPluginName = ecoHookProvider.getPlugin().getName();
|
||||
|
||||
getLogger().info("Using economy hook: " + hookName + " from plugin: " + hookPluginName);
|
||||
this.ecoHook = ecoHookProvider.getProvider();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Helps this plugin kill itself gracefully (in minecraft).
|
||||
public static void disableSelf(String reason) {
|
||||
|
||||
// Run a meta-task on the Bukkit server outside of the context of this plugin.
|
||||
Bukkit.getScheduler().runTask(Bukkit.getServer().getPluginManager().getPlugin("PlayerBounties-OG"), () -> {
|
||||
|
||||
// Attempt to fetch the active instance of this plugin.
|
||||
final PlayerBountiesOG pluginInstance = getInstance();
|
||||
|
||||
// If this plugin is already disabled, do this...
|
||||
if (!pluginInstance.isEnabled()) {
|
||||
|
||||
// Do nothing, task already completed.
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Inform console of this plugin being disabled.
|
||||
UtilitiesOG.logToConsole("&f[&bPlayerBountiesPlus&f]", reason);
|
||||
|
||||
// Commit sudoku.
|
||||
Bukkit.getPluginManager().disablePlugin(pluginInstance);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
package com.tcoded.playerbountiesplus;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.tcoded.folialib.FoliaLib;
|
||||
import com.tcoded.playerbountiesplus.command.BountyCommand;
|
||||
import com.tcoded.playerbountiesplus.command.PlayerBountiesPlusAdminCmd;
|
||||
import com.tcoded.playerbountiesplus.hook.currency.EconomyHook;
|
||||
import com.tcoded.playerbountiesplus.hook.currency.DummyEcoHook;
|
||||
import com.tcoded.playerbountiesplus.hook.currency.VaultHook;
|
||||
import com.tcoded.playerbountiesplus.hook.placeholder.PlaceholderHook;
|
||||
import com.tcoded.playerbountiesplus.hook.team.AbstractTeamHook;
|
||||
import com.tcoded.playerbountiesplus.hook.team.TeamHook;
|
||||
import com.tcoded.playerbountiesplus.listener.DeathListener;
|
||||
import com.tcoded.playerbountiesplus.listener.GuiListener;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import com.tcoded.playerbountiesplus.util.LangUtil;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class PlayerBountiesPlus extends JavaPlugin {
|
||||
|
||||
// Instance
|
||||
private static PlayerBountiesPlus instance;
|
||||
|
||||
public static PlayerBountiesPlus getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
// Utils
|
||||
private FoliaLib foliaLib;
|
||||
private LangUtil langUtil;
|
||||
|
||||
// Managers
|
||||
private BountyDataManager bountyDataManager;
|
||||
|
||||
// Hooks
|
||||
private EconomyHook ecoHook;
|
||||
private TeamHook teamHook;
|
||||
private PlaceholderHook placeholderHook;
|
||||
|
||||
public PlayerBountiesPlus() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Config
|
||||
saveDefaultConfig();
|
||||
FileConfiguration config = this.getConfig();
|
||||
|
||||
// Utils
|
||||
this.foliaLib = new FoliaLib(this);
|
||||
this.reloadLang();
|
||||
|
||||
// Managers
|
||||
this.bountyDataManager = new BountyDataManager(this);
|
||||
this.bountyDataManager.init();
|
||||
|
||||
// Economy Hooks
|
||||
registerDefaultEcoHooks();
|
||||
if (!applyEcoHookRegistration()) return;
|
||||
|
||||
// Team Hooks
|
||||
this.teamHook = TeamHook.findTeamHook(this);
|
||||
if (this.teamHook == null) {
|
||||
getLogger().warning("There is no supported team/clan/party plugin on the server! Feel free to request support for the plugin you use on GitHub or Discord!");
|
||||
}
|
||||
|
||||
// Placeholder Hooks
|
||||
this.placeholderHook = PlaceholderHook.findPlaceholderHook(this);
|
||||
this.placeholderHook.enable();
|
||||
|
||||
// Commands
|
||||
PluginCommand bountyCmd = this.getCommand("bounty");
|
||||
if (bountyCmd != null) {
|
||||
BountyCommand bountyExec = new BountyCommand(this);
|
||||
bountyCmd.setExecutor(bountyExec);
|
||||
bountyCmd.setTabCompleter(bountyExec);
|
||||
}
|
||||
PluginCommand adminCmd = this.getCommand("playerbountiesplusadmin");
|
||||
if (adminCmd != null) {
|
||||
PlayerBountiesPlusAdminCmd adminExec = new PlayerBountiesPlusAdminCmd(this);
|
||||
adminCmd.setExecutor(adminExec);
|
||||
adminCmd.setTabCompleter(adminExec);
|
||||
}
|
||||
|
||||
// Listeners
|
||||
this.getServer().getPluginManager().registerEvents(new DeathListener(this), this);
|
||||
this.getServer().getPluginManager().registerEvents(new GuiListener(), this);
|
||||
|
||||
List<Plugin> plugins = ImmutableList.copyOf(this.getServer().getPluginManager().getPlugins());
|
||||
findPluginWithQuery(plugins, "team");
|
||||
findPluginWithQuery(plugins, "teams");
|
||||
findPluginWithQuery(plugins, "clan");
|
||||
findPluginWithQuery(plugins, "clans");
|
||||
findPluginWithQuery(plugins, "party", "voteparty");
|
||||
findPluginWithQuery(plugins, "parties");
|
||||
findPluginWithQuery(plugins, "guild");
|
||||
findPluginWithQuery(plugins, "guilds");
|
||||
}
|
||||
|
||||
public void reloadLang() {
|
||||
this.langUtil = new LangUtil(this, this.getConfig().getString("lang", "en_us").toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
HandlerList.unregisterAll(this);
|
||||
this.placeholderHook.disable();
|
||||
}
|
||||
|
||||
public EconomyHook getEcoHook() {
|
||||
return this.ecoHook;
|
||||
}
|
||||
|
||||
public TeamHook getTeamHook() {
|
||||
return teamHook;
|
||||
}
|
||||
|
||||
public PlaceholderHook getPlaceholderHook() {
|
||||
return placeholderHook;
|
||||
}
|
||||
|
||||
public BountyDataManager getBountyDataManager() {
|
||||
return bountyDataManager;
|
||||
}
|
||||
|
||||
public FoliaLib getFoliaLib() {
|
||||
return this.foliaLib;
|
||||
}
|
||||
|
||||
public LangUtil getLang() {
|
||||
return this.langUtil;
|
||||
}
|
||||
|
||||
// Utils
|
||||
|
||||
private static void findPluginWithQuery(List<Plugin> plugins, String pluginNameQuery, String... excludeStrings) {
|
||||
String firstPluginFound = plugins.stream()
|
||||
.filter(p -> {
|
||||
String lowerName = p.getName().toLowerCase();
|
||||
// If the plugin name doesn't contain the query, skip
|
||||
if (!lowerName.contains(pluginNameQuery)) return false;
|
||||
// If the plugin name contains any of the exclude strings, skip
|
||||
for (String excludeString : excludeStrings) {
|
||||
if (lowerName.contains(excludeString)) return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.findFirst()
|
||||
.map(p -> {
|
||||
List<String> authors = p.getDescription().getAuthors();
|
||||
return p.getName() + " (" + (authors.isEmpty() ? "N/A" : authors.get(0)) + ")";
|
||||
}).orElse(null);
|
||||
|
||||
if (firstPluginFound == null) return;
|
||||
|
||||
}
|
||||
|
||||
private void registerDefaultEcoHooks() {
|
||||
ServicesManager servicesManager = getServer().getServicesManager();
|
||||
|
||||
// Unregister old eco hooks
|
||||
servicesManager.unregisterAll(this);
|
||||
|
||||
// Register vault economy hook
|
||||
VaultHook vaultEcoHook = new VaultHook(this);
|
||||
boolean ecoPresent = vaultEcoHook.init();
|
||||
|
||||
// Register or fallback
|
||||
if (ecoPresent) servicesManager.register(EconomyHook.class, vaultEcoHook, this, ServicePriority.Low);
|
||||
else servicesManager.register(EconomyHook.class, new DummyEcoHook(), this, ServicePriority.Lowest);
|
||||
}
|
||||
|
||||
public boolean applyEcoHookRegistration() {
|
||||
// Get economy hook
|
||||
ServicesManager servicesManager = getServer().getServicesManager();
|
||||
RegisteredServiceProvider<EconomyHook> ecoHookProvider = servicesManager.getRegistration(EconomyHook.class);
|
||||
if (ecoHookProvider == null) {
|
||||
getLogger().severe("No economy hook is present! Aborting startup!");
|
||||
return false;
|
||||
}
|
||||
|
||||
String hookName = ecoHookProvider.getProvider().getClass().getSimpleName();
|
||||
String hookPluginName = ecoHookProvider.getPlugin().getName();
|
||||
|
||||
getLogger().info("Using economy hook: " + hookName + " from plugin: " + hookPluginName);
|
||||
this.ecoHook = ecoHookProvider.getProvider();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.tcoded.playerbountiesplus.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.command.bounty.BountyCheckCmd;
|
||||
import com.tcoded.playerbountiesplus.command.bounty.BountySetCmd;
|
||||
import com.tcoded.playerbountiesplus.command.bounty.BountyTopCmd;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,67 +11,89 @@ import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.command.bounty.BountyCheckCmd;
|
||||
import com.tcoded.playerbountiesplus.command.bounty.BountySetCmd;
|
||||
import com.tcoded.playerbountiesplus.command.bounty.BountyTopCmd;
|
||||
|
||||
public class BountyCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
private PlayerBountiesPlus plugin;
|
||||
private final PlayerBountiesOG plugin;
|
||||
|
||||
public BountyCommand(PlayerBountiesOG plugin) {
|
||||
|
||||
public BountyCommand(PlayerBountiesPlus plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String cmdName, String[] args) {
|
||||
|
||||
if (args.length < 1) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.no-action"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String action = args[0].toLowerCase();
|
||||
|
||||
final String action = args[0].toLowerCase();
|
||||
switch (action) {
|
||||
case "set":
|
||||
|
||||
case "set" -> {
|
||||
|
||||
return BountySetCmd.handleCmd(plugin, sender, cmd, cmdName, args);
|
||||
case "top":
|
||||
|
||||
}
|
||||
case "top" -> {
|
||||
|
||||
return BountyTopCmd.handleCmd(plugin, sender, cmd, cmdName, args);
|
||||
case "check":
|
||||
|
||||
}
|
||||
case "check" -> {
|
||||
|
||||
return BountyCheckCmd.handleCmd(plugin, sender, cmd, cmdName, args);
|
||||
default:
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.invalid-action"));
|
||||
|
||||
}
|
||||
default -> sender.sendMessage(plugin.getLang().getColored("command.bounty.invalid-action"));
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
@NotNull String[] args)
|
||||
{
|
||||
|
||||
if (args.length == 1) {
|
||||
|
||||
return Lists.newArrayList("set", "top", "check").stream()
|
||||
.filter(action -> action.startsWith(args[0].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
.filter(action -> action.startsWith(args[0].toLowerCase())).collect(Collectors.toList());
|
||||
|
||||
} else if (args.length > 1) {
|
||||
String subCommand = args[0].toLowerCase();
|
||||
switch (subCommand) {
|
||||
case "set":
|
||||
return BountySetCmd.onTabComplete(sender, args).stream()
|
||||
.filter(suggestion -> suggestion.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
case "check":
|
||||
return BountyCheckCmd.onTabComplete(sender, args).stream()
|
||||
.filter(suggestion -> suggestion.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
case "top":
|
||||
return Collections.emptyList(); // No additional arguments for top
|
||||
default:
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final String subCommand = args[0].toLowerCase();
|
||||
return switch (subCommand) {
|
||||
|
||||
case "set" -> BountySetCmd.onTabComplete(sender, args).stream()
|
||||
.filter(suggestion -> suggestion.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
case "check" -> BountyCheckCmd.onTabComplete(sender, args).stream()
|
||||
.filter(suggestion -> suggestion.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
case "top" -> Collections.emptyList();
|
||||
default -> Collections.emptyList();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+84
-54
@@ -1,90 +1,120 @@
|
||||
package com.tcoded.playerbountiesplus.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.command.admin.PlayerBountiesPlusReloadCmd;
|
||||
import com.tcoded.playerbountiesplus.command.admin.PlayerBountiesPlusVersionCmd;
|
||||
import com.tcoded.playerbountiesplus.command.admin.bounty.AdminBountyCmd;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.command.admin.PlayerBountiesPlusReloadCmd;
|
||||
import com.tcoded.playerbountiesplus.command.admin.PlayerBountiesPlusVersionCmd;
|
||||
import com.tcoded.playerbountiesplus.command.admin.bounty.AdminBountyCmd;
|
||||
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class PlayerBountiesPlusAdminCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private static final ArrayList<String> completions = Lists.newArrayList("reload", "version", "bounty", "help");
|
||||
|
||||
private final PlayerBountiesPlus plugin;
|
||||
private final PlayerBountiesOG plugin;
|
||||
|
||||
public PlayerBountiesPlusAdminCmd(PlayerBountiesOG plugin) {
|
||||
|
||||
public PlayerBountiesPlusAdminCmd(PlayerBountiesPlus plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
@NotNull String[] args)
|
||||
{
|
||||
|
||||
if (args.length < 1) {
|
||||
|
||||
sendHelpMsg(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String arg0Lower = args[0].toLowerCase();
|
||||
final String arg0Lower = args[0].toLowerCase();
|
||||
return switch (arg0Lower) {
|
||||
|
||||
case "reload" -> PlayerBountiesPlusReloadCmd.handleCmd(plugin, sender, command, label, args);
|
||||
case "version" -> PlayerBountiesPlusVersionCmd.handleCmd(plugin, sender, command, label, args);
|
||||
case "bounty" -> AdminBountyCmd.handleCmd(plugin, sender, command, label, args);
|
||||
default -> {
|
||||
|
||||
switch (arg0Lower) {
|
||||
case "reload":
|
||||
return PlayerBountiesPlusReloadCmd.handleCmd(plugin, sender, command, label, args);
|
||||
case "version":
|
||||
return PlayerBountiesPlusVersionCmd.handleCmd(plugin, sender, command, label, args);
|
||||
case "bounty":
|
||||
return AdminBountyCmd.handleCmd(plugin, sender, command, label, args);
|
||||
default:
|
||||
sendHelpMsg(sender);
|
||||
return true;
|
||||
}
|
||||
yield true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private void sendHelpMsg(CommandSender sender) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
"&f[&bPlayerBountiesPlus&f] &7PlayerBountiesPlus by TechnicallyCoded\n" +
|
||||
"&fAdmin Commands:\n" +
|
||||
"&f/pbp reload &7- Reload the configuration file and the messages.\n" +
|
||||
"&f/pbp version &7- Check the version of the plugin.\n" +
|
||||
"&f/pbp bounty set <player> <amount> &7- Set a player's bounty.\n" +
|
||||
"&f/pbp bounty add <player> <amount> &7- Add to a player's bounty.\n" +
|
||||
"&f/pbp bounty remove <player> <amount> &7- Remove from a player's bounty.\n" +
|
||||
"&f/pbp bounty delete <player> &7- Delete a player's bounty.\n" +
|
||||
"&f/pbp help &7- Get this message."
|
||||
));
|
||||
|
||||
final String help = """
|
||||
&f[&bPlayerBountiesPlus&f] &7PlayerBountiesPlus by TechnicallyCoded
|
||||
&fAdmin Commands:
|
||||
&f/pbp reload &7- Reload the configuration file and the messages.
|
||||
&f/pbp version &7- Check the version of the plugin.
|
||||
&f/pbp bounty set <player> <amount> &7- Set a player's bounty.
|
||||
&f/pbp bounty add <player> <amount> &7- Add to a player's bounty.
|
||||
&f/pbp bounty remove <player> <amount> &7- Remove from a player's bounty.
|
||||
&f/pbp bounty delete <player> &7- Delete a player's bounty.
|
||||
&f/pbp help &7- Get this message.\
|
||||
""";
|
||||
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
sender.sendMessage(UtilitiesOG.trueogExpand(help, player));
|
||||
|
||||
} else {
|
||||
|
||||
sender.sendMessage(UtilitiesOG.stripFormatting(help));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
@NotNull String[] args)
|
||||
{
|
||||
|
||||
if (args.length == 1) {
|
||||
return completions.stream()
|
||||
.filter(s -> s.toLowerCase().startsWith(args[0].toLowerCase()))
|
||||
|
||||
return completions.stream().filter(s -> s.toLowerCase().startsWith(args[0].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
} else if (args.length > 1) {
|
||||
String subCommand = args[0].toLowerCase();
|
||||
switch (subCommand) {
|
||||
case "bounty":
|
||||
return AdminBountyCmd.onTabComplete(sender, args);
|
||||
case "version":
|
||||
return PlayerBountiesPlusVersionCmd.onTabComplete(sender, args);
|
||||
case "reload":
|
||||
case "help":
|
||||
return Collections.emptyList(); // No additional arguments for reload or help
|
||||
default:
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final String subCommand = args[0].toLowerCase();
|
||||
return switch (subCommand) {
|
||||
|
||||
case "bounty" -> AdminBountyCmd.onTabComplete(sender, args);
|
||||
case "version" -> PlayerBountiesPlusVersionCmd.onTabComplete(sender, args);
|
||||
case "reload", "help" -> Collections.emptyList();
|
||||
default -> Collections.emptyList();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+20
-10
@@ -1,28 +1,32 @@
|
||||
package com.tcoded.playerbountiesplus.command.admin;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
|
||||
public class PlayerBountiesPlusReloadCmd implements TabCompleter {
|
||||
|
||||
private static final String RELOAD_PERMISSION = "playerbountiesplus.command.playerbountiesplus.reload";
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String cmdName, String[] args) {
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String cmdName,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (!sender.hasPermission(RELOAD_PERMISSION)) {
|
||||
String noPerm = plugin.getLang().getColored("command.no-permission");
|
||||
String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed")
|
||||
.replace("{no-permission-msg}", noPerm)
|
||||
.replace("{permission}", RELOAD_PERMISSION);
|
||||
|
||||
final String noPerm = plugin.getLang().getColored("command.no-permission").content();
|
||||
final String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed").content()
|
||||
.replace("{no-permission-msg}", noPerm).replace("{permission}", RELOAD_PERMISSION);
|
||||
sender.sendMessage(noPermDetailed);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
plugin.reloadConfig();
|
||||
@@ -31,12 +35,18 @@ public class PlayerBountiesPlusReloadCmd implements TabCompleter {
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.reload.reloaded"));
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
@NotNull String[] args)
|
||||
{
|
||||
|
||||
// No additional arguments for reload command
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+36
-18
@@ -1,41 +1,59 @@
|
||||
package com.tcoded.playerbountiesplus.command.admin;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.util.LangUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.util.LangUtil;
|
||||
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class PlayerBountiesPlusVersionCmd {
|
||||
|
||||
private static final String VERSION_PERMISSION = "playerbountiesplus.command.playerbountiesplus.version";
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String cmdName, String[] args) {
|
||||
LangUtil lang = plugin.getLang();
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String cmdName,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
String version;
|
||||
final LangUtil lang = plugin.getLang();
|
||||
|
||||
final String version;
|
||||
if (sender.hasPermission(VERSION_PERMISSION)) {
|
||||
version = "v" + plugin.getDescription().getVersion();
|
||||
|
||||
version = "v" + plugin.getPluginMeta().getVersion();
|
||||
|
||||
} else {
|
||||
|
||||
version = "\n" + lang.getColored("command.admin.version.no-permission");
|
||||
|
||||
}
|
||||
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',
|
||||
"&f[&bPlayerBountiesPlus&f] Plugin Information:\n" +
|
||||
"&fPlugin: &7Running PlayerBountiesPlus " + version + "\n" +
|
||||
"&fAuthor: &7TechnicallyCoded\n" +
|
||||
"&fUpdate URL: &9https://www.spigotmc.org/resources/player-bounties-plus.108637/"
|
||||
));
|
||||
UtilitiesOG.trueogMessage(player, PlayerBountiesOG.getPrefix()
|
||||
+ "&6 Authors: &aTechnicallyCoded, NotAlexNoyle &6Version: &e" + version);
|
||||
|
||||
} else {
|
||||
|
||||
UtilitiesOG.logToConsole(PlayerBountiesOG.getPrefix(),
|
||||
"Authors: TechnicallyCoded, NotAlexNoyle Version: " + version);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public static List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
// No sub-commands for version, return empty list
|
||||
|
||||
// No sub-commands for version, return empty list.
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+52
-30
@@ -1,77 +1,99 @@
|
||||
package com.tcoded.playerbountiesplus.command.admin.bounty;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
|
||||
public class AdminBountyAddCmd {
|
||||
|
||||
private static final String PERMISSION = "playerbountiesplus.command.admin.bounty.add";
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String label, String[] args) {
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (!sender.hasPermission(PERMISSION)) {
|
||||
String noPerm = plugin.getLang().getColored("command.no-permission");
|
||||
String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed")
|
||||
.replace("{no-permission-msg}", noPerm)
|
||||
.replace("{permission}", PERMISSION);
|
||||
|
||||
final String noPerm = plugin.getLang().getColored("command.no-permission").content();
|
||||
final String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed").content()
|
||||
.replace("{no-permission-msg}", noPerm).replace("{permission}", PERMISSION);
|
||||
sender.sendMessage(noPermDetailed);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args.length < 4) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.add.missing-args"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String playerName = args[2];
|
||||
int amount;
|
||||
final String playerName = args[2];
|
||||
final int amount;
|
||||
try {
|
||||
|
||||
amount = Integer.parseInt(args[3]);
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.add.amount-nan"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
final OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
if (target == null || (!target.hasPlayedBefore() && !target.isOnline())) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.add.player-not-found"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
UUID uuid = target.getUniqueId();
|
||||
BountyDataManager m = plugin.getBountyDataManager();
|
||||
int current = m.getBounty(uuid);
|
||||
int total = current + amount;
|
||||
final UUID uuid = target.getUniqueId();
|
||||
final BountyDataManager m = plugin.getBountyDataManager();
|
||||
final int current = m.getBounty(uuid);
|
||||
final int total = current + amount;
|
||||
m.setBounty(uuid, total);
|
||||
m.saveBountiesAsync();
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.add.success")
|
||||
.replace("{target}", target.getName())
|
||||
.replace("{amount}", String.valueOf(amount))
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.add.success").content()
|
||||
.replace("{target}", target.getName()).replace("{amount}", String.valueOf(amount))
|
||||
.replace("{total}", String.valueOf(total)));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
|
||||
if (args.length == 3) {
|
||||
// Suggest all online player names for the username
|
||||
return sender.getServer().getOnlinePlayers().stream()
|
||||
.map(player -> player.getName())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// Suggest all online player names for the username.
|
||||
return sender.getServer().getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
|
||||
} else if (args.length == 4) {
|
||||
// Suggest a placeholder for the amount
|
||||
|
||||
// Suggest a placeholder for the amount.
|
||||
return Collections.singletonList("<amount>");
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+20
-5
@@ -1,6 +1,6 @@
|
||||
package com.tcoded.playerbountiesplus.command.admin.bounty;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -11,14 +11,20 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class AdminBountyCmd {
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String label, String[] args) {
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (args.length < 2) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.no-action"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String action = args[1].toLowerCase();
|
||||
switch (action) {
|
||||
|
||||
case "set":
|
||||
return AdminBountySetCmd.handleCmd(plugin, sender, cmd, label, args);
|
||||
case "add":
|
||||
@@ -32,17 +38,24 @@ public class AdminBountyCmd {
|
||||
default:
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.invalid-action"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
|
||||
List<String> suggestions = Collections.emptyList();
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
suggestions = Arrays.asList("set", "add", "remove", "delete", "get");
|
||||
|
||||
} else if (args.length > 2) {
|
||||
|
||||
String sub = args[1].toLowerCase();
|
||||
switch (sub) {
|
||||
|
||||
case "add":
|
||||
suggestions = AdminBountyAddCmd.onTabComplete(sender, null, null, args);
|
||||
break;
|
||||
@@ -58,12 +71,14 @@ public class AdminBountyCmd {
|
||||
case "set":
|
||||
suggestions = AdminBountySetCmd.onTabComplete(sender, null, null, args);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String input = args[args.length - 1].toLowerCase();
|
||||
return suggestions.stream()
|
||||
.filter(opt -> opt.toLowerCase().startsWith(input))
|
||||
.collect(Collectors.toList());
|
||||
return suggestions.stream().filter(opt -> opt.toLowerCase().startsWith(input)).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+37
-21
@@ -1,7 +1,10 @@
|
||||
package com.tcoded.playerbountiesplus.command.admin.bounty;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -9,55 +12,68 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
|
||||
public class AdminBountyDeleteCmd {
|
||||
|
||||
private static final String PERMISSION = "playerbountiesplus.command.admin.bounty.delete";
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String label, String[] args) {
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (!sender.hasPermission(PERMISSION)) {
|
||||
String noPerm = plugin.getLang().getColored("command.no-permission");
|
||||
String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed")
|
||||
.replace("{no-permission-msg}", noPerm)
|
||||
.replace("{permission}", PERMISSION);
|
||||
|
||||
final String noPerm = plugin.getLang().getColored("command.no-permission").content();
|
||||
final String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed").content()
|
||||
.replace("{no-permission-msg}", noPerm).replace("{permission}", PERMISSION);
|
||||
sender.sendMessage(noPermDetailed);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.delete.missing-args"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String playerName = args[2];
|
||||
OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
final String playerName = args[2];
|
||||
final OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
if (target == null || (!target.hasPlayedBefore() && !target.isOnline())) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.delete.player-not-found"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
UUID uuid = target.getUniqueId();
|
||||
BountyDataManager m = plugin.getBountyDataManager();
|
||||
final UUID uuid = target.getUniqueId();
|
||||
final BountyDataManager m = plugin.getBountyDataManager();
|
||||
m.removeBounty(uuid);
|
||||
m.saveBountiesAsync();
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.delete.success")
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.delete.success").content()
|
||||
.replace("{target}", target.getName()));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
|
||||
if (args.length == 3) {
|
||||
|
||||
// Suggest all online player names for the username
|
||||
return sender.getServer().getOnlinePlayers().stream()
|
||||
.map(Player::getName)
|
||||
.collect(Collectors.toList());
|
||||
return sender.getServer().getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+42
-26
@@ -1,63 +1,79 @@
|
||||
package com.tcoded.playerbountiesplus.command.admin.bounty;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
|
||||
public class AdminBountyGetCmd {
|
||||
|
||||
private static final String PERMISSION = "playerbountiesplus.command.admin.bounty.get";
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String label, String[] args) {
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (!sender.hasPermission(PERMISSION)) {
|
||||
String noPerm = plugin.getLang().getColored("command.no-permission");
|
||||
String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed")
|
||||
.replace("{no-permission-msg}", noPerm)
|
||||
.replace("{permission}", PERMISSION);
|
||||
|
||||
final String noPerm = plugin.getLang().getColored("command.no-permission").content();
|
||||
final String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed").content()
|
||||
.replace("{no-permission-msg}", noPerm).replace("{permission}", PERMISSION);
|
||||
sender.sendMessage(noPermDetailed);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.get.missing-args"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String playerName = args[2];
|
||||
final String playerName = args[2];
|
||||
|
||||
OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
final OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
if (target == null || (!target.hasPlayedBefore() && !target.isOnline())) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.get.player-not-found"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
UUID uuid = target.getUniqueId();
|
||||
BountyDataManager m = plugin.getBountyDataManager();
|
||||
int current = m.getBounty(uuid);
|
||||
final UUID uuid = target.getUniqueId();
|
||||
final BountyDataManager m = plugin.getBountyDataManager();
|
||||
final int current = m.getBounty(uuid);
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.get.success")
|
||||
.replace("{target}", target.getName())
|
||||
.replace("{bounty}", String.valueOf(current)));
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.get.success").content()
|
||||
.replace("{target}", target.getName()).replace("{bounty}", String.valueOf(current)));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
|
||||
if (args.length == 3) {
|
||||
|
||||
// Suggest all online player names for the username
|
||||
return sender.getServer().getOnlinePlayers().stream()
|
||||
.map(player -> player.getName())
|
||||
.collect(Collectors.toList());
|
||||
return sender.getServer().getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+54
-27
@@ -1,82 +1,109 @@
|
||||
package com.tcoded.playerbountiesplus.command.admin.bounty;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
|
||||
public class AdminBountyRemoveCmd {
|
||||
|
||||
private static final String PERMISSION = "playerbountiesplus.command.admin.bounty.remove";
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String label, String[] args) {
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (!sender.hasPermission(PERMISSION)) {
|
||||
String noPerm = plugin.getLang().getColored("command.no-permission");
|
||||
String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed")
|
||||
.replace("{no-permission-msg}", noPerm)
|
||||
.replace("{permission}", PERMISSION);
|
||||
|
||||
final String noPerm = plugin.getLang().getColored("command.no-permission").content();
|
||||
final String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed").content()
|
||||
.replace("{no-permission-msg}", noPerm).replace("{permission}", PERMISSION);
|
||||
sender.sendMessage(noPermDetailed);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args.length < 4) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.remove.missing-args"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String playerName = args[2];
|
||||
int amount;
|
||||
final String playerName = args[2];
|
||||
final int amount;
|
||||
try {
|
||||
|
||||
amount = Integer.parseInt(args[3]);
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.remove.amount-nan"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
final OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
if (target == null || (!target.hasPlayedBefore() && !target.isOnline())) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.remove.player-not-found"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
UUID uuid = target.getUniqueId();
|
||||
BountyDataManager m = plugin.getBountyDataManager();
|
||||
int current = m.getBounty(uuid);
|
||||
final UUID uuid = target.getUniqueId();
|
||||
final BountyDataManager m = plugin.getBountyDataManager();
|
||||
final int current = m.getBounty(uuid);
|
||||
int total = current - amount;
|
||||
if (total <= 0) {
|
||||
|
||||
m.removeBounty(uuid);
|
||||
total = 0;
|
||||
|
||||
} else {
|
||||
|
||||
m.setBounty(uuid, total);
|
||||
|
||||
}
|
||||
|
||||
m.saveBountiesAsync();
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.remove.success")
|
||||
.replace("{target}", target.getName())
|
||||
.replace("{amount}", String.valueOf(amount))
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.remove.success").content()
|
||||
.replace("{target}", target.getName()).replace("{amount}", String.valueOf(amount))
|
||||
.replace("{total}", String.valueOf(total)));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
|
||||
if (args.length == 3) {
|
||||
|
||||
// Suggest all online player names for the username
|
||||
return sender.getServer().getOnlinePlayers().stream()
|
||||
.map(player -> player.getName())
|
||||
.collect(Collectors.toList());
|
||||
return sender.getServer().getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
|
||||
} else if (args.length == 4) {
|
||||
|
||||
// Suggest a placeholder for the amount
|
||||
return Collections.singletonList("<amount>");
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+48
-26
@@ -1,74 +1,96 @@
|
||||
package com.tcoded.playerbountiesplus.command.admin.bounty;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
|
||||
public class AdminBountySetCmd {
|
||||
|
||||
private static final String PERMISSION = "playerbountiesplus.command.admin.bounty.set";
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String label, String[] args) {
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (!sender.hasPermission(PERMISSION)) {
|
||||
String noPerm = plugin.getLang().getColored("command.no-permission");
|
||||
String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed")
|
||||
.replace("{no-permission-msg}", noPerm)
|
||||
.replace("{permission}", PERMISSION);
|
||||
|
||||
final String noPerm = plugin.getLang().getColored("command.no-permission").content();
|
||||
final String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed").content()
|
||||
.replace("{no-permission-msg}", noPerm).replace("{permission}", PERMISSION);
|
||||
sender.sendMessage(noPermDetailed);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args.length < 4) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.set.missing-args"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String playerName = args[2];
|
||||
int amount;
|
||||
final String playerName = args[2];
|
||||
final int amount;
|
||||
try {
|
||||
|
||||
amount = Integer.parseInt(args[3]);
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.set.amount-nan"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
final OfflinePlayer target = plugin.getServer().getOfflinePlayer(playerName);
|
||||
if (target == null || (!target.hasPlayedBefore() && !target.isOnline())) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.set.player-not-found"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
UUID uuid = target.getUniqueId();
|
||||
BountyDataManager m = plugin.getBountyDataManager();
|
||||
final UUID uuid = target.getUniqueId();
|
||||
final BountyDataManager m = plugin.getBountyDataManager();
|
||||
m.setBounty(uuid, amount);
|
||||
m.saveBountiesAsync();
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.set.success")
|
||||
.replace("{target}", target.getName())
|
||||
.replace("{bounty}", String.valueOf(amount)));
|
||||
sender.sendMessage(plugin.getLang().getColored("command.admin.bounty.set.success").content()
|
||||
.replace("{target}", target.getName()).replace("{bounty}", String.valueOf(amount)));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
|
||||
if (args.length == 3) {
|
||||
|
||||
// Suggest all online player names for the username
|
||||
return sender.getServer().getOnlinePlayers().stream()
|
||||
.map(player -> player.getName())
|
||||
.collect(Collectors.toList());
|
||||
return sender.getServer().getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
|
||||
} else if (args.length == 4) {
|
||||
|
||||
// Suggest a placeholder for the amount
|
||||
return Collections.singletonList("<amount>");
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +1,79 @@
|
||||
package com.tcoded.playerbountiesplus.command.bounty;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
|
||||
public class BountyCheckCmd {
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String cmdName, String[] args) {
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String cmdName,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (args.length < 2) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.check.no-player-specified"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String playerNameArg = args[1];
|
||||
final String playerNameArg = args[1];
|
||||
|
||||
Player target = plugin.getServer().getPlayerExact(playerNameArg);
|
||||
final Player target = plugin.getServer().getPlayerExact(playerNameArg);
|
||||
|
||||
if (target == null) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.check.player-not-found"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
UUID playerUUID = target.getUniqueId();
|
||||
final UUID playerUUID = target.getUniqueId();
|
||||
|
||||
BountyDataManager bountyDataManager = plugin.getBountyDataManager();
|
||||
boolean hasBounty = bountyDataManager.hasBounty(playerUUID);
|
||||
final BountyDataManager bountyDataManager = plugin.getBountyDataManager();
|
||||
final boolean hasBounty = bountyDataManager.hasBounty(playerUUID);
|
||||
|
||||
if (hasBounty) {
|
||||
|
||||
// Confirmation
|
||||
int bounty = bountyDataManager.getBounty(playerUUID);
|
||||
sender.sendMessage(
|
||||
plugin.getLang().getColored("command.bounty.check.bounty-found")
|
||||
.replace("{target}", target.getName())
|
||||
.replace("{bounty}", Integer.toString(bounty))
|
||||
);
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.check.bounty-found").content()
|
||||
.replace("{target}", target.getName()).replace("{bounty}", Integer.toString(bounty)));
|
||||
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
plugin.getLang().getColored("command.bounty.check.no-bounty")
|
||||
.replace("{target}", target.getName())
|
||||
);
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.check.no-bounty").content()
|
||||
.replace("{target}", target.getName()));
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull String[] args) {
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
// Suggest online player names for the username
|
||||
return sender.getServer().getOnlinePlayers().stream()
|
||||
.map(Player::getName)
|
||||
.filter(name -> name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
return sender.getServer().getOnlinePlayers().stream().map(Player::getName)
|
||||
.filter(name -> name.toLowerCase().startsWith(args[1].toLowerCase())).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,152 +1,187 @@
|
||||
package com.tcoded.playerbountiesplus.command.bounty;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.event.BountySetEvent;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.event.BountySetEvent;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class BountySetCmd {
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String cmdName, String[] args) {
|
||||
static float amount;
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String cmdName,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (args.length < 3) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.missing-args"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !sender.hasPermission("playerbountiesplus.command.bounty.set")) {
|
||||
String noPerm = plugin.getLang().getColored("command.no-permission");
|
||||
String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed")
|
||||
|
||||
final String noPerm = plugin.getLang().getColored("command.no-permission").content();
|
||||
final String noPermDetailed = plugin.getLang().getColored("command.no-permission-detailed").content()
|
||||
.replace("{no-permission-msg}", noPerm)
|
||||
.replace("{permission}", "playerbountiesplus.command.bounty.set");
|
||||
sender.sendMessage(noPermDetailed);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
String playerNameArg = args[1];
|
||||
float amount;
|
||||
final String playerNameArg = args[1];
|
||||
try {
|
||||
|
||||
amount = Integer.parseInt(args[2]);
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.amount-nan"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
Player target = plugin.getServer().getPlayerExact(playerNameArg);
|
||||
|
||||
final Player target = plugin.getServer().getPlayerExact(playerNameArg);
|
||||
if (target == null) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.player-not-found"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Check limits
|
||||
double minimum = plugin.getConfig().getDouble("bounty-minimum", 1.0);
|
||||
final double minimum = plugin.getConfig().getDouble("bounty-minimum", 1.0);
|
||||
if (amount < minimum) {
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.under-minimum")
|
||||
.replace("{minimum}", String.valueOf(minimum))
|
||||
);
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.under-minimum").content()
|
||||
.replace("{minimum}", String.valueOf(minimum)));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
double maximum = plugin.getConfig().getDouble("bounty-maximum", 1000000.0);
|
||||
final double maximum = plugin.getConfig().getDouble("bounty-maximum", 1000000.0);
|
||||
if (amount > maximum) {
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.over-maximum")
|
||||
.replace("{maximum}", String.valueOf(minimum))
|
||||
);
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.over-maximum").content()
|
||||
.replace("{maximum}", String.valueOf(minimum)));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Check money
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
boolean allowed = plugin.getEcoHook().takeEco(player, amount);
|
||||
if (sender instanceof Player player) {
|
||||
|
||||
final boolean allowed = plugin.getEcoHook().takeEco(player, target, amount, false);
|
||||
|
||||
if (!allowed) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.not-enough-money"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Apply bounty multiplier
|
||||
amount *= (float) plugin.getConfig().getDouble("bounty-multiplier", 1.0);
|
||||
|
||||
// Trigger bounty set event
|
||||
BountySetEvent event = new BountySetEvent(sender instanceof Player ? (Player) sender : null, target, amount);
|
||||
final BountySetEvent event = new BountySetEvent(sender instanceof Player ? (Player) sender : null, target,
|
||||
amount);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
amount = event.getAmount();
|
||||
|
||||
// Check if event was cancelled
|
||||
if (event.isCancelled()) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.cancelled"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// Sanity check final amount
|
||||
if (amount <= 0) {
|
||||
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.internal-invalid-value"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
UUID playerUUID = target.getUniqueId();
|
||||
final UUID playerUUID = target.getUniqueId();
|
||||
|
||||
// Calculate total bounty including previous bounties
|
||||
BountyDataManager bountyDataManager = plugin.getBountyDataManager();
|
||||
int bountyAlreadyPresent = bountyDataManager.getBounty(playerUUID);
|
||||
int totalBounty = ((int) amount) + bountyAlreadyPresent;
|
||||
final BountyDataManager bountyDataManager = plugin.getBountyDataManager();
|
||||
final int bountyAlreadyPresent = bountyDataManager.getBounty(playerUUID);
|
||||
final int totalBounty = ((int) amount) + bountyAlreadyPresent;
|
||||
bountyDataManager.setBounty(playerUUID, totalBounty);
|
||||
|
||||
// Confirmation
|
||||
sender.sendMessage(
|
||||
plugin.getLang().getColored("command.bounty.set.success")
|
||||
.replace("{bounty}", String.valueOf(amount))
|
||||
.replace("{total}", String.valueOf(totalBounty))
|
||||
.replace("{target}", target.getName())
|
||||
.replace("{player}", sender.getName())
|
||||
);
|
||||
sender.sendMessage(plugin.getLang().getColored("command.bounty.set.success").content()
|
||||
.replace("{bounty}", String.valueOf(amount)).replace("{total}", String.valueOf(totalBounty))
|
||||
.replace("{target}", target.getName()).replace("{player}", sender.getName()));
|
||||
|
||||
// Announce
|
||||
String extra;
|
||||
if (bountyAlreadyPresent == 0) extra = "";
|
||||
else {
|
||||
extra = plugin.getLang().getColored("command.bounty.set.announce-extra")
|
||||
.replace("{total}", String.valueOf(totalBounty));
|
||||
final String extra;
|
||||
if (bountyAlreadyPresent == 0) {
|
||||
|
||||
extra = "";
|
||||
|
||||
} else {
|
||||
|
||||
extra = plugin.getLang().getColored("command.bounty.set.announce-extra").content().replace("{total}",
|
||||
String.valueOf(totalBounty));
|
||||
|
||||
}
|
||||
|
||||
if (plugin.getConfig().getBoolean("bounty-placed-announce", true)) {
|
||||
plugin.getServer().broadcastMessage(
|
||||
plugin.getLang().getColored("command.bounty.set.announce")
|
||||
.replace("{bounty}", String.valueOf(amount))
|
||||
.replace("{target}", target.getName())
|
||||
.replace("{player}", sender.getName())
|
||||
.replace("{extra}", extra)
|
||||
);
|
||||
|
||||
Bukkit.getOnlinePlayers()
|
||||
.forEach((Player player) -> UtilitiesOG.trueogMessage(player,
|
||||
plugin.getLang().getColored("command.bounty.set.announce").content()
|
||||
.replace("{bounty}", String.valueOf(amount)).replace("{target}", target.getName())
|
||||
.replace("{player}", sender.getName()).replace("{extra}", extra)));
|
||||
|
||||
}
|
||||
|
||||
bountyDataManager.saveBountiesAsync();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static List<String> onTabComplete(@NotNull CommandSender sender, @NotNull String[] args) {
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
// Suggest online player names for the username
|
||||
return sender.getServer().getOnlinePlayers().stream()
|
||||
.map(Player::getName)
|
||||
.filter(name -> name.toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
return sender.getServer().getOnlinePlayers().stream().map(Player::getName)
|
||||
.filter(name -> name.toLowerCase().startsWith(args[1].toLowerCase())).collect(Collectors.toList());
|
||||
|
||||
} else if (args.length == 3) {
|
||||
|
||||
// Suggest a placeholder for the amount
|
||||
return Collections.singletonList("<amount>");
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +1,59 @@
|
||||
package com.tcoded.playerbountiesplus.command.bounty;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import org.bukkit.ChatColor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
|
||||
public class BountyTopCmd {
|
||||
|
||||
public static boolean handleCmd(PlayerBountiesPlus plugin, CommandSender sender, Command cmd, String cmdName, String[] args) {
|
||||
public static boolean handleCmd(PlayerBountiesOG plugin, CommandSender sender, Command cmd, String cmdName,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
final Set<Map.Entry<UUID, Integer>> bountiesSet = plugin.getBountyDataManager().getBounties().entrySet();
|
||||
final List<Map.Entry<UUID, Integer>> bounties = new ArrayList<>(bountiesSet);
|
||||
|
||||
Set<Map.Entry<UUID, Integer>> bountiesSet = plugin.getBountyDataManager().getBounties().entrySet();
|
||||
List<Map.Entry<UUID, Integer>> bounties = new ArrayList<>(bountiesSet);
|
||||
|
||||
bounties.sort((a, b) -> b.getValue() - a.getValue());
|
||||
|
||||
StringBuilder strb = new StringBuilder();
|
||||
final StringBuilder strb = new StringBuilder();
|
||||
strb.append(plugin.getLang().getColored("command.bounty.top.top-10") + "\n");
|
||||
|
||||
int bountiesSize = bounties.size();
|
||||
int maxInList = Math.min(10, bountiesSize);
|
||||
final int bountiesSize = bounties.size();
|
||||
final int maxInList = Math.min(10, bountiesSize);
|
||||
|
||||
if (bountiesSize > 0) {
|
||||
|
||||
for (int i = 0; i < maxInList; i++) {
|
||||
strb.append(ChatColor.GRAY);
|
||||
|
||||
strb.append("&7");
|
||||
strb.append(" - ");
|
||||
Map.Entry<UUID, Integer> entry = bounties.get(i);
|
||||
final Map.Entry<UUID, Integer> entry = bounties.get(i);
|
||||
strb.append(plugin.getServer().getOfflinePlayer(entry.getKey()).getName());
|
||||
strb.append(": ");
|
||||
strb.append(entry.getValue());
|
||||
strb.append('\n');
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
strb.append(plugin.getLang().getColored("command.bounty.top.no-bounties") + "\n");
|
||||
|
||||
}
|
||||
|
||||
String message = strb.toString();
|
||||
message = message.substring(0, message.length() - 1); // remove last \n
|
||||
sender.sendMessage(message);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,41 +17,57 @@ public class BountyClaimEvent extends Event implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
public BountyClaimEvent(@NotNull Player claimant, @NotNull Player victim, double amount) {
|
||||
|
||||
this.claimant = claimant;
|
||||
this.victim = victim;
|
||||
this.amount = amount;
|
||||
this.cancelled = false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
return cancelled;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
|
||||
this.cancelled = cancel;
|
||||
|
||||
}
|
||||
|
||||
public Player getClaimant() {
|
||||
|
||||
return claimant;
|
||||
|
||||
}
|
||||
|
||||
public Player getVictim() {
|
||||
|
||||
return victim;
|
||||
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
|
||||
return amount;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,48 +17,67 @@ public class BountySetEvent extends Event implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
public BountySetEvent(Player setter, @NotNull Player target, float amount) {
|
||||
|
||||
this.setter = setter;
|
||||
this.target = target;
|
||||
this.amount = amount;
|
||||
this.cancelled = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The player who set the bounty or null if it's set by console/command block.
|
||||
* @return The player who set the bounty or null if it's set by console/command
|
||||
* block.
|
||||
*/
|
||||
public Player getSetter() {
|
||||
|
||||
return setter;
|
||||
|
||||
}
|
||||
|
||||
public Player getTarget() {
|
||||
|
||||
return target;
|
||||
|
||||
}
|
||||
|
||||
public float getAmount() {
|
||||
|
||||
return amount;
|
||||
|
||||
}
|
||||
|
||||
public void setAmount(float amount) {
|
||||
|
||||
this.amount = amount;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
return cancelled;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
|
||||
this.cancelled = cancel;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
|
||||
return handlers;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,5 +10,5 @@ public interface IPbpGui extends InventoryHolder {
|
||||
void setContents();
|
||||
|
||||
void handleClick(InventoryClickEvent event);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +1,55 @@
|
||||
package com.tcoded.playerbountiesplus.gui;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
|
||||
public class MainBountyGui implements IPbpGui {
|
||||
|
||||
private final PlayerBountiesPlus plugin;
|
||||
private final Player viewer;
|
||||
private final Inventory inventory;
|
||||
|
||||
public MainBountyGui(PlayerBountiesPlus plugin, Player viewer) {
|
||||
this.plugin = plugin;
|
||||
public MainBountyGui(PlayerBountiesOG plugin, Player viewer) {
|
||||
|
||||
this.viewer = viewer;
|
||||
|
||||
// Create inventory
|
||||
this.inventory = Bukkit.createInventory(
|
||||
this,
|
||||
9 * 3,
|
||||
plugin.getLang().getColored("gui.main.title")
|
||||
);
|
||||
this.inventory = Bukkit.createInventory(this, 9 * 3, plugin.getLang().getColored("gui.main.title"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
|
||||
return this.inventory;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
|
||||
setContents();
|
||||
|
||||
// Open the inventory for the viewer
|
||||
viewer.openInventory(this.inventory);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContents() {
|
||||
|
||||
// TODO: Populate the inventory
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClick(InventoryClickEvent event) {
|
||||
// TODO: Handle inventory clicks
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Handle inventory clicks
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.tcoded.playerbountiesplus.hook.currency;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
|
||||
import net.trueog.diamondbankog.DiamondBankAPIJava;
|
||||
import net.trueog.diamondbankog.DiamondBankException;
|
||||
import net.trueog.diamondbankog.DiamondBankException.DatabaseException;
|
||||
import net.trueog.diamondbankog.DiamondBankException.EconomyDisabledException;
|
||||
import net.trueog.diamondbankog.DiamondBankException.InsufficientFundsException;
|
||||
import net.trueog.diamondbankog.DiamondBankException.InsufficientInventorySpaceException;
|
||||
import net.trueog.diamondbankog.DiamondBankException.InvalidPlayerException;
|
||||
import net.trueog.diamondbankog.DiamondBankException.PlayerNotOnlineException;
|
||||
|
||||
public class DiamondBankOGHook implements EconomyHook {
|
||||
|
||||
private final PlayerBountiesOG plugin;
|
||||
private final DiamondBankAPIJava diamondBank;
|
||||
private long playerShards;
|
||||
|
||||
public DiamondBankOGHook(PlayerBountiesOG plugin, DiamondBankAPIJava diamondBankAPITransporter) {
|
||||
|
||||
this.plugin = plugin;
|
||||
this.diamondBank = diamondBankAPITransporter;
|
||||
|
||||
}
|
||||
|
||||
public boolean init() {
|
||||
|
||||
if (this.plugin.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
|
||||
return diamondBank != null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveEco(Player player, Player victim, double amount) {
|
||||
|
||||
// Player UUID, amount (as shards, as type long), reason, notes.
|
||||
try {
|
||||
|
||||
diamondBank.addToPlayerBankShards(
|
||||
player.getUniqueId(), (long) (amount / 9), ("Player " + player.getName() + "defeated "
|
||||
+ victim.getName() + " and earned a bounty of " + (amount / 9)),
|
||||
"Plugin: PlayerBounties-OG");
|
||||
|
||||
} catch (EconomyDisabledException | DatabaseException error) {
|
||||
|
||||
PlayerBountiesOG.disableSelf("[PlayerBounties-OG] Giving " + player.getName() + "the bounty for killing "
|
||||
+ victim.getName() + "failed at the giving step with error: " + error.getMessage());
|
||||
error.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeEco(Player player, Player victim, double amount) {
|
||||
|
||||
this.takeEco(player, victim, amount, false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeEco(Player player, Player victim, double amount, boolean force) {
|
||||
|
||||
final double balance = getBalance(player.getUniqueId());
|
||||
if (balance < (amount / 9) && !force) {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
diamondBank.consumeFromPlayer(victim.getUniqueId(), (long) (amount / 9), "", "");
|
||||
|
||||
} catch (EconomyDisabledException | InvalidPlayerException | PlayerNotOnlineException
|
||||
| InsufficientFundsException | InsufficientInventorySpaceException | DatabaseException error)
|
||||
{
|
||||
|
||||
PlayerBountiesOG.disableSelf("[PlayerBounties-OG] Giving " + player.getName() + "the bounty for killing "
|
||||
+ victim.getName() + "failed at the taking step with error: " + error.getMessage());
|
||||
error.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public long getBalance(UUID uuid) {
|
||||
|
||||
// Runs code off of the main server thread.
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
|
||||
try {
|
||||
|
||||
// Ask DiamondBank-OG for the player's total shard count.
|
||||
final long totalShards = diamondBank.getTotalShards(uuid);
|
||||
|
||||
playerShards = totalShards;
|
||||
|
||||
}
|
||||
// If the DiamondBank-OG economy is disabled, do this...
|
||||
catch (DiamondBankException.EconomyDisabledException error) {
|
||||
|
||||
// Commit sudoku, inform console of the DiamondBank-OG economy being disabled.
|
||||
PlayerBountiesOG
|
||||
.disableSelf("The DiamondBank-OG economy is disabled — disabling " + plugin.getName() + "!");
|
||||
|
||||
}
|
||||
// If the DiamondBank-OG database is having problems, do this...
|
||||
catch (DiamondBankException.DatabaseException error) {
|
||||
|
||||
// Commit sudoku, inform console of the DiamondBank-OG database error.
|
||||
PlayerBountiesOG.disableSelf("DiamondBank-OG database error — disabling " + plugin.getName()
|
||||
+ ". Cause: " + error.getMessage());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return playerShards;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.tcoded.playerbountiesplus.hook.currency;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DummyEcoHook implements EconomyHook {
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveEco(Player player, double amount) {
|
||||
throw new UnsupportedOperationException("Economy isn't setup. Dummy hook is the active fallback.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeEco(Player player, double amount) {
|
||||
throw new UnsupportedOperationException("Economy isn't setup. Dummy hook is the active fallback.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeEco(Player player, double amount, boolean force) {
|
||||
throw new UnsupportedOperationException("Economy isn't setup. Dummy hook is the active fallback.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,10 +6,10 @@ public interface EconomyHook {
|
||||
|
||||
boolean isValid();
|
||||
|
||||
void giveEco(Player player, double amount);
|
||||
void giveEco(Player killer, Player victim, double amount);
|
||||
|
||||
boolean takeEco(Player player, double amount);
|
||||
void takeEco(Player killer, Player victim, double amount);
|
||||
|
||||
boolean takeEco(Player player, double amount, boolean force);
|
||||
boolean takeEco(Player killer, Player victim, double amount, boolean force);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.tcoded.playerbountiesplus.hook.currency;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class VaultHook implements EconomyHook {
|
||||
|
||||
private final PlayerBountiesPlus plugin;
|
||||
|
||||
private Economy eco;
|
||||
|
||||
public VaultHook(PlayerBountiesPlus plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
public boolean init() {
|
||||
if (this.plugin.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RegisteredServiceProvider<Economy> rsp = this.plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
eco = rsp.getProvider();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return eco != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveEco(Player player, double amount) {
|
||||
this.eco.depositPlayer(player, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeEco(Player player, double amount) {
|
||||
return this.takeEco(player, amount, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean takeEco(Player player, double amount, boolean force) {
|
||||
double balance = this.eco.getBalance(player);
|
||||
if (balance < amount && !force) return false;
|
||||
|
||||
return this.eco.withdrawPlayer(player, amount).type == EconomyResponse.ResponseType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
+32
-8
@@ -1,63 +1,87 @@
|
||||
package com.tcoded.playerbountiesplus.hook.placeholder;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
|
||||
public class PlaceholderAPIHook extends PlaceholderExpansion implements PlaceholderHook {
|
||||
|
||||
private final PlayerBountiesPlus pbpPlugin;
|
||||
private final PlayerBountiesOG pbpPlugin;
|
||||
|
||||
public PlaceholderAPIHook(PlayerBountiesOG pbpPlugin, Plugin papiPlugin) {
|
||||
|
||||
public PlaceholderAPIHook(PlayerBountiesPlus pbpPlugin, Plugin papiPlugin) {
|
||||
this.pbpPlugin = pbpPlugin;
|
||||
if (!(papiPlugin instanceof PlaceholderAPIPlugin)) {
|
||||
|
||||
throw new IllegalArgumentException("Plugin is not PlaceholderAPI");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
|
||||
return pbpPlugin.getName().toLowerCase();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return pbpPlugin.getDescription().getAuthors().get(0);
|
||||
|
||||
return pbpPlugin.getPluginMeta().getAuthors().get(0);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return pbpPlugin.getDescription().getVersion();
|
||||
|
||||
return pbpPlugin.getPluginMeta().getVersion();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() {
|
||||
|
||||
this.register();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
this.unregister();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||
|
||||
if (params.equals("bounty")) {
|
||||
|
||||
return String.valueOf(pbpPlugin.getBountyDataManager().getBounty(player.getUniqueId()));
|
||||
|
||||
} else if (params.equals("hasbounty")) {
|
||||
|
||||
return String.valueOf(pbpPlugin.getBountyDataManager().hasBounty(player.getUniqueId()));
|
||||
|
||||
}
|
||||
|
||||
return "INVALID-OPTION";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tcoded.playerbountiesplus.hook.placeholder;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -8,16 +8,20 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface PlaceholderHook {
|
||||
|
||||
@NotNull
|
||||
static PlaceholderHook findPlaceholderHook(PlayerBountiesPlus plugin) {
|
||||
static PlaceholderHook findPlaceholderHook(PlayerBountiesOG plugin) {
|
||||
|
||||
PluginManager pluginManager = plugin.getServer().getPluginManager();
|
||||
|
||||
Plugin papiPlugin = pluginManager.getPlugin("PlaceholderAPI");
|
||||
if (papiPlugin != null) {
|
||||
|
||||
return new PlaceholderAPIHook(plugin, papiPlugin);
|
||||
|
||||
}
|
||||
|
||||
plugin.getLogger().warning("PlaceholderAPI not found, placeholders will be unavailable.");
|
||||
return new DummyPlaceholderHook();
|
||||
|
||||
}
|
||||
|
||||
void enable();
|
||||
|
||||
@@ -1,38 +1,57 @@
|
||||
package com.tcoded.playerbountiesplus.hook.team;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
|
||||
public abstract class AbstractTeamHook implements TeamHook {
|
||||
|
||||
protected PlayerBountiesPlus plugin;
|
||||
protected PlayerBountiesOG plugin;
|
||||
protected JavaPlugin teamPlugin;
|
||||
|
||||
public AbstractTeamHook(PlayerBountiesPlus plugin, Plugin teamPlugin) {
|
||||
public AbstractTeamHook(PlayerBountiesOG plugin, Plugin teamPlugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
this.teamPlugin = (JavaPlugin) teamPlugin;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
|
||||
return this.teamPlugin.getName();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
List<String> authors = this.teamPlugin.getDescription().getAuthors();
|
||||
if (authors.isEmpty()) return "N/A";
|
||||
|
||||
final List<String> authors = this.teamPlugin.getPluginMeta().getAuthors();
|
||||
if (authors.isEmpty()) {
|
||||
|
||||
return "N/A";
|
||||
|
||||
}
|
||||
|
||||
return authors.get(0);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAuthors() {
|
||||
List<String> authors = this.teamPlugin.getDescription().getAuthors();
|
||||
if (authors.isEmpty()) return new String[0];
|
||||
|
||||
final List<String> authors = this.teamPlugin.getPluginMeta().getAuthors();
|
||||
if (authors.isEmpty()) {
|
||||
|
||||
return new String[0];
|
||||
|
||||
}
|
||||
|
||||
return authors.toArray(new String[0]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tcoded.playerbountiesplus.hook.team;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import me.loving11ish.clans.api.ClansLiteAPI;
|
||||
import me.loving11ish.clans.api.models.Clan;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -11,24 +11,33 @@ public class ClansLiteHook extends AbstractTeamHook {
|
||||
|
||||
private final ClansLiteAPI api;
|
||||
|
||||
public ClansLiteHook(PlayerBountiesPlus plugin, Plugin teamPlugin) {
|
||||
public ClansLiteHook(PlayerBountiesOG plugin, Plugin teamPlugin) {
|
||||
|
||||
super(plugin, teamPlugin);
|
||||
api = ClansLiteAPI.getInstance();
|
||||
|
||||
}
|
||||
|
||||
public @Nullable String getClanId(Player player) {
|
||||
|
||||
Clan clan = api.getClanByBukkitPlayer(player);
|
||||
return clan == null ? null : clan.getClanFinalName();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFriendly(Player player1, Player player2) {
|
||||
|
||||
String clanId1 = this.getClanId(player1);
|
||||
String clanId2 = this.getClanId(player2);
|
||||
|
||||
if (clanId1 == null) return false;
|
||||
if (clanId2 == null) return false;
|
||||
if (clanId1 == null)
|
||||
return false;
|
||||
if (clanId2 == null)
|
||||
return false;
|
||||
|
||||
return clanId1.equals(this.getClanId(player2));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.tcoded.playerbountiesplus.hook.team;
|
||||
|
||||
import com.cortezromeo.clansplus.api.ClanPlus;
|
||||
import com.cortezromeo.clansplus.api.storage.IPlayerData;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -12,28 +12,41 @@ public class ClansPlusHook extends AbstractTeamHook {
|
||||
|
||||
private final ClanPlus api;
|
||||
|
||||
public ClansPlusHook(PlayerBountiesPlus plugin, Plugin teamPlugin) {
|
||||
public ClansPlusHook(PlayerBountiesOG plugin, Plugin teamPlugin) {
|
||||
|
||||
super(plugin, teamPlugin);
|
||||
this.api = Bukkit.getServicesManager().getRegistration(ClanPlus.class).getProvider();
|
||||
|
||||
}
|
||||
|
||||
private @Nullable String getClanId(Player player) {
|
||||
|
||||
IPlayerData data = api.getPluginDataManager().getPlayerDatabase(player.getName());
|
||||
if (data == null) {
|
||||
|
||||
api.getPluginDataManager().loadPlayerDatabase(player.getName());
|
||||
data = api.getPluginDataManager().getPlayerDatabase(player.getName());
|
||||
if (data == null) return null;
|
||||
if (data == null)
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
String clan = data.getClan();
|
||||
return clan == null || clan.isEmpty() ? null : clan;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFriendly(Player player1, Player player2) {
|
||||
|
||||
String clan1 = getClanId(player1);
|
||||
if (clan1 == null) return false;
|
||||
if (clan1 == null)
|
||||
return false;
|
||||
String clan2 = getClanId(player2);
|
||||
if (clan2 == null) return false;
|
||||
if (clan2 == null)
|
||||
return false;
|
||||
return clan1.equalsIgnoreCase(clan2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,22 @@
|
||||
package com.tcoded.playerbountiesplus.hook.team;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PartyAndFriendsHook extends AbstractTeamHook {
|
||||
|
||||
public PartyAndFriendsHook(PlayerBountiesPlus plugin, Plugin teamPlugin) {
|
||||
public PartyAndFriendsHook(PlayerBountiesOG plugin, Plugin teamPlugin) {
|
||||
|
||||
super(plugin, teamPlugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFriendly(Player player1, Player player2) {
|
||||
|
||||
return false; // todo: figure out which of the 5 different APIs I'm supposed to use...
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.tcoded.playerbountiesplus.hook.team;
|
||||
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class SaberFactionsHook extends AbstractTeamHook {
|
||||
|
||||
public SaberFactionsHook(PlayerBountiesPlus plugin, Plugin teamPlugin) {
|
||||
super(plugin, teamPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFriendly(Player player1, Player player2) {
|
||||
FPlayers fPlayers = FPlayers.getInstance();
|
||||
|
||||
String factionId1 = fPlayers.getByPlayer(player1).getFactionId();
|
||||
String factionId2 = fPlayers.getByPlayer(player2).getFactionId();
|
||||
|
||||
if (factionId1 == null) return false;
|
||||
if (factionId2 == null) return false;
|
||||
|
||||
return factionId1.equals(factionId2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.tcoded.playerbountiesplus.hook.team;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
|
||||
@@ -11,12 +11,15 @@ import java.util.UUID;
|
||||
|
||||
public class SimpleClansHook extends AbstractTeamHook {
|
||||
|
||||
public SimpleClansHook(PlayerBountiesPlus plugin, Plugin teamPlugin) {
|
||||
public SimpleClansHook(PlayerBountiesOG plugin, Plugin teamPlugin) {
|
||||
|
||||
super(plugin, teamPlugin);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFriendly(Player player1, Player player2) {
|
||||
|
||||
ClanManager clanManager = SimpleClans.getInstance().getClanManager();
|
||||
|
||||
UUID uuid1 = player1.getUniqueId();
|
||||
@@ -25,10 +28,13 @@ public class SimpleClansHook extends AbstractTeamHook {
|
||||
Clan clan1 = clanManager.getClanByPlayerUniqueId(uuid1);
|
||||
Clan clan2 = clanManager.getClanByPlayerUniqueId(uuid2);
|
||||
|
||||
if (clan1 == null) return false;
|
||||
if (clan2 == null) return false;
|
||||
if (clan1 == null)
|
||||
return false;
|
||||
if (clan2 == null)
|
||||
return false;
|
||||
|
||||
return clan1 == clan2;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +1,53 @@
|
||||
package com.tcoded.playerbountiesplus.hook.team;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
|
||||
public interface TeamHook {
|
||||
|
||||
static AbstractTeamHook findTeamHook(PlayerBountiesPlus plugin) {
|
||||
PluginManager pluginManager = plugin.getServer().getPluginManager();
|
||||
static AbstractTeamHook findTeamHook(PlayerBountiesOG plugin) {
|
||||
|
||||
// loving11ish - ClansLite - https://www.spigotmc.org/resources/clanslite-1-19-4-support.97163/
|
||||
Plugin clansLitePlugin = pluginManager.getPlugin("ClansLite");
|
||||
final PluginManager pluginManager = plugin.getServer().getPluginManager();
|
||||
|
||||
// loving11ish - ClansLite -
|
||||
// https://www.spigotmc.org/resources/clanslite-1-19-4-support.97163/
|
||||
final Plugin clansLitePlugin = pluginManager.getPlugin("ClansLite");
|
||||
if (clansLitePlugin != null && clansLitePlugin.isEnabled()) {
|
||||
|
||||
return new ClansLiteHook(plugin, clansLitePlugin);
|
||||
|
||||
}
|
||||
|
||||
// RoinujNosde - SimpleClans - https://www.spigotmc.org/resources/simpleclans.71242/
|
||||
Plugin simpleClansPlugin = pluginManager.getPlugin("SimpleClans");
|
||||
// RoinujNosde - SimpleClans -
|
||||
// https://www.spigotmc.org/resources/simpleclans.71242/
|
||||
final Plugin simpleClansPlugin = pluginManager.getPlugin("SimpleClans");
|
||||
if (simpleClansPlugin != null && simpleClansPlugin.isEnabled()) {
|
||||
return new SimpleClansHook(plugin, simpleClansPlugin);
|
||||
}
|
||||
|
||||
// SaberLLC - Factions (SaberFactions) - https://www.spigotmc.org/resources/simpleclans.71242/
|
||||
Plugin saberFactionsPlugin = pluginManager.getPlugin("Factions");
|
||||
if (saberFactionsPlugin != null &&
|
||||
saberFactionsPlugin.getDescription().getMain().equals("com.massivecraft.factions.FactionsPlugin") &&
|
||||
saberFactionsPlugin.isEnabled()) {
|
||||
return new SaberFactionsHook(plugin, saberFactionsPlugin);
|
||||
return new SimpleClansHook(plugin, simpleClansPlugin);
|
||||
|
||||
}
|
||||
|
||||
// LlmDl - Towny - https://www.spigotmc.org/resources/towny-advanced.72694/
|
||||
Plugin townyPlugin = pluginManager.getPlugin("Towny");
|
||||
if (townyPlugin != null && townyPlugin.isEnabled()) {
|
||||
|
||||
return new TownyHook(plugin, townyPlugin);
|
||||
|
||||
}
|
||||
|
||||
// CortezRomeo - ClansPlus - https://github.com/CortezRomeo/ClansPlus
|
||||
Plugin clansPlusPlugin = pluginManager.getPlugin("ClansPlus");
|
||||
if (clansPlusPlugin != null && clansPlusPlugin.isEnabled()) {
|
||||
|
||||
return new ClansPlusHook(plugin, clansPlusPlugin);
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
String getPluginName();
|
||||
@@ -53,4 +58,4 @@ public interface TeamHook {
|
||||
|
||||
boolean isFriendly(Player player1, Player player2);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,26 +3,33 @@ package com.tcoded.playerbountiesplus.hook.team;
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TownyHook extends AbstractTeamHook {
|
||||
|
||||
public TownyHook(PlayerBountiesPlus plugin, Plugin teamPlugin) {
|
||||
public TownyHook(PlayerBountiesOG plugin, Plugin teamPlugin) {
|
||||
|
||||
super(plugin, teamPlugin);
|
||||
|
||||
}
|
||||
|
||||
public Town getTown(Player player) {
|
||||
|
||||
return TownyAPI.getInstance().getTown(player);
|
||||
|
||||
}
|
||||
|
||||
public Nation getNation(Player player) {
|
||||
|
||||
return TownyAPI.getInstance().getNation(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFriendly(Player player1, Player player2) {
|
||||
|
||||
Town town1 = getTown(player1);
|
||||
Town town2 = getTown(player2);
|
||||
|
||||
@@ -30,8 +37,11 @@ public class TownyHook extends AbstractTeamHook {
|
||||
Nation nation2 = getNation(player2);
|
||||
|
||||
boolean sameTown = town1 != null && town2 != null && (town1.hasResident(player2) || town1.hasAlly(town2));
|
||||
boolean sameNation = nation1 != null && nation2 != null && (nation1.equals(nation2) || nation1.hasAlly(nation2));
|
||||
boolean sameNation = nation1 != null && nation2 != null
|
||||
&& (nation1.equals(nation2) || nation1.hasAlly(nation2));
|
||||
|
||||
return sameTown || sameNation;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,93 +1,116 @@
|
||||
package com.tcoded.playerbountiesplus.listener;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import com.tcoded.playerbountiesplus.event.BountyClaimEvent;
|
||||
import com.tcoded.playerbountiesplus.hook.team.TeamHook;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
import com.tcoded.playerbountiesplus.event.BountyClaimEvent;
|
||||
import com.tcoded.playerbountiesplus.hook.team.TeamHook;
|
||||
import com.tcoded.playerbountiesplus.manager.BountyDataManager;
|
||||
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class DeathListener implements Listener {
|
||||
|
||||
private final PlayerBountiesPlus plugin;
|
||||
private final PlayerBountiesOG plugin;
|
||||
|
||||
public DeathListener(PlayerBountiesOG plugin) {
|
||||
|
||||
public DeathListener(PlayerBountiesPlus plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDeath(PlayerDeathEvent event) {
|
||||
Player victim = event.getEntity();
|
||||
Player killer = victim.getKiller();
|
||||
|
||||
if (killer != null) {
|
||||
if (!killer.hasPermission("playerbountiesplus.event.claim")) {
|
||||
killer.sendMessage(plugin.getLang().getColored("death.no-permission"));
|
||||
return;
|
||||
}
|
||||
final Player victim = event.getEntity();
|
||||
final Player killer = victim.getKiller();
|
||||
|
||||
BountyDataManager bountyDataManager = this.plugin.getBountyDataManager();
|
||||
UUID victimId = victim.getUniqueId();
|
||||
if (killer == null) {
|
||||
|
||||
// Bounty check
|
||||
if (!bountyDataManager.hasBounty(victimId)) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
int bounty = bountyDataManager.getBounty(victimId);
|
||||
|
||||
// Clan check
|
||||
TeamHook teamHook = this.plugin.getTeamHook();
|
||||
if (teamHook != null && teamHook.isFriendly(killer, victim)) {
|
||||
killer.sendMessage(plugin.getLang().getColored("death.same-team"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Trigger Bounty Claimed Event
|
||||
BountyClaimEvent claimEvent = new BountyClaimEvent(killer, victim, bounty);
|
||||
this.plugin.getServer().getPluginManager().callEvent(claimEvent);
|
||||
|
||||
// Check if event is cancelled
|
||||
if (claimEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Give reward!
|
||||
if (plugin.getConfig().getBoolean("bounty-claimable", true)) {
|
||||
double claimMultiplier = plugin.getConfig().getDouble("bounty-claim-multiplier", 1.0);
|
||||
double awardedAmount = bounty * claimMultiplier;
|
||||
|
||||
if (awardedAmount > 0) {
|
||||
this.plugin.getEcoHook().giveEco(killer, awardedAmount);
|
||||
} else if (awardedAmount < 0) {
|
||||
this.plugin.getEcoHook().takeEco(killer, Math.abs(awardedAmount));
|
||||
}
|
||||
}
|
||||
|
||||
// Optional - Take from victim as punishment
|
||||
if (plugin.getConfig().getBoolean("bounty-take-from-victim", false)) {
|
||||
this.plugin.getEcoHook().takeEco(victim, bounty, true);
|
||||
}
|
||||
|
||||
// Announce Reward
|
||||
if (plugin.getConfig().getBoolean("bounty-claimed-announce", true)) {
|
||||
this.plugin.getServer().broadcastMessage(
|
||||
plugin.getLang().getColored("death.announce-claimed")
|
||||
.replace("{killer}", killer.getName())
|
||||
.replace("{victim}", victim.getName())
|
||||
.replace("{bounty}", String.valueOf(bounty))
|
||||
);
|
||||
}
|
||||
|
||||
// Remove bounty
|
||||
bountyDataManager.removeBounty(victimId);
|
||||
bountyDataManager.saveBountiesAsync();
|
||||
}
|
||||
|
||||
if (!killer.hasPermission("playerbountiesplus.event.claim")) {
|
||||
|
||||
killer.sendMessage(plugin.getLang().getColored("death.no-permission"));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final BountyDataManager bountyDataManager = this.plugin.getBountyDataManager();
|
||||
final UUID victimId = victim.getUniqueId();
|
||||
// Bounty check
|
||||
if (!bountyDataManager.hasBounty(victimId)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final int bounty = bountyDataManager.getBounty(victimId);
|
||||
// Clan check
|
||||
final TeamHook teamHook = this.plugin.getTeamHook();
|
||||
if (teamHook != null && teamHook.isFriendly(killer, victim)) {
|
||||
|
||||
killer.sendMessage(plugin.getLang().getColored("death.same-team"));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Trigger Bounty Claimed Event
|
||||
final BountyClaimEvent claimEvent = new BountyClaimEvent(killer, victim, bounty);
|
||||
this.plugin.getServer().getPluginManager().callEvent(claimEvent);
|
||||
// Check if event is cancelled
|
||||
if (claimEvent.isCancelled()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Give reward!
|
||||
if (plugin.getConfig().getBoolean("bounty-claimable", true)) {
|
||||
|
||||
final double claimMultiplier = plugin.getConfig().getDouble("bounty-claim-multiplier", 1.0);
|
||||
final double awardedAmount = bounty * claimMultiplier;
|
||||
|
||||
if (awardedAmount > 0) {
|
||||
|
||||
this.plugin.getEcoHook().giveEco(killer, victim, awardedAmount);
|
||||
|
||||
} else if (awardedAmount < 0) {
|
||||
|
||||
this.plugin.getEcoHook().takeEco(killer, victim, Math.abs(awardedAmount));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Optional - Take from victim as punishment
|
||||
if (plugin.getConfig().getBoolean("bounty-take-from-victim", false)) {
|
||||
|
||||
this.plugin.getEcoHook().takeEco(killer, victim, bounty, true);
|
||||
|
||||
}
|
||||
|
||||
// Announce Reward
|
||||
if (plugin.getConfig().getBoolean("bounty-claimed-announce", true)) {
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach((Player player) -> UtilitiesOG.trueogMessage(player, killer.getName()
|
||||
+ "killed " + victim.getName() + " and earned the " + String.valueOf(bounty) + " Diamond bounty!"));
|
||||
|
||||
}
|
||||
|
||||
// Remove bounty
|
||||
bountyDataManager.removeBounty(victimId);
|
||||
bountyDataManager.saveBountiesAsync();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,13 +10,17 @@ public class GuiListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
|
||||
// Get the inventory holder
|
||||
InventoryHolder holder = event.getView().getTopInventory().getHolder();
|
||||
|
||||
// Ensure the holder is a GUI
|
||||
if (!(holder instanceof IPbpGui)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
IPbpGui gui = (IPbpGui) holder;
|
||||
|
||||
// Cancel normal click behaviour
|
||||
@@ -24,6 +28,7 @@ public class GuiListener implements Listener {
|
||||
|
||||
// Delegate the click handling
|
||||
gui.handleClick(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
package com.tcoded.playerbountiesplus.manager;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
|
||||
public class BountyDataManager {
|
||||
|
||||
private final PlayerBountiesPlus plugin;
|
||||
private final PlayerBountiesOG plugin;
|
||||
|
||||
private File bountiesFile;
|
||||
private FileConfiguration bountiesConfig;
|
||||
@@ -23,90 +23,122 @@ public class BountyDataManager {
|
||||
private final AtomicBoolean savingAsync = new AtomicBoolean(false);
|
||||
private final ConcurrentHashMap<UUID, Integer> bounties;
|
||||
|
||||
public BountyDataManager(PlayerBountiesPlus plugin) {
|
||||
public BountyDataManager(PlayerBountiesOG plugin) {
|
||||
|
||||
this.plugin = plugin;
|
||||
this.bounties = new ConcurrentHashMap<>();
|
||||
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
// Bounties file
|
||||
String bountiesFileName = "bounties.yml";
|
||||
final String bountiesFileName = "bounties.yml";
|
||||
bountiesFile = new File(this.plugin.getDataFolder(), bountiesFileName);
|
||||
if (!bountiesFile.exists()) this.plugin.saveResource(bountiesFileName, false);
|
||||
if (!bountiesFile.exists()) {
|
||||
|
||||
this.plugin.saveResource(bountiesFileName, false);
|
||||
|
||||
}
|
||||
|
||||
bountiesConfig = YamlConfiguration.loadConfiguration(bountiesFile);
|
||||
|
||||
// Load bounties
|
||||
Set<String> keys = bountiesConfig.getKeys(false);
|
||||
for (String key: keys) {
|
||||
final Set<String> keys = bountiesConfig.getKeys(false);
|
||||
keys.forEach(key -> {
|
||||
|
||||
try {
|
||||
|
||||
this.bounties.put(UUID.fromString(key), bountiesConfig.getInt(key));
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
||||
ex.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<UUID, Integer> getBounties() {
|
||||
|
||||
return this.bounties;
|
||||
|
||||
}
|
||||
|
||||
public boolean hasBounty(UUID player) {
|
||||
|
||||
return this.bounties.containsKey(player) && this.bounties.get(player) > 0;
|
||||
|
||||
}
|
||||
|
||||
public void setBounty(UUID player, int amount) {
|
||||
|
||||
this.bounties.put(player, amount);
|
||||
|
||||
}
|
||||
|
||||
public int getBounty(UUID player) {
|
||||
|
||||
return this.bounties.getOrDefault(player, 0);
|
||||
|
||||
}
|
||||
|
||||
public void removeBounty(UUID player) {
|
||||
|
||||
this.bounties.remove(player);
|
||||
|
||||
}
|
||||
|
||||
public void saveBounties() {
|
||||
|
||||
synchronized (this.savingFileLock) {
|
||||
|
||||
// Clear existing
|
||||
Set<String> keys = bountiesConfig.getKeys(false);
|
||||
for (String key : keys) {
|
||||
bountiesConfig.set(key, null);
|
||||
}
|
||||
final Set<String> keys = bountiesConfig.getKeys(false);
|
||||
keys.forEach(key -> bountiesConfig.set(key, null));
|
||||
|
||||
// Write changes
|
||||
for (Map.Entry<UUID, Integer> entry : this.bounties.entrySet()) {
|
||||
this.bountiesConfig.set(entry.getKey().toString(), entry.getValue());
|
||||
}
|
||||
this.bounties.entrySet()
|
||||
.forEach(entry -> this.bountiesConfig.set(entry.getKey().toString(), entry.getValue()));
|
||||
|
||||
// Save to file
|
||||
try {
|
||||
|
||||
this.bountiesConfig.save(this.bountiesFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
} catch (IOException error) {
|
||||
|
||||
error.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void saveBountiesAsync() {
|
||||
|
||||
// Wait until the previous save is done
|
||||
while (this.savingAsync.getAndSet(true)) {
|
||||
try {
|
||||
synchronized (this.savingAsync) {
|
||||
this.savingAsync.wait();
|
||||
}
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
|
||||
// Save
|
||||
this.plugin.getFoliaLib().getScheduler().runAsync(wt -> {
|
||||
try {
|
||||
|
||||
synchronized (this.savingAsync) {
|
||||
|
||||
this.savingAsync.wait();
|
||||
|
||||
}
|
||||
|
||||
} catch (InterruptedException ignored) {
|
||||
|
||||
}
|
||||
|
||||
this.saveBounties();
|
||||
|
||||
this.savingAsync.set(false);
|
||||
synchronized (this.savingAsync) {
|
||||
this.savingAsync.notifyAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,109 +1,136 @@
|
||||
package com.tcoded.playerbountiesplus.util;
|
||||
|
||||
import com.tcoded.legacycolorcodeparser.LegacyColorCodeParser;
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesPlus;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.tcoded.playerbountiesplus.PlayerBountiesOG;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class LangUtil {
|
||||
|
||||
private final PlayerBountiesPlus plugin;
|
||||
private final PlayerBountiesOG plugin;
|
||||
private final File overrideMessagesFile;
|
||||
private final FileConfiguration messages;
|
||||
private final String lang;
|
||||
private final boolean customLang;
|
||||
|
||||
public enum SupportedLang {
|
||||
DE_DE,
|
||||
EN_GB,
|
||||
EN_US,
|
||||
EN_UWU,
|
||||
ES_ES,
|
||||
FR_FR,
|
||||
HI_IN,
|
||||
HU_HU,
|
||||
IT_IT,
|
||||
NL_NL,
|
||||
RU_RU,
|
||||
SE_SE,
|
||||
ZH_CN,
|
||||
;
|
||||
|
||||
DE_DE, EN_GB, EN_US, EN_UWU, ES_ES, FR_FR, HI_IN, HU_HU, IT_IT, NL_NL, RU_RU, SE_SE, ZH_CN,;
|
||||
|
||||
public static SupportedLang find(String name) {
|
||||
|
||||
for (SupportedLang lang : SupportedLang.values()) {
|
||||
if (lang.name().equals(name)) return EN_US;
|
||||
|
||||
if (lang.name().equals(name)) {
|
||||
|
||||
return EN_US;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public LangUtil(PlayerBountiesPlus plugin, String lang) {
|
||||
public LangUtil(PlayerBountiesOG plugin, String lang) {
|
||||
|
||||
this.plugin = plugin;
|
||||
this.lang = lang;
|
||||
Logger logger = this.plugin.getLogger();
|
||||
final Logger logger = this.plugin.getLogger();
|
||||
|
||||
// for (SupportedLang tmpLang : SupportedLang.values()) {
|
||||
// plugin.saveResource("lang/" + tmpLang.name().toLowerCase() + ".yml", false);
|
||||
// }
|
||||
// for (SupportedLang tmpLang : SupportedLang.values()) {
|
||||
// plugin.saveResource("lang/" + tmpLang.name().toLowerCase() + ".yml", false);
|
||||
// }
|
||||
|
||||
// Resolve the path of the lang files we're going to use
|
||||
String englishFilePath = "lang/" + SupportedLang.EN_US.name().toLowerCase() + ".yml";
|
||||
String langFilePath = "lang/" + lang + ".yml";
|
||||
final String englishFilePath = "lang/" + SupportedLang.EN_US.name().toLowerCase() + ".yml";
|
||||
final String langFilePath = "lang/" + lang + ".yml";
|
||||
|
||||
// Load internal default English file - Worst case scenario fallback
|
||||
InputStream internalEnglishDefaultFile = plugin.getResource(englishFilePath);
|
||||
if (internalEnglishDefaultFile == null) throw new IllegalStateException("Internal default English file could not be found!");
|
||||
FileConfiguration englishDefaults = YamlConfiguration.loadConfiguration(new InputStreamReader(internalEnglishDefaultFile));
|
||||
final InputStream internalEnglishDefaultFile = plugin.getResource(englishFilePath);
|
||||
if (internalEnglishDefaultFile == null) {
|
||||
|
||||
throw new IllegalStateException("Internal default English file could not be found!");
|
||||
|
||||
}
|
||||
|
||||
final FileConfiguration englishDefaults = YamlConfiguration
|
||||
.loadConfiguration(new InputStreamReader(internalEnglishDefaultFile));
|
||||
|
||||
// Check if language is supported
|
||||
SupportedLang supportedLang = SupportedLang.find(lang.toUpperCase());
|
||||
final SupportedLang supportedLang = SupportedLang.find(lang.toUpperCase());
|
||||
if (supportedLang == null) {
|
||||
logger.severe(String.format("Unsupported language was found: %s!", lang));
|
||||
logger.info("You can contribute new languages by following the instructions at the top of the config.yml file :)");
|
||||
|
||||
logger.severe("Unsupported language was found: %s!".formatted(lang));
|
||||
logger.info(
|
||||
"You can contribute new languages by following the instructions at the top of the config.yml file :)");
|
||||
throw new IllegalStateException("Unsupported language in config.yml");
|
||||
|
||||
}
|
||||
|
||||
// Load user-specified internal language file
|
||||
InputStream internalLangFile = plugin.getResource(langFilePath);
|
||||
if (internalLangFile == null) throw new IllegalStateException(String.format("Internal language file could not be found! (Lang: %s)", lang));
|
||||
FileConfiguration defaults = YamlConfiguration.loadConfiguration(new InputStreamReader(internalLangFile));
|
||||
final InputStream internalLangFile = plugin.getResource(langFilePath);
|
||||
if (internalLangFile == null) {
|
||||
|
||||
throw new IllegalStateException("Internal language file could not be found! (Lang: %s)".formatted(lang));
|
||||
|
||||
}
|
||||
|
||||
final FileConfiguration defaults = YamlConfiguration.loadConfiguration(new InputStreamReader(internalLangFile));
|
||||
defaults.setDefaults(englishDefaults);
|
||||
|
||||
// Check if the user has created an override language file
|
||||
this.overrideMessagesFile = new File(plugin.getDataFolder(), langFilePath);
|
||||
if (this.overrideMessagesFile.exists()) {
|
||||
logger.warning(String.format("Using custom override language file for language: %s", lang));
|
||||
|
||||
logger.warning("Using custom override language file for language: %s".formatted(lang));
|
||||
this.messages = YamlConfiguration.loadConfiguration(this.overrideMessagesFile);
|
||||
this.messages.setDefaults(defaults);
|
||||
this.customLang = true;
|
||||
|
||||
} else {
|
||||
|
||||
this.messages = defaults;
|
||||
this.customLang = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
if (this.messages == null) return "STARTUP-ERROR-CONTACT-DEV";
|
||||
return this.messages.getString(key);
|
||||
}
|
||||
public TextComponent getColored(String key) {
|
||||
|
||||
if (this.messages == null) {
|
||||
|
||||
return Component.text("STARTUP-ERROR-CONTACT-DEV");
|
||||
|
||||
}
|
||||
|
||||
return UtilitiesOG.trueogColorize(this.messages.getString(key));
|
||||
|
||||
public String getColored(String key) {
|
||||
String text = this.get(key);
|
||||
text = LegacyColorCodeParser.convertHexToLegacy('&', text);
|
||||
return ChatColor.translateAlternateColorCodes('&', text);
|
||||
}
|
||||
|
||||
public String getLang() {
|
||||
|
||||
return lang;
|
||||
|
||||
}
|
||||
|
||||
public boolean isCustomLang() {
|
||||
|
||||
return customLang;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
name: PlayerBounties-OG
|
||||
version: '${version}'
|
||||
main: com.tcoded.playerbountiesplus.PlayerBountiesPlus
|
||||
main: com.tcoded.playerbountiesplus.PlayerBountiesOG
|
||||
api-version: '${apiVersion}'
|
||||
authors: [ TechnicallyCoded, NotAlexNoyle ]
|
||||
description: A player bounty plugin for TrueOG Network using our custom Diamond Economy.
|
||||
|
||||
Reference in new issue
Block a user