61 Commits
Author SHA1 Message Date
NotAlexNoyle 34dc28b3c1 Point submodules at canonical Gitea repositories 2026-11-01 12:52:59 -05:00
NotAlexNoyle eb117db784 Update canonical Gitea links 2026-10-31 11:41:20 -04:00
NotAlexNoyle c8dec26372 Exclude CODEOWNERS from language statistics 2026-10-31 09:54:56 -04:00
NotAlexNoyle 510418c689 Add CODEOWNERS (one staff approval) 2026-10-31 09:54:56 -04:00
NotAlexNoyle dbfdd62217 Update Utilities-OG API 2026-09-14 02:05:39 -04:00
NotAlexNoyle 1b9cb42cfd Update DiamondBank-OG API 2026-07-29 11:41:19 -04:00
NotAlexNoyle 30e548d4ca Update DiamondBank-OG API 2026-07-27 08:01:57 -04:00
NotAlexNoyle b1561bb7f1 Update DiamondBank-OG API 2026-07-22 07:09:59 -04:00
NotAlexNoyle 6d3a36d787 Update Utilities-OG API 2026-07-20 00:52:37 -04:00
NotAlexNoyle 81cc8965c2 Update GxUI-OG 2026-07-17 12:51:30 -04:00
NotAlexNoyle 854a06dbb3 Fix signs 2026-07-15 15:50:31 -04:00
NotAlexNoyle 4bbdac1a96 Remove broken sign 2026-07-15 15:32:44 -04:00
NotAlexNoyle 06fa21a2a1 Remove stale signs 2026-05-25 11:54:55 -04:00
NotAlexNoyle 090d4b33e3 Remove stale signs 2026-05-25 11:22:12 -04:00
NotAlexNoyle 5ca4ec60db Update GxUI-OG 2026-05-21 11:38:33 -04:00
NotAlexNoyle 16a893f7db Update Utilities-OG API 2026-05-20 11:21:51 -04:00
NotAlexNoyle ee3eeabf10 Update Utilities-OG 2026-05-11 00:55:23 -04:00
NotAlexNoyle dfa2e7d95f Fix duplicate handling, delete invalid signs with /ss delete 2026-04-23 13:50:42 -04:00
NotAlexNoyle acfcbe4ea1 Update GxUI-OG and Utilities-OG APIs 2026-04-20 02:15:57 -04:00
NotAlexNoyle 951900d827 More detailed errors 2026-04-14 14:14:33 -04:00
NotAlexNoyle 9891ddc85c Fix sign detection and de-duplicate sign config 2026-04-13 04:22:22 -04:00
NotAlexNoyle 77e50f83ac Update DiamondBank-OG API 2026-04-07 09:28:59 -04:00
NotAlexNoyle aedcfecd0d Optimize Hopper checks 2026-04-06 02:52:13 -04:00
NotAlexNoyle e11979a4d4 Update DiamondBank-OG API 2026-04-06 00:20:18 -04:00
NotAlexNoyle e04e0defd0 DiamondBank-OG API Update 2026-04-05 13:37:58 -04:00
NotAlexNoyle 47bea30ba0 Update TrueOG Network APIs 2026-04-05 13:13:47 -04:00
NotAlexNoyle 61792b1f52 Update DiamondBank-OG API 2026-04-05 11:13:39 -04:00
NotAlexNoyle 71cc15863d Update DiamondBank-OG API 2026-04-04 14:10:52 -04:00
NotAlexNoyle 4c82e3b229 Update DiamondBank-OG API 2026-04-01 15:30:40 -04:00
NotAlexNoyle a1898bfb01 Update DiamondBank-OG API 2026-04-01 05:58:20 -04:00
NotAlexNoyle 44e855cfbb Update DiamondBank-OG API 2026-04-01 05:03:41 -04:00
NotAlexNoyle 48d7b49a78 Update DiamondBank-OG API 2026-03-30 08:36:41 -04:00
NotAlexNoyle 51a5748dde Update Utilities-OG API 2026-03-30 05:10:06 -04:00
NotAlexNoyle 22122393cd Update Utilities-OG 2026-03-25 11:58:16 -04:00
NotAlexNoyle b4d2590962 Fix depends 2026-03-24 11:16:50 -04:00
NotAlexNoyle a0003bf608 Update DiamondBank-OG 2026-03-11 00:28:21 -04:00
NotAlexNoyle 10122c5440 Fix GxUI-OG 2026-03-09 05:22:06 -04:00
NotAlexNoyle b759d2ad56 Depend on DiamondBank-OG 2026-03-02 06:11:59 -05:00
NotAlexNoyle d11cf4cb2e 1.3 Update 2026-03-02 05:45:18 -05:00
NotAlexNoyle cbab8af288 Update DiamondBank-OG API 2026-01-24 10:57:28 -05:00
NotAlexNoyle e607a983d9 Update DiamondBank-OG API 2026-01-19 13:31:00 -05:00
NotAlexNoyle 96452cb51e Include TrueOG Network config file 2025-12-26 12:43:43 -05:00
NotAlexNoyle 9f00558489 Use TrueOG Network config file, relocate dependencies 2025-12-26 12:01:48 -05:00
NotAlexNoyle de22c0b99d Update TrueOG libraries 2025-12-11 07:39:49 -05:00
NotAlexNoyle b84274368a Update GxUI-OG 2025-12-07 21:02:18 -05:00
NotAlexNoyle 5bf281f6b8 Update dependencies 2025-12-07 19:11:22 -05:00
NotAlexNoyle abfa8cf769 Update DiamondBank-OG API 2025-11-12 00:52:28 -05:00
NotAlexNoyle 1b8d8733d4 Update DB-OG API 2025-09-27 17:19:23 -04:00
NotAlexNoyle 9d09a3b220 Update DiamondBank-OG API 2025-08-27 12:41:07 -04:00
NotAlexNoyle 6257edaf1c Update eclise.gradle.kts 2025-08-27 11:51:27 -04:00
NotAlexNoyle bb70b3a5c6 Update gradle to 8.14.3, add formatting 2025-08-18 14:39:53 -04:00
NotAlexNoyle ca20c02f45 Update DiamondBank-OG API 2025-07-09 11:20:31 -04:00
NotAlexNoyle c8cc35cfb7 Update Utilities-OG dependency 2025-07-07 11:39:35 -04:00
NotAlexNoyle 9b027f620d Update dependencies 2025-06-23 20:16:02 -04:00
NotAlexNoyle 8474eb3ad7 Update gradle to 8.14.2, add auto formatting 2025-06-18 20:10:12 -04:00
NotAlexNoyle 5b2dcaf652 Update dependencies 2025-06-18 14:12:23 -04:00
NotAlexNoyle 517355ee2a Update DiamondBank-OG dependency 2025-06-11 19:31:42 -04:00
NotAlexNoyle 53cf20ba5d Update DiamondBank dependency 2025-06-11 15:54:47 -04:00
NotAlexNoyle 1d06e2858f Update DiamondBank-OG 2025-06-11 15:36:41 -04:00
NotAlexNoyle 134f2c1ff8 Update DiamondBank-OG 2025-06-11 11:59:47 -04:00
NotAlexNoyle 6ba351c1d6 Update gradle to 8.14.1 2025-06-06 08:46:18 -04:00
65 changed files with 5563 additions and 3804 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
.gitea/CODEOWNERS linguist-detectable=false
+3
View File
@@ -0,0 +1,3 @@
# Pull requests request review from the eligible staff team(s).
# One approval from either an Admin or Developer satisfies branch protection.
* @trueog/Admins @trueog/Developers
+1
View File
@@ -4,6 +4,7 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
.kotlin/
.classpath
.factorypath
.project
+9
View File
@@ -0,0 +1,9 @@
[submodule "libs/Utilities-OG"]
path = libs/Utilities-OG
url = https://git.trueog.net/trueog/Utilities-OG
[submodule "libs/GxUI-OG"]
path = libs/GxUI-OG
url = https://git.trueog.net/trueog/GxUI-OG
[submodule "libs/DiamondBank-OG"]
path = libs/DiamondBank-OG
url = https://git.trueog.net/trueog/DiamondBank-OG
+12 -4
View File
@@ -1,5 +1,3 @@
![SudoSigns logo](https://mylesmor.dev/sudosigns/logo.png)
# SudoSigns-OG
A modern fork of SudoSigns: A Spigot plugin used to run commands by interacting with a sign. Some inspiration for commands has been taken from [Nokorbis' Command Signs](https://www.spigotmc.org/resources/command-signs.10512/). MylesMor implemented a convenient inventory-based GUI. NotAlexNoyle updated the plugin for 1.19 on behalf of [TrueOG Network](https://true-og.net).
@@ -16,7 +14,7 @@ This allows you to perform actions on SudoSigns such as:
For in-depth details on the command, permissions and features of this plugin, visit the [Wiki](https://github.com/MylesMor/SudoSigns/wiki)!
## Installation
1. Clone the git repository: [https://github.com/NotAlexNoyle/SudoSigns-OG](https://github.com/NotAlexNoyle/SudoSigns-OG).
1. Clone the git repository: [https://git.trueog.net/trueog/SudoSigns-OG](https://git.trueog.net/trueog/SudoSigns-OG).
2. Build the plugin with `./gradlew build`
3. Place the JAR file from SudoSigns-OG/build/libs inside your server's `./plugins` directory.
4. Reload or restart the server.
@@ -40,6 +38,16 @@ In your issue report, please include as much information as possible including:
## Changelog:
**1.3.1:**
- Fix sign detection.
**1.3:**
- Switch from Vault API to [DiamondBank-OG](https://git.trueog.net/trueog/DiamondBank-OG) API.
- Refactor chat messages.
**1.2.3:**
- Added a config option to change the console prefix.
@@ -72,4 +80,4 @@ In your issue report, please include as much information as possible including:
- Lowercase color code support.
- Fixed errors when missing command parameters.
- Fixed errors when missing command parameters.
Executable
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/bash
# Fetch all submodule content.
git submodule update --force --recursive --init
-89
View File
@@ -1,89 +0,0 @@
plugins {
id 'java' // Tell gradle this is a java project.
id 'com.github.johnrengelman.shadow' version '8.1.1' // Import utility to package libraries into .jar file.
id 'eclipse' // Import eclipse plugin for IDE integration.
}
java {
// Declare java version.
sourceCompatibility = JavaVersion.VERSION_17
}
group = "dev.mylesmor.sudosigns" // Declare bundle identifier.
version = "1.2.3" // Declare plugin version (will be in .jar).
def apiVersion = "1.19" // Declare minecraft server target version.
processResources {
def props = [
version: version,
apiVersion: apiVersion,
]
inputs.properties props // Indicates to rerun if version changes.
filesMatching("plugin.yml") {
expand props
}
}
repositories {
mavenCentral()
maven {
url "https://repo.purpurmc.org/snapshots" // Get purpur API from purpur maven repository.
}
maven {
url "https://jitpack.io"
}
}
dependencies {
compileOnly "org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT" // Declare purpur API version to be packaged.
compileOnly "com.github.MilkBowl:VaultAPI:1.7" // Declare Vault APi version to be packaged.
}
shadowJar {
minimize()
}
jar.dependsOn shadowJar
tasks.jar.configure {
archiveClassifier = "part"
}
tasks.shadowJar.configure {
archiveClassifier = null
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ["-parameters"]
options.encoding = 'UTF-8' // Override the system character set with a universal set.
options.fork = true // Enable compilation in a separate daemon process.
}
+125
View File
@@ -0,0 +1,125 @@
/* ------------------------------ Plugins ------------------------------ */
plugins {
id("java") // Import Java plugin.
id("java-library") // Import Java Library plugin.
id("com.diffplug.spotless") version "8.1.0" // Import Spotless plugin.
id("com.gradleup.shadow") version "8.3.9" // Import Shadow plugin.
id("checkstyle") // Import Checkstyle plugin.
eclipse // 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.
toolchain { // Select Java toolchain.
languageVersion.set(JavaLanguageVersion.of(17)) // Use JDK 17.
vendor.set(JvmVendorSpec.GRAAL_VM) // Use GraalVM CE.
}
}
kotlin { jvmToolchain(17) }
/* ----------------------------- Metadata ------------------------------ */
group = "net.trueog.sudosigns-og" // Declare bundle identifier.
version = "1.3.2" // 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) // Indicates to rerun if version changes.
filesMatching("plugin.yml") { expand(props) }
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
}
/* ---------------------------- Repos ---------------------------------- */
repositories {
mavenCentral() // Import the Maven Central Maven Repository.
gradlePluginPortal() // Import the Gradle Plugin Portal Maven Repository.
maven { url = uri("https://repo.purpurmc.org/snapshots") } // Import the PurpurMC Maven Repository.
maven { url = uri("https://jitpack.io") } // Import Jitpack Maven Repository.
}
/* ---------------------- Java project deps ---------------------------- */
dependencies {
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare Purpur API version to be packaged.
compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG Java API (from source).
compileOnlyApi(project(":libs:GxUI-OG")) // Import TrueOG Network GxUI-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 { // Ensure reproducible .jars
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
/* ----------------------------- Shadow -------------------------------- */
tasks.shadowJar {
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()
}
tasks.jar { enabled = false } // Only the shaded jar is deployable to the server.
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) } // Build depends on spotless and shadow.
/* --------------------------- Javac opts ------------------------------- */
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-parameters") // Enable reflection for java code.
options.isFork = true // Run javac in its own process.
options.compilerArgs.add("-Xlint:deprecation") // Trigger deprecation warning messages.
options.encoding = "UTF-8" // Use UTF-8 file encoding.
}
/* ----------------------------- Auto Formatting ------------------------ */
spotless {
java {
eclipse().configFile("config/formatter/eclipse-java-formatter.xml") // Eclipse java formatting.
leadingTabsToSpaces() // Convert leftover leading tabs to spaces.
removeUnusedImports() // Remove imports that aren't being called.
}
kotlinGradle {
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
}
}
checkstyle {
toolVersion = "10.18.1" // Declare checkstyle version to use.
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
isShowViolations = true // Show the violations in any IDE with the checkstyle plugin.
}
tasks.named("compileJava") {
dependsOn("spotlessApply") // Run spotless before compiling with the JDK.
}
tasks.named("spotlessCheck") {
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
}
/* ------------------------------ 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}") }
}
+34
View File
@@ -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*&quot;Not yet implemented&quot;\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="(?&lt;!\w)fail\s*\(\s*&quot;Not yet implemented&quot;\s*\)\s*;"/>
<property name="message" value="Remove placeholder fail() and implement the test."/>
<property name="severity" value="warning"/>
</module>
</module>
+404
View File
@@ -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>
+151
View File
@@ -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 = "SudoSigns-OG"
}
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()
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+7 -5
View File
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -112,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
@@ -203,7 +205,7 @@ fi
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
@@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+14 -12
View File
@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
@@ -57,22 +59,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
Submodule libs/DiamondBank-OG added at 39d5a2b936.
Submodule
+1
Submodule libs/GxUI-OG added at 287d0eb3ee.
+1
Submodule libs/Utilities-OG added at 8b5c86cc9c.
-1
View File
@@ -1 +0,0 @@
rootProject.name = "SudoSigns-OG"
+13
View File
@@ -0,0 +1,13 @@
rootProject.name = "SudoSigns-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
}
@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
@@ -19,96 +20,81 @@ import dev.mylesmor.sudosigns.listeners.ChatListener;
import dev.mylesmor.sudosigns.listeners.InventoryListener;
import dev.mylesmor.sudosigns.listeners.PlayerListener;
import dev.mylesmor.sudosigns.listeners.SignListener;
import net.milkbowl.vault.economy.Economy;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
/**
* Main class for SudoSigns.
*
* @author MylesMor
* @author https://mylesmor.dev
*/
public class SudoSigns extends JavaPlugin {
public static Map<String, SudoSign> signs = new HashMap<>();
public static Map<String, SudoSign> signs = new HashMap<>();
public static ArrayList<String> invalidSigns = new ArrayList<>();
public static Map<UUID, SudoUser> users = new HashMap<>();
public static ConfigManager config;
public static Plugin sudoSignsPlugin;
public static String version;
public DiamondBankAPIJava diamondBankAPI;
public static ArrayList<String> invalidSigns = new ArrayList<>();
@Override
public void onEnable() {
public static Map<UUID, SudoUser> users = new HashMap<>();
final String version = getServer().getVersion().split("MC: ")[1];
SudoSigns.version = StringUtils.substring(version, 0, version.length() - 1);
public static ConfigManager config;
final RegisteredServiceProvider<DiamondBankAPIJava> provider = getServer().getServicesManager()
.getRegistration(DiamondBankAPIJava.class);
if (provider == null) {
public static Plugin sudoSignsPlugin;
getLogger().severe("DiamondBank-OG API is null – disabling plugin.");
public static String version;
Bukkit.getPluginManager().disablePlugin(this);
public static Economy econ = null;
return;
@Override
public void onEnable() {
}
setupEconomy();
this.diamondBankAPI = provider.getProvider();
String version = getServer().getVersion().split("MC: ")[1];
SudoSigns.version = version.substring(0, version.length() - 1);
getServer().getPluginManager().registerEvents(new SignListener(diamondBankAPI), this);
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
getServer().getPluginManager().registerEvents(new ChatListener(), this);
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
getServer().getPluginManager().registerEvents(new SignListener(), this);
getServer().getPluginManager().registerEvents(new InventoryListener(), this);
getServer().getPluginManager().registerEvents(new ChatListener(), this);
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
sudoSignsPlugin = this;
sudoSignsPlugin = this;
// Import signs.yml file(s).
config = new ConfigManager(diamondBankAPI);
config.loadModules();
// Import signs.yml file(s).
config = new ConfigManager();
config.loadModules();
// Import config.yml file.
getConfig().options().copyDefaults(true);
saveDefaultConfig();
// Import config.yml file.
getConfig().options().copyDefaults(true);
saveDefaultConfig();
this.getCommand("sudosigns").setExecutor(new Commands(diamondBankAPI));
this.getCommand("sudosigns").setTabCompleter(new SudoSignsTabCompleter());
this.getCommand("sudosigns").setExecutor(new Commands());
this.getCommand("sudosigns").setTabCompleter(new SudoSignsTabCompleter());
}
}
public static Plugin getPlugin() {
public static Plugin getPlugin() {
return sudoSignsPlugin;
return sudoSignsPlugin;
}
}
public static void setSudoSignsPlugin(Plugin sudoSignsPlugin) {
public static void setSudoSignsPlugin(Plugin sudoSignsPlugin) {
SudoSigns.sudoSignsPlugin = sudoSignsPlugin;
}
SudoSigns.sudoSignsPlugin = sudoSignsPlugin;
public boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
}
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "ERROR: Vault not found, sign prices disabled...");
@Override
public void onDisable() {
return false;
getLogger().info("SudoSigns-OG v" + version + " has been disabled.");
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "ERROR: No compatible economy plugin found, sign prices disabled...");
return false;
}
econ = rsp.getProvider();
return true;
}
@Override
public void onDisable() {
}
}
}
@@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandExecutor;
@@ -13,92 +14,90 @@ import org.bukkit.entity.Player;
import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.data.SudoUser;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
import net.trueog.utilitiesog.UtilitiesOG;
public class Commands implements CommandExecutor {
Map<String, BiConsumer<Player, String[]>> commands = new HashMap<>();
DiamondBankAPIJava diamondBankAPI;
Map<String, BiConsumer<Player, String[]>> commands = new HashMap<>();
public Commands() {
public Commands(DiamondBankAPIJava diamondBankAPI) {
commands.put("help", Help::help);
commands.put("near", Near::near);
commands.put("list", List::list);
commands.put("delete", Delete::delete);
commands.put("edit", Edit::edit);
commands.put("view", View::view);
commands.put("run", Run::run);
commands.put("confirmdelete", Delete::confirmDelete);
commands.put("reload", Reload::reload);
commands.put("create", Create::create);
commands.put("tp", Teleport::tp);
commands.put("copy", Copy::copy);
commands.put("select", Select::select);
commands.put("purge", Purge::purge);
commands.put("confirmpurge", Purge::confirmPurge);
commands.put("fix", Fix::fix);
this.diamondBankAPI = diamondBankAPI;
}
commands.put("help", Help::help);
commands.put("near", Near::near);
commands.put("list", List::list);
commands.put("delete", Delete::delete);
commands.put("edit", (p, args) -> Edit.edit(p, args, diamondBankAPI));
commands.put("view", View::view);
commands.put("run", Run::run);
commands.put("confirmdelete", Delete::confirmDelete);
commands.put("create", (p, args) -> Create.create(p, args, diamondBankAPI));
commands.put("tp", Teleport::tp);
commands.put("copy", (p, args) -> Copy.copy(p, args, diamondBankAPI));
commands.put("select", Select::select);
commands.put("purge", Purge::purge);
commands.put("confirmpurge", Purge::confirmPurge);
commands.put("fix", Fix::fix);
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
}
if (sender instanceof Player) {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
final Player p = (Player) sender;
SudoSigns.users.computeIfAbsent(p.getUniqueId(), k -> new SudoUser(p));
try {
if (sender instanceof Player p) {
BiConsumer<Player, String[]> command = commands.get(args[0].toLowerCase());
if(command != null) {
SudoSigns.users.computeIfAbsent(p.getUniqueId(), k -> new SudoUser(p));
try {
if (args.length > 1) {
String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
command.accept(p, newArgs);
}
else {
try {
command.accept(p, null);
}
catch(CommandException error) {
invalidCommandError(p);
}
}
final BiConsumer<Player, String[]> command = commands.get(StringUtils.lowerCase(args[0]));
}
else {
invalidCommandError(p);
}
}
catch (ArrayIndexOutOfBoundsException e) {
if (command != null) {
invalidCommandError(p);
}
if (args.length > 1) {
}
final String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
return true;
command.accept(p, newArgs);
}
private void invalidCommandError(Player p) {
Util.sudoSignsMessage(p, "&cERROR: Invalid command! &6Type &d/ss help &6for a list of valid commands.");
}
} else {
try {
command.accept(p, null);
} catch (CommandException error) {
invalidCommandError(p);
}
}
} else {
invalidCommandError(p);
}
} catch (ArrayIndexOutOfBoundsException arrayIndexOutOfBoundsException) {
invalidCommandError(p);
}
}
return true;
}
private void invalidCommandError(Player p) {
UtilitiesOG.trueogMessage(p, "&cERROR: Invalid command! &6Type &d/ss help &6for a list of valid commands.");
}
}
@@ -6,89 +6,92 @@ import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
import net.trueog.utilitiesog.UtilitiesOG;
public class Copy {
/**
* Copies one sign's data to another.
* @param p The player running the command.
* @param args 1 or 2 arguments: If 1, the name of the new sign. If 2, the name of the old sign in index 0 and name of new one in index 1.
*/
public static void copy(Player p, String[] args) {
if (p.hasPermission(Permissions.COPY)) {
/**
* Copies one sign's data to another.
*
* @param p The player running the command.
* @param args 1 or 2 arguments: If 1, the name of the new sign. If 2, the name
* of the old sign in index 0 and name of new one in index 1.
*/
public static void copy(Player p, String[] args, DiamondBankAPIJava diamondBankAPI) {
String oldName = null;
String newName = null;
if (args == null || args.length < 1 || args.length > 2) {
if (p.hasPermission(Permissions.COPY)) {
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss copy [old-sign-name] <new-sign-name>&6.");
return;
String oldName = null;
String newName = null;
if (args == null || args.length < 1 || args.length > 2) {
}
if (args.length == 1) {
UtilitiesOG.trueogMessage(p,
"&cERROR: Invalid syntax! &6Correct syntax: &d/ss copy [old-sign-name] <new-sign-name>&6.");
return;
newName = args[0];
}
}
else {
if (args.length == 1) {
newName = args[1];
oldName = args[0];
newName = args[0];
}
} else {
if (Util.checkName(newName)) {
newName = args[1];
oldName = args[0];
SudoSigns.users.get(p.getUniqueId()).setPassThru(newName);
if (oldName == null) {
}
Util.sudoSignsMessage(p, "&6Please click the sign you'd like to copy from.");
SudoSigns.users.get(p.getUniqueId()).setSelectToCopy(true);
if (Util.checkName(newName)) {
}
else {
SudoSigns.users.get(p.getUniqueId()).setPassThru(newName);
if (oldName == null) {
SudoSign oldSign = SudoSigns.signs.get(oldName);
if (oldSign != null) {
UtilitiesOG.trueogMessage(p, "&6Please click the sign you'd like to copy from.");
SudoSigns.users.get(p.getUniqueId()).setSelectToCopy(true);
if (! SudoSigns.signs.containsKey(newName)) {
} else {
Util.sudoSignsMessage(p, "&6Please click the sign you'd like to copy to.");
SudoSign newSign = new SudoSign(newName);
final SudoSign oldSign = SudoSigns.signs.get(oldName);
if (oldSign != null) {
newSign.copyFrom(oldSign);
if (!SudoSigns.signs.containsKey(newName)) {
SudoSigns.users.get(p.getUniqueId()).setCopy(true);
SudoSigns.signs.put(newName, newSign);
UtilitiesOG.trueogMessage(p, "&6Please click the sign you'd like to copy to.");
final SudoSign newSign = new SudoSign(newName, diamondBankAPI);
}
else {
newSign.copyFrom(oldSign);
Util.sudoSignsMessage(p, "&cERROR: A sign with the name &e%NAME% &calready exists!");
SudoSigns.users.get(p.getUniqueId()).setCopy(true);
SudoSigns.signs.put(newName, newSign);
}
} else {
}
else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with the name &e%NAME% &calready exists!");
Util.sudoSignsMessage(p, "&cERROR: A sign with the name &e%NAME% &cdoes not exist!");
}
}
} else {
}
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with the name &e%NAME% &cdoes not exist!");
}
else {
}
Util.sudoSignsMessage(p, "&cERROR: The name of a SudoSign must only contain numbers and letters!");
}
}
} else {
}
else {
UtilitiesOG.trueogMessage(p, "&cERROR: The name of a SudoSign must only contain numbers and letters!");
Util.sudoSignsErrorMessage(p);
}
} else {
Util.sudoSignsPermissionsError(p);
}
}
}
}
}
@@ -6,60 +6,62 @@ import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
import net.trueog.utilitiesog.UtilitiesOG;
public class Create {
/**
* Creates a sign.
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign (or null for click selection).
*/
public static void create(Player p, String[] args) {
/**
* Creates a sign.
*
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign (or null for click
* selection).
*/
public static void create(Player p, String[] args, DiamondBankAPIJava diamondBankAPI) {
if (p.hasPermission(Permissions.CREATE)) {
if (p.hasPermission(Permissions.CREATE)) {
if (args == null) {
if (args == null) {
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss create <name>&6.");
return;
UtilitiesOG.trueogMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss create <name>&6.");
}
else {
return;
String name = args[0];
if (Util.checkName(name)) {
} else {
if (! SudoSigns.signs.containsKey(name)) {
final String name = args[0];
if (Util.checkName(name)) {
SudoSigns.users.get(p.getUniqueId()).setCreate(true);
SudoSigns.users.get(p.getUniqueId()).setPassThru(name);
SudoSigns.signs.put(name, new SudoSign(name));
if (!SudoSigns.signs.containsKey(name)) {
Util.sudoSignsMessage(p, "&6Please click on the sign you'd like to create.");
SudoSigns.users.get(p.getUniqueId()).setCreate(true);
SudoSigns.users.get(p.getUniqueId()).setPassThru(name);
SudoSigns.signs.put(name, new SudoSign(name, diamondBankAPI));
}
else {
UtilitiesOG.trueogMessage(p, "&6Please click on the sign you'd like to create.");
Util.sudoSignsMessage(p, "&cERROR: A sign with name &e%NAME% &calready exists!", name);
} else {
}
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with name &e" + name + " &calready exists!");
}
else {
}
Util.sudoSignsMessage(p, "&cERROR: The name of a SudoSign must only contain numbers and letters!");
} else {
}
UtilitiesOG.trueogMessage(p,
"&cERROR: The name of a SudoSign must only contain numbers and letters!");
}
}
}
else {
}
Util.sudoSignsErrorMessage(p);
} else {
}
Util.sudoSignsPermissionsError(p);
}
}
}
}
@@ -5,90 +5,104 @@ import org.bukkit.entity.Player;
import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class Delete {
/**
* Deletes a sign.
* @param p The player running the command.
* @param args 1 or 2 arguments: The name of the sign (or null for click selection).
*/
public static void delete(Player p, String[] args) {
if (p.hasPermission(Permissions.DELETE)) {
/**
* Deletes a sign.
*
* @param p The player running the command.
* @param args 1 or 2 arguments: The name of the sign (or null for click
* selection).
*/
public static void delete(Player p, String[] args) {
String name;
if (args != null) {
if (p.hasPermission(Permissions.DELETE)) {
if (args.length > 1) {
final String name;
if (args != null) {
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! &7Correct syntax: &d/ss delete [name]&7.");
return;
if (args.length > 1) {
}
UtilitiesOG.trueogMessage(p, "&cERROR: Invalid syntax! &7Correct syntax: &d/ss delete [name]&7.");
}
else {
Util.sudoSignsMessage(p, "&6Please click the sign you'd like to delete.");
SudoSigns.users.get(p.getUniqueId()).setDelete(true);
return;
}
return;
name = args[0];
if (SudoSigns.signs.containsKey(name)) {
}
SudoSigns.signs.remove(name);
SudoSigns.config.deleteSign(name);
} else {
Util.sudoSignsMessage(p, "&6Sign &e%NAME% &6successfully deleted.", name);
UtilitiesOG.trueogMessage(p, "&6Please click the sign you'd like to delete.");
}
else {
SudoSigns.users.get(p.getUniqueId()).setDelete(true);
Util.sudoSignsMessage(p, "&cERROR: A sign with the name &eNAME% &cdoes not exist!", name);
return;
}
}
}
else {
name = args[0];
if (SudoSigns.signs.containsKey(name)) {
Util.sudoSignsErrorMessage(p);
SudoSigns.signs.remove(name);
SudoSigns.config.deleteSign(name);
}
UtilitiesOG.trueogMessage(p, "&6Sign &e" + name + " &6successfully deleted.");
}
} else if (SudoSigns.config.getInvalidEntriesManager().purgeInvalidEntry(name, false)) {
/**
* Confirms deletion of a sign (only run when [DELETE] is clicked in the selection message).
* @param p The player running the command.
* @param args 1 argument: The name of the sign.
*/
public static void confirmDelete(Player p, String[] args) {
UtilitiesOG.trueogMessage(p, "&6Sign &e" + name + " &6successfully deleted.");
// If the player has permission to delete signs, do this...
if (p.hasPermission(Permissions.DELETE)) {
} else {
// If the sign that was selected does not exist, do this...
if (args.length != 1) {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with the name &e" + name + " &cdoes not exist!");
// Cancel the deletion confirmation.
return;
}
}
} else {
if (SudoSigns.signs.containsKey(args[0])) {
Util.sudoSignsPermissionsError(p);
// Send a deletion confirmation menu with a clickable button.
Util.selectMenuParser(p, "&c&l[CONFIRM DELETION]", ("&6Are you sure you want to delete sign &e" + args[0] + "&6?"), p.getName(), ("/ss delete " + args[0]), ("&cYes, delete the sign: &6" + args[0] + "&c!"));
}
}
else {
}
Util.sudoSignsMessage(p, "&cERROR: A sign with the name &e%NAME% &cdoes not exist!", args[0]);
/**
* Confirms deletion of a sign (only run when [DELETE] is clicked in the
* selection message).
*
* @param p The player running the command.
* @param args 1 argument: The name of the sign.
*/
public static void confirmDelete(Player p, String[] args) {
}
// If the player has permission to delete signs, do this...
if (!p.hasPermission(Permissions.DELETE)) {
}
return;
}
}
// If the sign that was selected does not exist, do this...
if (args.length != 1) {
return;
}
if (SudoSigns.signs.containsKey(args[0])) {
// Send a deletion confirmation menu with a clickable button.
Util.selectMenuParser(p, "&c&l[CONFIRM DELETION]",
("&6Are you sure you want to delete sign &e" + args[0] + "&6?"), p.getName(),
("/ss delete " + args[0]), ("&cYes, delete the sign: &6" + args[0] + "&c!"));
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with the name &e" + args[0] + " &cdoes not exist!");
}
}
}
@@ -6,54 +6,58 @@ import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.menus.SignEditor;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
import net.trueog.utilitiesog.UtilitiesOG;
public class Edit {
/**
* Edits a sign.
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign (or null for click selection).
*/
public static void edit(Player p, String[] args) {
/**
* Edits a sign.
*
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign (or null for click
* selection).
*/
public static void edit(Player p, String[] args, DiamondBankAPIJava diamondBankAPI) {
if (p.hasPermission(Permissions.EDIT)) {
if (p.hasPermission(Permissions.EDIT)) {
String name;
if (args == null) {
final String name;
if (args == null) {
Util.sudoSignsMessage(p, "&6Please click on the sign you'd like to edit.");
UtilitiesOG.trueogMessage(p, "&6Please click on the sign you'd like to edit.");
SudoSigns.users.get(p.getUniqueId()).setEdit(true);
return;
SudoSigns.users.get(p.getUniqueId()).setEdit(true);
return;
}
if (args.length > 1) {
}
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! &aCorrect syntax: &d/ss edit [name]&a.");
return;
if (args.length > 1) {
}
UtilitiesOG.trueogMessage(p, "&cERROR: Invalid syntax! &aCorrect syntax: &d/ss edit [name]&a.");
return;
name = args[0];
if (SudoSigns.signs.containsKey(name)) {
}
SignEditor editor = new SignEditor(p, SudoSigns.signs.get(name), SudoSigns.users.get(p.getUniqueId()));
SudoSigns.users.get(p.getUniqueId()).setEditor(editor);
name = args[0];
if (SudoSigns.signs.containsKey(name)) {
}
else {
final SignEditor editor = new SignEditor(p, SudoSigns.signs.get(name),
SudoSigns.users.get(p.getUniqueId()), diamondBankAPI);
SudoSigns.users.get(p.getUniqueId()).setEditor(editor);
Util.sudoSignsMessage(p, "&cERROR: A sign with the name %NAME% &cdoes not exist!", name);
} else {
}
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with the name &e" + name + " &cdoes not exist!");
}
else {
}
Util.sudoSignsErrorMessage(p);
} else {
}
Util.sudoSignsPermissionsError(p);
}
}
}
}
@@ -5,82 +5,88 @@ import org.bukkit.entity.Player;
import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class Fix {
/**
* Attempt to fix an invalid entry by placing a sign in the config location.
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign.
*/
public static void fix(Player p, String[] args) {
if (p.hasPermission(Permissions.FIX)) {
/**
* Attempt to fix an invalid entry by placing a sign in the config location.
*
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign.
*/
public static void fix(Player p, String[] args) {
String name;
if (args == null) {
if (p.hasPermission(Permissions.FIX)) {
int size = SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size();
if (SudoSigns.config.getInvalidEntriesManager().fixInvalidEntry(null, true)) {
final String name;
if (args == null) {
SudoSigns.config.loadSigns();
if (SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size() == 0) {
final int size = SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size();
if (SudoSigns.config.getInvalidEntriesManager().fixInvalidEntry(null, true)) {
Util.sudoSignsMessage(p, "&aAll invalid entries have been successfully purged from the config.");
SudoSigns.config.loadSigns();
if (SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size() == 0) {
}
else if (SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size() == size) {
UtilitiesOG.trueogMessage(p,
"&aAll invalid entries have been successfully purged from the config.");
Util.sudoSignsMessage(p, "&cERROR: No invalid entries were able to be automatically purged from the config!");
} else if (SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size() == size) {
}
else if (SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size() < size) {
UtilitiesOG.trueogMessage(p,
"&cERROR: No invalid entries were able to be automatically purged from the config!");
Util.sudoSignsMessage(p, "&e" + (SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size() - size) + "&a invalid entries were able to be automatically purged from the config. &e" + Integer.toString(SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size()) + "&c were unable to be automatically purged from the config!");
} else if (SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size() < size) {
}
UtilitiesOG.trueogMessage(p,
"&e" + (SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size() - size)
+ "&a invalid entries were able to be automatically purged from the config. &e"
+ Integer.toString(
SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size())
+ "&c were unable to be automatically purged from the config!");
}
}
return;
}
}
return;
if (args.length > 2) {
}
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss fix [name]&6.");
return;
if (args.length > 2) {
}
UtilitiesOG.trueogMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss fix [name]&6.");
name = args[0];
if (SudoSigns.config.getInvalidEntriesManager().fixInvalidEntry(name, false)) {
return;
SudoSigns.config.loadSigns();
if (SudoSigns.signs.containsKey(name)) {
}
Util.sudoSignsMessage(p, "&aSign &e" + name + "&asuccessfully fixed!");
name = args[0];
if (SudoSigns.config.getInvalidEntriesManager().fixInvalidEntry(name, false)) {
}
else {
SudoSigns.config.loadSigns();
if (SudoSigns.signs.containsKey(name)) {
Util.sudoSignsMessage(p, "&cERROR: Sign &e" + name + "&c was unable to be fixed!");
UtilitiesOG.trueogMessage(p, "&aSign &e" + name + "&asuccessfully fixed!");
}
} else {
}
else {
UtilitiesOG.trueogMessage(p, "&cERROR: Sign &e" + name + "&c was unable to be fixed!");
Util.sudoSignsMessage(p, "&6WARNING: Nothing fixed! That entry is not invalid.");
}
}
} else {
}
else {
UtilitiesOG.trueogMessage(p, "&6WARNING: Nothing fixed! That entry is not invalid.");
Util.sudoSignsErrorMessage(p);
}
}
} else {
}
Util.sudoSignsPermissionsError(p);
}
}
}
@@ -7,73 +7,107 @@ import dev.mylesmor.sudosigns.util.Util;
public class Help {
/**
* Sends the player a help message.
* @param p The player running the command.
* @param args Not required.
*/
public static void help(Player p, String[] args) {
/**
* Sends the player a help message.
*
* @param p The player running the command.
* @param args Not required.
*/
public static void help(Player p, String[] args) {
if (p.hasPermission(Permissions.HELP)) {
if (p.hasPermission(Permissions.HELP)) {
Util.sudoSignsMessageNoPrefix(p, "&b======" + Util.chatPrefix + " &eHelp" + "&b======");
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d <>" + "&f - &6indicates a required argument.");
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d []" + "&f - &6indicates an optional argument.");
Util.sudoSignsMessageNoPrefix(p, "&b======" + Util.chatPrefix + " &eHelp" + "&b======");
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d <>" + "&f - &6indicates a required argument.");
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d []" + "&f - &6indicates an optional argument.");
if (p.hasPermission(Permissions.HELP)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss help" + " &f- &6Displays this menu.");
}
if (p.hasPermission(Permissions.HELP)) {
if (p.hasPermission(Permissions.LIST)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss list" + " &f- &6Lists all SudoSigns.");
}
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss help" + " &f- &6Displays this menu.");
if (p.hasPermission(Permissions.NEAR)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss near [radius]" + " &f- &6Lists SudoSigns within a specified radius (default 5 blocks).");
}
}
if (p.hasPermission(Permissions.VIEW)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss view [name]" + " &f- &6Displays the details of a SudoSign.");
}
if (p.hasPermission(Permissions.LIST)) {
if (p.hasPermission(Permissions.RUN)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss run [name]" + " &f- &6Runs a SudoSigns commands remotely.");
}
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss list" + " &f- &6Lists all SudoSigns.");
if (p.hasPermission(Permissions.TP)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss tp [name]" + " &f- &6Teleport to a SudoSign.");
}
}
if (p.hasPermission(Permissions.CREATE)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss create <name>" + " &f- &6Creates a SudoSign with the specified name.");
}
if (p.hasPermission(Permissions.NEAR)) {
if (p.hasPermission(Permissions.EDIT)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss edit [name]" + " &f- &6Displays the editor for the specified SudoSign.");
}
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss near [radius]"
+ " &f- &6Lists SudoSigns within a specified radius (default 5 blocks).");
if (p.hasPermission(Permissions.COPY)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss copy [old-sign-name] <new-sign-name>" + " &f- &6Copies the specified SudoSign to a new sign.");
}
}
if (p.hasPermission(Permissions.DELETE)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss delete [name]" + " &f- &6Deletes the specified SudoSign.");
}
if (p.hasPermission(Permissions.VIEW)) {
if (p.hasPermission(Permissions.RELOAD)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss reload" + " &f- &6Reloads the configuration file (signs.yml).");
}
Util.sudoSignsMessageNoPrefix(p,
"&e[!]" + "&d /ss view [name]" + " &f- &6Displays the details of a SudoSign.");
if (p.hasPermission(Permissions.PURGE)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss purge [name]" + " &f- &6Removes a specified invalid entry from the config (leave name blank to purge all invalid entries).");
}
}
}
if (p.hasPermission(Permissions.RUN)) {
else {
Util.sudoSignsMessageNoPrefix(p,
"&e[!]" + "&d /ss run [name]" + " &f- &6Runs a SudoSigns commands remotely.");
Util.sudoSignsErrorMessage(p);
}
}
}
}
if (p.hasPermission(Permissions.TP)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss tp [name]" + " &f- &6Teleport to a SudoSign.");
}
if (p.hasPermission(Permissions.CREATE)) {
Util.sudoSignsMessageNoPrefix(p,
"&e[!]" + "&d /ss create <name>" + " &f- &6Creates a SudoSign with the specified name.");
}
if (p.hasPermission(Permissions.EDIT)) {
Util.sudoSignsMessageNoPrefix(p,
"&e[!]" + "&d /ss edit [name]" + " &f- &6Displays the editor for the specified SudoSign.");
}
if (p.hasPermission(Permissions.COPY)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss copy [old-sign-name] <new-sign-name>"
+ " &f- &6Copies the specified SudoSign to a new sign.");
}
if (p.hasPermission(Permissions.DELETE)) {
Util.sudoSignsMessageNoPrefix(p,
"&e[!]" + "&d /ss delete [name]" + " &f- &6Deletes the specified SudoSign.");
}
if (p.hasPermission(Permissions.RELOAD)) {
Util.sudoSignsMessageNoPrefix(p,
"&e[!]" + "&d /ss reload" + " &f- &6Reloads the configuration file (signs.yml).");
}
if (p.hasPermission(Permissions.PURGE)) {
Util.sudoSignsMessageNoPrefix(p, "&e[!]" + "&d /ss purge [name]"
+ " &f- &6Removes a specified invalid entry from the config (leave name blank to purge all invalid entries).");
}
} else {
Util.sudoSignsPermissionsError(p);
}
}
}
@@ -1,46 +1,42 @@
package dev.mylesmor.sudosigns.commands;
import java.util.Map;
import org.bukkit.entity.Player;
import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class List {
/**
* Lists all signs.
* @param p The player running the command.
* @param args Not required
*/
public static void list(Player p, String[] args) {
/**
* Lists all signs.
*
* @param p The player running the command.
* @param args Not required
*/
public static void list(Player p, String[] args) {
if (p.hasPermission(Permissions.LIST)) {
if (p.hasPermission(Permissions.LIST)) {
if (SudoSigns.signs.size() == 0) {
if (SudoSigns.signs.isEmpty()) {
Util.sudoSignsMessage(p, "&cERROR: No SudoSigns were found!");
return;
UtilitiesOG.trueogMessage(p, "&cERROR: No SudoSigns were found!");
}
return;
Util.sudoSignsMessage(p, "&6Listing all SudoSigns...");
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
}
Util.sendSelectMenus(p, entry.getKey());
UtilitiesOG.trueogMessage(p, "&6Listing all SudoSigns...");
}
SudoSigns.signs.entrySet().forEach(entry -> Util.sendSelectMenus(p, entry.getKey()));
}
else {
} else {
Util.sudoSignsErrorMessage(p);
Util.sudoSignsPermissionsError(p);
}
}
}
}
}
@@ -9,53 +9,98 @@ import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class Near {
/**
* Displays signs within a set radius.
* @param p The player running the command.
* @param args 0 or 1 arguments, with the only argument being the radius to search in (default is 5 blocks).
*/
public static void near(Player p, String[] args) {
if (p.hasPermission(Permissions.NEAR)) {
int r;
String radius = null;
if (args != null) {
if (args.length > 1) {
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! " + "&6Correct syntax: " + "&d/ss near [radius]" + "&6.");
return;
} else if (args.length == 1) {
radius = args[0];
}
}
if (radius == null) {
r = 5;
} else {
try {
r = Integer.parseInt(radius);
} catch (NumberFormatException e) {
Util.sudoSignsMessage(p, "&cERROR: &e" + radius + " &cis not a valid number! &6Reverting to a radius of &e5&6.");
r = 5;
}
}
boolean found = false;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
Location signLoc = entry.getValue().getSign().getLocation();
try {
if (signLoc.distance(p.getLocation()) <= r) {
if (!found)
Util.sudoSignsMessage(p, "&6Displaying SudoSigns within a radius of &e%NAME% &6block(s):&e", Integer.toString(r));
found = true;
Util.sendSelectMenus(p, entry.getKey());
}
} catch (Exception ignored) {}
}
if (!found) {
Util.sudoSignsMessage(p, "&6No SudoSigns found within a radius of &e%NAME% &6block(s).&e", Integer.toString(r));
}
} else {
Util.sudoSignsMessage(p, "&cYou do not have permission to do that!");
}
}
}
/**
* Displays signs within a set radius.
*
* @param p The player running the command.
* @param args 0 or 1 arguments, with the only argument being the radius to
* search in (default is 5 blocks).
*/
public static void near(Player p, String[] args) {
if (p.hasPermission(Permissions.NEAR)) {
int r;
String radius = null;
if (args != null) {
if (args.length > 1) {
UtilitiesOG.trueogMessage(p,
"&cERROR: Invalid syntax! " + "&6Correct syntax: " + "&d/ss near [radius]" + "&6.");
return;
} else if (args.length == 1) {
radius = args[0];
}
}
if (radius == null) {
r = 5;
} else {
try {
r = Integer.parseInt(radius);
} catch (NumberFormatException numberFormatException) {
UtilitiesOG.trueogMessage(p,
"&cERROR: &e" + radius + " &cis not a valid number! &6Reverting to a radius of &e5&6.");
r = 5;
}
}
boolean found = false;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
final Location signLoc = entry.getValue().getSign().getLocation();
try {
if (signLoc.distance(p.getLocation()) <= r) {
if (!found) {
UtilitiesOG.trueogMessage(p, "&6Displaying SudoSigns within a radius of &e"
+ Integer.toString(r) + " &6block(s):&e");
}
found = true;
Util.sendSelectMenus(p, entry.getKey());
}
} catch (Exception ignored) {
}
}
if (!found) {
UtilitiesOG.trueogMessage(p,
"&6No SudoSigns found within a radius of &e" + Integer.toString(r) + " &6block(s).&e");
}
} else {
Util.sudoSignsPermissionsError(p);
}
}
}
@@ -5,111 +5,119 @@ import org.bukkit.entity.Player;
import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class Purge {
/**
* Purge an invalid sign's config entry (or all if name not provided).
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign.
*/
public static void purge(Player p, String[] args) {
/**
* Purge an invalid sign's config entry (or all if name not provided).
*
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign.
*/
public static void purge(Player p, String[] args) {
if (p.hasPermission(Permissions.PURGE)) {
if (p.hasPermission(Permissions.PURGE)) {
String name = null;
if (args == null) {
String name = null;
if (args == null) {
purgeAll(p);
return;
purgeAll(p);
}
return;
if (args.length > 1) {
}
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! " + "&6Correct syntax: " + "&d/ss purge [name]" + "&6.");
return;
if (args.length > 1) {
}
UtilitiesOG.trueogMessage(p,
"&cERROR: Invalid syntax! " + "&6Correct syntax: " + "&d/ss purge [name]" + "&6.");
return;
if (args.length == 1) {
}
name = args[0];
if (args.length == 1) {
}
name = args[0];
if (name != null) {
}
if (SudoSigns.config.getInvalidEntriesManager().purgeInvalidEntry(args[0], false)) {
if (name != null) {
Util.sudoSignsMessage(p, "&aSign &e" + args[0] + "&a successfully purged from the config!");
if (SudoSigns.config.getInvalidEntriesManager().purgeInvalidEntry(args[0], false)) {
}
else {
UtilitiesOG.trueogMessage(p, "&aSign &e" + args[0] + "&a successfully purged from the config!");
Util.sudoSignsMessage(p, "&eWARNING: &6Nothing purged! That entry is not invalid.");
} else {
}
UtilitiesOG.trueogMessage(p, "&eWARNING: &6Nothing purged! That entry is not invalid.");
}
}
}
else {
}
Util.sudoSignsErrorMessage(p);
} else {
}
Util.sudoSignsPermissionsError(p);
}
}
private static void purgeAll(Player p) {
}
int beforeSize = SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size();
if (beforeSize == 0) {
private static void purgeAll(Player p) {
Util.sudoSignsMessage(p, "&eWARNING: &6No invalid entries found to remove from the config!");
return;
final int beforeSize = SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size();
if (beforeSize == 0) {
}
if (SudoSigns.config.getInvalidEntriesManager().purgeInvalidEntry(null, true)) {
UtilitiesOG.trueogMessage(p, "&eWARNING: &6No invalid entries found to remove from the config!");
int afterSize = SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size();
if (afterSize == 0) {
return;
Util.sudoSignsMessage(p, "&aAll invalid entries have been successfully purged from the config!");
}
}
else if (afterSize == beforeSize) {
if (SudoSigns.config.getInvalidEntriesManager().purgeInvalidEntry(null, true)) {
Util.sudoSignsMessage(p, "&cERROR: No invalid entries were able to be removed automatically!");
final int afterSize = SudoSigns.config.getInvalidEntriesManager().getInvalidEntries().size();
if (afterSize == 0) {
}
else {
UtilitiesOG.trueogMessage(p, "&aAll invalid entries have been successfully purged from the config!");
Util.sudoSignsMessage(p, "&e" + (beforeSize - afterSize) + "&a invalid config entries were able to be removed automatically. &e" + afterSize + " &6were unable to be removed automatically.");
} else if (afterSize == beforeSize) {
}
UtilitiesOG.trueogMessage(p, "&cERROR: No invalid entries were able to be removed automatically!");
}
} else {
return;
UtilitiesOG.trueogMessage(p,
"&e" + (beforeSize - afterSize)
+ "&a invalid config entries were able to be removed automatically. &e" + afterSize
+ " &6were unable to be removed automatically.");
}
}
public static void confirmPurge(Player p, String[] args) {
}
if (p.hasPermission(Permissions.PURGE)) {
return;
if (args.length != 1) {
}
return;
public static void confirmPurge(Player p, String[] args) {
}
if (!p.hasPermission(Permissions.PURGE)) {
Util.selectMenuParser(p, "&a&l[YES]", ("&6Are you sure you want to purge sign &e" + args[0] + "&6?"), p.getName(), ("/ss purge " + args[0]), ("&aYes, delete the sign: &6" + args[0] + "&a!"));
return;
}
}
}
if (args.length != 1) {
return;
}
Util.selectMenuParser(p, "&a&l[YES]", ("&6Are you sure you want to purge sign &e" + args[0] + "&6?"),
p.getName(), ("/ss purge " + args[0]), ("&aYes, delete the sign: &6" + args[0] + "&a!"));
}
}
@@ -8,76 +8,86 @@ import org.bukkit.entity.Player;
import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class Reload {
/**
* Reloads the config file (signs.yml)
* @param p The player running the command.
* @param args Not required
*/
public static void reload(Player p, String[] args) {
/**
* Reloads the config file (signs.yml)
*
* @param p The player running the command.
* @param args Not required
*/
public static void reload(Player p, String[] args) {
if (p.hasPermission(Permissions.RELOAD)) {
if (p.hasPermission(Permissions.RELOAD)) {
Util.sudoSignsMessage(p, "&6Reloading config...");
SudoSigns.signs.clear();
UtilitiesOG.trueogMessage(p, "&6Reloading config...");
SudoSigns.signs.clear();
if (SudoSigns.config.loadCustomConfig()) {
if (SudoSigns.config.loadCustomConfig()) {
ArrayList<String> invalidSigns = SudoSigns.config.loadSigns();
if (invalidSigns != null) {
final ArrayList<String> invalidSigns = SudoSigns.config.loadSigns();
if (invalidSigns != null) {
if (invalidSigns.size() == 0) {
if (invalidSigns.size() == 0) {
Util.sudoSignsMessage(p, "&aConfig successfully reloaded! No invalid signs found.");
UtilitiesOG.trueogMessage(p, "&aConfig successfully reloaded! No invalid signs found.");
}
else {
} else {
Util.sudoSignsMessage(p, "&aConfig successfully reloaded! &cERROR: Found &e" + invalidSigns.size() + " &cinvalid signs!");
for (String name : invalidSigns) {
UtilitiesOG.trueogMessage(p, "&aConfig successfully reloaded! &cERROR: Found &e"
+ invalidSigns.size() + " &cinvalid signs!");
invalidSigns.forEach(name -> {
// If the player has permission to purge a sign, do this...
if (p.hasPermission(Permissions.PURGE)) {
// If the player has permission to purge a sign, do this...
if (p.hasPermission(Permissions.PURGE)) {
// Send a fix confirmation menu with a clickable button.
Util.selectMenuParser(p, "&a&l[FIX]", ("&cSign: &e&l" + name), name, ("/ss fix " + name), ("&6Fix &e" + name + "&6by placing a replica of the sign at the location."));
// Send a fix confirmation menu with a clickable button.
Util.selectMenuParser(p, "&a&l[FIX]", ("&cSign: &e&l" + name), name,
("/ss fix " + name),
("&6Fix &e" + name + "&6by placing a replica of the sign at the location."));
}
}
// If the player has permission to fix a sign, do this...
if (p.hasPermission(Permissions.FIX)) {
// If the player has permission to fix a sign, do this...
if (p.hasPermission(Permissions.FIX)) {
// Send a purge confirmation menu with a clickable button.
Util.selectMenuParser(p, "&c&l[PURGE]", ("&cSign: &e&l" + name), name, ("/ss confirmpurge " + name), (("&cRemove &e" + name + "&6from the config file.")));
// Send a purge confirmation menu with a clickable button.
Util.selectMenuParser(p, "&c&l[PURGE]", ("&cSign: &e&l" + name), name,
("/ss confirmpurge " + name),
(("&cRemove &e" + name + "&6from the config file.")));
}
}
}
});
}
}
return;
return;
}
}
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "There was an error with the SudoSigns config!");
Util.sudoSignsMessage(p, "&cERROR: The latest update to the SudoSigns config was invalid! &6Continuing to use old config...");
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix")
+ "There was an error with the SudoSigns config!");
UtilitiesOG.trueogMessage(p,
"&cERROR: The latest update to the SudoSigns config was invalid! &6Continuing to use old config...");
}
else {
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "There was an error with the SudoSigns config!");
Util.sudoSignsMessage(p, "&cERROR: The latest update to the SudoSigns config was invalid! &6Please attempt to fix it before the next server restart or plugin reload attempt.");
}
} else {
}
else {
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix")
+ "There was an error with the SudoSigns config!");
UtilitiesOG.trueogMessage(p,
"&cERROR: The latest update to the SudoSigns config was invalid! &6Please attempt to fix it before the next server restart or plugin reload attempt.");
Util.sudoSignsErrorMessage(p);
}
}
} else {
}
Util.sudoSignsPermissionsError(p);
}
}
}
@@ -6,55 +6,59 @@ import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class Run {
/**
* Runs a sign remotely.
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign (or null for click selection).
*/
public static void run(Player p, String[] args) {
if (p.hasPermission(Permissions.RUN)) {
/**
* Runs a sign remotely.
*
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign (or null for click
* selection).
*/
public static void run(Player p, String[] args) {
String name;
if (args == null) {
if (p.hasPermission(Permissions.RUN)) {
Util.sudoSignsMessage(p, "&6Please click on the sign you would like to run.");
SudoSigns.users.get(p.getUniqueId()).setRun(true);
return;
final String name;
if (args == null) {
}
UtilitiesOG.trueogMessage(p, "&6Please click on the sign you would like to run.");
SudoSigns.users.get(p.getUniqueId()).setRun(true);
return;
if (args.length > 1) {
}
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss run [name]&6.");
return;
if (args.length > 1) {
}
UtilitiesOG.trueogMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss run [name]&6.");
return;
name = args[0];
if (SudoSigns.signs.containsKey(name)) {
}
SudoSign sign = SudoSigns.signs.get(name);
name = args[0];
if (SudoSigns.signs.containsKey(name)) {
Util.sudoSignsMessage(p, "&6Executing &e" + sign.getMessages().size() + "&6 message(s) and &e" + (sign.getPlayerCommands().size() + sign.getConsoleCommands().size()) + "&6 command(s)...");
SudoSigns.signs.get(name).executeCommands(p);
final SudoSign sign = SudoSigns.signs.get(name);
}
else {
UtilitiesOG.trueogMessage(p, "&6Executing &e" + sign.getMessages().size() + "&6 message(s) and &e"
+ (sign.getPlayerCommands().size() + sign.getConsoleCommands().size()) + "&6 command(s)...");
Util.sudoSignsMessage(p, "&cERROR: A sign with the name &e%NAME% &cdoes not exist!", name);
SudoSigns.signs.get(name).executeCommands(p);
}
} else {
}
else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with the name &e" + name + " &cdoes not exist!");
Util.sudoSignsErrorMessage(p);
}
}
} else {
}
Util.sudoSignsPermissionsError(p);
}
}
}
@@ -4,36 +4,36 @@ import org.bukkit.entity.Player;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class Select {
/**
* Select a sign (display selection message in chat).
* @param p The player running the command.
* @param args 1 argument: The name of the sign.
*/
public static void select(Player p, String[] args) {
/**
* Select a sign (display selection message in chat).
*
* @param p The player running the command.
* @param args 1 argument: The name of the sign.
*/
public static void select(Player p, String[] args) {
if (p.hasPermission(Permissions.SELECT)) {
if (p.hasPermission(Permissions.SELECT)) {
if (args == null || args.length != 1) {
if (args == null || args.length != 1) {
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! " + "&6Correct syntax: &d/ss select <name> &6.");
UtilitiesOG.trueogMessage(p, "&cERROR: Invalid syntax! " + "&6Correct syntax: &d/ss select <name> &6.");
}
else {
} else {
Util.sendSelectMenus(p, args[0]);
Util.sendSelectMenus(p, args[0]);
}
}
}
else {
} else {
Util.sudoSignsErrorMessage(p);
Util.sudoSignsPermissionsError(p);
}
}
}
}
}
@@ -9,116 +9,206 @@ import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.util.Permissions;
public class SudoSignsTabCompleter implements TabCompleter {
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] args) {
if (commandSender instanceof Player) {
Player p = (Player) commandSender;
if (args.length == 1) {
ArrayList<String> commands = new ArrayList<>();
if (p.hasPermission(Permissions.HELP)) {
commands.add("help");
}
if (p.hasPermission(Permissions.RELOAD)) {
commands.add("reload");
}
if (p.hasPermission(Permissions.CREATE)) {
commands.add("create");
}
if (p.hasPermission(Permissions.LIST)) {
commands.add("list");
}
if (p.hasPermission(Permissions.NEAR)) {
commands.add("near");
}
if (p.hasPermission(Permissions.DELETE)) {
commands.add("delete");
}
if (p.hasPermission(Permissions.VIEW)) {
commands.add("view");
}
if (p.hasPermission(Permissions.RUN)) {
commands.add("run");
}
if (p.hasPermission(Permissions.RELOAD)) {
commands.add("reload");
}
if (p.hasPermission(Permissions.TP)) {
commands.add("tp");
}
if (p.hasPermission(Permissions.COPY)) {
commands.add("copy");
}
if (p.hasPermission(Permissions.SELECT)) {
commands.add("select");
}
if (p.hasPermission(Permissions.PURGE)) {
commands.add("purge");
}
if (p.hasPermission(Permissions.FIX)) {
commands.add("fix");
}
if (p.hasPermission(Permissions.EDIT)) {
commands.add("edit");
}
return commands;
}
if (args.length == 2) {
ArrayList<String> suggestions = new ArrayList<>();
switch (args[0]) {
case "create":
if (p.hasPermission(Permissions.CREATE)) {
suggestions.add("<sign-name>");
}
return suggestions;
case "delete":
case "view":
case "run":
case "tp":
case "copy":
case "select":
case "edit":
if (p.hasPermission(Permissions.SELECT) || p.hasPermission(Permissions.VIEW)
|| p.hasPermission(Permissions.RUN) || p.hasPermission(Permissions.TP)
|| p.hasPermission(Permissions.COPY) || p.hasPermission(Permissions.SELECT)
|| p.hasPermission(Permissions.EDIT)) {
for (SudoSign s : SudoSigns.signs.values()) {
suggestions.add(s.getName());
}
}
return suggestions;
case "fix":
case "purge":
if (p.hasPermission(Permissions.PURGE)) {
suggestions.addAll(SudoSigns.invalidSigns);
}
return suggestions;
case "near":
if (p.hasPermission(Permissions.NEAR)) {
suggestions.add("2");
suggestions.add("5");
suggestions.add("10");
suggestions.add("25");
suggestions.add("50");
}
return suggestions;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] args) {
}
if (args.length == 3) {
ArrayList<String> suggestions = new ArrayList<>();
switch (args[0]) {
case "copy":
suggestions.add("<new-sign-name>");
return suggestions;
}
}
}
if (commandSender instanceof Player p) {
if (args.length == 1) {
final ArrayList<String> commands = new ArrayList<>();
if (p.hasPermission(Permissions.HELP)) {
commands.add("help");
}
if (p.hasPermission(Permissions.RELOAD)) {
commands.add("reload");
}
if (p.hasPermission(Permissions.CREATE)) {
commands.add("create");
}
if (p.hasPermission(Permissions.LIST)) {
commands.add("list");
}
if (p.hasPermission(Permissions.NEAR)) {
commands.add("near");
}
if (p.hasPermission(Permissions.DELETE)) {
commands.add("delete");
}
if (p.hasPermission(Permissions.VIEW)) {
commands.add("view");
}
if (p.hasPermission(Permissions.RUN)) {
commands.add("run");
}
if (p.hasPermission(Permissions.RELOAD)) {
commands.add("reload");
}
if (p.hasPermission(Permissions.TP)) {
commands.add("tp");
}
if (p.hasPermission(Permissions.COPY)) {
commands.add("copy");
}
if (p.hasPermission(Permissions.SELECT)) {
commands.add("select");
}
if (p.hasPermission(Permissions.PURGE)) {
commands.add("purge");
}
if (p.hasPermission(Permissions.FIX)) {
commands.add("fix");
}
if (p.hasPermission(Permissions.EDIT)) {
commands.add("edit");
}
return commands;
}
if (args.length == 2) {
final ArrayList<String> suggestions = new ArrayList<>();
switch (args[0]) {
case "create" -> {
if (p.hasPermission(Permissions.CREATE)) {
suggestions.add("<sign-name>");
}
return suggestions;
}
case "delete" -> {
if (p.hasPermission(Permissions.DELETE)) {
SudoSigns.signs.values().forEach(s -> suggestions.add(s.getName()));
suggestions.addAll(SudoSigns.invalidSigns);
}
return suggestions;
}
case "view", "run", "tp", "copy", "select", "edit" -> {
if (p.hasPermission(Permissions.SELECT) || p.hasPermission(Permissions.VIEW)
|| p.hasPermission(Permissions.RUN) || p.hasPermission(Permissions.TP)
|| p.hasPermission(Permissions.COPY) || p.hasPermission(Permissions.SELECT)
|| p.hasPermission(Permissions.EDIT))
{
SudoSigns.signs.values().forEach(s -> suggestions.add(s.getName()));
}
return suggestions;
}
case "fix", "purge" -> {
if (p.hasPermission(Permissions.PURGE)) {
suggestions.addAll(SudoSigns.invalidSigns);
}
return suggestions;
}
case "near" -> {
if (p.hasPermission(Permissions.NEAR)) {
suggestions.add("2");
suggestions.add("5");
suggestions.add("10");
suggestions.add("25");
suggestions.add("50");
}
return suggestions;
}
}
}
if (args.length == 3) {
final ArrayList<String> suggestions = new ArrayList<>();
switch (args[0]) {
case "copy" -> {
suggestions.add("<new-sign-name>");
return suggestions;
}
}
}
}
return null;
}
return null;
}
}
@@ -6,48 +6,48 @@ import org.bukkit.entity.Player;
import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class Teleport {
/**
* Teleports a player to the sign.
* @param p The player running the command.
* @param args 1 argument: The name of the sign.
*/
public static void tp(Player p, String[] args) {
/**
* Teleports a player to the sign.
*
* @param p The player running the command.
* @param args 1 argument: The name of the sign.
*/
public static void tp(Player p, String[] args) {
if (p.hasPermission(Permissions.TP)) {
if (p.hasPermission(Permissions.TP)) {
if (args == null || args.length != 1) {
if (args == null || args.length != 1) {
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss tp <name>&6.");
return;
UtilitiesOG.trueogMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss tp <name>&6.");
return;
}
}
String name = args[0];
if (SudoSigns.signs.containsKey(name)) {
final String name = args[0];
if (SudoSigns.signs.containsKey(name)) {
Location newLoc = SudoSigns.signs.get(name).getSign().getLocation();
newLoc.setX(newLoc.getX() + 0.5);
newLoc.setZ(newLoc.getZ() + 0.5);
final Location newLoc = SudoSigns.signs.get(name).getSign().getLocation();
newLoc.setX(newLoc.getX() + 0.5);
newLoc.setZ(newLoc.getZ() + 0.5);
p.teleport(newLoc);
p.teleport(newLoc);
}
else {
} else {
Util.sudoSignsMessage(p, "&cERROR: A sign with the name &e%NAME% &cdoes not exist!", name);
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with the name &e" + name + " &cdoes not exist!");
}
}
}
else {
} else {
Util.sudoSignsErrorMessage(p);
Util.sudoSignsPermissionsError(p);
}
}
}
}
}
@@ -7,137 +7,157 @@ import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class View {
/**
* Views a sign's details, including location and number of permissions and commands assigned to it.
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign (or null for click selection).
*/
public static void view(Player p, String[] args) {
/**
* Views a sign's details, including location and number of permissions and
* commands assigned to it.
*
* @param p The player running the command.
* @param args 0 or 1 arguments: The name of the sign (or null for click
* selection).
*/
public static void view(Player p, String[] args) {
if (p.hasPermission(Permissions.VIEW)) {
if (p.hasPermission(Permissions.VIEW)) {
String name = null;
if (args == null) {
String name = null;
if (args == null) {
Util.sudoSignsMessage(p, "&6Please click on the sign you would like to view.");
SudoSigns.users.get(p.getUniqueId()).setView(true);
return;
UtilitiesOG.trueogMessage(p, "&6Please click on the sign you would like to view.");
SudoSigns.users.get(p.getUniqueId()).setView(true);
return;
}
if (args.length > 1) {
}
Util.sudoSignsMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss view [name]&6.");
return;
if (args.length > 1) {
}
UtilitiesOG.trueogMessage(p, "&cERROR: Invalid syntax! &6Correct syntax: &d/ss view [name]&6.");
return;
name = args[0];
SudoSign sign = SudoSigns.signs.get(name);
if (sign != null) {
}
Location signLoc = sign.getSign().getLocation();
String locString = "x=" + signLoc.getX() + " y=" + signLoc.getY() + " z=" + signLoc.getZ() + " ";
Util.sudoSignsMessage(p, "&6Displaying details for sign &e%NAME%&6:", name);
if (p.hasPermission(Permissions.TP)) {
name = args[0];
final SudoSign sign = SudoSigns.signs.get(name);
if (sign != null) {
// Send a teleport confirmation menu with a clickable button.
Util.selectMenuParser(p, "&d&l[TP]", ("&6Location: &e" + "&a" + locString), p.getName(), ("/ss tp " + name), ("&dTeleport to: &e" + name));
final Location signLoc = sign.getSign().getLocation();
final String locString = "x=" + signLoc.getX() + " y=" + signLoc.getY() + " z=" + signLoc.getZ() + " ";
UtilitiesOG.trueogMessage(p, "&6Displaying details for sign &e" + name + "&6:");
if (p.hasPermission(Permissions.TP)) {
}
else {
// Send a teleport confirmation menu with a clickable button.
Util.selectMenuParser(p, "&d&l[TP]", ("&6Location: &e" + "&a" + locString), p.getName(),
("/ss tp " + name), ("&dTeleport to: &e" + name));
Util.sudoSignsMessage(p, "&6Location: &e" + locString);
} else {
}
UtilitiesOG.trueogMessage(p, "&6Location: &e" + locString);
if(! SudoSigns.getPlugin().getConfig().getBoolean("config.currency-symbol-in-front")) {
}
if(Util.priceIsInteger()) {
if (!SudoSigns.getPlugin().getConfig().getBoolean("config.currency-symbol-in-front")) {
if (sign.getPriceAsInteger() == 1) {
if (Util.priceIsInteger()) {
Util.sudoSignsMessage(p, "&6Price: &e" + sign.getPriceAsInteger() + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&6.");
if (sign.getPriceAsInteger() == 1) {
}
else {
UtilitiesOG.trueogMessage(p, "&6Price: &e" + sign.getPriceAsInteger()
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular")
+ "&6.");
Util.sudoSignsMessage(p, "&6Price: &e" + sign.getPriceAsInteger() + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&6.");
} else {
}
UtilitiesOG.trueogMessage(p, "&6Price: &e" + sign.getPriceAsInteger()
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural")
+ "&6.");
}
else {
}
if (sign.getPriceAsDouble() == 1.0) {
} else {
Util.sudoSignsMessage(p, "&6Price: &e" + sign.getPriceAsDouble() + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&6.");
if (sign.getPriceAsDouble() == 1.0) {
}
else {
UtilitiesOG.trueogMessage(p, "&6Price: &e" + sign.getPriceAsDouble()
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular")
+ "&6.");
Util.sudoSignsMessage(p, "&6Price: &e" + sign.getPriceAsDouble() + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&6.");
} else {
}
UtilitiesOG.trueogMessage(p, "&6Price: &e" + sign.getPriceAsDouble()
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural")
+ "&6.");
}
}
}
else {
}
if(Util.priceIsInteger()) {
} else {
if (sign.getPriceAsInteger() == 1) {
if (Util.priceIsInteger()) {
Util.sudoSignsMessage(p, "&6Price: " + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e" + sign.getPriceAsInteger() + "&6.");
if (sign.getPriceAsInteger() == 1) {
}
else {
UtilitiesOG.trueogMessage(p,
"&6Price: "
+ SudoSigns.getPlugin().getConfig()
.getString("config.currency-symbol-singular")
+ "&e" + sign.getPriceAsInteger() + "&6.");
Util.sudoSignsMessage(p, "&6Price: " + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e" + sign.getPriceAsInteger() + "&6.");
} else {
}
UtilitiesOG.trueogMessage(p,
"&6Price: "
+ SudoSigns.getPlugin().getConfig()
.getString("config.currency-symbol-plural")
+ "&e" + sign.getPriceAsInteger() + "&6.");
}
else {
}
if (sign.getPriceAsDouble() == 1.0) {
} else {
Util.sudoSignsMessage(p, "&6Price: " + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e" + sign.getPriceAsDouble() + "&6.");
if (sign.getPriceAsDouble() == 1.0) {
}
else {
UtilitiesOG.trueogMessage(p,
"&6Price: "
+ SudoSigns.getPlugin().getConfig()
.getString("config.currency-symbol-singular")
+ "&e" + sign.getPriceAsDouble() + "&6.");
Util.sudoSignsMessage(p, "&6Price: " + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e" + sign.getPriceAsDouble() + "&6.");
} else {
}
UtilitiesOG.trueogMessage(p,
"&6Price: "
+ SudoSigns.getPlugin().getConfig()
.getString("config.currency-symbol-plural")
+ "&e" + sign.getPriceAsDouble() + "&6.");
}
}
}
}
Util.sudoSignsMessage(p, "&bPrice: " + sign.getMessages().size());
Util.sudoSignsMessage(p, "&6Messages: &e" + sign.getMessages().size());
Util.sudoSignsMessage(p, "&6Permissions: &e" + sign.getPermissions().size());
Util.sudoSignsMessage(p, "&6Player Commands: &e" + sign.getPlayerCommands().size());
Util.sudoSignsMessage(p, "&6Console Commands: &e" + sign.getConsoleCommands().size());
}
}
else {
UtilitiesOG.trueogMessage(p, "&bPrice: " + sign.getMessages().size());
UtilitiesOG.trueogMessage(p, "&6Messages: &e" + sign.getMessages().size());
UtilitiesOG.trueogMessage(p, "&6Permissions: &e" + sign.getPermissions().size());
UtilitiesOG.trueogMessage(p, "&6Player Commands: &e" + sign.getPlayerCommands().size());
UtilitiesOG.trueogMessage(p, "&6Console Commands: &e" + sign.getConsoleCommands().size());
Util.sudoSignsMessage(p, "&cERROR: A sign with the name &e%NAME% &cdoes not exist!", name);
} else {
}
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with the name &e" + name + " &cdoes not exist!");
}
else {
}
Util.sudoSignsErrorMessage(p);
} else {
}
Util.sudoSignsPermissionsError(p);
}
}
}
}
@@ -12,78 +12,120 @@ import dev.mylesmor.sudosigns.data.SudoSign;
public class CommandConfig {
private FileConfiguration signConfig;
private ConfigManager configManager;
private final FileConfiguration signConfig;
private final ConfigManager configManager;
CommandConfig(ConfigManager configManager) {
this.configManager = configManager;
this.signConfig = configManager.getSignConfig();
}
CommandConfig(ConfigManager configManager) {
public void addCommandToConfig(SudoSign s, SignCommand cmd, PlayerInput type) {
if (signConfig.isConfigurationSection("signs." + s.getName())) {
HashMap<String, Double> map;
switch (type) {
case PLAYER_COMMAND:
List<Map<?, ?>> pCmds = signConfig.getMapList("signs." + s.getName() + ".player-commands");
map = new HashMap<>();
map.put(cmd.getCommand(), cmd.getDelay());
pCmds.add(map);
signConfig.set("signs." + s.getName() + ".player-commands", pCmds);
break;
case CONSOLE_COMMAND:
List<Map<?, ?>> cCmds = signConfig.getMapList("signs." + s.getName() + ".console-commands");
map = new HashMap<>();
map.put(cmd.getCommand(), cmd.getDelay());
cCmds.add(map);
signConfig.set("signs." + s.getName() + ".console-commands", cCmds);
break;
default:
break;
}
}
configManager.save();
}
this.configManager = configManager;
this.signConfig = configManager.getSignConfig();
}
public void addCommandToConfig(SudoSign s, SignCommand cmd, PlayerInput type) {
if (signConfig.isConfigurationSection("signs." + s.getName())) {
final HashMap<String, Double> map;
switch (type) {
case PLAYER_COMMAND -> {
final List<Map<?, ?>> pCmds = signConfig.getMapList("signs." + s.getName() + ".player-commands");
map = new HashMap<>();
map.put(cmd.getCommand(), cmd.getDelay());
pCmds.add(map);
signConfig.set("signs." + s.getName() + ".player-commands", pCmds);
}
case CONSOLE_COMMAND -> {
final List<Map<?, ?>> cCmds = signConfig.getMapList("signs." + s.getName() + ".console-commands");
map = new HashMap<>();
map.put(cmd.getCommand(), cmd.getDelay());
cCmds.add(map);
signConfig.set("signs." + s.getName() + ".console-commands", cCmds);
}
default -> {
}
}
}
configManager.save();
}
/**
* Deletes a command from a sign in the config.
*
* @param s The SudoSign object to edit.
* @param s The .
* @param s The SudoSign object to edit.
*/
public void deleteCommandFromConfig(SudoSign s, SignCommand cmd, PlayerInput type, double oldDelay) {
if (type.equals(PlayerInput.PLAYER_COMMAND)) {
final List<Map<?, ?>> mapList = signConfig.getMapList("signs." + s.getName() + ".player-commands");
Map<?, ?> found = null;
for (Map<?, ?> map : mapList) {
for (Map.Entry<?, ?> cmds : map.entrySet()) {
if (cmds.getKey().equals(cmd.getCommand()) && (Double) cmds.getValue() == oldDelay) {
found = map;
break;
}
}
}
if (found != null) {
mapList.remove(found);
}
signConfig.set("signs." + s.getName() + ".player-commands", mapList);
} else if (type.equals(PlayerInput.CONSOLE_COMMAND)) {
final List<Map<?, ?>> mapList = signConfig.getMapList("signs." + s.getName() + ".console-commands");
Map<?, ?> found = null;
for (Map<?, ?> map : mapList) {
for (Map.Entry<?, ?> cmds : map.entrySet()) {
if (cmds.getKey().equals(cmd.getCommand()) && (Double) cmds.getValue() == oldDelay) {
found = map;
break;
}
}
}
if (found != null) {
mapList.remove(found);
}
signConfig.set("signs." + s.getName() + ".console-commands", mapList);
}
configManager.save();
}
/**
* Deletes a command from a sign in the config.
* @param s The SudoSign object to edit.
* @param s The .
* @param s The SudoSign object to edit.
*/
public void deleteCommandFromConfig(SudoSign s, SignCommand cmd, PlayerInput type, double oldDelay) {
if (type.equals(PlayerInput.PLAYER_COMMAND)) {
List<Map<?, ?>> mapList = signConfig.getMapList("signs." + s.getName() + ".player-commands");
Map<?, ?> found = null;
for (Map<?, ?> map : mapList) {
for (Map.Entry<?, ?> cmds : map.entrySet()) {
if (cmds.getKey().equals(cmd.getCommand()) && (Double) cmds.getValue() == oldDelay) {
found = map;
break;
}
}
}
if (found != null) {
mapList.remove(found);
}
signConfig.set("signs." + s.getName() + ".player-commands", mapList);
} else if (type.equals(PlayerInput.CONSOLE_COMMAND)) {
List<Map<?, ?>> mapList = signConfig.getMapList("signs." + s.getName() + ".console-commands");
Map<?, ?> found = null;
for (Map<?, ?> map : mapList) {
for (Map.Entry<?, ?> cmds : map.entrySet()) {
if (cmds.getKey().equals(cmd.getCommand()) && (Double) cmds.getValue() == oldDelay) {
found = map;
break;
}
}
}
if (found != null) {
mapList.remove(found);
}
signConfig.set("signs." + s.getName() + ".console-commands", mapList);
}
configManager.save();
}
}
@@ -18,309 +18,306 @@ import dev.mylesmor.sudosigns.data.SignCommand;
import dev.mylesmor.sudosigns.data.SignMessage;
import dev.mylesmor.sudosigns.data.SudoSign;
import net.kyori.adventure.text.TextComponent;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
/**
* The class for managing the plugins config.
*
* @author MylesMor
* @author https://mylesmor.dev
*/
public class ConfigManager {
private FileConfiguration signConfig;
private File signConfigFile;
private InvalidEntriesManager invalidEntriesManager;
private SignConfig signConfigManager;
private MessageConfig messageConfig;
private CommandConfig commandConfig;
private PermissionConfig permissionConfig;
private FileConfiguration signConfig;
private File signConfigFile;
private InvalidEntriesManager invalidEntriesManager;
private SignConfig signConfigManager;
private MessageConfig messageConfig;
private CommandConfig commandConfig;
private PermissionConfig permissionConfig;
private final DiamondBankAPIJava diamondBankAPI;
public ConfigManager(DiamondBankAPIJava diamondBankAPI) {
public ConfigManager() {
this.diamondBankAPI = diamondBankAPI;
loadCustomConfig();
loadModules();
loadCustomConfig();
}
}
public void loadModules() {
public void loadModules() {
invalidEntriesManager = new InvalidEntriesManager(this, signConfig);
signConfigManager = new SignConfig(this);
signConfigManager.loadSigns();
messageConfig = new MessageConfig(this);
commandConfig = new CommandConfig(this);
permissionConfig = new PermissionConfig(this);
invalidEntriesManager = new InvalidEntriesManager(this, signConfig);
signConfigManager = new SignConfig(this, diamondBankAPI);
signConfigManager.loadSigns();
messageConfig = new MessageConfig(this);
commandConfig = new CommandConfig(this);
permissionConfig = new PermissionConfig(this);
}
}
public InvalidEntriesManager getInvalidEntriesManager() {
public InvalidEntriesManager getInvalidEntriesManager() {
return invalidEntriesManager;
return invalidEntriesManager;
}
}
public FileConfiguration getSignConfig() {
public FileConfiguration getSignConfig() {
return signConfig;
return signConfig;
}
}
public ArrayList<String> loadSigns() {
public ArrayList<String> loadSigns() {
return signConfigManager.loadSigns();
return signConfigManager.loadSigns();
}
}
public void saveSign(SudoSign s, boolean singular, Player p) {
public void saveSign(SudoSign s, boolean singular, Player p) {
signConfigManager.saveToFile(s, singular, p);
signConfigManager.saveToFile(s, singular, p);
}
}
public void deleteSign(String name) {
public void deleteSign(String name) {
signConfigManager.deleteSign(name);
signConfigManager.deleteSign(name);
}
}
public void editSignText(String name, int lineNumber, TextComponent message) {
public void editSignText(String name, int lineNumber, TextComponent message) {
signConfigManager.editText(name, lineNumber, message);
signConfigManager.editText(name, lineNumber, message);
}
}
public void addMessage(SudoSign s, SignMessage sm) {
public void addMessage(SudoSign s, SignMessage sm) {
messageConfig.addMessageToConfig(s, sm);
messageConfig.addMessageToConfig(s, sm);
}
}
public void deleteMessage(SudoSign s, SignMessage sm, double delay) {
public void deleteMessage(SudoSign s, SignMessage sm, double delay) {
messageConfig.deleteMessageFromConfig(s, sm, delay);
messageConfig.deleteMessageFromConfig(s, sm, delay);
}
}
public void addCommand(SudoSign s, SignCommand sm, PlayerInput type) {
public void addCommand(SudoSign s, SignCommand sm, PlayerInput type) {
commandConfig.addCommandToConfig(s, sm, type);
commandConfig.addCommandToConfig(s, sm, type);
}
}
public void deleteCommand(SudoSign s, SignCommand sm, PlayerInput type, double oldDelay) {
public void deleteCommand(SudoSign s, SignCommand sm, PlayerInput type, double oldDelay) {
commandConfig.deleteCommandFromConfig(s, sm, type, oldDelay);
commandConfig.deleteCommandFromConfig(s, sm, type, oldDelay);
}
}
public void setPrice(String name, double price) {
public void setPrice(String name, double price) {
signConfigManager.setPrice(name, price);
signConfigManager.setPrice(name, price);
}
}
public void addPermission(SudoSign s, String permission) {
public void addPermission(SudoSign s, String permission) {
permissionConfig.addPermissionToConfig(s, permission);
permissionConfig.addPermissionToConfig(s, permission);
}
}
public void deletePermission(SudoSign s, String permission) {
public void deletePermission(SudoSign s, String permission) {
permissionConfig.deletePermissionFromConfig(s, permission);
permissionConfig.deletePermissionFromConfig(s, permission);
}
}
public boolean loadCustomConfig() {
public boolean loadCustomConfig() {
if (! SudoSigns.sudoSignsPlugin.getDataFolder().exists()) {
try {
SudoSigns.sudoSignsPlugin.getDataFolder().mkdir();
final File dataFolder = SudoSigns.sudoSignsPlugin.getDataFolder();
if (!dataFolder.exists() && !dataFolder.mkdirs()) {
}
Bukkit.getLogger().warning("ERROR: Failed to create plugin data folder!");
signConfigFile = new File(SudoSigns.sudoSignsPlugin.getDataFolder(), "signs.yml");
if (! signConfigFile.exists()) {
return false;
try {
}
signConfigFile.createNewFile();
signConfigFile = new File(dataFolder, "signs.yml");
}
catch (IOException e) {
// Copy default from jar if missing
if (!signConfigFile.exists()) {
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "ERROR: Failed to create config!");
e.printStackTrace();
SudoSigns.sudoSignsPlugin.saveResource("signs.yml", false);
}
}
}
signConfig = YamlConfiguration.loadConfiguration(signConfigFile);
try {
if (signConfigManager != null) {
signConfig = YamlConfiguration.loadConfiguration(signConfigFile);
signConfigManager.setSignConfig(signConfig);
if (signConfigManager != null) {
}
signConfigManager.setSignConfig(signConfig);
if (!signConfig.isConfigurationSection("signs")) {
}
signConfig.createSection("signs");
if (! signConfig.isConfigurationSection("signs")) {
save();
signConfig.createSection("signs");
}
save();
if (invalidEntriesManager != null) {
}
invalidEntriesManager.setConfig(signConfig);
if (invalidEntriesManager != null) {
}
invalidEntriesManager.setConfig(signConfig);
if (!signConfig.contains("version")) {
}
signConfig.set("version", "1.2.3");
if (! signConfig.contains("version")) {
save();
fixConfig();
signConfig.createSection("version");
signConfig.set("version", "1.2.3");
}
save();
fixConfig();
return true;
}
} catch (Exception error) {
}
catch (Exception e) {
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix")
+ "ERROR: Failed to initialise signs.yml!");
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "ERROR: Failed to initialise signs.yml!");
e.printStackTrace();
error.printStackTrace();
return false;
return false;
}
}
return true;
}
}
public void fixConfig() {
public void fixConfig() {
final Set<String> signSection = signConfig.getConfigurationSection("signs").getKeys(false);
String name = null;
for (String key : signSection) {
Set<String> signSection = signConfig.getConfigurationSection("signs").getKeys(false);
String name = null;
for (String key : signSection) {
signConfig.set("signs." + key + ".op-commands", null);
signConfig.set("signs." + key + ".price", 0.0);
signConfig.set("signs." + key + ".op-commands", null);
signConfig.set("signs." + key + ".price", 0.0);
name = key;
name = key;
final List<String> pCommands = signConfig.getStringList("signs." + key + ".player-commands");
final List<String> cCommands = signConfig.getStringList("signs." + key + ".console-commands");
final List<String> messages = signConfig.getStringList("signs." + key + ".messages");
List<String> pCommands = signConfig.getStringList("signs." + key + ".player-commands");
List<String> cCommands = signConfig.getStringList("signs." + key + ".console-commands");
List<String> messages = signConfig.getStringList("signs." + key + ".messages");
if (pCommands.size() == 0 && cCommands.size() == 0 && messages.size() == 0) {
if (pCommands.size() == 0 && cCommands.size() == 0 && messages.size() == 0) {
save();
continue;
save();
continue;
}
}
if (pCommands.size() != 0) {
if (pCommands.size() != 0) {
try {
try {
ArrayList<HashMap<String, Double>> mapList = new ArrayList<>();
HashMap<String, Double> map = new HashMap<>();
for (String cmd : pCommands) {
final ArrayList<HashMap<String, Double>> mapList = new ArrayList<>();
HashMap<String, Double> map = new HashMap<>();
for (String cmd : pCommands) {
map.put(cmd, 0.0);
mapList.add(map);
map = new HashMap<>();
map.put(cmd, 0.0);
mapList.add(map);
map = new HashMap<>();
}
}
signConfig.set("signs." + name + ".player-commands", mapList);
signConfig.set("signs." + name + ".player-commands", mapList);
}
catch (Exception ignored) {
} catch (Exception ignored) {
ignored.printStackTrace();
ignored.printStackTrace();
}
}
}
}
signConfig.set("signs." + key + ".op-commands", null);
signConfig.set("signs." + key + ".op-commands", null);
if (cCommands.size() != 0) {
try {
if (cCommands.size() != 0) {
ArrayList<HashMap<String, Double>> mapList = new ArrayList<>();
HashMap<String, Double> map = new HashMap<>();
for (String cmd : cCommands) {
try {
map.put(cmd, 0.0);
mapList.add(map);
map = new HashMap<>();
final ArrayList<HashMap<String, Double>> mapList = new ArrayList<>();
HashMap<String, Double> map = new HashMap<>();
for (String cmd : cCommands) {
}
map.put(cmd, 0.0);
mapList.add(map);
map = new HashMap<>();
signConfig.set("signs." + name + ".console-commands", mapList);
}
}
catch (Exception ignored) {
signConfig.set("signs." + name + ".console-commands", mapList);
ignored.printStackTrace();
} catch (Exception ignored) {
}
ignored.printStackTrace();
}
}
if (messages.size() != 0) {
}
try {
if (messages.size() != 0) {
ArrayList<HashMap<String, Double>> mapList = new ArrayList<>();
HashMap<String, Double> map = new HashMap<>();
for (String cmd : messages) {
try {
map.put(cmd, 0.0);
mapList.add(map);
map = new HashMap<>();
final ArrayList<HashMap<String, Double>> mapList = new ArrayList<>();
HashMap<String, Double> map = new HashMap<>();
for (String cmd : messages) {
}
map.put(cmd, 0.0);
mapList.add(map);
map = new HashMap<>();
signConfig.set("signs." + name + ".messages", mapList);
}
}
catch (Exception ignored) {
signConfig.set("signs." + name + ".messages", mapList);
ignored.printStackTrace();
} catch (Exception ignored) {
}
ignored.printStackTrace();
}
}
save();
}
}
save();
}
}
public void save() {
}
try {
public void save() {
signConfig.save(signConfigFile);
try {
}
catch (IOException e) {
signConfig.save(signConfigFile);
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "ERROR: Failed to save to signs.yml!");
e.printStackTrace();
} catch (IOException e) {
}
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix")
+ "ERROR: Failed to save to signs.yml!");
e.printStackTrace();
}
}
}
}
}
@@ -3,6 +3,7 @@ package dev.mylesmor.sudosigns.config;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -14,151 +15,215 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.utilitiesog.UtilitiesOG;
public class InvalidEntriesManager {
/**
* The class for managing invalid sign entries in the config.
* @author MylesMor
* @author https://mylesmor.dev
*/
ArrayList<String> invalidEntries = new ArrayList<>();
ConfigManager configManager;
FileConfiguration config;
/**
* The class for managing invalid sign entries in the config.
*
* @author MylesMor
* @author https://mylesmor.dev
*/
ArrayList<String> invalidEntries = new ArrayList<>();
InvalidEntriesManager(ConfigManager configManager, FileConfiguration config) {
this.configManager = configManager;
this.config = config;
}
ConfigManager configManager;
FileConfiguration config;
public void setConfig(FileConfiguration config) {
this.config = config;
}
InvalidEntriesManager(ConfigManager configManager, FileConfiguration config) {
/**
* Attempts to a fix an invalid entry by placing a sign in the correct position.
* @param s The sign's name.
* @return True if sign successfully fixed, otherwise False.
*/
private boolean fixEntry(String s) {
try {
ConfigurationSection locSec = config.getConfigurationSection("signs." + s + ".location");
String world = locSec.getString("world");
double x = locSec.getDouble("x");
double y = locSec.getDouble("y");
double z = locSec.getDouble("z");
String matString = config.getString("signs." + s + ".blocktype");
if (SudoSigns.version.contains("1.13")) {
matString = "SIGN";
}
Material material = Material.valueOf(matString);
BlockFace blockFace = BlockFace.valueOf(locSec.getString("rotation"));
World w = Bukkit.getServer().getWorld(world);
if (w != null) {
Location loc = new Location(Bukkit.getServer().getWorld(world), x, y, z);
w.getBlockAt(loc).setType(material);
Block b = w.getBlockAt(loc);
if (b.getBlockData() instanceof org.bukkit.block.data.type.Sign) {
org.bukkit.block.data.type.Sign facing = (org.bukkit.block.data.type.Sign) b.getBlockData();
facing.setRotation(blockFace);
b.setBlockData(facing);
} else if (b.getBlockData() instanceof org.bukkit.block.data.type.WallSign){
org.bukkit.block.data.type.WallSign facing = (org.bukkit.block.data.type.WallSign) b.getBlockData();
facing.setFacing(blockFace);
b.setBlockData(facing);
}
Sign newSign = (Sign) b.getState();
List<String> lines = getSignText(s);
int i = 0;
for (String line : lines) {
newSign.line(i, Util.legacySerializerAnyCase(line));
i++;
}
newSign.update();
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
this.configManager = configManager;
this.config = config;
public ArrayList<String> getInvalidEntries() {
return invalidEntries;
}
}
public void setInvalidEntries(ArrayList<String> invalid) {
invalidEntries = invalid;
}
public void setConfig(FileConfiguration config) {
public void addInvalidEntry(String entry) {
invalidEntries.add(entry);
}
this.config = config;
/**
* Retrieves the invalid sign's text from the config.
* @param name Name of the sign.
* @return The sign's message or null if not found.
*/
public List<String> getSignText(String name) {
List<String> signSec = config.getStringList("signs." + name + ".text");
for (String item : signSec) {
item = Util.legacySerializerAnyCase(item).content();
}
if (signSec.size() != 0) {
return signSec;
}
return null;
}
}
/**
* Removes a sign's entry in the config.
* @param name Name of the sign.
* @param all True if all invalid entries should be purged, or False for just one.
* @return The sign's message or null if not found.
*/
public boolean purgeInvalidEntry(String name, boolean all) {
if (all) {
for (String s : invalidEntries) {
Bukkit.getLogger().warning(Boolean.toString(config.isConfigurationSection("signs." + s)));
config.set("signs." + s, null);
}
configManager.loadSigns();
configManager.save();
return true;
} else {
for (String s : invalidEntries) {
if (name.equalsIgnoreCase(s)) {
Bukkit.getLogger().warning(Boolean.toString(config.isConfigurationSection("signs." + s)));
config.set("signs." + name, null);
configManager.loadSigns();
configManager.save();
return true;
}
}
}
return false;
}
/**
* Attempts to a fix an invalid entry by placing a sign in the correct position.
*
* @param s The sign's name.
* @return True if sign successfully fixed, otherwise False.
*/
private boolean fixEntry(String s) {
public boolean fixInvalidEntry(String name, boolean all) {
if (all) {
for (String s : invalidEntries) {
fixEntry(s);
}
configManager.save();
return true;
} else {
for (String s : invalidEntries) {
if (name.equals(s)) {
if (fixEntry(s)) {
configManager.save();
return true;
}
}
}
}
return false;
}
try {
final ConfigurationSection locSec = config.getConfigurationSection("signs." + s + ".location");
final String world = locSec.getString("world");
final double x = locSec.getDouble("x");
final double y = locSec.getDouble("y");
final double z = locSec.getDouble("z");
String matString = config.getString("signs." + s + ".blocktype");
if (StringUtils.contains(SudoSigns.version, "1.13")) {
matString = "SIGN";
}
final Material material = Material.valueOf(matString);
final BlockFace blockFace = BlockFace.valueOf(locSec.getString("rotation"));
final World w = Bukkit.getServer().getWorld(world);
if (w != null) {
final Location loc = new Location(Bukkit.getServer().getWorld(world), x, y, z);
w.getBlockAt(loc).setType(material);
final Block b = w.getBlockAt(loc);
if (b.getBlockData() instanceof org.bukkit.block.data.type.Sign) {
final org.bukkit.block.data.type.Sign facing = (org.bukkit.block.data.type.Sign) b.getBlockData();
facing.setRotation(blockFace);
b.setBlockData(facing);
} else if (b.getBlockData() instanceof org.bukkit.block.data.type.WallSign) {
final org.bukkit.block.data.type.WallSign facing = (org.bukkit.block.data.type.WallSign) b
.getBlockData();
facing.setFacing(blockFace);
b.setBlockData(facing);
}
final Sign newSign = (Sign) b.getState();
final List<String> lines = getSignText(s);
int i = 0;
for (String line : lines) {
newSign.line(i, UtilitiesOG.trueogColorize(line));
i++;
}
newSign.update();
}
} catch (Exception error) {
error.printStackTrace();
return false;
}
return true;
}
public ArrayList<String> getInvalidEntries() {
return invalidEntries;
}
public void setInvalidEntries(ArrayList<String> invalid) {
invalidEntries = invalid;
}
public void addInvalidEntry(String entry) {
invalidEntries.add(entry);
}
/**
* Retrieves the invalid sign's text from the config.
*
* @param name Name of the sign.
* @return The sign's message or null if not found.
*/
public List<String> getSignText(String name) {
final List<String> signSec = config.getStringList("signs." + name + ".text");
signSec.forEach(item -> item = UtilitiesOG.trueogColorize(item).content());
if (signSec.size() != 0) {
return signSec;
}
return null;
}
/**
* Removes a sign's entry in the config.
*
* @param name Name of the sign.
* @param all True if all invalid entries should be purged, or False for just
* one.
* @return The sign's message or null if not found.
*/
public boolean purgeInvalidEntry(String name, boolean all) {
if (all) {
invalidEntries.forEach(s -> {
Bukkit.getLogger().warning(Boolean.toString(config.isConfigurationSection("signs." + s)));
config.set("signs." + s, null);
});
configManager.loadSigns();
configManager.save();
return true;
} else {
for (String s : invalidEntries) {
if (StringUtils.equalsIgnoreCase(name, s)) {
Bukkit.getLogger().warning(Boolean.toString(config.isConfigurationSection("signs." + s)));
config.set("signs." + name, null);
configManager.loadSigns();
configManager.save();
return true;
}
}
}
return false;
}
public boolean fixInvalidEntry(String name, boolean all) {
if (all) {
invalidEntries.forEach(this::fixEntry);
configManager.save();
return true;
} else {
for (String s : invalidEntries) {
if (name.equals(s) && fixEntry(s)) {
configManager.save();
return true;
}
}
}
return false;
}
}
@@ -11,40 +11,57 @@ import dev.mylesmor.sudosigns.data.SudoSign;
public class MessageConfig {
private FileConfiguration signConfig;
private ConfigManager configManager;
private final FileConfiguration signConfig;
private final ConfigManager configManager;
MessageConfig(ConfigManager configManager) {
this.configManager = configManager;
this.signConfig = configManager.getSignConfig();
}
MessageConfig(ConfigManager configManager) {
public void addMessageToConfig(SudoSign s, SignMessage sm) {
HashMap<String, Double> map;
List<Map<?, ?>> messages = signConfig.getMapList("signs." + s.getName() + ".messages");
map = new HashMap<>();
map.put(sm.getMessage(), sm.getDelay());
messages.add(map);
signConfig.set("signs." + s.getName() + ".messages", messages);
configManager.save();
}
this.configManager = configManager;
this.signConfig = configManager.getSignConfig();
}
public void addMessageToConfig(SudoSign s, SignMessage sm) {
final HashMap<String, Double> map;
final List<Map<?, ?>> messages = signConfig.getMapList("signs." + s.getName() + ".messages");
map = new HashMap<>();
map.put(sm.getMessage(), sm.getDelay());
messages.add(map);
signConfig.set("signs." + s.getName() + ".messages", messages);
configManager.save();
}
public void deleteMessageFromConfig(SudoSign s, SignMessage sm, double oldDelay) {
final List<Map<?, ?>> mapList = signConfig.getMapList("signs." + s.getName() + ".messages");
Map<?, ?> found = null;
for (Map<?, ?> map : mapList) {
for (Map.Entry<?, ?> messages : map.entrySet()) {
final String key = (String) messages.getKey();
if (key.equals(sm.getMessage()) && (Double) messages.getValue() == oldDelay) {
found = map;
break;
}
}
}
if (found != null) {
mapList.remove(found);
}
signConfig.set("signs." + s.getName() + ".messages", mapList);
configManager.save();
}
public void deleteMessageFromConfig(SudoSign s, SignMessage sm, double oldDelay) {
List<Map<?, ?>> mapList = signConfig.getMapList("signs." + s.getName() + ".messages");
Map<?, ?> found = null;
for (Map<?, ?> map : mapList) {
for (Map.Entry<?, ?> messages : map.entrySet()) {
String key = (String) messages.getKey();
if (key.equals(sm.getMessage()) && (Double) messages.getValue() == oldDelay) {
found = map;
break;
}
}
}
if (found != null) {
mapList.remove(found);
}
signConfig.set("signs." + s.getName() + ".messages", mapList);
configManager.save();
}
}
@@ -8,27 +8,34 @@ import dev.mylesmor.sudosigns.data.SudoSign;
public class PermissionConfig {
private FileConfiguration signConfig;
private ConfigManager configManager;
private final FileConfiguration signConfig;
private final ConfigManager configManager;
PermissionConfig(ConfigManager configManager) {
this.configManager = configManager;
this.signConfig = configManager.getSignConfig();
}
PermissionConfig(ConfigManager configManager) {
public void addPermissionToConfig(SudoSign s, String perm) {
String path = "signs." + s.getName() + ".permissions";
List<String> perms = signConfig.getStringList(path);
perms.add(perm);
signConfig.set(path, perms);
configManager.save();
}
this.configManager = configManager;
this.signConfig = configManager.getSignConfig();
}
public void addPermissionToConfig(SudoSign s, String perm) {
final String path = "signs." + s.getName() + ".permissions";
final List<String> perms = signConfig.getStringList(path);
perms.add(perm);
signConfig.set(path, perms);
configManager.save();
}
public void deletePermissionFromConfig(SudoSign s, String perm) {
final String path = "signs." + s.getName() + ".permissions";
final List<String> perms = signConfig.getStringList(path);
perms.remove(perm);
signConfig.set(path, perms);
configManager.save();
}
public void deletePermissionFromConfig(SudoSign s, String perm) {
String path = "signs." + s.getName() + ".permissions";
List<String> perms = signConfig.getStringList(path);
perms.remove(perm);
signConfig.set(path, perms);
configManager.save();
}
}
@@ -2,6 +2,7 @@ package dev.mylesmor.sudosigns.config;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -11,6 +12,7 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Rotatable;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.configuration.ConfigurationSection;
@@ -24,313 +26,333 @@ import dev.mylesmor.sudosigns.data.SignMessage;
import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.util.Util;
import net.kyori.adventure.text.TextComponent;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
import net.trueog.utilitiesog.UtilitiesOG;
public class SignConfig {
private FileConfiguration signConfig;
private ConfigManager configManager;
private FileConfiguration signConfig;
private final ConfigManager configManager;
private final DiamondBankAPIJava diamondBankAPI;
SignConfig(ConfigManager configManager) {
SignConfig(ConfigManager configManager, DiamondBankAPIJava diamondBankAPI) {
this.configManager = configManager;
this.signConfig = configManager.getSignConfig();
this.configManager = configManager;
this.signConfig = configManager.getSignConfig();
this.diamondBankAPI = diamondBankAPI;
}
}
public void setSignConfig(FileConfiguration signConfig) {
public void setSignConfig(FileConfiguration signConfig) {
this.signConfig = signConfig;
this.signConfig = signConfig;
}
}
// Loads the signs from the config.
public ArrayList<String> loadSigns() {
// Loads the signs from the config.
public ArrayList<String> loadSigns() {
Map<String, SudoSign> tempSigns = new HashMap<>();
Set<String> signSection = signConfig.getConfigurationSection("signs").getKeys(false);
final Map<String, SudoSign> tempSigns = new HashMap<>();
final Set<String> loadedLocations = new HashSet<>();
final Set<String> signSection = signConfig.getConfigurationSection("signs").getKeys(false);
String name;
ArrayList<String> invalidSigns = new ArrayList<>();
String name;
final ArrayList<String> invalidSigns = new ArrayList<>();
for (String key : signSection) {
for (String key : signSection) {
name = key;
name = key;
try {
try {
ConfigurationSection locSec = signConfig.getConfigurationSection("signs." + key + ".location");
final ConfigurationSection locSec = signConfig.getConfigurationSection("signs." + key + ".location");
String world = locSec.getString("world");
double x = locSec.getDouble("x");
double y = locSec.getDouble("y");
double z = locSec.getDouble("z");
World w = Bukkit.getServer().getWorld(world);
final String world = locSec.getString("world");
final double x = locSec.getDouble("x");
final double y = locSec.getDouble("y");
final double z = locSec.getDouble("z");
final World w = Bukkit.getServer().getWorld(world);
if (w != null) {
if (w != null) {
Location loc = new Location(Bukkit.getServer().getWorld(world), x, y, z);
if (loc.getBlock().getState() instanceof Sign || loc.getBlock().getState() instanceof WallSign) {
final Location loc = new Location(Bukkit.getServer().getWorld(world), x, y, z);
final String locationKey = world + ":" + loc.getBlockX() + ":" + loc.getBlockY() + ":"
+ loc.getBlockZ();
if (!loadedLocations.add(locationKey)) {
Sign sign = (Sign) loc.getBlock().getState();
invalidSigns.add(key);
Bukkit.getLogger()
.warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix")
+ "ERROR: Failed to load Sign " + key + " at " + world + " " + loc.getBlockX()
+ ", " + loc.getBlockY() + ", " + loc.getBlockZ()
+ "! Cause: another SudoSign already uses that block location. Skipping...");
continue;
SudoSign ss = new SudoSign(key);
ss.setSign(sign);
}
List<Map<?, ?>> pCommands = signConfig.getMapList("signs." + key + ".player-commands");
List<Map<?, ?>> cCommands = signConfig.getMapList("signs." + key + ".console-commands");
List<String> permissions = signConfig.getStringList("signs." + key + ".permissions");
List<Map<?, ?>> messages = signConfig.getMapList("signs." + key + ".messages");
final Sign sign = Util.getSign(loc.getBlock());
if (sign != null) {
if(Util.priceIsInteger()) {
final SudoSign ss = new SudoSign(key, diamondBankAPI);
ss.setSign(sign);
try {
final List<Map<?, ?>> pCommands = signConfig.getMapList("signs." + key + ".player-commands");
final List<Map<?, ?>> cCommands = signConfig.getMapList("signs." + key + ".console-commands");
final List<String> permissions = signConfig.getStringList("signs." + key + ".permissions");
final List<Map<?, ?>> messages = signConfig.getMapList("signs." + key + ".messages");
ss.setPriceAsInteger((Integer) signConfig.get("signs." + key + ".price"));
if (Util.priceIsInteger()) {
}
catch (Exception e) {
try {
Bukkit.getLogger().info(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "ERROR: Invalid price for sign " + name + "! Defaulting to 0...");
ss.setPriceAsInteger((Integer) signConfig.get("signs." + key + ".price"));
ss.setPriceAsInteger(0);
} catch (Exception error) {
}
UtilitiesOG.logToConsole(
SudoSigns.getPlugin().getConfig().getString("config.console-prefix"),
"ERROR: Invalid price for sign " + name + "! Defaulting to 0...");
}
else {
ss.setPriceAsInteger(0);
try {
}
ss.setPriceAsDouble((Double) signConfig.get("signs." + key + ".price"));
} else {
}
catch (Exception e) {
try {
Bukkit.getLogger().info(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "ERROR: Invalid price for sign " + name + "! Defaulting to 0...");
ss.setPriceAsDouble((Double) signConfig.get("signs." + key + ".price"));
ss.setPriceAsDouble(0.0);
} catch (Exception error) {
}
Bukkit.getLogger()
.info(SudoSigns.getPlugin().getConfig().getString("config.console-prefix")
+ "ERROR: Invalid price for sign " + name + "! Defaulting to 0...");
}
ss.setPriceAsDouble(0.0);
int number = 0;
for (Map<?, ?> sc : pCommands) {
}
for (Map.Entry<?, ?> cmd : sc.entrySet()) {
}
ss.addPlayerCommand(new SignCommand(number++, (String) cmd.getKey(), (Double) cmd.getValue(), PlayerInput.PLAYER_COMMAND));
int number = 0;
for (Map<?, ?> sc : pCommands) {
}
for (Map.Entry<?, ?> cmd : sc.entrySet()) {
}
ss.addPlayerCommand(new SignCommand(number++, (String) cmd.getKey(),
(Double) cmd.getValue(), PlayerInput.PLAYER_COMMAND));
for (Map<?, ?> sc : cCommands) {
}
for (Map.Entry<?, ?> cmd : sc.entrySet()) {
}
ss.addConsoleCommand(new SignCommand(number++, (String) cmd.getKey(), (Double) cmd.getValue(), PlayerInput.CONSOLE_COMMAND));
for (Map<?, ?> sc : cCommands) {
}
for (Map.Entry<?, ?> cmd : sc.entrySet()) {
}
ss.addConsoleCommand(new SignCommand(number++, (String) cmd.getKey(),
(Double) cmd.getValue(), PlayerInput.CONSOLE_COMMAND));
for (String perm : permissions) {
}
ss.addPermission(perm);
}
}
permissions.forEach(ss::addPermission);
number = 0;
for (Map<?, ?> sc : messages) {
number = 0;
for (Map<?, ?> sc : messages) {
for (Map.Entry<?, ?> message : sc.entrySet()) {
for (Map.Entry<?, ?> message : sc.entrySet()) {
ss.addMessage(new SignMessage(number++, (String) message.getKey(), (Double) message.getValue(), PlayerInput.MESSAGE));
ss.addMessage(new SignMessage(number++, (String) message.getKey(),
(Double) message.getValue(), PlayerInput.MESSAGE));
}
}
}
}
tempSigns.put(name, ss);
tempSigns.put(name, ss);
}
else {
} else {
invalidSigns.add(key);
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "ERROR: Failed to load Sign " + key + "! The block at the provided location is not a sign. Skipping...");
invalidSigns.add(key);
final String actualBlockType = loc.getBlock().getType().toString();
Bukkit.getLogger()
.warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix")
+ "ERROR: Failed to load Sign " + key + " at " + world + " " + loc.getBlockX()
+ ", " + loc.getBlockY() + ", " + loc.getBlockZ()
+ "! Cause: the block at the provided location is " + actualBlockType
+ ", not a sign. Skipping...");
}
}
}
else {
} else {
invalidSigns.add(key);
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix") + "ERROR: Failed to load Sign " + key + "! The world name for this sign is invalid. Skipping...");
invalidSigns.add(key);
Bukkit.getLogger().warning(SudoSigns.getPlugin().getConfig().getString("config.console-prefix")
+ "ERROR: Failed to load Sign " + key + " at " + world + " " + x + ", " + y + ", " + z
+ "! Cause: the world '" + world + "' does not exist or is not loaded. Skipping...");
}
}
}
catch (Exception e) {
} catch (Exception error) {
e.printStackTrace();
return null;
error.printStackTrace();
}
return null;
}
configManager.getInvalidEntriesManager().setInvalidEntries(invalidSigns);
}
SudoSigns.signs = tempSigns;
SudoSigns.invalidSigns = invalidSigns;
}
return invalidSigns;
configManager.getInvalidEntriesManager().setInvalidEntries(invalidSigns);
}
SudoSigns.signs = tempSigns;
SudoSigns.invalidSigns = invalidSigns;
/**
* Deletes a sign from the config.
* @param name The name of the sign.
*/
public void deleteSign(String name) {
return invalidSigns;
if (signConfig.isSet("signs." + name)) {
}
signConfig.set("signs." + name, null);
/**
* Deletes a sign from the config.
*
* @param name The name of the sign.
*/
public void deleteSign(String name) {
}
if (signConfig.isSet("signs." + name)) {
configManager.save();
signConfig.set("signs." + name, null);
}
}
/**
* Saves the SudoSigns to config.
* @param s The SudoSign object.
* @param singular True to save a singular sign, False to save all.
* @param p The player who has edited the sign.
*/
public void saveToFile(SudoSign s, boolean singular, Player p) {
configManager.save();
if (singular) {
}
saveSign(s, p);
/**
* Saves the SudoSigns to config.
*
* @param s The SudoSign object.
* @param singular True to save a singular sign, False to save all.
* @param p The player who has edited the sign.
*/
public void saveToFile(SudoSign s, boolean singular, Player p) {
}
else {
if (singular) {
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
saveSign(s, p);
saveSign(entry.getValue(), p);
} else {
}
SudoSigns.signs.entrySet().forEach(entry -> saveSign(entry.getValue(), p));
}
}
configManager.save();
configManager.save();
}
}
/**
* Saves a SudoSign in the config.
* @param s The SudoSign object.
* @param p The player who has edited the sign.
*/
public void saveSign(SudoSign s, Player p) {
/**
* Saves a SudoSign in the config.
*
* @param s The SudoSign object.
* @param p The player who has edited the sign.
*/
public void saveSign(SudoSign s, Player p) {
String name = s.getName();
try {
final String name = s.getName();
try {
if (! signConfig.isConfigurationSection("signs." + name + "")) {
if (!signConfig.isConfigurationSection("signs." + name + "")) {
signConfig.createSection("signs." + name + "");
signConfig.createSection("signs." + name + ".text");
signConfig.createSection("signs." + name + "");
signConfig.createSection("signs." + name + ".text");
ArrayList<String> lines = new ArrayList<>();
final ArrayList<String> lines = new ArrayList<>(s.getText());
lines.addAll(s.getText());
signConfig.set("signs." + name + ".text", lines);
signConfig.set("signs." + name + ".price", 0.0);
signConfig.set("signs." + name + ".text", lines);
signConfig.set("signs." + name + ".price", 0.0);
final ConfigurationSection locSec = signConfig.createSection("signs." + name + ".location");
ConfigurationSection locSec = signConfig.createSection("signs." + name + ".location");
final String world = s.getSign().getWorld().getName();
final double x = s.getSign().getLocation().getX();
final double y = s.getSign().getLocation().getY();
final double z = s.getSign().getLocation().getZ();
String world = s.getSign().getWorld().getName();
double x = s.getSign().getLocation().getX();
double y = s.getSign().getLocation().getY();
double z = s.getSign().getLocation().getZ();
signConfig.set("signs." + name + ".blocktype", s.getSign().getType().toString());
signConfig.set("signs." + name + ".blocktype", s.getSign().getType().toString());
locSec.set("world", world);
locSec.set("x", x);
locSec.set("y", y);
locSec.set("z", z);
locSec.set("world", world);
locSec.set("x", x);
locSec.set("y", y);
locSec.set("z", z);
final BlockData blockData = s.getSign().getWorld().getBlockAt(s.getSign().getLocation()).getBlockData();
if (blockData instanceof Rotatable) {
if (s.getSign().getWorld().getBlockAt(s.getSign().getLocation()).getBlockData() instanceof Sign) {
final Rotatable data = (Rotatable) blockData;
final BlockFace rotation = data.getRotation();
Sign facing = (Sign) s.getSign().getWorld().getBlockAt(s.getSign().getLocation()).getBlockData();
locSec.set("rotation", rotation);
Rotatable data = (Rotatable) facing.getBlockData();
BlockFace rotation = data.getRotation();
} else if (blockData instanceof WallSign) {
locSec.set("rotation", rotation);
final WallSign facing = (WallSign) blockData;
}
else if (s.getSign().getWorld().getBlockAt(s.getSign().getLocation()).getBlockData() instanceof WallSign) {
locSec.set("rotation", facing.getFacing().toString());
WallSign facing = (WallSign) s.getSign().getWorld().getBlockAt(s.getSign().getLocation()).getBlockData();
}
locSec.set("rotation", facing.getFacing().toString());
signConfig.createSection("signs." + name + ".permissions");
signConfig.createSection("signs." + name + ".messages");
signConfig.createSection("signs." + name + ".player-commands");
signConfig.createSection("signs." + name + ".console-commands");
}
configManager.save();
signConfig.createSection("signs." + name + ".permissions");
signConfig.createSection("signs." + name + ".messages");
signConfig.createSection("signs." + name + ".player-commands");
signConfig.createSection("signs." + name + ".console-commands");
}
configManager.save();
} catch (Exception error) {
}
if (p != null) {
}
catch (Exception e) {
UtilitiesOG.trueogMessage(p, "&cERROR: Failed to save sign &e" + name + " &cto the config!");
error.printStackTrace();
if (p != null) {
}
Util.sudoSignsMessage(p, "&cERROR: Failed to save sign %NAME% to the config!", name);
}
}
}
}
public void editText(String name, int lineNumber, TextComponent newText) {
}
if (signConfig.isConfigurationSection("signs." + name + "")) {
public void editText(String name, int lineNumber, TextComponent newText) {
final List<String> text = signConfig.getStringList("signs." + name + ".text");
if (signConfig.isConfigurationSection("signs." + name + "")) {
text.set(lineNumber - 1, newText.content());
List<String> text = signConfig.getStringList("signs." + name + ".text");
text.set(lineNumber - 1, newText.content());
signConfig.set("signs." + name + ".text", text);
signConfig.set("signs." + name + ".text", text);
}
}
configManager.save();
configManager.save();
}
}
public void setPrice(String name, double price) {
public void setPrice(String name, double price) {
if (signConfig.isConfigurationSection("signs." + name + "")) {
if (signConfig.isConfigurationSection("signs." + name + "")) {
signConfig.set("signs." + name + ".price", price);
signConfig.set("signs." + name + ".price", price);
}
}
configManager.save();
configManager.save();
}
}
}
}
@@ -2,18 +2,11 @@ package dev.mylesmor.sudosigns.data;
/**
* Enum used for determing the type of player chat input.
*
* @author MylesMor
* @author https://mylesmor.dev
*/
public enum PlayerInput {
PLAYER_COMMAND,
CONSOLE_COMMAND,
RENAME,
PERMISSION,
MESSAGE,
COMMAND_DELAY,
MESSAGE_DELAY,
EDIT_TEXT_NUMBER,
EDIT_TEXT,
SET_PRICE,
}
PLAYER_COMMAND, CONSOLE_COMMAND, RENAME, PERMISSION, MESSAGE, COMMAND_DELAY, MESSAGE_DELAY, EDIT_TEXT_NUMBER,
EDIT_TEXT, SET_PRICE,
}
@@ -2,39 +2,54 @@ package dev.mylesmor.sudosigns.data;
/**
* The SignCommand class for storing sign command data.
*
* @author MylesMor
* @author https://mylesmor.dev
*/
public class SignCommand {
private String command;
private PlayerInput type;
private int number;
private double delay;
private final String command;
private final PlayerInput type;
private final int number;
private double delay;
public SignCommand(int number, String cmd, double delay, PlayerInput type) {
this.number = number;
command = cmd;
this.type = type;
this.delay = delay;
}
public SignCommand(int number, String cmd, double delay, PlayerInput type) {
public String getCommand() {
return command;
}
this.number = number;
command = cmd;
this.type = type;
this.delay = delay;
public PlayerInput getType() {
return type;
}
}
public int getNumber() { return number; }
public String getCommand() {
public double getDelay() {
return delay;
}
return command;
public void setDelay(double delay) {
this.delay = delay;
}
}
public PlayerInput getType() {
return type;
}
public int getNumber() {
return number;
}
public double getDelay() {
return delay;
}
public void setDelay(double delay) {
this.delay = delay;
}
}
@@ -2,33 +2,48 @@ package dev.mylesmor.sudosigns.data;
public class SignMessage {
private String message;
private PlayerInput type;
private int number;
private double delay;
private final String message;
private final PlayerInput type;
private final int number;
private double delay;
public SignMessage(int number, String message, double delay, PlayerInput type) {
this.number = number;
this.message = message;
this.type = type;
this.delay = delay;
}
public SignMessage(int number, String message, double delay, PlayerInput type) {
public String getMessage() {
return message;
}
this.number = number;
this.message = message;
this.type = type;
this.delay = delay;
public PlayerInput getType() {
return type;
}
}
public int getNumber() { return number; }
public String getMessage() {
public double getDelay() {
return delay;
}
return message;
public void setDelay(double delay) {
this.delay = delay;
}
}
}
public PlayerInput getType() {
return type;
}
public int getNumber() {
return number;
}
public double getDelay() {
return delay;
}
public void setDelay(double delay) {
this.delay = delay;
}
}
File diff suppressed because it is too large. Load diff
@@ -6,138 +6,192 @@ import dev.mylesmor.sudosigns.menus.SignEditor;
/**
* SudoUser class to store all user variables.
*
* @author MylesMor
* @author https://mylesmor.dev
*/
public class SudoUser {
private Player p;
private boolean edit = false;
private boolean create = false;
private boolean delete = false;
private boolean selectToCopy = false;
private boolean copy = false;
private boolean run = false;
private boolean view = false;
private boolean textInput = false;
private boolean editing = false;
private SignEditor editor;
private boolean edit = false;
private boolean create = false;
private boolean delete = false;
private boolean selectToCopy = false;
private boolean copy = false;
private boolean run = false;
private boolean view = false;
private boolean textInput = false;
private boolean editing = false;
private SignEditor editor;
private PlayerInput inputType;
private PlayerInput inputType;
public SudoUser(Player p) {
this.p = p;
}
public Player getPlayer() {
return p;
}
public void setPlayer(Player p) {
this.p = p;
}
public Player getPlayer() {
public boolean isSelectToCopy() {
return selectToCopy;
}
return p;
public void setSelectToCopy(boolean selectToCopy) {
this.selectToCopy = selectToCopy;
}
}
public boolean isEdit() {
return edit;
}
public void setPlayer(Player p) {
public SignEditor getEditor() {
return editor;
}
this.p = p;
public boolean isEditing() {
return editing;
}
}
public void setEditor(SignEditor editor) {
editing = true;
this.editor = editor;
}
public boolean isSelectToCopy() {
public void removeEditor() {
editing = false;
editor = null;
}
return selectToCopy;
public boolean isTextInput() {
return textInput;
}
}
public PlayerInput getInputType() {
return inputType;
}
public void setSelectToCopy(boolean selectToCopy) {
public void addTextInput(PlayerInput type) {
this.textInput = true;
this.inputType = type;
this.selectToCopy = selectToCopy;
}
}
public void removeTextInput() {
this.textInput = false;
this.inputType = null;
}
public boolean isEdit() {
return edit;
private String passThru;
}
public String getPassThru() {
return passThru;
}
public SignEditor getEditor() {
public void setPassThru(String passThru) {
this.passThru = passThru;
}
return editor;
public boolean isView() {
return view;
}
}
public void setView(boolean view) {
this.view = view;
}
public boolean isEditing() {
public void setEdit(boolean edit) {
this.edit = edit;
}
return editing;
public boolean isCreate() {
return create;
}
}
public void setCreate(boolean create) {
this.create = create;
}
public void setEditor(SignEditor editor) {
public boolean isDelete() {
return delete;
}
editing = true;
this.editor = editor;
public void setDelete(boolean delete) {
this.delete = delete;
}
}
public boolean isCopy() {
return copy;
}
public void removeEditor() {
public void setCopy(boolean copy) {
this.copy = copy;
}
editing = false;
editor = null;
public boolean isRun() {
return run;
}
}
public void setRun(boolean run) {
this.run = run;
}
}
public boolean isTextInput() {
return textInput;
}
public PlayerInput getInputType() {
return inputType;
}
public void addTextInput(PlayerInput type) {
this.textInput = true;
this.inputType = type;
}
public void removeTextInput() {
this.textInput = false;
this.inputType = null;
}
private String passThru;
public String getPassThru() {
return passThru;
}
public void setPassThru(String passThru) {
this.passThru = passThru;
}
public boolean isView() {
return view;
}
public void setView(boolean view) {
this.view = view;
}
public void setEdit(boolean edit) {
this.edit = edit;
}
public boolean isCreate() {
return create;
}
public void setCreate(boolean create) {
this.create = create;
}
public boolean isDelete() {
return delete;
}
public void setDelete(boolean delete) {
this.delete = delete;
}
public boolean isCopy() {
return copy;
}
public void setCopy(boolean copy) {
this.copy = copy;
}
public boolean isRun() {
return run;
}
public void setRun(boolean run) {
this.run = run;
}
}
@@ -14,330 +14,380 @@ import dev.mylesmor.sudosigns.menus.SignEditor;
import dev.mylesmor.sudosigns.util.Util;
import io.papermc.paper.event.player.AsyncChatEvent;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import net.trueog.utilitiesog.UtilitiesOG;
/**
* The ChatListener class for taking user input in chat.
*
* @author MylesMor
* @author https://mylesmor.dev
* @Maintainer NotAlexNoyle
* @Maintainer https://true-og.net
*/
public class ChatListener implements Listener {
@EventHandler
public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent e) {
@EventHandler
public void onPlayerCommandPreprocessEvent(PlayerCommandPreprocessEvent playerCommandPreprocessEvent) {
Player p = e.getPlayer();
SudoUser user = SudoSigns.users.get(p.getUniqueId());
if (user != null) {
final Player p = playerCommandPreprocessEvent.getPlayer();
final SudoUser user = SudoSigns.users.get(p.getUniqueId());
final boolean condition = user != null && user.isTextInput() && user.isEditing();
if (!condition) {
if (user.isTextInput() && user.isEditing()) {
return;
if (user.getInputType() == PlayerInput.CONSOLE_COMMAND || user.getInputType() == PlayerInput.PLAYER_COMMAND) {
}
user.getEditor().getCommandsMenu().addCommand(e.getMessage().substring(1), user.getInputType());
user.removeTextInput();
if (user.getInputType() == PlayerInput.CONSOLE_COMMAND || user.getInputType() == PlayerInput.PLAYER_COMMAND) {
}
else {
user.getEditor().getCommandsMenu().addCommand(playerCommandPreprocessEvent.getMessage().substring(1),
user.getInputType());
user.removeTextInput();
Util.sudoSignsMessage(p, "&eWARNING: &6Operation Cancelled!");
user.removeTextInput();
} else {
}
UtilitiesOG.trueogMessage(p, "&eWARNING: &6Operation Cancelled!");
e.setCancelled(true);
user.removeTextInput();
}
}
}
playerCommandPreprocessEvent.setCancelled(true);
}
}
@EventHandler
public void onAsyncPlayerChat(AsyncChatEvent e) {
@EventHandler
public void onAsyncPlayerChat(AsyncChatEvent asyncChatEvent) {
Player p = e.getPlayer();
SudoUser user = SudoSigns.users.get(p.getUniqueId());
if (user != null) {
final Player p = asyncChatEvent.getPlayer();
final SudoUser user = SudoSigns.users.get(p.getUniqueId());
final boolean condition = user != null && user.isTextInput() && user.isEditing();
if (!condition) {
if (user.isTextInput() && user.isEditing()) {
return;
SignEditor editor = user.getEditor();
}
switch (user.getInputType()) {
case PLAYER_COMMAND: case CONSOLE_COMMAND:
if (PlainTextComponentSerializer.plainText().serialize(e.message()).equalsIgnoreCase("cancel")) {
final SignEditor editor = user.getEditor();
switch (user.getInputType()) {
handle(e, true, "Cancelled!", editor, user, null, editor::goToCommands);
case PLAYER_COMMAND, CONSOLE_COMMAND -> {
return;
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.equalsIgnoreCase("cancel"))
{
}
handle(asyncChatEvent, true, "Cancelled!", editor, user, null, editor::goToCommands);
user.removeTextInput();
return;
handle(e, true, "No command found! Cancelling...", editor, user, null, editor::goToCommands);
}
break;
case RENAME:
if (PlainTextComponentSerializer.plainText().serialize(e.message()).equalsIgnoreCase("cancel")) {
user.removeTextInput();
handle(asyncChatEvent, true, "No command found! Cancelling...", editor, user, null,
editor::goToCommands);
handle(e, true, "Cancelled!", editor, user, null, editor::goToMain);
}
case RENAME -> {
return;
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.equalsIgnoreCase("cancel"))
{
}
handle(asyncChatEvent, true, "Cancelled!", editor, user, null, editor::goToMain);
handle(e, true, null, editor, user, edit -> editor.renameSign(PlainTextComponentSerializer.plainText().serialize(e.message())), editor::goToMain);
return;
break;
case PERMISSION:
if (PlainTextComponentSerializer.plainText().serialize(e.message()).equalsIgnoreCase("cancel")) {
}
handle(e, true, "Cancelled!", editor, user, null, editor::goToPermissions);
handle(asyncChatEvent, true, null, editor, user,
edit -> editor.renameSign(
PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())),
editor::goToMain);
return;
}
case PERMISSION -> {
}
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.equalsIgnoreCase("cancel"))
{
handle(e, true, null, editor, user, edit -> editor.getPermMenu().addPermission(true, PlainTextComponentSerializer.plainText().serialize(e.message())), editor::goToPermissions);
handle(asyncChatEvent, true, "Cancelled!", editor, user, null, editor::goToPermissions);
break;
case MESSAGE:
if (PlainTextComponentSerializer.plainText().serialize(e.message()).equalsIgnoreCase("cancel")) {
return;
handle(e, true, "Cancelled!", editor, user, null, editor::goToMessages);
}
return;
handle(asyncChatEvent, true, null, editor, user,
edit -> editor.getPermMenu().addPermission(true,
PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())),
editor::goToPermissions);
}
}
case MESSAGE -> {
handle(e, true, null, editor, user, edit -> editor.getMessagesMenu().addMessage(PlainTextComponentSerializer.plainText().serialize(e.message())), editor::goToMessages);
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.equalsIgnoreCase("cancel"))
{
break;
case COMMAND_DELAY:
if (PlainTextComponentSerializer.plainText().serialize(e.message()).equalsIgnoreCase("cancel")) {
handle(asyncChatEvent, true, "Cancelled!", editor, user, null, editor::goToMessages);
handle(e, true, "Cancelled!", editor, user, null, editor::goToCommands);
return;
return;
}
}
handle(asyncChatEvent, true, null, editor, user,
edit -> editor.getMessagesMenu().addMessage(
PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())),
editor::goToMessages);
double delay = 0;
try {
}
case COMMAND_DELAY -> {
delay = Double.parseDouble(PlainTextComponentSerializer.plainText().serialize(e.message()));
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.equalsIgnoreCase("cancel"))
{
}
catch (NumberFormatException nfe) {
handle(asyncChatEvent, true, "Cancelled!", editor, user, null, editor::goToCommands);
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: Please enter a valid number.");
return;
return;
}
}
double delay = 0;
try {
double finalDelay = delay;
delay = Double
.parseDouble(PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message()));
handle(e, true, null, editor, user, edit -> editor.getCommandOptionsMenu().setDelay(finalDelay), editor::goToCommands);
} catch (NumberFormatException numberFormatException) {
break;
case MESSAGE_DELAY:
if (PlainTextComponentSerializer.plainText().serialize(e.message()).equalsIgnoreCase("cancel")) {
asyncChatEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p, "&cERROR: Please enter a valid number.");
handle(e, true, "Cancelled!", editor, user, null, editor::goToMessages);
return;
return;
}
}
final double finalDelay = delay;
handle(asyncChatEvent, true, null, editor, user,
edit -> editor.getCommandOptionsMenu().setDelay(finalDelay), editor::goToCommands);
double messageDelay = 0;
try {
}
case MESSAGE_DELAY -> {
messageDelay = Double.parseDouble(PlainTextComponentSerializer.plainText().serialize(e.message()));
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.equalsIgnoreCase("cancel"))
{
}
catch (NumberFormatException nfe) {
handle(asyncChatEvent, true, "Cancelled!", editor, user, null, editor::goToMessages);
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: Please enter a valid number!");
return;
return;
}
}
double messageDelay = 0;
try {
double finalMessageDelay = messageDelay;
messageDelay = Double
.parseDouble(PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message()));
handle(e, true, null, editor, user, edit -> editor.getMessageOptionsMenu().setDelay(finalMessageDelay), editor::goToMessages);
} catch (NumberFormatException nfe) {
break;
case EDIT_TEXT_NUMBER:
if (PlainTextComponentSerializer.plainText().serialize(e.message()).equalsIgnoreCase("cancel")) {
asyncChatEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p, "&cERROR: Please enter a valid number!");
handle(e, true, "Cancelled!", editor, user, null, editor::goToMessages);
return;
return;
}
}
final double finalMessageDelay = messageDelay;
handle(asyncChatEvent, true, null, editor, user,
edit -> editor.getMessageOptionsMenu().setDelay(finalMessageDelay), editor::goToMessages);
int lineNumber = 0;
try {
}
case EDIT_TEXT_NUMBER -> {
lineNumber = Integer.parseInt(PlainTextComponentSerializer.plainText().serialize(e.message()));
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.equalsIgnoreCase("cancel"))
{
}
catch (NumberFormatException nfe) {
handle(asyncChatEvent, true, "Cancelled!", editor, user, null, editor::goToMessages);
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: Please enter a valid number between 1-4!");
return;
return;
}
}
if (lineNumber < 1 || lineNumber > 4) {
int lineNumber = 0;
try {
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: Please enter a valid number between 1-4!");
lineNumber = Integer
.parseInt(PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message()));
return;
} catch (NumberFormatException nfe) {
}
asyncChatEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p, "&cERROR: Please enter a valid number between 1-4!");
final int finalLineNumber = lineNumber;
return;
handle(e, true, null, editor, user, edit -> editor.getMainMenu().setLineNumber(finalLineNumber), null);
}
break;
case EDIT_TEXT:
if (PlainTextComponentSerializer.plainText().serialize(e.message()).equalsIgnoreCase("cancel")) {
if (lineNumber < 1 || lineNumber > 4) {
handle(e, true, "Cancelled!", editor, user, null, editor::goToMessages);
asyncChatEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p, "&cERROR: Please enter a valid number between 1-4!");
return;
return;
}
}
// Regular expression contributed by lazerl0rd (MIT) at https://github.com/MylesMor/SudoSigns/pull/4
if (PlainTextComponentSerializer.plainText().serialize(e.message()).replaceAll("&([0-9]|[a-g]|[k-o]|r)", "").length() > 15) {
final int finalLineNumber = lineNumber;
handle(asyncChatEvent, true, null, editor, user,
edit -> editor.getMainMenu().setLineNumber(finalLineNumber), null);
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: The message can't be greater than 15 characters!");
}
case EDIT_TEXT -> {
return;
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.equalsIgnoreCase("cancel"))
{
}
handle(asyncChatEvent, true, "Cancelled!", editor, user, null, editor::goToMessages);
handle(e, true, null, editor, user, edit -> editor.getMainMenu().setText(Util.legacySerializerAnyCase(PlainTextComponentSerializer.plainText().serialize(e.message()))), editor::goToMain);
return;
break;
case SET_PRICE:
if (PlainTextComponentSerializer.plainText().serialize(e.message()).equalsIgnoreCase("cancel")) {
}
handle(e, true, "Cancelled!", editor, user, null, editor::goToMessages);
// Regular expression contributed by lazerl0rd (MIT) at
// https://github.com/MylesMor/SudoSigns/pull/4
// https://web.archive.org/web/20260302082938/https://github.com/MylesMor/SudoSigns/pull/4
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.replaceAll("&([0-9]|[a-g]|[k-o]|r)", "").length() > 15)
{
return;
asyncChatEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p, "&cERROR: The message can't be greater than 15 characters!");
}
return;
if(Util.priceIsInteger()) {
}
int price;
try {
handle(asyncChatEvent, true, null, editor, user,
edit -> editor.getMainMenu()
.setText(UtilitiesOG.trueogColorize(
PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message()))),
editor::goToMain);
price = Integer.parseInt(PlainTextComponentSerializer.plainText().serialize(e.message()));
}
case SET_PRICE -> {
}
catch (NumberFormatException nfe) {
if (PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message())
.equalsIgnoreCase("cancel"))
{
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: Please enter a valid integer!");
handle(asyncChatEvent, true, "Cancelled!", editor, user, null, editor::goToMessages);
return;
return;
}
}
if (price < 0) {
if (Util.priceIsInteger()) {
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: Please enter &e0&c, or a positive integer!");
final int price;
try {
return;
price = Integer
.parseInt(PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message()));
}
} catch (NumberFormatException nfe) {
handle(e, true, null, editor, user, edit -> editor.getMainMenu().setPriceAsInteger(price), editor::goToMain);
asyncChatEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p, "&cERROR: Please enter a valid integer!");
}
else {
return;
double price;
try {
}
price = Double.parseDouble(PlainTextComponentSerializer.plainText().serialize(e.message()));
if (price < 0) {
}
catch (NumberFormatException nfe) {
asyncChatEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p, "&cERROR: Please enter &e0&c, or a positive integer!");
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: Please enter a valid number!");
return;
return;
}
}
handle(asyncChatEvent, true, null, editor, user,
edit -> editor.getMainMenu().setPriceAsInteger(price), editor::goToMain);
if (price < 0) {
} else {
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: Please enter &e0&c, or a positive number!");
final double price;
try {
return;
price = Double.parseDouble(
PlainTextComponentSerializer.plainText().serialize(asyncChatEvent.message()));
}
} catch (NumberFormatException nfe) {
handle(e, true, null, editor, user, edit -> editor.getMainMenu().setPriceAsDouble(price), editor::goToMain);
asyncChatEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p, "&cERROR: Please enter a valid number!");
}
return;
break;
}
}
if (price < 0) {
}
asyncChatEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p, "&cERROR: Please enter &e0&c, or a positive number!");
}
return;
}
}
private void handle(AsyncChatEvent e, boolean cancel, String message, SignEditor editor, SudoUser user, Consumer<SignEditor> eventConsumer, Runnable finalAction) {
handle(asyncChatEvent, true, null, editor, user,
edit -> editor.getMainMenu().setPriceAsDouble(price), editor::goToMain);
if (cancel) {
}
e.setCancelled(true);
}
}
}
if (message != null) {
}
Util.sudoSignsMessage(e.getPlayer(), "&c" + message);
private void handle(AsyncChatEvent e, boolean cancel, String message, SignEditor editor, SudoUser user,
Consumer<SignEditor> eventConsumer, Runnable finalAction)
{
}
if (cancel) {
if (eventConsumer != null) {
e.setCancelled(true);
Bukkit.getScheduler().runTask(SudoSigns.sudoSignsPlugin, () -> eventConsumer.accept(editor));
}
}
if (message != null) {
user.removeTextInput();
UtilitiesOG.trueogMessage(e.getPlayer(), "&c" + message);
if (finalAction != null) {
}
Bukkit.getScheduler().runTask(SudoSigns.sudoSignsPlugin, finalAction);
if (eventConsumer != null) {
}
Bukkit.getScheduler().runTask(SudoSigns.sudoSignsPlugin, () -> eventConsumer.accept(editor));
}
}
user.removeTextInput();
if (finalAction != null) {
Bukkit.getScheduler().runTask(SudoSigns.sudoSignsPlugin, finalAction);
}
}
}
@@ -19,260 +19,284 @@ import dev.mylesmor.sudosigns.menus.SignEditor;
import dev.mylesmor.sudosigns.util.Permissions;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
/**
* InventoryListener class to listen for GUI actions.
*
* @author MylesMor
* @author https://mylesmor.dev
*/
public class InventoryListener implements Listener {
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
SudoUser user = SudoSigns.users.get(p.getUniqueId());
if (user != null) {
if (user.isEditing()) {
if (Objects.equals(e.getClickedInventory(), e.getView().getTopInventory())) {
SignEditor editor = user.getEditor();
if (e.getCurrentItem() != null) {
e.setCancelled(true);
Material m = e.getCurrentItem().getType();
String itemName = e.getCurrentItem().getDisplayName();
switch (editor.getCurrentPage()) {
case MAIN:
checkForMainMenuClicks(editor, m);
break;
case COMMANDS:
checkForCommandsClicks(p, editor, m, e.getCurrentItem());
break;
case PERMISSIONS:
checkForPermissionsClicks(p, editor, m, itemName);
break;
case CHOOSE_COMMAND:
chooseCommandType(editor, m, itemName);
break;
case CHOOSE_PERMISSION:
choosePermissionType(editor, m);
break;
case MESSAGES:
checkForMessagesClicks(p, editor, m, e.getCurrentItem());
break;
case COMMAND_OPTIONS:
checkForCommandOptionClicks(p, editor, m, itemName);
break;
case MESSAGE_OPTIONS:
checkForMessageOptionClicks(p, editor, m, itemName);
break;
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
}
}
}
}
}
}
final Player p = (Player) e.getWhoClicked();
final SudoUser user = SudoSigns.users.get(p.getUniqueId());
final boolean condition = user != null && user.isEditing()
&& Objects.equals(e.getClickedInventory(), e.getView().getTopInventory());
if (condition) {
@EventHandler
public void closeInventory(InventoryCloseEvent e) {
Player p = (Player) e.getPlayer();
SudoUser user = SudoSigns.users.get(p.getUniqueId());
if (user != null) {
// Checks whether the user has closed the GUI.
if (user.isEditing()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(SudoSigns.sudoSignsPlugin, () -> {
InventoryView currentInv = p.getOpenInventory();
if (PlainTextComponentSerializer.plainText().serialize(currentInv.title()).equalsIgnoreCase("CRAFTING") && ! user.isTextInput()) {
user.getEditor().endEditor();
user.removeEditor();
}
}, 5L);
}
}
}
final SignEditor editor = user.getEditor();
if (e.getCurrentItem() != null) {
/**
* Checks for GUI clicks in the main menu.
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
*/
public void checkForMainMenuClicks(SignEditor editor, Material m) {
if (m.equals(Material.OAK_SIGN)) {
editor.goToMessages();
return;
}
switch (m) {
case NAME_TAG:
editor.prepareRename();
break;
case WRITABLE_BOOK:
editor.editSignNumber();
break;
case BARRIER:
editor.goToPermissions();
break;
case COMMAND_BLOCK:
editor.goToCommands();
break;
case BIRCH_SIGN:
editor.goToMessages();
break;
case GOLD_NUGGET:
editor.getMainMenu().prepareSetPrice();
break;
default:
break;
}
}
e.setCancelled(true);
final Material m = e.getCurrentItem().getType();
final String itemName = e.getCurrentItem().getDisplayName();
switch (editor.getCurrentPage()) {
/**
* Checks for GUI clicks in the Command Options menu.
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param item The ItemStack of the clicked item.
*/
public void checkForCommandsClicks(Player p, SignEditor editor, Material m, ItemStack item) {
switch (m) {
case WRITABLE_BOOK:
editor.getCommandsMenu().prepareCommand();
break;
case BOOK:
if (p.hasPermission(Permissions.COMMAND_OPTIONS)) {
editor.goToCommandOptionsMenu(item);
}
break;
case ARROW:
editor.goToMain();
break;
default:
break;
}
}
case MAIN -> checkForMainMenuClicks(editor, m);
case COMMANDS -> checkForCommandsClicks(p, editor, m, e.getCurrentItem());
case PERMISSIONS -> checkForPermissionsClicks(p, editor, m, itemName);
case CHOOSE_COMMAND -> chooseCommandType(editor, m, itemName);
case CHOOSE_PERMISSION -> choosePermissionType(editor, m);
case MESSAGES -> checkForMessagesClicks(p, editor, m, e.getCurrentItem());
case COMMAND_OPTIONS -> checkForCommandOptionClicks(p, editor, m, itemName);
case MESSAGE_OPTIONS -> checkForMessageOptionClicks(p, editor, m, itemName);
/**
* Checks for GUI clicks in the Command Options menu.
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param itemName The name of the item clicked.
*/
public void checkForCommandOptionClicks(Player p, SignEditor editor, Material m, String itemName) {
switch (m) {
case CLOCK:
editor.getCommandOptionsMenu().addDelay();
break;
case BARRIER:
if (p.hasPermission(Permissions.DELETE_COMMAND)) {
editor.getCommandOptionsMenu().deleteCommand();
}
break;
case ARROW:
editor.goToCommands();
break;
default:
break;
}
}
}
/**
* Checks for GUI clicks in the Commands menu.
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param itemName The name of the item clicked.
*/
public void checkForMessageOptionClicks(Player p, SignEditor editor, Material m, String itemName) {
switch (m) {
case CLOCK:
editor.getMessageOptionsMenu().addDelay();
break;
case BARRIER:
if (p.hasPermission(Permissions.DELETE_MESSAGE)) {
editor.getMessageOptionsMenu().deleteMessage();
}
break;
case ARROW:
editor.goToMessages();
break;
default:
break;
}
}
}
/**
* Checks for GUI clicks in the Commands menu.
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param item The ItemStack of the clicked item.
*/
public void checkForMessagesClicks(Player p, SignEditor editor, Material m, ItemStack item) {
switch (m) {
case WRITABLE_BOOK:
editor.getMessagesMenu().prepareMessage();
break;
case BOOK:
if (p.hasPermission(Permissions.MESSAGE_OPTIONS)) {
editor.goToMessageOptionsMenu(item);
}
break;
case ARROW:
editor.goToMain();
break;
default:
break;
}
}
}
public void choosePermissionType(SignEditor editor, Material m) {
switch (m) {
case PLAYER_HEAD:
editor.getPermMenu().addPermission(true, null);
break;
case COMMAND_BLOCK:
editor.getPermMenu().addPermission(false, null);
break;
case ARROW:
editor.goToPermissions();
break;
default:
break;
}
}
}
public void chooseCommandType(SignEditor editor, Material m, String itemName) {
switch (m) {
case PLAYER_HEAD:
editor.getCommandsMenu().chooseCommandType(PlayerInput.PLAYER_COMMAND);
break;
case COMMAND_BLOCK:
editor.getCommandsMenu().chooseCommandType(PlayerInput.CONSOLE_COMMAND);
break;
case ARROW:
editor.goToCommands();
break;
default:
break;
}
}
@EventHandler
public void closeInventory(InventoryCloseEvent e) {
/**
* Checks for GUI clicks in the Permissions menu.
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param itemName The name of the item clicked.
*/
public void checkForPermissionsClicks(Player p, SignEditor editor, Material m, String itemName) {
switch (m) {
case BOOK:
if (p.hasPermission(Permissions.DELETE_PERMISSION)) {
editor.getPermMenu().deletePermission(itemName);
}
break;
case WRITABLE_BOOK:
editor.getPermMenu().preparePermission();
break;
case ARROW:
editor.goToMain();
default:
break;
}
}
final Player p = (Player) e.getPlayer();
final SudoUser user = SudoSigns.users.get(p.getUniqueId());
final boolean condition = user != null && user.isEditing();
// Checks whether the user has closed the GUI.
if (condition) {
}
Bukkit.getScheduler().scheduleSyncDelayedTask(SudoSigns.sudoSignsPlugin, () -> {
final InventoryView currentInv = p.getOpenInventory();
if (PlainTextComponentSerializer.plainText().serialize(currentInv.title()).equalsIgnoreCase("CRAFTING")
&& !user.isTextInput())
{
user.getEditor().endEditor();
user.removeEditor();
}
}, 5L);
}
}
/**
* Checks for GUI clicks in the main menu.
*
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
*/
public void checkForMainMenuClicks(SignEditor editor, Material m) {
if (m.equals(Material.OAK_SIGN)) {
editor.goToMessages();
return;
}
switch (m) {
case NAME_TAG -> editor.prepareRename();
case WRITABLE_BOOK -> editor.editSignNumber();
case BARRIER -> editor.goToPermissions();
case COMMAND_BLOCK -> editor.goToCommands();
case BIRCH_SIGN -> editor.goToMessages();
case GOLD_NUGGET -> editor.getMainMenu().prepareSetPrice();
default -> {
}
}
}
/**
* Checks for GUI clicks in the Command Options menu.
*
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param item The ItemStack of the clicked item.
*/
public void checkForCommandsClicks(Player p, SignEditor editor, Material m, ItemStack item) {
switch (m) {
case WRITABLE_BOOK -> editor.getCommandsMenu().prepareCommand();
case BOOK -> {
if (p.hasPermission(Permissions.COMMAND_OPTIONS)) {
editor.goToCommandOptionsMenu(item);
}
}
case ARROW -> editor.goToMain();
default -> {
}
}
}
/**
* Checks for GUI clicks in the Command Options menu.
*
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param itemName The name of the item clicked.
*/
public void checkForCommandOptionClicks(Player p, SignEditor editor, Material m, String itemName) {
switch (m) {
case CLOCK -> editor.getCommandOptionsMenu().addDelay();
case BARRIER -> {
if (p.hasPermission(Permissions.DELETE_COMMAND)) {
editor.getCommandOptionsMenu().deleteCommand();
}
}
case ARROW -> editor.goToCommands();
default -> {
}
}
}
/**
* Checks for GUI clicks in the Commands menu.
*
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param itemName The name of the item clicked.
*/
public void checkForMessageOptionClicks(Player p, SignEditor editor, Material m, String itemName) {
switch (m) {
case CLOCK -> editor.getMessageOptionsMenu().addDelay();
case BARRIER -> {
if (p.hasPermission(Permissions.DELETE_MESSAGE)) {
editor.getMessageOptionsMenu().deleteMessage();
}
}
case ARROW -> editor.goToMessages();
default -> {
}
}
}
/**
* Checks for GUI clicks in the Commands menu.
*
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param item The ItemStack of the clicked item.
*/
public void checkForMessagesClicks(Player p, SignEditor editor, Material m, ItemStack item) {
switch (m) {
case WRITABLE_BOOK -> editor.getMessagesMenu().prepareMessage();
case BOOK -> {
if (p.hasPermission(Permissions.MESSAGE_OPTIONS)) {
editor.goToMessageOptionsMenu(item);
}
}
case ARROW -> editor.goToMain();
default -> {
}
}
}
public void choosePermissionType(SignEditor editor, Material m) {
switch (m) {
case PLAYER_HEAD -> editor.getPermMenu().addPermission(true, null);
case COMMAND_BLOCK -> editor.getPermMenu().addPermission(false, null);
case ARROW -> editor.goToPermissions();
default -> {
}
}
}
public void chooseCommandType(SignEditor editor, Material m, String itemName) {
switch (m) {
case PLAYER_HEAD -> editor.getCommandsMenu().chooseCommandType(PlayerInput.PLAYER_COMMAND);
case COMMAND_BLOCK -> editor.getCommandsMenu().chooseCommandType(PlayerInput.CONSOLE_COMMAND);
case ARROW -> editor.goToCommands();
default -> {
}
}
}
/**
* Checks for GUI clicks in the Permissions menu.
*
* @param editor The SignEditor class of the particular user.
* @param m The material clicked on in the menu.
* @param itemName The name of the item clicked.
*/
public void checkForPermissionsClicks(Player p, SignEditor editor, Material m, String itemName) {
switch (m) {
case BOOK:
if (p.hasPermission(Permissions.DELETE_PERMISSION)) {
editor.getPermMenu().deletePermission(itemName);
}
break;
case WRITABLE_BOOK:
editor.getPermMenu().preparePermission();
break;
case ARROW:
editor.goToMain();
default:
break;
}
}
}
@@ -8,8 +8,11 @@ import dev.mylesmor.sudosigns.SudoSigns;
public class PlayerListener implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
SudoSigns.users.remove(e.getPlayer().getUniqueId());
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
SudoSigns.users.remove(e.getPlayer().getUniqueId());
}
}
@@ -26,308 +26,486 @@ import dev.mylesmor.sudosigns.data.SudoUser;
import dev.mylesmor.sudosigns.menus.SignEditor;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
import net.trueog.utilitiesog.UtilitiesOG;
public class SignListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.getClickedBlock() != null) {
SudoUser user = SudoSigns.users.get(p.getUniqueId());
if (user != null) {
Block b = e.getClickedBlock();
if (user.isCreate()) {
e.setCancelled(true);
create(p, user, b);
} else if (user.isSelectToCopy()) {
e.setCancelled(true);
selectToCopy(p, user, b);
} else if (user.isCopy()) {
e.setCancelled(true);
copy(p, user, b);
} else if (user.isEdit()) {
e.setCancelled(true);
edit(p, user, b);
} else if (user.isDelete()) {
e.setCancelled(true);
delete(p, user, b);
} else if (user.isRun()) {
e.setCancelled(true);
runRemote(p, user, b);
} else if (user.isView()) {
e.setCancelled(true);
view(p, user, b);
} else {
runSign(p, e);
}
} else {
runSign(p, e);
}
}
}
private final DiamondBankAPIJava diamondBankAPI;
private void selectToCopy(Player p, SudoUser user, Block b) {
if (b.getState() instanceof Sign || b.getState() instanceof WallSign) {
Sign sign = (Sign) b.getState();
String name = Util.findSign(sign);
if (name != null) {
user.setSelectToCopy(false);
p.performCommand("ss copy " + name + " " + user.getPassThru());
} else {
Util.sudoSignsMessage(p, "&cERROR: Failed to copy: that is not a SudoSign!");
}
} else {
Util.sudoSignsMessage(p, "&cERROR: A sign wasn't clicked! &6Cancelling...");
}
user.setSelectToCopy(false);
}
public SignListener(DiamondBankAPIJava diamondBankAPI) {
private void runSign(Player p, PlayerInteractEvent e) {
if (Objects.requireNonNull(e.getClickedBlock()).getState() instanceof Sign || e.getClickedBlock().getState() instanceof WallSign) {
if (p.hasPermission(Permissions.SELECT) && e.getAction() == Action.RIGHT_CLICK_BLOCK || ! p.hasPermission(Permissions.SELECT)) {
Sign sign = (Sign) e.getClickedBlock().getState();
String name = Util.findSign(sign);
if (name != null) {
SudoSigns.signs.get(name).executeCommands(p);
}
}
}
}
this.diamondBankAPI = diamondBankAPI;
private void create(Player p, SudoUser user, Block b) {
if (b.getState() instanceof Sign || b.getState() instanceof WallSign) {
Sign sign = (Sign) b.getState();
String name = Util.findSign(sign);
if (name != null) {
user.setCreate(false);
SudoSigns.signs.remove(user.getPassThru());
Util.sudoSignsMessage(p, "&cERROR: That SudoSign already exists! &6Cancelling...");
return;
}
SudoSigns.signs.get(user.getPassThru()).setSign(sign);
SudoSigns.signs.get(user.getPassThru()).addLines();
if (p.hasPermission(Permissions.EDIT)) {
SignEditor editor = new SignEditor(p, SudoSigns.signs.get(user.getPassThru()), user);
user.setEditor(editor);
}
SudoSigns.config.saveSign(SudoSigns.signs.get(user.getPassThru()), true, p);
}
else {
Util.sudoSignsMessage(p, "&cERROR: A sign was not clicked! Cancelling...");
user.setCreate(false);
SudoSigns.signs.remove(user.getPassThru());
}
user.setCreate(false);
}
}
private void copy(Player p, SudoUser user, Block b) {
if (b.getState() instanceof Sign || b.getState() instanceof WallSign) {
Sign newSign = (Sign) b.getState();
String name = Util.findSign(newSign);
if (name != null) {
user.setCopy(false);
SudoSigns.signs.remove(user.getPassThru());
Util.sudoSignsMessage(p, "&cERROR: That sign is already a SudoSign! Cancelling...");
return;
}
SudoSigns.signs.get(user.getPassThru()).setSign(newSign);
SudoSigns.signs.get(user.getPassThru()).addLines();
SudoSigns.config.saveSign(SudoSigns.signs.get(user.getPassThru()), true, p);
Util.sudoSignsMessage(p, "&aSign has been copied to sign &e%NAME% &asuccessfully!", user.getPassThru());
} else {
Util.sudoSignsMessage(p, "&cERROR: A sign was not clicked! &6Cancelling...");
SudoSigns.signs.remove(user.getPassThru());
}
user.setCopy(false);
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent playerInteractEvent) {
private void runRemote(Player p, SudoUser user, Block b) {
if (b.getState() instanceof Sign || b.getState() instanceof WallSign) {
Sign sign = (Sign) b.getState();
String name = Util.findSign(sign);
if (name != null) {
p.performCommand("ss run " +name);
final Player p = playerInteractEvent.getPlayer();
if (playerInteractEvent.getClickedBlock() == null) {
} else {
Util.sudoSignsMessage(p, "&cERROR: That is not a SudoSign! &6Use: &d/ss create <name> &6instead.");
}
} else {
Util.sudoSignsMessage(p, "&cERROR: A sign was not clicked! Cancelling...");
}
user.setRun(false);
}
return;
private void edit(Player p, SudoUser user, Block b) {
if (b.getState() instanceof Sign || b.getState() instanceof WallSign) {
Sign sign = (Sign) b.getState();
String name = Util.findSign(sign);
if (name != null) {
p.performCommand("ss edit " + name);
} else {
Util.sudoSignsMessage(p, "&cERROR: That is not a SudoSign! &6Use: &d/ss create <name> &6instead.");
}
} else {
Util.sudoSignsMessage(p, "&cERROR: A sign was not clicked! Cancelling...");
}
user.setEdit(false);
}
}
private void delete(Player p, SudoUser user, Block b) {
if (b.getState() instanceof Sign || b.getState() instanceof WallSign) {
Sign sign = (Sign) b.getState();
String name = Util.findSign(sign);
if (name != null) {
p.performCommand("ss delete " + name);
} else {
Util.sudoSignsMessage(p, "&cERROR: That is not a SudoSign!");
}
} else {
Util.sudoSignsMessage(p, "&cERROR: A sign was not clicked! &6Cancelling...");
}
user.setDelete(false);
}
final SudoUser user = SudoSigns.users.get(p.getUniqueId());
if (user != null) {
private void view(Player p, SudoUser user, Block b) {
if (b.getState() instanceof Sign || b.getState() instanceof WallSign) {
Sign sign = (Sign) b.getState();
String name = Util.findSign(sign);
if (name != null) {
p.performCommand("ss view " + name);
} else {
Util.sudoSignsMessage(p, "&cERROR: That is not a SudoSign! &6Use: &d/ss create <name> &6instead.");
}
} else {
Util.sudoSignsMessage(p, "&cERROR: A sign was not clicked! &6Cancelling...");
}
user.setView(false);
}
final Block b = playerInteractEvent.getClickedBlock();
if (user.isCreate()) {
@EventHandler
public void onDestroy(BlockBreakEvent e) {
Player p = e.getPlayer();
if (e.getBlock().getState() instanceof Sign || e.getBlock().getState() instanceof WallSign) {
Sign sign = (Sign) e.getBlock().getState();
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
if (entry.getValue().getSign().equals(sign)) {
e.setCancelled(true);
if (p.hasPermission(Permissions.SELECT)) {
Util.sendSelectMenus(p, entry.getKey());
} else {
Util.sudoSignsMessage(p, "&cERROR: You do not have permission to destroy that sign!");
}
}
}
} else {
final BlockFace[] faces = {BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
for (BlockFace face : faces) {
Block br = e.getBlock().getRelative(face);
BlockState bs = br.getState();
if (bs instanceof Sign || bs instanceof WallSign) {
Sign sign = (Sign) bs;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
if (entry.getValue().getSign().equals(sign)) {
if (br.getBlockData() instanceof Sign) {
if (e.getBlock().equals(sign.getBlock().getRelative(BlockFace.DOWN))) {
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: You cannot destroy a block that is attached to a SudoSign!");
return;
}
} else if (br.getBlockData() instanceof WallSign) {
WallSign signData = (WallSign) sign.getBlock().getState().getBlockData();
BlockFace attached = signData.getFacing().getOppositeFace();
Block blockAttached = sign.getBlock().getRelative(attached);
if (e.getBlock().equals(blockAttached)) {
e.setCancelled(true);
Util.sudoSignsMessage(p, "&cERROR: You cannot destroy a block that is attached to a SudoSign!");
return;
}
playerInteractEvent.setCancelled(true);
create(p, user, b);
}
}
}
}
}
}
}
} else if (user.isSelectToCopy()) {
// The following events all attempt to prevent a SudoSign being broken
@EventHandler
public void onEntityExplode(EntityExplodeEvent e) {
ArrayList<Block> blocksToRemove = new ArrayList<>();
for (Block block : e.blockList()) {
if (block.getState() instanceof Sign || block.getState() instanceof WallSign) {
Sign sign = (Sign) block.getState();
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
if (entry.getValue().getSign().equals(sign)) {
blocksToRemove.add(block);
}
}
}
final BlockFace[] faces = {BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
for (BlockFace face : faces) {
BlockState b = block.getRelative(face).getState();
if (b instanceof Sign || b instanceof WallSign) {
Sign sign = (Sign) b;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
if (entry.getValue().getSign().equals(sign)) {
blocksToRemove.add(block);
}
}
}
}
}
for (Block b : blocksToRemove) {
e.blockList().remove(b);
}
}
playerInteractEvent.setCancelled(true);
selectToCopy(p, user, b);
@EventHandler
public void onBlockBurn(BlockBurnEvent e) {
final BlockFace[] faces = {BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
for (BlockFace face : faces) {
BlockState b = e.getBlock().getRelative(face).getState();
if (b instanceof Sign || b instanceof WallSign) {
Sign sign = (Sign) b;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
if (entry.getValue().getSign().equals(sign)) {
e.setCancelled(true);
}
}
}
}
}
} else if (user.isCopy()) {
@EventHandler
public void onBlockFade(BlockFadeEvent e) {
final BlockFace[] faces = {BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
for (BlockFace face : faces) {
BlockState b = e.getBlock().getRelative(face).getState();
if (b instanceof Sign || b instanceof WallSign) {
Sign sign = (Sign) b;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
if (entry.getValue().getSign().equals(sign)) {
e.setCancelled(true);
}
}
}
}
}
playerInteractEvent.setCancelled(true);
copy(p, user, b);
@EventHandler
public void onLeavesDecay(LeavesDecayEvent e) {
final BlockFace[] faces = {BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
for (BlockFace face : faces) {
BlockState b = e.getBlock().getRelative(face).getState();
if (b instanceof Sign || b instanceof WallSign) {
Sign sign = (Sign) b;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
if (entry.getValue().getSign().equals(sign)) {
e.setCancelled(true);
}
}
}
}
}
} else if (user.isEdit()) {
}
playerInteractEvent.setCancelled(true);
edit(p, user, b);
} else if (user.isDelete()) {
playerInteractEvent.setCancelled(true);
delete(p, user, b);
} else if (user.isRun()) {
playerInteractEvent.setCancelled(true);
runRemote(p, user, b);
} else if (user.isView()) {
playerInteractEvent.setCancelled(true);
view(p, user, b);
} else {
runSign(p, playerInteractEvent);
}
} else {
runSign(p, playerInteractEvent);
}
}
private void selectToCopy(Player p, SudoUser user, Block b) {
final Sign sign = Util.getSign(b);
if (sign != null) {
final String name = Util.findSign(sign);
if (name != null) {
user.setSelectToCopy(false);
p.performCommand("ss copy " + name + " " + user.getPassThru());
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: Failed to copy: that is not a SudoSign!");
}
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign wasn't clicked! &6Cancelling...");
}
user.setSelectToCopy(false);
}
private void runSign(Player p, PlayerInteractEvent e) {
final boolean condition = Util.isSignBlock(Objects.requireNonNull(e.getClickedBlock()))
&& (p.hasPermission(Permissions.SELECT) && e.getAction() == Action.RIGHT_CLICK_BLOCK
|| !p.hasPermission(Permissions.SELECT));
if (!condition) {
return;
}
final Sign sign = Util.getSign(e.getClickedBlock());
if (sign == null) {
return;
}
final String name = Util.findSign(sign);
if (name != null) {
SudoSigns.signs.get(name).executeCommands(p);
}
}
private void create(Player p, SudoUser user, Block b) {
final Sign sign = Util.getSign(b);
if (sign != null) {
final String name = Util.findSign(sign);
if (name != null) {
user.setCreate(false);
SudoSigns.signs.remove(user.getPassThru());
UtilitiesOG.trueogMessage(p, "&cERROR: That SudoSign already exists! &6Cancelling...");
return;
}
SudoSigns.signs.get(user.getPassThru()).setSign(sign);
SudoSigns.signs.get(user.getPassThru()).addLines();
if (p.hasPermission(Permissions.EDIT)) {
final SignEditor editor = new SignEditor(p, SudoSigns.signs.get(user.getPassThru()), user,
diamondBankAPI);
user.setEditor(editor);
}
SudoSigns.config.saveSign(SudoSigns.signs.get(user.getPassThru()), true, p);
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign was not clicked! Cancelling...");
user.setCreate(false);
SudoSigns.signs.remove(user.getPassThru());
}
user.setCreate(false);
}
private void copy(Player p, SudoUser user, Block b) {
final Sign newSign = Util.getSign(b);
if (newSign != null) {
final String name = Util.findSign(newSign);
if (name != null) {
user.setCopy(false);
SudoSigns.signs.remove(user.getPassThru());
UtilitiesOG.trueogMessage(p, "&cERROR: That sign is already a SudoSign! Cancelling...");
return;
}
SudoSigns.signs.get(user.getPassThru()).setSign(newSign);
SudoSigns.signs.get(user.getPassThru()).addLines();
SudoSigns.config.saveSign(SudoSigns.signs.get(user.getPassThru()), true, p);
UtilitiesOG.trueogMessage(p, "&aSign has been copied to sign &e" + user.getPassThru() + " &asuccessfully!");
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign was not clicked! &6Cancelling...");
SudoSigns.signs.remove(user.getPassThru());
}
user.setCopy(false);
}
private void runRemote(Player p, SudoUser user, Block b) {
final Sign sign = Util.getSign(b);
if (sign != null) {
final String name = Util.findSign(sign);
if (name != null) {
p.performCommand("ss run " + name);
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: That is not a SudoSign! &6Use: &d/ss create <name> &6instead.");
}
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign was not clicked! Cancelling...");
}
user.setRun(false);
}
private void edit(Player p, SudoUser user, Block b) {
final Sign sign = Util.getSign(b);
if (sign != null) {
final String name = Util.findSign(sign);
if (name != null) {
p.performCommand("ss edit " + name);
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: That is not a SudoSign! &6Use: &d/ss create <name> &6instead.");
}
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign was not clicked! Cancelling...");
}
user.setEdit(false);
}
private void delete(Player p, SudoUser user, Block b) {
final Sign sign = Util.getSign(b);
if (sign != null) {
final String name = Util.findSign(sign);
if (name != null) {
p.performCommand("ss delete " + name);
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: That is not a SudoSign!");
}
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign was not clicked! &6Cancelling...");
}
user.setDelete(false);
}
private void view(Player p, SudoUser user, Block b) {
final Sign sign = Util.getSign(b);
if (sign != null) {
final String name = Util.findSign(sign);
if (name != null) {
p.performCommand("ss view " + name);
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: That is not a SudoSign! &6Use: &d/ss create <name> &6instead.");
}
} else {
UtilitiesOG.trueogMessage(p, "&cERROR: A sign was not clicked! &6Cancelling...");
}
user.setView(false);
}
@EventHandler
public void onDestroy(BlockBreakEvent blockBreakEvent) {
final Player p = blockBreakEvent.getPlayer();
final Sign sign = Util.getSign(blockBreakEvent.getBlock());
if (sign != null) {
SudoSigns.signs.entrySet().stream()
.filter(entry -> Util.sameBlockLocation(entry.getValue(), sign.getLocation())).forEach(entry ->
{
blockBreakEvent.setCancelled(true);
if (p.hasPermission(Permissions.SELECT)) {
Util.sendSelectMenus(p, entry.getKey());
} else {
Util.sudoSignsPermissionsError(p);
}
});
} else {
final BlockFace[] faces = { BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH,
BlockFace.WEST };
for (BlockFace face : faces) {
final Block br = blockBreakEvent.getBlock().getRelative(face);
final BlockState bs = br.getState();
if (Util.isSignState(bs)) {
final Sign nearbySign = (Sign) bs;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
if (Util.sameBlockLocation(entry.getValue(), nearbySign.getLocation())) {
if (br.getBlockData() instanceof Sign) {
if (blockBreakEvent.getBlock()
.equals(nearbySign.getBlock().getRelative(BlockFace.DOWN)))
{
blockBreakEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p,
"&cERROR: You cannot destroy a block that is attached to a SudoSign!");
return;
}
} else if (br.getBlockData() instanceof WallSign) {
final WallSign signData = (WallSign) nearbySign.getBlock().getState().getBlockData();
final BlockFace attached = signData.getFacing().getOppositeFace();
final Block blockAttached = nearbySign.getBlock().getRelative(attached);
if (blockBreakEvent.getBlock().equals(blockAttached)) {
blockBreakEvent.setCancelled(true);
UtilitiesOG.trueogMessage(p,
"&cERROR: You cannot destroy a block that is attached to a SudoSign!");
return;
}
}
}
}
}
}
}
}
// The following events all attempts to prevent a SudoSign from being broken.
@EventHandler
public void onEntityExplode(EntityExplodeEvent entityExplodeEvent) {
final ArrayList<Block> blocksToRemove = new ArrayList<>();
entityExplodeEvent.blockList().forEach(block -> {
final Sign sign = Util.getSign(block);
if (sign != null) {
SudoSigns.signs.entrySet().stream()
.filter(entry -> Util.sameBlockLocation(entry.getValue(), sign.getLocation()))
.forEach(entry -> blocksToRemove.add(block));
}
final BlockFace[] faces = { BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH,
BlockFace.WEST };
for (BlockFace face : faces) {
final BlockState b = block.getRelative(face).getState();
if (Util.isSignState(b)) {
final Sign nearbySign = (Sign) b;
SudoSigns.signs.entrySet().stream()
.filter(entry -> Util.sameBlockLocation(entry.getValue(), nearbySign.getLocation()))
.forEach(entry -> blocksToRemove.add(block));
}
}
});
blocksToRemove.forEach(b -> entityExplodeEvent.blockList().remove(b));
}
@EventHandler
public void onBlockBurn(BlockBurnEvent blockBurnEvent) {
final BlockFace[] faces = { BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
for (BlockFace face : faces) {
final BlockState b = blockBurnEvent.getBlock().getRelative(face).getState();
if (Util.isSignState(b)) {
final Sign sign = (Sign) b;
SudoSigns.signs.entrySet().stream()
.filter(entry -> Util.sameBlockLocation(entry.getValue(), sign.getLocation()))
.forEach(entry -> blockBurnEvent.setCancelled(true));
}
}
}
@EventHandler
public void onBlockFade(BlockFadeEvent blockFadeEvent) {
final BlockFace[] faces = { BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
for (BlockFace face : faces) {
final BlockState b = blockFadeEvent.getBlock().getRelative(face).getState();
if (Util.isSignState(b)) {
final Sign sign = (Sign) b;
SudoSigns.signs.entrySet().stream()
.filter(entry -> Util.sameBlockLocation(entry.getValue(), sign.getLocation()))
.forEach(entry -> blockFadeEvent.setCancelled(true));
}
}
}
@EventHandler
public void onLeavesDecay(LeavesDecayEvent leavesDecayEvent) {
final BlockFace[] faces = { BlockFace.UP, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
for (BlockFace face : faces) {
final BlockState b = leavesDecayEvent.getBlock().getRelative(face).getState();
if (Util.isSignState(b)) {
final Sign sign = (Sign) b;
SudoSigns.signs.entrySet().stream()
.filter(entry -> Util.sameBlockLocation(entry.getValue(), sign.getLocation()))
.forEach(entry -> leavesDecayEvent.setCancelled(true));
}
}
}
}
@@ -22,146 +22,145 @@ import dev.mylesmor.sudosigns.data.SudoUser;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.kyori.adventure.text.TextComponent;
import net.trueog.utilitiesog.UtilitiesOG;
public class CommandOptionsMenu {
private Inventory menu;
private SudoUser su;
private SudoSign sign;
private SignCommand sc;
private Player p;
private SignEditor editor;
private Inventory menu;
private final SudoUser su;
private final SudoSign sign;
private final SignCommand sc;
private final Player p;
private final SignEditor editor;
CommandOptionsMenu(SudoUser su, Player p, SudoSign sign, ItemStack item, SignEditor editor) {
CommandOptionsMenu(SudoUser su, Player p, SudoSign sign, ItemStack item, SignEditor editor) {
this.su = su;
this.sign = sign;
this.p = p;
this.editor = editor;
this.sc = findSignCommand(item);
this.su = su;
this.sign = sign;
this.p = p;
this.editor = editor;
this.sc = findSignCommand(item);
if (this.sc == null) {
if (this.sc == null) {
editor.goToCommands();
editor.goToCommands();
return;
return;
}
}
}
}
public void goToCommandOptionsMenu() {
public void goToCommandOptionsMenu() {
createCommandOptionsMenu();
p.openInventory(menu);
createCommandOptionsMenu();
p.openInventory(menu);
}
}
private SignCommand findSignCommand(ItemStack item) {
private SignCommand findSignCommand(ItemStack item) {
NamespacedKey key = new NamespacedKey(SudoSigns.sudoSignsPlugin, "command-number");
ItemMeta itemMeta = item.getItemMeta();
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
final NamespacedKey key = new NamespacedKey(SudoSigns.sudoSignsPlugin, "command-number");
final ItemMeta itemMeta = item.getItemMeta();
final PersistentDataContainer container = itemMeta.getPersistentDataContainer();
if (container.has(key, PersistentDataType.INTEGER)) {
if (container.has(key, PersistentDataType.INTEGER)) {
int foundValue = container.get(key, PersistentDataType.INTEGER);
final int foundValue = container.get(key, PersistentDataType.INTEGER);
return sign.getSignCommandByNumber(foundValue);
return sign.getSignCommandByNumber(foundValue);
}
}
return null;
return null;
}
}
private void createCommandOptionsMenu() {
private void createCommandOptionsMenu() {
Inventory playersInventory = p.getInventory();
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
TextComponent nameHandler = Util.legacySerializerAnyCase("Command options: /" + sc.getCommand());
final Inventory playersInventory = p.getInventory();
final InventoryHolder inventoryContainer = playersInventory.getHolder(false);
final TextComponent nameHandler = UtilitiesOG.trueogColorize("Command options: /" + sc.getCommand());
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
}
}
List<String> lore = new ArrayList<>();
ItemStack arrow = new ItemStack(Material.ARROW);
ItemMeta arrowMeta = arrow.getItemMeta();
final List<String> lore = new ArrayList<>();
final ItemStack arrow = new ItemStack(Material.ARROW);
final ItemMeta arrowMeta = arrow.getItemMeta();
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
arrowMeta.displayName(UtilitiesOG.trueogColorize("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
ItemStack clock = new ItemStack(Material.CLOCK);
ItemMeta clockMeta = clock.getItemMeta();
final ItemStack clock = new ItemStack(Material.CLOCK);
final ItemMeta clockMeta = clock.getItemMeta();
lore.add("&eChange the delay after which the command executes");
clockMeta.displayName(Util.legacySerializerAnyCase("&r&dChange Delay"));
clockMeta.lore(Util.convertToTextComponents(lore));
clock.setItemMeta(clockMeta);
lore.add("&eChange the delay after which the command executes");
clockMeta.displayName(UtilitiesOG.trueogColorize("&r&dChange Delay"));
clockMeta.lore(Util.convertToTextComponents(lore));
clock.setItemMeta(clockMeta);
ItemStack barrier = new ItemStack(Material.BARRIER);
ItemMeta barrierMeta = barrier.getItemMeta();
final ItemStack barrier = new ItemStack(Material.BARRIER);
final ItemMeta barrierMeta = barrier.getItemMeta();
barrierMeta.displayName(Util.legacySerializerAnyCase("&r&cDelete Command"));
barrier.setItemMeta(barrierMeta);
barrierMeta.displayName(UtilitiesOG.trueogColorize("&r&cDelete Command"));
barrier.setItemMeta(barrierMeta);
if (p.hasPermission(Permissions.COMMAND_OPTIONS) && p.hasPermission(Permissions.DELETE_COMMAND)) {
if (p.hasPermission(Permissions.COMMAND_OPTIONS) && p.hasPermission(Permissions.DELETE_COMMAND)) {
menu.setItem(20, clock);
menu.setItem(24, barrier);
menu.setItem(20, clock);
menu.setItem(24, barrier);
}
else {
} else {
menu.setItem(22, clock);
menu.setItem(22, clock);
}
}
menu.setItem(36, arrow);
menu.setItem(36, arrow);
}
}
public void addDelay() {
public void addDelay() {
p.closeInventory();
p.closeInventory();
Util.sudoSignsMessage(p, "&6Please enter the delay in seconds. To cancel, type &cCANCEL&6.");
UtilitiesOG.trueogMessage(p, "&6Please enter the delay in seconds. To cancel, type &cCANCEL&6.");
su.addTextInput(PlayerInput.COMMAND_DELAY);
su.addTextInput(PlayerInput.COMMAND_DELAY);
}
}
public void setDelay(double delay) {
public void setDelay(double delay) {
double oldDelay = sc.getDelay();
sc.setDelay(delay * 1000);
final double oldDelay = sc.getDelay();
sc.setDelay(delay * 1000);
SudoSigns.config.deleteCommand(sign, sc, sc.getType(), oldDelay);
SudoSigns.config.addCommand(sign, sc, sc.getType());
SudoSigns.config.deleteCommand(sign, sc, sc.getType(), oldDelay);
SudoSigns.config.addCommand(sign, sc, sc.getType());
}
}
public void deleteCommand() {
public void deleteCommand() {
if (sc.getType() == PlayerInput.CONSOLE_COMMAND) {
if (sc.getType() == PlayerInput.CONSOLE_COMMAND) {
SudoSigns.config.deleteCommand(sign, sc, PlayerInput.CONSOLE_COMMAND, sc.getDelay());
sign.deleteConsoleCommand(sc);
SudoSigns.config.deleteCommand(sign, sc, PlayerInput.CONSOLE_COMMAND, sc.getDelay());
sign.deleteConsoleCommand(sc);
}
else if (sc.getType() == PlayerInput.PLAYER_COMMAND) {
} else if (sc.getType() == PlayerInput.PLAYER_COMMAND) {
SudoSigns.config.deleteCommand(sign, sc, PlayerInput.PLAYER_COMMAND, sc.getDelay());
sign.deletePlayerCommand(sc);
SudoSigns.config.deleteCommand(sign, sc, PlayerInput.PLAYER_COMMAND, sc.getDelay());
sign.deletePlayerCommand(sc);
}
}
editor.goToCommands();
editor.goToCommands();
}
}
}
@@ -22,240 +22,255 @@ import dev.mylesmor.sudosigns.data.SudoUser;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.kyori.adventure.text.TextComponent;
import net.trueog.utilitiesog.UtilitiesOG;
public class CommandsMenu {
private Inventory menu;
private Player p;
private SudoSign sign;
private SignEditor editor;
private SudoUser su;
private Inventory menu;
private final Player p;
private final SudoSign sign;
private final SignEditor editor;
private final SudoUser su;
public CommandsMenu(SudoUser su, Player p, SudoSign sign, SignEditor editor) {
public CommandsMenu(SudoUser su, Player p, SudoSign sign, SignEditor editor) {
this.su = su;
this.sign = sign;
this.editor = editor;
this.p = p;
this.su = su;
this.sign = sign;
this.editor = editor;
this.p = p;
}
}
public void goToCommandsMenu() {
public void goToCommandsMenu() {
createCommandsMenu();
createCommandsMenu();
p.openInventory(menu);
p.openInventory(menu);
}
}
private void createCommandsMenu() {
private void createCommandsMenu() {
Inventory playersInventory = p.getInventory();
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
TextComponent nameHandler = Util.legacySerializerAnyCase("Commands: " + sign.getName());
final Inventory playersInventory = p.getInventory();
final InventoryHolder inventoryContainer = playersInventory.getHolder(false);
final TextComponent nameHandler = UtilitiesOG.trueogColorize("Commands: " + sign.getName());
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
}
}
ItemStack arrow = new ItemStack(Material.ARROW);
ItemMeta arrowMeta = arrow.getItemMeta();
final ItemStack arrow = new ItemStack(Material.ARROW);
final ItemMeta arrowMeta = arrow.getItemMeta();
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
arrowMeta.displayName(UtilitiesOG.trueogColorize("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
if (p.hasPermission(Permissions.ADD_COMMAND)) {
if (p.hasPermission(Permissions.ADD_COMMAND)) {
ItemStack bookQuill = new ItemStack(Material.WRITABLE_BOOK);
ItemMeta bqMeta = bookQuill.getItemMeta();
final ItemStack bookQuill = new ItemStack(Material.WRITABLE_BOOK);
final ItemMeta bqMeta = bookQuill.getItemMeta();
bqMeta.displayName(Util.legacySerializerAnyCase("&r&2Add new command"));
bookQuill.setItemMeta(bqMeta);
bqMeta.displayName(UtilitiesOG.trueogColorize("&r&2Add new command"));
bookQuill.setItemMeta(bqMeta);
menu.setItem(40, bookQuill);
menu.setItem(40, bookQuill);
}
}
ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
final ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
final ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
cmdBlockMeta.displayName(Util.legacySerializerAnyCase("&r&5Console Commands"));
cmdBlock.setItemMeta(cmdBlockMeta);
cmdBlockMeta.displayName(UtilitiesOG.trueogColorize("&r&5Console Commands"));
cmdBlock.setItemMeta(cmdBlockMeta);
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
ItemMeta headMeta = head.getItemMeta();
final ItemStack head = new ItemStack(Material.PLAYER_HEAD);
final ItemMeta headMeta = head.getItemMeta();
headMeta.displayName(Util.legacySerializerAnyCase("&r&d Player Commands"));
head.setItemMeta(headMeta);
headMeta.displayName(UtilitiesOG.trueogColorize("&r&d Player Commands"));
head.setItemMeta(headMeta);
List<String> lore = new ArrayList<>();
NamespacedKey key = new NamespacedKey(SudoSigns.sudoSignsPlugin, "command-number");
final List<String> lore = new ArrayList<>();
final NamespacedKey key = new NamespacedKey(SudoSigns.sudoSignsPlugin, "command-number");
ArrayList<SignCommand> orderedSignCommands = sign.getPlayerCommands();
orderedSignCommands.sort(Comparator.comparing(SignCommand::getDelay));
ArrayList<SignCommand> orderedSignCommands = sign.getPlayerCommands();
orderedSignCommands.sort(Comparator.comparing(SignCommand::getDelay));
// Populates spaces with commands.
int i = 1;
for (SignCommand sc : orderedSignCommands) {
// Populates spaces with commands.
int i = 1;
for (SignCommand sc : orderedSignCommands) {
if (i > 26) break;
if (i > 26) {
ItemStack book = new ItemStack(Material.BOOK);
ItemMeta bookMeta = book.getItemMeta();
break;
lore.add("&6Player Command");
bookMeta.displayName(Util.legacySerializerAnyCase("&r&6/" + sc.getCommand()));
lore.add("&6Delay: &e" + (sc.getDelay() / 1000) + "s");
}
if (p.hasPermission(Permissions.COMMAND_OPTIONS)) {
final ItemStack book = new ItemStack(Material.BOOK);
final ItemMeta bookMeta = book.getItemMeta();
lore.add("");
lore.add("&2Click for options!");
lore.add("&6Player Command");
bookMeta.displayName(UtilitiesOG.trueogColorize("&r&6/" + sc.getCommand()));
lore.add("&6Delay: &e" + (sc.getDelay() / 1000) + "s");
}
if (p.hasPermission(Permissions.COMMAND_OPTIONS)) {
bookMeta.getPersistentDataContainer().set(key, PersistentDataType.INTEGER, sc.getNumber());
bookMeta.lore(Util.convertToTextComponents(lore));
lore.add("");
lore.add("&2Click for options!");
lore.clear();
book.setItemMeta(bookMeta);
}
if (i == 9) i++;
bookMeta.getPersistentDataContainer().set(key, PersistentDataType.INTEGER, sc.getNumber());
bookMeta.lore(Util.convertToTextComponents(lore));
menu.setItem(i, book);
lore.clear();
book.setItemMeta(bookMeta);
i++;
if (i == 9) {
}
i++;
orderedSignCommands = sign.getConsoleCommands();
orderedSignCommands.sort(Comparator.comparing(SignCommand::getDelay));
}
i = 19;
for (SignCommand sc : orderedSignCommands) {
menu.setItem(i, book);
if (i > 35) break;
i++;
ItemStack book = new ItemStack(Material.BOOK);
ItemMeta bookMeta = book.getItemMeta();
}
lore.add("&6Console Command");
bookMeta.displayName(Util.legacySerializerAnyCase("&r&6/" + sc.getCommand()));
lore.add("&6Delay: &e" + (sc.getDelay() / 1000) + "s");
orderedSignCommands = sign.getConsoleCommands();
orderedSignCommands.sort(Comparator.comparing(SignCommand::getDelay));
if (p.hasPermission(Permissions.COMMAND_OPTIONS)) {
i = 19;
for (SignCommand sc : orderedSignCommands) {
lore.add("");
lore.add("&2Click for options!");
if (i > 35) {
}
break;
bookMeta.getPersistentDataContainer().set(key, PersistentDataType.INTEGER, sc.getNumber());
bookMeta.lore(Util.convertToTextComponents(lore));
}
lore.clear();
book.setItemMeta(bookMeta);
final ItemStack book = new ItemStack(Material.BOOK);
final ItemMeta bookMeta = book.getItemMeta();
if (i == 27) i++;
lore.add("&6Console Command");
bookMeta.displayName(UtilitiesOG.trueogColorize("&r&6/" + sc.getCommand()));
lore.add("&6Delay: &e" + (sc.getDelay() / 1000) + "s");
menu.setItem(i, book);
if (p.hasPermission(Permissions.COMMAND_OPTIONS)) {
i++;
lore.add("");
lore.add("&2Click for options!");
}
}
menu.setItem(0, head);
menu.setItem(9, head);
menu.setItem(18, cmdBlock);
menu.setItem(27, cmdBlock);
menu.setItem(36, arrow);
bookMeta.getPersistentDataContainer().set(key, PersistentDataType.INTEGER, sc.getNumber());
bookMeta.lore(Util.convertToTextComponents(lore));
}
lore.clear();
book.setItemMeta(bookMeta);
public void prepareCommand() {
if (i == 27) {
Inventory playersInventory = p.getInventory();
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
TextComponent nameHandler = Util.legacySerializerAnyCase("Player or Console command?");
i++;
Inventory choiceInv = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < choiceInv.getSize(); i++) {
}
choiceInv.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
menu.setItem(i, book);
}
i++;
ItemStack arrow = new ItemStack(Material.ARROW);
ItemMeta arrowMeta = arrow.getItemMeta();
}
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
menu.setItem(0, head);
menu.setItem(9, head);
menu.setItem(18, cmdBlock);
menu.setItem(27, cmdBlock);
menu.setItem(36, arrow);
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
ItemMeta headMeta = head.getItemMeta();
List<String> lore = new ArrayList<>();
}
lore.add("&cThe player must have permission to run the command!");
headMeta.displayName(Util.legacySerializerAnyCase("&r&dPlayer Command"));
headMeta.lore(Util.convertToTextComponents(lore));
head.setItemMeta(headMeta);
public void prepareCommand() {
ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
cmdBlockMeta.displayName(Util.legacySerializerAnyCase("&r&dConsole Command"));
cmdBlock.setItemMeta(cmdBlockMeta);
final Inventory playersInventory = p.getInventory();
final InventoryHolder inventoryContainer = playersInventory.getHolder(false);
final TextComponent nameHandler = UtilitiesOG.trueogColorize("Player or Console command?");
if (p.hasPermission(Permissions.CONSOLE_COMMAND)) {
final Inventory choiceInv = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < choiceInv.getSize(); i++) {
choiceInv.setItem(21, head);
choiceInv.setItem(23, cmdBlock);
choiceInv.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
}
else {
}
choiceInv.setItem(22, head);
final ItemStack arrow = new ItemStack(Material.ARROW);
final ItemMeta arrowMeta = arrow.getItemMeta();
}
arrowMeta.displayName(UtilitiesOG.trueogColorize("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
choiceInv.setItem(36, arrow);
final ItemStack head = new ItemStack(Material.PLAYER_HEAD);
final ItemMeta headMeta = head.getItemMeta();
final List<String> lore = new ArrayList<>();
editor.setCurrentPage(GUIPage.CHOOSE_COMMAND);
p.openInventory(choiceInv);
lore.add("&cThe player must have permission to run the command!");
headMeta.displayName(UtilitiesOG.trueogColorize("&r&dPlayer Command"));
headMeta.lore(Util.convertToTextComponents(lore));
head.setItemMeta(headMeta);
}
final ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
final ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
cmdBlockMeta.displayName(UtilitiesOG.trueogColorize("&r&dConsole Command"));
cmdBlock.setItemMeta(cmdBlockMeta);
if (p.hasPermission(Permissions.CONSOLE_COMMAND)) {
public void chooseCommandType(PlayerInput type) {
choiceInv.setItem(21, head);
choiceInv.setItem(23, cmdBlock);
p.closeInventory();
} else {
Util.sudoSignsMessage(p, "&6Please enter the full command in chat with the beginning &e/&6. The placeholder &e%PLAYER% &6will be replaced with the player who clicked the sign. To cancel, type &cCANCEL&6.");
su.addTextInput(type);
choiceInv.setItem(22, head);
}
}
public void addCommand(String cmd, PlayerInput type) {
choiceInv.setItem(36, arrow);
SignCommand command = new SignCommand(sign.getNextCommandNumber(), cmd, 0, type);
switch (type) {
case CONSOLE_COMMAND:
sign.addConsoleCommand(command);
break;
case PLAYER_COMMAND:
sign.addPlayerCommand(command);
break;
default:
break;
}
editor.setCurrentPage(GUIPage.CHOOSE_COMMAND);
p.openInventory(choiceInv);
SudoSigns.config.addCommand(sign, command, type);
}
Util.sudoSignsMessage(p, "&aCommand added successfully!");
editor.goToCommands();
public void chooseCommandType(PlayerInput type) {
}
p.closeInventory();
UtilitiesOG.trueogMessage(p,
"&6Please enter the full command in chat with the beginning &e/&6. The placeholder &e%PLAYER% &6will be replaced with the player who clicked the sign. To cancel, type &cCANCEL&6.");
su.addTextInput(type);
}
public void addCommand(String cmd, PlayerInput type) {
final SignCommand command = new SignCommand(sign.getNextCommandNumber(), cmd, 0, type);
switch (type) {
case CONSOLE_COMMAND -> sign.addConsoleCommand(command);
case PLAYER_COMMAND -> sign.addPlayerCommand(command);
default -> {
}
}
SudoSigns.config.addCommand(sign, command, type);
UtilitiesOG.trueogMessage(p, "&aCommand added successfully!");
editor.goToCommands();
}
}
@@ -1,12 +1,5 @@
package dev.mylesmor.sudosigns.menus;
public enum GUIPage {
MAIN,
COMMANDS,
PERMISSIONS,
CHOOSE_PERMISSION,
CHOOSE_COMMAND,
MESSAGES,
COMMAND_OPTIONS,
MESSAGE_OPTIONS
}
MAIN, COMMANDS, PERMISSIONS, CHOOSE_PERMISSION, CHOOSE_COMMAND, MESSAGES, COMMAND_OPTIONS, MESSAGE_OPTIONS
}
@@ -17,367 +17,379 @@ import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.kyori.adventure.text.TextComponent;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
import net.trueog.utilitiesog.UtilitiesOG;
public class MainMenu {
private Inventory menu;
private SudoSign sign;
private Player p;
private int lineNumber = 0;
private Inventory menu;
private final SudoSign sign;
private final Player p;
private int lineNumber = 0;
private final DiamondBankAPIJava diamondBankAPI;
public MainMenu(Player p, SudoSign sign, SignEditor editor) {
public MainMenu(Player p, SudoSign sign, SignEditor editor, DiamondBankAPIJava diamondBankAPI) {
this.sign = sign;
this.p = p;
this.sign = sign;
this.p = p;
this.diamondBankAPI = diamondBankAPI;
}
}
public void goToMainMenu() {
public void goToMainMenu() {
createMainMenu();
p.openInventory(menu);
createMainMenu();
p.openInventory(menu);
}
}
private void createMainMenu() {
private void createMainMenu() {
ArrayList<ItemStack> items = new ArrayList<>();
final ArrayList<ItemStack> items = new ArrayList<>();
Inventory playersInventory = p.getInventory();
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
TextComponent nameHandler = Util.legacySerializerAnyCase("&r&2Editing: &e" + sign.getName());
final Inventory playersInventory = p.getInventory();
final InventoryHolder inventoryContainer = playersInventory.getHolder(false);
final TextComponent nameHandler = UtilitiesOG.trueogColorize("&r&2Editing: &e" + sign.getName());
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
List<String> lore = new ArrayList<>();
lore.add(" ");
menu.getItem(i).lore(Util.convertToTextComponents(lore));
final List<String> lore = new ArrayList<>();
lore.add(" ");
menu.getItem(i).lore(lore.stream().map(UtilitiesOG::trueogColorize).toList());
}
}
if (p.hasPermission(Permissions.RENAME)) {
if (p.hasPermission(Permissions.RENAME)) {
ItemStack nametag = new ItemStack(Material.NAME_TAG);
ItemMeta ntMeta = nametag.getItemMeta();
final ItemStack nametag = new ItemStack(Material.NAME_TAG);
final ItemMeta ntMeta = nametag.getItemMeta();
ntMeta.displayName(Util.legacySerializerAnyCase("&r&5Rename Sign"));
ntMeta.displayName(UtilitiesOG.trueogColorize("&r&5Rename Sign"));
List<String> lore = new ArrayList<>();
lore.add("&eChange the text that refers");
lore.add("&eto this sign in the config");
lore.add("&efile and in commands.");
final List<String> lore = new ArrayList<>();
lore.add("&eChange the text that refers");
lore.add("&eto this sign in the config");
lore.add("&efile and in commands.");
ntMeta.lore(Util.convertToTextComponents(lore));
nametag.setItemMeta(ntMeta);
ntMeta.lore(lore.stream().map(UtilitiesOG::trueogColorize).toList());
nametag.setItemMeta(ntMeta);
items.add(nametag);
items.add(nametag);
}
}
if (p.hasPermission(Permissions.EDIT_TEXT)) {
if (p.hasPermission(Permissions.EDIT_TEXT)) {
ItemStack book = new ItemStack(Material.WRITABLE_BOOK);
ItemMeta bookMeta = book.getItemMeta();
final ItemStack book = new ItemStack(Material.WRITABLE_BOOK);
final ItemMeta bookMeta = book.getItemMeta();
bookMeta.displayName(Util.legacySerializerAnyCase("&r&5Edit Sign Text"));
bookMeta.displayName(UtilitiesOG.trueogColorize("&r&5Edit Sign Text"));
List<String> lore = new ArrayList<>();
lore.add("&eChange the text that displays");
lore.add("&eon the sign itself. Colored");
lore.add("&esigns require another plugin.");
final List<String> lore = new ArrayList<>();
lore.add("&eChange the text that displays");
lore.add("&eon the sign itself. Colored");
lore.add("&esigns require another plugin.");
bookMeta.lore(Util.convertToTextComponents(lore));
book.setItemMeta(bookMeta);
bookMeta.lore(lore.stream().map(UtilitiesOG::trueogColorize).toList());
book.setItemMeta(bookMeta);
items.add(book);
items.add(book);
}
}
if (p.hasPermission(Permissions.VIEW_PERMISSION)) {
if (p.hasPermission(Permissions.VIEW_PERMISSION)) {
ItemStack barrier = new ItemStack(Material.BARRIER);
ItemMeta barrierMeta = barrier.getItemMeta();
final ItemStack barrier = new ItemStack(Material.BARRIER);
final ItemMeta barrierMeta = barrier.getItemMeta();
barrierMeta.displayName(Util.legacySerializerAnyCase("&r&dPermissions"));
barrierMeta.displayName(UtilitiesOG.trueogColorize("&r&dPermissions"));
List<String> lore = new ArrayList<>();
lore.add("&ePlayers must have all permissions");
lore.add("&elisted in this section to be able");
lore.add("&eto use the sign.");
final List<String> lore = new ArrayList<>();
lore.add("&ePlayers must have all permissions");
lore.add("&elisted in this section to be able");
lore.add("&eto use the sign.");
barrierMeta.lore(Util.convertToTextComponents(lore));
barrier.setItemMeta(barrierMeta);
barrierMeta.lore(lore.stream().map(UtilitiesOG::trueogColorize).toList());
barrier.setItemMeta(barrierMeta);
items.add(barrier);
items.add(barrier);
}
}
if (p.hasPermission(Permissions.VIEW_COMMAND)) {
if (p.hasPermission(Permissions.VIEW_COMMAND)) {
ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
final ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
final ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("&eCommands listed here will be executed");
lore.add("&ewhen a player uses the sign.");
final List<String> lore = new ArrayList<>();
lore.add("&eCommands listed here will be executed");
lore.add("&ewhen a player uses the sign.");
cmdBlockMeta.lore(Util.convertToTextComponents(lore));
cmdBlockMeta.displayName(Util.legacySerializerAnyCase("&r&5Commands"));
cmdBlock.setItemMeta(cmdBlockMeta);
cmdBlockMeta.lore(lore.stream().map(UtilitiesOG::trueogColorize).toList());
cmdBlockMeta.displayName(UtilitiesOG.trueogColorize("&r&5Commands"));
cmdBlock.setItemMeta(cmdBlockMeta);
items.add(cmdBlock);
items.add(cmdBlock);
}
}
if (p.hasPermission(Permissions.VIEW_MESSAGE)) {
if (p.hasPermission(Permissions.VIEW_MESSAGE)) {
ItemStack signBlock = new ItemStack(Material.OAK_SIGN);
ItemMeta signMeta = signBlock.getItemMeta();
final ItemStack signBlock = new ItemStack(Material.OAK_SIGN);
final ItemMeta signMeta = signBlock.getItemMeta();
signMeta.displayName(Util.legacySerializerAnyCase("&r&5Messages"));
signMeta.displayName(UtilitiesOG.trueogColorize("&r&5Messages"));
List<String> lore = new ArrayList<>();
lore.add("&eMessages listed here will be shown");
lore.add("&eto the player when they use the sign.");
final List<String> lore = new ArrayList<>();
lore.add("&eMessages listed here will be shown");
lore.add("&eto the player when they use the sign.");
signMeta.lore(Util.convertToTextComponents(lore));
signBlock.setItemMeta(signMeta);
signMeta.lore(lore.stream().map(UtilitiesOG::trueogColorize).toList());
signBlock.setItemMeta(signMeta);
items.add(signBlock);
items.add(signBlock);
}
}
if (SudoSigns.econ != null) {
final boolean condition = diamondBankAPI != null && p.hasPermission(Permissions.VIEW_PRICE);
if (condition) {
if (p.hasPermission(Permissions.VIEW_PRICE)) {
final ItemStack goldNugget = new ItemStack(Material.GOLD_NUGGET);
final ItemMeta goldNuggetItemMeta = goldNugget.getItemMeta();
if (SudoSigns.econ != null) {
final List<String> lore = new ArrayList<>();
lore.add("&eThe cost to use this sign.");
lore.add("&e");
ItemStack goldNugget = new ItemStack(Material.GOLD_NUGGET);
ItemMeta goldNuggetItemMeta = goldNugget.getItemMeta();
if (!SudoSigns.getPlugin().getConfig().getBoolean("config.currency-symbol-in-front")) {
List<String> lore = new ArrayList<>();
lore.add("&eThe cost to use this sign.");
lore.add("&e");
if (Util.priceIsInteger()) {
if(! SudoSigns.getPlugin().getConfig().getBoolean("config.currency-symbol-in-front")) {
if (sign.getPriceAsInteger() == 1) {
if(Util.priceIsInteger()) {
lore.add("&e" + sign.getPriceAsInteger()
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular"));
if (sign.getPriceAsInteger() == 1) {
} else {
lore.add("&e" + sign.getPriceAsInteger() + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular"));
lore.add("&e" + sign.getPriceAsInteger()
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural"));
}
else {
}
lore.add("&e" + sign.getPriceAsInteger() + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural"));
} else {
}
if (sign.getPriceAsDouble() == 1.0) {
}
else {
lore.add("&e" + sign.getPriceAsDouble()
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular"));
if (sign.getPriceAsDouble() == 1.0) {
} else {
lore.add("&e" + sign.getPriceAsDouble() + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular"));
lore.add("&e" + sign.getPriceAsDouble()
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural"));
}
else {
}
lore.add("&e" + sign.getPriceAsDouble() + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural"));
}
}
} else {
}
if (Util.priceIsInteger()) {
}
else {
if (sign.getPriceAsInteger() == 1) {
if(Util.priceIsInteger()) {
lore.add(SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e"
+ sign.getPriceAsInteger());
if (sign.getPriceAsInteger() == 1) {
} else {
lore.add(SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e" + sign.getPriceAsInteger());
lore.add(SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e"
+ sign.getPriceAsInteger());
}
else {
}
lore.add(SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e" + sign.getPriceAsInteger());
} else {
}
if (sign.getPriceAsDouble() == 1.0) {
}
else {
lore.add(SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e"
+ sign.getPriceAsDouble());
if (sign.getPriceAsDouble() == 1.0) {
} else {
lore.add(SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e" + sign.getPriceAsDouble());
lore.add(SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e"
+ sign.getPriceAsDouble());
}
else {
}
lore.add(SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e" + sign.getPriceAsDouble());
}
}
}
}
if (p.hasPermission(Permissions.SET_PRICE)) {
}
lore.add("&e");
lore.add("&aClick to edit!");
if (p.hasPermission(Permissions.SET_PRICE)) {
}
lore.add("&e");
lore.add("&aClick to edit!");
goldNuggetItemMeta.lore(lore.stream().map(UtilitiesOG::trueogColorize).toList());
goldNuggetItemMeta.displayName(UtilitiesOG.trueogColorize("&r&dPrice"));
goldNugget.setItemMeta(goldNuggetItemMeta);
}
items.add(goldNugget);
goldNuggetItemMeta.lore(Util.convertToTextComponents(lore));
goldNuggetItemMeta.displayName(Util.legacySerializerAnyCase("&r&dPrice"));
goldNugget.setItemMeta(goldNuggetItemMeta);
}
items.add(goldNugget);
}
switch (items.size()) {
}
case 6:
menu.setItem(11, items.get(0));
menu.setItem(13, items.get(1));
menu.setItem(15, items.get(2));
menu.setItem(29, items.get(3));
menu.setItem(31, items.get(4));
menu.setItem(33, items.get(5));
case 5:
menu.setItem(11, items.get(0));
menu.setItem(13, items.get(1));
menu.setItem(15, items.get(2));
menu.setItem(29, items.get(3));
menu.setItem(31, items.get(4));
case 4:
menu.setItem(11, items.get(0));
menu.setItem(13, items.get(1));
menu.setItem(15, items.get(2));
menu.setItem(29, items.get(3));
break;
case 3:
menu.setItem(20, items.get(0));
menu.setItem(22, items.get(1));
menu.setItem(24, items.get(2));
break;
case 2:
menu.setItem(21, items.get(0));
menu.setItem(23, items.get(1));
break;
case 1:
menu.setItem(22, items.get(0));
break;
}
}
switch (items.size()) {
case 6:
menu.setItem(11, items.get(0));
menu.setItem(13, items.get(1));
menu.setItem(15, items.get(2));
menu.setItem(29, items.get(3));
menu.setItem(31, items.get(4));
menu.setItem(33, items.get(5));
case 5:
menu.setItem(11, items.get(0));
menu.setItem(13, items.get(1));
menu.setItem(15, items.get(2));
menu.setItem(29, items.get(3));
menu.setItem(31, items.get(4));
case 4:
menu.setItem(11, items.get(0));
menu.setItem(13, items.get(1));
menu.setItem(15, items.get(2));
menu.setItem(29, items.get(3));
break;
case 3:
menu.setItem(20, items.get(0));
menu.setItem(22, items.get(1));
menu.setItem(24, items.get(2));
break;
case 2:
menu.setItem(21, items.get(0));
menu.setItem(23, items.get(1));
break;
case 1:
menu.setItem(22, items.get(0));
break;
}
}
public void prepareSetPrice() {
p.closeInventory();
Util.sudoSignsMessage(p, "&6Please enter the price to use the sign! Type &cCANCEL &6to cancel the operation.");
SudoSigns.users.get(p.getUniqueId()).addTextInput(PlayerInput.SET_PRICE);
}
public void setPriceAsDouble(double price) {
sign.setPriceAsDouble(price);
SudoSigns.config.setPrice(sign.getName(), price);
if(! SudoSigns.getPlugin().getConfig().getBoolean("config.currency-symbol-in-front")) {
if (sign.getPriceAsDouble() == 1.0) {
Util.sudoSignsMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: &e" + price + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&6.");
}
else {
Util.sudoSignsMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: &e" + price + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&6.");
}
}
else {
if (sign.getPriceAsInteger() == 1) {
Util.sudoSignsMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: " + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e" + price + "&6.");
}
else {
Util.sudoSignsMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: " + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e" + price + "&6.");
}
}
}
public void setPriceAsInteger(int price) {
sign.setPriceAsInteger(price);
SudoSigns.config.setPrice(sign.getName(), price);
if(! SudoSigns.getPlugin().getConfig().getBoolean("config.currency-symbol-in-front")) {
if (sign.getPriceAsInteger() == 1) {
Util.sudoSignsMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: &e" + price + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&6.");
}
else {
Util.sudoSignsMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: &e" + price + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&6.");
}
}
else {
if (sign.getPriceAsInteger() == 1) {
Util.sudoSignsMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: " + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e" + price + "&6.");
}
else {
Util.sudoSignsMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: " + SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e" + price + "&6.");
}
}
}
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
Util.sudoSignsMessage(p, "&6Please enter the new text (maximum 15 characters), using the &e& &6symbol for color codes. Type &cCANCEL &6to cancel the operation.");
SudoSigns.users.get(p.getUniqueId()).addTextInput(PlayerInput.EDIT_TEXT);
}
public void setText(TextComponent message) {
Util.sudoSignsMessage(p, "&aLine &e" + lineNumber + " &ahas been set to: " + message.content());
sign.editLine(lineNumber - 1, message);
SudoSigns.config.editSignText(sign.getName(), lineNumber, message);
}
}
public void prepareSetPrice() {
p.closeInventory();
UtilitiesOG.trueogMessage(p,
"&6Please enter the price to use the sign! Type &cCANCEL &6to cancel the operation.");
SudoSigns.users.get(p.getUniqueId()).addTextInput(PlayerInput.SET_PRICE);
}
public void setPriceAsDouble(double price) {
sign.setPriceAsDouble(price);
SudoSigns.config.setPrice(sign.getName(), price);
if (!SudoSigns.getPlugin().getConfig().getBoolean("config.currency-symbol-in-front")) {
if (sign.getPriceAsDouble() == 1.0) {
UtilitiesOG.trueogMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: &e" + price
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&6.");
} else {
UtilitiesOG.trueogMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: &e" + price
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&6.");
}
} else {
if (sign.getPriceAsInteger() == 1) {
UtilitiesOG.trueogMessage(p,
"&6The price of &e" + sign.getName() + " &6has been set to: "
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e"
+ price + "&6.");
} else {
UtilitiesOG.trueogMessage(p,
"&6The price of &e" + sign.getName() + " &6has been set to: "
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e"
+ price + "&6.");
}
}
}
public void setPriceAsInteger(int price) {
sign.setPriceAsInteger(price);
SudoSigns.config.setPrice(sign.getName(), price);
if (!SudoSigns.getPlugin().getConfig().getBoolean("config.currency-symbol-in-front")) {
if (sign.getPriceAsInteger() == 1) {
UtilitiesOG.trueogMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: &e" + price
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&6.");
} else {
UtilitiesOG.trueogMessage(p, "&6The price of &e" + sign.getName() + " &6has been set to: &e" + price
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&6.");
}
} else {
if (sign.getPriceAsInteger() == 1) {
UtilitiesOG.trueogMessage(p,
"&6The price of &e" + sign.getName() + " &6has been set to: "
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-singular") + "&e"
+ price + "&6.");
} else {
UtilitiesOG.trueogMessage(p,
"&6The price of &e" + sign.getName() + " &6has been set to: "
+ SudoSigns.getPlugin().getConfig().getString("config.currency-symbol-plural") + "&e"
+ price + "&6.");
}
}
}
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
UtilitiesOG.trueogMessage(p,
"&6Please enter the new text (maximum 15 characters), using the &e& &6symbol for color codes. Type &cCANCEL &6to cancel the operation.");
SudoSigns.users.get(p.getUniqueId()).addTextInput(PlayerInput.EDIT_TEXT);
}
public void setText(TextComponent message) {
UtilitiesOG.trueogMessage(p, "&aLine &e" + lineNumber + " &ahas been set to: " + message.content());
sign.editLine(lineNumber - 1, message);
SudoSigns.config.editSignText(sign.getName(), lineNumber, message);
}
}
@@ -22,135 +22,137 @@ import dev.mylesmor.sudosigns.data.SudoUser;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.kyori.adventure.text.TextComponent;
import net.trueog.utilitiesog.UtilitiesOG;
public class MessageOptionsMenu {
private Inventory menu;
private SudoUser su;
private SudoSign sign;
private SignMessage sm;
private Player p;
private SignEditor editor;
private Inventory menu;
private final SudoUser su;
private final SudoSign sign;
private final SignMessage sm;
private final Player p;
private final SignEditor editor;
MessageOptionsMenu(SudoUser su, Player p, SudoSign sign, ItemStack item, SignEditor editor) {
MessageOptionsMenu(SudoUser su, Player p, SudoSign sign, ItemStack item, SignEditor editor) {
this.su = su;
this.sign = sign;
this.p = p;
this.editor = editor;
this.sm = findSignMessage(item);
this.su = su;
this.sign = sign;
this.p = p;
this.editor = editor;
this.sm = findSignMessage(item);
if (this.sm == null) {
if (this.sm == null) {
editor.goToMessages();
editor.goToMessages();
return;
return;
}
}
}
}
public void goToMessageOptionsMenu() {
public void goToMessageOptionsMenu() {
createMessageOptionsMenu();
p.openInventory(menu);
createMessageOptionsMenu();
p.openInventory(menu);
}
}
private SignMessage findSignMessage(ItemStack item) {
private SignMessage findSignMessage(ItemStack item) {
NamespacedKey key = new NamespacedKey(SudoSigns.sudoSignsPlugin, "message-number");
ItemMeta itemMeta = item.getItemMeta();
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
final NamespacedKey key = new NamespacedKey(SudoSigns.sudoSignsPlugin, "message-number");
final ItemMeta itemMeta = item.getItemMeta();
final PersistentDataContainer container = itemMeta.getPersistentDataContainer();
if (container.has(key, PersistentDataType.INTEGER)) {
if (container.has(key, PersistentDataType.INTEGER)) {
int foundValue = container.get(key, PersistentDataType.INTEGER);
final int foundValue = container.get(key, PersistentDataType.INTEGER);
return sign.getSignMessageByNumber(foundValue);
return sign.getSignMessageByNumber(foundValue);
}
}
return null;
return null;
}
}
private void createMessageOptionsMenu() {
private void createMessageOptionsMenu() {
Inventory playersInventory = p.getInventory();
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
TextComponent nameHandler = Util.legacySerializerAnyCase("&6Message options");
final Inventory playersInventory = p.getInventory();
final InventoryHolder inventoryContainer = playersInventory.getHolder(false);
final TextComponent nameHandler = UtilitiesOG.trueogColorize("&6Message options");
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
for (int i = 0; i < menu.getSize(); i++) {
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
}
}
List<String> lore = new ArrayList<>();
final List<String> lore = new ArrayList<>();
ItemStack arrow = new ItemStack(Material.ARROW);
ItemMeta arrowMeta = arrow.getItemMeta();
final ItemStack arrow = new ItemStack(Material.ARROW);
final ItemMeta arrowMeta = arrow.getItemMeta();
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
arrowMeta.displayName(UtilitiesOG.trueogColorize("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
ItemStack clock = new ItemStack(Material.CLOCK);
ItemMeta clockMeta = clock.getItemMeta();
final ItemStack clock = new ItemStack(Material.CLOCK);
final ItemMeta clockMeta = clock.getItemMeta();
lore.add("&eChange the delay after which the message is sent");
clockMeta.displayName(Util.legacySerializerAnyCase("&r&dChange Delay"));
clockMeta.lore(Util.convertToTextComponents(lore));
clock.setItemMeta(clockMeta);
lore.add("&eChange the delay after which the message is sent");
clockMeta.displayName(UtilitiesOG.trueogColorize("&r&dChange Delay"));
clockMeta.lore(Util.convertToTextComponents(lore));
clock.setItemMeta(clockMeta);
ItemStack barrier = new ItemStack(Material.BARRIER);
ItemMeta barrierMeta = barrier.getItemMeta();
final ItemStack barrier = new ItemStack(Material.BARRIER);
final ItemMeta barrierMeta = barrier.getItemMeta();
barrierMeta.displayName(Util.legacySerializerAnyCase("&r&dDelete Message"));
barrier.setItemMeta(barrierMeta);
barrierMeta.displayName(UtilitiesOG.trueogColorize("&r&dDelete Message"));
barrier.setItemMeta(barrierMeta);
if (p.hasPermission(Permissions.MESSAGE_OPTIONS) && p.hasPermission(Permissions.DELETE_MESSAGE)) {
if (p.hasPermission(Permissions.MESSAGE_OPTIONS) && p.hasPermission(Permissions.DELETE_MESSAGE)) {
menu.setItem(20, clock);
menu.setItem(24, barrier);
menu.setItem(20, clock);
menu.setItem(24, barrier);
}
else {
} else {
menu.setItem(22, clock);
menu.setItem(22, clock);
}
}
menu.setItem(36, arrow);
menu.setItem(36, arrow);
}
}
public void addDelay() {
public void addDelay() {
p.closeInventory();
Util.sudoSignsMessage(p, "&6Please enter the delay in seconds. To cancel, type &cCANCEL &6.");
su.addTextInput(PlayerInput.MESSAGE_DELAY);
p.closeInventory();
}
UtilitiesOG.trueogMessage(p, "&6Please enter the delay in seconds. To cancel, type &cCANCEL &6.");
public void setDelay(double delay) {
su.addTextInput(PlayerInput.MESSAGE_DELAY);
double oldDelay = sm.getDelay();
sm.setDelay(delay * 1000);
}
SudoSigns.config.deleteMessage(sign, sm, oldDelay);
SudoSigns.config.addMessage(sign, sm);
public void setDelay(double delay) {
}
final double oldDelay = sm.getDelay();
sm.setDelay(delay * 1000);
public void deleteMessage() {
SudoSigns.config.deleteMessage(sign, sm, oldDelay);
SudoSigns.config.addMessage(sign, sm);
sign.removeMessage(sm);
SudoSigns.config.deleteMessage(sign, sm, sm.getDelay());
editor.goToMessages();
}
}
public void deleteMessage() {
sign.removeMessage(sm);
SudoSigns.config.deleteMessage(sign, sm, sm.getDelay());
editor.goToMessages();
}
}
@@ -22,140 +22,152 @@ import dev.mylesmor.sudosigns.data.SudoUser;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.kyori.adventure.text.TextComponent;
import net.trueog.utilitiesog.UtilitiesOG;
import org.apache.commons.lang3.StringUtils;
public class MessagesMenu {
private Inventory menu;
private Player p;
private SudoSign sign;
private SudoUser su;
private Inventory menu;
private final Player p;
private final SudoSign sign;
private final SudoUser su;
public MessagesMenu(SudoUser su, Player p, SudoSign sign, SignEditor editor) {
public MessagesMenu(SudoUser su, Player p, SudoSign sign, SignEditor editor) {
this.su = su;
this.sign = sign;
this.p = p;
this.su = su;
this.sign = sign;
this.p = p;
}
}
public void goToMessagesMenu() {
public void goToMessagesMenu() {
createMessagesMenu();
p.openInventory(menu);
createMessagesMenu();
p.openInventory(menu);
}
}
private void createMessagesMenu() {
private void createMessagesMenu() {
Inventory playersInventory = p.getInventory();
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
TextComponent nameHandler = Util.legacySerializerAnyCase("&6Messages: " + sign.getName());
final Inventory playersInventory = p.getInventory();
final InventoryHolder inventoryContainer = playersInventory.getHolder(false);
final TextComponent nameHandler = UtilitiesOG.trueogColorize("&6Messages: " + sign.getName());
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
for (int i = 0; i < menu.getSize(); i++) {
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
}
}
ItemStack arrow = new ItemStack(Material.ARROW);
ItemMeta arrowMeta = arrow.getItemMeta();
final ItemStack arrow = new ItemStack(Material.ARROW);
final ItemMeta arrowMeta = arrow.getItemMeta();
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
arrowMeta.displayName(UtilitiesOG.trueogColorize("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
if (p.hasPermission(Permissions.ADD_MESSAGE)) {
if (p.hasPermission(Permissions.ADD_MESSAGE)) {
ItemStack bookQuill = new ItemStack(Material.WRITABLE_BOOK);
ItemMeta bqMeta = bookQuill.getItemMeta();
final ItemStack bookQuill = new ItemStack(Material.WRITABLE_BOOK);
final ItemMeta bqMeta = bookQuill.getItemMeta();
bqMeta.displayName(Util.legacySerializerAnyCase("&r&2Add new message"));
bookQuill.setItemMeta(bqMeta);
bqMeta.displayName(UtilitiesOG.trueogColorize("&r&2Add new message"));
bookQuill.setItemMeta(bqMeta);
menu.setItem(40, bookQuill);
menu.setItem(40, bookQuill);
}
}
ItemStack signItem = null;
if (SudoSigns.version.contains("1.13")) {
ItemStack signItem = null;
if (StringUtils.contains(SudoSigns.version, "1.13")) {
signItem = new ItemStack(Material.valueOf("SIGN"));
signItem = new ItemStack(Material.valueOf("SIGN"));
}
else {
} else {
signItem = new ItemStack(Material.BIRCH_SIGN);
signItem = new ItemStack(Material.BIRCH_SIGN);
}
}
ItemMeta signMeta = signItem.getItemMeta();
final ItemMeta signMeta = signItem.getItemMeta();
signMeta.displayName(Util.legacySerializerAnyCase("&r&dMessages"));
signItem.setItemMeta(signMeta);
signMeta.displayName(UtilitiesOG.trueogColorize("&r&dMessages"));
signItem.setItemMeta(signMeta);
List<String> lore = new ArrayList<>();
NamespacedKey key = new NamespacedKey(SudoSigns.sudoSignsPlugin, "message-number");
final List<String> lore = new ArrayList<>();
final NamespacedKey key = new NamespacedKey(SudoSigns.sudoSignsPlugin, "message-number");
ArrayList<SignMessage> orderedSignMessages = sign.getMessages();
orderedSignMessages.sort(Comparator.comparing(SignMessage::getDelay));
final ArrayList<SignMessage> orderedSignMessages = sign.getMessages();
orderedSignMessages.sort(Comparator.comparing(SignMessage::getDelay));
int i = 1;
for (SignMessage sm : orderedSignMessages) {
int i = 1;
for (SignMessage sm : orderedSignMessages) {
if (i > 35) break;
if (i > 35) {
ItemStack book = new ItemStack(Material.BOOK);
ItemMeta bookMeta = book.getItemMeta();
break;
lore.clear();
bookMeta.displayName(Util.legacySerializerAnyCase("&dMessage:"));
lore.add("&r&f" + sm.getMessage());
lore.add("");
lore.add("");
lore.add("&6Delay: &e" + (sm.getDelay() / 1000) + "s");
}
if (p.hasPermission(Permissions.MESSAGE_OPTIONS)) {
final ItemStack book = new ItemStack(Material.BOOK);
final ItemMeta bookMeta = book.getItemMeta();
lore.add("");
lore.add("&2Click for options!");
lore.clear();
bookMeta.displayName(UtilitiesOG.trueogColorize("&dMessage:"));
lore.add("&r&f" + sm.getMessage());
lore.add("");
lore.add("");
lore.add("&6Delay: &e" + (sm.getDelay() / 1000) + "s");
}
if (p.hasPermission(Permissions.MESSAGE_OPTIONS)) {
bookMeta.getPersistentDataContainer().set(key, PersistentDataType.INTEGER, sm.getNumber());
bookMeta.lore(Util.convertToTextComponents(lore));
book.setItemMeta(bookMeta);
lore.add("");
lore.add("&2Click for options!");
if (i == 9 || i == 18 || i == 27) i++;
menu.setItem(i, book);
}
i++;
bookMeta.getPersistentDataContainer().set(key, PersistentDataType.INTEGER, sm.getNumber());
bookMeta.lore(Util.convertToTextComponents(lore));
book.setItemMeta(bookMeta);
}
if (i == 9 || i == 18 || i == 27) {
menu.setItem(0, signItem);
menu.setItem(9, signItem);
menu.setItem(18, signItem);
menu.setItem(27, signItem);
menu.setItem(36, arrow);
i++;
}
}
public void addMessage(String message) {
menu.setItem(i, book);
SignMessage signMessage = new SignMessage(sign.getNextMessageNumber(), message, 0, PlayerInput.MESSAGE);
SudoSigns.config.addMessage(sign, signMessage);
sign.addMessage(signMessage);
i++;
}
}
public void prepareMessage() {
menu.setItem(0, signItem);
menu.setItem(9, signItem);
menu.setItem(18, signItem);
menu.setItem(27, signItem);
menu.setItem(36, arrow);
p.closeInventory();
}
Util.sudoSignsMessage(p, "&6Please enter in chat the message which will be shown when the sign is clicked. Use the & symbol for chat color codes and the placeholder &e%PLAYER% &6for the player who clicked the sign. To cancel the operation, type &cCANCEL&6.");
su.addTextInput(PlayerInput.MESSAGE);
public void addMessage(String message) {
}
final SignMessage signMessage = new SignMessage(sign.getNextMessageNumber(), message, 0, PlayerInput.MESSAGE);
SudoSigns.config.addMessage(sign, signMessage);
sign.addMessage(signMessage);
}
public void prepareMessage() {
p.closeInventory();
UtilitiesOG.trueogMessage(p,
"&6Please enter in chat the message which will be shown when the sign is clicked. Use the & symbol for chat color codes and the placeholder &e%PLAYER% &6for the player who clicked the sign. To cancel the operation, type &cCANCEL&6.");
su.addTextInput(PlayerInput.MESSAGE);
}
}
@@ -18,197 +18,204 @@ import dev.mylesmor.sudosigns.data.SudoUser;
import dev.mylesmor.sudosigns.util.Permissions;
import dev.mylesmor.sudosigns.util.Util;
import net.kyori.adventure.text.TextComponent;
import net.trueog.utilitiesog.UtilitiesOG;
public class PermissionsMenu {
private final GUIPage PAGE = GUIPage.PERMISSIONS;
private final GUIPage PAGE = GUIPage.PERMISSIONS;
private Inventory menu;
private Player p;
private SudoSign sign;
private SignEditor editor;
private SudoUser su;
private Inventory menu;
private final Player p;
private final SudoSign sign;
private final SignEditor editor;
private final SudoUser su;
public PermissionsMenu(SudoUser su, Player p, SudoSign sign, SignEditor editor) {
public PermissionsMenu(SudoUser su, Player p, SudoSign sign, SignEditor editor) {
this.su = su;
this.sign = sign;
this.editor = editor;
this.p = p;
this.su = su;
this.sign = sign;
this.editor = editor;
this.p = p;
}
}
public void goToPermissionsMenu() {
public void goToPermissionsMenu() {
createPermissionsMenu();
createPermissionsMenu();
p.openInventory(menu);
editor.setCurrentPage(PAGE);
p.openInventory(menu);
editor.setCurrentPage(PAGE);
}
}
private void createPermissionsMenu() {
private void createPermissionsMenu() {
Inventory playersInventory = p.getInventory();
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
TextComponent nameHandler = Util.legacySerializerAnyCase("&6Default or Custom?");
final Inventory playersInventory = p.getInventory();
final InventoryHolder inventoryContainer = playersInventory.getHolder(false);
final TextComponent nameHandler = UtilitiesOG.trueogColorize("&6Default or Custom?");
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
menu = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
for (int i = 0; i < menu.getSize(); i++) {
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
menu.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
}
}
ItemStack arrow = new ItemStack(Material.ARROW);
ItemMeta arrowMeta = arrow.getItemMeta();
final ItemStack arrow = new ItemStack(Material.ARROW);
final ItemMeta arrowMeta = arrow.getItemMeta();
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
arrowMeta.displayName(UtilitiesOG.trueogColorize("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
ItemStack barrier = new ItemStack(Material.BARRIER);
ItemMeta barrierMeta = barrier.getItemMeta();
final ItemStack barrier = new ItemStack(Material.BARRIER);
final ItemMeta barrierMeta = barrier.getItemMeta();
barrierMeta.displayName(Util.legacySerializerAnyCase("&r&5Permissions"));
barrier.setItemMeta(barrierMeta);
barrierMeta.displayName(UtilitiesOG.trueogColorize("&r&5Permissions"));
barrier.setItemMeta(barrierMeta);
if (p.hasPermission(Permissions.ADD_PERMISSION)) {
if (p.hasPermission(Permissions.ADD_PERMISSION)) {
ItemStack bookQuill = new ItemStack(Material.WRITABLE_BOOK);
ItemMeta bqMeta = bookQuill.getItemMeta();
final ItemStack bookQuill = new ItemStack(Material.WRITABLE_BOOK);
final ItemMeta bqMeta = bookQuill.getItemMeta();
bqMeta.displayName(Util.legacySerializerAnyCase("&aAdd new permission"));
bookQuill.setItemMeta(bqMeta);
menu.setItem(40, bookQuill);
bqMeta.displayName(UtilitiesOG.trueogColorize("&aAdd new permission"));
bookQuill.setItemMeta(bqMeta);
menu.setItem(40, bookQuill);
}
}
final List<String> lore = new ArrayList<>();
List<String> lore = new ArrayList<>();
lore.add("&cClick to delete!");
lore.add("&cClick to delete!");
int i = 1;
for (String perm : sign.getPermissions()) {
int i = 1;
for (String perm : sign.getPermissions()) {
if (i > 35) {
if (i > 35) break;
break;
ItemStack book = new ItemStack(Material.BOOK);
ItemMeta bookMeta = book.getItemMeta();
bookMeta.displayName(Util.legacySerializerAnyCase("&r&6" + perm));
if (p.hasPermission(Permissions.DELETE_PERMISSION)) {
}
lore.add("");
bookMeta.lore(Util.convertToTextComponents(lore));
final ItemStack book = new ItemStack(Material.BOOK);
final ItemMeta bookMeta = book.getItemMeta();
bookMeta.displayName(UtilitiesOG.trueogColorize("&r&6" + perm));
if (p.hasPermission(Permissions.DELETE_PERMISSION)) {
}
lore.add("");
bookMeta.lore(Util.convertToTextComponents(lore));
book.setItemMeta(bookMeta);
}
if (i == 9 || i == 18 || i == 27) i++;
book.setItemMeta(bookMeta);
menu.setItem(i, book);
if (i == 9 || i == 18 || i == 27) {
i++;
i++;
}
}
menu.setItem(0, barrier);
menu.setItem(9, barrier);
menu.setItem(18, barrier);
menu.setItem(27, barrier);
menu.setItem(36, arrow);
menu.setItem(i, book);
}
i++;
}
public void preparePermission() {
menu.setItem(0, barrier);
menu.setItem(9, barrier);
menu.setItem(18, barrier);
menu.setItem(27, barrier);
menu.setItem(36, arrow);
Inventory playersInventory = p.getInventory();
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
TextComponent nameHandler = Util.legacySerializerAnyCase("&6Default or Custom?");
Inventory choiceInv = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
}
int inventorySize = choiceInv.getSize();
ArrayList<String> lore = new ArrayList<String>(inventorySize);
for (int i = 0; i < inventorySize; i++) {
public void preparePermission() {
lore.add("");
final Inventory playersInventory = p.getInventory();
final InventoryHolder inventoryContainer = playersInventory.getHolder(false);
final TextComponent nameHandler = UtilitiesOG.trueogColorize("&6Default or Custom?");
final Inventory choiceInv = Bukkit.createInventory(inventoryContainer, 45, nameHandler);
choiceInv.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
choiceInv.getItem(i).lore(Util.convertToTextComponents(lore));
final int inventorySize = choiceInv.getSize();
final ArrayList<String> lore = new ArrayList<>(inventorySize);
for (int i = 0; i < inventorySize; i++) {
}
lore.add("");
ItemStack arrow = new ItemStack(Material.ARROW);
ItemMeta arrowMeta = arrow.getItemMeta();
choiceInv.setItem(i, new ItemStack(Material.GRAY_STAINED_GLASS_PANE));
choiceInv.getItem(i).lore(Util.convertToTextComponents(lore));
arrowMeta.displayName(Util.legacySerializerAnyCase("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
}
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
ItemMeta headMeta = head.getItemMeta();
List<String> loreString = new ArrayList<>();
final ItemStack arrow = new ItemStack(Material.ARROW);
final ItemMeta arrowMeta = arrow.getItemMeta();
loreString.add("&6sudosigns.sign." + sign.getName());
headMeta.displayName(Util.legacySerializerAnyCase("&r&dDefault Permission"));
headMeta.lore(Util.convertToTextComponents(loreString));
head.setItemMeta(headMeta);
arrowMeta.displayName(UtilitiesOG.trueogColorize("&r&dBACK"));
arrow.setItemMeta(arrowMeta);
ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
final ItemStack head = new ItemStack(Material.PLAYER_HEAD);
final ItemMeta headMeta = head.getItemMeta();
final List<String> loreString = new ArrayList<>();
cmdBlockMeta.displayName(Util.legacySerializerAnyCase("&r&5Custom Permission"));
cmdBlock.setItemMeta(cmdBlockMeta);
loreString.add("&6sudosigns.sign." + sign.getName());
headMeta.displayName(UtilitiesOG.trueogColorize("&r&dDefault Permission"));
headMeta.lore(Util.convertToTextComponents(loreString));
head.setItemMeta(headMeta);
choiceInv.setItem(21, head);
choiceInv.setItem(23, cmdBlock);
choiceInv.setItem(36, arrow);
final ItemStack cmdBlock = new ItemStack(Material.COMMAND_BLOCK);
final ItemMeta cmdBlockMeta = cmdBlock.getItemMeta();
editor.setCurrentPage(GUIPage.CHOOSE_PERMISSION);
cmdBlockMeta.displayName(UtilitiesOG.trueogColorize("&r&5Custom Permission"));
cmdBlock.setItemMeta(cmdBlockMeta);
p.openInventory(choiceInv);
choiceInv.setItem(21, head);
choiceInv.setItem(23, cmdBlock);
choiceInv.setItem(36, arrow);
}
editor.setCurrentPage(GUIPage.CHOOSE_PERMISSION);
public void addPermission(boolean provided, String perm) {
p.openInventory(choiceInv);
if (provided) {
}
if (perm == null) {
public void addPermission(boolean provided, String perm) {
sign.addPermission("sudosigns.sign." + sign.getName());
SudoSigns.config.addPermission(sign, "sudosigns.sign." + sign.getName());
if (provided) {
goToPermissionsMenu();
if (perm == null) {
}
else {
sign.addPermission("sudosigns.sign." + sign.getName());
SudoSigns.config.addPermission(sign, "sudosigns.sign." + sign.getName());
SudoSigns.config.addPermission(sign, perm);
sign.addPermission(perm);
goToPermissionsMenu();
}
} else {
}
else {
SudoSigns.config.addPermission(sign, perm);
sign.addPermission(perm);
p.closeInventory();
}
Util.sudoSignsMessage(p, "&6Please enter in chat the permission which the player must have to run this sign, or type &cCANCEL &6to cancel the operation.");
su.addTextInput(PlayerInput.PERMISSION);
} else {
}
p.closeInventory();
}
UtilitiesOG.trueogMessage(p,
"&6Please enter in chat the permission which the player must have to run this sign, or type &cCANCEL &6to cancel the operation.");
public void deletePermission(String perm) {
su.addTextInput(PlayerInput.PERMISSION);
sign.removePermission(perm);
SudoSigns.config.deletePermission(sign, perm);
}
goToPermissionsMenu();
}
}
public void deletePermission(String perm) {
sign.removePermission(perm);
SudoSigns.config.deletePermission(sign, perm);
goToPermissionsMenu();
}
}
@@ -1,6 +1,8 @@
package dev.mylesmor.sudosigns.menus;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -9,209 +11,214 @@ import dev.mylesmor.sudosigns.SudoSigns;
import dev.mylesmor.sudosigns.data.PlayerInput;
import dev.mylesmor.sudosigns.data.SudoSign;
import dev.mylesmor.sudosigns.data.SudoUser;
import dev.mylesmor.sudosigns.util.Util;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
import net.trueog.utilitiesog.UtilitiesOG;
public class SignEditor {
private Player p;
private SudoUser su;
private SudoSign sign;
private MainMenu mainMenu;
private PermissionsMenu permMenu;
private CommandsMenu commandsMenu;
private CommandOptionsMenu commandOptionsMenu;
private MessageOptionsMenu messageOptionsMenu;
private MessagesMenu messagesMenu;
private GUIPage currentPage;
private final Player p;
private final SudoUser su;
private final SudoSign sign;
private MainMenu mainMenu;
private PermissionsMenu permMenu;
private CommandsMenu commandsMenu;
private CommandOptionsMenu commandOptionsMenu;
private MessageOptionsMenu messageOptionsMenu;
private MessagesMenu messagesMenu;
private GUIPage currentPage;
private final DiamondBankAPIJava diamondBankAPI;
public SignEditor(Player p, SudoSign s, SudoUser su) {
public SignEditor(Player p, SudoSign s, SudoUser su, DiamondBankAPIJava diamondBankAPI) {
this.su = su;
this.p = p;
this.sign = s;
this.su = su;
this.p = p;
this.sign = s;
this.diamondBankAPI = diamondBankAPI;
goToMain();
goToMain();
}
}
public GUIPage getCurrentPage() {
public GUIPage getCurrentPage() {
return currentPage;
return currentPage;
}
}
public void setCurrentPage(GUIPage page) {
public void setCurrentPage(GUIPage page) {
currentPage = page;
currentPage = page;
}
}
public void goToMain() {
public void goToMain() {
if (mainMenu == null) {
if (mainMenu == null) {
mainMenu = new MainMenu(p, sign, this);
mainMenu = new MainMenu(p, sign, this, diamondBankAPI);
}
}
setCurrentPage(GUIPage.MAIN);
mainMenu.goToMainMenu();
setCurrentPage(GUIPage.MAIN);
mainMenu.goToMainMenu();
}
}
public void goToPermissions() {
public void goToPermissions() {
if (permMenu == null) {
if (permMenu == null) {
permMenu = new PermissionsMenu(su, p, sign, this);
permMenu = new PermissionsMenu(su, p, sign, this);
}
}
setCurrentPage(GUIPage.PERMISSIONS);
permMenu.goToPermissionsMenu();
setCurrentPage(GUIPage.PERMISSIONS);
permMenu.goToPermissionsMenu();
}
}
public void goToCommands() {
public void goToCommands() {
if (commandsMenu == null) {
if (commandsMenu == null) {
commandsMenu = new CommandsMenu(su, p, sign, this);
commandsMenu = new CommandsMenu(su, p, sign, this);
}
}
setCurrentPage(GUIPage.COMMANDS);
commandsMenu.goToCommandsMenu();
setCurrentPage(GUIPage.COMMANDS);
commandsMenu.goToCommandsMenu();
}
}
public void goToMessages() {
public void goToMessages() {
if (messagesMenu == null) {
if (messagesMenu == null) {
messagesMenu = new MessagesMenu(su, p, sign, this);
messagesMenu = new MessagesMenu(su, p, sign, this);
}
}
setCurrentPage(GUIPage.MESSAGES);
messagesMenu.goToMessagesMenu();
setCurrentPage(GUIPage.MESSAGES);
messagesMenu.goToMessagesMenu();
}
}
public void goToCommandOptionsMenu(ItemStack item) {
public void goToCommandOptionsMenu(ItemStack item) {
commandOptionsMenu = new CommandOptionsMenu(su, p, sign, item, this);
commandOptionsMenu = new CommandOptionsMenu(su, p, sign, item, this);
setCurrentPage(GUIPage.COMMAND_OPTIONS);
commandOptionsMenu.goToCommandOptionsMenu();
setCurrentPage(GUIPage.COMMAND_OPTIONS);
commandOptionsMenu.goToCommandOptionsMenu();
}
}
public void goToMessageOptionsMenu(ItemStack item) {
public void goToMessageOptionsMenu(ItemStack item) {
messageOptionsMenu = new MessageOptionsMenu(su, p, sign, item, this);
messageOptionsMenu = new MessageOptionsMenu(su, p, sign, item, this);
setCurrentPage(GUIPage.MESSAGE_OPTIONS);
messageOptionsMenu.goToMessageOptionsMenu();
setCurrentPage(GUIPage.MESSAGE_OPTIONS);
messageOptionsMenu.goToMessageOptionsMenu();
}
}
public MainMenu getMainMenu() {
public MainMenu getMainMenu() {
return mainMenu;
return mainMenu;
}
}
public PermissionsMenu getPermMenu() {
public PermissionsMenu getPermMenu() {
return permMenu;
return permMenu;
}
}
public CommandsMenu getCommandsMenu() {
public CommandsMenu getCommandsMenu() {
return commandsMenu;
return commandsMenu;
}
}
public CommandOptionsMenu getCommandOptionsMenu() {
public CommandOptionsMenu getCommandOptionsMenu() {
return commandOptionsMenu;
return commandOptionsMenu;
}
}
public MessagesMenu getMessagesMenu() {
public MessagesMenu getMessagesMenu() {
return messagesMenu;
return messagesMenu;
}
}
public MessageOptionsMenu getMessageOptionsMenu() {
public MessageOptionsMenu getMessageOptionsMenu() {
return messageOptionsMenu;
return messageOptionsMenu;
}
}
public void endEditor() {
public void endEditor() {
UtilitiesOG.trueogMessage(p, "&aChanges saved to sign &e" + sign.getName() + " &a.");
Util.sudoSignsMessage(p, "&aChanges saved to sign &e%NAME%&a.", sign.getName());
}
}
public void editSignNumber() {
UtilitiesOG.trueogMessage(p, "&6Please enter the line you would like to edit (1-4) or type &cCANCEL&6!");
su.addTextInput(PlayerInput.EDIT_TEXT_NUMBER);
p.closeInventory();
public void editSignNumber() {
}
Util.sudoSignsMessage(p, "&6Please enter the line you would like to edit (1-4) or type &cCANCEL&6!");
su.addTextInput(PlayerInput.EDIT_TEXT_NUMBER);
p.closeInventory();
public void prepareRename() {
}
UtilitiesOG.trueogMessage(p, "&6Please enter the new name for the sign in chat or type &cCANCEL&6!");
public void prepareRename() {
su.addTextInput(PlayerInput.RENAME);
Util.sudoSignsMessage(p, "&6Please enter the new name for the sign in chat or type &cCANCEL&6!");
su.addTextInput(PlayerInput.RENAME);
p.closeInventory();
p.closeInventory();
}
}
public void renameSign(String s) {
public void renameSign(String s) {
if (SudoSigns.signs.containsKey(s)) {
if (SudoSigns.signs.containsKey(s)) {
Util.sudoSignsMessage(p, "&cERROR: A sign with the name &e%NAME% &calready exists! &6Cancelling...", s);
UtilitiesOG.trueogMessage(p, "&cERROR: A sign with the name &e" + s + " &calready exists! &6Cancelling...");
}
else {
} else {
sign.setName(s);
sign.setName(s);
Map.Entry<String, SudoSign> found = null;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
Map.Entry<String, SudoSign> found = null;
for (Iterator<Entry<String, SudoSign>> iterator = SudoSigns.signs.entrySet().iterator(); iterator
.hasNext();)
{
if (entry.getValue().equals(sign)) {
final Map.Entry<String, SudoSign> entry = iterator.next();
if (entry.getValue().equals(sign)) {
found = entry;
found = entry;
}
}
}
}
if (found != null) {
if (found != null) {
SudoSigns.signs.remove(found.getKey());
SudoSigns.signs.put(s, sign);
SudoSigns.signs.remove(found.getKey());
SudoSigns.signs.put(s, sign);
Util.sudoSignsMessage(p, "&aSign successfully renamed to &e%NAME%&a.", s);
UtilitiesOG.trueogMessage(p, "&aSign successfully renamed to &e" + s + "&a.");
SudoSigns.config.saveSign(found.getValue(), true, p);
SudoSigns.config.deleteSign(found.getKey());
SudoSigns.config.saveSign(found.getValue(), true, p);
SudoSigns.config.deleteSign(found.getKey());
}
}
}
}
}
}
}
@@ -2,39 +2,43 @@ package dev.mylesmor.sudosigns.util;
/**
* Permissions class for SudoSigns.
*
* @author MylesMor
* @author https://mylesmor.dev
* @Maintainer NotAlexNoyle
* @Maintainer https://true-og.net
*/
public final class Permissions {
public static final String CREATE = "sudosigns.create";
public static final String EDIT = "sudosigns.edit";
public static final String DELETE = "sudosigns.delete";
public static final String RUN = "sudosigns.run";
public static final String TP = "sudosigns.tp";
public static final String COPY = "sudosigns.copy";
public static final String RELOAD = "sudosigns.reload";
public static final String VIEW = "sudosigns.view";
public static final String HELP = "sudosigns.help";
public static final String SELECT = "sudosigns.select";
public static final String NEAR = "sudosigns.near";
public static final String LIST = "sudosigns.list";
public static final String RENAME = "sudosigns.rename";
public static final String PURGE = "sudosigns.purge";
public static final String FIX = "sudosigns.fix";
public static final String VIEW_COMMAND = "sudosigns.command.view";
public static final String ADD_COMMAND = "sudosigns.command.add";
public static final String DELETE_COMMAND = "sudosigns.command.delete";
public static final String CONSOLE_COMMAND = "sudosigns.command.console";
public static final String COMMAND_OPTIONS = "sudosigns.command.options";
public static final String VIEW_PERMISSION = "sudosigns.permission.view";
public static final String ADD_PERMISSION = "sudosigns.permission.add";
public static final String DELETE_PERMISSION = "sudosigns.permission.delete";
public static final String VIEW_MESSAGE = "sudosigns.message.view";
public static final String ADD_MESSAGE = "sudosigns.message.add";
public static final String DELETE_MESSAGE = "sudosigns.message.delete";
public static final String MESSAGE_OPTIONS = "sudosigns.message.options";
public static final String EDIT_TEXT = "sudosigns.text.edit";
public static final String VIEW_PRICE = "sudosigns.price.view";
public static final String SET_PRICE = "sudosigns.price.set";
public static final String CREATE = "sudosigns.create";
public static final String EDIT = "sudosigns.edit";
public static final String DELETE = "sudosigns.delete";
public static final String RUN = "sudosigns.run";
public static final String TP = "sudosigns.tp";
public static final String COPY = "sudosigns.copy";
public static final String RELOAD = "sudosigns.reload";
public static final String VIEW = "sudosigns.view";
public static final String HELP = "sudosigns.help";
public static final String SELECT = "sudosigns.select";
public static final String NEAR = "sudosigns.near";
public static final String LIST = "sudosigns.list";
public static final String RENAME = "sudosigns.rename";
public static final String PURGE = "sudosigns.purge";
public static final String FIX = "sudosigns.fix";
public static final String VIEW_COMMAND = "sudosigns.command.view";
public static final String ADD_COMMAND = "sudosigns.command.add";
public static final String DELETE_COMMAND = "sudosigns.command.delete";
public static final String CONSOLE_COMMAND = "sudosigns.command.console";
public static final String COMMAND_OPTIONS = "sudosigns.command.options";
public static final String VIEW_PERMISSION = "sudosigns.permission.view";
public static final String ADD_PERMISSION = "sudosigns.permission.add";
public static final String DELETE_PERMISSION = "sudosigns.permission.delete";
public static final String VIEW_MESSAGE = "sudosigns.message.view";
public static final String ADD_MESSAGE = "sudosigns.message.add";
public static final String DELETE_MESSAGE = "sudosigns.message.delete";
public static final String MESSAGE_OPTIONS = "sudosigns.message.options";
public static final String EDIT_TEXT = "sudosigns.text.edit";
public static final String VIEW_PRICE = "sudosigns.price.view";
public static final String SET_PRICE = "sudosigns.price.set";
}
@@ -6,6 +6,11 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
@@ -14,229 +19,219 @@ import dev.mylesmor.sudosigns.data.SudoSign;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.trueog.utilitiesog.UtilitiesOG;
public class Util {
// Create a colored chat prefix.
public static String chatPrefix = SudoSigns.getPlugin().getConfig().getString("config.prefix");
// Create a colored chat prefix.
public static String chatPrefix = SudoSigns.getPlugin().getConfig().getString("config.prefix");
// Send the sign selection menu according to permissions.
public static void sendSelectMenus(Player p, String name) {
public static ArrayList<TextComponent> convertToTextComponents(List<String> stringList) {
selectMenuParser(p, chatPrefix, "&e-----", name, "", "&2True&4OG&a's Fork of &BSudoSigns&a.");
final ArrayList<TextComponent> textComponents = new ArrayList<>(18);
stringList.stream().map(UtilitiesOG::trueogColorize)
.forEach(textComponent -> textComponents.add(textComponent));
if (p.hasPermission(Permissions.VIEW)) {
return textComponents;
selectMenuParser(p, "&9&l[V]", "&9View Details", name, ("/ss view " + name), ("&9View &6" + name + "\'s &9details."));
}
}
// Send the sign selection menu according to permissions.
public static void sendSelectMenus(Player p, String name) {
if (p.hasPermission(Permissions.RUN)) {
selectMenuParser(p, chatPrefix, "&e-----", name, "", "&2True&4OG&a's Fork of &BSudoSigns&a.");
selectMenuParser(p, "&2&l[R]", "&2Run Commands", name, ("/ss run " + name), ("&2Run &6" + name + "\'s &2commands."));
if (p.hasPermission(Permissions.VIEW)) {
}
selectMenuParser(p, "&9&l[V]", "&9View Details", name, ("/ss view " + name),
("&9View &6" + name + "\'s &9details."));
if (p.hasPermission(Permissions.TP)) {
}
selectMenuParser(p, "&3&l[TP]", "&3Teleport To", name, ("/ss tp " + name), ("&3Teleport to &6" + name + "&3."));
if (p.hasPermission(Permissions.RUN)) {
}
selectMenuParser(p, "&2&l[R]", "&2Run Commands", name, ("/ss run " + name),
("&2Run &6" + name + "\'s &2commands."));
if (p.hasPermission(Permissions.EDIT)) {
}
selectMenuParser(p, "&d&l[EDIT]", "&dEdit Details", name, ("/ss edit " + name), ("&dEdit &6" + name + "\'s &dcolor."));
if (p.hasPermission(Permissions.TP)) {
}
selectMenuParser(p, "&3&l[TP]", "&3Teleport To", name, ("/ss tp " + name),
("&3Teleport to &6" + name + "&3."));
if (p.hasPermission(Permissions.DELETE)) {
}
selectMenuParser(p, "&c&l[DEL]", "&cDelete SudoSign", name, ("/ss confirmdelete " + name), ("&cDelete &6" + name + "&c."));
if (p.hasPermission(Permissions.EDIT)) {
}
selectMenuParser(p, "&d&l[EDIT]", "&dEdit Details", name, ("/ss edit " + name),
("&dEdit &6" + name + "\'s &dcolor."));
}
}
// Sends customizable clickable message dialogues to the player.
public static void selectMenuParser(Player p, String prefix, String prompt, String name, String command, String hoverMessage) {
if (p.hasPermission(Permissions.DELETE)) {
// The clickable part of the confirmation message.
TextComponent button = legacySerializerAnyCase(prefix);
selectMenuParser(p, "&c&l[DEL]", "&cDelete SudoSign", name, ("/ss confirmdelete " + name),
("&cDelete &6" + name + "&c."));
// Add a hover dialogue to the clickable confirmation text.
button.hoverEvent(HoverEvent.hoverEvent(HoverEvent.Action.SHOW_TEXT, legacySerializerAnyCase(hoverMessage)));
}
// Make sure that a command is intended to be run.
if(! command.equals("")) {
// Create a click event on the delete confirmation chat text.
button = button.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, (command)));
}
}
// Send the prompt and clickable confirmation button to the player.
sudoSignsPrompt(p, (prompt + " "), button);
// Sends customizable clickable message dialogues to the player.
public static void selectMenuParser(Player p, String prefix, String prompt, String name, String command,
String hoverMessage)
{
}
// The clickable part of the confirmation message.
TextComponent button = UtilitiesOG.trueogColorize(prefix);
public static TextComponent legacySerializerAnyCase(String subject) {
// Add a hover dialogue to the clickable confirmation text.
button.hoverEvent(HoverEvent.hoverEvent(HoverEvent.Action.SHOW_TEXT, UtilitiesOG.trueogColorize(hoverMessage)));
int count = 0;
// Count the number of '&' characters to determine the size of the array
for (char c : subject.toCharArray()) {
// Make sure that a command is intended to be run.
if (!"".equals(command)) {
if (c == '&') {
// Create a click event on the delete confirmation chat text.
button = button.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, (command)));
count++;
}
}
// Send the prompt and clickable confirmation button to the player.
sudoSignsPrompt(p, (prompt + " "), button);
}
}
// Create an array to store the positions of '&' characters
int[] positions = new int[count];
int index = 0;
// Find the positions of '&' characters and store in the array
for (int i = 0; i < subject.length(); i++) {
// Sends a permissions error message to the player.
public static void sudoSignsPermissionsError(Player p) {
if (subject.charAt(i) == '&') {
UtilitiesOG.trueogMessage(p, "&c&lERROR: &cYou do not have permission to do that!");
if (isUpperBukkitCode(subject.charAt(i + 1))) {
}
subject = replaceCharAtIndex(subject, (i + 1), Character.toLowerCase(subject.charAt(i + 1)));
// Sends a formatted message without a prefix to the player.
public static void sudoSignsMessageNoPrefix(Player p, String message) {
}
UtilitiesOG.trueogMessage(p, message);
positions[index++] = i;
}
}
// Sends a formatted prompt and clickable chat button to the player.
public static void sudoSignsPrompt(Player player, String prompt, TextComponent button) {
}
player.sendMessage(UtilitiesOG.trueogColorize(prompt).append(button));
return LegacyComponentSerializer.legacyAmpersand().deserialize(subject);
}
}
public static boolean checkName(String name) {
private static boolean isUpperBukkitCode(char input) {
final String regex = "^[A-z0-9]+$";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(name);
char[] bukkitColorCodes = {'A', 'B', 'C', 'D', 'E', 'F', 'K', 'L', 'M', 'N', 'O', 'R'};
boolean match = false;
return matcher.matches();
// Loop through each character in the array.
for (char c : bukkitColorCodes) {
// Check if the current character in the array is equal to the input character.
if (c == input) {
}
match = true;
public static String findSign(Sign s) {
}
String found = null;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
}
if (sameBlockLocation(entry.getValue(), s.getLocation())) {
return match;
found = entry.getKey();
}
}
private static String replaceCharAtIndex(String original, int index, char newChar) {
}
// Check if the index is valid
if (index >= 0 && index < original.length()) {
return found;
// Create a new string with the replaced character
return original.substring(0, index) + newChar + original.substring(index + 1);
}
}
public static boolean sameBlockLocation(Location first, Location second) {
// If the index is invalid, return the original string
return original;
if (first == null || second == null || first.getWorld() == null || second.getWorld() == null) {
}
return false;
// Sends a formatted message to the player.
public static void sudoSignsMessage(Player p, String message) {
}
p.sendMessage(legacySerializerAnyCase(chatPrefix + message));
return first.getWorld().getName().equals(second.getWorld().getName()) && first.getBlockX() == second.getBlockX()
&& first.getBlockY() == second.getBlockY() && first.getBlockZ() == second.getBlockZ();
}
}
// Sends a formatted message to the player (including name replacement).
public static void sudoSignsMessage(Player p, String message, String name) {
public static boolean sameBlockLocation(SudoSign sign, Location location) {
if (message.contains("%NAME%")) {
if (sign == null || sign.getWorldName() == null || location == null || location.getWorld() == null) {
message = message.replace("%NAME%", "&6" + name);
return false;
}
}
sudoSignsMessage(p, message);
return sign.getWorldName().equals(location.getWorld().getName()) && sign.getBlockX() == location.getBlockX()
&& sign.getBlockY() == location.getBlockY() && sign.getBlockZ() == location.getBlockZ();
}
}
// Sends a formatted message without a prefix to the player.
public static void sudoSignsMessageNoPrefix(Player p, String message) {
public static boolean isSignState(BlockState blockState) {
p.sendMessage(legacySerializerAnyCase(message));
return blockState instanceof Sign;
}
}
// Sends a standard error message to the player.
public static void sudoSignsErrorMessage(Player p) {
private static boolean isSignMaterial(Material material) {
sudoSignsMessage(p, "&c&lERROR: &cYou do not have permission to do that!");
return material != null && material.name().endsWith("SIGN");
}
}
// Sends a formatted prompt and clickable chat button to the player.
public static void sudoSignsPrompt(Player player, String prompt, TextComponent button) {
private static void ensureChunkLoaded(Block block) {
player.sendMessage(legacySerializerAnyCase(prompt).append(button));
final Chunk chunk = block.getChunk();
if (!chunk.isLoaded()) {
}
chunk.load();
public static boolean checkName(String name) {
}
String regex = "^[A-z0-9]+$";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(name);
}
return matcher.matches();
public static boolean isSignBlock(Block block) {
}
ensureChunkLoaded(block);
public static String findSign(Sign s) {
if (isSignMaterial(block.getType())) {
String found = null;
for (Map.Entry<String, SudoSign> entry : SudoSigns.signs.entrySet()) {
return true;
Sign sign = entry.getValue().getSign();
if (sign != null && sign.equals(s)) {
}
found = entry.getKey();
return isSignState(block.getState());
}
}
}
public static Sign getSign(Block block) {
return found;
ensureChunkLoaded(block);
}
final BlockState blockState = block.getState();
if (isSignState(blockState)) {
public static ArrayList<TextComponent> convertToTextComponents(List<String> stringList) {
ArrayList<TextComponent> textComponents = new ArrayList<TextComponent>(18);
return (Sign) blockState;
for (String str : stringList) {
}
TextComponent textComponent = legacySerializerAnyCase(str);
textComponents.add(textComponent);
return null;
}
}
return textComponents;
}
public static boolean priceIsInteger() {
public static boolean priceIsInteger() {
return SudoSigns.getPlugin().getConfig().getBoolean("config.use-decimals-in-prices");
return SudoSigns.getPlugin().getConfig().getBoolean("config.use-decimals-in-prices");
}
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
config:
prefix: "&8[&2SudoSigns&4-OG&8] "
console-prefix: "[SUDOSIGNS-OG] "
prefix: "&7[&3SudoSigns&4-OG&7] "
console-prefix: "[SudoSigns-OG] "
currency-symbol-singular: " &BDiamond"
currency-symbol-plural: " &BDiamonds"
currency-symbol-in-front: false
+4 -3
View File
@@ -1,10 +1,11 @@
name: SudoSigns-OG
version: '${version}'
author: MylesMor
authors: [ MylesMor, NotAlexNoyle ]
main: dev.mylesmor.sudosigns.SudoSigns
softdepend: [Multiverse-Core, Vault]
depend: [DiamondBank-OG]
softdepend: [Multiverse-Core]
api-version: '${apiVersion}'
commands:
sudosigns:
description: Opens the SudoSigns help menu.
description: Opens the SudoSigns-OG help menu.
aliases: [sudosign, ss]
+192
View File
@@ -0,0 +1,192 @@
signs:
SpleggFFA:
text:
- §8[§aFFA§8]
- §60 of 10
- §6Players Waiting
- §8[§B§lJOIN§8]
price: 0.0
location:
world: world
x: 1.0
y: 64.0
z: -249.0
rotation: SOUTH
blocktype: OAK_WALL_SIGN
permissions: {}
messages:
- Splegg is not out yet!: 0.0
player-commands: {}
console-commands: {}
communitychest:
text:
- ''
- §5Community
- §BChest
- ''
price: 0.0
location:
world: world
x: -21.0
y: 63.0
z: -200.0
rotation: NORTH
blocktype: OAK_WALL_SIGN
permissions: {}
messages:
- Use this chest to share items with the community.: 0.0
player-commands: {}
console-commands: {}
balance:
text:
- ''
- §BCHECK
- §BBALANCE
- ''
price: 0.0
location:
world: world
x: -125.0
y: 43.0
z: -261.0
rotation: NORTH
blocktype: WARPED_WALL_SIGN
permissions: {}
messages: {}
player-commands:
- balance: 0.0
console-commands: {}
deposit:
text:
- ''
- §BDEPOSIT
- §BDIAMONDS
- ''
price: 0.0
location:
world: world
x: -123.0
y: 43.0
z: -261.0
rotation: NORTH
blocktype: WARPED_WALL_SIGN
permissions: {}
messages: {}
player-commands:
- deposit all: 0.0
console-commands: {}
withdraw1:
text:
- ''
- §BWITHDRAW
- §B1 DIAMOND
- ''
price: 0.0
location:
world: world
x: -120.0
y: 41.0
z: -261.0
rotation: NORTH
blocktype: WARPED_WALL_SIGN
permissions: {}
messages: {}
player-commands:
- withdraw 1: 0.0
console-commands: {}
withdraw16:
text:
- ''
- §BWITHDRAW
- §B16 DIAMONDS
- ''
price: 0.0
location:
world: world
x: -120.0
y: 43.0
z: -261.0
rotation: NORTH
blocktype: WARPED_WALL_SIGN
permissions: {}
messages: {}
player-commands:
- withdraw 16: 0.0
console-commands: {}
withdraw64:
text:
- ''
- §BWITHDRAW
- §B64 DIAMONDS
- ''
price: 0.0
location:
world: world
x: -121.0
y: 43.0
z: -261.0
rotation: NORTH
blocktype: WARPED_WALL_SIGN
permissions: {}
messages: {}
player-commands:
- withdraw 64: 0.0
console-commands: {}
store:
text:
- §2True§4OG Shop
- §BClick here to
- §bpurchase a
- §brank!
price: 0.0
location:
world: world
x: -128.0
y: 42.0
z: -261.0
rotation: NORTH
blocktype: OAK_WALL_SIGN
permissions: {}
messages: {}
player-commands:
- ranks: 0.0
console-commands: {}
withdraw4:
text:
- ''
- '&BWITHDRAW'
- '&B4 DIAMONDS'
- ''
price: 0.0
location:
world: world
x: -120.0
y: 42.0
z: -261.0
rotation: NORTH
blocktype: WARPED_WALL_SIGN
permissions: {}
messages: {}
player-commands:
- withdraw 4: 0.0
console-commands: {}
SpleggFFA2:
text:
- '[1v1 Duel]'
- 0 of 10
- Players Waiting
- '[JOIN]'
price: 0.0
location:
world: world
x: -1.0
y: 64.0
z: -249.0
rotation: SOUTH
blocktype: OAK_WALL_SIGN
permissions: {}
messages:
- Splegg is not out yet!: 0.0
player-commands: {}
console-commands: {}
version: 1.2.3