Compare commits
40
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d55a0279a2 | ||
|
|
c3a3eee293
|
||
|
|
da228d2654
|
||
|
|
3abfb3584c | ||
|
|
e7e8d62622 | ||
|
|
dbf9851aa1 | ||
|
|
df9ed6b2d2 | ||
|
|
1bba5670d1 | ||
|
|
86037d0a7a | ||
|
|
ae93303d33 | ||
|
|
dab5f1cf5d | ||
|
|
3d9bb9d92b | ||
|
|
b3542eb1a0 | ||
|
|
7da763c39f | ||
|
|
7cd02aa0a6 | ||
|
|
47d1d1c52e | ||
|
|
997297111c | ||
|
|
735c056ae1 | ||
|
|
7ea775fa3d | ||
|
|
9cbfeb6b96 | ||
|
|
95cc117756 | ||
|
|
f4af71409a | ||
|
|
23f76572fc | ||
|
|
99618a56ed | ||
|
|
b3cf484bf4 | ||
|
|
01c62225e8 | ||
|
|
24b3900911 | ||
|
|
6d3ad8009a | ||
|
|
d73e92c92b | ||
|
|
75d53bdea1 | ||
|
|
e163e1c587 | ||
|
|
dc10644dea | ||
|
|
b4476d44f5 | ||
|
|
34df9cd8c0 | ||
|
|
6acc935cd3 | ||
|
|
fda25c609c | ||
|
|
ef4a23c848 | ||
|
|
842caee0c9 | ||
|
|
1e007981ad | ||
|
|
a3263ec499 |
No files matched your search
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
+10
@@ -8,6 +8,16 @@
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# Eclipse
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
# Gradle
|
||||
bin/
|
||||
build/
|
||||
.gradle/
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
image: maven:3.8.3-openjdk-17
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script:
|
||||
- mvn --version
|
||||
- java --version
|
||||
- mvn clean package -DskipTests
|
||||
allow_failure: false
|
||||
artifacts:
|
||||
when: on_success
|
||||
paths:
|
||||
- target/QSFindItemAddOn*.jar
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "libs/Utilities-OG"]
|
||||
path = libs/Utilities-OG
|
||||
url = https://git.trueog.net/trueog/Utilities-OG
|
||||
@@ -0,0 +1,23 @@
|
||||
## Release 2.0.5.3
|
||||
### Features
|
||||
- Added shop TP delay ([#28](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues/28))
|
||||
### Bug fixes
|
||||
- Fix for issue [#31](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues/31)
|
||||
|
||||
## Release 2.0.5.2
|
||||
### Plugin updates
|
||||
- Updated the addon to make it compatible with the recent QuickShop and other dependency updates.
|
||||
|
||||
## Release 2.0.5.1
|
||||
### Plugin updates
|
||||
- Updated QuickShop-Hikari dependency to v4.0.0.0
|
||||
- Updated PlayerWarps dependency to v6.18.1
|
||||
- Updated QuickShop-Reremake dependency to v5.1.1.2
|
||||
### Bug fixes
|
||||
- Fixed issue [#25](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues/25)
|
||||
|
||||
## Release 2.0.5.0
|
||||
### Bug fixes
|
||||
- Fix for Issue [#24](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues/24)
|
||||
- Fixed a bug related to nearest warp teleportation algorithm
|
||||
- Other minor bug fixes
|
||||
@@ -1,26 +0,0 @@
|
||||
# Contributing to Shop Search AddOn
|
||||
|
||||
If you have experience in making bukkit/spigot plugins, you can contribute to the Shop Search AddOn codebase.
|
||||
Just make a fork and then make a pull request when you're done.
|
||||
Please try to follow the [Google Java Style](https://google.github.io/styleguide/javaguide.html), or just try to copy the style of code found in the class you're editing.
|
||||
But, please don't increase the plugin version number.
|
||||
|
||||
### How to compile?
|
||||
|
||||
**Requirements**
|
||||
1. Java 17 JDK in PATH
|
||||
2. Git
|
||||
3. Maven
|
||||
|
||||
**Compiling from source**
|
||||
```shell
|
||||
git clone https://gitlab.com/ronsane/QSFindItemAddOn.git
|
||||
cd QSFindItemAddOn/
|
||||
mvn clean install
|
||||
```
|
||||
|
||||
### After making a Fork
|
||||
1. Please create your own sub-branch before adding your changes.
|
||||
2. Sub-branch naming convention:
|
||||
1. If it's a new feature you are implementing, name should be `feature/<your feature name>` without the `<>`.
|
||||
2. If it's a bug you're fixing, name should be `issuefix/<issue number>` without the `<>`.
|
||||
@@ -1,10 +1,9 @@
|
||||
# Shop Search AddOn For QuickShop
|
||||
### Version: 2.0.5.1-RELEASE
|
||||
# QSFindItemAddOn-OG
|
||||
|
||||
An unofficial add-on for the QuickShop Reremake and Hikari spigot plugin.
|
||||
Adds a `/finditem` command in game for searching through all the shops on the server.
|
||||
A 1.19.4 fork of QSFindItemAddOn, an unofficial add-on for the QuickShop Hikari and Reremake spigot plugin.
|
||||
Adds a `/find` command in game for searching through all the shops on the server.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
## Features
|
||||
@@ -29,13 +28,13 @@ Adds a `/finditem` command in game for searching through all the shops on the se
|
||||
- All messages in the config.yml support hexcodes.
|
||||
|
||||
**View all shops on server**
|
||||
- You can do `/finditem TO_BUY *` or `/finditem TO_SELL *` to view all shops on the server. As of this version, the sequence is always randomized. Sorting options are a work in progress.
|
||||
- You can do `/find TO_BUY *` or `/find TO_SELL *` to view all shops on the server. As of this version, the sequence is always randomized. Sorting options are a work in progress.
|
||||
|
||||
**Shop visit count**
|
||||
- You can choose to display shop visits count in the shop lore in Search GUI. Just add the placeholder `{SHOP_VISITS}` in the `shop-gui-item-lore` in config.yml. To prevent visit spamming, a new config property `shop-player-visit-cooldown-in-minutes` has been added. Please don't use decimals here. 😁
|
||||
|
||||
**Customizable command aliases**
|
||||
- You can find a property in config.yml called `command-alias` where you can specify your own list of command aliases for /finditem command. If you don't wish to add any, just make it as:
|
||||
- You can find a property in config.yml called `command-alias` where you can specify your own list of command aliases for /find command. If you don't wish to add any, just make it as:
|
||||
```yaml
|
||||
command-alias: []
|
||||
```
|
||||
@@ -48,25 +47,25 @@ command-alias: []
|
||||
- Remember, this applies only to Essential Warps.
|
||||
- WorldGuard region support for fetching the WorldGuard region the shop is in (if overlapping regions, highest priority will be chosen)
|
||||
|
||||
>Check out the sample config.yml [here](https://gitlab.com/ronsane/QSFindItemAddOn/-/wikis/config.yml-%5BFor-QuickShopAddOn-v2.*%5D).
|
||||
>Check out the sample config.yml [here](https://github.com/myzticbean/QSFindItemAddOn/wiki/Sample-config.yml).
|
||||
|
||||
## Requires
|
||||
- [QuickShop Reremake](https://www.spigotmc.org/resources/62575/) 5.0 or higher (Use add-on v1.7 for QuickShop version 4.0.*)
|
||||
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v5.2 or higher
|
||||
|
||||
OR
|
||||
**OR**
|
||||
|
||||
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v4.0.0.0 or higher
|
||||
- [QuickShop Reremake](https://www.spigotmc.org/resources/62575/) 5.1 or higher (Use add-on v1.7 for QuickShop version 4.0.*)
|
||||
|
||||
## Assumptions
|
||||
- A compatible economy plugin is installed
|
||||
- [Vault](https://www.spigotmc.org/resources/34315/) 1.7.3 or higher is installed
|
||||
|
||||
## Issue Tracking
|
||||
Please create a new issue [here](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues) if you encounter any errors. Please try to explain in detail about your issue, and attach your console log if possible.
|
||||
Please create a new issue [here](https://github.com/myzticbean/QSFindItemAddOn/issues) if you encounter any errors. Please try to explain in detail about your issue, and attach your console log if possible.
|
||||
You can also find the list of features currently being worked on (if any) in the same link.
|
||||
|
||||
## How to contribute?
|
||||
See more details [here](../../../CONTRIBUTING.md).
|
||||
See more details [here](https://github.com/myzticbean/QSFindItemAddOn/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## BStats Metrics
|
||||
[](https://bstats.org/plugin/bukkit/QSFindItemAddOn/12382)
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Fetch all submodule content.
|
||||
git submodule update --force --recursive --init
|
||||
@@ -0,0 +1,190 @@
|
||||
/* ------------------------------ 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.
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------- Metadata ------------------------------ */
|
||||
group = "io.myzticbean.FindItemAddOnOG" // Declare bundle identifier.
|
||||
|
||||
version = "1.0.1" // Declare plugin version (will be in .jar).
|
||||
|
||||
val apiVersion = "1.19" // Declare minecraft server target version.
|
||||
val platformApi = "org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT"
|
||||
|
||||
/* ----------------------------- Resources ----------------------------- */
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
val inputsProps =
|
||||
mapOf(
|
||||
"version" to version.toString(),
|
||||
"apiVersion" to apiVersion,
|
||||
"projectName" to project.name,
|
||||
"projectGroup" to project.group.toString(),
|
||||
)
|
||||
val templateProps =
|
||||
mapOf(
|
||||
"version" to version.toString(),
|
||||
"apiVersion" to apiVersion,
|
||||
"project" to mapOf("name" to project.name, "group" to project.group.toString()),
|
||||
)
|
||||
inputs.properties(inputsProps) // Indicates to rerun if version changes.
|
||||
filteringCharset = "UTF-8"
|
||||
filesMatching("plugin.yml") { expand(templateProps) }
|
||||
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
|
||||
}
|
||||
|
||||
val copyReadme by
|
||||
tasks.registering(Copy::class) {
|
||||
val templateProps =
|
||||
mapOf(
|
||||
"version" to version.toString(),
|
||||
"apiVersion" to apiVersion,
|
||||
"project" to mapOf("name" to project.name, "group" to project.group.toString()),
|
||||
)
|
||||
from("src/main/doc") {
|
||||
include("README.md")
|
||||
expand(templateProps)
|
||||
}
|
||||
into(layout.buildDirectory.dir("generated/readme"))
|
||||
}
|
||||
|
||||
/* ---------------------- Java project deps ---------------------------- */
|
||||
dependencies {
|
||||
implementation("com.ghostchu.quickshop.compatibility:common:5.2.0.7") {
|
||||
exclude(group = "org.jetbrains", module = "annotations")
|
||||
exclude(group = "net.kyori", module = "adventure-platform-bukkit")
|
||||
exclude(group = "com.github.juliomarcopineda", module = "jdbc-stream")
|
||||
exclude(group = "one.util", module = "streamex")
|
||||
exclude(group = "tne.tne", module = "TheNewEconomy")
|
||||
exclude(group = "me.xanium", module = "GemsEconomy")
|
||||
}
|
||||
compileOnly("com.ghostchu:quickshop-bukkit:5.2.0.5:shaded") {
|
||||
exclude(group = "org.jetbrains", module = "annotations")
|
||||
exclude(group = "net.kyori", module = "adventure-platform-bukkit")
|
||||
exclude(group = "com.github.juliomarcopineda", module = "jdbc-stream")
|
||||
exclude(group = "one.util", module = "streamex")
|
||||
exclude(group = "tne.tne", module = "TheNewEconomy")
|
||||
exclude(group = "me.xanium", module = "GemsEconomy")
|
||||
}
|
||||
compileOnly(platformApi) // Declare Purpur API version to be packaged.
|
||||
compileOnlyApi(project(":libs:Utilities-OG")) // Import TrueOG Network Utilities-OG Java API (from source).
|
||||
compileOnly("com.ghostchu:quickshop-api:5.2.0.7") { // Import QuickShop-Hikari Core API.
|
||||
exclude(group = "org.jetbrains", module = "annotations")
|
||||
exclude(group = "net.kyori", module = "adventure-platform-bukkit")
|
||||
exclude(group = "com.github.juliomarcopineda", module = "jdbc-stream")
|
||||
exclude(group = "one.util", module = "streamex")
|
||||
exclude(group = "tne.tne", module = "TheNewEconomy")
|
||||
exclude(group = "me.xanium", module = "GemsEconomy")
|
||||
}
|
||||
compileOnly("com.github.true-og.OpenInv:openinvapi:a85e8ebc28")
|
||||
compileOnly("org.maxgamer:QuickShop:5.1.2.5-SNAPSHOT") { isTransitive = false }
|
||||
implementation("io.papermc:paperlib:1.0.7")
|
||||
compileOnly("net.essentialsx:EssentialsX:2.21.0") { isTransitive = false }
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.8") { // Import WorldGuard API.
|
||||
exclude(group = "com.google.code.findbugs", module = "annotations")
|
||||
exclude(group = "net.java.truecommons", module = "truecommons-logging")
|
||||
exclude(group = "org.slf4j", module = "jcl-over-slf4j")
|
||||
exclude(group = "org.bstats", module = "bstats-bukkit")
|
||||
exclude(group = "org.bukkit", module = "bukkit")
|
||||
exclude(group = "com.google.guava", module = "guava")
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
exclude(group = "org.yaml", module = "snakeyaml")
|
||||
exclude(group = "com.google.code.findbugs", module = "jsr305")
|
||||
exclude(group = "org.spigotmc", module = "spigot-api")
|
||||
exclude(group = "org.apache.httpcomponents", module = "httpclient")
|
||||
exclude(group = "net.java.truevfs", module = "truevfs-comp-zip")
|
||||
exclude(group = "net.java.truevfs", module = "truevfs-comp-tardriver")
|
||||
}
|
||||
implementation("com.google.code.gson:gson:2.9.0")
|
||||
compileOnly("org.jetbrains:annotations:23.0.0") { isTransitive = false }
|
||||
compileOnly("org.projectlombok:lombok:1.18.26")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.26")
|
||||
implementation("org.apache.commons:commons-lang3:3.12.0") { isTransitive = false }
|
||||
compileOnly("net.kyori:adventure-api:4.16.0")
|
||||
compileOnly("cc.carm.lib:easysql-api:0.4.7")
|
||||
}
|
||||
|
||||
apply(from = "eclipse.gradle.kts") // Import eclipse classpath support script.
|
||||
|
||||
tasks.matching { it.name.startsWith("eclipse") }.configureEach { dependsOn(copyReadme) }
|
||||
|
||||
/* ---------------------- 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.
|
||||
archiveClassifier.set("") // Use empty string instead of null.
|
||||
minimize()
|
||||
}
|
||||
|
||||
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
|
||||
|
||||
tasks.build { dependsOn(tasks.shadowJar, copyReadme) } // 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}") }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
<module name="Checker">
|
||||
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="FinalLocalVariable"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="Indentation">
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\borg\.junit\.jupiter\.api\.Assertions\.fail\s*\(\s*"Not yet implemented"\s*\)\s*;"/>
|
||||
<property name="message" value="Remove placeholder fail() and implement the test."/>
|
||||
<property name="ignoreCase" value="true"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="(?<!\w)fail\s*\(\s*"Not yet implemented"\s*\)\s*;"/>
|
||||
<property name="message" value="Remove placeholder fail() and implement the test."/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,404 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<profiles version="23">
|
||||
<profile kind="CodeFormatterProfile" name="TrueOG Network Formatting" version="23">
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_not_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case_after_arrow" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_arrows_in_switch_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow" value="20"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
</profile>
|
||||
</profiles>
|
||||
@@ -0,0 +1,151 @@
|
||||
/* This is free and unencumbered software released into the public domain */
|
||||
|
||||
import org.gradle.plugins.ide.eclipse.model.EclipseModel
|
||||
import java.nio.file.Files
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.transform.OutputKeys
|
||||
import javax.xml.transform.TransformerFactory
|
||||
import javax.xml.transform.dom.DOMSource
|
||||
import javax.xml.transform.stream.StreamResult
|
||||
|
||||
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
|
||||
|
||||
val kotlinPluginProjects = configurations
|
||||
.getByName("compileClasspath")
|
||||
.allDependencies
|
||||
.filterIsInstance<ProjectDependency>()
|
||||
.filter { it -> it.attributes.getAttribute(kotlinAttribute) != null }
|
||||
.map { it.path }
|
||||
kotlinPluginProjects.forEach { evaluationDependsOn(it) }
|
||||
|
||||
val ideLibs: Configuration by
|
||||
configurations.creating {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
}
|
||||
|
||||
configure<EclipseModel> {
|
||||
project {
|
||||
name = "QSFindItemAddOn-OG-Plugin"
|
||||
}
|
||||
classpath {
|
||||
plusConfigurations.add(ideLibs)
|
||||
}
|
||||
}
|
||||
|
||||
val ideLibDir = layout.buildDirectory.dir("ide-libs")
|
||||
val hashRegex = Regex("-[0-9a-fA-F]{10}(?=\\.jar$)") // Black magic.
|
||||
|
||||
val copyTasks = mutableListOf<TaskProvider<Copy>>()
|
||||
|
||||
kotlinPluginProjects.forEach { path ->
|
||||
val sub = project(path)
|
||||
val shadowJarProv = sub.tasks.named("shadowJar")
|
||||
val copyTask =
|
||||
tasks.register<Copy>("ideCopy${sub.name.replaceFirstChar(Char::titlecase)}") {
|
||||
dependsOn(shadowJarProv)
|
||||
from(shadowJarProv)
|
||||
into(ideLibDir)
|
||||
rename { it.replace(hashRegex, "") } // Remove git commit hash from jarfile.
|
||||
}
|
||||
copyTasks += copyTask
|
||||
}
|
||||
|
||||
/* Ensure the jars exist before .classpath is generated */
|
||||
tasks.named("eclipseClasspath").configure { dependsOn(copyTasks) }
|
||||
|
||||
/* Supply those jars to the ideLibs configuration (after evaluation) */
|
||||
afterEvaluate { dependencies { add("ideLibs", fileTree(ideLibDir) { include("*.jar") }) } }
|
||||
|
||||
val injectIdeLibs =
|
||||
tasks.register("injectIdeLibs") {
|
||||
dependsOn("eclipse") // run after all eclipse files are generated
|
||||
doLast {
|
||||
val cpFile = file(".classpath")
|
||||
if (!cpFile.exists()) return@doLast
|
||||
|
||||
val jars = fileTree(ideLibDir.get()) { include("*.jar") }.files.sortedBy { it.name }
|
||||
if (jars.isEmpty()) return@doLast
|
||||
|
||||
// Parse DOM
|
||||
val dbf = DocumentBuilderFactory.newInstance()
|
||||
val doc = dbf.newDocumentBuilder().parse(cpFile)
|
||||
val root = doc.documentElement
|
||||
|
||||
// Helper to see if an entry already exists
|
||||
fun exists(path: String): Boolean =
|
||||
root.getElementsByTagName("classpathentry").let { list ->
|
||||
(0 until list.length).any { i ->
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue
|
||||
kind == "lib" && p == path
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any entry that points to ide-libs dir (folder or jars) to avoid dupes
|
||||
val toRemove = mutableListOf<org.w3c.dom.Node>()
|
||||
val list = root.getElementsByTagName("classpathentry")
|
||||
val dirPath = ideLibDir.get().asFile.absolutePath
|
||||
for (i in 0 until list.length) {
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue ?: ""
|
||||
if (kind == "lib" && (p == dirPath || p.startsWith("$dirPath/"))) {
|
||||
toRemove += n
|
||||
}
|
||||
}
|
||||
toRemove.forEach { root.removeChild(it) }
|
||||
|
||||
// Append our jar entries LAST
|
||||
jars.forEach { f ->
|
||||
val abs = f.absolutePath
|
||||
if (!exists(abs)) {
|
||||
val entry = doc.createElement("classpathentry")
|
||||
entry.setAttribute("kind", "lib")
|
||||
entry.setAttribute("path", abs)
|
||||
root.appendChild(entry)
|
||||
}
|
||||
}
|
||||
|
||||
// Write back pretty
|
||||
val tf =
|
||||
TransformerFactory.newInstance().newTransformer().apply {
|
||||
setOutputProperty(OutputKeys.INDENT, "yes")
|
||||
setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1")
|
||||
setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no")
|
||||
setOutputProperty(OutputKeys.ENCODING, "UTF-8")
|
||||
}
|
||||
Files.newBufferedWriter(cpFile.toPath()).use { w -> tf.transform(DOMSource(doc), StreamResult(w)) }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("eclipse").configure { finalizedBy(injectIdeLibs) }
|
||||
|
||||
val eclipseModel = extensions.getByType<EclipseModel>()
|
||||
|
||||
fun Project.addResolvableEclipseConfigs() {
|
||||
val jarAttr =
|
||||
objects.named(org.gradle.api.attributes.LibraryElements::class, org.gradle.api.attributes.LibraryElements.JAR)
|
||||
val apiAttr = objects.named(org.gradle.api.attributes.Usage::class, org.gradle.api.attributes.Usage.JAVA_API)
|
||||
|
||||
val compileOnlyRes =
|
||||
configurations.create("eclipseCompileOnly") {
|
||||
extendsFrom(configurations.getByName("compileOnly"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
val compileOnlyApiRes =
|
||||
configurations.create("eclipseCompileOnlyApi") {
|
||||
extendsFrom(configurations.getByName("compileOnlyApi"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
eclipseModel.classpath.plusConfigurations.addAll(listOf(compileOnlyRes, compileOnlyApiRes))
|
||||
}
|
||||
|
||||
addResolvableEclipseConfigs()
|
||||
Vendored
BIN
Binary file not shown.
+7
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
Submodule
+1
Submodule libs/Utilities-OG added at 8b5c86cc9c.
@@ -1,318 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>io.myzticbean.FindItemAddOn</groupId>
|
||||
<artifactId>QSFindItemAddOn</artifactId>
|
||||
<version>2.0.5.1-RELEASE</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>QSFindItemAddOn</name>
|
||||
|
||||
<properties>
|
||||
<java.version>16</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<!-- Below path is where your plugin jar will be copied automatically upon build, comment out if on a Mac -->
|
||||
<!-- <outputDirectory>E:\MCServer_1.18\plugins</outputDirectory> -->
|
||||
<!-- Comment out if on a PC -->
|
||||
<!-- <outputDirectory>/Users/${user.name}/IdeaProjects/MCServer_1.18/plugins</outputDirectory> -->
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>readme</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.basedir}</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/doc</directory>
|
||||
<includes>
|
||||
<include>README.md</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-public</id>
|
||||
<url>https://repo.codemc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>essentials-releases</id>
|
||||
<url>https://repo.essentialsx.net/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>essentials-snapshots</id>
|
||||
<url>https://repo.essentialsx.net/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>olzie-repo</id>
|
||||
<url>https://repo.olziedev.com/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.19.3-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.maxgamer</groupId>
|
||||
<artifactId>QuickShop</artifactId>
|
||||
<version>5.1.1.2</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ghostchu</groupId>
|
||||
<artifactId>quickshop-bukkit</artifactId>
|
||||
<version>4.0.0.0</version>
|
||||
<scope>provided</scope>
|
||||
<classifier>shaded</classifier>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.github.juliomarcopineda</groupId>
|
||||
<artifactId>jdbc-stream</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>one.util</groupId>
|
||||
<artifactId>streamex</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>tne.tne</groupId>
|
||||
<artifactId>TheNewEconomy</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>me.xanium</groupId>
|
||||
<artifactId>GemsEconomy</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.essentialsx</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.19.4</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.olziedev</groupId>
|
||||
<artifactId>playerwarps-api</artifactId>
|
||||
<version>6.18.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.7</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>annotations</artifactId>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>truecommons-logging</artifactId>
|
||||
<groupId>net.java.truecommons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<groupId>org.bstats</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<groupId>org.bukkit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>truevfs-comp-zip</artifactId>
|
||||
<groupId>net.java.truevfs</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>truevfs-comp-tardriver</artifactId>
|
||||
<groupId>net.java.truevfs</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>23.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.KodySimpson</groupId>
|
||||
<artifactId>SimpAPI</artifactId>
|
||||
<version>4.3.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,35 @@
|
||||
rootProject.name = "QSFindItemAddOn-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
|
||||
}
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
|
||||
/* ---------------------------- 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://oss.sonatype.org/content/groups/public/") }
|
||||
maven { url = uri("https://repo.codemc.io/repository/maven-public/") }
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.essentialsx.net/releases/") }
|
||||
maven { url = uri("https://repo.essentialsx.net/snapshots/") }
|
||||
maven { url = uri("https://maven.enginehub.org/repo/") }
|
||||
maven { url = uri("https://repo.glaremasters.me/repository/public/") }
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven { url = uri("https://jitpack.io") }
|
||||
maven { url = uri("https://repo.olziedev.com/") }
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -1,10 +1,10 @@
|
||||
# Shop Search AddOn For QuickShop
|
||||
### Version: ${project.version}
|
||||
|
||||
An unofficial add-on for the QuickShop Reremake and Hikari spigot plugin.
|
||||
Adds a `/finditem` command in game for searching through all the shops on the server.
|
||||
An unofficial add-on for the QuickShop Hikari and Reremake spigot plugin.
|
||||
Adds a `/find` command in game for searching through all the shops on the server.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
## Features
|
||||
@@ -29,13 +29,13 @@ Adds a `/finditem` command in game for searching through all the shops on the se
|
||||
- All messages in the config.yml support hexcodes.
|
||||
|
||||
**View all shops on server**
|
||||
- You can do `/finditem TO_BUY *` or `/finditem TO_SELL *` to view all shops on the server. As of this version, the sequence is always randomized. Sorting options are a work in progress.
|
||||
- You can do `/find TO_BUY *` or `/find TO_SELL *` to view all shops on the server. As of this version, the sequence is always randomized. Sorting options are a work in progress.
|
||||
|
||||
**Shop visit count**
|
||||
- You can choose to display shop visits count in the shop lore in Search GUI. Just add the placeholder `{SHOP_VISITS}` in the `shop-gui-item-lore` in config.yml. To prevent visit spamming, a new config property `shop-player-visit-cooldown-in-minutes` has been added. Please don't use decimals here. 😁
|
||||
|
||||
**Customizable command aliases**
|
||||
- You can find a property in config.yml called `command-alias` where you can specify your own list of command aliases for /finditem command. If you don't wish to add any, just make it as:
|
||||
- You can find a property in config.yml called `command-alias` where you can specify your own list of command aliases for /find command. If you don't wish to add any, just make it as:
|
||||
```yaml
|
||||
command-alias: []
|
||||
```
|
||||
@@ -48,25 +48,25 @@ command-alias: []
|
||||
- Remember, this applies only to Essential Warps.
|
||||
- WorldGuard region support for fetching the WorldGuard region the shop is in (if overlapping regions, highest priority will be chosen)
|
||||
|
||||
>Check out the sample config.yml [here](https://gitlab.com/ronsane/QSFindItemAddOn/-/wikis/config.yml-%5BFor-QuickShopAddOn-v2.*%5D).
|
||||
>Check out the sample config.yml [here](https://github.com/myzticbean/QSFindItemAddOn/wiki/Sample-config.yml).
|
||||
|
||||
## Requires
|
||||
- [QuickShop Reremake](https://www.spigotmc.org/resources/62575/) 5.0 or higher (Use add-on v1.7 for QuickShop version 4.0.*)
|
||||
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v5.2 or higher
|
||||
|
||||
OR
|
||||
**OR**
|
||||
|
||||
- [QuickShop-Hikari](https://www.spigotmc.org/resources/100125/) v4.0.0.0 or higher
|
||||
- [QuickShop Reremake](https://www.spigotmc.org/resources/62575/) 5.1 or higher (Use add-on v1.7 for QuickShop version 4.0.*)
|
||||
|
||||
## Assumptions
|
||||
- A compatible economy plugin is installed
|
||||
- [Vault](https://www.spigotmc.org/resources/34315/) 1.7.3 or higher is installed
|
||||
|
||||
## Issue Tracking
|
||||
Please create a new issue [here](https://gitlab.com/ronsane/QSFindItemAddOn/-/issues) if you encounter any errors. Please try to explain in detail about your issue, and attach your console log if possible.
|
||||
Please create a new issue [here](https://github.com/myzticbean/QSFindItemAddOn/issues) if you encounter any errors. Please try to explain in detail about your issue, and attach your console log if possible.
|
||||
You can also find the list of features currently being worked on (if any) in the same link.
|
||||
|
||||
## How to contribute?
|
||||
See more details [here](../../../CONTRIBUTING.md).
|
||||
See more details [here](https://github.com/myzticbean/QSFindItemAddOn/blob/master/CONTRIBUTING.md).
|
||||
|
||||
## BStats Metrics
|
||||
[](https://bstats.org/plugin/bukkit/QSFindItemAddOn/12382)
|
||||
+122
-53
@@ -1,21 +1,23 @@
|
||||
package io.myzticbean.finditemaddon.Commands.QSSubCommands;
|
||||
|
||||
import com.ghostchu.quickshop.api.command.CommandHandler;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.ghostchu.quickshop.api.command.CommandHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* @author ronsane
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class FindItemCmdHikariImpl implements CommandHandler<Player> {
|
||||
|
||||
@@ -26,96 +28,163 @@ public class FindItemCmdHikariImpl implements CommandHandler<Player> {
|
||||
private final List<String> buyOrSellList = new ArrayList<>();
|
||||
|
||||
public FindItemCmdHikariImpl() {
|
||||
if(StringUtils.isBlank(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
|
||||
if (StringUtils.isBlank(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
|
||||
this.hideSubCommand = "hideshop";
|
||||
}
|
||||
else {
|
||||
this.hideSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
|
||||
} else {
|
||||
|
||||
this.hideSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(
|
||||
FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " ")) {
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
this.revealShopSubCommand = "revealshop";
|
||||
|
||||
} else {
|
||||
|
||||
this.revealShopSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
else {
|
||||
this.revealShopSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Player commandSender, @NotNull String label, @NotNull String[] args) {
|
||||
if(args.length == 0) {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
}
|
||||
else if(args.length == 1) {
|
||||
if(commandSender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
if(args[0].equalsIgnoreCase(hideSubCommand)) {
|
||||
|
||||
if (args.length == 0) {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
} else if (args.length == 1) {
|
||||
|
||||
if (commandSender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
if (args[0].equalsIgnoreCase(hideSubCommand)) {
|
||||
|
||||
cmdExecutor.handleHideShop(commandSender);
|
||||
} else if(args[0].equalsIgnoreCase(revealShopSubCommand)) {
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(revealShopSubCommand)) {
|
||||
|
||||
cmdExecutor.handleRevealShop(commandSender);
|
||||
|
||||
} else {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cYou don't have permission to use that!"));
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&cYou don't have permission to use that!"));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
cmdExecutor.handleShopSearch(args[0], commandSender, args[1]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
if(itemsList.isEmpty()) {
|
||||
for(Material mat : Material.values()) {
|
||||
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel,
|
||||
@NotNull String[] args)
|
||||
{
|
||||
|
||||
if (itemsList.isEmpty()) {
|
||||
|
||||
for (Material mat : Material.values()) {
|
||||
|
||||
itemsList.add(mat.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(buyOrSellList.isEmpty()) {
|
||||
|
||||
if (buyOrSellList.isEmpty()) {
|
||||
|
||||
// to-buy
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " ")) {
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buyOrSellList.add("TO_BUY");
|
||||
|
||||
} else {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
else {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
}
|
||||
|
||||
// to-sell
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " ")) {
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buyOrSellList.add("TO_SELL");
|
||||
|
||||
} else {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
else {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
|
||||
}
|
||||
|
||||
// hide
|
||||
if(sender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE);
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE);
|
||||
if (sender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE);
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
if(args.length == 1) {
|
||||
for(String a : buyOrSellList) {
|
||||
if(a.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
if (args.length == 1) {
|
||||
|
||||
for (String a : buyOrSellList) {
|
||||
|
||||
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
|
||||
result.add(a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else if(args.length == 2) {
|
||||
for(String a : itemsList) {
|
||||
if(a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
|
||||
} else if (args.length == 2) {
|
||||
|
||||
for (String a : itemsList) {
|
||||
|
||||
if (a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
|
||||
result.add(a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+119
-51
@@ -1,9 +1,8 @@
|
||||
package io.myzticbean.finditemaddon.Commands.QSSubCommands;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -11,8 +10,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.api.command.CommandHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class FindItemCmdReremakeImpl implements CommandHandler<Player> {
|
||||
|
||||
@@ -23,96 +24,163 @@ public class FindItemCmdReremakeImpl implements CommandHandler<Player> {
|
||||
private final List<String> buyOrSellList = new ArrayList<>();
|
||||
|
||||
public FindItemCmdReremakeImpl() {
|
||||
if(StringUtils.isBlank(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
|
||||
if (StringUtils.isBlank(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
|
||||
this.hideSubCommand = "hideshop";
|
||||
}
|
||||
else {
|
||||
this.hideSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
|
||||
} else {
|
||||
|
||||
this.hideSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(
|
||||
FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " ")) {
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
this.revealShopSubCommand = "revealshop";
|
||||
|
||||
} else {
|
||||
|
||||
this.revealShopSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
else {
|
||||
this.revealShopSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(Player commandSender, @NotNull String label, @NotNull String[] args) {
|
||||
if(args.length == 0) {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
}
|
||||
else if(args.length == 1) {
|
||||
if(commandSender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
if(args[0].equalsIgnoreCase(hideSubCommand)) {
|
||||
|
||||
if (args.length == 0) {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
} else if (args.length == 1) {
|
||||
|
||||
if (commandSender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
if (args[0].equalsIgnoreCase(hideSubCommand)) {
|
||||
|
||||
cmdExecutor.handleHideShop(commandSender);
|
||||
} else if(args[0].equalsIgnoreCase(revealShopSubCommand)) {
|
||||
|
||||
} else if (args[0].equalsIgnoreCase(revealShopSubCommand)) {
|
||||
|
||||
cmdExecutor.handleRevealShop(commandSender);
|
||||
|
||||
} else {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cIncorrect usage!"));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cYou don't have permission to use that!"));
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&cYou don't have permission to use that!"));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
cmdExecutor.handleShopSearch(args[0], commandSender, args[1]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||
if(itemsList.isEmpty()) {
|
||||
for(Material mat : Material.values()) {
|
||||
public @Nullable List<String> onTabComplete(@NotNull Player sender, @NotNull String commandLabel,
|
||||
@NotNull String[] args)
|
||||
{
|
||||
|
||||
if (itemsList.isEmpty()) {
|
||||
|
||||
for (Material mat : Material.values()) {
|
||||
|
||||
itemsList.add(mat.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(buyOrSellList.isEmpty()) {
|
||||
|
||||
if (buyOrSellList.isEmpty()) {
|
||||
|
||||
// to-buy
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " ")) {
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buyOrSellList.add("TO_BUY");
|
||||
|
||||
} else {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
else {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
}
|
||||
|
||||
// to-sell
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " ")) {
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buyOrSellList.add("TO_SELL");
|
||||
|
||||
} else {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
else {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE);
|
||||
}
|
||||
|
||||
// hide
|
||||
if(sender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE);
|
||||
buyOrSellList.add(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE);
|
||||
if (sender.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE);
|
||||
buyOrSellList.add(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
if(args.length == 1) {
|
||||
for(String a : buyOrSellList) {
|
||||
if(a.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
if (args.length == 1) {
|
||||
|
||||
for (String a : buyOrSellList) {
|
||||
|
||||
if (a.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
|
||||
result.add(a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else if(args.length == 2) {
|
||||
for(String a : itemsList) {
|
||||
if(a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
|
||||
} else if (args.length == 2) {
|
||||
|
||||
for (String a : itemsList) {
|
||||
|
||||
if (a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
|
||||
result.add(a);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,83 +1,131 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditem TO_BUY
|
||||
* @author ronsane
|
||||
* Sub Command Handler for /find TO_BUY
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class BuySubCmd extends SubCommand {
|
||||
public class BuySubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final String buySubCommand;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public BuySubCmd() {
|
||||
|
||||
// to-buy
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " ")) {
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
buySubCommand = "TO_BUY";
|
||||
|
||||
} else {
|
||||
|
||||
buySubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
else {
|
||||
buySubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE;
|
||||
}
|
||||
if(itemsList.isEmpty()) {
|
||||
for(Material mat : Material.values()) {
|
||||
|
||||
if (itemsList.isEmpty()) {
|
||||
|
||||
for (Material mat : Material.values()) {
|
||||
|
||||
itemsList.add(mat.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
return buySubCommand;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
||||
return "Find shops that buy a specific item";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditem " + buySubCommand + " {item type | item name}";
|
||||
|
||||
return "/find " + buySubCommand + " {item type | item name}";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
if(args.length != 2)
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INCORRECT_USAGE_MSG));
|
||||
else
|
||||
cmdExecutor.handleShopSearch(buySubCommand, commandSender, args[1]);
|
||||
}
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
final String itemArg;
|
||||
if (args.length == 1) {
|
||||
|
||||
itemArg = args[0];
|
||||
|
||||
} else if (args.length == 2 && buySubCommand.equalsIgnoreCase(args[0])) {
|
||||
|
||||
itemArg = args[1];
|
||||
|
||||
} else {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INCORRECT_USAGE_MSG));
|
||||
return true;
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] args) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for(String a : itemsList) {
|
||||
if(a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
result.add(a);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
cmdExecutor.handleShopSearch(buySubCommand, commandSender, itemArg);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
final String token;
|
||||
if (args.length == 1) {
|
||||
|
||||
token = args[0];
|
||||
|
||||
} else if (args.length == 2 && buySubCommand.equalsIgnoreCase(args[0])) {
|
||||
|
||||
token = args[1];
|
||||
|
||||
} else {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
final String lower = token == null ? "" : token.toLowerCase();
|
||||
return new ArrayList<>(
|
||||
itemsList.stream().filter(a -> a.toLowerCase().startsWith(lower)).collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+44
-26
@@ -1,62 +1,80 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditem hideshop
|
||||
* @author ronsane
|
||||
* Sub Command Handler for /find hideshop
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class HideShopSubCmd extends SubCommand {
|
||||
public class HideShopSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final String hideSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public HideShopSubCmd() {
|
||||
if(StringUtils.isBlank(FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
|
||||
if (StringUtils.isBlank(FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE)) {
|
||||
|
||||
hideSubCommand = "hideshop";
|
||||
|
||||
} else {
|
||||
|
||||
hideSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
else {
|
||||
hideSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_HIDESHOP_AUTOCOMPLETE;
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
return hideSubCommand;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Run this command while looking at the shop (NOT the shop sign) you wish to hide and it will no" +
|
||||
" longer appear in searches";
|
||||
|
||||
return "Run this command while looking at the shop (NOT the shop sign) you wish to hide and it will no"
|
||||
+ " longer appear in searches";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditem " + hideSubCommand;
|
||||
|
||||
return "/find " + hideSubCommand;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
cmdExecutor.handleHideShop(commandSender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] strings) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,52 +1,66 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditemadmin reload
|
||||
* @author ronsane
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class ReloadSubCmd extends SubCommand {
|
||||
public class ReloadSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public ReloadSubCmd() {
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
return "reload";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
||||
return "Reloads config.yml";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
|
||||
return "/finditemadmin reload";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] strings) {
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
cmdExecutor.handlePluginReload(commandSender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] strings) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+32
-17
@@ -1,53 +1,68 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditem restart
|
||||
* Sub Command Handler for /find restart
|
||||
*
|
||||
* @deprecated No longer used, will be removed in future versions
|
||||
* @author ronsane
|
||||
* @author myzticbean
|
||||
*/
|
||||
@Deprecated
|
||||
public class RestartSubCmd extends SubCommand {
|
||||
public class RestartSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public RestartSubCmd() {
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
@Override
|
||||
|
||||
public String getName() {
|
||||
|
||||
return "restart";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
||||
return "Restarts the plugin (NOT recommended in most cases, restart server if necessary)";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
|
||||
return "/finditemadmin restart";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
cmdExecutor.handlePluginRestart(commandSender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] strings) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+43
-25
@@ -1,63 +1,81 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditemadmin revealshop
|
||||
* @author ronsane
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class RevealShopSubCmd extends SubCommand {
|
||||
public class RevealShopSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final String revealShopSubCommand;
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public RevealShopSubCmd() {
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(
|
||||
FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " ")) {
|
||||
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
revealShopSubCommand = "revealshop";
|
||||
|
||||
} else {
|
||||
|
||||
revealShopSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
else {
|
||||
revealShopSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_REVEALSHOP_AUTOCOMPLETE;
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
return revealShopSubCommand;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
||||
return "Run this command while looking at a hidden shop to make it public again";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditem " + revealShopSubCommand;
|
||||
|
||||
return "/find " + revealShopSubCommand;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
cmdExecutor.handleRevealShop(commandSender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] strings) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +1,129 @@
|
||||
package io.myzticbean.finditemaddon.Commands.SAPICommands;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Handlers.CommandHandler.CmdExecutorHandler;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* Sub Command Handler for /finditem TO_SELL
|
||||
* @author ronsane
|
||||
* Sub Command Handler for /find TO_SELL
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class SellSubCmd extends SubCommand {
|
||||
public class SellSubCmd implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final String sellSubCommand;
|
||||
private final List<String> itemsList = new ArrayList<>();
|
||||
private final CmdExecutorHandler cmdExecutor;
|
||||
|
||||
public SellSubCmd() {
|
||||
|
||||
// to-sell
|
||||
if(StringUtils.isBlank(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)) {
|
||||
if (StringUtils.isBlank(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)) {
|
||||
|
||||
sellSubCommand = "TO_SELL";
|
||||
|
||||
} else {
|
||||
|
||||
sellSubCommand = FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE;
|
||||
|
||||
}
|
||||
else {
|
||||
sellSubCommand = FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE;
|
||||
}
|
||||
if(itemsList.isEmpty()) {
|
||||
for(Material mat : Material.values()) {
|
||||
|
||||
if (itemsList.isEmpty()) {
|
||||
|
||||
for (Material mat : Material.values()) {
|
||||
|
||||
itemsList.add(mat.name());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cmdExecutor = new CmdExecutorHandler();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
return sellSubCommand;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases() {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
|
||||
return "Find shops that sell a specific item";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/finditem " + sellSubCommand + " {item type | item name}";
|
||||
|
||||
return "/find " + sellSubCommand + " {item type | item name}";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandSender commandSender, String[] args) {
|
||||
if(args.length != 2)
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INCORRECT_USAGE_MSG));
|
||||
else
|
||||
cmdExecutor.handleShopSearch(sellSubCommand, commandSender, args[1]);
|
||||
}
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
||||
|
||||
final String itemArg;
|
||||
if (args.length == 1) {
|
||||
|
||||
itemArg = args[0];
|
||||
|
||||
} else if (args.length == 2 && sellSubCommand.equalsIgnoreCase(args[0])) {
|
||||
|
||||
itemArg = args[1];
|
||||
|
||||
} else {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INCORRECT_USAGE_MSG));
|
||||
return true;
|
||||
|
||||
@Override
|
||||
public List<String> getSubcommandArguments(Player player, String[] args) {
|
||||
List<String> result = new ArrayList<>();
|
||||
for(String a : itemsList) {
|
||||
if(a.toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
result.add(a);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
cmdExecutor.handleShopSearch(sellSubCommand, commandSender, itemArg);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
final String token;
|
||||
if (args.length == 1) {
|
||||
|
||||
token = args[0];
|
||||
|
||||
} else if (args.length == 2 && sellSubCommand.equalsIgnoreCase(args[0])) {
|
||||
|
||||
token = args[1];
|
||||
|
||||
} else {
|
||||
|
||||
return List.of();
|
||||
|
||||
}
|
||||
|
||||
final String lower = token == null ? "" : token.toLowerCase();
|
||||
return new ArrayList<>(
|
||||
itemsList.stream().filter(a -> a.toLowerCase().startsWith(lower)).collect(Collectors.toList()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +1,68 @@
|
||||
package io.myzticbean.finditemaddon.ConfigUtil;
|
||||
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
|
||||
public class ConfigProvider {
|
||||
|
||||
public final String PLUGIN_PREFIX = ColorTranslator.translateColorCodes(ConfigSetup.get().getString("plugin-prefix"));
|
||||
public final List<String> FIND_ITEM_COMMAND_ALIAS = (List<String>) ConfigSetup.get().getList("find-item-command.command-alias");
|
||||
public final String FIND_ITEM_TO_BUY_AUTOCOMPLETE = ConfigSetup.get().getString("find-item-command.to-buy-autocomplete");
|
||||
public final String FIND_ITEM_TO_SELL_AUTOCOMPLETE = ConfigSetup.get().getString("find-item-command.to-sell-autocomplete");
|
||||
public final String FIND_ITEM_HIDESHOP_AUTOCOMPLETE = ConfigSetup.get().getString("find-item-command.hideshop-autocomplete");
|
||||
public final String FIND_ITEM_REVEALSHOP_AUTOCOMPLETE = ConfigSetup.get().getString("find-item-command.revealshop-autocomplete");
|
||||
public final String FIND_ITEM_CMD_INCORRECT_USAGE_MSG = ConfigSetup.get().getString("find-item-command.incorrect-usage-message");
|
||||
public final String FIND_ITEM_CMD_INVALID_MATERIAL_MSG = ConfigSetup.get().getString("find-item-command.invalid-material-message");
|
||||
public final String FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG = ConfigSetup.get().getString("find-item-command.hiding-shop-owner-invalid-message");
|
||||
public final String SHOP_SEARCH_LOADING_MSG = ConfigSetup.get().getString("find-item-command.shop-search-loading-message");
|
||||
public final String PLUGIN_PREFIX = ConfigSetup.get().getString("plugin-prefix");
|
||||
public final List<String> FIND_ITEM_COMMAND_ALIAS = (List<String>) ConfigSetup.get()
|
||||
.getList("find-item-command.command-alias");
|
||||
public final String FIND_ITEM_TO_BUY_AUTOCOMPLETE = ConfigSetup.get()
|
||||
.getString("find-item-command.to-buy-autocomplete");
|
||||
public final String FIND_ITEM_TO_SELL_AUTOCOMPLETE = ConfigSetup.get()
|
||||
.getString("find-item-command.to-sell-autocomplete");
|
||||
public final String FIND_ITEM_HIDESHOP_AUTOCOMPLETE = ConfigSetup.get()
|
||||
.getString("find-item-command.hideshop-autocomplete");
|
||||
public final String FIND_ITEM_REVEALSHOP_AUTOCOMPLETE = ConfigSetup.get()
|
||||
.getString("find-item-command.revealshop-autocomplete");
|
||||
public final String FIND_ITEM_CMD_INCORRECT_USAGE_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.incorrect-usage-message");
|
||||
public final String FIND_ITEM_CMD_INVALID_MATERIAL_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.invalid-material-message");
|
||||
public final String FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.hiding-shop-owner-invalid-message");
|
||||
public final String SHOP_SEARCH_LOADING_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.shop-search-loading-message");
|
||||
public final String NO_SHOP_FOUND_MSG = ConfigSetup.get().getString("find-item-command.no-shop-found-message");
|
||||
public final String FIND_ITEM_CMD_NO_PERMISSION_MSG = ConfigSetup.get().getString("find-item-command.find-item-command-no-permission-message");
|
||||
public final String FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG = ConfigSetup.get().getString("find-item-command.shop-hide-success-message");
|
||||
public final String FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG = ConfigSetup.get().getString("find-item-command.shop-reveal-success-message");
|
||||
public final String FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG = ConfigSetup.get().getString("find-item-command.shop-already-hidden-message");
|
||||
public final String FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG = ConfigSetup.get().getString("find-item-command.shop-already-public-message");
|
||||
public final String FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG = ConfigSetup.get().getString("find-item-command.invalid-shop-block-message");
|
||||
public final String FIND_ITEM_CMD_NO_PERMISSION_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.find-item-command-no-permission-message");
|
||||
public final String FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.shop-hide-success-message");
|
||||
public final String FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.shop-reveal-success-message");
|
||||
public final String FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.shop-already-hidden-message");
|
||||
public final String FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.shop-already-public-message");
|
||||
public final String FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG = ConfigSetup.get()
|
||||
.getString("find-item-command.invalid-shop-block-message");
|
||||
public final int SHOP_SORTING_METHOD = ConfigSetup.get().getInt("shop-sorting-method");
|
||||
public final boolean SEARCH_LOADED_SHOPS_ONLY = ConfigSetup.get().getBoolean("search-loaded-shops-only");
|
||||
public final String SHOP_SEARCH_GUI_TITLE = ConfigSetup.get().getString("shop-search-gui-title");
|
||||
public final int NEAREST_WARP_MODE = ConfigSetup.get().getInt("nearest-warp-mode");
|
||||
public final List<String> SHOP_GUI_ITEM_LORE = (List<String>) ConfigSetup.get().getList("shop-gui-item-lore");
|
||||
public final boolean TP_PLAYER_DIRECTLY_TO_SHOP = ConfigSetup.get().getBoolean("player-shop-teleportation.direct-shop-tp-mode.tp-player-directly-to-shop");
|
||||
public final String CLICK_TO_TELEPORT_MSG = ConfigSetup.get().getString("player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message");
|
||||
public final String SHOP_TP_NO_PERMISSION_MSG = ConfigSetup.get().getString("player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message");
|
||||
public final String UNSAFE_SHOP_AREA_MSG = ConfigSetup.get().getString("player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message");
|
||||
public final boolean TP_PLAYER_TO_NEAREST_WARP = ConfigSetup.get().getBoolean("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp");
|
||||
public final boolean TP_PLAYER_DIRECTLY_TO_SHOP = ConfigSetup.get()
|
||||
.getBoolean("player-shop-teleportation.direct-shop-tp-mode.tp-player-directly-to-shop");
|
||||
public final String CLICK_TO_TELEPORT_MSG = ConfigSetup.get()
|
||||
.getString("player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message");
|
||||
public final String SHOP_TP_NO_PERMISSION_MSG = ConfigSetup.get()
|
||||
.getString("player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message");
|
||||
public final String UNSAFE_SHOP_AREA_MSG = ConfigSetup.get()
|
||||
.getString("player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message");
|
||||
public final String TP_DELAY_IN_SECONDS = ConfigSetup.get()
|
||||
.getString("player-shop-teleportation.direct-shop-tp-mode.tp-delay-in-seconds");
|
||||
public final String TP_DELAY_MESSAGE = ConfigSetup.get()
|
||||
.getString("player-shop-teleportation.direct-shop-tp-mode.tp-delay-message");
|
||||
public final String TP_TO_OWN_SHOP_NO_PERMISSION_MESSAGE = ConfigSetup.get()
|
||||
.getString("player-shop-teleportation.direct-shop-tp-mode.tp-to-own-shop-no-permission-message");
|
||||
public final boolean TP_PLAYER_TO_NEAREST_WARP = ConfigSetup.get()
|
||||
.getBoolean("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp");
|
||||
public final String SHOP_GUI_BACK_BUTTON_MATERIAL = ConfigSetup.get().getString("shop-gui-back-button-material");
|
||||
public final String SHOP_GUI_BACK_BUTTON_TEXT = ConfigSetup.get().getString("shop-gui-back-button-text");
|
||||
public final String SHOP_GUI_NEXT_BUTTON_MATERIAL = ConfigSetup.get().getString("shop-gui-next-button-material");
|
||||
@@ -44,12 +70,31 @@ public class ConfigProvider {
|
||||
public final String SHOP_GUI_FILLER_ITEM = ConfigSetup.get().getString("shop-gui-filler-item");
|
||||
public final String SHOP_GUI_CLOSE_BUTTON_MATERIAL = ConfigSetup.get().getString("shop-gui-close-button-material");
|
||||
public final String SHOP_GUI_CLOSE_BUTTON_TEXT = ConfigSetup.get().getString("shop-gui-close-button-text");
|
||||
public final String SHOP_GUI_BACK_BUTTON_CMD = ConfigSetup.get().getString("shop-gui-back-button-custom-model-data");
|
||||
public final String SHOP_GUI_NEXT_BUTTON_CMD = ConfigSetup.get().getString("shop-gui-next-button-custom-model-data");
|
||||
public final String SHOP_GUI_CLOSE_BUTTON_CMD = ConfigSetup.get().getString("shop-gui-close-button-custom-model-data");
|
||||
public final String SHOP_NAV_FIRST_PAGE_ALERT_MSG = ConfigSetup.get().getString("shop-navigation-first-page-alert-message");
|
||||
public final String SHOP_NAV_LAST_PAGE_ALERT_MSG = ConfigSetup.get().getString("shop-navigation-last-page-alert-message");
|
||||
public final int SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES = ConfigSetup.get().getInt("shop-player-visit-cooldown-in-minutes");
|
||||
public final String SHOP_GUI_BACK_BUTTON_CMD = ConfigSetup.get()
|
||||
.getString("shop-gui-back-button-custom-model-data");
|
||||
public final String SHOP_GUI_NEXT_BUTTON_CMD = ConfigSetup.get()
|
||||
.getString("shop-gui-next-button-custom-model-data");
|
||||
public final String SHOP_GUI_CLOSE_BUTTON_CMD = ConfigSetup.get()
|
||||
.getString("shop-gui-close-button-custom-model-data");
|
||||
public final String SHOP_NAV_FIRST_PAGE_ALERT_MSG = ConfigSetup.get()
|
||||
.getString("shop-navigation-first-page-alert-message");
|
||||
public final String SHOP_NAV_LAST_PAGE_ALERT_MSG = ConfigSetup.get()
|
||||
.getString("shop-navigation-last-page-alert-message");
|
||||
public final int SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES = ConfigSetup.get()
|
||||
.getInt("shop-player-visit-cooldown-in-minutes");
|
||||
public final boolean IGNORE_EMPTY_CHESTS = ConfigSetup.get().getBoolean("ignore-empty-chests");
|
||||
public final String SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_MATERIAL = ConfigSetup.get()
|
||||
.getString("shop-gui-goto-first-page-button-material");
|
||||
public final String SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_TEXT = ConfigSetup.get()
|
||||
.getString("shop-gui-goto-first-page-button-text");
|
||||
public final String SHOP_GUI_GOTO_LAST_PAGE_BUTTON_MATERIAL = ConfigSetup.get()
|
||||
.getString("shop-gui-goto-last-page-button-material");
|
||||
public final String SHOP_GUI_GOTO_LAST_PAGE_BUTTON_TEXT = ConfigSetup.get()
|
||||
.getString("shop-gui-goto-last-page-button-text");
|
||||
public final String SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_CMD = ConfigSetup.get()
|
||||
.getString("shop-gui-goto-first-page-button-custom-model-data");
|
||||
public final String SHOP_GUI_GOTO_LAST_PAGE_BUTTON_CMD = ConfigSetup.get()
|
||||
.getString("shop-gui-goto-last-page-button-custom-model-data");
|
||||
public final List<String> BLACKLISTED_WORLDS = (List<String>) ConfigSetup.get().getList("blacklisted-worlds");
|
||||
public final boolean DEBUG_MODE = ConfigSetup.get().getBoolean("debug-mode");
|
||||
public final int CONFIG_VERSION = ConfigSetup.get().getInt("config-version");
|
||||
@@ -57,27 +102,44 @@ public class ConfigProvider {
|
||||
private final List<World> blacklistedWorldsList = new ArrayList<>();
|
||||
|
||||
public ConfigProvider() {
|
||||
if(BLACKLISTED_WORLDS != null) {
|
||||
|
||||
if (BLACKLISTED_WORLDS != null) {
|
||||
|
||||
BLACKLISTED_WORLDS.forEach(world -> {
|
||||
|
||||
World worldObj = Bukkit.getWorld(world);
|
||||
if(worldObj != null) {
|
||||
if (worldObj != null) {
|
||||
|
||||
blacklistedWorldsList.add(worldObj);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Config loaded!");
|
||||
|
||||
}
|
||||
|
||||
public List<World> getBlacklistedWorlds() {
|
||||
|
||||
return blacklistedWorldsList;
|
||||
|
||||
}
|
||||
|
||||
public boolean shopGUIItemLoreHasKey(String key) {
|
||||
|
||||
if (SHOP_GUI_ITEM_LORE != null) {
|
||||
|
||||
return SHOP_GUI_ITEM_LORE.stream().anyMatch(key::contains);
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.myzticbean.finditemaddon.ConfigUtil;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -15,58 +15,86 @@ public class ConfigSetup {
|
||||
private static File configFile;
|
||||
private static File sampleConfigFile;
|
||||
private static FileConfiguration configFileConfiguration;
|
||||
private static final int CURRENT_CONFIG_VERSION = 11;
|
||||
private static final int CURRENT_CONFIG_VERSION = 13;
|
||||
|
||||
public static void setupConfig() {
|
||||
configFile = new File(FindItemAddOn.getInstance().getDataFolder(), "config.yml");
|
||||
|
||||
if(!configFile.exists()) {
|
||||
configFile = new File(FindItemAddOnOG.getInstance().getDataFolder(), "config.yml");
|
||||
|
||||
if (!configFile.exists()) {
|
||||
|
||||
try {
|
||||
|
||||
boolean isConfigGenerated = configFile.createNewFile();
|
||||
if(isConfigGenerated) {
|
||||
if (isConfigGenerated) {
|
||||
|
||||
LoggerUtils.logInfo("Generated a new config.yml");
|
||||
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
LoggerUtils.logError("Error generating config.yml");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
configFileConfiguration = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
}
|
||||
|
||||
public static void saveConfig() {
|
||||
|
||||
try {
|
||||
|
||||
configFileConfiguration.save(configFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
LoggerUtils.logError("Error saving config.yml");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkForMissingProperties() {
|
||||
if(!configFileConfiguration.contains("search-loaded-shops-only", true)) {
|
||||
|
||||
if (!configFileConfiguration.contains("search-loaded-shops-only", true)) {
|
||||
|
||||
configFileConfiguration.set("search-loaded-shops-only", false);
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("nearest-warp-mode", true)) {
|
||||
|
||||
if (!configFileConfiguration.contains("nearest-warp-mode", true)) {
|
||||
|
||||
configFileConfiguration.set("nearest-warp-mode", 1);
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
try {
|
||||
|
||||
int nearestWarpMode = configFileConfiguration.getInt("nearest-warp-mode");
|
||||
if(nearestWarpMode != 1 && nearestWarpMode != 2 && nearestWarpMode != 3) {
|
||||
if (nearestWarpMode != 1 && nearestWarpMode != 2 && nearestWarpMode != 3) {
|
||||
|
||||
LoggerUtils.logError("Invalid value for 'nearest-warp-mode' in config.yml!");
|
||||
LoggerUtils.logError("Resetting by default to &e1");
|
||||
configFileConfiguration.set("nearest-warp-mode", 1);
|
||||
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
LoggerUtils.logError("Invalid value for 'nearest-warp-mode' in config.yml!");
|
||||
LoggerUtils.logError("Resetting by default to &e1");
|
||||
configFileConfiguration.set("nearest-warp-mode", 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("shop-gui-item-lore", true)) {
|
||||
|
||||
if (!configFileConfiguration.contains("shop-gui-item-lore", true)) {
|
||||
|
||||
List<String> shopGUIItemLore = new ArrayList<>();
|
||||
shopGUIItemLore.add("");
|
||||
shopGUIItemLore.add("&fPrice: &a${ITEM_PRICE}");
|
||||
@@ -77,45 +105,83 @@ public class ConfigSetup {
|
||||
shopGUIItemLore.add("&fWarp: &7{NEAREST_WARP}");
|
||||
shopGUIItemLore.add("");
|
||||
configFileConfiguration.set("shop-gui-item-lore", shopGUIItemLore);
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("blacklisted-worlds", true)) {
|
||||
|
||||
if (!configFileConfiguration.contains("blacklisted-worlds", true)) {
|
||||
|
||||
List<String> blacklistedWorlds = new ArrayList<>();
|
||||
blacklistedWorlds.add("world_number_1");
|
||||
blacklistedWorlds.add("world_number_2");
|
||||
configFileConfiguration.set("blacklisted-worlds", blacklistedWorlds);
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.hideshop-autocomplete", true)) {
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.hideshop-autocomplete", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.hideshop-autocomplete", "hideshop");
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.revealshop-autocomplete", true)) {
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.revealshop-autocomplete", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.revealshop-autocomplete", "revealshop");
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.shop-hide-success-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.shop-hide-success-message", "&aShop is now hidden from search list!");
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.shop-hide-success-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.shop-hide-success-message",
|
||||
"&aShop is now hidden from search list!");
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.shop-reveal-success-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.shop-reveal-success-message", "&aShop is no longer hidden from search list!");
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.shop-reveal-success-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.shop-reveal-success-message",
|
||||
"&aShop is no longer hidden from search list!");
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.shop-already-hidden-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.shop-already-hidden-message", "&cThis shop is already hidden!");
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.shop-already-hidden-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.shop-already-hidden-message",
|
||||
"&cThis shop is already hidden!");
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.shop-already-public-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.shop-already-public-message", "&cThis shop is already public!");
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.shop-already-public-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.shop-already-public-message",
|
||||
"&cThis shop is already public!");
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.invalid-shop-block-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.invalid-shop-block-message", "&cThe block you are looking at is not a shop!");
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.invalid-shop-block-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.invalid-shop-block-message",
|
||||
"&cThe block you are looking at is not a shop!");
|
||||
|
||||
}
|
||||
if(!configFileConfiguration.contains("find-item-command.hiding-shop-owner-invalid-message", true)) {
|
||||
configFileConfiguration.set("find-item-command.hiding-shop-owner-invalid-message", "&cThat shop is not yours!");
|
||||
|
||||
if (!configFileConfiguration.contains("find-item-command.hiding-shop-owner-invalid-message", true)) {
|
||||
|
||||
configFileConfiguration.set("find-item-command.hiding-shop-owner-invalid-message",
|
||||
"&cThat shop is not yours!");
|
||||
|
||||
}
|
||||
|
||||
// ALWAYS AT LAST
|
||||
if(!configFileConfiguration.contains("config-version", true)) {
|
||||
if (!configFileConfiguration.contains("config-version", true)) {
|
||||
|
||||
configFileConfiguration.set("config-version", CURRENT_CONFIG_VERSION);
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
// Automatic Config upgrade process
|
||||
// Config v10
|
||||
if(configFileConfiguration.getInt("config-version") < 10) {
|
||||
if (configFileConfiguration.getInt("config-version") < 10) {
|
||||
|
||||
boolean allowDirectShopTp = configFileConfiguration.getBoolean("allow-direct-shop-tp");
|
||||
String clickToTeleportMsg = configFileConfiguration.getString("click-to-teleport-message");
|
||||
String shopTPNoPermMsg = configFileConfiguration.getString("shop-tp-no-permission-message");
|
||||
@@ -126,65 +192,130 @@ public class ConfigSetup {
|
||||
configFileConfiguration.set("shop-tp-no-permission-message", null);
|
||||
configFileConfiguration.set("unsafe-shop-area-message", null);
|
||||
// set the new properties
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.tp-player-directly-to-shop", allowDirectShopTp);
|
||||
if(clickToTeleportMsg == null || clickToTeleportMsg.isEmpty())
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message", "&6&lClick to teleport to the shop!");
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.tp-player-directly-to-shop",
|
||||
allowDirectShopTp);
|
||||
if (clickToTeleportMsg == null || clickToTeleportMsg.isEmpty())
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message",
|
||||
"&6&lClick to teleport to the shop!");
|
||||
else
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message", clickToTeleportMsg);
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.click-to-teleport-message",
|
||||
clickToTeleportMsg);
|
||||
|
||||
if(shopTPNoPermMsg == null || shopTPNoPermMsg.isEmpty())
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message", "&cYou don't have permission to teleport to shop!");
|
||||
if (shopTPNoPermMsg == null || shopTPNoPermMsg.isEmpty())
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message",
|
||||
"&cYou don't have permission to teleport to shop!");
|
||||
else
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message", shopTPNoPermMsg);
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.shop-tp-no-permission-message",
|
||||
shopTPNoPermMsg);
|
||||
|
||||
if(unsafeShopAreaMsg == null || unsafeShopAreaMsg.isEmpty())
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message", "&cThe area around the shop is unsafe!");
|
||||
if (unsafeShopAreaMsg == null || unsafeShopAreaMsg.isEmpty())
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message",
|
||||
"&cThe area around the shop is unsafe!");
|
||||
else
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message", unsafeShopAreaMsg);
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.unsafe-shop-area-message",
|
||||
unsafeShopAreaMsg);
|
||||
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp",
|
||||
false);
|
||||
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp", false);
|
||||
}
|
||||
|
||||
// Config v11
|
||||
if(configFileConfiguration.getInt("config-version") < 11) {
|
||||
if (configFileConfiguration.getInt("config-version") < 11) {
|
||||
|
||||
List<String> cmdAliases = new ArrayList<>();
|
||||
cmdAliases.add("searchshop");
|
||||
cmdAliases.add("shopsearch");
|
||||
cmdAliases.add("searchitem");
|
||||
configFileConfiguration.set("find-item-command.command-alias", cmdAliases);
|
||||
|
||||
boolean warpState = configFileConfiguration.getBoolean("player-shop-teleportation.nearest-warp-tp-mode.warp-player-to-nearest-warp");
|
||||
if(warpState)
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp", true);
|
||||
boolean warpState = configFileConfiguration
|
||||
.getBoolean("player-shop-teleportation.nearest-warp-tp-mode.warp-player-to-nearest-warp");
|
||||
if (warpState)
|
||||
configFileConfiguration
|
||||
.set("player-shop-teleportation.nearest-warp-tp-mode.tp-player-to-nearest-warp", true);
|
||||
// if warpState is false, don't bother updating tPState
|
||||
|
||||
// remove an erroneous field added in previous version
|
||||
configFileConfiguration.set("player-shop-teleportation.nearest-warp-tp-mode.warp-player-to-nearest-warp", null);
|
||||
configFileConfiguration
|
||||
.set("player-shop-teleportation.nearest-warp-tp-mode.warp-player-to-nearest-warp", null);
|
||||
|
||||
// Update GUI next/previous button to blank if set to default value for the new
|
||||
// player-head icons
|
||||
if (configFileConfiguration.getString("shop-gui-back-button-material")
|
||||
.equalsIgnoreCase("RED_CONCRETE"))
|
||||
{
|
||||
|
||||
// Update GUI next/previous button to blank if set to default value for the new player-head icons
|
||||
if(configFileConfiguration.getString("shop-gui-back-button-material").equalsIgnoreCase("RED_CONCRETE")) {
|
||||
configFileConfiguration.set("shop-gui-back-button-material", "");
|
||||
|
||||
}
|
||||
if(configFileConfiguration.getString("shop-gui-next-button-material").equalsIgnoreCase("GREEN_CONCRETE")) {
|
||||
|
||||
if (configFileConfiguration.getString("shop-gui-next-button-material")
|
||||
.equalsIgnoreCase("GREEN_CONCRETE"))
|
||||
{
|
||||
|
||||
configFileConfiguration.set("shop-gui-next-button-material", "");
|
||||
|
||||
}
|
||||
|
||||
// Add option to configure player visit cooldown
|
||||
configFileConfiguration.set("shop-player-visit-cooldown-in-minutes", 5);
|
||||
|
||||
}
|
||||
|
||||
// Config 12
|
||||
if (configFileConfiguration.getInt("config-version") < 12) {
|
||||
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.tp-delay-in-seconds", 0);
|
||||
configFileConfiguration.set("player-shop-teleportation.direct-shop-tp-mode.tp-delay-message",
|
||||
"&6You will be teleported in &c{DELAY} &6seconds...");
|
||||
|
||||
}
|
||||
|
||||
// Config 13
|
||||
if (configFileConfiguration.getInt("config-version") < 13) {
|
||||
|
||||
configFileConfiguration.set(
|
||||
"player-shop-teleportation.direct-shop-tp-mode.tp-to-own-shop-no-permission-message",
|
||||
"&cYou cannot teleport to your own shop!");
|
||||
configFileConfiguration.set("ignore-empty-chests", true);
|
||||
configFileConfiguration.set("shop-gui-goto-first-page-button-material", "");
|
||||
configFileConfiguration.set("shop-gui-goto-first-page-button-text", "&7&l« &cGo to First Page");
|
||||
configFileConfiguration.set("shop-gui-goto-first-page-button-custom-model-data", "");
|
||||
configFileConfiguration.set("shop-gui-goto-last-page-button-material", "");
|
||||
configFileConfiguration.set("shop-gui-goto-last-page-button-text", "&aGo to Last Page &7&l»");
|
||||
configFileConfiguration.set("shop-gui-goto-last-page-button-custom-model-data", "");
|
||||
|
||||
}
|
||||
|
||||
// AT LAST
|
||||
// Moving debug-mode and config-version to the last
|
||||
boolean userDefinedDebugMode = configFileConfiguration.getBoolean("debug-mode");
|
||||
configFileConfiguration.set("debug-mode", null);
|
||||
configFileConfiguration.set("debug-mode", userDefinedDebugMode);
|
||||
configFileConfiguration.set("config-version", null);
|
||||
configFileConfiguration.set("config-version", CURRENT_CONFIG_VERSION);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static FileConfiguration get() {
|
||||
|
||||
return configFileConfiguration;
|
||||
|
||||
}
|
||||
|
||||
public static void reloadConfig() {
|
||||
|
||||
configFileConfiguration = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,19 +323,8 @@ public class ConfigSetup {
|
||||
*/
|
||||
public static void copySampleConfig() {
|
||||
|
||||
FindItemAddOn.getInstance().saveResource("sample-config.yml", true);
|
||||
FindItemAddOnOG.getInstance().saveResource("sample-config.yml", true);
|
||||
|
||||
// sampleConfigFile = new File(FindItemAddOn.getInstance().getDataFolder(), "sample-config.yml");
|
||||
// if(!sampleConfigFile.exists()) {
|
||||
// try {
|
||||
// boolean isConfigGenerated = sampleConfigFile.createNewFile();
|
||||
// if(isConfigGenerated) {
|
||||
// LoggerUtils.logInfo("Generated a new config.yml");
|
||||
// }
|
||||
// }
|
||||
// catch (IOException e) {
|
||||
// LoggerUtils.logError("Error generating config.yml");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,8 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Hook for EssentialsX Plugin
|
||||
* @author ronsane
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class EssentialsXPlugin {
|
||||
|
||||
@@ -19,39 +20,61 @@ public class EssentialsXPlugin {
|
||||
private static List<EssentialWarpModel> allWarpsList = null;
|
||||
|
||||
public static void setup() {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
|
||||
essAPI = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
|
||||
if(essAPI != null) {
|
||||
LoggerUtils.logInfo("Found Essentials");
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("Essentials-OG")) {
|
||||
|
||||
essAPI = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials-OG");
|
||||
if (essAPI != null) {
|
||||
|
||||
LoggerUtils.logInfo("Found Essentials-OG...");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
|
||||
return essAPI != null;
|
||||
|
||||
}
|
||||
|
||||
public static Essentials getAPI() {
|
||||
|
||||
return essAPI;
|
||||
|
||||
}
|
||||
|
||||
public static List<EssentialWarpModel> getAllWarps() { return allWarpsList; }
|
||||
public static List<EssentialWarpModel> getAllWarps() {
|
||||
|
||||
return allWarpsList;
|
||||
|
||||
}
|
||||
|
||||
public static void updateAllWarps() {
|
||||
LoggerUtils.logInfo("Updating Essentials warps list...");
|
||||
if(essAPI.isEnabled()) {
|
||||
|
||||
if (essAPI.isEnabled()) {
|
||||
|
||||
Collection<String> allWarps = EssentialsXPlugin.getAPI().getWarps().getList();
|
||||
allWarpsList = new ArrayList<>();
|
||||
allWarps.forEach(warp -> {
|
||||
|
||||
try {
|
||||
|
||||
EssentialWarpModel essWarp = new EssentialWarpModel();
|
||||
essWarp.warpName = warp;
|
||||
essWarp.warpLoc = essAPI.getWarps().getWarp(warp);
|
||||
allWarpsList.add(essWarp);
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
LoggerUtils.logInfo("Update complete! Found " + getAllWarps().size() + " warps.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Dependencies;
|
||||
|
||||
import com.olziedev.playerwarps.api.PlayerWarpsAPI;
|
||||
import com.olziedev.playerwarps.api.warp.Warp;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerWarpsPlugin {
|
||||
|
||||
private static boolean isEnabled = false;
|
||||
private static List<Warp> allWarpsList = null;
|
||||
private static PlayerWarpsAPI playerWarpsAPI = null;
|
||||
private static final String ALL_WARPS_LIST_CLASSPATH = PlayerWarpsPlugin.class.getCanonicalName() + ".allWarpsList";
|
||||
|
||||
private PlayerWarpsPlugin() { }
|
||||
|
||||
public static void setup() {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("PlayerWarps")) {
|
||||
LoggerUtils.logInfo("Found PlayerWarps");
|
||||
PlayerWarpsAPI.getInstance(api -> {
|
||||
playerWarpsAPI = api;
|
||||
isEnabled = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getIsEnabled() { return isEnabled; }
|
||||
|
||||
/**
|
||||
* Issue #24 Fix: Changing all api get references to callback, making this method deprecated
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static PlayerWarpsAPI getAPI() {
|
||||
return playerWarpsAPI;
|
||||
}
|
||||
|
||||
public static List<Warp> getAllWarps() {
|
||||
PlayerWarpsAPI.getInstance(api -> {
|
||||
allWarpsList = api.getPlayerWarps(false);
|
||||
});
|
||||
return allWarpsList;
|
||||
}
|
||||
|
||||
public static void updateAllWarpsFromAPI() {
|
||||
if(isEnabled) {
|
||||
LoggerUtils.logInfo("Updating Player warps list...");
|
||||
// Issue #24 Fix: Changing api instance to callback
|
||||
PlayerWarpsAPI.getInstance(api -> {
|
||||
allWarpsList = api.getPlayerWarps(false);
|
||||
LoggerUtils.logInfo("Update complete! Found " + getAllWarps().size() + " warps.");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateWarpsOnEventCall(Warp warp, boolean isRemoved) {
|
||||
LoggerUtils.logDebugInfo("Got a PlayerWarps event call... checking nearest-warp-mode");
|
||||
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 2) {
|
||||
LoggerUtils.logDebugInfo("'nearest-warp-mode' found set to 2");
|
||||
if (getIsEnabled()) {
|
||||
LoggerUtils.logDebugInfo("PlayerWarps plugin is enabled");
|
||||
tryUpdateWarps(warp, isRemoved, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LoggerUtils.logDebugInfo("No update required to '" + ALL_WARPS_LIST_CLASSPATH + "' as PlayerWarps integration is disabled.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void tryUpdateWarps(Warp warp, boolean isRemoved, int updateTrialSequence) {
|
||||
// Issue #21 Fix: Adding a NPE check
|
||||
if(allWarpsList != null) {
|
||||
if(isRemoved) {
|
||||
if(allWarpsList.contains(warp)) {
|
||||
allWarpsList.remove(warp);
|
||||
LoggerUtils.logDebugInfo("Warp removed from allWarpsList: " + warp.getWarpName());
|
||||
} else {
|
||||
LoggerUtils.logError("Error occurred while updating '" + ALL_WARPS_LIST_CLASSPATH + "'. Warp name: '" + warp.getWarpName() + "' does not exist!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
allWarpsList.add(warp);
|
||||
LoggerUtils.logDebugInfo("New warp added to allWarpsList: " + warp.getWarpName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Issue #21 Fix: forcing update of allWarpsList
|
||||
if(updateTrialSequence == 1) {
|
||||
updateAllWarpsFromAPI();
|
||||
tryUpdateWarps(warp, isRemoved, 2);
|
||||
} else {
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
errorMsg.append("Error occurred while updating '").append(ALL_WARPS_LIST_CLASSPATH).append("' as it is null! ")
|
||||
.append("Please install PlayerWarps by Olzie-12 if you would like to use 'nearest-warp-mode' as 2. ")
|
||||
.append("If PlayerWarps plugin is installed and issue persists, please contact the developer!");
|
||||
LoggerUtils.logError(errorMsg.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue #24 Fix: Extracted method from FoundShopsMenu class
|
||||
* @param player
|
||||
* @param warpName
|
||||
*/
|
||||
public static void executeWarpPlayer(Player player, String warpName) {
|
||||
PlayerWarpsAPI.getInstance(api -> {
|
||||
Warp playerWarp = api.getPlayerWarp(warpName);
|
||||
if(playerWarp != null) {
|
||||
playerWarp.getWarpLocation().teleportWarp(player);
|
||||
}
|
||||
else {
|
||||
LoggerUtils.logError("&e" + player.getName() + " &cis trying to teleport to a PlayerWarp that does not exist!");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -10,23 +10,36 @@ public class WGPlugin {
|
||||
private static boolean isPluginEnabled;
|
||||
|
||||
public static void setup() {
|
||||
if(Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) {
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("WorldGuard")) {
|
||||
|
||||
LoggerUtils.logInfo("Found WorldGuard");
|
||||
isPluginEnabled = true;
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
isPluginEnabled = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static WorldGuardPlugin getWgPluginInstance() {
|
||||
|
||||
return WorldGuardPlugin.inst();
|
||||
|
||||
}
|
||||
|
||||
public static WorldGuard getWgInstance () { return WorldGuard.getInstance(); }
|
||||
public static WorldGuard getWgInstance() {
|
||||
|
||||
return WorldGuard.getInstance();
|
||||
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
|
||||
return isPluginEnabled;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,339 +0,0 @@
|
||||
package io.myzticbean.finditemaddon;
|
||||
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.*;
|
||||
import io.myzticbean.finditemaddon.ConfigUtil.ConfigProvider;
|
||||
import io.myzticbean.finditemaddon.ConfigUtil.ConfigSetup;
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.Dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.Dependencies.WGPlugin;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.PlayerMenuUtility;
|
||||
import io.myzticbean.finditemaddon.Listeners.*;
|
||||
import io.myzticbean.finditemaddon.Metrics.Metrics;
|
||||
import io.myzticbean.finditemaddon.QuickShopHandler.QSApi;
|
||||
import io.myzticbean.finditemaddon.QuickShopHandler.QSHikariAPIHandler;
|
||||
import io.myzticbean.finditemaddon.QuickShopHandler.QSReremakeAPIHandler;
|
||||
import io.myzticbean.finditemaddon.ScheduledTasks.Task15MinInterval;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.UpdateChecker;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import me.kodysimpson.simpapi.command.CommandManager;
|
||||
import me.kodysimpson.simpapi.command.SubCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public final class FindItemAddOn extends JavaPlugin {
|
||||
|
||||
private static Plugin plugin;
|
||||
public FindItemAddOn() { plugin = this; }
|
||||
public static Plugin getInstance() { return plugin; }
|
||||
public static String serverVersion;
|
||||
private final static int BS_PLUGIN_METRIC_ID = 12382;
|
||||
private final static int SPIGOT_PLUGIN_ID = 95104;
|
||||
private final static int REPEATING_TASK_SCHEDULE_MINS = 15*60*20;
|
||||
private static ConfigProvider configProvider;
|
||||
private static boolean isPluginOutdated = false;
|
||||
private static boolean qSReremakeInstalled = false;
|
||||
private static boolean qSHikariInstalled = false;
|
||||
private static QSApi qsApi;
|
||||
|
||||
private static final HashMap<Player, PlayerMenuUtility> playerMenuUtilityMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
LoggerUtils.logInfo("A Shop Search AddOn for QuickShop developed by ronsane");
|
||||
|
||||
// Show warning if it's a snapshot build
|
||||
if(this.getDescription().getVersion().toLowerCase().contains("snapshot")) {
|
||||
LoggerUtils.logWarning("This is a SNAPSHOT build! NOT recommended for production servers.");
|
||||
LoggerUtils.logWarning("If you find any bugs, please report them here: https://gitlab.com/ronsane/QSFindItemAddOn/-/issues");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
if(!Bukkit.getPluginManager().isPluginEnabled("QuickShop")
|
||||
&& !Bukkit.getPluginManager().isPluginEnabled("QuickShop-Hikari")) {
|
||||
LoggerUtils.logInfo("Delaying QuickShop hook as they are not enabled yet");
|
||||
}
|
||||
else if(Bukkit.getPluginManager().isPluginEnabled("QuickShop")) {
|
||||
qSReremakeInstalled = true;
|
||||
}
|
||||
else {
|
||||
qSHikariInstalled = true;
|
||||
}
|
||||
|
||||
// Registering Bukkit event listeners
|
||||
initBukkitEventListeners();
|
||||
|
||||
// Handle config file
|
||||
this.saveDefaultConfig();
|
||||
this.getConfig().options().copyDefaults(true);
|
||||
ConfigSetup.setupConfig();
|
||||
ConfigSetup.get().options().copyDefaults(true);
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
initConfigProvider();
|
||||
ConfigSetup.copySampleConfig();
|
||||
|
||||
initCommands();
|
||||
|
||||
// Run plugin startup logic after server is done loading
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FindItemAddOn.getInstance(), () -> runPluginStartupTasks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
if(qsApi != null) {
|
||||
ShopSearchActivityStorageUtil.saveShopsToFile();
|
||||
}
|
||||
else {
|
||||
LoggerUtils.logError("Uh oh! Looks like either this plugin has crashed or you don't have QuickShop or QuickShop-Hikari installed.");
|
||||
}
|
||||
LoggerUtils.logInfo("Bye!");
|
||||
}
|
||||
|
||||
private void runPluginStartupTasks() {
|
||||
// if(!Bukkit.getPluginManager().isPluginEnabled("QuickShop")
|
||||
// && !Bukkit.getPluginManager().isPluginEnabled("QuickShop-Hikari")) {
|
||||
// LoggerUtils.logError("QuickShop is required to use this addon. Please install QuickShop and try again!");
|
||||
// LoggerUtils.logError("Both QuickShop-Reremake and QuickShop-Hikari are supported by this addon.");
|
||||
// LoggerUtils.logError("Download links:");
|
||||
// LoggerUtils.logError("» QuickShop-Reremake: https://www.spigotmc.org/resources/62575");
|
||||
// LoggerUtils.logError("» QuickShop-Hikari: https://www.spigotmc.org/resources/100125");
|
||||
// getServer().getPluginManager().disablePlugin(this);
|
||||
// return;
|
||||
// }
|
||||
// else if(Bukkit.getPluginManager().isPluginEnabled("QuickShop")) {
|
||||
// qSReremakeInstalled = true;
|
||||
// qsApi = new QSReremakeAPIHandler();
|
||||
// LoggerUtils.logInfo("Found QuickShop-Reremake");
|
||||
// }
|
||||
// else if(Bukkit.getPluginManager().isPluginEnabled("QuickShop-Hikari")) {
|
||||
// qSHikariInstalled = true;
|
||||
// qsApi = new QSHikariAPIHandler();
|
||||
// LoggerUtils.logInfo("Found QuickShop-Hikari");
|
||||
// }
|
||||
|
||||
serverVersion = Bukkit.getServer().getVersion();
|
||||
LoggerUtils.logInfo("Server version found: " + serverVersion);
|
||||
|
||||
if(!isQSReremakeInstalled() && !isQSHikariInstalled()) {
|
||||
LoggerUtils.logError("QuickShop is required to use this addon. Please install QuickShop and try again!");
|
||||
LoggerUtils.logError("Both QuickShop-Reremake and QuickShop-Hikari are supported by this addon.");
|
||||
LoggerUtils.logError("Download links:");
|
||||
LoggerUtils.logError("» QuickShop-Reremake: https://www.spigotmc.org/resources/62575");
|
||||
LoggerUtils.logError("» QuickShop-Hikari: https://www.spigotmc.org/resources/100125");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
else if(isQSReremakeInstalled()) {
|
||||
LoggerUtils.logInfo("Found QuickShop-Reremake");
|
||||
qsApi = new QSReremakeAPIHandler();
|
||||
qsApi.registerSubCommand();
|
||||
} else {
|
||||
LoggerUtils.logInfo("Found QuickShop-Hikari");
|
||||
qsApi = new QSHikariAPIHandler();
|
||||
qsApi.registerSubCommand();
|
||||
}
|
||||
|
||||
// Load all hidden shops from file
|
||||
ShopSearchActivityStorageUtil.loadShopsFromFile();
|
||||
|
||||
// v2.0.0 - Migrating hiddenShops.json to shops.json
|
||||
ShopSearchActivityStorageUtil.migrateHiddenShopsToShopsJson();
|
||||
|
||||
PlayerWarpsPlugin.setup();
|
||||
EssentialsXPlugin.setup();
|
||||
WGPlugin.setup();
|
||||
|
||||
initExternalPluginEventListeners();
|
||||
|
||||
// Initiate batch tasks
|
||||
LoggerUtils.logInfo("Registering tasks");
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Task15MinInterval(), 0, REPEATING_TASK_SCHEDULE_MINS);
|
||||
|
||||
// init metrics
|
||||
LoggerUtils.logInfo("Registering anonymous bStats metrics");
|
||||
Metrics metrics = new Metrics(this, BS_PLUGIN_METRIC_ID);
|
||||
|
||||
// Check for plugin updates
|
||||
new UpdateChecker(SPIGOT_PLUGIN_ID).getLatestVersion(version -> {
|
||||
if(this.getDescription().getVersion().equalsIgnoreCase(version)) {
|
||||
LoggerUtils.logInfo("Oh awesome! Plugin is up to date");
|
||||
} else {
|
||||
isPluginOutdated = true;
|
||||
if(version.toLowerCase().contains("snapshot")) {
|
||||
LoggerUtils.logWarning("Plugin has a new snapshot version available! (Version: " + version + ")");
|
||||
}
|
||||
else {
|
||||
LoggerUtils.logWarning("Plugin has a new update available! (Version: " + version + ")");
|
||||
}
|
||||
LoggerUtils.logWarning("Download here: https://www.spigotmc.org/resources/" + SPIGOT_PLUGIN_ID + "/");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCommands() {
|
||||
LoggerUtils.logInfo("Registering commands");
|
||||
initFindItemCmd();
|
||||
initFindItemAdminCmd();
|
||||
}
|
||||
|
||||
private void initBukkitEventListeners() {
|
||||
LoggerUtils.logInfo("Registering Bukkit event listeners");
|
||||
this.getServer().getPluginManager().registerEvents(new PluginEnableEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerCommandSendEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new MenuListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerJoinEventListener(), this);
|
||||
}
|
||||
private void initExternalPluginEventListeners() {
|
||||
LoggerUtils.logInfo("Registering external plugin event listeners");
|
||||
if(PlayerWarpsPlugin.getIsEnabled()) {
|
||||
this.getServer().getPluginManager().registerEvents(new PWPlayerWarpRemoveEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PWPlayerWarpCreateEventListener(), this);
|
||||
}
|
||||
}
|
||||
|
||||
public static ConfigProvider getConfigProvider() {
|
||||
return configProvider;
|
||||
}
|
||||
|
||||
public static void initConfigProvider() {
|
||||
configProvider = new ConfigProvider();
|
||||
}
|
||||
|
||||
public static PlayerMenuUtility getPlayerMenuUtility(Player p){
|
||||
PlayerMenuUtility playerMenuUtility;
|
||||
if(playerMenuUtilityMap.containsKey(p)) {
|
||||
return playerMenuUtilityMap.get(p);
|
||||
}
|
||||
else {
|
||||
playerMenuUtility = new PlayerMenuUtility(p);
|
||||
playerMenuUtilityMap.put(p, playerMenuUtility);
|
||||
return playerMenuUtility;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getPluginOutdated() {
|
||||
return isPluginOutdated;
|
||||
}
|
||||
|
||||
public static int getPluginID() {
|
||||
return SPIGOT_PLUGIN_ID;
|
||||
}
|
||||
|
||||
private void initFindItemCmd() {
|
||||
List<String> alias;
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " ")) {
|
||||
alias = Arrays.asList("shopsearch", "searchshop", "searchitem");
|
||||
}
|
||||
else {
|
||||
alias = FindItemAddOn.getConfigProvider().FIND_ITEM_COMMAND_ALIAS;
|
||||
}
|
||||
// Register the subcommands under a core command
|
||||
try {
|
||||
CommandManager.createCoreCommand(
|
||||
this,
|
||||
"finditem",
|
||||
"Search for items from all shops using an interactive GUI",
|
||||
"/finditem",
|
||||
(commandSender, subCommandList) -> {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&7------------------------"));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&6&lShop Search Commands"));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&7------------------------"));
|
||||
for (SubCommand subCommand : subCommandList) {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#ff9933" + subCommand.getSyntax() + " &#a3a3c2" + subCommand.getDescription()));
|
||||
}
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#b3b300Command alias:"));
|
||||
alias.forEach(alias_i -> {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&8&l» db300/" + alias_i));
|
||||
});
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
},
|
||||
alias,
|
||||
SellSubCmd.class,
|
||||
BuySubCmd.class,
|
||||
HideShopSubCmd.class,
|
||||
RevealShopSubCmd.class);
|
||||
LoggerUtils.logInfo("Registered /finditem command");
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
LoggerUtils.logError(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void initFindItemAdminCmd() {
|
||||
List<String> alias = List.of("fiadmin");
|
||||
try {
|
||||
CommandManager.createCoreCommand(
|
||||
this,
|
||||
"finditemadmin",
|
||||
"Admin command for Shop Search addon",
|
||||
"/finditemadmin",
|
||||
(commandSender, subCommandList) -> {
|
||||
if (
|
||||
(commandSender.isOp())
|
||||
|| (!commandSender.isOp() && (commandSender.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())
|
||||
|| commandSender.hasPermission(PlayerPerms.FINDITEM_RELOAD.value())))
|
||||
) {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&7-----------------------------"));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&6&lShop Search Admin Commands"));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&7-----------------------------"));
|
||||
|
||||
for (SubCommand subCommand : subCommandList) {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#ff1a1a" + subCommand.getSyntax() + " &#a3a3c2" + subCommand.getDescription()));
|
||||
}
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&#b3b300Command alias:"));
|
||||
alias.forEach(alias_i -> {
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes("&8&l» db300/" + alias_i));
|
||||
});
|
||||
commandSender.sendMessage(ColorTranslator.translateColorCodes(""));
|
||||
}
|
||||
},
|
||||
alias,
|
||||
ReloadSubCmd.class);
|
||||
LoggerUtils.logInfo("Registered /finditemadmin command");
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
LoggerUtils.logError(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isQSReremakeInstalled() {
|
||||
return qSReremakeInstalled;
|
||||
}
|
||||
|
||||
public static boolean isQSHikariInstalled() {
|
||||
return qSHikariInstalled;
|
||||
}
|
||||
|
||||
public static void setQSReremakeInstalled(boolean qSReremakeInstalled) {
|
||||
FindItemAddOn.qSReremakeInstalled = qSReremakeInstalled;
|
||||
}
|
||||
|
||||
public static void setQSHikariInstalled(boolean qSHikariInstalled) {
|
||||
FindItemAddOn.qSHikariInstalled = qSHikariInstalled;
|
||||
}
|
||||
|
||||
public static QSApi getQsApiInstance() {
|
||||
return qsApi;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,809 @@
|
||||
package io.myzticbean.finditemaddon;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.BuySubCmd;
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.HideShopSubCmd;
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.ReloadSubCmd;
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.RevealShopSubCmd;
|
||||
import io.myzticbean.finditemaddon.Commands.SAPICommands.SellSubCmd;
|
||||
import io.myzticbean.finditemaddon.ConfigUtil.ConfigProvider;
|
||||
import io.myzticbean.finditemaddon.ConfigUtil.ConfigSetup;
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.Dependencies.WGPlugin;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.PlayerMenuUtility;
|
||||
import io.myzticbean.finditemaddon.Listeners.MenuListener;
|
||||
import io.myzticbean.finditemaddon.Listeners.PlayerCommandSendEventListener;
|
||||
import io.myzticbean.finditemaddon.Listeners.PluginEnableEventListener;
|
||||
import io.myzticbean.finditemaddon.QuickShopHandler.QSApi;
|
||||
import io.myzticbean.finditemaddon.QuickShopHandler.QSHikariAPIHandler;
|
||||
import io.myzticbean.finditemaddon.QuickShopHandler.QSReremakeAPIHandler;
|
||||
import io.myzticbean.finditemaddon.ScheduledTasks.Task15MinInterval;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public final class FindItemAddOnOG extends JavaPlugin {
|
||||
|
||||
private static Plugin plugin;
|
||||
|
||||
public FindItemAddOnOG() {
|
||||
|
||||
plugin = this;
|
||||
|
||||
}
|
||||
|
||||
public static Plugin getInstance() {
|
||||
|
||||
return plugin;
|
||||
|
||||
}
|
||||
|
||||
public static String serverVersion;
|
||||
private static final int SPIGOT_PLUGIN_ID = 95104;
|
||||
private static final int REPEATING_TASK_SCHEDULE_MINS = 15 * 60 * 20;
|
||||
private static ConfigProvider configProvider;
|
||||
private static final boolean isPluginOutdated = false;
|
||||
private static boolean qSReremakeInstalled = false;
|
||||
private static boolean qSHikariInstalled = false;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private static QSApi qsApi;
|
||||
|
||||
private static final HashMap<Player, PlayerMenuUtility> playerMenuUtilityMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
LoggerUtils.logInfo("A Shop Search AddOn for QuickShop developed by myzticbean");
|
||||
|
||||
// Show warning if it's a snapshot build
|
||||
if (!this.getPluginMeta().getVersion().toLowerCase().contains("snapshot")) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logWarning("This is a SNAPSHOT build! NOT recommended for production servers.");
|
||||
LoggerUtils.logWarning(
|
||||
"If you find any bugs, please report them here: https://github.com/myzticbean/QSFindItemAddOn/issues");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("QuickShop-OG-Alt")
|
||||
&& !Bukkit.getPluginManager().isPluginEnabled("QuickShop-OG"))
|
||||
{
|
||||
|
||||
LoggerUtils.logInfo("Delaying QuickShop hook as they are not enabled yet");
|
||||
|
||||
} else if (Bukkit.getPluginManager().isPluginEnabled("QuickShop-OG-Alt")) {
|
||||
|
||||
qSReremakeInstalled = true;
|
||||
|
||||
} else {
|
||||
|
||||
qSHikariInstalled = true;
|
||||
|
||||
}
|
||||
|
||||
// Registering Bukkit event listeners
|
||||
initBukkitEventListeners();
|
||||
|
||||
// Handle config file
|
||||
this.saveDefaultConfig();
|
||||
this.getConfig().options().copyDefaults(true);
|
||||
ConfigSetup.setupConfig();
|
||||
ConfigSetup.get().options().copyDefaults(true);
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
initConfigProvider();
|
||||
ConfigSetup.copySampleConfig();
|
||||
|
||||
initCommands();
|
||||
|
||||
// Run plugin startup logic after server is done loading
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FindItemAddOnOG.getInstance(), this::runPluginStartupTasks);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
// Plugin shutdown logic
|
||||
if (qsApi != null) {
|
||||
|
||||
ShopSearchActivityStorageUtil.saveShopsToFile();
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logError(
|
||||
"Uh oh! Looks like either this plugin has crashed or you don't have QuickShop or QuickShop-Hikari installed.");
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Bye!");
|
||||
|
||||
}
|
||||
|
||||
private void runPluginStartupTasks() {
|
||||
// if(!Bukkit.getPluginManager().isPluginEnabled("QuickShop")
|
||||
|
||||
// && !Bukkit.getPluginManager().isPluginEnabled("QuickShop-Hikari")) {
|
||||
// LoggerUtils.logError("QuickShop is required to use this addon. Please install
|
||||
// QuickShop and try again!");
|
||||
// LoggerUtils.logError("Both QuickShop-Reremake and QuickShop-Hikari are
|
||||
// supported by this addon.");
|
||||
// LoggerUtils.logError("Download links:");
|
||||
// LoggerUtils.logError("» QuickShop-Reremake:
|
||||
// https://www.spigotmc.org/resources/62575");
|
||||
// LoggerUtils.logError("» QuickShop-Hikari:
|
||||
// https://www.spigotmc.org/resources/100125");
|
||||
// getServer().getPluginManager().disablePlugin(this);
|
||||
// return;
|
||||
// }
|
||||
// else if(Bukkit.getPluginManager().isPluginEnabled("QuickShop")) {
|
||||
// qSReremakeInstalled = true;
|
||||
// qsApi = new QSReremakeAPIHandler();
|
||||
// LoggerUtils.logInfo("Found QuickShop-Reremake");
|
||||
// }
|
||||
// else if(Bukkit.getPluginManager().isPluginEnabled("QuickShop-Hikari")) {
|
||||
// qSHikariInstalled = true;
|
||||
// qsApi = new QSHikariAPIHandler();
|
||||
// LoggerUtils.logInfo("Found QuickShop-Hikari");
|
||||
// }
|
||||
|
||||
serverVersion = Bukkit.getServer().getVersion();
|
||||
LoggerUtils.logInfo("Server version found: " + serverVersion);
|
||||
|
||||
if (!isQSReremakeInstalled() && !isQSHikariInstalled()) {
|
||||
|
||||
LoggerUtils.logError("QuickShop is required to use this addon. Please install QuickShop and try again!");
|
||||
LoggerUtils.logError("Both QuickShop-Reremake and QuickShop-Hikari are supported by this addon.");
|
||||
LoggerUtils.logError("Download links:");
|
||||
LoggerUtils.logError("» QuickShop-Reremake: https://www.spigotmc.org/resources/62575");
|
||||
LoggerUtils.logError("» QuickShop-Hikari: https://www.spigotmc.org/resources/100125");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
|
||||
} else if (isQSReremakeInstalled()) {
|
||||
|
||||
LoggerUtils.logInfo("Found QuickShop-Reremake");
|
||||
qsApi = new QSReremakeAPIHandler();
|
||||
qsApi.registerSubCommand();
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logInfo("Found QuickShop-Hikari");
|
||||
qsApi = new QSHikariAPIHandler();
|
||||
qsApi.registerSubCommand();
|
||||
|
||||
}
|
||||
|
||||
// Load all hidden shops from file
|
||||
ShopSearchActivityStorageUtil.loadShopsFromFile();
|
||||
|
||||
// v2.0.0 - Migrating hiddenShops.json to shops.json
|
||||
ShopSearchActivityStorageUtil.migrateHiddenShopsToShopsJson();
|
||||
|
||||
EssentialsXPlugin.setup();
|
||||
WGPlugin.setup();
|
||||
|
||||
// Initiate batch tasks
|
||||
LoggerUtils.logInfo("Registering tasks");
|
||||
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Task15MinInterval(), 0,
|
||||
REPEATING_TASK_SCHEDULE_MINS);
|
||||
|
||||
}
|
||||
|
||||
private void initCommands() {
|
||||
|
||||
LoggerUtils.logInfo("Registering commands");
|
||||
initFindItemCmd();
|
||||
initFindItemAdminCmd();
|
||||
|
||||
}
|
||||
|
||||
private void initBukkitEventListeners() {
|
||||
|
||||
LoggerUtils.logInfo("Registering Bukkit event listeners");
|
||||
this.getServer().getPluginManager().registerEvents(new PluginEnableEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerCommandSendEventListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new MenuListener(), this);
|
||||
|
||||
}
|
||||
|
||||
public static ConfigProvider getConfigProvider() {
|
||||
|
||||
return configProvider;
|
||||
|
||||
}
|
||||
|
||||
public static void initConfigProvider() {
|
||||
|
||||
configProvider = new ConfigProvider();
|
||||
|
||||
}
|
||||
|
||||
public static PlayerMenuUtility getPlayerMenuUtility(Player p) {
|
||||
|
||||
final PlayerMenuUtility playerMenuUtility;
|
||||
if (playerMenuUtilityMap.containsKey(p)) {
|
||||
|
||||
return playerMenuUtilityMap.get(p);
|
||||
|
||||
} else {
|
||||
|
||||
playerMenuUtility = new PlayerMenuUtility(p);
|
||||
playerMenuUtilityMap.put(p, playerMenuUtility);
|
||||
return playerMenuUtility;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean getPluginOutdated() {
|
||||
|
||||
return isPluginOutdated;
|
||||
|
||||
}
|
||||
|
||||
public static int getPluginID() {
|
||||
|
||||
return SPIGOT_PLUGIN_ID;
|
||||
|
||||
}
|
||||
|
||||
private void initFindItemCmd() {
|
||||
|
||||
final List<String> alias;
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE) || StringUtils
|
||||
.containsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_SELL_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
alias = Arrays.asList("shopsearch", "searchshop", "searchitem");
|
||||
|
||||
} else {
|
||||
|
||||
alias = FindItemAddOnOG.getConfigProvider().FIND_ITEM_COMMAND_ALIAS;
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Registering /find command");
|
||||
registerBukkitCommand("find", alias, "Search for items from all shops using an interactive GUI", "/find",
|
||||
new FindCommandExecutor(alias), new FindCommandExecutor(alias));
|
||||
LoggerUtils.logInfo("Registered /find command");
|
||||
|
||||
}
|
||||
|
||||
private void initFindItemAdminCmd() {
|
||||
|
||||
final List<String> alias = List.of("fiadmin");
|
||||
LoggerUtils.logInfo("Registering /finditemadmin command");
|
||||
registerBukkitCommand("finditemadmin", alias, "Admin command for Shop Search addon", "/finditemadmin",
|
||||
new FindItemAdminCommandExecutor(alias), new FindItemAdminCommandExecutor(alias));
|
||||
LoggerUtils.logInfo("Registered /finditemadmin command");
|
||||
|
||||
}
|
||||
|
||||
private void registerBukkitCommand(String name, List<String> aliases, String description, String usage,
|
||||
CommandExecutor executor, TabCompleter completer)
|
||||
{
|
||||
|
||||
PluginCommand cmd = this.getCommand(name);
|
||||
if (cmd == null) {
|
||||
|
||||
cmd = registerDynamicPluginCommand(name);
|
||||
|
||||
}
|
||||
|
||||
if (cmd == null) {
|
||||
|
||||
LoggerUtils.logError("Failed to register command: " + name);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
cmd.setDescription(description);
|
||||
cmd.setUsage(usage);
|
||||
|
||||
if (aliases != null) {
|
||||
|
||||
cmd.setAliases(aliases);
|
||||
|
||||
}
|
||||
|
||||
cmd.setExecutor(executor);
|
||||
cmd.setTabCompleter(completer);
|
||||
|
||||
}
|
||||
|
||||
private PluginCommand registerDynamicPluginCommand(String name) {
|
||||
|
||||
try {
|
||||
|
||||
final CommandMap commandMap = getCommandMap();
|
||||
if (commandMap == null) {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
final Constructor<PluginCommand> ctor = PluginCommand.class.getDeclaredConstructor(String.class,
|
||||
Plugin.class);
|
||||
ctor.setAccessible(true);
|
||||
|
||||
final PluginCommand cmd = ctor.newInstance(name, this);
|
||||
commandMap.register(this.getPluginMeta().getName(), cmd);
|
||||
return cmd;
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
||||
LoggerUtils.logError(t.getMessage());
|
||||
t.printStackTrace();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private CommandMap getCommandMap() {
|
||||
|
||||
try {
|
||||
|
||||
final Method m = Bukkit.getServer().getClass().getMethod("getCommandMap");
|
||||
return (CommandMap) m.invoke(Bukkit.getServer());
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
||||
LoggerUtils.logError(t.getMessage());
|
||||
t.printStackTrace();
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private record FindCommandExecutor(List<String> aliases) implements CommandExecutor, TabCompleter {
|
||||
|
||||
private FindCommandExecutor(List<String> aliases) {
|
||||
|
||||
this.aliases = aliases == null ? Collections.emptyList() : aliases;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if (args.length == 0 || "help".equalsIgnoreCase(args[0])) {
|
||||
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
final String sub = args[0].toLowerCase();
|
||||
final String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
final SellSubCmd sellSubCmd = new SellSubCmd();
|
||||
final BuySubCmd buySubCmd = new BuySubCmd();
|
||||
final HideShopSubCmd hideShopSubCmd = new HideShopSubCmd();
|
||||
final RevealShopSubCmd revealShopSubCmd = new RevealShopSubCmd();
|
||||
|
||||
if (matchesSubCommand(sub, "sell", sellSubCmd)) {
|
||||
|
||||
return invokeSubCommand(sellSubCmd, sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "buy", buySubCmd)) {
|
||||
|
||||
return invokeSubCommand(buySubCmd, sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "hide", hideShopSubCmd) || "hideshop".equals(sub)) {
|
||||
|
||||
return invokeSubCommand(hideShopSubCmd, sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "reveal", revealShopSubCmd) || "revealshop".equals(sub)) {
|
||||
|
||||
return invokeSubCommand(revealShopSubCmd, sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
final SellSubCmd sellSubCmd = new SellSubCmd();
|
||||
final BuySubCmd buySubCmd = new BuySubCmd();
|
||||
final HideShopSubCmd hideShopSubCmd = new HideShopSubCmd();
|
||||
final RevealShopSubCmd revealShopSubCmd = new RevealShopSubCmd();
|
||||
|
||||
if (args.length == 1) {
|
||||
|
||||
return partialMatches(args[0],
|
||||
Arrays.asList(getSubCommandName(sellSubCmd), getSubCommandName(buySubCmd),
|
||||
getSubCommandName(hideShopSubCmd), getSubCommandName(revealShopSubCmd), "sell", "buy",
|
||||
"hide", "reveal", "help", "hideshop", "revealshop"));
|
||||
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
|
||||
final String sub = args[0].toLowerCase();
|
||||
final String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if (matchesSubCommand(sub, "sell", sellSubCmd)) {
|
||||
|
||||
return invokeTabComplete(sellSubCmd, sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "buy", buySubCmd)) {
|
||||
|
||||
return invokeTabComplete(buySubCmd, sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "hide", hideShopSubCmd) || "hideshop".equals(sub)) {
|
||||
|
||||
return invokeTabComplete(hideShopSubCmd, sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
if (matchesSubCommand(sub, "reveal", revealShopSubCmd) || "revealshop".equals(sub)) {
|
||||
|
||||
return invokeTabComplete(revealShopSubCmd, sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
private void sendHelp(CommandSender commandSender) {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&7------------------------"));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&6&lShop Search Commands"));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&7------------------------"));
|
||||
|
||||
final List<Object> subCommands = Arrays.asList(new SellSubCmd(), new BuySubCmd(), new HideShopSubCmd(),
|
||||
new RevealShopSubCmd());
|
||||
|
||||
subCommands.forEach(subCommand -> commandSender.sendMessage(UtilitiesOG.trueogColorize("<#ff9933>"
|
||||
+ getSubCommandSyntax(subCommand) + " <#a3a3c2>" + getSubCommandDescription(subCommand))));
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("<#b3b300>Command alias:"));
|
||||
aliases.forEach(
|
||||
alias_i -> commandSender.sendMessage(UtilitiesOG.trueogColorize("&8&l» <#2db300>/" + alias_i)));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private record FindItemAdminCommandExecutor(List<String> aliases) implements CommandExecutor, TabCompleter {
|
||||
|
||||
private FindItemAdminCommandExecutor(List<String> aliases) {
|
||||
|
||||
this.aliases = aliases == null ? Collections.emptyList() : aliases;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if (!((sender.isOp()) || (!sender.isOp() && (sender.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())
|
||||
|| sender.hasPermission(PlayerPerms.FINDITEM_RELOAD.value())))))
|
||||
{
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args.length == 0 || "help".equalsIgnoreCase(args[0])) {
|
||||
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
final String sub = args[0].toLowerCase();
|
||||
final String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if ("reload".equals(sub)) {
|
||||
|
||||
return invokeSubCommand(new ReloadSubCmd(), sender, command, label, subArgs);
|
||||
|
||||
}
|
||||
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
|
||||
if (!((sender.isOp()) || (!sender.isOp() && (sender.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())
|
||||
|| sender.hasPermission(PlayerPerms.FINDITEM_RELOAD.value())))))
|
||||
{
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
|
||||
return partialMatches(args[0], Arrays.asList("reload", "help"));
|
||||
|
||||
}
|
||||
|
||||
if (args.length >= 2) {
|
||||
|
||||
final String sub = args[0].toLowerCase();
|
||||
final String[] subArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if ("reload".equals(sub)) {
|
||||
|
||||
return invokeTabComplete(new ReloadSubCmd(), sender, command, alias, subArgs);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
private void sendHelp(CommandSender commandSender) {
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&7-----------------------------"));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&6&lShop Search Admin Commands"));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("&7-----------------------------"));
|
||||
|
||||
final List<Object> subCommands = Collections.singletonList(new ReloadSubCmd());
|
||||
|
||||
subCommands.forEach(subCommand -> commandSender.sendMessage(UtilitiesOG.trueogColorize("<#ff1a1a>"
|
||||
+ getSubCommandSyntax(subCommand) + " <#a3a3c2>" + getSubCommandDescription(subCommand))));
|
||||
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize("<#b3b300>Command alias:"));
|
||||
aliases.forEach(
|
||||
alias_i -> commandSender.sendMessage(UtilitiesOG.trueogColorize("&8&l» <#2db300>/" + alias_i)));
|
||||
commandSender.sendMessage(UtilitiesOG.trueogColorize(""));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static boolean invokeSubCommand(Object subCommand, CommandSender sender, Command command, String label,
|
||||
String[] args)
|
||||
{
|
||||
|
||||
if (subCommand instanceof CommandExecutor) {
|
||||
|
||||
return ((CommandExecutor) subCommand).onCommand(sender, command, label, args);
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("execute", CommandSender.class, String[].class);
|
||||
final Object res = m.invoke(subCommand, sender, args);
|
||||
if (res instanceof Boolean) {
|
||||
|
||||
return (Boolean) res;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("execute", CommandSender.class, Command.class,
|
||||
String.class, String[].class);
|
||||
final Object res = m.invoke(subCommand, sender, command, label, args);
|
||||
if (res instanceof Boolean) {
|
||||
|
||||
return (Boolean) res;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("onCommand", CommandSender.class, Command.class,
|
||||
String.class, String[].class);
|
||||
final Object res = m.invoke(subCommand, sender, command, label, args);
|
||||
if (res instanceof Boolean) {
|
||||
|
||||
return (Boolean) res;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} catch (Throwable t) {
|
||||
|
||||
LoggerUtils.logError(t.getMessage());
|
||||
t.printStackTrace();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static List<String> invokeTabComplete(Object subCommand, CommandSender sender, Command command,
|
||||
String label, String[] args)
|
||||
{
|
||||
|
||||
if (subCommand instanceof TabCompleter) {
|
||||
|
||||
final List<String> res = ((TabCompleter) subCommand).onTabComplete(sender, command, label, args);
|
||||
return res == null ? Collections.emptyList() : res;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("onTabComplete", CommandSender.class, Command.class,
|
||||
String.class, String[].class);
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<String> res = (List<String>) m.invoke(subCommand, sender, command, label, args);
|
||||
return res == null ? Collections.emptyList() : res;
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
private static String getSubCommandSyntax(Object subCommand) {
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("getSyntax");
|
||||
final Object res = m.invoke(subCommand);
|
||||
return res == null ? "" : String.valueOf(res);
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
private static String getSubCommandName(Object subCommand) {
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("getName");
|
||||
final Object res = m.invoke(subCommand);
|
||||
return res == null ? "" : String.valueOf(res);
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
private static boolean matchesSubCommand(String input, String fallbackCommand, Object subCommand) {
|
||||
|
||||
if (fallbackCommand.equalsIgnoreCase(input)) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
final String subCommandName = getSubCommandName(subCommand);
|
||||
return !subCommandName.isBlank() && subCommandName.equalsIgnoreCase(input);
|
||||
|
||||
}
|
||||
|
||||
private static String getSubCommandDescription(Object subCommand) {
|
||||
|
||||
try {
|
||||
|
||||
final Method m = subCommand.getClass().getMethod("getDescription");
|
||||
final Object res = m.invoke(subCommand);
|
||||
return res == null ? "" : String.valueOf(res);
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
private static List<String> partialMatches(String token, List<String> options) {
|
||||
|
||||
if (token == null || token.isEmpty()) {
|
||||
|
||||
return options;
|
||||
|
||||
}
|
||||
|
||||
final String lower = token.toLowerCase();
|
||||
return options.stream().filter(s -> s.toLowerCase().startsWith(lower)).toList();
|
||||
|
||||
}
|
||||
|
||||
public static boolean isQSReremakeInstalled() {
|
||||
|
||||
return qSReremakeInstalled;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isQSHikariInstalled() {
|
||||
|
||||
return qSHikariInstalled;
|
||||
|
||||
}
|
||||
|
||||
public static void setQSReremakeInstalled(boolean qSReremakeInstalled) {
|
||||
|
||||
FindItemAddOnOG.qSReremakeInstalled = qSReremakeInstalled;
|
||||
|
||||
}
|
||||
|
||||
public static void setQSHikariInstalled(boolean qSHikariInstalled) {
|
||||
|
||||
FindItemAddOnOG.qSHikariInstalled = qSHikariInstalled;
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static QSApi getQsApiInstance() {
|
||||
|
||||
return qsApi;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+412
-270
@@ -1,14 +1,7 @@
|
||||
package io.myzticbean.finditemaddon.Handlers.CommandHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.ConfigUtil.ConfigSetup;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.Menus.FoundShopsMenu;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.HiddenShopStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.WarpUtils;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -18,423 +11,572 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.quickshop.api.shop.Shop;
|
||||
|
||||
import java.util.List;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.ConfigUtil.ConfigSetup;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.Menus.FoundShopsMenu;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.HiddenShopStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.WarpUtils;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* Handler for different parameters of /finditem command
|
||||
* @author ronsane
|
||||
* Handler for different parameters of /find command
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class CmdExecutorHandler {
|
||||
|
||||
/**
|
||||
* Handles the main shop search process
|
||||
*
|
||||
* @param buySellSubCommand Whether player is buying or selling
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
* @param itemArg Specifies Item ID or Item name
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
* @param itemArg Specifies Item ID or Item name
|
||||
*/
|
||||
public void handleShopSearch(String buySellSubCommand, CommandSender commandSender, String itemArg) {
|
||||
|
||||
if (!(commandSender instanceof Player)) {
|
||||
|
||||
LoggerUtils.logInfo("This command can only be run from in game");
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if(player.hasPermission(PlayerPerms.FINDITEM_USE.value())) {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_SEARCH_LOADING_MSG)) {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().SHOP_SEARCH_LOADING_MSG));
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_USE.value())) {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_SEARCH_LOADING_MSG)) {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_SEARCH_LOADING_MSG));
|
||||
|
||||
}
|
||||
|
||||
boolean isBuying;
|
||||
if(StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " ")) {
|
||||
if (StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE)
|
||||
|| StringUtils.containsIgnoreCase(
|
||||
FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE, " "))
|
||||
{
|
||||
|
||||
isBuying = buySellSubCommand.equalsIgnoreCase("to_buy");
|
||||
}
|
||||
else {
|
||||
isBuying = buySellSubCommand.equalsIgnoreCase(FindItemAddOn.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
|
||||
} else {
|
||||
|
||||
isBuying = buySellSubCommand
|
||||
.equalsIgnoreCase(FindItemAddOnOG.getConfigProvider().FIND_ITEM_TO_BUY_AUTOCOMPLETE);
|
||||
|
||||
}
|
||||
|
||||
if(itemArg.equalsIgnoreCase("*")) {
|
||||
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().fetchAllItemsFromAllShops(isBuying, player);
|
||||
if(searchResultList.size() > 0) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
|
||||
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
|
||||
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
|
||||
if (itemArg.equalsIgnoreCase("*")) {
|
||||
|
||||
List<FoundShopItemModel> searchResultList = FindItemAddOnOG.getQsApiInstance()
|
||||
.fetchAllItemsFromAllShops(isBuying, player);
|
||||
if (searchResultList.size() > 0) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOnOG.getPlayerMenuUtility(player),
|
||||
searchResultList);
|
||||
Bukkit.getScheduler().runTask(FindItemAddOnOG.getInstance(),
|
||||
() -> menu.open(searchResultList));
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG)) {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().NO_SHOP_FOUND_MSG)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().NO_SHOP_FOUND_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
Material mat = Material.getMaterial(itemArg.toUpperCase());
|
||||
if(mat != null) {
|
||||
|
||||
} else {
|
||||
|
||||
final Material mat = Material.getMaterial(itemArg.toUpperCase());
|
||||
if (mat != null) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Material found: " + mat.toString());
|
||||
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().findItemBasedOnTypeFromAllShops(new ItemStack(mat), isBuying, player);
|
||||
if(searchResultList.size() > 0) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
|
||||
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
|
||||
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
|
||||
final List<FoundShopItemModel> searchResultList = FindItemAddOnOG.getQsApiInstance()
|
||||
.findItemBasedOnTypeFromAllShops(new ItemStack(mat), isBuying, player);
|
||||
if (searchResultList.size() > 0) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
final FoundShopsMenu menu = new FoundShopsMenu(
|
||||
FindItemAddOnOG.getPlayerMenuUtility(player), searchResultList);
|
||||
Bukkit.getScheduler().runTask(FindItemAddOnOG.getInstance(),
|
||||
() -> menu.open(searchResultList));
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG)) {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().NO_SHOP_FOUND_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().NO_SHOP_FOUND_MSG)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().NO_SHOP_FOUND_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo("Material not found! Performing query based search..");
|
||||
List<FoundShopItemModel> searchResultList = FindItemAddOn.getQsApiInstance().findItemBasedOnDisplayNameFromAllShops(itemArg, isBuying, player);
|
||||
if(searchResultList.size() > 0) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
|
||||
FoundShopsMenu menu = new FoundShopsMenu(FindItemAddOn.getPlayerMenuUtility(player), searchResultList);
|
||||
Bukkit.getScheduler().runTask(FindItemAddOn.getInstance(), () -> menu.open(searchResultList));
|
||||
List<FoundShopItemModel> searchResultList = FindItemAddOnOG.getQsApiInstance()
|
||||
.findItemBasedOnDisplayNameFromAllShops(itemArg, isBuying, player);
|
||||
if (searchResultList.size() > 0) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
final FoundShopsMenu menu = new FoundShopsMenu(
|
||||
FindItemAddOnOG.getPlayerMenuUtility(player), searchResultList);
|
||||
Bukkit.getScheduler().runTask(FindItemAddOnOG.getInstance(),
|
||||
() -> menu.open(searchResultList));
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Invalid Material
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG)) {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
// Invalid Material.
|
||||
if (!StringUtils
|
||||
.isEmpty(FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG))
|
||||
{
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(
|
||||
FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + FindItemAddOnOG
|
||||
.getConfigProvider().FIND_ITEM_CMD_INVALID_MATERIAL_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the shop hiding feature
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
public void handleHideShop(CommandSender commandSender) {
|
||||
|
||||
if (!(commandSender instanceof Player)) {
|
||||
|
||||
LoggerUtils.logInfo("This command can only be run from in game");
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if(player.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
Block playerLookAtBlock = player.getTargetBlock(null, 100);
|
||||
if(FindItemAddOn.isQSReremakeInstalled()) {
|
||||
hideShop((Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
}
|
||||
else {
|
||||
hideShop((com.ghostchu.quickshop.api.shop.Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
if (FindItemAddOnOG.isQSReremakeInstalled()) {
|
||||
|
||||
hideShop((Shop) FindItemAddOnOG.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
|
||||
} else {
|
||||
|
||||
hideShop((com.ghostchu.quickshop.api.shop.Shop) FindItemAddOnOG.getQsApiInstance()
|
||||
.findShopAtLocation(playerLookAtBlock), player);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the shop reveal feature
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
public void handleRevealShop(CommandSender commandSender) {
|
||||
|
||||
if (!(commandSender instanceof Player)) {
|
||||
|
||||
LoggerUtils.logInfo("This command can only be run from in game");
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if(player.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_HIDESHOP.value())) {
|
||||
|
||||
Block playerLookAtBlock = player.getTargetBlock(null, 100);
|
||||
if(FindItemAddOn.isQSReremakeInstalled()) {
|
||||
revealShop((Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
}
|
||||
else {
|
||||
revealShop((com.ghostchu.quickshop.api.shop.Shop) FindItemAddOn.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
if (FindItemAddOnOG.isQSReremakeInstalled()) {
|
||||
|
||||
revealShop((Shop) FindItemAddOnOG.getQsApiInstance().findShopAtLocation(playerLookAtBlock), player);
|
||||
|
||||
} else {
|
||||
|
||||
revealShop((com.ghostchu.quickshop.api.shop.Shop) FindItemAddOnOG.getQsApiInstance()
|
||||
.findShopAtLocation(playerLookAtBlock), player);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the saving hidden shops to file feature
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
/*
|
||||
public void handleHiddenShopSavingToFile(CommandSender commandSender) {
|
||||
if (!(commandSender instanceof Player)) {
|
||||
LoggerUtils.logInfo("This command can only be run from in game");
|
||||
}
|
||||
else {
|
||||
Player player = (Player) commandSender;
|
||||
if(player.hasPermission(PlayerPerms.FINDITEM_ADMIN.toString())) {
|
||||
HiddenShopStorageUtil.saveHiddenShopsToFile();
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&aSaved hidden shops!"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(
|
||||
ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&cNo permission!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
* public void handleHiddenShopSavingToFile(CommandSender commandSender) { if
|
||||
* (!(commandSender instanceof Player)) {
|
||||
* LoggerUtils.logInfo("This command can only be run from in game"); } else {
|
||||
* Player player = (Player) commandSender;
|
||||
* if(player.hasPermission(PlayerPerms.FINDITEM_ADMIN.toString())) {
|
||||
* HiddenShopStorageUtil.saveHiddenShopsToFile();
|
||||
* player.sendMessage(UtilitiesOG.trueogColorize(
|
||||
* FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&aSaved hidden shops!"));
|
||||
* } else { player.sendMessage( UtilitiesOG.trueogColorize(
|
||||
* FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!")); } } }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles the loading of hidden shops from file feature
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
/*
|
||||
public void handleHiddenShopLoadingFromFile(CommandSender commandSender) {
|
||||
if (!(commandSender instanceof Player)) {
|
||||
LoggerUtils.logInfo("This command can only be run from in game");
|
||||
}
|
||||
else {
|
||||
Player player = (Player) commandSender;
|
||||
if(player.hasPermission(PlayerPerms.FINDITEM_ADMIN.toString())) {
|
||||
HiddenShopStorageUtil.loadHiddenShopsFromFile();
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&aSaved hidden shops!"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(
|
||||
ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&cNo permission!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
* public void handleHiddenShopLoadingFromFile(CommandSender commandSender) { if
|
||||
* (!(commandSender instanceof Player)) {
|
||||
* LoggerUtils.logInfo("This command can only be run from in game"); } else {
|
||||
* Player player = (Player) commandSender;
|
||||
* if(player.hasPermission(PlayerPerms.FINDITEM_ADMIN.toString())) {
|
||||
* HiddenShopStorageUtil.loadHiddenShopsFromFile();
|
||||
* player.sendMessage(UtilitiesOG.trueogColorize(
|
||||
* FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&aSaved hidden shops!"));
|
||||
* } else { player.sendMessage( UtilitiesOG.trueogColorize(
|
||||
* FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!")); } } }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handles plugin reload
|
||||
*
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
public void handlePluginReload(CommandSender commandSender) {
|
||||
|
||||
if (!(commandSender instanceof Player)) {
|
||||
|
||||
ConfigSetup.reloadConfig();
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
FindItemAddOn.initConfigProvider();
|
||||
List allServerShops = FindItemAddOn.getQsApiInstance().getAllShops();
|
||||
if(allServerShops.size() == 0) {
|
||||
LoggerUtils.logWarning("&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
}
|
||||
else {
|
||||
FindItemAddOnOG.initConfigProvider();
|
||||
List allServerShops = FindItemAddOnOG.getQsApiInstance().getAllShops();
|
||||
if (allServerShops.size() == 0) {
|
||||
|
||||
LoggerUtils.logWarning(
|
||||
"&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logInfo("&aFound &e" + allServerShops.size() + " &ashops on the server.");
|
||||
|
||||
}
|
||||
|
||||
WarpUtils.updateWarps();
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if(player.hasPermission(PlayerPerms.FINDITEM_RELOAD.value()) || player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())) {
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_RELOAD.value())
|
||||
|| player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value()))
|
||||
{
|
||||
|
||||
ConfigSetup.reloadConfig();
|
||||
ConfigSetup.checkForMissingProperties();
|
||||
ConfigSetup.saveConfig();
|
||||
FindItemAddOn.initConfigProvider();
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&aConfig reloaded!"));
|
||||
List allServerShops = FindItemAddOn.getQsApiInstance().getAllShops();
|
||||
if(allServerShops.size() == 0) {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&aFound &e" + allServerShops.size() + " &ashops on the server."));
|
||||
FindItemAddOnOG.initConfigProvider();
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&aConfig reloaded!"));
|
||||
final List allServerShops = FindItemAddOnOG.getQsApiInstance().getAllShops();
|
||||
if (allServerShops.size() == 0) {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!"));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&aFound &e" + allServerShops.size() + " &ashops on the server."));
|
||||
|
||||
}
|
||||
|
||||
WarpUtils.updateWarps();
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles plugin restart
|
||||
* @deprecated Handles plugin restart
|
||||
* @param commandSender Who is the command sender: console or player
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public void handlePluginRestart(CommandSender commandSender) {
|
||||
|
||||
if (!(commandSender instanceof Player)) {
|
||||
Bukkit.getPluginManager().disablePlugin(FindItemAddOn.getInstance());
|
||||
Bukkit.getPluginManager().enablePlugin(FindItemAddOn.getPlugin(FindItemAddOn.class));
|
||||
|
||||
Bukkit.getPluginManager().disablePlugin(FindItemAddOnOG.getInstance());
|
||||
Bukkit.getPluginManager().enablePlugin(FindItemAddOnOG.getPlugin(FindItemAddOnOG.class));
|
||||
LoggerUtils.logInfo("&aPlugin restarted!");
|
||||
List allServerShops = FindItemAddOn.getQsApiInstance().getAllShops();
|
||||
if(allServerShops.size() == 0) {
|
||||
LoggerUtils.logWarning("&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
}
|
||||
else {
|
||||
List allServerShops = FindItemAddOnOG.getQsApiInstance().getAllShops();
|
||||
if (allServerShops.size() == 0) {
|
||||
|
||||
LoggerUtils.logWarning(
|
||||
"&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!");
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logInfo("&aFound &e" + allServerShops.size() + " &ashops on the server.");
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if(player.hasPermission(PlayerPerms.FINDITEM_RESTART.value()) || player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())) {
|
||||
Bukkit.getPluginManager().disablePlugin(FindItemAddOn.getInstance());
|
||||
Bukkit.getPluginManager().enablePlugin(FindItemAddOn.getPlugin(FindItemAddOn.class));
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&aPlugin restarted!"));
|
||||
List allServerShops = FindItemAddOn.getQsApiInstance().getAllShops();
|
||||
if(allServerShops.size() == 0) {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!"));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&aFound &e" + allServerShops.size() + " &ashops on the server."));
|
||||
if (player.hasPermission(PlayerPerms.FINDITEM_RESTART.value())
|
||||
|| player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value()))
|
||||
{
|
||||
|
||||
Bukkit.getPluginManager().disablePlugin(FindItemAddOnOG.getInstance());
|
||||
Bukkit.getPluginManager().enablePlugin(FindItemAddOnOG.getPlugin(FindItemAddOnOG.class));
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&aPlugin restarted!"));
|
||||
List allServerShops = FindItemAddOnOG.getQsApiInstance().getAllShops();
|
||||
if (allServerShops.size() == 0) {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&6Found &e0 &6shops on the server. If you ran &e/qs reload &6recently, please restart your server!"));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ "&aFound &e" + allServerShops.size() + " &ashops on the server."));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + "&cNo permission!"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles hide shop for QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void hideShop(Shop shop, Player player) {
|
||||
if(shop != null) {
|
||||
private void hideShop(org.maxgamer.quickshop.api.shop.Shop shop, Player player) {
|
||||
|
||||
if (shop != null) {
|
||||
|
||||
// check if command runner same as shop owner
|
||||
if(FindItemAddOn.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
if (FindItemAddOnOG.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, true);
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG));
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles hide shop for QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void hideShop(com.ghostchu.quickshop.api.shop.Shop shop, Player player) {
|
||||
if(shop != null) {
|
||||
|
||||
if (shop != null) {
|
||||
|
||||
// check if command runner same as shop owner
|
||||
if(FindItemAddOn.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
if (FindItemAddOnOG.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, true);
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG));
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_HIDE_SUCCESS_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_HIDDEN_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles reveal shop for QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void revealShop(Shop shop, Player player) {
|
||||
if(shop != null) {
|
||||
|
||||
if (shop != null) {
|
||||
|
||||
// check if command runner same as shop owner
|
||||
if(FindItemAddOn.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
if(HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
if (FindItemAddOnOG.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
|
||||
if (HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, false);
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG));
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles reveal shop for QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
* @param player
|
||||
*/
|
||||
private void revealShop(com.ghostchu.quickshop.api.shop.Shop shop, Player player) {
|
||||
if(shop != null) {
|
||||
// check if command runner same as shop owner
|
||||
if(FindItemAddOn.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
if(HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, false);
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shop != null) {
|
||||
|
||||
// check if command runner same as shop owner
|
||||
if (FindItemAddOnOG.getQsApiInstance().isShopOwnerCommandRunner(player, shop)) {
|
||||
|
||||
if (HiddenShopStorageUtil.isShopHidden(shop)) {
|
||||
|
||||
HiddenShopStorageUtil.handleShopSearchVisibilityAsync(shop, false);
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_REVEAL_SUCCESS_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_SHOP_ALREADY_PUBLIC_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_HIDING_SHOP_OWNER_INVALID_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
player.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().FIND_ITEM_CMD_INVALID_SHOP_BLOCK_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.myzticbean.finditemaddon.Handlers.GUIHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@@ -11,10 +11,15 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
|
||||
// Based on an awesome tutorial from https://www.youtube.com/watch?v=xebH6M_7k18
|
||||
// Gui pagination: https://www.youtube.com/watch?v=e80NO9Pgz7s
|
||||
/**
|
||||
* Based on an awesome tutorial from https://www.youtube.com/watch?v=xebH6M_7k18
|
||||
* Gui pagination: https://www.youtube.com/watch?v=e80NO9Pgz7s
|
||||
*/
|
||||
public abstract class Menu implements InventoryHolder {
|
||||
|
||||
protected Inventory inventory;
|
||||
@@ -23,22 +28,27 @@ public abstract class Menu implements InventoryHolder {
|
||||
|
||||
protected ItemStack GUI_FILLER_ITEM;
|
||||
|
||||
public Menu(PlayerMenuUtility playerMenuUtility) {
|
||||
protected Menu(PlayerMenuUtility playerMenuUtility) {
|
||||
|
||||
this.playerMenuUtility = playerMenuUtility;
|
||||
|
||||
assert FindItemAddOn.getConfigProvider().SHOP_GUI_FILLER_ITEM != null;
|
||||
Material fillerMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_FILLER_ITEM);
|
||||
if(fillerMaterial == null) {
|
||||
assert FindItemAddOnOG.getConfigProvider().SHOP_GUI_FILLER_ITEM != null;
|
||||
Material fillerMaterial = Material.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_FILLER_ITEM);
|
||||
if (fillerMaterial == null) {
|
||||
|
||||
fillerMaterial = Material.GRAY_STAINED_GLASS_PANE;
|
||||
|
||||
}
|
||||
|
||||
GUI_FILLER_ITEM = new ItemStack(fillerMaterial);
|
||||
ItemMeta FILLER_GLASS_meta = this.GUI_FILLER_ITEM.getItemMeta();
|
||||
final ItemMeta FILLER_GLASS_meta = this.GUI_FILLER_ITEM.getItemMeta();
|
||||
assert FILLER_GLASS_meta != null;
|
||||
FILLER_GLASS_meta.setDisplayName(" ");
|
||||
FILLER_GLASS_meta.displayName(Component.text(" "));
|
||||
this.GUI_FILLER_ITEM.setItemMeta(FILLER_GLASS_meta);
|
||||
|
||||
}
|
||||
|
||||
public abstract String getMenuName();
|
||||
public abstract TextComponent getMenuName();
|
||||
|
||||
public abstract int getSlots();
|
||||
|
||||
@@ -49,20 +59,27 @@ public abstract class Menu implements InventoryHolder {
|
||||
public abstract void setMenuItems(List<FoundShopItemModel> foundShops);
|
||||
|
||||
public void open() {
|
||||
|
||||
inventory = Bukkit.createInventory(this, getSlots(), getMenuName());
|
||||
this.setMenuItems();
|
||||
playerMenuUtility.getOwner().openInventory(inventory);
|
||||
|
||||
}
|
||||
|
||||
public void open(List<FoundShopItemModel> foundShops) {
|
||||
|
||||
inventory = Bukkit.createInventory(this, getSlots(), getMenuName());
|
||||
this.setMenuItems(foundShops);
|
||||
playerMenuUtility.getOwner().openInventory(inventory);
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
|
||||
return inventory;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+508
-243
@@ -1,24 +1,18 @@
|
||||
package io.myzticbean.finditemaddon.Handlers.GUIHandler.Menus;
|
||||
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.Dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.Dependencies.WGPlugin;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.PaginatedMenu;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.PlayerMenuUtility;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.ShopLorePlaceholders;
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.LocationUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.EssentialWarpsUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.PlayerWarpsUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.WGRegionUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
@@ -26,14 +20,28 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.Dependencies.WGPlugin;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.PaginatedMenu;
|
||||
import io.myzticbean.finditemaddon.Handlers.GUIHandler.PlayerMenuUtility;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LocationUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.ShopLorePlaceholders;
|
||||
import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStorageUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.EssentialWarpsUtil;
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.WGRegionUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
/**
|
||||
* Handler class for FoundShops GUI
|
||||
* @author ronsane
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class FoundShopsMenu extends PaginatedMenu {
|
||||
|
||||
@@ -41,302 +49,559 @@ public class FoundShopsMenu extends PaginatedMenu {
|
||||
private final String NO_WG_REGION_NEAR_SHOP_ERROR_MSG = "No WG Region near this shop";
|
||||
|
||||
public FoundShopsMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
|
||||
|
||||
super(playerMenuUtility, searchResult);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMenuName() {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_SEARCH_GUI_TITLE)) {
|
||||
return ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_SEARCH_GUI_TITLE);
|
||||
}
|
||||
else {
|
||||
return ColorTranslator.translateColorCodes("&l» &rShops");
|
||||
public TextComponent getMenuName() {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_SEARCH_GUI_TITLE)) {
|
||||
|
||||
return UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_SEARCH_GUI_TITLE);
|
||||
|
||||
} else {
|
||||
|
||||
return UtilitiesOG.trueogColorize("&l» &rShops");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots() {
|
||||
|
||||
return 54;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMenu(InventoryClickEvent event) {
|
||||
if(event.getSlot() == 45) {
|
||||
if(page == 0) {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
|
||||
event.getWhoClicked().sendMessage(
|
||||
ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOn.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG));
|
||||
}
|
||||
}
|
||||
else {
|
||||
page = page - 1;
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
}
|
||||
|
||||
// Previous Page
|
||||
if (event.getSlot() == 45) {
|
||||
|
||||
handleMenuClickForNavToPrevPage(event);
|
||||
|
||||
}
|
||||
else if(event.getSlot() == 53) {
|
||||
if(!((index + 1) >= super.playerMenuUtility.getPlayerShopSearchResult().size())) {
|
||||
page = page + 1;
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
}
|
||||
else {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
|
||||
event.getWhoClicked().sendMessage(
|
||||
ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG));
|
||||
}
|
||||
}
|
||||
// First Page
|
||||
else if (event.getSlot() == 46) {
|
||||
|
||||
handleFirstPageClick(event);
|
||||
|
||||
}
|
||||
else if(event.getCurrentItem().getType().equals(Material.BARRIER) && event.getSlot() == 49) {
|
||||
// Last Page
|
||||
else if (event.getSlot() == 52) {
|
||||
|
||||
handleLastPageClick(event);
|
||||
|
||||
}
|
||||
// Next Page
|
||||
else if (event.getSlot() == 53) {
|
||||
|
||||
handleMenuClickForNavToNextPage(event);
|
||||
|
||||
}
|
||||
// Issue #31: Removing condition
|
||||
// 'event.getCurrentItem().getType().equals(Material.BARRIER)'
|
||||
else if (event.getSlot() == 49) {
|
||||
|
||||
event.getWhoClicked().closeInventory();
|
||||
}
|
||||
else if(event.getCurrentItem().getType().equals(Material.AIR)) {
|
||||
// do nothing
|
||||
LoggerUtils.logDebugInfo(event.getWhoClicked().getName() + " just clicked on AIR!");
|
||||
}
|
||||
else {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
ItemStack item = event.getCurrentItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
NamespacedKey key = new NamespacedKey(FindItemAddOn.getInstance(), "locationData");
|
||||
if(!meta.getPersistentDataContainer().isEmpty() && meta.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
|
||||
String locData = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
||||
List<String> locDataList = Arrays.asList(locData.split("\\s*,\\s*"));
|
||||
if(FindItemAddOn.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP) {
|
||||
if(playerMenuUtility.getOwner().hasPermission(PlayerPerms.FINDITEM_SHOPTP.value())) {
|
||||
World world = Bukkit.getWorld(locDataList.get(0));
|
||||
int locX = Integer.parseInt(locDataList.get(1)), locY = Integer.parseInt(locDataList.get(2)), locZ = Integer.parseInt(locDataList.get(3));
|
||||
Location shopLocation = new Location(world, locX, locY, locZ);
|
||||
Location locToTeleport = LocationUtils.findSafeLocationAroundShop(shopLocation);
|
||||
if(locToTeleport != null) {
|
||||
// Add Player Visit Entry
|
||||
|
||||
} else {
|
||||
|
||||
final ItemStack clicked = event.getCurrentItem();
|
||||
if (clicked == null || clicked.getType() == Material.AIR) {
|
||||
|
||||
LoggerUtils.logDebugInfo(event.getWhoClicked().getName() + " just clicked on AIR!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
final ItemMeta meta = clicked.getItemMeta();
|
||||
if (meta == null) {
|
||||
|
||||
LoggerUtils.logError("Clicked item has no ItemMeta!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final NamespacedKey key = new NamespacedKey(FindItemAddOnOG.getInstance(), "locationData");
|
||||
if (!meta.getPersistentDataContainer().isEmpty()
|
||||
&& meta.getPersistentDataContainer().has(key, PersistentDataType.STRING))
|
||||
{
|
||||
|
||||
final String locData = meta.getPersistentDataContainer().get(key, PersistentDataType.STRING);
|
||||
if (locData == null) {
|
||||
|
||||
LoggerUtils.logError("PersistentDataContainer locationData is null!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final List<String> locDataList = Arrays.asList(locData.split("\\s*,\\s*"));
|
||||
if (FindItemAddOnOG.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP) {
|
||||
|
||||
if (playerMenuUtility.getOwner().hasPermission(PlayerPerms.FINDITEM_SHOPTP.value())) {
|
||||
|
||||
final World world = Bukkit.getWorld(locDataList.get(0));
|
||||
if (world == null) {
|
||||
|
||||
LoggerUtils.logError("World not found: " + locDataList.get(0));
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final int locX = Integer.parseInt(locDataList.get(1));
|
||||
final int locY = Integer.parseInt(locDataList.get(2));
|
||||
final int locZ = Integer.parseInt(locDataList.get(3));
|
||||
final Location shopLocation = new Location(world, locX, locY, locZ);
|
||||
final UUID shopOwner = ShopSearchActivityStorageUtil.getShopOwnerUUID(shopLocation);
|
||||
if (player.getUniqueId().equals(shopOwner) && !PlayerPerms.canPlayerTpToOwnShop(player)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG));
|
||||
|
||||
}
|
||||
|
||||
final Location locToTeleport = LocationUtils.findSafeLocationAroundShop(shopLocation);
|
||||
if (locToTeleport != null) {
|
||||
|
||||
ShopSearchActivityStorageUtil.addPlayerVisitEntryAsync(shopLocation, player);
|
||||
|
||||
// Add Short Blindness effect... maybe?
|
||||
/**
|
||||
* @// TODO: 16/06/22 Make this an option in config
|
||||
*/
|
||||
// player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 0, false, false, false));
|
||||
if (EssentialsXPlugin.isEnabled()) {
|
||||
|
||||
// Teleport
|
||||
// If EssentialsX is enabled, register last location before teleporting to make /back work
|
||||
if(EssentialsXPlugin.isEnabled()) {
|
||||
EssentialsXPlugin.getAPI().getUser(player).setLastLocation();
|
||||
|
||||
}
|
||||
PaperLib.teleportAsync(player, locToTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
}
|
||||
else {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().UNSAFE_SHOP_AREA_MSG)) {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().UNSAFE_SHOP_AREA_MSG));
|
||||
|
||||
if (StringUtils.isNumeric(FindItemAddOnOG.getConfigProvider().TP_DELAY_IN_SECONDS)
|
||||
&& !"0".equals(FindItemAddOnOG.getConfigProvider().TP_DELAY_IN_SECONDS)
|
||||
&& !PlayerPerms.hasShopTpDelayBypassPermOrAdmin(player))
|
||||
{
|
||||
|
||||
final long delay = Long
|
||||
.parseLong(FindItemAddOnOG.getConfigProvider().TP_DELAY_IN_SECONDS);
|
||||
LoggerUtils.logDebugInfo("Teleporting delay is set to: " + delay);
|
||||
final String tpDelayMsg = FindItemAddOnOG.getConfigProvider().TP_DELAY_MESSAGE;
|
||||
if (!StringUtils.isEmpty(tpDelayMsg)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ replaceDelayPlaceholder(tpDelayMsg, delay)));
|
||||
|
||||
}
|
||||
|
||||
Bukkit.getScheduler()
|
||||
.scheduleSyncDelayedTask(
|
||||
FindItemAddOnOG.getInstance(), () -> PaperLib.teleportAsync(player,
|
||||
locToTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN),
|
||||
delay * 20);
|
||||
|
||||
} else {
|
||||
|
||||
PaperLib.teleportAsync(player, locToTeleport, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().UNSAFE_SHOP_AREA_MSG)) {
|
||||
|
||||
player.sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().UNSAFE_SHOP_AREA_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG)) {
|
||||
playerMenuUtility.getOwner()
|
||||
.sendMessage(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().PLUGIN_PREFIX + FindItemAddOn.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG));
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG)) {
|
||||
|
||||
playerMenuUtility.getOwner().sendMessage(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_TP_NO_PERMISSION_MSG));
|
||||
event.getWhoClicked().closeInventory();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
}
|
||||
else if(FindItemAddOn.getConfigProvider().TP_PLAYER_TO_NEAREST_WARP) {
|
||||
// if list size = 1, it contains Warp name
|
||||
if(locDataList.size() == 1) {
|
||||
String warpName = locDataList.get(0);
|
||||
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 1) {
|
||||
Bukkit.dispatchCommand(player, "essentials:warp " + warpName);
|
||||
}
|
||||
else if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 2) {
|
||||
PlayerWarpsPlugin.executeWarpPlayer(player, warpName);
|
||||
}
|
||||
|
||||
} else if (FindItemAddOnOG.getConfigProvider().TP_PLAYER_TO_NEAREST_WARP && locDataList.size() == 1) {
|
||||
|
||||
final String warpName = locDataList.get(0);
|
||||
if (FindItemAddOnOG.getConfigProvider().NEAREST_WARP_MODE == 1) {
|
||||
|
||||
Bukkit.dispatchCommand(player, "essentials:warp " + warpName);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logError("PersistentDataContainer doesn't have the right kind of data!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleMenuClickForNavToNextPage(InventoryClickEvent event) {
|
||||
|
||||
if (!((index + 1) >= super.playerMenuUtility.getPlayerShopSearchResult().size())) {
|
||||
|
||||
page = page + 1;
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
|
||||
|
||||
event.getWhoClicked()
|
||||
.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleMenuClickForNavToPrevPage(InventoryClickEvent event) {
|
||||
|
||||
if (page == 0) {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
|
||||
|
||||
event.getWhoClicked()
|
||||
.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
page = page - 1;
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleFirstPageClick(InventoryClickEvent event) {
|
||||
|
||||
if (page == 0) {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG)) {
|
||||
|
||||
event.getWhoClicked()
|
||||
.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_NAV_FIRST_PAGE_ALERT_MSG));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
page = 0;
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void handleLastPageClick(InventoryClickEvent event) {
|
||||
|
||||
int listSize = super.playerMenuUtility.getPlayerShopSearchResult().size();
|
||||
if (!((index + 1) >= listSize)) {
|
||||
|
||||
double totalPages = listSize / maxItemsPerPage;
|
||||
if (totalPages % 10 == 0) {
|
||||
|
||||
page = (int) Math.floor(totalPages);
|
||||
LoggerUtils.logDebugInfo("Floor page value: " + page);
|
||||
|
||||
} else {
|
||||
|
||||
page = (int) Math.ceil(totalPages);
|
||||
LoggerUtils.logDebugInfo("Ceiling page value: " + page);
|
||||
|
||||
}
|
||||
|
||||
super.open(super.playerMenuUtility.getPlayerShopSearchResult());
|
||||
|
||||
} else {
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG)) {
|
||||
|
||||
event.getWhoClicked()
|
||||
.sendMessage(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().PLUGIN_PREFIX
|
||||
+ FindItemAddOnOG.getConfigProvider().SHOP_NAV_LAST_PAGE_ALERT_MSG));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty method in case we need to handle static GUI icons in future
|
||||
*/
|
||||
@Override
|
||||
public void setMenuItems() {}
|
||||
public void setMenuItems() {
|
||||
|
||||
// Just overriding
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the slots in the search result GUI
|
||||
*
|
||||
* @param foundShops List of found shops
|
||||
*/
|
||||
@Override
|
||||
public void setMenuItems(List<FoundShopItemModel> foundShops) {
|
||||
|
||||
addMenuBottomBar();
|
||||
if(foundShops != null && !foundShops.isEmpty()) {
|
||||
int guiSlotCounter = 0;
|
||||
while(guiSlotCounter < super.maxItemsPerPage) {
|
||||
index = super.maxItemsPerPage * page + guiSlotCounter;
|
||||
if (!(foundShops != null && !foundShops.isEmpty())) {
|
||||
|
||||
if(index >= foundShops.size()) break;
|
||||
return;
|
||||
|
||||
if(foundShops.get(index) != null) {
|
||||
// Place Search Results here
|
||||
FoundShopItemModel foundShop_i = foundShops.get(index);
|
||||
NamespacedKey key = new NamespacedKey(FindItemAddOn.getInstance(), "locationData");
|
||||
ItemStack item = new ItemStack(foundShop_i.getItem().getType());
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
List<String> lore;
|
||||
lore = new ArrayList<>();
|
||||
com.olziedev.playerwarps.api.warp.Warp nearestPlayerWarp = null;
|
||||
String nearestEWarp = null;
|
||||
|
||||
if(foundShop_i.getItem().hasItemMeta()) {
|
||||
meta = foundShop_i.getItem().getItemMeta();
|
||||
if(foundShop_i.getItem().getItemMeta().hasLore()) {
|
||||
for(String s : foundShop_i.getItem().getItemMeta().getLore()) {
|
||||
lore.add(ColorTranslator.translateColorCodes(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
List<String> shopItemLore = FindItemAddOn.getConfigProvider().SHOP_GUI_ITEM_LORE;
|
||||
for(String shopItemLore_i : shopItemLore) {
|
||||
if(shopItemLore_i.contains(ShopLorePlaceholders.NEAREST_WARP.value())) {
|
||||
switch(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE) {
|
||||
case 1:
|
||||
// EssentialWarp: Check nearest warp
|
||||
if(EssentialsXPlugin.isEnabled()) {
|
||||
nearestEWarp = new EssentialWarpsUtil().findNearestWarp(foundShop_i.getShopLocation());
|
||||
if(nearestEWarp != null && !StringUtils.isEmpty(nearestEWarp)) {
|
||||
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), nearestEWarp)));
|
||||
}
|
||||
else {
|
||||
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), NO_WARP_NEAR_SHOP_ERROR_MSG)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// PlayerWarp: Check nearest warp
|
||||
if(PlayerWarpsPlugin.getIsEnabled()) {
|
||||
nearestPlayerWarp = new PlayerWarpsUtil().findNearestWarp(foundShop_i.getShopLocation());
|
||||
if(nearestPlayerWarp != null) {
|
||||
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), nearestPlayerWarp.getWarpName())));
|
||||
}
|
||||
else {
|
||||
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), NO_WARP_NEAR_SHOP_ERROR_MSG)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// WG Region: Check nearest WG Region
|
||||
if(WGPlugin.isEnabled()) {
|
||||
String nearestWGRegion = new WGRegionUtils().findNearestWGRegion((foundShop_i.getShopLocation()));
|
||||
if(nearestWGRegion != null && !StringUtils.isEmpty(nearestWGRegion)) {
|
||||
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), nearestWGRegion)));
|
||||
}
|
||||
else {
|
||||
lore.add(ColorTranslator.translateColorCodes(shopItemLore_i.replace(ShopLorePlaceholders.NEAREST_WARP.value(), NO_WG_REGION_NEAR_SHOP_ERROR_MSG)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LoggerUtils.logDebugInfo("Invalid value in 'nearest-warp-mode' in config.yml!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
lore.add(ColorTranslator.translateColorCodes(replaceLorePlaceholders(shopItemLore_i, foundShop_i)));
|
||||
}
|
||||
}
|
||||
|
||||
if(FindItemAddOn.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP) {
|
||||
if(playerMenuUtility.getOwner().hasPermission(PlayerPerms.FINDITEM_SHOPTP.value())) {
|
||||
lore.add(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().CLICK_TO_TELEPORT_MSG));
|
||||
}
|
||||
}
|
||||
assert meta != null;
|
||||
meta.setLore(lore);
|
||||
|
||||
// storing location data in item persistent storage
|
||||
String locData = StringUtils.EMPTY;
|
||||
// store the coordinates
|
||||
if(FindItemAddOn.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP) {
|
||||
locData = Objects.requireNonNull(foundShop_i.getShopLocation().getWorld()).getName() + ","
|
||||
+ foundShop_i.getShopLocation().getBlockX() + ","
|
||||
+ foundShop_i.getShopLocation().getBlockY() + ","
|
||||
+ foundShop_i.getShopLocation().getBlockZ();
|
||||
}
|
||||
else if(FindItemAddOn.getConfigProvider().TP_PLAYER_TO_NEAREST_WARP) {
|
||||
// if Nearest Warp is set to EssentialsX Warps, store the warp name
|
||||
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 1) {
|
||||
if(nearestEWarp != null) {
|
||||
locData = nearestEWarp;
|
||||
}
|
||||
}
|
||||
// if Nearest Warp is set to PlayerWarps, store the warp name
|
||||
else if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 2) {
|
||||
if(nearestPlayerWarp != null) {
|
||||
locData = nearestPlayerWarp.getWarpName();
|
||||
}
|
||||
}
|
||||
}
|
||||
meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, locData);
|
||||
|
||||
// handling custom model data
|
||||
if(Objects.requireNonNull(foundShop_i.getItem().getItemMeta()).hasCustomModelData()) {
|
||||
meta.setCustomModelData(foundShop_i.getItem().getItemMeta().getCustomModelData());
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
inventory.addItem(item);
|
||||
}
|
||||
guiSlotCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
int guiSlotCounter = 0;
|
||||
while (guiSlotCounter < super.maxItemsPerPage) {
|
||||
|
||||
index = super.maxItemsPerPage * page + guiSlotCounter;
|
||||
|
||||
if (index >= foundShops.size()) {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (foundShops.get(index) != null) {
|
||||
|
||||
final FoundShopItemModel foundShop_i = foundShops.get(index);
|
||||
final NamespacedKey key = new NamespacedKey(FindItemAddOnOG.getInstance(), "locationData");
|
||||
final ItemStack item = new ItemStack(foundShop_i.getItem().getType());
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) {
|
||||
|
||||
guiSlotCounter++;
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
final List<Component> lore = new ArrayList<>();
|
||||
if (foundShop_i.getItem().hasItemMeta()) {
|
||||
|
||||
final ItemMeta foundMeta = foundShop_i.getItem().getItemMeta();
|
||||
if (foundMeta != null) {
|
||||
|
||||
meta = foundMeta;
|
||||
final List<Component> existingLore = foundMeta.lore();
|
||||
if (existingLore != null && !existingLore.isEmpty()) {
|
||||
|
||||
lore.addAll(existingLore);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
final List<String> shopItemLore = FindItemAddOnOG.getConfigProvider().SHOP_GUI_ITEM_LORE;
|
||||
String nearestEWarp = null;
|
||||
|
||||
for (String shopItemLore_i : shopItemLore) {
|
||||
|
||||
if (shopItemLore_i.contains(ShopLorePlaceholders.NEAREST_WARP.value())) {
|
||||
|
||||
switch (FindItemAddOnOG.getConfigProvider().NEAREST_WARP_MODE) {
|
||||
|
||||
case 1 -> {
|
||||
|
||||
String replacement = NO_WARP_NEAR_SHOP_ERROR_MSG;
|
||||
if (EssentialsXPlugin.isEnabled()) {
|
||||
|
||||
nearestEWarp = new EssentialWarpsUtil()
|
||||
.findNearestWarp(foundShop_i.getShopLocation());
|
||||
if (nearestEWarp != null && !StringUtils.isEmpty(nearestEWarp)) {
|
||||
|
||||
replacement = nearestEWarp;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lore.add(UtilitiesOG.trueogColorize(shopItemLore_i
|
||||
.replace(ShopLorePlaceholders.NEAREST_WARP.value(), replacement)));
|
||||
|
||||
}
|
||||
case 2 -> {
|
||||
|
||||
String replacement = NO_WG_REGION_NEAR_SHOP_ERROR_MSG;
|
||||
if (WGPlugin.isEnabled()) {
|
||||
|
||||
final String nearestWGRegion = new WGRegionUtils()
|
||||
.findNearestWGRegion((foundShop_i.getShopLocation()));
|
||||
if (nearestWGRegion != null && !StringUtils.isEmpty(nearestWGRegion)) {
|
||||
|
||||
replacement = nearestWGRegion;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lore.add(UtilitiesOG.trueogColorize(shopItemLore_i
|
||||
.replace(ShopLorePlaceholders.NEAREST_WARP.value(), replacement)));
|
||||
|
||||
}
|
||||
default -> LoggerUtils.logDebugInfo("Invalid value in 'nearest-warp-mode' in config.yml!");
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
lore.add(UtilitiesOG.trueogColorize(replaceLorePlaceholders(shopItemLore_i, foundShop_i)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (FindItemAddOnOG.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP
|
||||
&& playerMenuUtility.getOwner().hasPermission(PlayerPerms.FINDITEM_SHOPTP.value()))
|
||||
{
|
||||
|
||||
lore.add(UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().CLICK_TO_TELEPORT_MSG));
|
||||
|
||||
}
|
||||
|
||||
meta.lore(lore);
|
||||
|
||||
String locData = StringUtils.EMPTY;
|
||||
if (FindItemAddOnOG.getConfigProvider().TP_PLAYER_DIRECTLY_TO_SHOP) {
|
||||
|
||||
locData = Objects.requireNonNull(foundShop_i.getShopLocation().getWorld()).getName() + ","
|
||||
+ foundShop_i.getShopLocation().getBlockX() + ","
|
||||
+ foundShop_i.getShopLocation().getBlockY() + ","
|
||||
+ foundShop_i.getShopLocation().getBlockZ();
|
||||
|
||||
} else if (FindItemAddOnOG.getConfigProvider().TP_PLAYER_TO_NEAREST_WARP) {
|
||||
|
||||
final boolean condition = FindItemAddOnOG.getConfigProvider().NEAREST_WARP_MODE == 1
|
||||
&& nearestEWarp != null;
|
||||
if (condition) {
|
||||
|
||||
locData = nearestEWarp;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, locData);
|
||||
|
||||
if (Objects.requireNonNull(foundShop_i.getItem().getItemMeta()).hasCustomModelData()) {
|
||||
|
||||
meta.setCustomModelData(foundShop_i.getItem().getItemMeta().getCustomModelData());
|
||||
|
||||
}
|
||||
|
||||
item.setItemMeta(meta);
|
||||
inventory.addItem(item);
|
||||
|
||||
}
|
||||
|
||||
guiSlotCounter++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all the placeholders in the Shop item lore in GUI
|
||||
*
|
||||
* @param text Line of lore
|
||||
* @param shop Shop instance
|
||||
* @return Line of lore replaced with placeholder values
|
||||
*/
|
||||
private String replaceLorePlaceholders(String text, FoundShopItemModel shop) {
|
||||
|
||||
if(text.contains(ShopLorePlaceholders.ITEM_PRICE.value())) {
|
||||
if (text.contains(ShopLorePlaceholders.ITEM_PRICE.value())) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.ITEM_PRICE.value(), String.valueOf(shop.getShopPrice()));
|
||||
|
||||
}
|
||||
if(text.contains(ShopLorePlaceholders.SHOP_STOCK.value())) {
|
||||
if(shop.getRemainingStockOrSpace() == -1) {
|
||||
|
||||
if (text.contains(ShopLorePlaceholders.SHOP_STOCK.value())) {
|
||||
|
||||
if (shop.getRemainingStockOrSpace() == Integer.MAX_VALUE) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_STOCK.value(), "Unlimited");
|
||||
|
||||
} else {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_STOCK.value(),
|
||||
String.valueOf(shop.getRemainingStockOrSpace()));
|
||||
|
||||
}
|
||||
else {
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_STOCK.value(), String.valueOf(shop.getRemainingStockOrSpace()));
|
||||
}
|
||||
|
||||
}
|
||||
if(text.contains(ShopLorePlaceholders.SHOP_OWNER.value())) {
|
||||
|
||||
if (text.contains(ShopLorePlaceholders.SHOP_OWNER.value())) {
|
||||
|
||||
OfflinePlayer shopOwner = Bukkit.getOfflinePlayer(shop.getShopOwner());
|
||||
if(shopOwner.getName() != null) {
|
||||
if (shopOwner.getName() != null) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_OWNER.value(), shopOwner.getName());
|
||||
}
|
||||
else {
|
||||
// set a generic name for shops with no owner name
|
||||
|
||||
} else {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_OWNER.value(), "Admin");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(text.contains(ShopLorePlaceholders.SHOP_LOCATION.value())) {
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_LOCATION.value(),
|
||||
shop.getShopLocation().getBlockX() + ", "
|
||||
+ shop.getShopLocation().getBlockY() + ", "
|
||||
+ shop.getShopLocation().getBlockZ());
|
||||
|
||||
if (text.contains(ShopLorePlaceholders.SHOP_LOCATION.value())) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_LOCATION.value(), shop.getShopLocation().getBlockX() + ", "
|
||||
+ shop.getShopLocation().getBlockY() + ", " + shop.getShopLocation().getBlockZ());
|
||||
|
||||
}
|
||||
if(text.contains(ShopLorePlaceholders.SHOP_WORLD.value())) {
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_WORLD.value(), Objects.requireNonNull(shop.getShopLocation().getWorld()).getName());
|
||||
|
||||
if (text.contains(ShopLorePlaceholders.SHOP_WORLD.value())) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_WORLD.value(),
|
||||
Objects.requireNonNull(shop.getShopLocation().getWorld()).getName());
|
||||
|
||||
}
|
||||
// Added in v2.0
|
||||
if(text.contains(ShopLorePlaceholders.SHOP_VISITS.value())) {
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_VISITS.value(), String.valueOf(ShopSearchActivityStorageUtil.getPlayerVisitCount(shop.getShopLocation())));
|
||||
|
||||
if (text.contains(ShopLorePlaceholders.SHOP_VISITS.value())) {
|
||||
|
||||
text = text.replace(ShopLorePlaceholders.SHOP_VISITS.value(),
|
||||
String.valueOf(ShopSearchActivityStorageUtil.getPlayerVisitCount(shop.getShopLocation())));
|
||||
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String replaceDelayPlaceholder(String tpDelayMsg, long delay) {
|
||||
|
||||
return tpDelayMsg.replace("{DELAY}", String.valueOf(delay));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,141 +1,281 @@
|
||||
package io.myzticbean.finditemaddon.Handlers.GUIHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public abstract class PaginatedMenu extends Menu {
|
||||
|
||||
protected int page = 0;
|
||||
protected int maxItemsPerPage = 45;
|
||||
protected final int maxItemsPerPage = 45;
|
||||
protected int index = 0;
|
||||
|
||||
protected ItemStack backButton;
|
||||
protected ItemStack firstPageButton;
|
||||
protected ItemStack nextButton;
|
||||
protected ItemStack lastPageButton;
|
||||
protected ItemStack closeInvButton;
|
||||
|
||||
private final String BACK_BUTTON_SKIN_ID = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjZkYWI3MjcxZjRmZjA0ZDU0NDAyMTkwNjdhMTA5YjVjMGMxZDFlMDFlYzYwMmMwMDIwNDc2ZjdlYjYxMjE4MCJ9fX0=";
|
||||
private final String FIRST_PAGE_BUTTON_SKIN_ID = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTI5M2E2MDcwNTAzMTcyMDcxZjM1ZjU4YzgyMjA0ZTgxOGNkMDY1MTg2OTAxY2ExOWY3ZGFkYmRhYzE2NWU0NCJ9fX0=";
|
||||
private final String NEXT_BUTTON_SKIN_ID = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGFhMTg3ZmVkZTg4ZGUwMDJjYmQ5MzA1NzVlYjdiYTQ4ZDNiMWEwNmQ5NjFiZGM1MzU4MDA3NTBhZjc2NDkyNiJ9fX0=";
|
||||
private final String LAST_PAGE_BUTTON_SKIN_ID = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWRhNDRjNzY3Y2NhMjU4NjFkM2E1MmZlMTdjMjY0MjhlNjYwZWUyM2RjMGQ3OTNiZjdiZDg2ZWEyMDJmNzAzZCJ9fX0=";
|
||||
|
||||
protected PaginatedMenu(PlayerMenuUtility playerMenuUtility) {
|
||||
|
||||
public PaginatedMenu(PlayerMenuUtility playerMenuUtility) {
|
||||
super(playerMenuUtility);
|
||||
initMaterialsForBottomBar();
|
||||
|
||||
}
|
||||
|
||||
public PaginatedMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
|
||||
protected PaginatedMenu(PlayerMenuUtility playerMenuUtility, List<FoundShopItemModel> searchResult) {
|
||||
|
||||
super(playerMenuUtility);
|
||||
initMaterialsForBottomBar();
|
||||
super.playerMenuUtility.setPlayerShopSearchResult(searchResult);
|
||||
|
||||
}
|
||||
|
||||
private void initMaterialsForBottomBar() {
|
||||
|
||||
createGUIBackButton();
|
||||
createGUIFirstPageButton();
|
||||
createGUINextButton();
|
||||
createGUILastPageButton();
|
||||
createGUICloseInvButton();
|
||||
|
||||
}
|
||||
|
||||
public void addMenuBottomBar() {
|
||||
|
||||
inventory.setItem(45, backButton);
|
||||
inventory.setItem(46, firstPageButton);
|
||||
inventory.setItem(53, nextButton);
|
||||
inventory.setItem(52, lastPageButton);
|
||||
inventory.setItem(49, closeInvButton);
|
||||
|
||||
inventory.setItem(46, super.GUI_FILLER_ITEM);
|
||||
inventory.setItem(47, super.GUI_FILLER_ITEM);
|
||||
inventory.setItem(48, super.GUI_FILLER_ITEM);
|
||||
inventory.setItem(50, super.GUI_FILLER_ITEM);
|
||||
inventory.setItem(51, super.GUI_FILLER_ITEM);
|
||||
inventory.setItem(52, super.GUI_FILLER_ITEM);
|
||||
|
||||
}
|
||||
|
||||
private void createGUIBackButton() {
|
||||
Material backButtonMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_MATERIAL);
|
||||
if(backButtonMaterial == null) {
|
||||
|
||||
Material backButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_MATERIAL);
|
||||
if (backButtonMaterial == null) {
|
||||
|
||||
backButton = createPlayerHead(BACK_BUTTON_SKIN_ID);
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
backButton = new ItemStack(backButtonMaterial);
|
||||
|
||||
}
|
||||
ItemMeta backButton_meta = backButton.getItemMeta();
|
||||
assert backButton_meta != null;
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_TEXT)) {
|
||||
backButton_meta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_TEXT));
|
||||
|
||||
ItemMeta backButtonMeta = backButton.getItemMeta();
|
||||
assert backButtonMeta != null;
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_TEXT)) {
|
||||
|
||||
backButtonMeta.displayName(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_TEXT));
|
||||
|
||||
}
|
||||
|
||||
int backButtonCMD;
|
||||
try {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_CMD)) {
|
||||
backButtonCMD = Integer.parseInt(FindItemAddOn.getConfigProvider().SHOP_GUI_BACK_BUTTON_CMD);
|
||||
backButton_meta.setCustomModelData(backButtonCMD);
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_CMD)) {
|
||||
|
||||
backButtonCMD = Integer.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_BACK_BUTTON_CMD);
|
||||
backButtonMeta.setCustomModelData(backButtonCMD);
|
||||
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
|
||||
} catch (NumberFormatException eror) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Back Button in config.yml");
|
||||
|
||||
}
|
||||
backButton.setItemMeta(backButton_meta);
|
||||
|
||||
backButton.setItemMeta(backButtonMeta);
|
||||
|
||||
}
|
||||
|
||||
private void createGUINextButton() {
|
||||
Material nextButtonMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_MATERIAL);
|
||||
if(nextButtonMaterial == null) {
|
||||
|
||||
Material nextButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_MATERIAL);
|
||||
if (nextButtonMaterial == null) {
|
||||
|
||||
nextButton = createPlayerHead(NEXT_BUTTON_SKIN_ID);
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
nextButton = new ItemStack(nextButtonMaterial);
|
||||
|
||||
}
|
||||
ItemMeta nextButton_meta = nextButton.getItemMeta();
|
||||
assert nextButton_meta != null;
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_TEXT)) {
|
||||
nextButton_meta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_TEXT));
|
||||
|
||||
ItemMeta nextButtonMeta = nextButton.getItemMeta();
|
||||
assert nextButtonMeta != null;
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_TEXT)) {
|
||||
|
||||
nextButtonMeta.displayName(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_TEXT));
|
||||
|
||||
}
|
||||
|
||||
int nextButtonCMD;
|
||||
try {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_CMD)) {
|
||||
nextButtonCMD = Integer.parseInt(FindItemAddOn.getConfigProvider().SHOP_GUI_NEXT_BUTTON_CMD);
|
||||
nextButton_meta.setCustomModelData(nextButtonCMD);
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_CMD)) {
|
||||
|
||||
nextButtonCMD = Integer.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_NEXT_BUTTON_CMD);
|
||||
nextButtonMeta.setCustomModelData(nextButtonCMD);
|
||||
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
|
||||
} catch (NumberFormatException error) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Next Button in config.yml");
|
||||
|
||||
}
|
||||
nextButton.setItemMeta(nextButton_meta);
|
||||
|
||||
nextButton.setItemMeta(nextButtonMeta);
|
||||
|
||||
}
|
||||
|
||||
private void createGUIFirstPageButton() {
|
||||
|
||||
Material firstPageButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_MATERIAL);
|
||||
if (firstPageButtonMaterial == null)
|
||||
firstPageButton = createPlayerHead(FIRST_PAGE_BUTTON_SKIN_ID);
|
||||
else
|
||||
firstPageButton = new ItemStack(firstPageButtonMaterial);
|
||||
ItemMeta firstPageButtonMeta = firstPageButton.getItemMeta();
|
||||
if (firstPageButtonMeta != null
|
||||
&& !StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_TEXT))
|
||||
firstPageButtonMeta.displayName(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_TEXT));
|
||||
int firstPageButtonCMD;
|
||||
try {
|
||||
|
||||
if (firstPageButtonMeta != null
|
||||
&& !StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_CMD))
|
||||
{
|
||||
|
||||
firstPageButtonCMD = Integer
|
||||
.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_FIRST_PAGE_BUTTON_CMD);
|
||||
firstPageButtonMeta.setCustomModelData(firstPageButtonCMD);
|
||||
|
||||
}
|
||||
|
||||
} catch (NumberFormatException error) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Goto First Page Button in config.yml");
|
||||
|
||||
}
|
||||
|
||||
firstPageButton.setItemMeta(firstPageButtonMeta);
|
||||
|
||||
}
|
||||
|
||||
private void createGUILastPageButton() {
|
||||
|
||||
Material lastPageButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_MATERIAL);
|
||||
if (lastPageButtonMaterial == null)
|
||||
lastPageButton = createPlayerHead(LAST_PAGE_BUTTON_SKIN_ID);
|
||||
else
|
||||
lastPageButton = new ItemStack(lastPageButtonMaterial);
|
||||
ItemMeta lastPageButtonMeta = lastPageButton.getItemMeta();
|
||||
if (lastPageButtonMeta != null
|
||||
&& !StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_TEXT))
|
||||
lastPageButtonMeta.displayName(UtilitiesOG
|
||||
.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_TEXT));
|
||||
int lastPageButtonCMD;
|
||||
try {
|
||||
|
||||
if (lastPageButtonMeta != null
|
||||
&& !StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_CMD))
|
||||
{
|
||||
|
||||
lastPageButtonCMD = Integer
|
||||
.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_GOTO_LAST_PAGE_BUTTON_CMD);
|
||||
lastPageButtonMeta.setCustomModelData(lastPageButtonCMD);
|
||||
|
||||
}
|
||||
|
||||
} catch (NumberFormatException error) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Goto Last Page Button in config.yml");
|
||||
|
||||
}
|
||||
|
||||
lastPageButton.setItemMeta(lastPageButtonMeta);
|
||||
|
||||
}
|
||||
|
||||
private void createGUICloseInvButton() {
|
||||
Material closeInvButtonMaterial = Material.getMaterial(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_MATERIAL);
|
||||
if(closeInvButtonMaterial == null) {
|
||||
|
||||
Material closeInvButtonMaterial = Material
|
||||
.getMaterial(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_MATERIAL);
|
||||
if (closeInvButtonMaterial == null) {
|
||||
|
||||
closeInvButtonMaterial = Material.BARRIER;
|
||||
|
||||
}
|
||||
|
||||
closeInvButton = new ItemStack(closeInvButtonMaterial);
|
||||
ItemMeta closeInv_meta = closeInvButton.getItemMeta();
|
||||
assert closeInv_meta != null;
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_TEXT)) {
|
||||
closeInv_meta.setDisplayName(ColorTranslator.translateColorCodes(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_TEXT));
|
||||
ItemMeta closeInvMeta = closeInvButton.getItemMeta();
|
||||
assert closeInvMeta != null;
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_TEXT)) {
|
||||
|
||||
closeInvMeta.displayName(
|
||||
UtilitiesOG.trueogColorize(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_TEXT));
|
||||
|
||||
}
|
||||
|
||||
int closeInvButtonCMD;
|
||||
try {
|
||||
if(!StringUtils.isEmpty(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_CMD)) {
|
||||
closeInvButtonCMD = Integer.parseInt(FindItemAddOn.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_CMD);
|
||||
closeInv_meta.setCustomModelData(closeInvButtonCMD);
|
||||
|
||||
if (!StringUtils.isEmpty(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_CMD)) {
|
||||
|
||||
closeInvButtonCMD = Integer.parseInt(FindItemAddOnOG.getConfigProvider().SHOP_GUI_CLOSE_BUTTON_CMD);
|
||||
closeInvMeta.setCustomModelData(closeInvButtonCMD);
|
||||
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
|
||||
} catch (NumberFormatException error) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Invalid Custom Model Data for Close Button in config.yml");
|
||||
|
||||
}
|
||||
closeInvButton.setItemMeta(closeInv_meta);
|
||||
|
||||
closeInvButton.setItemMeta(closeInvMeta);
|
||||
|
||||
}
|
||||
|
||||
private ItemStack createPlayerHead(String value) {
|
||||
|
||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||
UUID hashAsId = new UUID(value.hashCode(), value.hashCode());
|
||||
return Bukkit.getUnsafe().modifyItemStack(skull,
|
||||
"{SkullOwner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + value + "\"}]}}}"
|
||||
);
|
||||
"{SkullOwner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + value + "\"}]}}}");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,27 +6,39 @@ import org.bukkit.entity.Player;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerMenuUtility {
|
||||
|
||||
private Player owner;
|
||||
|
||||
private List<FoundShopItemModel> playerShopSearchResult;
|
||||
|
||||
public List<FoundShopItemModel> getPlayerShopSearchResult() {
|
||||
|
||||
return playerShopSearchResult;
|
||||
|
||||
}
|
||||
|
||||
public void setPlayerShopSearchResult(List<FoundShopItemModel> playerShopSearchResult) {
|
||||
|
||||
this.playerShopSearchResult = playerShopSearchResult;
|
||||
|
||||
}
|
||||
|
||||
public PlayerMenuUtility(Player owner) {
|
||||
|
||||
this.owner = owner;
|
||||
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
|
||||
return owner;
|
||||
|
||||
}
|
||||
|
||||
public void setOwner(Player owner) {
|
||||
|
||||
this.owner = owner;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,19 +11,26 @@ public class MenuListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onMenuClick(InventoryClickEvent e) {
|
||||
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
|
||||
InventoryHolder holder = e.getInventory().getHolder();
|
||||
|
||||
if(holder instanceof Menu) {
|
||||
if (holder instanceof Menu) {
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
if(e.getCurrentItem() == null) {
|
||||
if (e.getCurrentItem() == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
Menu menu = (Menu) holder;
|
||||
menu.handleMenu(e);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Listeners;
|
||||
|
||||
import com.olziedev.playerwarps.api.events.PlayerWarpCreateEvent;
|
||||
import io.myzticbean.finditemaddon.Dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class PWPlayerWarpCreateEventListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerWarpCreate(PlayerWarpCreateEvent event) {
|
||||
// Issue #24 Fix: Converted updateWarpsOnEventCall() call to async
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(),
|
||||
() -> PlayerWarpsPlugin.updateWarpsOnEventCall(event.getPlayerWarp(), false));
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Listeners;
|
||||
|
||||
import com.olziedev.playerwarps.api.events.PlayerWarpRemoveEvent;
|
||||
import io.myzticbean.finditemaddon.Dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class PWPlayerWarpRemoveEventListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerWarpRemove(PlayerWarpRemoveEvent event) {
|
||||
// Issue #24 Fix: Converted updateWarpsOnEventCall() call to async
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(),
|
||||
() -> PlayerWarpsPlugin.updateWarpsOnEventCall(event.getPlayerWarp(), true));
|
||||
}
|
||||
}
|
||||
+15
-6
@@ -1,6 +1,6 @@
|
||||
package io.myzticbean.finditemaddon.Listeners;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
@@ -9,20 +9,29 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerCommandSendEventListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommandTab(PlayerCommandSendEvent event) {
|
||||
if(!event.getPlayer().isOp()) {
|
||||
|
||||
if (!event.getPlayer().isOp()) {
|
||||
|
||||
List<String> blockedCommands = new ArrayList<>();
|
||||
blockedCommands.add("finditem:finditem");
|
||||
assert FindItemAddOn.getConfigProvider().FIND_ITEM_COMMAND_ALIAS != null;
|
||||
for(String cmd : FindItemAddOn.getConfigProvider().FIND_ITEM_COMMAND_ALIAS) {
|
||||
blockedCommands.add("finditem:" + cmd);
|
||||
blockedCommands.add("find:find");
|
||||
assert FindItemAddOnOG.getConfigProvider().FIND_ITEM_COMMAND_ALIAS != null;
|
||||
for (String cmd : FindItemAddOnOG.getConfigProvider().FIND_ITEM_COMMAND_ALIAS) {
|
||||
|
||||
blockedCommands.add("find:" + cmd);
|
||||
|
||||
}
|
||||
|
||||
blockedCommands.add("finditemadmin:finditemadmin");
|
||||
blockedCommands.add("finditemadmin:fiadmin");
|
||||
blockedCommands.add("finditemadmin");
|
||||
blockedCommands.add("fiadmin");
|
||||
event.getCommands().removeAll(blockedCommands);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Listeners;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Utils.UpdateChecker;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerJoinEventListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
new UpdateChecker(FindItemAddOn.getPluginID()).notifyPlayerAboutUpdateOnJoin(event);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,35 @@
|
||||
package io.myzticbean.finditemaddon.Listeners;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
|
||||
public class PluginEnableEventListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPluginEnable(PluginEnableEvent event) {
|
||||
if(!FindItemAddOn.isQSReremakeInstalled() && !FindItemAddOn.isQSHikariInstalled()) {
|
||||
|
||||
if (!FindItemAddOnOG.isQSReremakeInstalled() && !FindItemAddOnOG.isQSHikariInstalled()) {
|
||||
|
||||
// if(!event.getPlugin().getName().equalsIgnoreCase("QuickShop")
|
||||
// && !event.getPlugin().getName().equalsIgnoreCase("QuickShop-Hikari")) {
|
||||
// // do nothing
|
||||
// }
|
||||
if(event.getPlugin().getName().equalsIgnoreCase("QuickShop") && !FindItemAddOn.isQSHikariInstalled()) {
|
||||
FindItemAddOn.setQSReremakeInstalled(true);
|
||||
} else if (event.getPlugin().getName().equalsIgnoreCase("QuickShop-Hikari") && !FindItemAddOn.isQSReremakeInstalled()) {
|
||||
FindItemAddOn.setQSHikariInstalled(true);
|
||||
if (event.getPlugin().getName().equalsIgnoreCase("QuickShop") && !FindItemAddOnOG.isQSHikariInstalled()) {
|
||||
|
||||
FindItemAddOnOG.setQSReremakeInstalled(true);
|
||||
|
||||
} else if (event.getPlugin().getName().equalsIgnoreCase("QuickShop-Hikari")
|
||||
&& !FindItemAddOnOG.isQSReremakeInstalled())
|
||||
{
|
||||
|
||||
FindItemAddOnOG.setQSHikariInstalled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,19 @@
|
||||
package io.myzticbean.finditemaddon.Models;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
public class CachedShop {
|
||||
|
||||
private long shopId;
|
||||
private Location shopLocation;
|
||||
private int remainingStock;
|
||||
private int remainingSpace;
|
||||
private Date lastFetched;
|
||||
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package io.myzticbean.finditemaddon.Models;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class EssentialWarpModel {
|
||||
|
||||
public String warpName;
|
||||
public Location warpLoc;
|
||||
|
||||
}
|
||||
@@ -13,9 +13,11 @@ import java.util.UUID;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class FoundShopItemModel {
|
||||
|
||||
private final double shopPrice;
|
||||
private final int remainingStockOrSpace;
|
||||
private final UUID shopOwner;
|
||||
private final Location shopLocation;
|
||||
private final ItemStack item;
|
||||
|
||||
}
|
||||
@@ -14,18 +14,27 @@ public class PlayerShopVisitModel {
|
||||
private String visitDateTime;
|
||||
|
||||
public void setPlayerUUID(UUID uuid) {
|
||||
|
||||
this.playerUUID = uuid.toString();
|
||||
|
||||
}
|
||||
|
||||
public UUID getPlayerUUID() {
|
||||
|
||||
return UUID.fromString(this.playerUUID);
|
||||
|
||||
}
|
||||
|
||||
public void setVisitDateTime() {
|
||||
|
||||
this.visitDateTime = Instant.now().toString();
|
||||
|
||||
}
|
||||
|
||||
public Instant getVisitDateTime() {
|
||||
|
||||
return Instant.parse(visitDateTime);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,19 +23,20 @@ public class ShopSearchActivityModel {
|
||||
private List<PlayerShopVisitModel> playerVisitList;
|
||||
private boolean isHiddenFromSearch;
|
||||
|
||||
public boolean compareWith(String targetWorldName, double targetX, double targetY, double targetZ, String targetShopOwnerUUID) {
|
||||
return this.getWorldName().equalsIgnoreCase(targetWorldName)
|
||||
&& this.getX() == targetX
|
||||
&& this.getY() == targetY
|
||||
&& this.getZ() == targetZ
|
||||
&& this.getShopOwnerUUID().equalsIgnoreCase(targetShopOwnerUUID);
|
||||
public boolean compareWith(String targetWorldName, double targetX, double targetY, double targetZ,
|
||||
String targetShopOwnerUUID)
|
||||
{
|
||||
|
||||
return this.getWorldName().equalsIgnoreCase(targetWorldName) && this.getX() == targetX && this.getY() == targetY
|
||||
&& this.getZ() == targetZ && this.getShopOwnerUUID().equalsIgnoreCase(targetShopOwnerUUID);
|
||||
|
||||
}
|
||||
|
||||
public boolean compareWith(String targetWorldName, double targetX, double targetY, double targetZ) {
|
||||
return this.getWorldName().equalsIgnoreCase(targetWorldName)
|
||||
&& this.getX() == targetX
|
||||
&& this.getY() == targetY
|
||||
|
||||
return this.getWorldName().equalsIgnoreCase(targetWorldName) && this.getX() == targetX && this.getY() == targetY
|
||||
&& this.getZ() == targetZ;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.myzticbean.finditemaddon.QuickShopHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
@@ -8,21 +9,29 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Interface for QS API.
|
||||
* Implement it depending on which API is being used (Reremake/Hikari).
|
||||
* Interface for QS API. Implement it depending on which API is being used
|
||||
* (Reremake/Hikari).
|
||||
*
|
||||
* @param <QSType>
|
||||
* @param <Shop>
|
||||
* @author ronsane
|
||||
* @author myzticbean
|
||||
*/
|
||||
public interface QSApi<QSType, Shop> {
|
||||
|
||||
String QS_TOTAL_SHOPS_ON_SERVER = "Total shops on server: ";
|
||||
String QS_REMAINING_STOCK_OR_SPACE = "Remaining Stock/Space: ";
|
||||
|
||||
/**
|
||||
* Search based on Item Type from all server shops
|
||||
*
|
||||
* @param item
|
||||
* @param toBuy
|
||||
* @param searchingPlayer
|
||||
@@ -32,15 +41,18 @@ public interface QSApi<QSType, Shop> {
|
||||
|
||||
/**
|
||||
* Search based on display name of item from all server shops
|
||||
*
|
||||
* @param displayName
|
||||
* @param toBuy
|
||||
* @param searchingPlayer
|
||||
* @return
|
||||
*/
|
||||
List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy, Player searchingPlayer);
|
||||
List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy,
|
||||
Player searchingPlayer);
|
||||
|
||||
/**
|
||||
* Fetch all items from all server shops
|
||||
*
|
||||
* @param toBuy
|
||||
* @param searchingPlayer
|
||||
* @return
|
||||
@@ -59,23 +71,69 @@ public interface QSApi<QSType, Shop> {
|
||||
|
||||
void registerSubCommand();
|
||||
|
||||
static List<FoundShopItemModel> sortShops(int sortingMethod, List<FoundShopItemModel> shopsFoundList) {
|
||||
static List<FoundShopItemModel> sortShops(int sortingMethod, List<FoundShopItemModel> shopsFoundList,
|
||||
boolean toBuy)
|
||||
{
|
||||
|
||||
switch (sortingMethod) {
|
||||
|
||||
// Random
|
||||
case 1 -> Collections.shuffle(shopsFoundList);
|
||||
// Based on prices (lower to higher)
|
||||
case 2 -> shopsFoundList.sort(Comparator.comparing(FoundShopItemModel::getShopPrice));
|
||||
// Based on stocks (higher to lower)
|
||||
case 3 -> {
|
||||
|
||||
shopsFoundList.sort(Comparator.comparing(FoundShopItemModel::getRemainingStockOrSpace));
|
||||
Collections.reverse(shopsFoundList);
|
||||
|
||||
}
|
||||
default -> {
|
||||
|
||||
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
|
||||
LoggerUtils.logError("Defaulting to sorting by prices method");
|
||||
shopsFoundList.sort(Comparator.comparing(FoundShopItemModel::getShopPrice));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (FindItemAddOnOG.getConfigProvider().DEBUG_MODE)
|
||||
shopsFoundList.forEach(foundShopItem -> LoggerUtils
|
||||
.logDebugInfo(QS_REMAINING_STOCK_OR_SPACE + foundShopItem.getRemainingStockOrSpace()));
|
||||
return shopsFoundList;
|
||||
|
||||
}
|
||||
|
||||
static int processStockOrSpace(int stockOrSpace) {
|
||||
|
||||
if (stockOrSpace == -1)
|
||||
return Integer.MAX_VALUE;
|
||||
return stockOrSpace;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to check if the time difference between two dates is greater than or
|
||||
* equal to the specified seconds
|
||||
*
|
||||
* @param date1
|
||||
* @param date2
|
||||
* @param seconds
|
||||
* @return
|
||||
*/
|
||||
static boolean isTimeDifferenceGreaterThanSeconds(Date date1, Date date2, int seconds) {
|
||||
|
||||
Instant instant1 = date1.toInstant();
|
||||
Instant instant2 = date2.toInstant();
|
||||
|
||||
Duration duration = Duration.between(instant1, instant2);
|
||||
long secondsDifference = Math.abs(duration.getSeconds());
|
||||
|
||||
LoggerUtils.logDebugInfo("Difference: " + secondsDifference);
|
||||
|
||||
return secondsDifference >= seconds;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+338
-146
@@ -1,12 +1,16 @@
|
||||
package io.myzticbean.finditemaddon.QuickShopHandler;
|
||||
|
||||
import cc.carm.lib.easysql.api.SQLQuery;
|
||||
import com.ghostchu.quickshop.QuickShop;
|
||||
import com.ghostchu.quickshop.api.QuickShopAPI;
|
||||
import com.ghostchu.quickshop.api.command.CommandContainer;
|
||||
import com.ghostchu.quickshop.api.obj.QUser;
|
||||
import com.ghostchu.quickshop.api.shop.Shop;
|
||||
import com.ghostchu.quickshop.api.shop.permission.BuiltInShopPermission;
|
||||
import com.ghostchu.quickshop.database.DataTables;
|
||||
import io.myzticbean.finditemaddon.Commands.QSSubCommands.FindItemCmdHikariImpl;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.CachedShop;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
@@ -18,243 +22,431 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Implementation of QSApi for Reremake
|
||||
* @author ronsane
|
||||
* Implementation of QSApi for Hikari
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class QSHikariAPIHandler implements QSApi<QuickShop, Shop> {
|
||||
|
||||
private QuickShopAPI api;
|
||||
private Plugin qsHikariPluginInstance;
|
||||
private final String QS_HIKARI_PLUGIN_NAME = "QuickShop-Hikari";
|
||||
private final QuickShopAPI api;
|
||||
|
||||
private final ConcurrentMap<Long, CachedShop> shopCache;
|
||||
|
||||
private final int SHOP_CACHE_TIMEOUT_SECONDS = 60;
|
||||
|
||||
public QSHikariAPIHandler() {
|
||||
|
||||
api = QuickShopAPI.getInstance();
|
||||
LoggerUtils.logInfo("Initializing Shop caching");
|
||||
shopCache = new ConcurrentHashMap<>();
|
||||
|
||||
}
|
||||
|
||||
public List<FoundShopItemModel> findItemBasedOnTypeFromAllShops(ItemStack item, boolean toBuy, Player searchingPlayer) {
|
||||
public List<FoundShopItemModel> findItemBasedOnTypeFromAllShops(ItemStack item, boolean toBuy,
|
||||
Player searchingPlayer)
|
||||
{
|
||||
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
if (FindItemAddOnOG.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
|
||||
} else {
|
||||
|
||||
allShops = getAllShops();
|
||||
|
||||
}
|
||||
else {
|
||||
allShops = api.getShopManager().getAllShops();
|
||||
}
|
||||
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
|
||||
allShops.forEach((shop_i) -> {
|
||||
|
||||
LoggerUtils.logDebugInfo(QS_TOTAL_SHOPS_ON_SERVER + allShops.size());
|
||||
for (Shop shopIterator : allShops) {
|
||||
|
||||
// @TODO: Testing
|
||||
testQuickShopHikariExternalCache(shopIterator);
|
||||
LoggerUtils.logWarning("2: Location: " + shopIterator.getLocation() + "Stock: "
|
||||
+ shopIterator.getRemainingStock() + " | Space: " + shopIterator.getRemainingSpace());
|
||||
|
||||
// check for quickshop hikari internal per-shop based search permission
|
||||
if(shop_i.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)) {
|
||||
// check for blacklisted worlds
|
||||
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
|
||||
&& shop_i.getItem().getType().equals(item.getType())
|
||||
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
|
||||
if (shopIterator.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)
|
||||
// check for blacklisted worlds
|
||||
&& (!FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds()
|
||||
.contains(shopIterator.getLocation().getWorld())
|
||||
&& shopIterator.getItem().getType().equals(item.getType())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true) != 0 : getRemainingStockOrSpaceFromShopCache(shopIterator, false) != 0)
|
||||
&& (toBuy ? shopIterator.isSelling() : shopIterator.isBuying()))
|
||||
// check for shop if hidden
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
shopsFoundList.add(new FoundShopItemModel(
|
||||
shop_i.getPrice(),
|
||||
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
|
||||
shop_i.getOwner(),
|
||||
shop_i.getLocation(),
|
||||
shop_i.getItem()
|
||||
));
|
||||
}
|
||||
&& (!HiddenShopStorageUtil.isShopHidden(shopIterator)))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shopIterator)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shopIterator.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shopIterator, false))),
|
||||
shopIterator.getOwner().getUniqueIdOptional().orElse(new UUID(0, 0)),
|
||||
shopIterator.getLocation(), shopIterator.getItem()));
|
||||
|
||||
}
|
||||
});
|
||||
if(!shopsFoundList.isEmpty()) {
|
||||
int sortingMethod = 2;
|
||||
try {
|
||||
sortingMethod = FindItemAddOn.getConfigProvider().SHOP_SORTING_METHOD;
|
||||
}
|
||||
catch(Exception e) {
|
||||
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
|
||||
LoggerUtils.logError("Defaulting to sorting by prices method");
|
||||
}
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList);
|
||||
|
||||
}
|
||||
return shopsFoundList;
|
||||
|
||||
return handleShopSorting(toBuy, shopsFoundList);
|
||||
|
||||
}
|
||||
|
||||
public List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy, Player searchingPlayer) {
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
}
|
||||
else {
|
||||
allShops = api.getShopManager().getAllShops();
|
||||
}
|
||||
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
|
||||
for(Shop shop_i : allShops) {
|
||||
// check for quickshop hikari internal per-shop based search permission
|
||||
if(shop_i.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)) {
|
||||
// check for blacklisted worlds
|
||||
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())) {
|
||||
// match the item based on query
|
||||
if(shop_i.getItem().hasItemMeta()) {
|
||||
if(Objects.requireNonNull(shop_i.getItem().getItemMeta()).hasDisplayName()) {
|
||||
if(shop_i.getItem().getItemMeta().getDisplayName().toLowerCase().contains(displayName.toLowerCase())
|
||||
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
|
||||
// check for shop if hidden
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
shopsFoundList.add(new FoundShopItemModel(
|
||||
shop_i.getPrice(),
|
||||
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
|
||||
shop_i.getOwner(),
|
||||
shop_i.getLocation(),
|
||||
shop_i.getItem()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!shopsFoundList.isEmpty()) {
|
||||
@NotNull
|
||||
static List<FoundShopItemModel> handleShopSorting(boolean toBuy, List<FoundShopItemModel> shopsFoundList) {
|
||||
|
||||
if (!shopsFoundList.isEmpty()) {
|
||||
|
||||
int sortingMethod = 2;
|
||||
try {
|
||||
sortingMethod = FindItemAddOn.getConfigProvider().SHOP_SORTING_METHOD;
|
||||
}
|
||||
catch(Exception e) {
|
||||
|
||||
sortingMethod = FindItemAddOnOG.getConfigProvider().SHOP_SORTING_METHOD;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
|
||||
LoggerUtils.logError("Defaulting to sorting by prices method");
|
||||
|
||||
}
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList);
|
||||
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
|
||||
|
||||
}
|
||||
|
||||
return shopsFoundList;
|
||||
|
||||
}
|
||||
|
||||
public List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy,
|
||||
Player searchingPlayer)
|
||||
{
|
||||
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if (FindItemAddOnOG.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
|
||||
} else {
|
||||
|
||||
allShops = getAllShops();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo(QS_TOTAL_SHOPS_ON_SERVER + allShops.size());
|
||||
for (Shop shopIterator : allShops) {
|
||||
|
||||
// check for quickshop hikari internal per-shop based search permission
|
||||
if (shopIterator.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)
|
||||
// check for blacklisted worlds
|
||||
&& !FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds()
|
||||
.contains(shopIterator.getLocation().getWorld())
|
||||
// match the item based on query
|
||||
&& shopIterator.getItem().hasItemMeta()
|
||||
&& Objects.requireNonNull(shopIterator.getItem().getItemMeta()).hasDisplayName() && (shopIterator
|
||||
.getItem().getItemMeta().getDisplayName().toLowerCase().contains(displayName.toLowerCase())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true) != 0 : getRemainingStockOrSpaceFromShopCache(shopIterator, false) != 0)
|
||||
&& (toBuy ? shopIterator.isSelling() : shopIterator.isBuying()))
|
||||
// check for shop if hidden
|
||||
&& !HiddenShopStorageUtil.isShopHidden(shopIterator))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shopIterator)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shopIterator.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shopIterator, false))),
|
||||
shopIterator.getOwner().getUniqueIdOptional().orElse(new UUID(0, 0)),
|
||||
shopIterator.getLocation(), shopIterator.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return handleShopSorting(toBuy, shopsFoundList);
|
||||
|
||||
}
|
||||
|
||||
public List<FoundShopItemModel> fetchAllItemsFromAllShops(boolean toBuy, Player searchingPlayer) {
|
||||
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
if (FindItemAddOnOG.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
|
||||
} else {
|
||||
|
||||
allShops = getAllShops();
|
||||
|
||||
}
|
||||
else {
|
||||
allShops = api.getShopManager().getAllShops();
|
||||
}
|
||||
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
|
||||
allShops.forEach((shop_i) -> {
|
||||
|
||||
LoggerUtils.logDebugInfo(QS_TOTAL_SHOPS_ON_SERVER + allShops.size());
|
||||
for (Shop shopIterator : allShops) {
|
||||
|
||||
// check for quickshop hikari internal per-shop based search permission
|
||||
if(shop_i.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)) {
|
||||
// check for blacklisted worlds
|
||||
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
|
||||
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
|
||||
if (shopIterator.playerAuthorize(searchingPlayer.getUniqueId(), BuiltInShopPermission.SEARCH)
|
||||
// check for blacklisted worlds
|
||||
&& (!FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds()
|
||||
.contains(shopIterator.getLocation().getWorld())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true) != 0 : getRemainingStockOrSpaceFromShopCache(shopIterator, false) != 0)
|
||||
&& (toBuy ? shopIterator.isSelling() : shopIterator.isBuying()))
|
||||
// check for shop if hidden
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
shopsFoundList.add(new FoundShopItemModel(
|
||||
shop_i.getPrice(),
|
||||
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
|
||||
shop_i.getOwner(),
|
||||
shop_i.getLocation(),
|
||||
shop_i.getItem()
|
||||
));
|
||||
}
|
||||
&& (!HiddenShopStorageUtil.isShopHidden(shopIterator)))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shopIterator)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shopIterator.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shopIterator, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shopIterator, false))),
|
||||
shopIterator.getOwner().getUniqueIdOptional().orElse(new UUID(0, 0)),
|
||||
shopIterator.getLocation(), shopIterator.getItem()));
|
||||
|
||||
}
|
||||
});
|
||||
if(!shopsFoundList.isEmpty()) {
|
||||
int sortingMethod = 1;
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList);
|
||||
|
||||
}
|
||||
|
||||
if (!shopsFoundList.isEmpty()) {
|
||||
|
||||
int sortingMethod = 1;
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
|
||||
|
||||
}
|
||||
|
||||
return shopsFoundList;
|
||||
|
||||
}
|
||||
|
||||
public Material getShopSignMaterial() {
|
||||
|
||||
return com.ghostchu.quickshop.util.Util.getSignMaterial();
|
||||
|
||||
}
|
||||
|
||||
public Shop findShopAtLocation(Block block) {
|
||||
|
||||
Location loc = new Location(block.getWorld(), block.getX(), block.getY(), block.getZ());
|
||||
return api.getShopManager().getShop(loc);
|
||||
|
||||
}
|
||||
|
||||
public boolean isShopOwnerCommandRunner(Player player, Shop shop) {
|
||||
|
||||
return shop.getOwner().toString().equalsIgnoreCase(player.getUniqueId().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Shop> getAllShops() {
|
||||
|
||||
return api.getShopManager().getAllShops();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopSearchActivityModel> syncShopsListForStorage(List<ShopSearchActivityModel> globalShopsList) {
|
||||
|
||||
// copy all shops from shops list in API to a temp globalShopsList
|
||||
// now check shops from temp globalShopsList in current globalShopsList and pull playerVisit data
|
||||
// now check shops from temp globalShopsList in current globalShopsList and pull
|
||||
// playerVisit data
|
||||
List<ShopSearchActivityModel> tempGlobalShopsList = new ArrayList<>();
|
||||
for(Shop shop_i : getAllShops()) {
|
||||
for (Shop shop_i : getAllShops()) {
|
||||
|
||||
Location shopLoc = shop_i.getLocation();
|
||||
tempGlobalShopsList.add(new ShopSearchActivityModel(
|
||||
shopLoc.getWorld().getName(),
|
||||
shopLoc.getX(),
|
||||
shopLoc.getY(),
|
||||
shopLoc.getZ(),
|
||||
shopLoc.getPitch(),
|
||||
shopLoc.getYaw(),
|
||||
shop_i.getOwner().toString(),
|
||||
new ArrayList<>(),
|
||||
false
|
||||
));
|
||||
tempGlobalShopsList.add(new ShopSearchActivityModel(shopLoc.getWorld().getName(), shopLoc.getX(),
|
||||
shopLoc.getY(), shopLoc.getZ(), shopLoc.getPitch(), shopLoc.getYaw(), shop_i.getOwner().toString(),
|
||||
new ArrayList<>(), false));
|
||||
|
||||
}
|
||||
|
||||
for(ShopSearchActivityModel shop_temp : tempGlobalShopsList) {
|
||||
for (ShopSearchActivityModel shop_temp : tempGlobalShopsList) {
|
||||
|
||||
ShopSearchActivityModel tempShopToRemove = null;
|
||||
for(ShopSearchActivityModel shop_global : globalShopsList) {
|
||||
if(shop_temp.getWorldName().equalsIgnoreCase(shop_global.getWorldName())
|
||||
&& shop_temp.getX() == shop_global.getX()
|
||||
&& shop_temp.getY() == shop_global.getY()
|
||||
for (ShopSearchActivityModel shop_global : globalShopsList) {
|
||||
|
||||
if (shop_temp.getWorldName().equalsIgnoreCase(shop_global.getWorldName())
|
||||
&& shop_temp.getX() == shop_global.getX() && shop_temp.getY() == shop_global.getY()
|
||||
&& shop_temp.getZ() == shop_global.getZ()
|
||||
&& shop_temp.getShopOwnerUUID().equalsIgnoreCase(shop_global.getShopOwnerUUID())
|
||||
) {
|
||||
&& shop_temp.getShopOwnerUUID().equalsIgnoreCase(shop_global.getShopOwnerUUID()))
|
||||
{
|
||||
|
||||
shop_temp.setPlayerVisitList(shop_global.getPlayerVisitList());
|
||||
shop_temp.setHiddenFromSearch(shop_global.isHiddenFromSearch());
|
||||
tempShopToRemove = shop_global;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(tempShopToRemove != null)
|
||||
|
||||
if (tempShopToRemove != null)
|
||||
globalShopsList.remove(tempShopToRemove);
|
||||
|
||||
}
|
||||
|
||||
return tempGlobalShopsList;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register finditem sub-command for /qs
|
||||
* Unregister /qs find
|
||||
* Register find sub-command for /qs Unregister /qs find
|
||||
*/
|
||||
@Override
|
||||
public void registerSubCommand() {
|
||||
|
||||
LoggerUtils.logInfo("Unregistered find sub-command for /qs");
|
||||
for(CommandContainer cmdContainer : api.getCommandManager().getRegisteredCommands()) {
|
||||
if(cmdContainer.getPrefix().equalsIgnoreCase("find")) {
|
||||
for (CommandContainer cmdContainer : api.getCommandManager().getRegisteredCommands()) {
|
||||
|
||||
if (cmdContainer.getPrefix().equalsIgnoreCase("find")) {
|
||||
|
||||
api.getCommandManager().unregisterCmd(cmdContainer);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
LoggerUtils.logInfo("Registered finditem sub-command for /qs");
|
||||
|
||||
LoggerUtils.logInfo("Registered find sub-command for /qs");
|
||||
/*
|
||||
final TextComponent textComponent = Component.text("Search for items from all shops using an interactive GUI");
|
||||
final Function<String, Component> func = x -> Component.text("Search for items from all shops using an interactive GUI");
|
||||
* final TextComponent textComponent =
|
||||
* Component.text("Search for items from all shops using an interactive GUI");
|
||||
* final Function<String, Component> func = x ->
|
||||
* Component.text("Search for items from all shops using an interactive GUI");
|
||||
*/
|
||||
api.getCommandManager().registerCmd(
|
||||
CommandContainer.builder()
|
||||
.prefix("finditem")
|
||||
.permission(PlayerPerms.FINDITEM_USE.value())
|
||||
.hidden(false)
|
||||
.description(locale -> Component.text("Search for items from all shops using an interactive GUI"))
|
||||
.executor(new FindItemCmdHikariImpl())
|
||||
.build());
|
||||
api.getCommandManager().registerCmd(CommandContainer.builder().prefix("find")
|
||||
.permission(PlayerPerms.FINDITEM_USE.value()).hidden(false)
|
||||
.description(locale -> Component.text("Search for items from all shops using an interactive GUI"))
|
||||
.executor(new FindItemCmdHikariImpl()).build());
|
||||
|
||||
}
|
||||
|
||||
private UUID convertQUserToUUID(QUser qUser) {
|
||||
|
||||
Optional<UUID> uuid = qUser.getUniqueIdOptional();
|
||||
if (uuid.isPresent()) {
|
||||
|
||||
return uuid.get();
|
||||
|
||||
}
|
||||
|
||||
String username = qUser.getUsernameOptional().orElse("Unknown");
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* If IGNORE_EMPTY_CHESTS is true -> do not add empty stock or space If to buy
|
||||
* -> If shop has no stock -> based on ignore flag, decide to include it or not
|
||||
* If to sell -> If shop has no space -> based on ignore flag, decide to include
|
||||
* it or not
|
||||
*
|
||||
* @param toBuy
|
||||
* @param shop
|
||||
* @return If shop needs to be ignored from list
|
||||
*/
|
||||
private boolean checkIfShopToBeIgnoredForFullOrEmpty(boolean toBuy, Shop shop) {
|
||||
|
||||
boolean ignoreEmptyChests = FindItemAddOnOG.getConfigProvider().IGNORE_EMPTY_CHESTS;
|
||||
if (ignoreEmptyChests) {
|
||||
|
||||
if (toBuy) {
|
||||
|
||||
return getRemainingStockOrSpaceFromShopCache(shop, true) == 0;
|
||||
|
||||
} else
|
||||
return getRemainingStockOrSpaceFromShopCache(shop, false) == 0;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback to fetching info from ShopCache to avoid lag
|
||||
*
|
||||
* @param shop QuickShop Shop instance
|
||||
* @param fetchRemainingStock True if fetching remaning stock, False if fetching
|
||||
* remaining space
|
||||
* @return
|
||||
*/
|
||||
private int getRemainingStockOrSpaceFromShopCache(Shop shop, boolean fetchRemainingStock) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Shop ID: " + shop.getShopId());
|
||||
CachedShop cachedShop = shopCache.get(shop.getShopId());
|
||||
if (cachedShop == null || QSApi.isTimeDifferenceGreaterThanSeconds(cachedShop.getLastFetched(), new Date(),
|
||||
SHOP_CACHE_TIMEOUT_SECONDS))
|
||||
{
|
||||
|
||||
cachedShop = CachedShop.builder().shopId(shop.getShopId()).remainingStock(shop.getRemainingStock())
|
||||
.remainingSpace(shop.getRemainingSpace()).lastFetched(new Date()).build();
|
||||
shopCache.put(cachedShop.getShopId(), cachedShop);
|
||||
LoggerUtils.logDebugInfo("Adding to ShopCache: " + shop.getShopId());
|
||||
|
||||
}
|
||||
|
||||
return (fetchRemainingStock ? cachedShop.getRemainingStock() : cachedShop.getRemainingSpace());
|
||||
|
||||
}
|
||||
|
||||
// An empty ResultSet or a value that returns -1 means that the value is not
|
||||
// cached.
|
||||
// Normally when space is -1, stock is not, and vice versa.
|
||||
// In special cases, neither value may be -1.
|
||||
// If Stock 0 -> Shop is admin or no stock
|
||||
private void testQuickShopHikariExternalCache(Shop shop) throws RuntimeException {
|
||||
|
||||
long shopId = shop.getShopId();
|
||||
try (SQLQuery query = DataTables.EXTERNAL_CACHE.createQuery().addCondition("shop", shopId)
|
||||
.selectColumns("space", "stock").setLimit(1).build().execute();
|
||||
ResultSet resultSet = query.getResultSet())
|
||||
{
|
||||
|
||||
if (resultSet.next()) {
|
||||
|
||||
long stock = resultSet.getLong("stock");
|
||||
long space = resultSet.getLong("space");
|
||||
// stock or space can be `-1`
|
||||
LoggerUtils.logWarning("1: Location: " + shop.getLocation() + "Stock: " + stock + " | Space: " + space);
|
||||
|
||||
} else {
|
||||
|
||||
// no cached data
|
||||
LoggerUtils.logWarning("No cached data found!");
|
||||
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
||||
throw new RuntimeException(e);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+338
-114
@@ -1,7 +1,8 @@
|
||||
package io.myzticbean.finditemaddon.QuickShopHandler;
|
||||
|
||||
import io.myzticbean.finditemaddon.Commands.QSSubCommands.FindItemCmdReremakeImpl;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.CachedShop;
|
||||
import io.myzticbean.finditemaddon.Models.FoundShopItemModel;
|
||||
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
@@ -13,237 +14,460 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.api.QuickShopAPI;
|
||||
import org.maxgamer.quickshop.api.command.CommandContainer;
|
||||
import org.maxgamer.quickshop.api.shop.Shop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Implementation of QSApi for Reremake
|
||||
* @author ronsane
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public class QSReremakeAPIHandler implements QSApi<QuickShop, Shop> {
|
||||
|
||||
private final QuickShopAPI api;
|
||||
|
||||
private final QuickShop quickShop;
|
||||
|
||||
private final ConcurrentMap<Location, CachedShop> shopCache;
|
||||
|
||||
private final int SHOP_CACHE_TIMEOUT_SECONDS = 60;
|
||||
private final String QS_REREMAKE_PLUGIN_NAME = "QuickShop";
|
||||
|
||||
public QSReremakeAPIHandler() {
|
||||
|
||||
api = (QuickShopAPI) Bukkit.getPluginManager().getPlugin(QS_REREMAKE_PLUGIN_NAME);
|
||||
quickShop = (QuickShop) Bukkit.getPluginManager().getPlugin(QS_REREMAKE_PLUGIN_NAME);
|
||||
LoggerUtils.logInfo("Initializing Shop caching");
|
||||
shopCache = new ConcurrentHashMap<>();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FoundShopItemModel> findItemBasedOnTypeFromAllShops(ItemStack item, boolean toBuy, Player searchingPlayer) {
|
||||
public List<FoundShopItemModel> findItemBasedOnTypeFromAllShops(ItemStack item, boolean toBuy,
|
||||
Player searchingPlayer)
|
||||
{
|
||||
|
||||
long begin = System.currentTimeMillis();
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
if (FindItemAddOnOG.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
allShops = api.getShopManager().getAllShops();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
|
||||
allShops.forEach((shop_i) -> {
|
||||
for (Shop shop_i : allShops) {
|
||||
|
||||
// check for blacklisted worlds
|
||||
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
|
||||
if (!FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
|
||||
&& shop_i.getItem().getType().equals(item.getType())
|
||||
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
|
||||
// check for shop if hidden
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
shopsFoundList.add(new FoundShopItemModel(
|
||||
shop_i.getPrice(),
|
||||
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
|
||||
shop_i.getOwner(),
|
||||
shop_i.getLocation(),
|
||||
shop_i.getItem()
|
||||
));
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) != 0 : getRemainingStockOrSpaceFromShopCache(shop_i, false) != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying()))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shop_i)) {
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// if(checkIfShopToBeIgnoredIfAdminShop(shop_i))
|
||||
// continue;
|
||||
// check for shop if hidden
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shop_i.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shop_i, false))),
|
||||
shop_i.getOwner(), shop_i.getLocation(), shop_i.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if(!shopsFoundList.isEmpty()) {
|
||||
int sortingMethod = 2;
|
||||
try {
|
||||
sortingMethod = FindItemAddOn.getConfigProvider().SHOP_SORTING_METHOD;
|
||||
}
|
||||
catch(Exception e) {
|
||||
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
|
||||
LoggerUtils.logError("Defaulting to sorting by prices method");
|
||||
}
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList);
|
||||
|
||||
}
|
||||
return shopsFoundList;
|
||||
|
||||
List<FoundShopItemModel> sortedShops = handleShopSorting(toBuy, shopsFoundList);
|
||||
long end = System.currentTimeMillis();
|
||||
logTimeTookMsg((end - begin));
|
||||
return sortedShops;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy, Player searchingPlayer) {
|
||||
public List<FoundShopItemModel> findItemBasedOnDisplayNameFromAllShops(String displayName, boolean toBuy,
|
||||
Player searchingPlayer)
|
||||
{
|
||||
|
||||
long begin = System.currentTimeMillis();
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
if (FindItemAddOnOG.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
allShops = api.getShopManager().getAllShops();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
|
||||
for(Shop shop_i : allShops) {
|
||||
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())) {
|
||||
if(shop_i.getItem().hasItemMeta()) {
|
||||
if(Objects.requireNonNull(shop_i.getItem().getItemMeta()).hasDisplayName()) {
|
||||
if(shop_i.getItem().getItemMeta().getDisplayName().toLowerCase().contains(displayName.toLowerCase())
|
||||
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
|
||||
for (Shop shop_i : allShops) {
|
||||
|
||||
if (!FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())) {
|
||||
|
||||
if (shop_i.getItem().hasItemMeta()) {
|
||||
|
||||
if (Objects.requireNonNull(shop_i.getItem().getItemMeta()).hasDisplayName()) {
|
||||
|
||||
if (shop_i.getItem().getItemMeta().getDisplayName().toLowerCase()
|
||||
.contains(displayName.toLowerCase())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) != 0 : getRemainingStockOrSpaceFromShopCache(shop_i, false) != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying()))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shop_i))
|
||||
continue;
|
||||
// if(checkIfShopToBeIgnoredIfAdminShop(shop_i))
|
||||
// continue;
|
||||
// check for shop if hidden
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
shopsFoundList.add(new FoundShopItemModel(
|
||||
shop_i.getPrice(),
|
||||
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
|
||||
shop_i.getOwner(),
|
||||
shop_i.getLocation(),
|
||||
shop_i.getItem()
|
||||
));
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shop_i.getPrice(),
|
||||
QSApi.processStockOrSpace(
|
||||
(toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shop_i, false))),
|
||||
shop_i.getOwner(), shop_i.getLocation(), shop_i.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(!shopsFoundList.isEmpty()) {
|
||||
int sortingMethod = 2;
|
||||
try {
|
||||
sortingMethod = FindItemAddOn.getConfigProvider().SHOP_SORTING_METHOD;
|
||||
}
|
||||
catch(Exception e) {
|
||||
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
|
||||
LoggerUtils.logError("Defaulting to sorting by prices method");
|
||||
}
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList);
|
||||
}
|
||||
return shopsFoundList;
|
||||
|
||||
List<FoundShopItemModel> sortedShops = handleShopSorting(toBuy, shopsFoundList);
|
||||
long end = System.currentTimeMillis();
|
||||
logTimeTookMsg((end - begin));
|
||||
return sortedShops;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FoundShopItemModel> fetchAllItemsFromAllShops(boolean toBuy, Player searchingPlayer) {
|
||||
|
||||
long begin = System.currentTimeMillis();
|
||||
List<FoundShopItemModel> shopsFoundList = new ArrayList<>();
|
||||
List<Shop> allShops;
|
||||
if(FindItemAddOn.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
if (FindItemAddOnOG.getConfigProvider().SEARCH_LOADED_SHOPS_ONLY) {
|
||||
|
||||
allShops = new ArrayList<>(api.getShopManager().getLoadedShops());
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
allShops = api.getShopManager().getAllShops();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo("Total shops on server: " + allShops.size());
|
||||
allShops.forEach((shop_i) -> {
|
||||
for (Shop shop_i : allShops) {
|
||||
|
||||
// check for blacklisted worlds
|
||||
if(!FindItemAddOn.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
|
||||
&& (toBuy ? shop_i.getRemainingStock() != 0 : shop_i.getRemainingSpace() != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying())) {
|
||||
if (!FindItemAddOnOG.getConfigProvider().getBlacklistedWorlds().contains(shop_i.getLocation().getWorld())
|
||||
// && (toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true) != 0 : getRemainingStockOrSpaceFromShopCache(shop_i, false) != 0)
|
||||
&& (toBuy ? shop_i.isSelling() : shop_i.isBuying()))
|
||||
{
|
||||
|
||||
if (checkIfShopToBeIgnoredForFullOrEmpty(toBuy, shop_i))
|
||||
continue;
|
||||
// if(checkIfShopToBeIgnoredIfAdminShop(shop_i))
|
||||
// continue;
|
||||
// check for shop if hidden
|
||||
if(!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
shopsFoundList.add(new FoundShopItemModel(
|
||||
shop_i.getPrice(),
|
||||
(toBuy ? shop_i.getRemainingStock() : shop_i.getRemainingSpace()),
|
||||
shop_i.getOwner(),
|
||||
shop_i.getLocation(),
|
||||
shop_i.getItem()
|
||||
));
|
||||
if (!HiddenShopStorageUtil.isShopHidden(shop_i)) {
|
||||
|
||||
shopsFoundList.add(new FoundShopItemModel(shop_i.getPrice(),
|
||||
QSApi.processStockOrSpace((toBuy ? getRemainingStockOrSpaceFromShopCache(shop_i, true)
|
||||
: getRemainingStockOrSpaceFromShopCache(shop_i, false))),
|
||||
shop_i.getOwner(), shop_i.getLocation(), shop_i.getItem()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
if(!shopsFoundList.isEmpty()) {
|
||||
int sortingMethod = 1;
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList);
|
||||
|
||||
}
|
||||
|
||||
if (!shopsFoundList.isEmpty()) {
|
||||
|
||||
int sortingMethod = 1;
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
|
||||
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
logTimeTookMsg((end - begin));
|
||||
return shopsFoundList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getShopSignMaterial() {
|
||||
|
||||
return org.maxgamer.quickshop.util.Util.getSignMaterial();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Shop findShopAtLocation(Block block) {
|
||||
|
||||
Location loc = new Location(block.getWorld(), block.getX(), block.getY(), block.getZ());
|
||||
return api.getShopManager().getShop(loc);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShopOwnerCommandRunner(Player player, Shop shop) {
|
||||
|
||||
return shop.getOwner().toString().equalsIgnoreCase(player.getUniqueId().toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Shop> getAllShops() {
|
||||
|
||||
return api.getShopManager().getAllShops();
|
||||
|
||||
}
|
||||
|
||||
public List<ShopSearchActivityModel> syncShopsListForStorage(List<ShopSearchActivityModel> globalShopsList) {
|
||||
|
||||
// copy all shops from shops list in API to a temp globalShopsList
|
||||
// now check shops from temp globalShopsList in current globalShopsList and pull playerVisit data
|
||||
// now check shops from temp globalShopsList in current globalShopsList and pull
|
||||
// playerVisit data
|
||||
List<ShopSearchActivityModel> tempGlobalShopsList = new ArrayList<>();
|
||||
|
||||
for(Shop shop_i : getAllShops()) {
|
||||
for (Shop shop_i : getAllShops()) {
|
||||
|
||||
Location shopLoc = shop_i.getLocation();
|
||||
tempGlobalShopsList.add(new ShopSearchActivityModel(
|
||||
shopLoc.getWorld().getName(),
|
||||
shopLoc.getX(),
|
||||
shopLoc.getY(),
|
||||
shopLoc.getZ(),
|
||||
shopLoc.getPitch(),
|
||||
shopLoc.getYaw(),
|
||||
shop_i.getOwner().toString(),
|
||||
new ArrayList<>(),
|
||||
false
|
||||
));
|
||||
tempGlobalShopsList.add(new ShopSearchActivityModel(shopLoc.getWorld().getName(), shopLoc.getX(),
|
||||
shopLoc.getY(), shopLoc.getZ(), shopLoc.getPitch(), shopLoc.getYaw(), shop_i.getOwner().toString(),
|
||||
new ArrayList<>(), false));
|
||||
|
||||
}
|
||||
|
||||
for(ShopSearchActivityModel shop_temp : tempGlobalShopsList) {
|
||||
for (ShopSearchActivityModel shop_temp : tempGlobalShopsList) {
|
||||
|
||||
ShopSearchActivityModel tempShopToRemove = null;
|
||||
for(ShopSearchActivityModel shop_global : globalShopsList) {
|
||||
if(shop_temp.getWorldName().equalsIgnoreCase(shop_global.getWorldName())
|
||||
&& shop_temp.getX() == shop_global.getX()
|
||||
&& shop_temp.getY() == shop_global.getY()
|
||||
for (ShopSearchActivityModel shop_global : globalShopsList) {
|
||||
|
||||
if (shop_temp.getWorldName().equalsIgnoreCase(shop_global.getWorldName())
|
||||
&& shop_temp.getX() == shop_global.getX() && shop_temp.getY() == shop_global.getY()
|
||||
&& shop_temp.getZ() == shop_global.getZ()
|
||||
&& shop_temp.getShopOwnerUUID().equalsIgnoreCase(shop_global.getShopOwnerUUID())
|
||||
) {
|
||||
&& shop_temp.getShopOwnerUUID().equalsIgnoreCase(shop_global.getShopOwnerUUID()))
|
||||
{
|
||||
|
||||
shop_temp.setPlayerVisitList(shop_global.getPlayerVisitList());
|
||||
shop_temp.setHiddenFromSearch(shop_global.isHiddenFromSearch());
|
||||
tempShopToRemove = shop_global;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(tempShopToRemove != null)
|
||||
|
||||
if (tempShopToRemove != null)
|
||||
globalShopsList.remove(tempShopToRemove);
|
||||
|
||||
}
|
||||
|
||||
return tempGlobalShopsList;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register finditem sub-command for /qs
|
||||
* Register find sub-command for /qs
|
||||
*/
|
||||
@Override
|
||||
public void registerSubCommand() {
|
||||
|
||||
LoggerUtils.logInfo("Unregistered find sub-command for /qs");
|
||||
for(CommandContainer cmdContainer : api.getCommandManager().getRegisteredCommands()) {
|
||||
if(cmdContainer.getPrefix().equalsIgnoreCase("find")) {
|
||||
for (CommandContainer cmdContainer : api.getCommandManager().getRegisteredCommands()) {
|
||||
|
||||
if (cmdContainer.getPrefix().equalsIgnoreCase("find")) {
|
||||
|
||||
api.getCommandManager().unregisterCmd(cmdContainer);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
LoggerUtils.logInfo("Registered finditem sub-command for /qs");
|
||||
api.getCommandManager().registerCmd(
|
||||
CommandContainer.builder()
|
||||
.prefix("finditem")
|
||||
.permission(PlayerPerms.FINDITEM_USE.value())
|
||||
.hidden(false)
|
||||
.description("Search for items from all shops using an interactive GUI")
|
||||
.executor(new FindItemCmdReremakeImpl())
|
||||
.build());
|
||||
|
||||
LoggerUtils.logInfo("Registered find sub-command for /qs");
|
||||
api.getCommandManager()
|
||||
.registerCmd(CommandContainer.builder().prefix("find").permission(PlayerPerms.FINDITEM_USE.value())
|
||||
.hidden(false).description("Search for items from all shops using an interactive GUI")
|
||||
.executor(new FindItemCmdReremakeImpl()).build());
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static List<FoundShopItemModel> handleShopSorting(boolean toBuy, List<FoundShopItemModel> shopsFoundList) {
|
||||
|
||||
if (!shopsFoundList.isEmpty()) {
|
||||
|
||||
int sortingMethod = 2;
|
||||
try {
|
||||
|
||||
sortingMethod = FindItemAddOnOG.getConfigProvider().SHOP_SORTING_METHOD;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
LoggerUtils.logError("Invalid value in config.yml : 'shop-sorting-method'");
|
||||
LoggerUtils.logError("Defaulting to sorting by prices method");
|
||||
|
||||
}
|
||||
|
||||
return QSApi.sortShops(sortingMethod, shopsFoundList, toBuy);
|
||||
|
||||
}
|
||||
|
||||
return shopsFoundList;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* If IGNORE_EMPTY_CHESTS is true -> do not add empty stock or space If to buy
|
||||
* -> If shop has no stock -> based on ignore flag, decide to include it or not
|
||||
* If to sell -> If shop has no space -> based on ignore flag, decide to include
|
||||
* it or not
|
||||
*
|
||||
* @param toBuy
|
||||
* @param shop
|
||||
* @return If shop needs to be ignored from list
|
||||
*/
|
||||
private boolean checkIfShopToBeIgnoredForFullOrEmpty(boolean toBuy, Shop shop) {
|
||||
|
||||
boolean ignoreEmptyChests = FindItemAddOnOG.getConfigProvider().IGNORE_EMPTY_CHESTS;
|
||||
if (ignoreEmptyChests) {
|
||||
|
||||
if (toBuy) {
|
||||
|
||||
return getRemainingStockOrSpaceFromShopCache(shop, true) == 0;
|
||||
|
||||
} else
|
||||
return getRemainingStockOrSpaceFromShopCache(shop, false) == 0;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param shop
|
||||
* @return True if shop to be ignored
|
||||
*/
|
||||
/*
|
||||
* private boolean checkIfShopToBeIgnoredIfAdminShop(Shop shop) { boolean
|
||||
* ignoreAdminShops = FindItemAddOn.getConfigProvider().IGNORE_ADMIN_SHOPS;
|
||||
* if(ignoreAdminShops) { OfflinePlayer shopOwner =
|
||||
* Bukkit.getOfflinePlayer(shop.getOwner()); return shopOwner.getName() == null;
|
||||
* } return false; }
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fallback to fetching info from ShopCache to avoid lag
|
||||
*
|
||||
* @param shop QuickShop Shop instance
|
||||
* @param fetchRemainingStock True if fetching remaning stock, False if fetching
|
||||
* remaining space
|
||||
* @return
|
||||
*/
|
||||
private int getRemainingStockOrSpaceFromShopCache(Shop shop, boolean fetchRemainingStock) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Shop Location: " + shop.getLocation());
|
||||
CachedShop cachedShop = shopCache.get(shop.getLocation());
|
||||
if (cachedShop == null || QSApi.isTimeDifferenceGreaterThanSeconds(cachedShop.getLastFetched(), new Date(),
|
||||
SHOP_CACHE_TIMEOUT_SECONDS))
|
||||
{
|
||||
|
||||
Shop possibleCachedShop = getRemainingStockOrSpaceFromQSCache(shop);
|
||||
if (possibleCachedShop != null) {
|
||||
|
||||
cachedShop = CachedShop.builder().shopLocation(possibleCachedShop.getLocation())
|
||||
.remainingStock(possibleCachedShop.getRemainingStock())
|
||||
.remainingSpace(possibleCachedShop.getRemainingSpace()).lastFetched(new Date()).build();
|
||||
shopCache.put(cachedShop.getShopLocation(), cachedShop);
|
||||
LoggerUtils.logDebugInfo("Added to ShopCache: " + shop.getLocation());
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logError("No shop found from QS cache for location: " + shop.getLocation());
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logInfo("Shop found from cache: " + shop.getLocation());
|
||||
|
||||
}
|
||||
|
||||
return (fetchRemainingStock ? (cachedShop != null ? cachedShop.getRemainingStock() : -1)
|
||||
: (cachedShop != null ? cachedShop.getRemainingSpace() : -1));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fallback to fetching info from ShopCache to avoid lag
|
||||
*
|
||||
* @param shop QuickShop Shop instance
|
||||
* @return
|
||||
*/
|
||||
private @Nullable Shop getRemainingStockOrSpaceFromQSCache(Shop shop) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Shop Location: " + shop.getLocation());
|
||||
|
||||
return quickShop.getShopCache().find(shop.getLocation(), false);
|
||||
|
||||
/*
|
||||
* CachedShop cachedShop = shopCache.get(shop.getLocation()); if (cachedShop ==
|
||||
* null || QSApi.isTimeDifferenceGreaterThanSeconds(cachedShop.getLastFetched(),
|
||||
* new Date(), SHOP_CACHE_TIMEOUT_SECONDS)) { cachedShop = CachedShop.builder()
|
||||
* .shopLocation(shop.getLocation()) .remainingStock(shop.getRemainingStock())
|
||||
* .remainingSpace(shop.getRemainingSpace()) .lastFetched(new Date()) .build();
|
||||
* shopCache.put(cachedShop.getShopLocation(), cachedShop);
|
||||
* LoggerUtils.logDebugInfo("Adding to ShopCache: " + shop.getLocation()); }
|
||||
* return (fetchRemainingStock ? cachedShop.getRemainingStock() :
|
||||
* cachedShop.getRemainingSpace());
|
||||
*/
|
||||
}
|
||||
|
||||
private void logTimeTookMsg(long timeTook) {
|
||||
|
||||
LoggerUtils.logInfo("Shop search took: " + timeTook + " milliseconds");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,14 @@ import io.myzticbean.finditemaddon.Utils.JsonStorageUtils.ShopSearchActivityStor
|
||||
import io.myzticbean.finditemaddon.Utils.WarpUtils.WarpUtils;
|
||||
|
||||
public class Task15MinInterval implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
WarpUtils.updateWarps();
|
||||
// HiddenShopStorageUtil.saveHiddenShopsToFile();
|
||||
ShopSearchActivityStorageUtil.syncShops();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,41 +1,57 @@
|
||||
package io.myzticbean.finditemaddon.Utils;
|
||||
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class CommonUtils {
|
||||
|
||||
public static String parseColors(String msg) {
|
||||
return ChatColor.translateAlternateColorCodes('&', msg);
|
||||
}
|
||||
|
||||
public static void sendPlayerActionBar(Player player, String msg) {
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, ColorTranslator.translateColorCodesToTextComponent(msg));
|
||||
|
||||
if (player == null || msg == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Component component = UtilitiesOG.trueogColorize(msg);
|
||||
player.sendActionBar(component);
|
||||
|
||||
}
|
||||
|
||||
public static String capitalizeFirstLetters(String str) {
|
||||
char[] array = str.toCharArray();
|
||||
|
||||
final char[] array = str.toCharArray();
|
||||
|
||||
// Uppercase first letter.
|
||||
array[0] = Character.toUpperCase(array[0]);
|
||||
|
||||
// Uppercase all letters that follow a whitespace character.
|
||||
for (int i = 1; i < array.length; i++) {
|
||||
|
||||
if (Character.isWhitespace(array[i - 1])) {
|
||||
|
||||
array[i] = Character.toUpperCase(array[i]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new String(array);
|
||||
|
||||
}
|
||||
|
||||
public static Double calculateDistance2D(double x1, double y1, double x2, double y2) {
|
||||
|
||||
return Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
|
||||
|
||||
}
|
||||
|
||||
public static Double calculateDistance3D(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
|
||||
return Math.pow((Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2) + Math.pow(z2 - z1, 2)), 0.5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,57 @@
|
||||
package io.myzticbean.finditemaddon.Utils.Defaults;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* List of all the permissions used by the addon
|
||||
* @author ronsane
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public enum PlayerPerms {
|
||||
FINDITEM_ADMIN("finditem.admin"),
|
||||
FINDITEM_USE("finditem.use"),
|
||||
FINDITEM_HIDESHOP("finditem.hideshop"),
|
||||
|
||||
FINDITEM_ADMIN("finditem.admin"), FINDITEM_USE("finditem.use"), FINDITEM_HIDESHOP("finditem.hideshop"),
|
||||
FINDITEM_RELOAD("finditem.reload"),
|
||||
FINDITEM_RESTART("finditem.restart"),
|
||||
FINDITEM_SHOPTP("finditem.shoptp");
|
||||
|
||||
@Deprecated
|
||||
FINDITEM_RESTART("finditem.restart"), FINDITEM_SHOPTP("finditem.shoptp"),
|
||||
FINDITEM_SHOPTP_OWN("finditem.shoptp.own"), FINDITEM_SHOPTP_BYPASS_DELAY("finditem.shoptp-delay.bypass");
|
||||
|
||||
private final String permName;
|
||||
|
||||
PlayerPerms(String perm) {
|
||||
|
||||
permName = perm;
|
||||
|
||||
}
|
||||
|
||||
public String value() {
|
||||
|
||||
return permName;
|
||||
|
||||
}
|
||||
|
||||
public static boolean isAdmin(Player p) {
|
||||
|
||||
return p.hasPermission(FINDITEM_ADMIN.permName);
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasShopTpDelayBypassPermOrAdmin(Player p) {
|
||||
|
||||
return (isAdmin(p) || hasShopTpDelayBypassPerm(p));
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasShopTpDelayBypassPerm(Player p) {
|
||||
|
||||
return p.hasPermission(FINDITEM_SHOPTP_BYPASS_DELAY.permName);
|
||||
|
||||
}
|
||||
|
||||
public static boolean canPlayerTpToOwnShop(Player p) {
|
||||
|
||||
return p.hasPermission(FINDITEM_SHOPTP_OWN.permName);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,20 +2,26 @@ package io.myzticbean.finditemaddon.Utils.Defaults;
|
||||
|
||||
/**
|
||||
* List of all the placeholds used in the Shop lore in GUI
|
||||
* @author ronsane
|
||||
*
|
||||
* @author myzticbean
|
||||
*/
|
||||
public enum ShopLorePlaceholders {
|
||||
ITEM_PRICE("{ITEM_PRICE}"),
|
||||
SHOP_STOCK("{SHOP_STOCK}"),
|
||||
SHOP_OWNER("{SHOP_OWNER}"),
|
||||
SHOP_LOCATION("{SHOP_LOC}"),
|
||||
SHOP_WORLD("{SHOP_WORLD}"),
|
||||
NEAREST_WARP("{NEAREST_WARP}"),
|
||||
SHOP_VISITS("{SHOP_VISITS}");
|
||||
|
||||
ITEM_PRICE("{ITEM_PRICE}"), SHOP_STOCK("{SHOP_STOCK}"), SHOP_OWNER("{SHOP_OWNER}"), SHOP_LOCATION("{SHOP_LOC}"),
|
||||
SHOP_WORLD("{SHOP_WORLD}"), NEAREST_WARP("{NEAREST_WARP}"), SHOP_VISITS("{SHOP_VISITS}");
|
||||
|
||||
private final String placeholder;
|
||||
|
||||
ShopLorePlaceholders(String placeholder) {
|
||||
|
||||
this.placeholder = placeholder;
|
||||
|
||||
}
|
||||
public String value() {return placeholder;}
|
||||
|
||||
public String value() {
|
||||
|
||||
return placeholder;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+99
-45
@@ -2,7 +2,7 @@ package io.myzticbean.finditemaddon.Utils.JsonStorageUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.HiddenShopModel;
|
||||
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
@@ -23,27 +23,35 @@ public class HiddenShopStorageUtil {
|
||||
|
||||
/**
|
||||
* QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
public static void handleShopSearchVisibilityAsync(Shop shop, boolean hideShop) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
|
||||
Iterator<ShopSearchActivityModel> shopSearchActivityIterator = ShopSearchActivityStorageUtil.getGlobalShopsList().iterator();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
Iterator<ShopSearchActivityModel> shopSearchActivityIterator = ShopSearchActivityStorageUtil
|
||||
.getGlobalShopsList().iterator();
|
||||
int i = 0;
|
||||
while(shopSearchActivityIterator.hasNext()) {
|
||||
while (shopSearchActivityIterator.hasNext()) {
|
||||
|
||||
ShopSearchActivityModel shopSearchActivity = shopSearchActivityIterator.next();
|
||||
Location shopLocation = shop.getLocation();
|
||||
if(shopSearchActivity.compareWith(
|
||||
shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(),
|
||||
shopLocation.getY(),
|
||||
shopLocation.getZ()
|
||||
)) {
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
ShopSearchActivityStorageUtil.getGlobalShopsList().get(i).setHiddenFromSearch(hideShop);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// HiddenShopModel hiddenShop = new HiddenShopModel(
|
||||
// shop.getLocation().getWorld().getName(),
|
||||
// shop.getLocation().getX(),
|
||||
@@ -57,27 +65,35 @@ public class HiddenShopStorageUtil {
|
||||
|
||||
/**
|
||||
* QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
public static void handleShopSearchVisibilityAsync(com.ghostchu.quickshop.api.shop.Shop shop, boolean hideShop) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
|
||||
Iterator<ShopSearchActivityModel> shopSearchActivityIterator = ShopSearchActivityStorageUtil.getGlobalShopsList().iterator();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
Iterator<ShopSearchActivityModel> shopSearchActivityIterator = ShopSearchActivityStorageUtil
|
||||
.getGlobalShopsList().iterator();
|
||||
int i = 0;
|
||||
while(shopSearchActivityIterator.hasNext()) {
|
||||
while (shopSearchActivityIterator.hasNext()) {
|
||||
|
||||
ShopSearchActivityModel shopSearchActivity = shopSearchActivityIterator.next();
|
||||
Location shopLocation = shop.getLocation();
|
||||
if(shopSearchActivity.compareWith(
|
||||
shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(),
|
||||
shopLocation.getY(),
|
||||
shopLocation.getZ()
|
||||
)) {
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
ShopSearchActivityStorageUtil.getGlobalShopsList().get(i).setHiddenFromSearch(hideShop);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// HiddenShopModel hiddenShop = new HiddenShopModel(
|
||||
// shop.getLocation().getWorld().getName(),
|
||||
// shop.getLocation().getX(),
|
||||
@@ -91,6 +107,7 @@ public class HiddenShopStorageUtil {
|
||||
|
||||
/**
|
||||
* QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
// public static void deleteShop(Shop shop) {
|
||||
@@ -110,6 +127,7 @@ public class HiddenShopStorageUtil {
|
||||
|
||||
/**
|
||||
* QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
// public static void deleteShop(com.ghostchu.quickshop.api.shop.Shop shop) {
|
||||
@@ -129,27 +147,35 @@ public class HiddenShopStorageUtil {
|
||||
|
||||
/**
|
||||
* QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
* @return
|
||||
*/
|
||||
public static boolean isShopHidden(Shop shop) {
|
||||
for(ShopSearchActivityModel shopSearchActivity : ShopSearchActivityStorageUtil.getGlobalShopsList()) {
|
||||
|
||||
for (ShopSearchActivityModel shopSearchActivity : ShopSearchActivityStorageUtil.getGlobalShopsList()) {
|
||||
|
||||
Location shopLocation = shop.getLocation();
|
||||
if(shopSearchActivity.compareWith(
|
||||
shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(),
|
||||
shopLocation.getY(),
|
||||
shopLocation.getZ()
|
||||
)) {
|
||||
if(shopSearchActivity.isHiddenFromSearch()) {
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
if (shopSearchActivity.isHiddenFromSearch()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
// for(HiddenShopModel hiddenShop : hiddenShopsList) {
|
||||
// if(hiddenShop.getWorldName().equalsIgnoreCase(shop.getLocation().getWorld().getName())
|
||||
// && hiddenShop.getX() == shop.getLocation().getX()
|
||||
@@ -166,27 +192,35 @@ public class HiddenShopStorageUtil {
|
||||
|
||||
/**
|
||||
* QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
* @return
|
||||
*/
|
||||
public static boolean isShopHidden(com.ghostchu.quickshop.api.shop.Shop shop) {
|
||||
for(ShopSearchActivityModel shopSearchActivity : ShopSearchActivityStorageUtil.getGlobalShopsList()) {
|
||||
|
||||
for (ShopSearchActivityModel shopSearchActivity : ShopSearchActivityStorageUtil.getGlobalShopsList()) {
|
||||
|
||||
Location shopLocation = shop.getLocation();
|
||||
if(shopSearchActivity.compareWith(
|
||||
shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(),
|
||||
shopLocation.getY(),
|
||||
shopLocation.getZ()
|
||||
)) {
|
||||
if(shopSearchActivity.isHiddenFromSearch()) {
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
if (shopSearchActivity.isHiddenFromSearch()) {
|
||||
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
// for(HiddenShopModel hiddenShop : hiddenShopsList) {
|
||||
// if(hiddenShop.getWorldName().equalsIgnoreCase(shop.getLocation().getWorld().getName())
|
||||
// && hiddenShop.getX() == shop.getLocation().getX()
|
||||
@@ -202,40 +236,60 @@ public class HiddenShopStorageUtil {
|
||||
}
|
||||
|
||||
public static void loadHiddenShopsFromFile() {
|
||||
|
||||
Gson gson = new Gson();
|
||||
File file = new File(FindItemAddOn.getInstance().getDataFolder().getAbsolutePath() + "/" + HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
|
||||
if(file.exists()) {
|
||||
File file = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
|
||||
if (file.exists()) {
|
||||
|
||||
try {
|
||||
|
||||
Reader reader = new FileReader(file);
|
||||
// Type listType = new TypeToken<List<HiddenShopModel>>() {}.getType();
|
||||
HiddenShopModel[] h = gson.fromJson(reader, HiddenShopModel[].class);
|
||||
if(h != null) {
|
||||
if (h != null) {
|
||||
|
||||
hiddenShopsList = new ArrayList<>(Arrays.asList(h));
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
hiddenShopsList = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Loaded hidden shops from file");
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void saveHiddenShopsToFile() {
|
||||
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
File file = new File(FindItemAddOn.getInstance().getDataFolder().getAbsolutePath() + "/" + HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
|
||||
File file = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
|
||||
file.getParentFile().mkdir();
|
||||
try {
|
||||
|
||||
file.createNewFile();
|
||||
Writer writer = new FileWriter(file, false);
|
||||
gson.toJson(hiddenShopsList, writer);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
LoggerUtils.logInfo("Saved hidden shops to file");
|
||||
|
||||
} catch (IOException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+282
-195
@@ -1,325 +1,412 @@
|
||||
package io.myzticbean.finditemaddon.Utils.JsonStorageUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Models.HiddenShopModel;
|
||||
import io.myzticbean.finditemaddon.Models.PlayerShopVisitModel;
|
||||
import io.myzticbean.finditemaddon.Models.ShopSearchActivityModel;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import lombok.Getter;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.*;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ShopSearchActivityStorageUtil {
|
||||
|
||||
private static final String SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME = "shops.json";
|
||||
private static final String COOLDOWNS_YAML_FILE_NAME = "cooldowns.yml";
|
||||
// private static final String COOLDOWNS_YAML_FILE_NAME = "cooldowns.yml";
|
||||
|
||||
@Getter
|
||||
private static final Map<String, Long> cooldowns = new HashMap<>();
|
||||
private static final Map<String, Long> cooldowns = Collections.unmodifiableMap(new HashMap<>());
|
||||
|
||||
private static File cooldownsYaml;
|
||||
private static FileConfiguration cooldownsConfig;
|
||||
// private static File cooldownsYaml;
|
||||
// private static FileConfiguration cooldownsConfig;
|
||||
|
||||
@Getter
|
||||
private static List<ShopSearchActivityModel> globalShopsList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Returns true if cooldown is not present
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
private static boolean handleCooldownIfPresent(Location shopLocation, Player player) {
|
||||
// The below logic is flawed
|
||||
|
||||
/*
|
||||
// check player is inside hashmap
|
||||
if(cooldowns.containsKey(player.getName())) {
|
||||
// check if player still has cooldown
|
||||
if(cooldowns.get(player.getName()) > (System.currentTimeMillis()/1000)) {
|
||||
long timeLeft = (cooldowns.get(player.getName()) - System.currentTimeMillis()/1000);
|
||||
LoggerUtils.logDebugInfo(ColorTranslator.translateColorCodes("&6" + player.getName() + " still has cooldown of " + timeLeft + " seconds!"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
cooldowns.put(player.getName(), (System.currentTimeMillis()/1000) + FindItemAddOn.getConfigProvider().SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES * 60);
|
||||
LoggerUtils.logDebugInfo(ColorTranslator.translateColorCodes("&aCooldown added for " + FindItemAddOn.getConfigProvider().SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES * 60 + " seconds for " + player.getName()));
|
||||
return true;
|
||||
* // check player is inside hashmap if(cooldowns.containsKey(player.getName()))
|
||||
* { // check if player still has cooldown if(cooldowns.get(player.getName()) >
|
||||
* (System.currentTimeMillis()/1000)) { long timeLeft =
|
||||
* (cooldowns.get(player.getName()) - System.currentTimeMillis()/1000);
|
||||
* LoggerUtils.logDebugInfo(ColorTranslator.translateColorCodes("&6" +
|
||||
* player.getName() + " still has cooldown of " + timeLeft + " seconds!"));
|
||||
* return false; } } cooldowns.put(player.getName(),
|
||||
* (System.currentTimeMillis()/1000) +
|
||||
* FindItemAddOn.getConfigProvider().SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES *
|
||||
* 60); LoggerUtils.logDebugInfo(ColorTranslator.
|
||||
* translateColorCodes("&aCooldown added for " +
|
||||
* FindItemAddOn.getConfigProvider().SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES * 60
|
||||
* + " seconds for " + player.getName())); return true;
|
||||
*/
|
||||
|
||||
// New logic
|
||||
for(ShopSearchActivityModel shopSearchActivity : globalShopsList) {
|
||||
if(shopSearchActivity.compareWith(
|
||||
shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(),
|
||||
shopLocation.getY(),
|
||||
shopLocation.getZ()
|
||||
)) {
|
||||
List<PlayerShopVisitModel> playerShopVisitList = shopSearchActivity.getPlayerVisitList()
|
||||
.stream()
|
||||
for (ShopSearchActivityModel shopSearchActivity : globalShopsList) {
|
||||
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
final List<PlayerShopVisitModel> playerShopVisitList = shopSearchActivity.getPlayerVisitList().stream()
|
||||
.filter(p -> p.getPlayerUUID().equals(player.getUniqueId()))
|
||||
.sorted(Comparator.comparing(PlayerShopVisitModel::getVisitDateTime))
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
boolean isCooldownTimeElapsed;
|
||||
if(playerShopVisitList.size() > 0) {
|
||||
isCooldownTimeElapsed = Instant.now().minusSeconds(
|
||||
FindItemAddOn.getConfigProvider().SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES * 60)
|
||||
final boolean isCooldownTimeElapsed;
|
||||
if (playerShopVisitList.size() > 0) {
|
||||
|
||||
isCooldownTimeElapsed = Instant.now()
|
||||
.minusSeconds(
|
||||
FindItemAddOnOG.getConfigProvider().SHOP_PLAYER_VISIT_COOLDOWN_IN_MINUTES * 60)
|
||||
.isAfter(playerShopVisitList.get(playerShopVisitList.size() - 1).getVisitDateTime());
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
isCooldownTimeElapsed = true;
|
||||
|
||||
}
|
||||
if(isCooldownTimeElapsed) {
|
||||
LoggerUtils.logDebugInfo(ColorTranslator.translateColorCodes("&6" + player.getName() + " is out of cooldown"));
|
||||
|
||||
if (isCooldownTimeElapsed) {
|
||||
|
||||
LoggerUtils.logDebugInfo(("&6" + player.getName() + " is out of cooldown"));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
LoggerUtils.logDebugInfo(ColorTranslator.translateColorCodes("&6" + player.getName() + " still has cooldown"));
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo(("&6" + player.getName() + " still has cooldown"));
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
LoggerUtils.logDebugInfo(ColorTranslator.translateColorCodes("&6Shop not found, returning false for cooldown check"));
|
||||
|
||||
LoggerUtils.logDebugInfo(("&6Shop not found, returning false for cooldown check"));
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static void syncShops() {
|
||||
globalShopsList = FindItemAddOn.getQsApiInstance().syncShopsListForStorage(globalShopsList);
|
||||
|
||||
globalShopsList = FindItemAddOnOG.getQsApiInstance().syncShopsListForStorage(globalShopsList);
|
||||
|
||||
}
|
||||
|
||||
// public static void saveCooldowns() {
|
||||
// try {
|
||||
// for(Map.Entry<String, Long> entry : cooldowns.entrySet()) {
|
||||
// cooldownsConfig.set("cooldowns." + entry.getKey(), entry.getValue());
|
||||
// }
|
||||
// cooldownsConfig.save(cooldownsYaml);
|
||||
// }
|
||||
// catch (IOException e) {
|
||||
// LoggerUtils.logError("Error saving config.yml");
|
||||
// }
|
||||
// }
|
||||
// public static void saveCooldowns() {
|
||||
// try {
|
||||
// for(Map.Entry<String, Long> entry : cooldowns.entrySet()) {
|
||||
// cooldownsConfig.set("cooldowns." + entry.getKey(), entry.getValue());
|
||||
// }
|
||||
// cooldownsConfig.save(cooldownsYaml);
|
||||
// }
|
||||
// catch (IOException e) {
|
||||
// LoggerUtils.logError("Error saving config.yml");
|
||||
// }
|
||||
// }
|
||||
|
||||
// public static void restoreCooldowns() {
|
||||
// if(cooldownsConfig.isConfigurationSection("cooldowns")) {
|
||||
// cooldownsConfig.getConfigurationSection("cooldowns").getKeys(false).forEach(key -> {
|
||||
// long timeLeft = cooldownsConfig.getLong("cooldowns." + key);
|
||||
// cooldowns.put(key, timeLeft);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// public static void restoreCooldowns() {
|
||||
// if(cooldownsConfig.isConfigurationSection("cooldowns")) {
|
||||
// cooldownsConfig.getConfigurationSection("cooldowns").getKeys(false).forEach(key
|
||||
// -> {
|
||||
// long timeLeft = cooldownsConfig.getLong("cooldowns." + key);
|
||||
// cooldowns.put(key, timeLeft);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* QuickShop Reremake
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
public void addShop(org.maxgamer.quickshop.api.shop.Shop shop) {
|
||||
for(ShopSearchActivityModel shop_i : globalShopsList) {
|
||||
if(shop_i.getX() == shop.getLocation().getX()
|
||||
&& shop_i.getY() == shop.getLocation().getY()
|
||||
&& shop_i.getZ() == shop.getLocation().getZ()
|
||||
&& shop_i.getWorldName().equalsIgnoreCase(shop.getLocation().getWorld().getName())
|
||||
) {
|
||||
|
||||
for (ShopSearchActivityModel shop_i : globalShopsList) {
|
||||
|
||||
if (shop_i.getX() == shop.getLocation().getX() && shop_i.getY() == shop.getLocation().getY()
|
||||
&& shop_i.getZ() == shop.getLocation().getZ()
|
||||
&& shop_i.getWorldName().equalsIgnoreCase(shop.getLocation().getWorld().getName()))
|
||||
{
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
ShopSearchActivityModel shopModel = new ShopSearchActivityModel(
|
||||
shop.getLocation().getWorld().getName(),
|
||||
shop.getLocation().getX(),
|
||||
shop.getLocation().getY(),
|
||||
shop.getLocation().getZ(),
|
||||
shop.getLocation().getPitch(),
|
||||
shop.getLocation().getYaw(),
|
||||
shop.getOwner().toString(),
|
||||
new ArrayList<>(),
|
||||
false
|
||||
);
|
||||
|
||||
final ShopSearchActivityModel shopModel = new ShopSearchActivityModel(shop.getLocation().getWorld().getName(),
|
||||
shop.getLocation().getX(), shop.getLocation().getY(), shop.getLocation().getZ(),
|
||||
shop.getLocation().getPitch(), shop.getLocation().getYaw(), shop.getOwner().toString(),
|
||||
new ArrayList<>(), false);
|
||||
globalShopsList.add(shopModel);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* QuickShop Hikari
|
||||
*
|
||||
* @param shop
|
||||
*/
|
||||
public void addShop(com.ghostchu.quickshop.api.shop.Shop shop) {
|
||||
ShopSearchActivityModel shopModel = new ShopSearchActivityModel(
|
||||
shop.getLocation().getWorld().getName(),
|
||||
shop.getLocation().getX(),
|
||||
shop.getLocation().getY(),
|
||||
shop.getLocation().getZ(),
|
||||
shop.getLocation().getPitch(),
|
||||
shop.getLocation().getYaw(),
|
||||
shop.getOwner().toString(),
|
||||
new ArrayList<>(),
|
||||
false
|
||||
);
|
||||
|
||||
final ShopSearchActivityModel shopModel = new ShopSearchActivityModel(shop.getLocation().getWorld().getName(),
|
||||
shop.getLocation().getX(), shop.getLocation().getY(), shop.getLocation().getZ(),
|
||||
shop.getLocation().getPitch(), shop.getLocation().getYaw(), shop.getOwner().toString(),
|
||||
new ArrayList<>(), false);
|
||||
globalShopsList.add(shopModel);
|
||||
|
||||
}
|
||||
|
||||
// public void deleteShop(org.maxgamer.quickshop.api.shop.Shop shop) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void deleteShop(com.ghostchu.quickshop.api.shop.Shop shop) {
|
||||
//
|
||||
// }
|
||||
// public void deleteShop(org.maxgamer.quickshop.api.shop.Shop shop) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void deleteShop(com.ghostchu.quickshop.api.shop.Shop shop) {
|
||||
//
|
||||
// }
|
||||
|
||||
public static void loadShopsFromFile() {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
File file = new File(FindItemAddOn.getInstance().getDataFolder().getAbsolutePath() + "/" + SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
if(file.exists()) {
|
||||
|
||||
final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
final File file = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
if (file.exists()) {
|
||||
|
||||
try {
|
||||
Reader reader = new FileReader(file);
|
||||
ShopSearchActivityModel[] h = gson.fromJson(reader, ShopSearchActivityModel[].class);
|
||||
if(h != null) {
|
||||
|
||||
final Reader reader = new FileReader(file);
|
||||
final ShopSearchActivityModel[] h = gson.fromJson(reader, ShopSearchActivityModel[].class);
|
||||
if (h != null) {
|
||||
|
||||
globalShopsList = new ArrayList<>(Arrays.asList(h));
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
globalShopsList = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logInfo("Loaded shops from file");
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
} catch (FileNotFoundException error) {
|
||||
|
||||
error.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// else {
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// LoggerUtils.logInfo("Generated new " + SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
// } catch (IOException e) {
|
||||
// LoggerUtils.logError("Error generating " + SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
globalShopsList = FindItemAddOn.getQsApiInstance().syncShopsListForStorage(globalShopsList);
|
||||
|
||||
// else {
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// LoggerUtils.logInfo("Generated new " + SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
// } catch (IOException e) {
|
||||
// LoggerUtils.logError("Error generating " +
|
||||
// SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
globalShopsList = FindItemAddOnOG.getQsApiInstance().syncShopsListForStorage(globalShopsList);
|
||||
|
||||
}
|
||||
|
||||
public static void saveShopsToFile() {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
File file = new File(FindItemAddOn.getInstance().getDataFolder().getAbsolutePath() + "/" + SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
|
||||
final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
final File file = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ SHOP_SEARCH_ACTIVITY_JSON_FILE_NAME);
|
||||
file.getParentFile().mkdir();
|
||||
try {
|
||||
|
||||
file.createNewFile();
|
||||
Writer writer = new FileWriter(file, false);
|
||||
final Writer writer = new FileWriter(file, false);
|
||||
gson.toJson(globalShopsList, writer);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
LoggerUtils.logInfo("Saved shops to file");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
} catch (IOException error) {
|
||||
|
||||
error.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public static void setupCooldownsConfigFile() {
|
||||
cooldownsYaml = new File(FindItemAddOn.getInstance().getDataFolder(), COOLDOWNS_YAML_FILE_NAME);
|
||||
if(!cooldownsYaml.exists()) {
|
||||
try {
|
||||
boolean isConfigGenerated = cooldownsYaml.createNewFile();
|
||||
if(isConfigGenerated) {
|
||||
LoggerUtils.logInfo("Generated a new " + COOLDOWNS_YAML_FILE_NAME);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LoggerUtils.logError("Error generating " + COOLDOWNS_YAML_FILE_NAME);
|
||||
}
|
||||
}
|
||||
cooldownsConfig = YamlConfiguration.loadConfiguration(cooldownsYaml);
|
||||
}
|
||||
* public static void setupCooldownsConfigFile() { cooldownsYaml = new
|
||||
* File(FindItemAddOn.getInstance().getDataFolder(), COOLDOWNS_YAML_FILE_NAME);
|
||||
* if(!cooldownsYaml.exists()) { try { boolean isConfigGenerated =
|
||||
* cooldownsYaml.createNewFile(); if(isConfigGenerated) {
|
||||
* LoggerUtils.logInfo("Generated a new " + COOLDOWNS_YAML_FILE_NAME); } } catch
|
||||
* (IOException e) { LoggerUtils.logError("Error generating " +
|
||||
* COOLDOWNS_YAML_FILE_NAME); } } cooldownsConfig =
|
||||
* YamlConfiguration.loadConfiguration(cooldownsYaml); }
|
||||
*/
|
||||
|
||||
public static void migrateHiddenShopsToShopsJson() {
|
||||
File hiddenShopsJsonfile = new File(FindItemAddOn.getInstance().getDataFolder().getAbsolutePath() + "/" + HiddenShopStorageUtil.HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
|
||||
if(hiddenShopsJsonfile.exists()) {
|
||||
|
||||
final File hiddenShopsJsonfile = new File(FindItemAddOnOG.getInstance().getDataFolder().getAbsolutePath() + "/"
|
||||
+ HiddenShopStorageUtil.HIDDEN_SHOP_STORAGE_JSON_FILE_NAME);
|
||||
if (hiddenShopsJsonfile.exists()) {
|
||||
|
||||
HiddenShopStorageUtil.loadHiddenShopsFromFile();
|
||||
if(HiddenShopStorageUtil.hiddenShopsList.size() > 0) {
|
||||
for(int globalShopsList_i = 0 ; globalShopsList_i < globalShopsList.size() ; globalShopsList_i++) {
|
||||
ShopSearchActivityModel shopSearchActivity = globalShopsList.get(globalShopsList_i);
|
||||
if (HiddenShopStorageUtil.hiddenShopsList.size() > 0) {
|
||||
|
||||
for (int globalShopsList_i = 0; globalShopsList_i < globalShopsList.size(); globalShopsList_i++) {
|
||||
|
||||
final ShopSearchActivityModel shopSearchActivity = globalShopsList.get(globalShopsList_i);
|
||||
HiddenShopModel tempHiddenShop = null;
|
||||
for(HiddenShopModel hiddenShop_i : HiddenShopStorageUtil.hiddenShopsList) {
|
||||
if(shopSearchActivity.compareWith(hiddenShop_i.getWorldName(),
|
||||
hiddenShop_i.getX(),
|
||||
hiddenShop_i.getY(),
|
||||
hiddenShop_i.getZ(),
|
||||
hiddenShop_i.getShopOwnerUUID())) {
|
||||
for (HiddenShopModel hiddenShop_i : HiddenShopStorageUtil.hiddenShopsList) {
|
||||
|
||||
if (shopSearchActivity.compareWith(hiddenShop_i.getWorldName(), hiddenShop_i.getX(),
|
||||
hiddenShop_i.getY(), hiddenShop_i.getZ(), hiddenShop_i.getShopOwnerUUID()))
|
||||
{
|
||||
|
||||
tempHiddenShop = hiddenShop_i;
|
||||
shopSearchActivity.setHiddenFromSearch(true);
|
||||
globalShopsList.set(globalShopsList_i, shopSearchActivity);
|
||||
LoggerUtils.logDebugInfo("Converted shop: " + shopSearchActivity);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HiddenShopStorageUtil.hiddenShopsList.remove(tempHiddenShop);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo("Here we will delete the hiddenShops.json");
|
||||
hiddenShopsJsonfile.delete();
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo("hiddenshops.json: No conversion required");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void addPlayerVisitEntryAsync(Location shopLocation, Player visitingPlayer) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
|
||||
if(handleCooldownIfPresent(shopLocation, visitingPlayer)) {
|
||||
Iterator<ShopSearchActivityModel> shopSearchActivityIterator = globalShopsList.iterator();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOnOG.getInstance(), () -> {
|
||||
|
||||
if (handleCooldownIfPresent(shopLocation, visitingPlayer)) {
|
||||
|
||||
final Iterator<ShopSearchActivityModel> shopSearchActivityIterator = globalShopsList.iterator();
|
||||
int i = 0;
|
||||
while(shopSearchActivityIterator.hasNext()) {
|
||||
ShopSearchActivityModel shopSearchActivity = shopSearchActivityIterator.next();
|
||||
if(shopSearchActivity.compareWith(
|
||||
shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(),
|
||||
shopLocation.getY(),
|
||||
shopLocation.getZ()
|
||||
)) {
|
||||
PlayerShopVisitModel playerShopVisit = new PlayerShopVisitModel();
|
||||
while (shopSearchActivityIterator.hasNext()) {
|
||||
|
||||
final ShopSearchActivityModel shopSearchActivity = shopSearchActivityIterator.next();
|
||||
if (shopSearchActivity.compareWith(shopLocation.getWorld().getName(), shopLocation.getX(),
|
||||
shopLocation.getY(), shopLocation.getZ()))
|
||||
{
|
||||
|
||||
final PlayerShopVisitModel playerShopVisit = new PlayerShopVisitModel();
|
||||
playerShopVisit.setPlayerUUID(visitingPlayer.getUniqueId());
|
||||
playerShopVisit.setVisitDateTime();
|
||||
// shopSearchActivity.getPlayerVisitList().add(playerShopVisit);
|
||||
// shopSearchActivity.getPlayerVisitList().add(playerShopVisit);
|
||||
globalShopsList.get(i).getPlayerVisitList().add(playerShopVisit);
|
||||
LoggerUtils.logDebugInfo("Added new player visit entry at " + shopLocation.toString());
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
// for(ShopSearchActivityModel shopSearchActivity : globalShopsList) {
|
||||
// if(shopSearchActivity.compareWith(
|
||||
// shopLocation.getWorld().getName(),
|
||||
// shopLocation.getX(),
|
||||
// shopLocation.getY(),
|
||||
// shopLocation.getZ()
|
||||
// )) {
|
||||
// PlayerShopVisitModel playerShopVisit = new PlayerShopVisitModel();
|
||||
// playerShopVisit.setPlayerUUID(visitingPlayer.getUniqueId());
|
||||
// playerShopVisit.setVisitDateTime();
|
||||
// shopSearchActivity.getPlayerVisitList().add(playerShopVisit);
|
||||
// LoggerUtils.logDebugInfo("Added new player visit entry at " + shopLocation.toString());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// for(ShopSearchActivityModel shopSearchActivity : globalShopsList) {
|
||||
// if(shopSearchActivity.compareWith(
|
||||
// shopLocation.getWorld().getName(),
|
||||
// shopLocation.getX(),
|
||||
// shopLocation.getY(),
|
||||
// shopLocation.getZ()
|
||||
// )) {
|
||||
// PlayerShopVisitModel playerShopVisit = new PlayerShopVisitModel();
|
||||
// playerShopVisit.setPlayerUUID(visitingPlayer.getUniqueId());
|
||||
// playerShopVisit.setVisitDateTime();
|
||||
// shopSearchActivity.getPlayerVisitList().add(playerShopVisit);
|
||||
// LoggerUtils.logDebugInfo("Added new player visit entry at " +
|
||||
// shopLocation.toString());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static int getPlayerVisitCount(Location shopLocation) {
|
||||
for(ShopSearchActivityModel shopSearchActivity : globalShopsList) {
|
||||
if (shopSearchActivity.compareWith(
|
||||
shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(),
|
||||
shopLocation.getY(),
|
||||
shopLocation.getZ()
|
||||
)) {
|
||||
return shopSearchActivity.getPlayerVisitList().size();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
return globalShopsList.stream()
|
||||
.filter(shopSearchActivity -> shopSearchActivity.compareWith(shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(), shopLocation.getY(), shopLocation.getZ()))
|
||||
.findFirst().map(shopSearchActivity -> shopSearchActivity.getPlayerVisitList().size()).orElse(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static OfflinePlayer getShopOwner(@NotNull Location shopLocation) {
|
||||
|
||||
return globalShopsList.stream()
|
||||
.filter(shopSearchActivity -> shopSearchActivity.compareWith(shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(), shopLocation.getY(), shopLocation.getZ()))
|
||||
.findFirst().map(shopSearchActivity -> Bukkit
|
||||
.getOfflinePlayer(UUID.fromString(shopSearchActivity.getShopOwnerUUID())))
|
||||
.orElse(null);
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static UUID getShopOwnerUUID(@NotNull Location shopLocation) {
|
||||
|
||||
return globalShopsList.stream()
|
||||
.filter(shopSearchActivity -> shopSearchActivity.compareWith(shopLocation.getWorld().getName(),
|
||||
shopLocation.getX(), shopLocation.getY(), shopLocation.getZ()))
|
||||
.findFirst().map(shopSearchActivity -> UUID.fromString(shopSearchActivity.getShopOwnerUUID()))
|
||||
.orElse(null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.myzticbean.finditemaddon.Utils;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.QuickShopHandler.QSApi;
|
||||
import io.myzticbean.finditemaddon.QuickShopHandler.QSHikariAPIHandler;
|
||||
import io.myzticbean.finditemaddon.QuickShopHandler.QSReremakeAPIHandler;
|
||||
@@ -14,7 +14,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class LocationUtils {
|
||||
|
||||
private static final List<Material> damagingBlocks = new ArrayList<>();
|
||||
@@ -22,6 +21,7 @@ public class LocationUtils {
|
||||
private static final int BELOW_SAFE_BLOCK_CHECK_LIMIT = 20;
|
||||
|
||||
static {
|
||||
|
||||
// Initializing Damaging blocks
|
||||
damagingBlocks.add(Material.LAVA);
|
||||
damagingBlocks.add(Material.CACTUS);
|
||||
@@ -38,13 +38,11 @@ public class LocationUtils {
|
||||
nonSuffocatingBlocks.add(Material.AIR);
|
||||
// Glass
|
||||
nonSuffocatingBlocks.add(Material.GLASS);
|
||||
nonSuffocatingBlocks.addAll(
|
||||
new ArrayList<>(Arrays.asList(Material.values()).stream().filter(p -> p.toString().toLowerCase().contains("_glass")).toList())
|
||||
);
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("_glass")).toList()));
|
||||
// Glass Panes
|
||||
nonSuffocatingBlocks.addAll(
|
||||
new ArrayList<>(Arrays.asList(Material.values()).stream().filter(p -> p.toString().toLowerCase().contains("glass_pane")).toList())
|
||||
);
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("glass_pane")).toList()));
|
||||
// Leaves
|
||||
nonSuffocatingBlocks.add(Material.ACACIA_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.BIRCH_LEAVES);
|
||||
@@ -52,22 +50,22 @@ public class LocationUtils {
|
||||
nonSuffocatingBlocks.add(Material.JUNGLE_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.OAK_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.SPRUCE_LEAVES);
|
||||
if(Bukkit.getServer().getVersion().contains("1.17")) {
|
||||
if (Bukkit.getServer().getVersion().contains("1.17")) {
|
||||
|
||||
nonSuffocatingBlocks.add(Material.AZALEA_LEAVES);
|
||||
nonSuffocatingBlocks.add(Material.FLOWERING_AZALEA_LEAVES);
|
||||
|
||||
}
|
||||
|
||||
// Slabs
|
||||
nonSuffocatingBlocks.addAll(
|
||||
new ArrayList<>(Arrays.asList(Material.values()).stream().filter(p -> p.toString().toLowerCase().contains("_slab")).toList())
|
||||
);
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("_slab")).toList()));
|
||||
// Walled Signs
|
||||
nonSuffocatingBlocks.addAll(
|
||||
new ArrayList<>(Arrays.asList(Material.values()).stream().filter(p -> p.toString().toLowerCase().contains("_sign")).toList())
|
||||
);
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("_sign")).toList()));
|
||||
// Stairs
|
||||
nonSuffocatingBlocks.addAll(
|
||||
new ArrayList<>(Arrays.asList(Material.values()).stream().filter(p -> p.toString().toLowerCase().contains("_stairs")).toList())
|
||||
);
|
||||
nonSuffocatingBlocks.addAll(new ArrayList<>(Arrays.asList(Material.values()).stream()
|
||||
.filter(p -> p.toString().toLowerCase().contains("_stairs")).toList()));
|
||||
// MISC
|
||||
nonSuffocatingBlocks.add(Material.HONEY_BLOCK);
|
||||
nonSuffocatingBlocks.add(Material.BELL);
|
||||
@@ -85,110 +83,115 @@ public class LocationUtils {
|
||||
|
||||
@Nullable
|
||||
public static Location findSafeLocationAroundShop(Location shopLocation) {
|
||||
|
||||
Location roundedShopLoc = getRoundedDestination(shopLocation);
|
||||
QSApi qsApi;
|
||||
if(FindItemAddOn.isQSReremakeInstalled()) {
|
||||
if (FindItemAddOnOG.isQSReremakeInstalled()) {
|
||||
|
||||
qsApi = new QSReremakeAPIHandler();
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
qsApi = new QSHikariAPIHandler();
|
||||
|
||||
}
|
||||
LoggerUtils.logDebugInfo("Rounded location: " + roundedShopLoc.getX() + ", " + roundedShopLoc.getY() + ", " + roundedShopLoc.getZ());
|
||||
|
||||
LoggerUtils.logDebugInfo("Rounded location: " + roundedShopLoc.getX() + ", " + roundedShopLoc.getY() + ", "
|
||||
+ roundedShopLoc.getZ());
|
||||
// Creating a list of four block locations in 4 sides of the shop
|
||||
List<Location> possibleSafeLocList = new ArrayList<>();
|
||||
possibleSafeLocList.add(new Location(
|
||||
roundedShopLoc.getWorld(),
|
||||
roundedShopLoc.getX() + 1,
|
||||
roundedShopLoc.getY(),
|
||||
roundedShopLoc.getZ()
|
||||
));
|
||||
possibleSafeLocList.add(new Location(
|
||||
roundedShopLoc.getWorld(),
|
||||
roundedShopLoc.getX() - 1,
|
||||
roundedShopLoc.getY(),
|
||||
roundedShopLoc.getZ()
|
||||
));
|
||||
possibleSafeLocList.add(new Location(
|
||||
roundedShopLoc.getWorld(),
|
||||
roundedShopLoc.getX(),
|
||||
roundedShopLoc.getY(),
|
||||
roundedShopLoc.getZ() + 1
|
||||
));
|
||||
possibleSafeLocList.add(new Location(
|
||||
roundedShopLoc.getWorld(),
|
||||
roundedShopLoc.getX(),
|
||||
roundedShopLoc.getY(),
|
||||
roundedShopLoc.getZ() - 1
|
||||
));
|
||||
for(Location loc_i : possibleSafeLocList) {
|
||||
LoggerUtils.logDebugInfo("Possible safe location: " + loc_i.getX() + ", " + loc_i.getY() + ", " + loc_i.getZ());
|
||||
if(loc_i.getBlock().getType().equals(qsApi.getShopSignMaterial())) {
|
||||
LoggerUtils.logDebugInfo("Shop sign block found at " + loc_i.getX() + ", " + loc_i.getY() + ", " + loc_i.getZ());
|
||||
possibleSafeLocList.add(new Location(roundedShopLoc.getWorld(), roundedShopLoc.getX() + 1,
|
||||
roundedShopLoc.getY(), roundedShopLoc.getZ()));
|
||||
possibleSafeLocList.add(new Location(roundedShopLoc.getWorld(), roundedShopLoc.getX() - 1,
|
||||
roundedShopLoc.getY(), roundedShopLoc.getZ()));
|
||||
possibleSafeLocList.add(new Location(roundedShopLoc.getWorld(), roundedShopLoc.getX(), roundedShopLoc.getY(),
|
||||
roundedShopLoc.getZ() + 1));
|
||||
possibleSafeLocList.add(new Location(roundedShopLoc.getWorld(), roundedShopLoc.getX(), roundedShopLoc.getY(),
|
||||
roundedShopLoc.getZ() - 1));
|
||||
for (Location loc_i : possibleSafeLocList) {
|
||||
|
||||
LoggerUtils.logDebugInfo(
|
||||
"Possible safe location: " + loc_i.getX() + ", " + loc_i.getY() + ", " + loc_i.getZ());
|
||||
if (loc_i.getBlock().getType().equals(qsApi.getShopSignMaterial())) {
|
||||
|
||||
LoggerUtils.logDebugInfo(
|
||||
"Shop sign block found at " + loc_i.getX() + ", " + loc_i.getY() + ", " + loc_i.getZ());
|
||||
// check if the block above is suffocating
|
||||
Location blockAbove = new Location(
|
||||
loc_i.getWorld(),
|
||||
loc_i.getBlockX(),
|
||||
loc_i.getBlockY() + 1,
|
||||
Location blockAbove = new Location(loc_i.getWorld(), loc_i.getBlockX(), loc_i.getBlockY() + 1,
|
||||
loc_i.getBlockZ());
|
||||
LoggerUtils.logDebugInfo("Block above shop sign: "
|
||||
+ blockAbove.getX() + ", " + blockAbove.getY() + ", " + blockAbove.getZ());
|
||||
if(!isBlockSuffocating(blockAbove)) {
|
||||
LoggerUtils.logDebugInfo("Block above shop sign: " + blockAbove.getX() + ", " + blockAbove.getY() + ", "
|
||||
+ blockAbove.getZ());
|
||||
if (!isBlockSuffocating(blockAbove)) {
|
||||
|
||||
Location blockBelow = null;
|
||||
boolean safeLocFound = false;
|
||||
for(int i = 1; i <= BELOW_SAFE_BLOCK_CHECK_LIMIT; i++) {
|
||||
blockBelow = new Location(
|
||||
loc_i.getWorld(),
|
||||
loc_i.getBlockX(),
|
||||
loc_i.getBlockY() - i,
|
||||
loc_i.getBlockZ()
|
||||
);
|
||||
LoggerUtils.logDebugInfo("Block below shop sign: "
|
||||
+ blockBelow.getBlock().getType() + " " + blockBelow.getX() + ", " + blockBelow.getY() + ", " + blockBelow.getZ());
|
||||
if(blockBelow.getBlock().getType().equals(Material.AIR)
|
||||
|| blockBelow.getBlock().getType().equals(Material.CAVE_AIR)
|
||||
|| blockBelow.getBlock().getType().equals(Material.VOID_AIR)
|
||||
|| blockBelow.getBlock().getType().equals(qsApi.getShopSignMaterial())) {
|
||||
for (int i = 1; i <= BELOW_SAFE_BLOCK_CHECK_LIMIT; i++) {
|
||||
|
||||
blockBelow = new Location(loc_i.getWorld(), loc_i.getBlockX(), loc_i.getBlockY() - i,
|
||||
loc_i.getBlockZ());
|
||||
LoggerUtils.logDebugInfo("Block below shop sign: " + blockBelow.getBlock().getType() + " "
|
||||
+ blockBelow.getX() + ", " + blockBelow.getY() + ", " + blockBelow.getZ());
|
||||
if (blockBelow.getBlock().getType().equals(Material.AIR)
|
||||
|| blockBelow.getBlock().getType().equals(Material.CAVE_AIR)
|
||||
|| blockBelow.getBlock().getType().equals(Material.VOID_AIR)
|
||||
|| blockBelow.getBlock().getType().equals(qsApi.getShopSignMaterial()))
|
||||
{
|
||||
|
||||
// do nothing and let the loop run
|
||||
LoggerUtils.logDebugInfo("Shop or Air found below");
|
||||
}
|
||||
else if(!isBlockDamaging(blockBelow)) {
|
||||
|
||||
} else if (!isBlockDamaging(blockBelow)) {
|
||||
|
||||
LoggerUtils.logDebugInfo("Safe block found!");
|
||||
safeLocFound = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(safeLocFound) {
|
||||
loc_i = lookAt(getRoundedDestination(new Location(
|
||||
blockBelow.getWorld(),
|
||||
blockBelow.getX(),
|
||||
blockBelow.getY() + 1,
|
||||
blockBelow.getZ()
|
||||
)), roundedShopLoc);
|
||||
|
||||
if (safeLocFound) {
|
||||
|
||||
loc_i = lookAt(getRoundedDestination(new Location(blockBelow.getWorld(), blockBelow.getX(),
|
||||
blockBelow.getY() + 1, blockBelow.getZ())), roundedShopLoc);
|
||||
return loc_i;
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
LoggerUtils.logDebugInfo("Block above shop sign found not air. Block type: " + blockAbove.getBlock().getType());
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo(
|
||||
"Block above shop sign found not air. Block type: " + blockAbove.getBlock().getType());
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
LoggerUtils.logDebugInfo("Block not shop sign. Block type: " + loc_i.getBlock().getType());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LoggerUtils.logDebugInfo("No safe block found near shop");
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
// Found the below function from this thread: https://bukkit.org/threads/lookat-and-move-functions.26768/
|
||||
// Found the below function from this thread:
|
||||
// https://bukkit.org/threads/lookat-and-move-functions.26768/
|
||||
private static Location lookAt(Location loc, Location lookat) {
|
||||
//Clone the loc to prevent applied changes to the input loc
|
||||
|
||||
// Clone the loc to prevent applied changes to the input loc
|
||||
loc = loc.clone();
|
||||
|
||||
// Values of change in distance (make it relative)
|
||||
@@ -198,15 +201,24 @@ public class LocationUtils {
|
||||
|
||||
// Set yaw
|
||||
if (dx != 0) {
|
||||
|
||||
// Set yaw start value based on dx
|
||||
if (dx < 0) {
|
||||
|
||||
loc.setYaw((float) (1.5 * Math.PI));
|
||||
|
||||
} else {
|
||||
|
||||
loc.setYaw((float) (0.5 * Math.PI));
|
||||
|
||||
}
|
||||
|
||||
loc.setYaw((float) loc.getYaw() - (float) Math.atan(dz / dx));
|
||||
|
||||
} else if (dz < 0) {
|
||||
|
||||
loc.setYaw((float) Math.PI);
|
||||
|
||||
}
|
||||
|
||||
// Get the distance from dx/dz
|
||||
@@ -215,26 +227,35 @@ public class LocationUtils {
|
||||
// Set pitch
|
||||
loc.setPitch((float) -Math.atan(dy / dxz));
|
||||
|
||||
// Set values, convert to degrees (invert the yaw since Bukkit uses a different yaw dimension format)
|
||||
// Set values, convert to degrees (invert the yaw since Bukkit uses a different
|
||||
// yaw dimension format)
|
||||
loc.setYaw(-loc.getYaw() * 180f / (float) Math.PI);
|
||||
loc.setPitch(loc.getPitch() * 180f / (float) Math.PI);
|
||||
|
||||
return loc;
|
||||
|
||||
}
|
||||
|
||||
private static boolean isBlockDamaging(Location loc) {
|
||||
|
||||
return damagingBlocks.contains(loc.getBlock().getType());
|
||||
|
||||
}
|
||||
|
||||
private static boolean isBlockSuffocating(Location loc) {
|
||||
|
||||
return !nonSuffocatingBlocks.contains(loc.getBlock().getType());
|
||||
|
||||
}
|
||||
|
||||
private static Location getRoundedDestination(final Location loc) {
|
||||
|
||||
World world = loc.getWorld();
|
||||
int x = loc.getBlockX();
|
||||
int y = (int)Math.round(loc.getY());
|
||||
int y = (int) Math.round(loc.getY());
|
||||
int z = loc.getBlockZ();
|
||||
return new Location(world, (double)x + 0.5D, (double)y, (double)z + 0.5D, loc.getYaw(), loc.getPitch());
|
||||
return new Location(world, (double) x + 0.5D, (double) y, (double) z + 0.5D, loc.getYaw(), loc.getPitch());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +1,36 @@
|
||||
package io.myzticbean.finditemaddon.Utils;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import org.bukkit.Bukkit;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import net.trueog.utilitiesog.UtilitiesOG;
|
||||
|
||||
public class LoggerUtils {
|
||||
|
||||
public static void logDebugInfo(String text) {
|
||||
if(FindItemAddOn.getConfigProvider().DEBUG_MODE) {
|
||||
Bukkit.getLogger().warning(ColorTranslator.translateColorCodes("[QSFindItemAddOn-DebugLog] " + text));
|
||||
|
||||
if (FindItemAddOnOG.getConfigProvider().DEBUG_MODE) {
|
||||
|
||||
UtilitiesOG.logToConsole("[QSFindItemAddOn-OG] Debug:", text);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void logInfo(String text) {
|
||||
Bukkit.getLogger().info(ColorTranslator.translateColorCodes("[QSFindItemAddOn] " + text));
|
||||
|
||||
UtilitiesOG.logToConsole("[QSFindItemAddOn-OG] Info:", text);
|
||||
|
||||
}
|
||||
|
||||
public static void logError(String text) {
|
||||
Bukkit.getLogger().severe(ColorTranslator.translateColorCodes("[QSFindItemAddOn] " + text));
|
||||
|
||||
UtilitiesOG.logToConsole("[QSFindItemAddOn-OG] Error:", text);
|
||||
|
||||
}
|
||||
|
||||
public static void logWarning(String text) {
|
||||
// Bukkit.getConsoleSender().sendMessage(ColorTranslator.translateColorCodes("[QSFindItemAddOn] &6" + text));
|
||||
Bukkit.getLogger().warning(ColorTranslator.translateColorCodes("[QSFindItemAddOn] " + text));
|
||||
|
||||
UtilitiesOG.logToConsole("[QSFindItemAddOn-OG] Warning:", text);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Utils.Defaults.PlayerPerms;
|
||||
import me.kodysimpson.simpapi.colors.ColorTranslator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Scanner;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class UpdateChecker {
|
||||
|
||||
private final String prefix = "&8["
|
||||
+ "7a800Q"
|
||||
+ "ea800S"
|
||||
+ "Ba800F"
|
||||
+ "ea900i"
|
||||
+ "La900n"
|
||||
+ "da900d"
|
||||
+ "Ta900I"
|
||||
+ "ba900t"
|
||||
+ "\a900e"
|
||||
+ "ba900m"
|
||||
+ "	ea900A"
|
||||
+ "&#a4a900d"
|
||||
+ "&#aaa800d"
|
||||
+ "&#b0a800O"
|
||||
+ "&#b6a800n"
|
||||
+ "&8] ";
|
||||
private final int resourceId;
|
||||
|
||||
public UpdateChecker(int resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public void getLatestVersion(Consumer<String> consumer) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(FindItemAddOn.getInstance(), () -> {
|
||||
try (InputStream inputStream = new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId).openStream();
|
||||
Scanner scanner = new Scanner(inputStream)) {
|
||||
if (scanner.hasNext()) {
|
||||
consumer.accept(scanner.next());
|
||||
}
|
||||
} catch (IOException exception) {
|
||||
LoggerUtils.logError("Update checker is broken, can't find an update!" + exception.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void notifyPlayerAboutUpdateOnJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(player.isOp() || player.hasPermission(PlayerPerms.FINDITEM_ADMIN.value())) {
|
||||
if(FindItemAddOn.getPluginOutdated()) {
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
prefix
|
||||
+ ";b300Hey Ie600" + player.getName() + ";b300! Plugin has an update... You are still on v"
|
||||
+ FindItemAddOn.getInstance().getDescription().getVersion()));
|
||||
|
||||
player.sendMessage(ColorTranslator.translateColorCodes(
|
||||
prefix
|
||||
+ ";b300Download here: &#a3a3c2&nhttps://www.spigotmc.org/resources/"
|
||||
+ FindItemAddOn.getPluginID() + "/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package io.myzticbean.finditemaddon.Utils.WarpUtils;
|
||||
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Models.EssentialWarpModel;
|
||||
import io.myzticbean.finditemaddon.Utils.CommonUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -16,30 +14,31 @@ public class EssentialWarpsUtil {
|
||||
|
||||
@Nullable
|
||||
public String findNearestWarp(Location shopLocation) {
|
||||
|
||||
List<EssentialWarpModel> allWarps = EssentialsXPlugin.getAllWarps();
|
||||
if(allWarps != null && allWarps.size() > 0) {
|
||||
if (allWarps != null && !allWarps.isEmpty()) {
|
||||
|
||||
Map<Double, String> warpDistanceMap = new TreeMap<>();
|
||||
allWarps.forEach(warp -> {
|
||||
Double distance = CommonUtils.calculateDistance3D(
|
||||
shopLocation.getX(),
|
||||
shopLocation.getY(),
|
||||
shopLocation.getZ(),
|
||||
warp.warpLoc.getX(),
|
||||
warp.warpLoc.getY(),
|
||||
warp.warpLoc.getZ()
|
||||
);
|
||||
|
||||
Double distance = CommonUtils.calculateDistance3D(shopLocation.getX(), shopLocation.getY(),
|
||||
shopLocation.getZ(), warp.warpLoc.getX(), warp.warpLoc.getY(), warp.warpLoc.getZ());
|
||||
warpDistanceMap.put(distance, warp.warpName);
|
||||
|
||||
});
|
||||
if(FindItemAddOn.getConfigProvider().DEBUG_MODE) {
|
||||
for(Map.Entry<Double, String> entry : warpDistanceMap.entrySet()) {
|
||||
LoggerUtils.logDebugInfo(entry.getValue() + " : " + entry.getKey());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if(FindItemAddOn.getConfigProvider().DEBUG_MODE) { for(Map.Entry<Double,
|
||||
* String> entry : warpDistanceMap.entrySet()) {
|
||||
* LoggerUtils.logDebugInfo(entry.getValue() + " : " + entry.getKey()); } }
|
||||
*/
|
||||
return warpDistanceMap.entrySet().iterator().next().getValue();
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils.WarpUtils;
|
||||
|
||||
//import me.ronsane.finditemaddon.finditemaddon.Dependencies.PWarpPlugin;
|
||||
//import me.ronsane.finditemaddon.finditemaddon.FindItemAddOn;
|
||||
//import me.ronsane.finditemaddon.finditemaddon.Utils.CommonUtils;
|
||||
//import me.ronsane.finditemaddon.finditemaddon.Utils.LoggerUtils;
|
||||
//import me.tks.playerwarp.Warp;
|
||||
//import org.bukkit.Location;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//import java.util.TreeMap;
|
||||
|
||||
public class PWarpsUtil {
|
||||
|
||||
// @Nullable
|
||||
// public Warp findNearestWarp(Location shopLocation) {
|
||||
// List<Warp> allWarps = PWarpPlugin.getAllWarps();
|
||||
// if(allWarps.size() > 0) {
|
||||
// Map<Double, Warp> warpDistanceMap = new TreeMap<>();
|
||||
// allWarps.parallelStream().forEach(warp -> {
|
||||
// warpDistanceMap.put(CommonUtils.calculateDistance2D(
|
||||
// shopLocation.getX(),
|
||||
// shopLocation.getY(),
|
||||
// warp.getWarpLocation().getX(),
|
||||
// warp.getWarpLocation().getY()
|
||||
// ), warp);
|
||||
// });
|
||||
// if(FindItemAddOn.getConfigProvider().DEBUG_MODE) {
|
||||
// for(Map.Entry<Double, Warp> entry : warpDistanceMap.entrySet()) {
|
||||
// LoggerUtils.logDebugInfo(entry.getValue().getName() + " : " + entry.getKey());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return warpDistanceMap.entrySet().iterator().next().getValue();
|
||||
// }
|
||||
// else {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package io.myzticbean.finditemaddon.Utils.WarpUtils;
|
||||
|
||||
import com.olziedev.playerwarps.api.warp.Warp;
|
||||
import io.myzticbean.finditemaddon.Dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
import io.myzticbean.finditemaddon.Utils.CommonUtils;
|
||||
import io.myzticbean.finditemaddon.Utils.LoggerUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class PlayerWarpsUtil {
|
||||
|
||||
@Nullable
|
||||
public Warp findNearestWarp(Location shopLocation) {
|
||||
List<Warp> allWarps = PlayerWarpsPlugin.getAllWarps();
|
||||
if(!allWarps.isEmpty()) {
|
||||
Map<Double, Warp> warpDistanceMap = new TreeMap<>();
|
||||
allWarps.forEach(warp -> {
|
||||
warpDistanceMap.put(CommonUtils.calculateDistance3D(
|
||||
shopLocation.getX(),
|
||||
shopLocation.getY(),
|
||||
shopLocation.getZ(),
|
||||
warp.getWarpLocation().getX(),
|
||||
warp.getWarpLocation().getY(),
|
||||
warp.getWarpLocation().getZ()
|
||||
), warp);
|
||||
});
|
||||
if(FindItemAddOn.getConfigProvider().DEBUG_MODE) {
|
||||
for(Map.Entry<Double, Warp> entry : warpDistanceMap.entrySet()) {
|
||||
LoggerUtils.logDebugInfo(entry.getValue().getWarpName() + " : " + entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
return warpDistanceMap.entrySet().iterator().next().getValue();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,20 +13,30 @@ public class WGRegionUtils {
|
||||
|
||||
@Nullable
|
||||
public String findNearestWGRegion(Location shopLocation) {
|
||||
ApplicableRegionSet set = WGPlugin.getWgInstance().getPlatform().getRegionContainer().createQuery().getApplicableRegions(BukkitAdapter.adapt(shopLocation));
|
||||
|
||||
ApplicableRegionSet set = WGPlugin.getWgInstance().getPlatform().getRegionContainer().createQuery()
|
||||
.getApplicableRegions(BukkitAdapter.adapt(shopLocation));
|
||||
|
||||
Set<ProtectedRegion> regions = set.getRegions();
|
||||
if(!regions.isEmpty()) {
|
||||
if (!regions.isEmpty()) {
|
||||
|
||||
Iterator<ProtectedRegion> regionIterator = regions.iterator();
|
||||
Map<Integer, ProtectedRegion> regionPriorityMap = new TreeMap<>(Collections.reverseOrder());
|
||||
while(regionIterator.hasNext()) {
|
||||
while (regionIterator.hasNext()) {
|
||||
|
||||
ProtectedRegion region_i = regionIterator.next();
|
||||
regionPriorityMap.put(region_i.getPriority(), region_i);
|
||||
|
||||
}
|
||||
|
||||
return regionPriorityMap.entrySet().iterator().next().getValue().getId();
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,20 @@
|
||||
package io.myzticbean.finditemaddon.Utils.WarpUtils;
|
||||
|
||||
import io.myzticbean.finditemaddon.FindItemAddOnOG;
|
||||
import io.myzticbean.finditemaddon.Dependencies.EssentialsXPlugin;
|
||||
import io.myzticbean.finditemaddon.Dependencies.PlayerWarpsPlugin;
|
||||
import io.myzticbean.finditemaddon.FindItemAddOn;
|
||||
|
||||
public class WarpUtils {
|
||||
|
||||
public static void updateWarps() {
|
||||
if(FindItemAddOn.getConfigProvider().shopGUIItemLoreHasKey("{NEAREST_WARP}")) {
|
||||
if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 1) {
|
||||
if(EssentialsXPlugin.isEnabled()) {
|
||||
EssentialsXPlugin.updateAllWarps();
|
||||
}
|
||||
}
|
||||
else if(FindItemAddOn.getConfigProvider().NEAREST_WARP_MODE == 2) {
|
||||
if(PlayerWarpsPlugin.getIsEnabled()) {
|
||||
PlayerWarpsPlugin.updateAllWarpsFromAPI();
|
||||
}
|
||||
}
|
||||
|
||||
final boolean condition = FindItemAddOnOG.getConfigProvider().shopGUIItemLoreHasKey("{NEAREST_WARP}")
|
||||
&& FindItemAddOnOG.getConfigProvider().NEAREST_WARP_MODE == 1 && EssentialsXPlugin.isEnabled();
|
||||
if (condition) {
|
||||
|
||||
EssentialsXPlugin.updateAllWarps();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +1,84 @@
|
||||
# QuickShop Shop Search AddOn
|
||||
# Works with both Reremake and Hikari forks of QuickShop
|
||||
# Works with both Hikari and Reremake forks of QuickShop
|
||||
|
||||
# PLEASE refer the below link to understand the meaning of all the fields and sample data:
|
||||
# https://gitlab.com/ronsane/QSFindItemAddOn/-/wikis/Sample-config.yml
|
||||
# https://github.com/myzticbean/QSFindItemAddOn/wiki/Sample-config.yml
|
||||
|
||||
plugin-prefix: "&8[&a&lShop Search&8] &r"
|
||||
plugin-prefix: '&8[&a&lShop Search&8] &r'
|
||||
find-item-command:
|
||||
command-alias:
|
||||
- "searchshop"
|
||||
- "shopsearch"
|
||||
- "searchitem"
|
||||
incorrect-usage-message: "&cIncorrect usage! Try &e/finditem &a{TO-BUY | TO-SELL} &6{item type | item name}"
|
||||
invalid-material-message: "&cEither no shops were found or you provided an invalid item! &fTry selecting from autofill."
|
||||
shop-search-loading-message: "&7Searching..."
|
||||
no-shop-found-message: "&7No shops found!"
|
||||
find-item-command-no-permission-message: "&cNo permission!"
|
||||
to-buy-autocomplete: "TO_BUY"
|
||||
to-sell-autocomplete: "TO_SELL"
|
||||
hideshop-autocomplete: "hideshop"
|
||||
revealshop-autocomplete: "revealshop"
|
||||
shop-hide-success-message: "&aShop is now hidden from search list!"
|
||||
shop-reveal-success-message: "&aShop is no longer hidden from search list!"
|
||||
shop-already-hidden-message: "&cThis shop is already hidden!"
|
||||
shop-already-public-message: "&cThis shop is already public!"
|
||||
invalid-shop-block-message: "&cThe block you are looking at is not a shop!"
|
||||
hiding-shop-owner-invalid-message: "&cThat shop is not yours!"
|
||||
- searchshop
|
||||
- shopsearch
|
||||
- searchitem
|
||||
incorrect-usage-message: '&cIncorrect usage! Try &e/find &a{TO-BUY | TO-SELL} &6{item
|
||||
type | item name}'
|
||||
invalid-material-message: '&cEither no shops were found or you provided an invalid
|
||||
item! &fTry selecting from autofill.'
|
||||
shop-search-loading-message: '&7Searching...'
|
||||
no-shop-found-message: '&7No shops found!'
|
||||
find-item-command-no-permission-message: '&cNo permission!'
|
||||
to-buy-autocomplete: TO_BUY
|
||||
to-sell-autocomplete: TO_SELL
|
||||
hideshop-autocomplete: hideshop
|
||||
revealshop-autocomplete: revealshop
|
||||
shop-hide-success-message: '&aShop is now hidden from search list!'
|
||||
shop-reveal-success-message: '&aShop is no longer hidden from search list!'
|
||||
shop-already-hidden-message: '&cThis shop is already hidden!'
|
||||
shop-already-public-message: '&cThis shop is already public!'
|
||||
invalid-shop-block-message: '&cThe block you are looking at is not a shop!'
|
||||
hiding-shop-owner-invalid-message: '&cThat shop is not yours!'
|
||||
shop-sorting-method: 2
|
||||
search-loaded-shops-only: false
|
||||
shop-search-gui-title: "&l» &rShops"
|
||||
shop-search-gui-title: '&l» &rShops'
|
||||
nearest-warp-mode: 1
|
||||
shop-gui-item-lore:
|
||||
- ""
|
||||
- "&fPrice: &a${ITEM_PRICE}"
|
||||
- "&fStock: &7{SHOP_STOCK}"
|
||||
- "&fOwner: &7{SHOP_OWNER}"
|
||||
- "&fLocation: &7{SHOP_LOC}"
|
||||
- "&fWorld: &7{SHOP_WORLD}"
|
||||
- "&fWarp: &7{NEAREST_WARP}"
|
||||
- "&fShop Visits: &7{SHOP_VISITS}"
|
||||
- ""
|
||||
- ''
|
||||
- '&fPrice: &a${ITEM_PRICE}'
|
||||
- '&fStock: &7{SHOP_STOCK}'
|
||||
- '&fOwner: &7{SHOP_OWNER}'
|
||||
- '&fLocation: &7{SHOP_LOC}'
|
||||
- '&fWorld: &7{SHOP_WORLD}'
|
||||
- '&fWarp: &7{NEAREST_WARP}'
|
||||
- '&fShop Visits: &7{SHOP_VISITS}'
|
||||
- ''
|
||||
player-shop-teleportation:
|
||||
direct-shop-tp-mode:
|
||||
tp-player-directly-to-shop: true
|
||||
click-to-teleport-message: "&6&lClick to teleport to the shop!"
|
||||
shop-tp-no-permission-message: "&cYou don't have permission to teleport to shop!"
|
||||
unsafe-shop-area-message: "&cThe area around the shop is unsafe!"
|
||||
tp-player-directly-to-shop: false
|
||||
click-to-teleport-message: '&6&lClick to teleport to the shop!'
|
||||
shop-tp-no-permission-message: '&cYou don''t have permission to teleport to shop!'
|
||||
unsafe-shop-area-message: '&cThe area around the shop is unsafe!'
|
||||
tp-delay-in-seconds: 0
|
||||
tp-delay-message: '&6You will be teleported in &c{DELAY} &6seconds...'
|
||||
tp-to-own-shop-no-permission-message: '&cYou cannot teleport to your own shop!'
|
||||
nearest-warp-tp-mode:
|
||||
tp-player-to-nearest-warp: false
|
||||
shop-gui-back-button-material: ""
|
||||
shop-gui-back-button-text: "&7&l« &cBack"
|
||||
shop-gui-next-button-material: ""
|
||||
shop-gui-next-button-text: "&aNext &7&l»"
|
||||
shop-gui-filler-item: "GRAY_STAINED_GLASS_PANE"
|
||||
shop-gui-close-button-material: "BARRIER"
|
||||
shop-gui-close-button-text: "&fClose Search"
|
||||
shop-gui-back-button-custom-model-data: ""
|
||||
shop-gui-next-button-custom-model-data: ""
|
||||
shop-gui-close-button-custom-model-data: ""
|
||||
shop-navigation-first-page-alert-message: "&cYou are already on first page!"
|
||||
shop-navigation-last-page-alert-message: "&cYou are already on last page!"
|
||||
shop-gui-back-button-material: ''
|
||||
shop-gui-back-button-text: '&7&l« &cBack'
|
||||
shop-gui-next-button-material: ''
|
||||
shop-gui-next-button-text: '&aNext &7&l»'
|
||||
shop-gui-filler-item: GRAY_STAINED_GLASS_PANE
|
||||
shop-gui-close-button-material: BARRIER
|
||||
shop-gui-close-button-text: '&fClose Search'
|
||||
shop-gui-goto-first-page-button-material: ''
|
||||
shop-gui-goto-first-page-button-text: '&7&l« &cGo to First Page'
|
||||
shop-gui-goto-last-page-button-material: ''
|
||||
shop-gui-goto-last-page-button-text: '&aGo to Last Page &7&l»'
|
||||
shop-gui-back-button-custom-model-data: ''
|
||||
shop-gui-next-button-custom-model-data: ''
|
||||
shop-gui-goto-first-page-button-custom-model-data: ''
|
||||
shop-gui-goto-last-page-button-custom-model-data: ''
|
||||
shop-gui-close-button-custom-model-data: ''
|
||||
shop-navigation-first-page-alert-message: '&cYou are already on the first page!'
|
||||
shop-navigation-last-page-alert-message: '&cYou are already on the last page!'
|
||||
shop-player-visit-cooldown-in-minutes: 5
|
||||
ignore-empty-chests: true
|
||||
blacklisted-worlds:
|
||||
- "world_number_1"
|
||||
- "world_number_2"
|
||||
- "HB1-hub"
|
||||
- "SP1-hub"
|
||||
- "Shake_It"
|
||||
- "Ancient_Plateau"
|
||||
|
||||
# Enabling this will spam your console with logs from the plugin
|
||||
# Set this to true only for debugging purposes
|
||||
debug-mode: false
|
||||
config-version: 11
|
||||
config-version: 13
|
||||
@@ -1,31 +1,52 @@
|
||||
name: QSFindItemAddOn
|
||||
version: ${project.version}
|
||||
main: io.myzticbean.finditemaddon.FindItemAddOn
|
||||
api-version: 1.16
|
||||
authors: [ ronsane ]
|
||||
name: ${project.name}
|
||||
version: ${version}
|
||||
main: io.myzticbean.finditemaddon.FindItemAddOnOG
|
||||
api-version: '${apiVersion}'
|
||||
authors: [myzticbean]
|
||||
description: Search items from QuickShop shops with /find.
|
||||
website: https://github.com/myzticbean/QSFindItemAddOn
|
||||
softdepend:
|
||||
- QuickShop
|
||||
- QuickShop-Hikari
|
||||
- PlayerWarps
|
||||
- WorldGuard
|
||||
- QuickShop-OG
|
||||
- QuickShop-OG-Alt
|
||||
- Essentials
|
||||
|
||||
- WorldGuard
|
||||
- PlayerWarps
|
||||
commands:
|
||||
find:
|
||||
description: Search for items from all shops using an interactive GUI.
|
||||
usage: /find
|
||||
aliases: [shopsearch, searchshop, searchitem]
|
||||
permission: finditem.use
|
||||
finditemadmin:
|
||||
description: Admin command for Shop Search addon.
|
||||
usage: /finditemadmin
|
||||
aliases: [fiadmin]
|
||||
permission: finditem.admin
|
||||
permissions:
|
||||
finditem.use:
|
||||
description: Enables players to use the /finditem command
|
||||
description: Allows using /find.
|
||||
default: true
|
||||
finditem.hideshop:
|
||||
description: Enables players to use the /finditem hideshop & /finditem revealshop
|
||||
default: true
|
||||
finditem.reload:
|
||||
description: For OP. Enables use of '/finditem reload' to reload the config
|
||||
default: op
|
||||
finditem.restart:
|
||||
description: For OP. Enables use of '/finditem restart' to restart the plugin
|
||||
description: Allows hiding your own shops from /find search results.
|
||||
default: op
|
||||
finditem.admin:
|
||||
description: For OP. Enables use of all admin commands
|
||||
description: Full admin access to /finditemadmin.
|
||||
default: op
|
||||
children:
|
||||
finditem.reload: true
|
||||
finditem.restart: true
|
||||
finditem.reload:
|
||||
description: Allows reloading this plugin using /finditemadmin reload.
|
||||
default: op
|
||||
finditem.restart:
|
||||
description: Legacy restart subcommand permission.
|
||||
default: op
|
||||
finditem.shoptp:
|
||||
description: If 'allow-direct-shop-tp' is enabled in config, players require this permission to be able to teleport
|
||||
default: op
|
||||
description: Allows teleporting to shops from the search GUI.
|
||||
default: true
|
||||
finditem.shoptp.own:
|
||||
description: Allows teleporting to your own shops.
|
||||
default: op
|
||||
finditem.shoptp-delay.bypass:
|
||||
description: Bypasses any configured shop teleport delay.
|
||||
default: op
|
||||
@@ -1,4 +1,4 @@
|
||||
# QuickShop Reremake and Hikari Shop Search AddOn
|
||||
# QuickShop Hikari and Reremake Shop Search AddOn
|
||||
|
||||
########################################
|
||||
# THIS IS JUST A SAMPLE CONFIG FILE
|
||||
@@ -7,11 +7,11 @@
|
||||
########################################
|
||||
|
||||
# Requires finditem.use permission node for players
|
||||
# Requires finditem.hideshop permission node for running /finditem hideshop or /finditem revealshop
|
||||
# Requires finditem.hideshop permission node for running /find hideshop or /find revealshop
|
||||
# Requires finditem.admin permission node for admin commands (/finditemadmin reload)
|
||||
# Do '/finditemadmin reload' to reload this config and update your changes
|
||||
# Color codes and Hexcodes are supported below
|
||||
# For a hexcode such as #55a800Q you can use 7a800Q below
|
||||
# For a hexcode such as #55a800Q, use MiniMessage format like <#55a800>Q below
|
||||
# If you want to keep a field empty, make it as ""
|
||||
# DON'T leave it empty without quotes, or bad and soul crushing things might happen!
|
||||
|
||||
@@ -21,13 +21,13 @@ plugin-prefix: "&8[&a&lShop Search&8] &r"
|
||||
|
||||
# Below messages will be prefixed with the above specified prefix
|
||||
find-item-command:
|
||||
# Specify a list of command aliases for /finditem
|
||||
# Specify a list of command aliases for /find
|
||||
# If you don't wish to use aliases, make the field as 'command-alias: []'
|
||||
command-alias:
|
||||
- "searchshop"
|
||||
- "shopsearch"
|
||||
- "searchitem"
|
||||
incorrect-usage-message: "&cIncorrect usage! Try &e/finditem &a{TO-BUY | TO-SELL} &6{item type | item name}"
|
||||
incorrect-usage-message: "&cIncorrect usage! Try &e/find &a{TO-BUY | TO-SELL} &6{item type | item name}"
|
||||
invalid-material-message: "&cEither no shops were found or you provided an invalid item! &fTry selecting from autofill."
|
||||
shop-search-loading-message: "&7Searching..."
|
||||
no-shop-found-message: "&7No shops found!"
|
||||
@@ -42,7 +42,7 @@ find-item-command:
|
||||
# NEEDS A SERVER RESTART IF CHANGED
|
||||
hideshop-autocomplete: "hideshop"
|
||||
revealshop-autocomplete: "revealshop"
|
||||
# Messages shown when running /finditem hideshop and /finditem revealshop
|
||||
# Messages shown when running /find hideshop and /find revealshop
|
||||
shop-hide-success-message: "&aShop is now hidden from search list!"
|
||||
shop-reveal-success-message: "&aShop is no longer hidden from search list!"
|
||||
shop-already-hidden-message: "&cThis shop is already hidden!"
|
||||
@@ -113,6 +113,15 @@ player-shop-teleportation:
|
||||
click-to-teleport-message: '&6&lClick to teleport to the shop!'
|
||||
shop-tp-no-permission-message: '&cYou don''t have permission to teleport to shop!'
|
||||
unsafe-shop-area-message: '&cThe area around the shop is unsafe!'
|
||||
# When player clicks on a shop, how long to wait before teleporting to the shop (in seconds)
|
||||
tp-delay-in-seconds: 0
|
||||
# Message to show a player when they have clicked on a shop in GUI (Shown only if there is a non-zero TP delay)
|
||||
# Set as '' if you do not want to show any message to player
|
||||
# {DELAY} will be automatically replaced with value set in 'tp-delay-in-seconds'
|
||||
tp-delay-message: "&6You will be teleported in &c{DELAY} &6seconds..."
|
||||
# Players require 'finditem.shoptp.own' permission to teleport to their own shop.
|
||||
# If no permission, below message will be shown.
|
||||
tp-to-own-shop-no-permission-message: "&cYou cannot teleport to your own shop!"
|
||||
nearest-warp-tp-mode:
|
||||
# The player will be teleported to the nearest warp as if they ran the warp command
|
||||
# Only works with EssentialsX Warps or PlayerWarps (configurable using 'nearest-warp-mode' in this config)
|
||||
@@ -125,25 +134,36 @@ shop-gui-next-button-text: "&aNext &7&l»"
|
||||
shop-gui-filler-item: "GRAY_STAINED_GLASS_PANE"
|
||||
shop-gui-close-button-material: "BARRIER"
|
||||
shop-gui-close-button-text: "&fClose Search"
|
||||
shop-gui-goto-first-page-button-material: ""
|
||||
shop-gui-goto-first-page-button-text: "&7&l« &cGo to First Page"
|
||||
shop-gui-goto-last-page-button-material: ""
|
||||
shop-gui-goto-last-page-button-text: "&aGo to Last Page &7&l»"
|
||||
|
||||
# Enter Item Custom Model Data below, if available, within quotes
|
||||
# or leave as "" if not available
|
||||
shop-gui-back-button-custom-model-data: ""
|
||||
shop-gui-next-button-custom-model-data: ""
|
||||
shop-gui-close-button-custom-model-data: ""
|
||||
|
||||
shop-gui-goto-first-page-button-custom-model-data: ""
|
||||
shop-gui-goto-last-page-button-custom-model-data: ""
|
||||
|
||||
# Alert shown when player is already on first/last page and clicks back/next button
|
||||
shop-navigation-first-page-alert-message: "&cYou are already on first page!"
|
||||
shop-navigation-last-page-alert-message: "&cYou are already on last page!"
|
||||
shop-navigation-first-page-alert-message: "&cYou are already on the first page!"
|
||||
shop-navigation-last-page-alert-message: "&cYou are already on the last page!"
|
||||
|
||||
# Specify (in minutes) how long the plugin will wait before incrementing the player
|
||||
# shop visit when teleporting to it from Search GUI
|
||||
shop-player-visit-cooldown-in-minutes: 5
|
||||
|
||||
# Ignore empty chests from search result
|
||||
ignore-empty-chests: true
|
||||
|
||||
# When fetching shops, the below worlds will be ignored
|
||||
blacklisted-worlds:
|
||||
- "world_number_1"
|
||||
- "world_number_2"
|
||||
- "HB1-hub"
|
||||
- "SP1-hub"
|
||||
- "Shake_It"
|
||||
- "Ancient_Plateau"
|
||||
|
||||
# Enabling this will spam your console with logs from the plugin
|
||||
# Set this to true only for debugging purposes
|
||||
@@ -151,4 +171,4 @@ blacklisted-worlds:
|
||||
debug-mode: false
|
||||
|
||||
# Do not change the below value
|
||||
config-version: 11
|
||||
config-version: 13
|
||||
@@ -0,0 +1 @@
|
||||
[]
|
||||
Reference in new issue
Block a user