Author SHA1 Message Date
NotAlexNoyle 1d0c04ddd1 Point submodules at canonical Gitea repositories 2026-11-01 12:50:43 -05:00
NotAlexNoyle b0f8a4e912 Exclude CODEOWNERS from language statistics 2026-10-31 09:54:53 -04:00
NotAlexNoyle 57bb58988e Add CODEOWNERS (one staff approval) 2026-10-31 09:54:52 -04:00
NotAlexNoyle 58ba3a5a3f Update DiamondBank-OG API 2026-07-29 11:37:52 -04:00
NotAlexNoyle 26a284ea76 Update DiamondBank-OG 2026-07-27 07:58:22 -04:00
NotAlexNoyle e07596a0be Update DiamondBank-OG API 2026-07-22 07:09:31 -04:00
NotAlexNoyle fe006667a1 Update GxUI-OG 2026-07-17 12:46:51 -04:00
NotAlexNoyle a31ccfef84 Fix jar 2026-05-31 11:51:23 -04:00
NotAlexNoyle 7dd7f2908b Vault -> DiamondBankOG, CraftingStore GUI -> GxUI-OG, rename project to CraftingStore-OG 2026-05-27 14:30:13 -04:00
NotAlexNoyle 5e7b1632ab Fix SubstAgent variable substitution 2026-03-31 23:45:41 -04:00
NotAlexNoyle 762705bc7c Use live TrueOG Network config file via true-og/SubstAgent 2026-03-30 03:06:23 -04:00
NotAlexNoyle 123dd06fe2 Formatting 2026-03-15 13:54:06 -04:00
NotAlexNoyle 44129ed663 Merge pull request #1 from true-og/codex/fix-gradle-jar-build-configuration
Fix root Gradle output to ship the server plugin jar
2026-03-13 15:01:50 -04:00
NotAlexNoyle a116346185 Fix root build jar packaging for Bukkit plugin 2026-03-13 14:57:58 -04:00
NotAlexNoyle d25a2519fc Update README with project title
Added project title and description to README.
2026-01-19 10:24:49 -05:00
NotAlexNoyle c8ee722211 Add CraftingStore plugin description to README 2026-01-19 10:24:23 -05:00
NotAlexNoyle 752ac2fd81 Fix build 2025-08-27 17:27:38 -04:00
NotAlexNoyle 45ae2870ca Normalize jarfile name 2025-08-22 11:21:27 -04:00
NotAlexNoyle 02de1eec9b Maven -> Gradle 2025-08-22 11:19:28 -04:00
Thijs Alders e366d322f8 Add support for folia
Bump version to 2.10.0.
2024-05-13 20:16:52 +02:00
Thijs Alders ef3a688c9f Fix for duplicated commands in super rare occasions.
Bump version to 2.9.3.
2024-05-07 19:50:54 +02:00
Thijs Alders 78bf4f9301 Ensure donations jobs will always run on the same single threaded scheduler.
Bump version to 2.9.2.
2024-04-16 23:45:46 +02:00
gecko10000 8108b06f59 Make PAPI expansion persist across reloads (#23) 2024-03-28 16:58:34 +01:00
Thijs Alders 9340a29965 Merge remote-tracking branch 'origin/master' 2023-07-05 20:37:00 +02:00
Thijs Alders 8f59413283 Update dependencies.
Bump version to 2.9.1.
2023-07-05 20:36:44 +02:00
thijs_a 2ea52f9a7d Create LICENSE 2022-12-16 22:12:28 +01:00
Thijs Alders c57293a51a Add support for alternative API endpoint.
Bump version to 2.9.0.
2022-09-17 13:32:09 +02:00
Thijs Alders 2e6d4b02c3 Fix hex code colors not supporting uppercase characters.
Bump XSeries library to 8.6.1.
Bump version to 2.8.1.
2022-02-16 18:24:59 +01:00
Thijs Alders 21950514a8 Fix inventory closing when the user is not allowed to buy the package. 2021-08-03 22:05:26 +02:00
Tim Kwakman 2920732e88 Corrected the API endpoint path. 2021-08-03 17:50:22 +02:00
thijs_a 01f809de73 Merge pull request #19 from CraftingStore/feature/CRAF-111/virtual-currency
Add virtual currency.
2021-08-02 23:40:05 +02:00
Thijs Alders 5cfd48300e Add virtual currency. 2021-07-28 00:19:39 +02:00
Thijs Alders 25d077fd55 Bump version to 2.7.0. 2021-07-09 12:06:00 +02:00
thijs_a a9850c2abe Merge pull request #18 from RoccoDev/master
Fix support for Velocity 3.0.0
2021-07-08 12:04:44 +02:00
RoccoDev f0b9a05de2 Fix support for Velocity 3.0.0
* Removes usages of deprecated Adventure Text API
* Fixes command registration (new 3.x API)
* Bumps API in pom.xml
2021-07-08 09:21:50 +02:00
Thijs Alders 2a24f9a874 Fix another apache library. 2021-07-06 03:36:02 +02:00
Thijs Alders 9d0d680a8c Fix apache library. 2021-06-27 01:31:10 +02:00
Thijs Alders c4d6a5ebbd Fix 1.17 shutdown process. 2021-06-25 20:46:32 +02:00
Thijs Alders b43d668d2e Shade apache commons library into final jar. 2021-06-07 00:10:42 +02:00
thijs_a 1e04991242 Update to use the new xseries xmaterial library. (#16) 2021-06-02 00:34:50 +02:00
Thijs Alders 45c8d6dc40 Add chunked donation processing. 2021-05-25 22:27:41 +02:00
Thijs Alders 6b7e15b3bc Allow hex colors in inventories. 2021-03-03 19:34:46 +01:00
Thijs Alders e22dd9fe31 Add command to enable/disable debug mode without restarting the server. 2021-02-05 18:30:54 +01:00
Thijs Alders 03d7adde87 Fix bug in PlaceholderAPI integration when there are no payments. 2021-02-04 12:30:51 +01:00
Thijs Alders 51d382a737 Fix build of velocity plugin. 2021-01-12 21:26:48 +01:00
Thijs Alders 28717b17f1 Fix placeholderapi dependency. 2020-12-09 11:54:59 +01:00
thijs_a f9bda5ff04 Add support for custom model data. (#9) 2020-10-19 23:03:04 +02:00
94 changed files with 2494 additions and 1245 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
.gitea/CODEOWNERS linguist-detectable=false
+3
View File
@@ -0,0 +1,3 @@
# Pull requests request review from the eligible staff team(s).
# One approval from either an Admin or Developer satisfies branch protection.
* @trueog/Admins @trueog/Developers
+32 -13
View File
@@ -1,17 +1,36 @@
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# Eclipse project files.
.project
.classpath
.settings/
assembly/.project
assembly/.classpath
assembly/.settings/
bukkit/.project
bukkit/.classpath
bukkit/.settings/
core/.project
core/.classpath
core/.settings/
bungee/.project
bungee/.classpath
bungee/.settings/
sponge/.project
sponge/.classpath
sponge/.settings/
velocity/.project
velocity/.classpath
velocity/.settings/
# IntelliJ project files
# Build artifacts.
.gradle/
build/
assembly/build/
bukkit/build/
bungee/build/
core/build/
velocity/build/
# IntelliJ project files.
.idea
*.iml
out
+6
View File
@@ -0,0 +1,6 @@
[submodule "libs/DiamondBank-OG"]
path = libs/DiamondBank-OG
url = https://git.trueog.net/trueog/DiamondBank-OG
[submodule "libs/GxUI-OG"]
path = libs/GxUI-OG
url = https://git.trueog.net/trueog/GxUI-OG
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2022 CraftingStore.net
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+3
View File
@@ -0,0 +1,3 @@
# CraftingStore-OG
Plugin to connect with CraftingStore for granting users purchased ranks.
-98
View File
@@ -1,98 +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>
<parent>
<groupId>net.craftingstore</groupId>
<artifactId>craftingstore</artifactId>
<version>${revision}</version>
</parent>
<artifactId>assembly</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>CraftingStore-${project.version}</finalName>
<relocations>
<relocation>
<pattern>org.apache</pattern>
<shadedPattern>net.craftingstore.libraries.apache</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>net.craftingstore.libraries.json</shadedPattern>
</relocation>
<relocation>
<pattern>io.socket</pattern>
<shadedPattern>net.craftingstore.libraries.socket</shadedPattern>
</relocation>
<relocation>
<pattern>okhttp3</pattern>
<shadedPattern>net.craftingstore.libraries.okhttp3</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>net.craftingstore.libraries.okio</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.craftingstore</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.craftingstore</groupId>
<artifactId>bukkit</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.craftingstore</groupId>
<artifactId>bungee</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.craftingstore</groupId>
<artifactId>sponge</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.craftingstore</groupId>
<artifactId>velocity</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Executable
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/bash
# Fetch all submodule content.
git submodule update --force --recursive --init
+251
View File
@@ -0,0 +1,251 @@
import org.gradle.kotlin.dsl.provideDelegate
/* ------------------------------ Plugins ------------------------------ */
plugins {
id("java") // Import Java plugin.
id("java-library") // Import Java Library plugin.
id("com.diffplug.spotless") version "8.1.0" // Import Spotless plugin.
id("com.gradleup.shadow") version "8.3.9" // Import Shadow plugin.
id("checkstyle") // Import Checkstyle plugin.
eclipse // Import Eclipse plugin.
kotlin("jvm") version "2.1.21" // Import Kotlin JVM plugin.
}
extra["kotlinAttribute"] = Attribute.of("kotlin-tag", Boolean::class.javaObjectType)
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
/* --------------------------- JDK / Kotlin ---------------------------- */
java {
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
toolchain { // Select Java toolchain.
languageVersion.set(JavaLanguageVersion.of(17)) // Use JDK 17.
vendor.set(JvmVendorSpec.GRAAL_VM) // Use GraalVM CE.
}
}
kotlin { jvmToolchain(17) }
/* ----------------------------- Metadata ------------------------------ */
group = "net.craftingstore" // Declare bundle identifier.
version = "2.10.1" // Declare plugin version (will be in .jar).
val apiVersion = "1.19" // Declare minecraft server target version.
extra["apiVersion"] = apiVersion
/* ----------------------------- Resources ----------------------------- */
tasks.named<ProcessResources>("processResources") {
val props = mapOf("version" to version, "apiVersion" to apiVersion)
inputs.properties(props) // Indicates to rerun if version changes.
filesMatching("plugin.yml") { expand(props) }
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
}
/* ---------------------------- Repos ---------------------------------- */
allprojects {
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("file://${System.getProperty("user.home")}/.m2/repository") }
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") }
maven { url = uri("https://rayzr.dev/repo/") }
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
maven { url = uri("https://jitpack.io") }
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
maven { url = uri("https://repo.spongepowered.org/maven") }
maven { url = uri("https://repo.velocitypowered.com/snapshots/") }
System.getProperty("SELF_MAVEN_LOCAL_REPO")?.let {
val dir = file(it)
if (dir.isDirectory) {
println("Using SELF_MAVEN_LOCAL_REPO at: $it")
maven { url = uri("file://${dir.absolutePath}") }
} else {
mavenLocal()
}
}
}
}
/* ---------------------- Java project deps ---------------------------- */
dependencies {
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT") // Declare Purpur API version to be packaged.
compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.2.3") // Import MiniPlaceholders API.
}
/* ---------------------- 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()
enabled = false // Root project does not produce the server-installable plugin jar.
}
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
val copyServerJarToRootBuildLibs by
tasks.registering(Copy::class) {
dependsOn(":assembly:shadowJar")
from(project(":assembly").layout.buildDirectory.file("libs/CraftingStore-OG-${rootProject.version}.jar"))
into(layout.buildDirectory.dir("libs"))
}
tasks.build {
dependsOn(tasks.spotlessApply, copyServerJarToRootBuildLibs)
} // Build depends on spotless and server jar copy.
/* --------------------------- 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.
}
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}") }
}
project(":core") {
java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
dependencies {
compileOnly("com.google.code.gson:gson:2.8.9")
implementation("com.github.thijsa:socket.io-client-java:1.0.3")
implementation("org.apache.httpcomponents:httpclient:4.5.13")
implementation("commons-lang:commons-lang:2.6")
implementation("org.apache.commons:commons-lang3:3.18.0")
implementation("commons-logging:commons-logging:1.2")
implementation("org.apache.commons:commons-text:1.10.0")
}
}
project(":bukkit") {
java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
dependencies {
implementation(project(":core"))
compileOnly("dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT")
compileOnly("net.md-5:bungeecord-chat:1.20-R0.2")
compileOnly("me.clip:placeholderapi:2.11.6")
implementation("com.github.cryptomorin:XSeries:9.4.0")
compileOnlyApi(project(":libs:DiamondBank-OG")) {
attributes { attribute(kotlinAttribute, true) }
} // Import TrueOG network DiamondBank-OG Kotlin API (from source).
implementation(project(":libs:GxUI-OG")) // Import and package TrueOG Network GxUI-OG Java API (from source).
implementation("org.apache.commons:commons-text:1.10.0")
}
tasks.named<ProcessResources>("processResources") {
val props =
mapOf(
"version" to rootProject.version.toString(),
"apiVersion" to (rootProject.extra["apiVersion"]?.toString().orEmpty()),
)
inputs.properties(props)
filesMatching("plugin.yml") { expand(props) }
}
}
project(":sponge") {
java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
dependencies {
implementation(project(":core"))
compileOnly("org.spongepowered:spongeapi:7.1.0")
}
tasks.named<ProcessResources>("processResources") {
val props = mapOf("version" to rootProject.version.toString())
inputs.properties(props)
from("src/main/java") { expand(props) }
}
}
project(":velocity") {
java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
dependencies {
implementation(project(":core"))
compileOnly("com.velocitypowered:velocity-api:3.0.0")
implementation("com.googlecode.json-simple:json-simple:1.1.1") {
exclude(group = "junit", module = "junit")
exclude(group = "org.hamcrest", module = "hamcrest-core")
}
}
tasks.named<ProcessResources>("processResources") {
val props = mapOf("version" to rootProject.version.toString())
inputs.properties(props)
filesMatching("**/*") { expand(props) }
}
}
project(":assembly") {
apply(plugin = "com.gradleup.shadow")
java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
dependencies {
implementation(project(":core"))
implementation(project(":bukkit"))
implementation(project(":sponge"))
implementation(project(":velocity"))
}
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
archiveFileName.set("CraftingStore-OG-${rootProject.version}.jar")
relocate("org.apache.http", "net.craftingstore.libraries.apache.http")
relocate("org.apache.commons.lang", "me.dadus33.libs.commonslang2")
relocate("org.apache.commons.lang3", "net.craftingstore.libraries.apache.commons.lang3")
relocate("org.apache.commons.logging", "net.craftingstore.libraries.apache.commons.logging")
relocate("org.apache.commons.codec", "net.craftingstore.libraries.apache.commons.codec")
relocate("org.apache.commons.text", "net.craftingstore.libraries.apache.commons.text")
relocate("org.json", "net.craftingstore.libraries.json")
relocate("io.socket", "net.craftingstore.libraries.socket")
relocate("okhttp3", "net.craftingstore.libraries.okhttp3")
relocate("okio", "net.craftingstore.libraries.okio")
relocate("com.cryptomorin.xseries", "net.craftingstore.libraries.xseries")
exclude("com/cryptomorin/xseries/messages/**")
exclude("com/cryptomorin/xseries/particles/**")
exclude("com/cryptomorin/xseries/XBiome*")
exclude("com/cryptomorin/xseries/NMSExtras*")
exclude("com/cryptomorin/xseries/NoteBlockMusic*")
exclude("com/cryptomorin/xseries/XSound*")
exclude("com/cryptomorin/xseries/XPotion*")
exclude("com/cryptomorin/xseries/XEnchantment*")
exclude("com/cryptomorin/xseries/XEntity*")
}
tasks.named<Jar>("jar") { enabled = false }
tasks.named("build") { dependsOn(tasks.named("shadowJar")) }
}
-79
View File
@@ -1,79 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>net.craftingstore</groupId>
<artifactId>craftingstore</artifactId>
<version>${revision}</version>
</parent>
<artifactId>bukkit</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<!-- PlaceHolderAPI start -->
<repository>
<id>PlaceholderAPI</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>razyr-dev</id>
<url>https://rayzr.dev/repo/</url>
</repository>
<repository>
<id>codemc</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<!-- PlaceholderRAPI end -->
</repositories>
<dependencies>
<dependency>
<groupId>net.craftingstore</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.3-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId>
<version>1.16-R0.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>PlaceholderAPI</artifactId>
<version>2.10.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -39,4 +39,14 @@ public class BukkitPluginConfiguration implements PluginConfiguration {
public int getTimeBetweenCommands() {
return plugin.getConfig().getInt("time-between-commands", 200);
}
@Override
public String getNotEnoughBalanceMessage() {
return plugin.getConfig().getString("not-enough-balance-message", "&4You do not have enough in-game money in your account! You can also buy this package on the website:");
}
@Override
public boolean isUsingAlternativeApi() {
return plugin.getConfig().getBoolean("use-alternative-api", false);
}
}
@@ -3,10 +3,11 @@ package net.craftingstore.bukkit;
import net.craftingstore.bukkit.commands.BuyCommand;
import net.craftingstore.bukkit.commands.CraftingStoreCommand;
import net.craftingstore.bukkit.config.Config;
import net.craftingstore.bukkit.hooks.DiamondBankHook;
import net.craftingstore.bukkit.hooks.PlaceholderAPIHook;
import net.craftingstore.bukkit.listeners.InventoryListener;
import net.craftingstore.bukkit.listeners.AdminJoinListener;
import net.craftingstore.bukkit.listeners.PendingDonationJoinListener;
import net.craftingstore.bukkit.util.VersionUtil;
import net.craftingstore.core.CraftingStore;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -17,7 +18,8 @@ public class CraftingStoreBukkit extends JavaPlugin {
private CraftingStore craftingStore;
private Config config;
private String prefix = ChatColor.GRAY + "[" + ChatColor.RED + "CraftingStore" + ChatColor.GRAY + "] " + ChatColor.WHITE;
private String prefix = ChatColor.GRAY + "[" + ChatColor.RED + "CraftingStore-OG" + ChatColor.GRAY + "] " + ChatColor.WHITE;
private DiamondBankHook diamondBankHook;
@Override
public void onEnable() {
@@ -29,7 +31,6 @@ public class CraftingStoreBukkit extends JavaPlugin {
this.getCommand("csbuy").setExecutor(new BuyCommand(this));
}
this.getServer().getPluginManager().registerEvents(new InventoryListener(this), this);
this.getServer().getPluginManager().registerEvents(new AdminJoinListener(this), this);
this.getServer().getPluginManager().registerEvents(new PendingDonationJoinListener(this), this);
@@ -38,6 +39,16 @@ public class CraftingStoreBukkit extends JavaPlugin {
new PlaceholderAPIHook(craftingStore);
craftingStore.getLogger().info("Hooked with PlaceholderAPI");
}
// DiamondBank-OG hook
if (Bukkit.getPluginManager().isPluginEnabled("DiamondBank-OG")) {
this.diamondBankHook = new DiamondBankHook(this);
if (this.diamondBankHook.register()) {
craftingStore.getLogger().info("Hooked with DiamondBank-OG");
} else {
craftingStore.getLogger().info("There was a problem hooking with DiamondBank-OG");
this.diamondBankHook = null;
}
}
}
@Override
@@ -62,4 +73,20 @@ public class CraftingStoreBukkit extends JavaPlugin {
public String getPrefix() {
return prefix;
}
public DiamondBankHook getDiamondBankHook() {
return diamondBankHook;
}
public boolean isHookedWithDiamondBank() {
return diamondBankHook != null;
}
public void runSyncTask(Runnable runnable) {
if (VersionUtil.isFoliaSchedulerAvailable()) {
this.getServer().getGlobalRegionScheduler().run(this, (task) -> runnable.run());
} else {
this.getServer().getScheduler().runTask(this, runnable);
}
}
}
@@ -1,6 +1,7 @@
package net.craftingstore.bukkit;
import net.craftingstore.bukkit.events.DonationReceivedEvent;
import net.craftingstore.bukkit.util.VersionUtil;
import net.craftingstore.core.CraftingStorePlugin;
import net.craftingstore.core.PluginConfiguration;
import net.craftingstore.core.logging.CraftingStoreLogger;
@@ -9,6 +10,9 @@ import net.craftingstore.core.models.donation.Donation;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import java.util.concurrent.TimeUnit;
public class CraftingStoreBukkitImpl implements CraftingStorePlugin {
private CraftingStoreBukkit bukkitPlugin;
@@ -28,7 +32,7 @@ public class CraftingStoreBukkitImpl implements CraftingStorePlugin {
return false;
}
}
Server server = bukkitPlugin.getServer();
Server server = this.bukkitPlugin.getServer();
DonationReceivedEvent event = new DonationReceivedEvent(donation);
server.getPluginManager().callEvent(event);
@@ -36,7 +40,7 @@ public class CraftingStoreBukkitImpl implements CraftingStorePlugin {
return false;
}
server.getScheduler().runTask(bukkitPlugin, () -> server.dispatchCommand(server.getConsoleSender(), donation.getCommand()));
this.bukkitPlugin.runSyncTask(() -> server.dispatchCommand(server.getConsoleSender(), donation.getCommand()));
return true;
}
@@ -45,11 +49,19 @@ public class CraftingStoreBukkitImpl implements CraftingStorePlugin {
}
public void registerRunnable(Runnable runnable, int delay, int interval) {
bukkitPlugin.getServer().getScheduler().runTaskTimerAsynchronously(bukkitPlugin, runnable, delay * 20, interval * 20);
if (VersionUtil.isFoliaSchedulerAvailable()) {
this.bukkitPlugin.getServer().getAsyncScheduler().runAtFixedRate(this.bukkitPlugin, task -> runnable.run(), delay, interval, TimeUnit.SECONDS);
} else {
this.bukkitPlugin.getServer().getScheduler().runTaskTimerAsynchronously(this.bukkitPlugin, runnable, delay * 20, interval * 20);
}
}
public void runAsyncTask(Runnable runnable) {
bukkitPlugin.getServer().getScheduler().runTaskAsynchronously(bukkitPlugin, runnable);
if (VersionUtil.isFoliaSchedulerAvailable()) {
this.bukkitPlugin.getServer().getAsyncScheduler().runNow(this.bukkitPlugin, task -> runnable.run());
} else {
this.bukkitPlugin.getServer().getScheduler().runTaskAsynchronously(this.bukkitPlugin, runnable);
}
}
public String getToken() {
@@ -1,15 +1,15 @@
package net.craftingstore.bukkit.commands;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.craftingstore.bukkit.inventory.CraftingStoreGUI;
import net.craftingstore.bukkit.inventory.InventoryBuilder;
import net.craftingstore.core.exceptions.CraftingStoreApiException;
import net.craftingstore.core.models.api.ApiInventory;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import java.util.concurrent.ExecutionException;
@@ -26,19 +26,22 @@ public class BuyCommand implements CommandExecutor {
if (!(sender instanceof Player)) {
return false;
}
if (!instance.getCraftingStore().isEnabled()) {
if (!this.instance.getCraftingStore().isEnabled()) {
sender.sendMessage(instance.getPrefix() + "The plugin has not been set-up correctly. Please contact an administrator.");
return false;
}
Player p = (Player) sender;
Bukkit.getScheduler().runTaskAsynchronously(instance, () -> {
this.instance.getCraftingStore().getImplementation().runAsyncTask(() -> {
try {
InventoryBuilder builder = new InventoryBuilder(this.instance);
CraftingStoreInventory gui = instance.getCraftingStore().getApi().getGUI().get();
Inventory inventory = builder.buildInventory(gui);
Bukkit.getScheduler().runTask(instance, () -> {
ApiInventory gui = instance.getCraftingStore().getApi().getGUI().get();
CraftingStoreGUI inventory = builder.build(
p,
new CraftingStoreInventory(gui.getTitle(), gui.getContent(), gui.getSize())
);
this.instance.runSyncTask(() -> {
if (p.isOnline()) {
p.openInventory(inventory);
inventory.open(false);
}
});
} catch (CraftingStoreApiException | InterruptedException | ExecutionException e) {
@@ -44,6 +44,35 @@ public class CraftingStoreCommand implements CommandExecutor {
});
return true;
}
if ((args.length == 1 || args.length == 2) && args[0].equalsIgnoreCase("debug")) {
boolean isDebugging = this.instance.getCraftingStore().getLogger().isDebugging();
if (args.length == 1) {
sender.sendMessage(String.format(
"%sDebug mode is currently %s.",
this.instance.getPrefix(),
isDebugging ? "enabled" : "disabled"
));
return true;
}
String debugValue = args[1].toLowerCase();
if (debugValue.equalsIgnoreCase("true")) {
isDebugging = true;
} else if (debugValue.equalsIgnoreCase("false")) {
isDebugging = false;
} else {
sender.sendMessage(instance.getPrefix() + "Unknown debug value.");
return true;
}
this.instance.getCraftingStore().getLogger().setDebugging(isDebugging);
instance.getConfig().set("debug", isDebugging);
instance.getConfigWrapper().saveConfig();
sender.sendMessage(String.format(
"%sDebug mode has been %s.",
this.instance.getPrefix(),
isDebugging ? "enabled" : "disabled"
));
return true;
}
sender.sendMessage(ChatColor.GRAY + "" +ChatColor.STRIKETHROUGH + "-----------------------");
sender.sendMessage(ChatColor.DARK_GRAY + ">" + ChatColor.GRAY + " /" + label + " reload" + ChatColor.DARK_GRAY + " -> " + ChatColor.GRAY + "Reload the config.");
@@ -0,0 +1,58 @@
package net.craftingstore.bukkit.hooks;
import java.util.UUID;
import org.bukkit.plugin.RegisteredServiceProvider;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.trueog.diamondbankog.DiamondBankException.EconomyDisabledException;
import net.trueog.diamondbankog.DiamondBankException.InsufficientFundsException;
import net.trueog.diamondbankog.DiamondBankException.InvalidPlayerException;
import net.trueog.diamondbankog.DiamondBankException.PlayerNotOnlineException;
import net.trueog.diamondbankog.api.DiamondBankAPIJava;
public class DiamondBankHook {
private static final String PURCHASE_REASON = "CraftingStore-OG in-game package purchase";
private static final String REFUND_REASON = "CraftingStore-OG in-game package purchase refund";
private final CraftingStoreBukkit instance;
private DiamondBankAPIJava diamondBank;
public DiamondBankHook(CraftingStoreBukkit instance) {
this.instance = instance;
}
public boolean register() {
RegisteredServiceProvider<DiamondBankAPIJava> rsp = instance.getServer().getServicesManager()
.getRegistration(DiamondBankAPIJava.class);
if (rsp == null) {
return false;
}
this.diamondBank = rsp.getProvider();
return true;
}
public boolean hasFunds(UUID playerId, int price) throws EconomyDisabledException {
long shards = toShards(price);
long availableShards = diamondBank.getBankShards(playerId) + diamondBank.getInventoryShards(playerId);
return availableShards >= shards;
}
public void charge(UUID playerId, int price, int packageId) throws EconomyDisabledException, InvalidPlayerException,
PlayerNotOnlineException, InsufficientFundsException {
diamondBank.consumeFromPlayer(playerId, toShards(price), PURCHASE_REASON, notes(packageId));
}
public void refund(UUID playerId, int price, int packageId) throws EconomyDisabledException {
diamondBank.addToPlayerBankShards(playerId, toShards(price), REFUND_REASON, notes(packageId));
}
private long toShards(int price) {
return diamondBank.diamondsToShards((double) price);
}
private String notes(int packageId) {
return "Plugin: CraftingStore-OG; package ID: " + packageId;
}
}
@@ -63,8 +63,8 @@ public class PlaceholderAPIHook extends PlaceholderExpansion {
private String handlePayments(OfflinePlayer player, String s) throws CraftingStoreApiException, ExecutionException, InterruptedException {
ApiPayment[] payments = instance.getApi().getPayments().get();
if (payments == null) {
return ""; // Recent payments are not retrieved yet.
if (payments == null || payments.length == 0) {
return ""; // Recent payments are not retrieved yet or there are no payments.
} else if (s.equalsIgnoreCase("payment")) {
StringBuilder builder = new StringBuilder();
for (ApiPayment payment : payments) {
@@ -94,11 +94,16 @@ public class PlaceholderAPIHook extends PlaceholderExpansion {
@Override
public String getAuthor() {
return "CraftingStore";
return "CraftingStore-OG";
}
@Override
public String getVersion() {
return this.instance.getImplementation().getConfiguration().getVersion();
}
@Override
public boolean persist() {
return true;
}
}
@@ -0,0 +1,85 @@
package net.craftingstore.bukkit.inventory;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.craftingstore.bukkit.util.ChatColorUtil;
import net.craftingstore.core.exceptions.CraftingStoreApiException;
import net.craftingstore.core.models.api.ApiInventory;
import net.craftingstore.core.models.api.ApiPackageInformation;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import net.craftingstore.core.models.api.inventory.InventoryItem;
import net.craftingstore.core.models.api.inventory.InventoryItemIcon;
import net.craftingstore.core.models.api.inventory.InventoryItemType;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBuyablePackage;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
public class BuyInventoryBuilder {
private final CraftingStoreBukkit instance;
private final InventoryBuilder inventoryBuilder;
public BuyInventoryBuilder(CraftingStoreBukkit instance, InventoryBuilder inventoryBuilder) {
this.instance = instance;
this.inventoryBuilder = inventoryBuilder;
}
public CraftingStoreGUI build(Player p, InventoryItemBuyablePackage item, CraftingStoreGUI inventory) throws CraftingStoreApiException, ExecutionException, InterruptedException {
ApiInventory buyMenu = this.instance.getCraftingStore().getApi().getGUI().get().getBuyMenu();
CraftingStoreInventory craftingStoreInventory = new CraftingStoreInventory(buyMenu.getTitle(), buyMenu.getContent(), buyMenu.getSize());
String ip = p.getAddress().getAddress().getHostAddress();
ApiPackageInformation packageInformation = this.instance.getCraftingStore().getApi().getPackageInformation(
p.getName(),
p.getUniqueId(),
ip,
item.getPackageId()
).get();
if (!packageInformation.isAllowedToBuy()) {
p.sendMessage(ChatColorUtil.translate(packageInformation.getMessage()));
this.closeInventory(p);
return null;
}
if (packageInformation.getPrice() != item.getPrice()) {
p.sendMessage(this.instance.getPrefix() + "There was a problem with the payment data. Please try again later.");
this.closeInventory(p);
return null;
}
Map<String, Object> placeholders = new HashMap<>();
placeholders.put("package_name", item.getName());
placeholders.put("package_price_ingame", packageInformation.getPrice());
return this.inventoryBuilder.buildBuyMenu(
p,
craftingStoreInventory,
inventory,
item,
placeholders
);
}
public CraftingStoreGUI buildLoadInventory(Player player) {
InventoryItemIcon icon = new InventoryItemIcon("LIGHT_BLUE_STAINED_GLASS_PANE", 1, 0, null);
InventoryItem[] content = new InventoryItem[9];
for (int i = 0; i < 9; i++) {
content[i] = new InventoryItem("Loading...", null, InventoryItemType.NULL, icon, i);
}
CraftingStoreInventory craftingStoreInventory = new CraftingStoreInventory(
"Loading...",
content,
9
);
return this.inventoryBuilder.build(player, craftingStoreInventory);
}
private void closeInventory(Player p) {
this.instance.runSyncTask(() -> {
if (p.isOnline()) {
p.closeInventory();
}
});
}
}
@@ -0,0 +1,52 @@
package net.craftingstore.bukkit.inventory;
import java.util.Map;
import org.bukkit.entity.Player;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import net.craftingstore.core.models.api.inventory.InventoryItem;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBuyablePackage;
import net.trueog.gxui.GUIBase;
public class CraftingStoreGUI extends GUIBase {
private final InventoryBuilder inventoryBuilder;
private final CraftingStoreInventory inventory;
private final CraftingStoreGUI parentInventory;
private final InventoryItemBuyablePackage itemBuyablePackage;
private final Map<String, ?> placeholders;
public CraftingStoreGUI(
CraftingStoreBukkit instance,
Player player,
InventoryBuilder inventoryBuilder,
CraftingStoreInventory inventory,
CraftingStoreGUI parentInventory,
InventoryItemBuyablePackage itemBuyablePackage,
Map<String, ?> placeholders
) {
super(instance, player, inventoryBuilder.buildTitle(inventory, placeholders), inventory.getSize(), false);
this.inventoryBuilder = inventoryBuilder;
this.inventory = inventory;
this.parentInventory = parentInventory;
this.itemBuyablePackage = itemBuyablePackage;
this.placeholders = placeholders;
}
@Override
public void setupItems() {
for (InventoryItem item : this.inventory.getContent()) {
addItem(item.getIndex(), this.inventoryBuilder.buildItem(item, this.placeholders, this));
}
}
public CraftingStoreGUI getParentInventory() {
return parentInventory;
}
public InventoryItemBuyablePackage getItemBuyablePackage() {
return itemBuyablePackage;
}
}
@@ -1,29 +0,0 @@
package net.craftingstore.bukkit.inventory;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
public class CraftingStoreInventoryHolder implements InventoryHolder {
private CraftingStoreInventory csInventory;
private CraftingStoreInventoryHolder parentInventory;
public CraftingStoreInventoryHolder(CraftingStoreInventory csInventory, CraftingStoreInventoryHolder parentInventory) {
this.csInventory = csInventory;
this.parentInventory = parentInventory;
}
@Override
public Inventory getInventory() {
return null;
}
public CraftingStoreInventory getCsInventory() {
return csInventory;
}
public CraftingStoreInventoryHolder getParentInventory() {
return parentInventory;
}
}
@@ -1,64 +1,172 @@
package net.craftingstore.bukkit.inventory;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.craftingstore.bukkit.util.XMaterial;
import net.craftingstore.core.CraftingStore;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import net.craftingstore.core.models.api.inventory.InventoryItem;
import org.bukkit.Bukkit;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.text.StringSubstitutor;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
import java.util.stream.Collectors;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.craftingstore.bukkit.inventory.handlers.BackButtonHandler;
import net.craftingstore.bukkit.inventory.handlers.BuyButtonHandler;
import net.craftingstore.bukkit.inventory.handlers.BuyablePackageHandler;
import net.craftingstore.bukkit.inventory.handlers.CategoryItemHandler;
import net.craftingstore.bukkit.inventory.handlers.CloseButtonHandler;
import net.craftingstore.bukkit.inventory.handlers.MessageButtonHandler;
import net.craftingstore.bukkit.util.ChatColorUtil;
import net.craftingstore.bukkit.util.VersionUtil;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import net.craftingstore.core.models.api.inventory.InventoryItem;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBackButton;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBuyButton;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBuyablePackage;
import net.craftingstore.core.models.api.inventory.types.InventoryItemCategory;
import net.craftingstore.core.models.api.inventory.types.InventoryItemCloseButton;
import net.craftingstore.core.models.api.inventory.types.InventoryItemMessage;
import net.trueog.gxui.GUIButton;
import net.trueog.gxui.GUIItem;
public class InventoryBuilder {
private CraftingStoreBukkit instance;
private final CraftingStoreBukkit instance;
private final InventoryItemBuilder inventoryItemBuilder;
private final HashMap<Class<? extends InventoryItem>, InventoryItemHandler> handlers = new HashMap<>();
public InventoryBuilder(CraftingStoreBukkit instance) {
this.instance = instance;
this.inventoryItemBuilder = new InventoryItemBuilder(instance);
BuyInventoryBuilder buyInventoryBuilder = new BuyInventoryBuilder(instance, this);
this.handlers.put(InventoryItemBackButton.class, new BackButtonHandler());
this.handlers.put(InventoryItemCategory.class, new CategoryItemHandler(this));
this.handlers.put(InventoryItemCloseButton.class, new CloseButtonHandler());
this.handlers.put(InventoryItemMessage.class, new MessageButtonHandler());
this.handlers.put(InventoryItemBuyablePackage.class, new BuyablePackageHandler(instance, buyInventoryBuilder));
this.handlers.put(InventoryItemBuyButton.class, new BuyButtonHandler(instance, buyInventoryBuilder));
}
public Inventory buildInventory(CraftingStoreInventory csInventory) {
return buildInventory(csInventory, null);
public CraftingStoreGUI build(Player player, CraftingStoreInventory inventory) {
return build(player, inventory, null);
}
public Inventory buildInventory(CraftingStoreInventory csInventory, CraftingStoreInventoryHolder parent) {
String title = csInventory.getTitle();
public CraftingStoreGUI build(Player player, CraftingStoreInventory inventory, CraftingStoreGUI parentInventory) {
return new CraftingStoreGUI(this.instance, player, this, inventory, parentInventory, null, new HashMap<>());
}
public CraftingStoreGUI buildBuyMenu(
Player player,
CraftingStoreInventory inventory,
CraftingStoreGUI parentInventory,
InventoryItemBuyablePackage itemBuyablePackage,
Map<String, ?> placeholders
) {
return new CraftingStoreGUI(
this.instance,
player,
this,
inventory,
parentInventory,
itemBuyablePackage,
placeholders
);
}
String buildTitle(CraftingStoreInventory inventory, Map<String, ?> placeholders) {
String title = inventory.getTitle();
if (title == null || title.isEmpty()) {
title = "CraftingStore";
title = "CraftingStore-OG";
}
title = ChatColor.translateAlternateColorCodes('&', title);
Inventory inventory = Bukkit.createInventory(new CraftingStoreInventoryHolder(csInventory, parent), csInventory.getSize(), title);
for (InventoryItem inventoryItem : csInventory.getContent()) {
XMaterial xMaterial;
if (inventoryItem.getIcon().getMaterial() == null) {
xMaterial = XMaterial.CHEST;
} else {
xMaterial = XMaterial.fromString(inventoryItem.getIcon().getMaterial());
if (xMaterial == null || xMaterial.parseMaterial() == null) {
instance.getCraftingStore().getLogger().debug("Material " + inventoryItem.getIcon().getMaterial() + " not found.");
xMaterial = XMaterial.CHEST;
}
}
ItemStack itemStack = xMaterial.parseItem(inventoryItem.getIcon().getAmount());
ItemMeta meta = itemStack.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', inventoryItem.getName()));
StringSubstitutor stringSubstitutor = new StringSubstitutor(placeholders, "{", "}");
return ChatColorUtil.translate(stringSubstitutor.replace(title)).replace(ChatColor.COLOR_CHAR, '&');
}
GUIItem buildItem(InventoryItem inventoryItem, Map<String, ?> placeholders, CraftingStoreGUI inventory) {
StringSubstitutor stringSubstitutor = new StringSubstitutor(placeholders, "{", "}");
ItemStack itemStack = this.inventoryItemBuilder.getItemStack(
inventoryItem.getIcon().getMaterial(),
inventoryItem.getIcon().getAmount()
);
ItemMeta meta = itemStack.getItemMeta();
if (meta != null) {
meta.setDisplayName(ChatColorUtil.translate(stringSubstitutor.replace(inventoryItem.getName())));
if (inventoryItem.getDescription() != null && inventoryItem.getDescription().length != 0) {
meta.setLore(Arrays.stream(inventoryItem.getDescription())
.map(d -> ChatColor.translateAlternateColorCodes('&', d))
.map(stringSubstitutor::replace)
.map(ChatColorUtil::translate)
.collect(Collectors.toList())
);
}
if (VersionUtil.isCustomModalDataAvailable() && inventoryItem.getIcon().getCustomModelData() != null) {
meta.setCustomModelData(inventoryItem.getIcon().getCustomModelData());
}
itemStack.setItemMeta(meta);
inventory.setItem(inventoryItem.getIndex(), itemStack);
}
return inventory;
GUIItem item = new ItemStackGUIItem(itemStack);
item.setPlayErrorSound(false);
if (this.handlers.containsKey(inventoryItem.getClass())) {
item.button(new InventoryButton(inventoryItem, inventory));
}
return item;
}
@SuppressWarnings("unchecked")
private boolean handleClick(InventoryItem item, CraftingStoreGUI inventory) {
InventoryItemHandler<InventoryItem> handler = this.handlers.get(item.getClass());
if (handler == null) {
return false;
}
handler.handle(inventory.getPlayer(), item, inventory);
return true;
}
private final class InventoryButton implements GUIButton {
private final InventoryItem item;
private final CraftingStoreGUI inventory;
private InventoryButton(InventoryItem item, CraftingStoreGUI inventory) {
this.item = item;
this.inventory = inventory;
}
@Override
public boolean leftClick() {
return handleClick(this.item, this.inventory);
}
@Override
public boolean leftClickShift() {
return leftClick();
}
@Override
public boolean rightClick() {
return leftClick();
}
@Override
public boolean rightClickShift() {
return leftClick();
}
}
private static final class ItemStackGUIItem extends GUIItem {
private final ItemStack itemStack;
private ItemStackGUIItem(ItemStack itemStack) {
this.itemStack = itemStack;
}
@Override
public ItemStack build() {
return itemStack.clone();
}
}
}
@@ -0,0 +1,56 @@
package net.craftingstore.bukkit.inventory;
import com.cryptomorin.xseries.XMaterial;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.craftingstore.bukkit.util.VersionUtil;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.Optional;
public class InventoryItemBuilder {
private CraftingStoreBukkit instance;
public InventoryItemBuilder(CraftingStoreBukkit instance) {
this.instance = instance;
}
public ItemStack getItemStack(String material, int amount) {
ItemStack itemStack;
if (VersionUtil.isGuavaAvailable()) {
// 1.8+
com.cryptomorin.xseries.XMaterial xMaterial;
if (material == null) {
xMaterial = com.cryptomorin.xseries.XMaterial.CHEST;
} else {
Optional<XMaterial> xMaterialOptional = com.cryptomorin.xseries.XMaterial.matchXMaterial(material);
if (!xMaterialOptional.isPresent()) {
instance.getCraftingStore().getLogger().debug("Material " + material + " not found.");
xMaterial = com.cryptomorin.xseries.XMaterial.CHEST;
} else {
xMaterial = xMaterialOptional.get();
}
}
itemStack = xMaterial.parseItem();
if (itemStack == null) {
itemStack = new ItemStack(Material.CHEST);
}
itemStack.setAmount(amount);
} else {
// 1.7 support
net.craftingstore.bukkit.util.XMaterial xMaterial;
if (material == null) {
xMaterial = net.craftingstore.bukkit.util.XMaterial.CHEST;
} else {
xMaterial = net.craftingstore.bukkit.util.XMaterial.fromString(material);
if (xMaterial == null || xMaterial.parseMaterial() == null) {
instance.getCraftingStore().getLogger().debug("Material " + material + " not found.");
xMaterial = net.craftingstore.bukkit.util.XMaterial.CHEST;
}
}
itemStack = xMaterial.parseItem(amount);
}
return itemStack;
}
}
@@ -4,5 +4,5 @@ import net.craftingstore.core.models.api.inventory.InventoryItem;
import org.bukkit.entity.Player;
public interface InventoryItemHandler<T extends InventoryItem> {
void handle(Player p, T item, CraftingStoreInventoryHolder holder);
void handle(Player p, T item, CraftingStoreGUI inventory);
}
@@ -1,25 +1,16 @@
package net.craftingstore.bukkit.inventory.handlers;
import net.craftingstore.bukkit.inventory.CraftingStoreInventoryHolder;
import net.craftingstore.bukkit.inventory.InventoryBuilder;
import net.craftingstore.bukkit.inventory.CraftingStoreGUI;
import net.craftingstore.bukkit.inventory.InventoryItemHandler;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBackButton;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
public class BackButtonHandler implements InventoryItemHandler<InventoryItemBackButton> {
private InventoryBuilder builder;
public BackButtonHandler(InventoryBuilder builder) {
this.builder = builder;
}
@Override
public void handle(Player p, InventoryItemBackButton item, CraftingStoreInventoryHolder holder) {
if (holder.getParentInventory() != null) {
Inventory inventory = builder.buildInventory(holder.getParentInventory().getCsInventory(), holder.getParentInventory().getParentInventory());
p.openInventory(inventory);
public void handle(Player p, InventoryItemBackButton item, CraftingStoreGUI inventory) {
if (inventory.getParentInventory() != null) {
inventory.getParentInventory().open(false);
}
}
}
@@ -0,0 +1,166 @@
package net.craftingstore.bukkit.inventory.handlers;
import java.util.UUID;
import org.bukkit.entity.Player;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.craftingstore.bukkit.inventory.BuyInventoryBuilder;
import net.craftingstore.bukkit.inventory.CraftingStoreGUI;
import net.craftingstore.bukkit.inventory.InventoryItemHandler;
import net.craftingstore.bukkit.util.ChatColorUtil;
import net.craftingstore.core.models.api.ApiPackageInformation;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBuyButton;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBuyablePackage;
import net.trueog.diamondbankog.DiamondBankException;
import net.trueog.diamondbankog.DiamondBankException.InsufficientFundsException;
public class BuyButtonHandler implements InventoryItemHandler<InventoryItemBuyButton> {
private final CraftingStoreBukkit instance;
private final BuyInventoryBuilder buyInventoryBuilder;
public BuyButtonHandler(CraftingStoreBukkit instance, BuyInventoryBuilder buyInventoryBuilder) {
this.instance = instance;
this.buyInventoryBuilder = buyInventoryBuilder;
}
@Override
public void handle(Player p, InventoryItemBuyButton item, CraftingStoreGUI inventory) {
if (inventory.getItemBuyablePackage() == null) {
throw new RuntimeException("BuyButtonHandler only works in a buy menu");
}
InventoryItemBuyablePackage itemBuyablePackage = inventory.getItemBuyablePackage();
InventoryItemBuyButton.InventoryItemBuyButtonAction action = item.getAction();
if (action.equals(InventoryItemBuyButton.InventoryItemBuyButtonAction.ONLINE)) {
for (String message : itemBuyablePackage.getMessages()) {
p.sendMessage(ChatColorUtil.translate(message));
}
p.closeInventory();
return;
}
if (action.equals(InventoryItemBuyButton.InventoryItemBuyButtonAction.IN_GAME)) {
if (!this.instance.isHookedWithDiamondBank()) {
p.sendMessage(instance.getPrefix() + "CraftingStore-OG is not hooked with DiamondBank-OG!");
p.closeInventory();
return;
}
UUID playerId = p.getUniqueId();
String playerName = p.getName();
String ip = p.getAddress().getAddress().getHostAddress();
CraftingStoreGUI loading = this.buyInventoryBuilder.buildLoadInventory(p);
loading.open(false);
this.instance.getCraftingStore().getImplementation().runAsyncTask(() -> {
try {
ApiPackageInformation packageInformation = this.instance.getCraftingStore().getApi().getPackageInformation(
playerName,
playerId,
ip,
itemBuyablePackage.getPackageId()
).get();
if (!packageInformation.isAllowedToBuy()) {
p.sendMessage(ChatColorUtil.translate(packageInformation.getMessage()));
for (String message : itemBuyablePackage.getMessages()) {
p.sendMessage(ChatColorUtil.translate(message));
}
closeInventory(p);
return;
}
if (packageInformation.getPrice() != itemBuyablePackage.getPrice()) {
p.sendMessage(this.instance.getPrefix() + "There was a problem with the payment data. Please try again later.");
closeInventory(p);
return;
}
if (!this.instance.getDiamondBankHook().hasFunds(playerId, packageInformation.getPrice())) {
p.sendMessage(ChatColorUtil.translate(
this.instance.getCraftingStore().getImplementation().getConfiguration().getNotEnoughBalanceMessage()
));
closeInventory(p);
return;
}
try {
this.instance.getDiamondBankHook().charge(
playerId,
packageInformation.getPrice(),
itemBuyablePackage.getPackageId()
);
} catch (InsufficientFundsException exception) {
p.sendMessage(ChatColorUtil.translate(
this.instance.getCraftingStore().getImplementation().getConfiguration().getNotEnoughBalanceMessage()
));
closeInventory(p);
return;
} catch (DiamondBankException exception) {
exception.printStackTrace();
p.sendMessage(this.instance.getPrefix() + "There was a problem with the transaction. Please try again later");
closeInventory(p);
return;
}
try {
boolean success = this.instance.getCraftingStore().getApi().createPayment(
playerName,
packageInformation.getPrice(),
new int[]{itemBuyablePackage.getPackageId()}
).get();
if (success) {
p.sendMessage(ChatColorUtil.translate(itemBuyablePackage.getSuccessMessage()));
closeInventory(p);
return;
}
throw new RuntimeException("Failed to create a transaction at CraftingStore. Giving money back.");
} catch (Exception exception) {
exception.printStackTrace();
this.instance.getCraftingStore().getLogger().error(String.format(
"Unable to create a transaction for player %s with package %s and cost %s. Giving the player's money back...",
playerName,
itemBuyablePackage.getPackageId(),
packageInformation.getPrice()
));
try {
this.instance.getDiamondBankHook().refund(
playerId,
packageInformation.getPrice(),
itemBuyablePackage.getPackageId()
);
} catch (DiamondBankException rollbackException) {
rollbackException.printStackTrace();
p.sendMessage(this.instance.getPrefix() + "There was a problem with the transaction, and we were unable to give you back your money. Please contact an administrator");
this.instance.getCraftingStore().getLogger().error(String.format(
"Unable to give the player's money back. Player: %s, cost: %s.",
playerName,
packageInformation.getPrice()
));
closeInventory(p);
return;
}
p.sendMessage(this.instance.getPrefix() + "A problem occurred while creating your payment. Your money has been given back. Please try again later");
closeInventory(p);
}
} catch (DiamondBankException exception) {
exception.printStackTrace();
closeInventory(p);
p.sendMessage(this.instance.getPrefix()
+ "There was a problem accessing DiamondBank-OG. Please try again later.");
} catch (Exception exception) {
exception.printStackTrace();
closeInventory(p);
p.sendMessage(this.instance.getPrefix() + "A problem occurred. Please try again later.");
}
});
}
}
private void closeInventory(Player p) {
this.instance.runSyncTask(() -> {
if (p.isOnline()) {
p.closeInventory();
}
});
}
}
@@ -0,0 +1,79 @@
package net.craftingstore.bukkit.inventory.handlers;
import java.util.UUID;
import org.bukkit.entity.Player;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.craftingstore.bukkit.inventory.BuyInventoryBuilder;
import net.craftingstore.bukkit.inventory.CraftingStoreGUI;
import net.craftingstore.bukkit.inventory.InventoryItemHandler;
import net.craftingstore.bukkit.util.ChatColorUtil;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBuyablePackage;
import net.trueog.diamondbankog.DiamondBankException.EconomyDisabledException;
public class BuyablePackageHandler implements InventoryItemHandler<InventoryItemBuyablePackage> {
private final CraftingStoreBukkit instance;
private final BuyInventoryBuilder buyInventoryBuilder;
public BuyablePackageHandler(CraftingStoreBukkit instance, BuyInventoryBuilder buyInventoryBuilder) {
this.instance = instance;
this.buyInventoryBuilder = buyInventoryBuilder;
}
@Override
public void handle(Player p, InventoryItemBuyablePackage item, CraftingStoreGUI inventory) {
if (!this.instance.isHookedWithDiamondBank()) {
p.sendMessage(instance.getPrefix() + "CraftingStore-OG is not hooked with DiamondBank-OG!");
p.closeInventory();
return;
}
CraftingStoreGUI loading = this.buyInventoryBuilder.buildLoadInventory(p);
loading.open(false);
UUID playerId = p.getUniqueId();
this.instance.getCraftingStore().getImplementation().runAsyncTask(() -> {
try {
if (!this.instance.getDiamondBankHook().hasFunds(playerId, item.getPrice())) {
this.instance.runSyncTask(() -> {
if (p.isOnline()) {
p.sendMessage(ChatColorUtil.translate(this.instance.getCraftingStore().getImplementation()
.getConfiguration().getNotEnoughBalanceMessage()));
for (String message : item.getMessages()) {
p.sendMessage(ChatColorUtil.translate(message));
}
p.closeInventory();
}
});
return;
}
CraftingStoreGUI buyMenu = this.buyInventoryBuilder.build(p, item, inventory);
if (buyMenu != null) {
this.instance.runSyncTask(() -> {
if (p.isOnline()) {
buyMenu.open(false);
}
});
}
} catch (EconomyDisabledException exception) {
exception.printStackTrace();
this.instance.runSyncTask(() -> {
if (p.isOnline()) {
p.sendMessage(instance.getPrefix()
+ "There was a problem accessing DiamondBank-OG. Please try again later.");
p.closeInventory();
}
});
} catch (Exception exception) {
exception.printStackTrace();
this.instance.runSyncTask(() -> {
if (p.isOnline()) {
p.closeInventory();
}
});
}
});
}
}
@@ -1,12 +1,11 @@
package net.craftingstore.bukkit.inventory.handlers;
import net.craftingstore.bukkit.inventory.CraftingStoreInventoryHolder;
import net.craftingstore.bukkit.inventory.CraftingStoreGUI;
import net.craftingstore.bukkit.inventory.InventoryBuilder;
import net.craftingstore.bukkit.inventory.InventoryItemHandler;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import net.craftingstore.core.models.api.inventory.types.InventoryItemCategory;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
public class CategoryItemHandler implements InventoryItemHandler<InventoryItemCategory> {
@@ -17,9 +16,8 @@ public class CategoryItemHandler implements InventoryItemHandler<InventoryItemCa
}
@Override
public void handle(Player p, InventoryItemCategory category, CraftingStoreInventoryHolder holder) {
public void handle(Player p, InventoryItemCategory category, CraftingStoreGUI inventory) {
CraftingStoreInventory csInventory = new CraftingStoreInventory(category.getTitle(), category.getContent(), category.getSize());
Inventory inventory = builder.buildInventory(csInventory, holder);
p.openInventory(inventory);
builder.build(p, csInventory, inventory).open(false);
}
}
@@ -1,13 +1,13 @@
package net.craftingstore.bukkit.inventory.handlers;
import net.craftingstore.bukkit.inventory.CraftingStoreInventoryHolder;
import net.craftingstore.bukkit.inventory.CraftingStoreGUI;
import net.craftingstore.bukkit.inventory.InventoryItemHandler;
import net.craftingstore.core.models.api.inventory.types.InventoryItemCloseButton;
import org.bukkit.entity.Player;
public class CloseButtonHandler implements InventoryItemHandler<InventoryItemCloseButton> {
@Override
public void handle(Player p, InventoryItemCloseButton item, CraftingStoreInventoryHolder holder) {
public void handle(Player p, InventoryItemCloseButton item, CraftingStoreGUI inventory) {
p.closeInventory();
}
}
@@ -1,6 +1,6 @@
package net.craftingstore.bukkit.inventory.handlers;
import net.craftingstore.bukkit.inventory.CraftingStoreInventoryHolder;
import net.craftingstore.bukkit.inventory.CraftingStoreGUI;
import net.craftingstore.bukkit.inventory.InventoryItemHandler;
import net.craftingstore.bukkit.util.ChatColorUtil;
import net.craftingstore.core.models.api.inventory.types.InventoryItemMessage;
@@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
public class MessageButtonHandler implements InventoryItemHandler<InventoryItemMessage> {
@Override
public void handle(Player p, InventoryItemMessage item, CraftingStoreInventoryHolder holder) {
public void handle(Player p, InventoryItemMessage item, CraftingStoreGUI inventory) {
for (String message : item.getMessages()) {
p.sendMessage(ChatColorUtil.translate(message));
}
@@ -35,9 +35,9 @@ public class AdminJoinListener implements Listener {
if (!instance.getCraftingStore().isEnabled()) {
if (update != null && update.shouldDisable()) {
p.sendMessage(instance.getPrefix() + "The CraftingStore plugin has been disabled because this is an outdated version. Please update the plugin.");
p.sendMessage(instance.getPrefix() + "The CraftingStore-OG plugin has been disabled because this is an outdated version. Please update the plugin.");
} else {
p.sendMessage(instance.getPrefix() + "The CraftingStore plugin has not been set-up correctly. Please set your API key using /craftingstore key <your key>.");
p.sendMessage(instance.getPrefix() + "The CraftingStore-OG plugin has not been set-up correctly. Please set your API key using /craftingstore key <your key>.");
}
}
}
@@ -1,64 +0,0 @@
package net.craftingstore.bukkit.listeners;
import net.craftingstore.bukkit.CraftingStoreBukkit;
import net.craftingstore.bukkit.inventory.CraftingStoreInventoryHolder;
import net.craftingstore.bukkit.inventory.InventoryBuilder;
import net.craftingstore.bukkit.inventory.InventoryItemHandler;
import net.craftingstore.bukkit.inventory.handlers.BackButtonHandler;
import net.craftingstore.bukkit.inventory.handlers.CategoryItemHandler;
import net.craftingstore.bukkit.inventory.handlers.CloseButtonHandler;
import net.craftingstore.bukkit.inventory.handlers.MessageButtonHandler;
import net.craftingstore.core.models.api.inventory.*;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBackButton;
import net.craftingstore.core.models.api.inventory.types.InventoryItemCategory;
import net.craftingstore.core.models.api.inventory.types.InventoryItemCloseButton;
import net.craftingstore.core.models.api.inventory.types.InventoryItemMessage;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import java.util.HashMap;
public class InventoryListener implements Listener {
private HashMap<Class<? extends InventoryItem>, InventoryItemHandler> handlers = new HashMap<>();
private CraftingStoreBukkit instance;
private InventoryBuilder inventoryBuilder;
public InventoryListener(CraftingStoreBukkit instance) {
this.instance = instance;
this.inventoryBuilder = new InventoryBuilder(instance);
this.handlers.put(InventoryItemBackButton.class, new BackButtonHandler(this.inventoryBuilder));
this.handlers.put(InventoryItemCategory.class, new CategoryItemHandler(this.inventoryBuilder));
this.handlers.put(InventoryItemCloseButton.class, new CloseButtonHandler());
this.handlers.put(InventoryItemMessage.class, new MessageButtonHandler());
}
@EventHandler
public void onClick(InventoryClickEvent e) {
// Fix "Negative, non outside slot -1" error.
if (e.getRawSlot() < 0) {
return;
}
if (e.getInventory() == null
|| e.getInventory().getHolder() == null
|| !(e.getInventory().getHolder() instanceof CraftingStoreInventoryHolder)) {
return;
}
e.setCancelled(true);
Player p = (Player) e.getWhoClicked();
CraftingStoreInventoryHolder holder = (CraftingStoreInventoryHolder) e.getInventory().getHolder();
InventoryItem item = holder.getCsInventory().getByIndex(e.getRawSlot());
if (item == null) {
return;
}
if (handlers.containsKey(item.getClass())) {
handlers.get(item.getClass()).handle(p, item, holder);
}
}
}
@@ -4,19 +4,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ChatColorUtil {
private static final Pattern HEX_PATTERN = Pattern.compile("&#(\\w{5}[0-9a-f])");
private static boolean hasHexAvailable = false;
static {
try {
Class.forName("net.md_5.bungee.api.ChatColor").getMethod("of", String.class);
hasHexAvailable = true;
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
}
}
private static final Pattern HEX_PATTERN = Pattern.compile("&#(\\w{5}[0-9a-f])", Pattern.CASE_INSENSITIVE);
public static String translate(String textToTranslate) {
if (hasHexAvailable) {
if (VersionUtil.isHexAvailable()) {
return translateHexCodes(textToTranslate);
}
return org.bukkit.ChatColor.translateAlternateColorCodes('&', textToTranslate);
@@ -0,0 +1,47 @@
package net.craftingstore.bukkit.util;
public class VersionUtil {
private static boolean hexAvailable = false;
private static boolean customModalDataAvailable = false;
private static boolean guavaAvailable = false;
private static boolean foliaSchedulerAvailable = false;
static {
try {
Class.forName("net.md_5.bungee.api.ChatColor").getMethod("of", String.class);
hexAvailable = true;
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
}
try {
Class.forName("org.bukkit.inventory.meta.ItemMeta").getMethod("hasCustomModelData");
customModalDataAvailable = true;
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
}
try {
Class.forName("com.google.common.cache.CacheBuilder").getMethod("build");
guavaAvailable = true;
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
}
try {
Class.forName("org.bukkit.Bukkit").getMethod("getAsyncScheduler");
foliaSchedulerAvailable = true;
} catch (NoSuchMethodException | ClassNotFoundException ignored) {
}
}
public static boolean isHexAvailable() {
return hexAvailable;
}
public static boolean isCustomModalDataAvailable() {
return customModalDataAvailable;
}
public static boolean isGuavaAvailable() {
return guavaAvailable;
}
public static boolean isFoliaSchedulerAvailable() {
return foliaSchedulerAvailable;
}
}
@@ -894,7 +894,7 @@ public enum XMaterial {
public ItemStack parseItem(int amount) {
Material mat = parseMaterial();
if (isNewVersion()) {
return new ItemStack(mat);
return new ItemStack(mat, amount);
}
return new ItemStack(mat, amount, (byte) data);
}
+2 -2
View File
@@ -1,2 +1,2 @@
api-key: ''
disable-buy-command: false
api-key: '^{CRAFTINGSTORE_API_TOKEN}'
disable-buy-command: false
+7 -7
View File
@@ -1,14 +1,14 @@
name: CraftingStore
name: CraftingStore-OG
main: net.craftingstore.bukkit.CraftingStoreBukkit
version: ${craftingstore-version}
version: ${version}
authors: [Tim_kwakman, thijs_a]
prefix: CraftingStore
softdepend: [PlaceholderAPI]
api-version: "1.13"
prefix: CraftingStore-OG
softdepend: [PlaceholderAPI, DiamondBank-OG]
api-version: '${apiVersion}'
folia-supported: true
commands:
craftingstore:
description: CraftingStore command
description: CraftingStore-OG command
aliases: [cs]
csbuy:
description: Buy command
aliases: [buy]
-54
View File
@@ -1,54 +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>
<parent>
<groupId>net.craftingstore</groupId>
<artifactId>craftingstore</artifactId>
<version>${revision}</version>
</parent>
<artifactId>bungee</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.craftingstore</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.10-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -1,42 +0,0 @@
package net.craftingstore.bungee;
import net.craftingstore.core.PluginConfiguration;
public class BungeePluginConfiguration implements PluginConfiguration {
private CraftingStoreBungee plugin;
BungeePluginConfiguration(CraftingStoreBungee plugin) {
this.plugin = plugin;
}
@Override
public String getName() {
return "BungeeCord";
}
@Override
public String[] getMainCommands() {
return new String[]{"csb"};
}
@Override
public String getVersion() {
return plugin.getDescription().getVersion();
}
@Override
public String getPlatform() {
return plugin.getProxy().getVersion();
}
@Override
public boolean isBuyCommandEnabled() {
return false;
}
@Override
public int getTimeBetweenCommands() {
return plugin.getConfig().getInt("time-between-commands", 200);
}
}
@@ -1,47 +0,0 @@
package net.craftingstore.bungee;
import net.craftingstore.bungee.commands.CraftingStoreCommand;
import net.craftingstore.bungee.config.Config;
import net.craftingstore.bungee.listeners.AdminJoinListener;
import net.craftingstore.bungee.listeners.PendingDonationJoinListener;
import net.craftingstore.core.CraftingStore;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
public class CraftingStoreBungee extends Plugin {
private Config config;
private CraftingStore craftingStore;
private String prefix = ChatColor.GRAY + "[" + ChatColor.RED + "CraftingStore" + ChatColor.GRAY + "] " + ChatColor.WHITE;
@Override
public void onEnable() {
config = new Config(this, "config.yml");
this.craftingStore = new CraftingStore(new CraftingStoreBungeeImpl(this));
getProxy().getPluginManager().registerCommand(this, new CraftingStoreCommand(this));
getProxy().getPluginManager().registerListener(this, new AdminJoinListener(this));
getProxy().getPluginManager().registerListener(this, new PendingDonationJoinListener(this));
}
@Override
public void onDisable() {
craftingStore.setEnabled(false);
}
public Configuration getConfig() {
return config.getConfig();
}
public Config getConfigWrapper() {
return config;
}
public CraftingStore getCraftingStore() {
return craftingStore;
}
public String getPrefix() {
return prefix;
}
}
@@ -1,66 +0,0 @@
package net.craftingstore.bungee;
import net.craftingstore.bungee.events.DonationReceivedEvent;
import net.craftingstore.core.CraftingStorePlugin;
import net.craftingstore.core.PluginConfiguration;
import net.craftingstore.core.logging.CraftingStoreLogger;
import net.craftingstore.core.logging.impl.JavaLogger;
import net.craftingstore.core.models.donation.Donation;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.concurrent.TimeUnit;
public class CraftingStoreBungeeImpl implements CraftingStorePlugin {
private CraftingStoreBungee bungeePlugin;
private JavaLogger logger;
private BungeePluginConfiguration configuration;
CraftingStoreBungeeImpl(CraftingStoreBungee bungeePlugin) {
this.bungeePlugin = bungeePlugin;
this.configuration = new BungeePluginConfiguration(bungeePlugin);
this.logger = new JavaLogger(bungeePlugin.getLogger());
this.logger.setDebugging(bungeePlugin.getConfig().getBoolean("debug", false));
}
public boolean executeDonation(final Donation donation) {
ProxyServer proxy = bungeePlugin.getProxy();
if (donation.getPlayer().isRequiredOnline()) {
ProxiedPlayer player = proxy.getPlayer(donation.getPlayer().getUsername());
if (player == null || !player.isConnected()) {
return false;
}
}
DonationReceivedEvent event = new DonationReceivedEvent(donation);
proxy.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
proxy.getScheduler().runAsync(bungeePlugin, () -> proxy.getPluginManager().dispatchCommand(proxy.getConsole(), donation.getCommand()));
return true;
}
public CraftingStoreLogger getLogger() {
return this.logger;
}
public void registerRunnable(Runnable runnable, int delay, int interval) {
bungeePlugin.getProxy().getScheduler().schedule(bungeePlugin, runnable, delay, interval, TimeUnit.SECONDS);
}
public void runAsyncTask(Runnable runnable) {
bungeePlugin.getProxy().getScheduler().runAsync(bungeePlugin, runnable);
}
public String getToken() {
return bungeePlugin.getConfig().getString("api-key");
}
@Override
public PluginConfiguration getConfiguration() {
return this.configuration;
}
}
@@ -1,53 +0,0 @@
package net.craftingstore.bungee.commands;
import net.craftingstore.bungee.CraftingStoreBungee;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command;
import java.util.concurrent.ExecutionException;
public class CraftingStoreCommand extends Command {
private CraftingStoreBungee instance;
public CraftingStoreCommand(CraftingStoreBungee instance) {
super("csb", instance.getCraftingStore().ADMIN_PERMISSION);
this.instance = instance;
}
@Override
public void execute(CommandSender sender, String[] args) {
if (!sender.hasPermission(instance.getCraftingStore().ADMIN_PERMISSION)) {
sender.sendMessage(new TextComponent(instance.getPrefix() + "You don't have the required permission!"));
return;
}
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
instance.getCraftingStore().reload();
sender.sendMessage(new TextComponent(instance.getPrefix() + "The plugin is reloading!"));
return;
}
if (args.length == 2 && args[0].equalsIgnoreCase("key")) {
instance.getConfig().set("api-key", args[1]);
instance.getConfigWrapper().saveConfig();
instance.getProxy().getScheduler().runAsync(instance, () -> {
try {
if (instance.getCraftingStore().reload().get()) {
sender.sendMessage(new TextComponent(instance.getPrefix() + "The new API key has been set in the config, and the plugin has been reloaded."));
} else {
sender.sendMessage(new TextComponent(instance.getPrefix() + "The API key is invalid. The plugin will not work until you set a valid API key."));
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
});
return;
}
sender.sendMessage(new TextComponent(ChatColor.GRAY + "" +ChatColor.STRIKETHROUGH + "-----------------------"));
sender.sendMessage(new TextComponent(ChatColor.DARK_GRAY + ">" + ChatColor.GRAY + " /csb reload" + ChatColor.DARK_GRAY + " -> " + ChatColor.GRAY + "Reload the config."));
sender.sendMessage(new TextComponent(ChatColor.DARK_GRAY + ">" + ChatColor.GRAY + " /csb key <your key>" + ChatColor.DARK_GRAY + " -> " + ChatColor.GRAY + "Update the key."));
sender.sendMessage(new TextComponent(ChatColor.GRAY + "" +ChatColor.STRIKETHROUGH + "-----------------------"));
}
}
@@ -1,71 +0,0 @@
package net.craftingstore.bungee.config;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.logging.Level;
public class Config {
private Plugin instance;
private Configuration configuration;
private String filename;
public Config(Plugin instance, String filename) {
this.instance = instance;
this.filename = filename;
instance.getDataFolder().mkdir();
File file = new File(instance.getDataFolder(), filename);
if (!file.exists()) {
InputStream is = instance.getResourceAsStream(filename);
if (is != null) {
instance.getLogger().info("Copying default config file.");
try {
Files.copy(is, file.toPath());
} catch (IOException e) {
instance.getLogger().log(Level.SEVERE, "An error occurred while copying the default config file " + filename + ".", e);
}
} else {
try {
file.createNewFile();
} catch (IOException e) {
instance.getLogger().log(Level.SEVERE, "An error occurred while creating the config file " + filename + ".", e);
}
}
}
reload();
}
public void reload() {
try {
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(instance.getDataFolder(), filename));
} catch (IOException e) {
instance.getLogger().log(Level.SEVERE, "An error occurred while loading the config file " + filename + ".", e);
}
}
public Configuration getConfig() {
if (configuration == null) {
reload();
}
return configuration;
}
public void saveConfig() {
try {
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(instance.getDataFolder(), filename));
} catch (IOException e) {
instance.getLogger().log(Level.SEVERE, "An error occured while saving the config file " + filename + ".", e);
}
}
}
@@ -1,89 +0,0 @@
package net.craftingstore.bungee.events;
import net.craftingstore.core.models.donation.Donation;
import net.md_5.bungee.api.plugin.Cancellable;
import net.md_5.bungee.api.plugin.Event;
import java.util.UUID;
public class DonationReceivedEvent extends Event implements Cancellable {
@Deprecated
private String command;
@Deprecated
private String username;
@Deprecated
private UUID uuid;
@Deprecated
private String packageName;
@Deprecated
private int packagePrice;
@Deprecated
private int couponDiscount;
private Donation donation;
private boolean cancelled = false;
@Deprecated
public DonationReceivedEvent(String command, String username, UUID uuid, String packageName, int packagePrice, int couponDiscount) {
this.command = command;
this.username = username;
this.uuid = uuid;
this.packageName = packageName;
this.packagePrice = packagePrice;
this.couponDiscount = couponDiscount;
}
public DonationReceivedEvent(Donation donation) {
this.command = donation.getCommand();
this.username = donation.getPlayer().getUsername();
this.uuid = donation.getPlayer().getUUID();
this.packageName = donation.getPackage().getName();
this.packagePrice = donation.getPackage().getPrice();
this.couponDiscount = donation.getDiscount();
this.donation = donation;
}
public Donation getDonation() {
return this.donation;
}
@Deprecated
public String getCommand() {
return command;
}
@Deprecated
public String getUsername() {
return username;
}
@Deprecated
public UUID getUuid() {
return uuid;
}
@Deprecated
public String getPackageName() {
return packageName;
}
@Deprecated
public int getPackagePrice() {
return packagePrice;
}
@Deprecated
public int getCouponDiscount() {
return couponDiscount;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}
@@ -1,45 +0,0 @@
package net.craftingstore.bungee.listeners;
import net.craftingstore.bungee.CraftingStoreBungee;
import net.craftingstore.core.models.api.misc.CraftingStoreInformation;
import net.craftingstore.core.models.api.misc.UpdateInformation;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
public class AdminJoinListener implements Listener {
private CraftingStoreBungee instance;
public AdminJoinListener(CraftingStoreBungee instance) {
this.instance = instance;
}
@EventHandler
public void onPostLogin(PostLoginEvent e) {
ProxiedPlayer p = e.getPlayer();
if (!p.hasPermission(instance.getCraftingStore().ADMIN_PERMISSION)) {
return;
}
CraftingStoreInformation information = instance.getCraftingStore().getInformation();
UpdateInformation update = null;
if (information != null) {
update = information.getUpdateInformation();
// Update notification
if (update != null) {
p.sendMessage(new TextComponent(instance.getPrefix() + update.getMessage()));
}
}
if (!instance.getCraftingStore().isEnabled()) {
if (update != null && update.shouldDisable()) {
p.sendMessage(new TextComponent(instance.getPrefix() + "The CraftingStore plugin has been disabled because this is an outdated version. Please update the plugin."));
} else {
p.sendMessage(new TextComponent(instance.getPrefix() + "The CraftingStore plugin has not been set-up correctly. Please set your API key using /csb key <your key>."));
}
}
}
}
@@ -1,31 +0,0 @@
package net.craftingstore.bungee.listeners;
import net.craftingstore.bungee.CraftingStoreBungee;
import net.craftingstore.core.exceptions.CraftingStoreApiException;
import net.craftingstore.core.jobs.ProcessPendingPaymentsJob;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
public class PendingDonationJoinListener implements Listener {
private final CraftingStoreBungee instance;
public PendingDonationJoinListener(CraftingStoreBungee instance) {
this.instance = instance;
}
@EventHandler
public void onPostLogin(PostLoginEvent e) {
ProxiedPlayer p = e.getPlayer();
String username = p.getName();
instance.getCraftingStore().getImplementation().runAsyncTask(() -> {
try {
new ProcessPendingPaymentsJob(instance.getCraftingStore(), username);
} catch (CraftingStoreApiException ex) {
ex.printStackTrace();
}
});
}
}
-5
View File
@@ -1,5 +0,0 @@
name: CraftingStore
main: net.craftingstore.bungee.CraftingStoreBungee
version: ${craftingstore-version}
author: thijs_a
prefix: CraftingStore
+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
<property name="severity" value="error"/>
</module>
<module name="TreeWalker">
<module name="FinalLocalVariable"/>
<module name="AvoidStarImport"/>
<module name="Indentation">
<property name="severity" value="ignore"/>
</module>
</module>
<module name="RegexpSingleline">
<property name="format" value="\borg\.junit\.jupiter\.api\.Assertions\.fail\s*\(\s*&quot;Not yet implemented&quot;\s*\)\s*;"/>
<property name="message" value="Remove placeholder fail() and implement the test."/>
<property name="ignoreCase" value="true"/>
<property name="severity" value="warning"/>
</module>
<module name="RegexpSingleline">
<property name="format" value="(?&lt;!\w)fail\s*\(\s*&quot;Not yet implemented&quot;\s*\)\s*;"/>
<property name="message" value="Remove placeholder fail() and implement the test."/>
<property name="severity" value="warning"/>
</module>
</module>
+404
View File
@@ -0,0 +1,404 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="23">
<profile kind="CodeFormatterProfile" name="TrueOG Network Formatting" version="23">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_not_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case_after_arrow" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.align_arrows_in_switch_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow" value="20"/>
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line_on_wrap"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
</profile>
</profiles>
-53
View File
@@ -1,53 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
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>
<parent>
<groupId>net.craftingstore</groupId>
<artifactId>craftingstore</artifactId>
<version>${revision}</version>
</parent>
<artifactId>core</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.thijsa</groupId>
<artifactId>socket.io-client-java</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
</dependencies>
</project>
@@ -141,4 +141,8 @@ public class CraftingStore {
public Map<Integer, Donation> getPendingDonations() {
return pendingDonations;
}
public DonationRunner getDonationRunner() {
return donationRunner;
}
}
@@ -1,14 +1,11 @@
package net.craftingstore.core;
import net.craftingstore.core.exceptions.CraftingStoreApiException;
import net.craftingstore.core.models.api.ApiCategory;
import net.craftingstore.core.models.api.ApiPayment;
import net.craftingstore.core.models.api.ApiTopDonator;
import net.craftingstore.core.models.api.Root;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import net.craftingstore.core.models.api.*;
import net.craftingstore.core.models.api.misc.CraftingStoreInformation;
import net.craftingstore.core.models.donation.Donation;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -20,7 +17,7 @@ public abstract class CraftingStoreAPI {
public abstract Future<CraftingStoreInformation> getInformation() throws CraftingStoreApiException;
public abstract Future<Root> checkKey() throws CraftingStoreApiException;
public abstract Future<Root<?>> checkKey() throws CraftingStoreApiException;
public abstract Future<Donation[]> getDonationQueue() throws CraftingStoreApiException;
@@ -28,12 +25,23 @@ public abstract class CraftingStoreAPI {
public abstract Future<ApiPayment[]> getPayments() throws CraftingStoreApiException;
public abstract Future<ApiCategory[]> getCategories() throws CraftingStoreApiException;
public abstract Future<CraftingStoreInventory> getGUI() throws CraftingStoreApiException;
public abstract Future<ApiInventory> getGUI() throws CraftingStoreApiException;
public abstract Future<ApiTopDonator[]> getTopDonators() throws CraftingStoreApiException;
public abstract Future<ApiPackageInformation> getPackageInformation(
String inGameName,
UUID uuid,
String ip,
int packageId
) throws CraftingStoreApiException;
public abstract Future<Boolean> createPayment(
String inGameName,
int price,
int[] packages
) throws CraftingStoreApiException;
public String getToken() {
return this.token;
}
@@ -12,4 +12,8 @@ public interface PluginConfiguration {
boolean isBuyCommandEnabled();
int getTimeBetweenCommands();
String getNotEnoughBalanceMessage();
boolean isUsingAlternativeApi();
}
@@ -5,7 +5,11 @@ import java.io.IOException;
public class CraftingStoreApiException extends Exception {
public CraftingStoreApiException(String s, IOException e) {
super(s, e.getCause());
e.printStackTrace();
super(s, e);
}
@Override
public void printStackTrace() {
super.getCause().printStackTrace();
}
}
@@ -8,11 +8,13 @@ import net.craftingstore.core.exceptions.CraftingStoreApiException;
import net.craftingstore.core.http.util.InformationAdapter;
import net.craftingstore.core.http.util.InventoryAdapter;
import net.craftingstore.core.http.util.JsonResponseHandler;
import net.craftingstore.core.http.util.JsonResponseHandlerV7;
import net.craftingstore.core.models.api.*;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import net.craftingstore.core.models.api.inventory.InventoryItem;
import net.craftingstore.core.models.api.misc.CraftingStoreInformation;
import net.craftingstore.core.models.api.provider.ProviderInformation;
import net.craftingstore.core.models.api.request.PackageInformationRequest;
import net.craftingstore.core.models.api.request.PaymentCreateRequest;
import net.craftingstore.core.models.donation.Donation;
import net.craftingstore.core.models.donation.DonationPackage;
import net.craftingstore.core.models.donation.DonationPlayer;
@@ -24,23 +26,26 @@ import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.math.BigDecimal;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Future;
public class CraftingStoreAPIImpl extends CraftingStoreAPI {
private final String BASE_URL = "https://api.craftingstore.net/v4/";
private final String BASE_URL = "https://api.craftingstore.net/";
private final String ALTERNATIVE_BASE_URL = "https://api-fallback.craftingstore.net/";
private CraftingStore instance;
private Gson gson;
private HttpClient httpClient;
@@ -65,7 +70,7 @@ public class CraftingStoreAPIImpl extends CraftingStoreAPI {
public Future<CraftingStoreInformation> getInformation() throws CraftingStoreApiException {
return executor.submit(() -> {
try {
HttpPost request = post("info");
HttpPost request = post("v4/info");
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("version", instance.getImplementation().getConfiguration().getVersion()));
params.add(new BasicNameValuePair("platform", instance.getImplementation().getConfiguration().getPlatform()));
@@ -77,10 +82,10 @@ public class CraftingStoreAPIImpl extends CraftingStoreAPI {
});
}
public Future<Root> checkKey() throws CraftingStoreApiException {
public Future<Root<?>> checkKey() throws CraftingStoreApiException {
return executor.submit(() -> {
try {
return httpClient.execute(get("validateToken"), new JsonResponseHandler<>(gson, Root.class));
return httpClient.execute(get("v4/validateToken"), new JsonResponseHandler<>(gson, Root.class));
} catch (IOException e) {
throw new CraftingStoreApiException("Check Key call failed", e);
}
@@ -90,7 +95,7 @@ public class CraftingStoreAPIImpl extends CraftingStoreAPI {
public Future<Donation[]> getDonationQueue() throws CraftingStoreApiException {
return executor.submit(() -> {
try {
ApiDonation[] apiDonations = httpClient.execute(get("queue"), new JsonResponseHandler<>(gson, ApiDonation[].class));
ApiDonation[] apiDonations = httpClient.execute(get("v4/queue"), new JsonResponseHandler<>(gson, ApiDonation[].class));
return Arrays.stream(apiDonations).map(apiDonation -> {
DonationPlayer player = new DonationPlayer(apiDonation.getMcName(), apiDonation.getUuid(), apiDonation.getRequireOnline());
DonationPackage donationPackage = new DonationPackage(apiDonation.getPackageName(), apiDonation.getPackagePriceCents());
@@ -112,7 +117,7 @@ public class CraftingStoreAPIImpl extends CraftingStoreAPI {
public void completeDonations(int[] ids) throws CraftingStoreApiException {
executor.submit(() -> {
try {
HttpPost request = post("queue/markComplete");
HttpPost request = post("v4/queue/markComplete");
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("removeIds", gson.toJson(ids)));
request.setEntity(new UrlEncodedFormEntity(params));
@@ -128,28 +133,17 @@ public class CraftingStoreAPIImpl extends CraftingStoreAPI {
public Future<ApiPayment[]> getPayments() throws CraftingStoreApiException {
return executor.submit(() -> {
try {
return httpClient.execute(get("buyers/recent"), new JsonResponseHandler<>(gson, ApiPayment[].class));
return httpClient.execute(get("v4/buyers/recent"), new JsonResponseHandler<>(gson, ApiPayment[].class));
} catch (IOException e) {
throw new CraftingStoreApiException("Payments call failed", e);
}
});
}
@Deprecated
public Future<ApiCategory[]> getCategories() throws CraftingStoreApiException {
public Future<ApiInventory> getGUI() throws CraftingStoreApiException {
return executor.submit(() -> {
try {
return httpClient.execute(get("plugin/inventory"), new JsonResponseHandler<>(gson, ApiCategory[].class));
} catch (IOException e) {
throw new CraftingStoreApiException("Categories call failed", e);
}
});
}
public Future<CraftingStoreInventory> getGUI() throws CraftingStoreApiException {
return executor.submit(() -> {
try {
return httpClient.execute(get("plugin/gui"), new JsonResponseHandler<>(gson, CraftingStoreInventory.class));
return httpClient.execute(get("v4/plugin/gui"), new JsonResponseHandler<>(gson, ApiInventory.class));
} catch (IOException e) {
throw new CraftingStoreApiException("Inventory call failed", e);
}
@@ -159,15 +153,67 @@ public class CraftingStoreAPIImpl extends CraftingStoreAPI {
public Future<ApiTopDonator[]> getTopDonators() throws CraftingStoreApiException {
return executor.submit(() -> {
try {
return httpClient.execute(get("buyers/top"), new JsonResponseHandler<>(gson, ApiTopDonator[].class));
return httpClient.execute(get("v4/buyers/top"), new JsonResponseHandler<>(gson, ApiTopDonator[].class));
} catch (IOException e) {
throw new CraftingStoreApiException("Top Donators call failed", e);
}
});
}
public Future<ApiPackageInformation> getPackageInformation(
String inGameName,
UUID uuid,
String ip,
int packageId
) throws CraftingStoreApiException {
return executor.submit(() -> {
try {
HttpPost request = post("v7/package/ingame/information");
PackageInformationRequest packageInformationRequest = new PackageInformationRequest(
inGameName,
uuid.toString(),
ip,
packageId
);
request.setEntity(new StringEntity(gson.toJson(packageInformationRequest), ContentType.APPLICATION_JSON));
return httpClient.execute(request, new JsonResponseHandlerV7<>(gson, ApiPackageInformation.class));
} catch (IOException e) {
throw new CraftingStoreApiException("Get package information call failed", e);
}
});
}
public Future<Boolean> createPayment(
String inGameName,
int price,
int[] packages
) throws CraftingStoreApiException {
return executor.submit(() -> {
try {
HttpPost request = post("v7/payments");
PaymentCreateRequest paymentCreateRequest = new PaymentCreateRequest(
inGameName,
"Paid with in-game currency",
"ingame",
price,
null,
true,
packages
);
request.setEntity(new StringEntity(gson.toJson(paymentCreateRequest), ContentType.APPLICATION_JSON));
HttpResponse response = httpClient.execute(request);
EntityUtils.consumeQuietly(response.getEntity());
return true;
} catch (IOException e) {
instance.getLogger().error("Payment create call failed");
e.printStackTrace();
return false;
}
});
}
private HttpGet get(String endpoint) {
HttpGet request = new HttpGet(BASE_URL + endpoint);
HttpGet request = new HttpGet(this.getEndpoint(endpoint));
request.setConfig(RequestConfig.custom()
.setSocketTimeout(10000)
.setConnectTimeout(10000)
@@ -178,7 +224,7 @@ public class CraftingStoreAPIImpl extends CraftingStoreAPI {
}
private HttpPost post(String endpoint) {
HttpPost request = new HttpPost(BASE_URL + endpoint);
HttpPost request = new HttpPost(this.getEndpoint(endpoint));
request.setConfig(RequestConfig.custom()
.setSocketTimeout(10000)
.setConnectTimeout(10000)
@@ -194,4 +240,11 @@ public class CraftingStoreAPIImpl extends CraftingStoreAPI {
request.addHeader("version", this.instance.getImplementation().getConfiguration().getVersion());
request.addHeader("platform", this.instance.getImplementation().getConfiguration().getPlatform());
}
private String getEndpoint(String endpoint) {
if (this.instance.getImplementation().getConfiguration().isUsingAlternativeApi()) {
return this.ALTERNATIVE_BASE_URL + endpoint;
}
return this.BASE_URL + endpoint;
}
}
@@ -2,9 +2,9 @@ package net.craftingstore.core.http;
import net.craftingstore.core.CraftingStore;
import net.craftingstore.core.exceptions.CraftingStoreApiException;
import net.craftingstore.core.models.api.ApiInventory;
import net.craftingstore.core.models.api.ApiPayment;
import net.craftingstore.core.models.api.ApiTopDonator;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import java.util.HashMap;
import java.util.concurrent.ExecutionException;
@@ -12,20 +12,20 @@ import java.util.concurrent.Future;
public class CraftingStoreCachedAPI extends CraftingStoreAPIImpl {
private HashMap<String, Object> cache = new HashMap<>();
private final HashMap<String, Object> cache = new HashMap<>();
public CraftingStoreCachedAPI(CraftingStore instance) {
super(instance);
}
@Override
public Future<CraftingStoreInventory> getGUI() throws CraftingStoreApiException {
public Future<ApiInventory> getGUI() throws CraftingStoreApiException {
return executor.submit(() -> {
String key = "plugin/inventory";
if (!cache.containsKey(key)) {
cache.put(key, super.getGUI().get());
}
return (CraftingStoreInventory) cache.get(key);
return (ApiInventory) cache.get(key);
});
}
@@ -13,7 +13,7 @@ public class InventoryAdapter implements JsonDeserializer<InventoryItem> {
JsonPrimitive prim = (JsonPrimitive) jsonObject.get("type");
InventoryItemType itemType = InventoryItemType.valueOf(prim.getAsString());
Class klass = itemType.getActualClass();
Class<? extends InventoryItem> klass = itemType.getActualClass();
return context.deserialize(jsonObject, klass);
}
}
@@ -0,0 +1,45 @@
package net.craftingstore.core.http.util;
import com.google.gson.Gson;
import net.craftingstore.core.models.api.RootV7;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
public class JsonResponseHandlerV7<T> implements ResponseHandler<T> {
private Gson gson;
private Class<T> aClass;
public JsonResponseHandlerV7(Gson gson, Class<T> aClass) {
this.gson = gson;
this.aClass = aClass;
}
public T handleResponse(HttpResponse response) throws IOException {
StatusLine statusLine = response.getStatusLine();
HttpEntity entity = response.getEntity();
if (statusLine.getStatusCode() >= 300) {
throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
}
if (entity == null) {
throw new ClientProtocolException("Response contains no content");
}
String value = EntityUtils.toString(entity);
if (aClass == RootV7.class) {
return gson.fromJson(value, aClass);
}
RootV7<T> result = gson.fromJson(value, new GenericOf<>(RootV7.class, aClass));
return result.getData();
}
}
@@ -8,6 +8,9 @@ import java.util.*;
import java.util.stream.Stream;
public class ExecuteDonationsJob {
public static final int CHUNK_SIZE = 25;
private CraftingStore instance;
private Donation[] donations;
@@ -18,7 +21,7 @@ public class ExecuteDonationsJob {
}
private void execute() throws CraftingStoreApiException {
this.instance.getLogger().debug("Executing ExecuteDonationsJob.");
this.instance.getLogger().debug(String.format("Executing ExecuteDonationsJob for %d donations.", this.donations.length));
Map<Donation, Boolean> donations = new HashMap<>();
for (int i = 0; i < this.donations.length; i++) {
@@ -61,7 +64,7 @@ public class ExecuteDonationsJob {
// Check if the donation has been executed and is in the cache
if (entry.getValue() && instance.getPendingDonations().containsKey(entry.getKey().getId())) {
instance.getPendingDonations().remove(entry.getKey().getId());
} else if (!entry.getValue()){
} else if (!entry.getValue()) {
// Add the donation to the list of pending donations so it gets executed when the player gets online.
instance.getPendingDonations().put(entry.getKey().getId(), entry.getKey());
}
@@ -0,0 +1,26 @@
package net.craftingstore.core.models.api;
import net.craftingstore.core.models.api.inventory.InventoryItem;
public class ApiInventory {
private String title;
private InventoryItem[] content;
private int size;
private ApiInventory buyMenu;
public String getTitle() {
return title;
}
public InventoryItem[] getContent() {
return content;
}
public int getSize() {
return size;
}
public ApiInventory getBuyMenu() {
return buyMenu;
}
}
@@ -0,0 +1,19 @@
package net.craftingstore.core.models.api;
public class ApiPackageInformation {
private boolean mayBuy;
private int price;
private String message;
public boolean isAllowedToBuy() {
return mayBuy;
}
public int getPrice() {
return price;
}
public String getMessage() {
return message;
}
}
@@ -0,0 +1,17 @@
package net.craftingstore.core.models.api;
public class RootV7<T> {
private T data;
private boolean success;
private String message;
public T getData() {
return data;
}
public boolean isSuccess() {
return success;
}
}
@@ -1,11 +1,23 @@
package net.craftingstore.core.models.api.inventory;
public class InventoryItem {
private String name;
private String[] description;
private InventoryItemType type;
private InventoryItemIcon icon;
private int index;
protected String name;
protected String[] description;
protected InventoryItemType type;
protected InventoryItemIcon icon;
protected int index;
public InventoryItem() {
}
public InventoryItem(String name, String[] description, InventoryItemType type, InventoryItemIcon icon, int index) {
this.name = name;
this.description = description;
this.type = type;
this.icon = icon;
this.index = index;
}
public String getName() {
return name;
@@ -2,9 +2,20 @@ package net.craftingstore.core.models.api.inventory;
public class InventoryItemIcon {
private String material;
private int amount;
private Integer amount;
private int customModelData;
private InventoryItemEnhancement[] enhancements;
public InventoryItemIcon() {
}
public InventoryItemIcon(String material, Integer amount, int customModelData, InventoryItemEnhancement[] enhancements) {
this.material = material;
this.amount = amount;
this.customModelData = customModelData;
this.enhancements = enhancements;
}
public String getMaterial() {
return material;
}
@@ -13,6 +24,10 @@ public class InventoryItemIcon {
return amount;
}
public Integer getCustomModelData() {
return customModelData;
}
public InventoryItemEnhancement[] getEnhancements() {
return enhancements;
}
@@ -1,23 +1,24 @@
package net.craftingstore.core.models.api.inventory;
import net.craftingstore.core.models.api.inventory.types.InventoryItemBackButton;
import net.craftingstore.core.models.api.inventory.types.InventoryItemCategory;
import net.craftingstore.core.models.api.inventory.types.InventoryItemCloseButton;
import net.craftingstore.core.models.api.inventory.types.InventoryItemMessage;
import net.craftingstore.core.models.api.inventory.types.*;
public enum InventoryItemType {
NULL(null),
CATEGORY(InventoryItemCategory.class),
MESSAGE(InventoryItemMessage.class),
BACK(InventoryItemBackButton.class),
CLOSE(InventoryItemCloseButton.class);
CLOSE(InventoryItemCloseButton.class),
BUYABLE_PACKAGE(InventoryItemBuyablePackage.class),
BUY_DETAILS(InventoryItemBuyDetails.class),
BUY_BUTTON(InventoryItemBuyButton.class);
private Class c;
private final Class<? extends InventoryItem> c;
InventoryItemType(Class c) {
InventoryItemType(Class<? extends InventoryItem> c) {
this.c = c;
}
public Class getActualClass() {
public Class<? extends InventoryItem> getActualClass() {
return c;
}
}
@@ -1,6 +1,19 @@
package net.craftingstore.core.models.api.inventory.types;
import net.craftingstore.core.models.api.inventory.InventoryItem;
import net.craftingstore.core.models.api.inventory.InventoryItemIcon;
import net.craftingstore.core.models.api.inventory.InventoryItemType;
public class InventoryItemBackButton extends InventoryItem {
public InventoryItemBackButton() {}
public InventoryItemBackButton(
String name,
String[] description,
InventoryItemIcon icon,
int index
) {
super(name, description, InventoryItemType.BACK, icon, index);
}
}
@@ -0,0 +1,29 @@
package net.craftingstore.core.models.api.inventory.types;
import net.craftingstore.core.models.api.inventory.InventoryItem;
import net.craftingstore.core.models.api.inventory.InventoryItemIcon;
import net.craftingstore.core.models.api.inventory.InventoryItemType;
public class InventoryItemBuyButton extends InventoryItem {
private final InventoryItemBuyButtonAction action;
public InventoryItemBuyButton(
String name,
String[] description,
InventoryItemIcon icon,
int index,
InventoryItemBuyButtonAction action
) {
super(name, description, InventoryItemType.BUY_BUTTON, icon, index);
this.action = action;
}
public InventoryItemBuyButtonAction getAction() {
return action;
}
public enum InventoryItemBuyButtonAction {
IN_GAME,
ONLINE,
}
}
@@ -0,0 +1,19 @@
package net.craftingstore.core.models.api.inventory.types;
import net.craftingstore.core.models.api.inventory.InventoryItem;
import net.craftingstore.core.models.api.inventory.InventoryItemIcon;
import net.craftingstore.core.models.api.inventory.InventoryItemType;
public class InventoryItemBuyDetails extends InventoryItem {
public InventoryItemBuyDetails() {}
public InventoryItemBuyDetails(
String name,
String[] description,
InventoryItemIcon icon,
int index
) {
super(name, description, InventoryItemType.BUY_DETAILS, icon, index);
}
}
@@ -0,0 +1,30 @@
package net.craftingstore.core.models.api.inventory.types;
import net.craftingstore.core.models.api.inventory.InventoryItem;
public class InventoryItemBuyablePackage extends InventoryItem {
private int price;
private int packageId;
private String[] messages;
private String successMessage;
public InventoryItemBuyablePackage() {
}
public int getPrice() {
return price;
}
public int getPackageId() {
return packageId;
}
public String[] getMessages() {
return messages;
}
public String getSuccessMessage() {
return successMessage;
}
}
@@ -1,11 +1,29 @@
package net.craftingstore.core.models.api.inventory.types;
import net.craftingstore.core.models.api.inventory.InventoryItem;
import net.craftingstore.core.models.api.inventory.InventoryItemIcon;
import net.craftingstore.core.models.api.inventory.InventoryItemType;
public class InventoryItemMessage extends InventoryItem {
private String[] messages;
private boolean close;
public InventoryItemMessage() {
}
public InventoryItemMessage(
String name,
String[] description,
InventoryItemIcon icon,
int index,
String[] messages,
boolean close
) {
super(name, description, InventoryItemType.MESSAGE, icon, index);
this.messages = messages;
this.close = close;
}
public String[] getMessages() {
return messages;
}
@@ -0,0 +1,17 @@
package net.craftingstore.core.models.api.request;
import java.io.Serializable;
public class PackageInformationRequest implements Serializable {
String inGameName;
String uuid;
String ip;
int packageId;
public PackageInformationRequest(String inGameName, String uuid, String ip, int packageId) {
this.inGameName = inGameName;
this.uuid = uuid;
this.ip = ip;
this.packageId = packageId;
}
}
@@ -0,0 +1,29 @@
package net.craftingstore.core.models.api.request;
public class PaymentCreateRequest {
String inGameName;
String notes;
String gateway;
int inGamePricePaid;
Integer pricePaid;
boolean executeCommands;
int[] packages;
public PaymentCreateRequest(
String inGameName,
String notes,
String gateway,
int inGamePricePaid,
Integer pricePaid,
boolean executeCommands,
int[] packages
) {
this.inGameName = inGameName;
this.notes = notes;
this.gateway = gateway;
this.inGamePricePaid = inGamePricePaid;
this.pricePaid = pricePaid;
this.executeCommands = executeCommands;
this.packages = packages;
}
}
@@ -35,6 +35,8 @@ public class SocketProvider extends CraftingStoreProvider {
break;
}
}
// Wait some time on SocketIO
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -4,10 +4,14 @@ import net.craftingstore.core.CraftingStore;
import net.craftingstore.core.exceptions.CraftingStoreApiException;
import net.craftingstore.core.jobs.ExecuteDonationsJob;
import net.craftingstore.core.models.donation.Donation;
import net.craftingstore.core.util.ArrayUtil;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Stream;
public class DonationRunner {
@@ -19,12 +23,18 @@ public class DonationRunner {
}
public void runDonations() {
this.craftingStore.getLogger().debug("Scheduling new execute donations job");
this.craftingStore.getLogger().debug("Scheduling new donation runner job.");
this.executor.submit(() -> {
this.craftingStore.getLogger().debug("Executing donation queue.");
this.craftingStore.getLogger().debug("Requesting donation queue.");
try {
Donation[] donationQueue = this.craftingStore.getApi().getDonationQueue().get();
new ExecuteDonationsJob(this.craftingStore, donationQueue);
this.craftingStore.getLogger().debug(String.format("Found %d donations in queue.", donationQueue.length));
Donation[][] chunked = ArrayUtil.splitArray(donationQueue, ExecuteDonationsJob.CHUNK_SIZE);
for (int i = 0; i < chunked.length; i++) {
Donation[] chunk = chunked[i];
this.craftingStore.getLogger().debug(String.format("Creating ExecuteDonationsJob for chunk %d/%d", i + 1, chunked.length));
new ExecuteDonationsJob(this.craftingStore, chunk);
}
} catch (CraftingStoreApiException | InterruptedException | ExecutionException e) {
if (craftingStore.getLogger().isDebugging()) {
e.printStackTrace();
@@ -34,4 +44,8 @@ public class DonationRunner {
}
});
}
public ExecutorService getExecutor() {
return executor;
}
}
@@ -4,7 +4,9 @@ import net.craftingstore.core.CraftingStore;
import net.craftingstore.core.exceptions.CraftingStoreApiException;
import net.craftingstore.core.jobs.ExecuteDonationsJob;
import net.craftingstore.core.models.donation.Donation;
import net.craftingstore.core.util.ArrayUtil;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;
public class DonationChecker implements Runnable {
@@ -21,23 +23,14 @@ public class DonationChecker implements Runnable {
return;
}
if (instance.getProviderSelector().isConnected()) {
// Only run this runnable every 25 minutes when we are connected to a websocket.
long target = System.currentTimeMillis() - (25 * 60 * 1000);
// Only run this runnable every 30 minutes when we are connected to a websocket.
long target = System.currentTimeMillis() - (30 * 60 * 1000);
if (lastRun > target) {
return;
}
}
lastRun = System.currentTimeMillis();
this.instance.getLogger().debug("Checking for donations.");
try {
Donation[] donationQueue = instance.getApi().getDonationQueue().get();
new ExecuteDonationsJob(instance, donationQueue);
} catch (CraftingStoreApiException | InterruptedException | ExecutionException e) {
if (instance.getLogger().isDebugging()) {
e.printStackTrace();
} else {
instance.getLogger().error("Failed to check for donations. If this issue persists, please contact support at https://craftingstore.net.");
}
}
this.instance.getLogger().debug("Checking for donations by interval.");
this.instance.getDonationRunner().runDonations();
}
}
@@ -0,0 +1,24 @@
package net.craftingstore.core.util;
import java.lang.reflect.Array;
import java.util.Arrays;
public class ArrayUtil {
public static <T> T[][] splitArray(T[] arrayToSplit, int chunkSize) {
if (chunkSize <= 0) {
return (T[][]) Array.newInstance(arrayToSplit.getClass(), 0);
}
int rest = arrayToSplit.length % chunkSize;
int chunks = arrayToSplit.length / chunkSize + (rest > 0 ? 1 : 0);
T[][] arrays = (T[][]) Array.newInstance(arrayToSplit.getClass(), chunks);
for (int i = 0; i < (rest > 0 ? chunks - 1 : chunks); i++) {
arrays[i] = Arrays.copyOfRange(arrayToSplit, i * chunkSize, i * chunkSize + chunkSize);
}
if (rest > 0) {
arrays[chunks - 1] = Arrays.copyOfRange(arrayToSplit, (chunks - 1) * chunkSize, (chunks - 1) * chunkSize + rest);
}
return arrays;
}
}
Binary file not shown.
+7
View File
@@ -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
Vendored Executable
+251
View File
@@ -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
View File
@@ -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 libs/DiamondBank-OG added at 39d5a2b936.
Submodule
+1
Submodule libs/GxUI-OG added at 287d0eb3ee.
-55
View File
@@ -1,55 +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>net.craftingstore</groupId>
<artifactId>craftingstore</artifactId>
<packaging>pom</packaging>
<version>${revision}</version>
<properties>
<revision>${craftingstore-version}-RELEASE</revision>
<craftingstore-version>2.5.0</craftingstore-version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modules>
<module>core</module>
<module>bukkit</module>
<module>bungee</module>
<module>sponge</module>
<module>assembly</module>
<module>velocity</module>
</modules>
</project>
+15
View File
@@ -0,0 +1,15 @@
rootProject.name = "CraftingStore-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(".") && it.name != "build" }
?.forEach { dir ->
include(":libs:${dir.name}")
project(":libs:${dir.name}").projectDir = dir
}
include(":core", ":bukkit", ":sponge", ":assembly", ":velocity")
-55
View File
@@ -1,55 +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>
<parent>
<groupId>net.craftingstore</groupId>
<artifactId>craftingstore</artifactId>
<version>${revision}</version>
</parent>
<artifactId>sponge</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>sponge</id>
<url>https://repo.spongepowered.org/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.craftingstore</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>7.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
@@ -24,7 +24,7 @@ import org.spongepowered.api.text.format.TextColors;
import java.nio.file.Path;
@Plugin(id = "craftingstore", name = "CraftingStore")
@Plugin(id = "craftingstore", name = "CraftingStore-OG")
public class CraftingStoreSponge {
private CraftingStore craftingStore;
@@ -41,7 +41,7 @@ public class CraftingStoreSponge {
private Config config;
private LiteralText prefix = Text.builder("[").color(TextColors.GRAY)
.append(Text.builder("CraftingStore").color(TextColors.RED).build())
.append(Text.builder("CraftingStore-OG").color(TextColors.RED).build())
.append(Text.builder("] ").color(TextColors.WHITE).build()).build();
@Listener
@@ -53,7 +53,7 @@ public class CraftingStoreSponge {
injector = injector.createChildInjector(new CraftingStoreModule(craftingStore));
CommandSpec craftingStoreCommand = CommandSpec.builder()
.description(Text.of("CraftingStore main command"))
.description(Text.of("CraftingStore-OG main command"))
.permission(craftingStore.ADMIN_PERMISSION)
.arguments(
GenericArguments.optional(GenericArguments.string(Text.of("action"))),
@@ -63,7 +63,7 @@ public class CraftingStoreSponge {
.build();
CommandSpec buyCommand = CommandSpec.builder()
.description(Text.of("CraftingStore buy command"))
.description(Text.of("CraftingStore-OG buy command"))
.executor(injector.getInstance(BuyCommand.class))
.build();
game.getCommandManager().register(this, craftingStoreCommand, "craftingstore", "cs");
@@ -48,4 +48,14 @@ public class SpongePluginConfiguration implements PluginConfiguration {
public int getTimeBetweenCommands() {
return craftingStoreSponge.getConfigWrapper().getConfig().getNode("time-between-commands").getInt(200);
}
@Override
public String getNotEnoughBalanceMessage() {
return null;
}
@Override
public boolean isUsingAlternativeApi() {
return craftingStoreSponge.getConfigWrapper().getConfig().getNode("use-alternative-api").getBoolean(false);
}
}
@@ -3,6 +3,7 @@ package net.craftingstore.sponge.commands;
import com.google.inject.Inject;
import net.craftingstore.core.CraftingStore;
import net.craftingstore.core.exceptions.CraftingStoreApiException;
import net.craftingstore.core.models.api.ApiInventory;
import net.craftingstore.core.models.api.inventory.CraftingStoreInventory;
import net.craftingstore.sponge.CraftingStoreSponge;
import net.craftingstore.sponge.inventory.InventoryBuilder;
@@ -43,8 +44,9 @@ public class BuyCommand implements CommandExecutor {
game.getScheduler().createTaskBuilder()
.execute(() -> {
try {
CraftingStoreInventory gui = craftingStore.getApi().getGUI().get();
Inventory inventory = this.inventoryBuilder.buildInventory(gui);
ApiInventory gui = craftingStore.getApi().getGUI().get();
CraftingStoreInventory craftingStoreInventory = new CraftingStoreInventory(gui.getTitle(), gui.getContent(), gui.getSize());
Inventory inventory = this.inventoryBuilder.buildInventory(craftingStoreInventory);
game.getScheduler().createTaskBuilder()
.execute(() -> {
if (p.isOnline()) {
@@ -36,7 +36,7 @@ public class InventoryBuilder {
public Inventory buildInventory(CraftingStoreInventory csInventory, InventoryAttachment parent) {
String title = csInventory.getTitle();
if (title == null || title.isEmpty()) {
title = "CraftingStore";
title = "CraftingStore-OG";
}
Text formattedTitle = TextSerializers.FORMATTING_CODE.deserialize(title).toText();
-75
View File
@@ -1,75 +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>
<parent>
<groupId>net.craftingstore</groupId>
<artifactId>craftingstore</artifactId>
<version>${revision}</version>
</parent>
<artifactId>velocity</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>velocity</id>
<url>https://repo.velocitypowered.com/snapshots/</url>
</repository>
<repository>
<id>sponge</id>
<url>https://repo.spongepowered.org/maven</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.craftingstore</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>1.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
@@ -20,7 +20,7 @@ import net.craftingstore.velocity.module.CraftingStoreModule;
import java.nio.file.Path;
@Singleton
@Plugin(id = "craftingstore", name = "CraftingStore")
@Plugin(id = "craftingstore", name = "CraftingStore-OG")
public class CraftingStoreVelocity {
@Inject
@@ -44,7 +44,7 @@ public class CraftingStoreVelocity {
this.craftingStore = new CraftingStore(injector.getInstance(CraftingStoreVelocityImpl.class));
injector = injector.createChildInjector(new CraftingStoreModule(craftingStore));
commandManager.register(injector.getInstance(CraftingStoreCommand.class), "csv");
commandManager.register("csv", injector.getInstance(CraftingStoreCommand.class));
eventManager.register(this, injector.getInstance(PendingDonationJoinListener.class));
}
@@ -53,9 +53,11 @@ public class CraftingStoreVelocityImpl implements CraftingStorePlugin {
return false;
}
if (!proxyServer.getCommandManager().execute(proxyServer.getConsoleCommandSource(), donation.getCommand())) {
logger.error("Command " + donation.getCommand() + " failed");
}
proxyServer.getCommandManager().executeAsync(proxyServer.getConsoleCommandSource(), donation.getCommand())
.exceptionally(e -> {
logger.error("Command " + donation.getCommand() + " failed");
return null;
});
return true;
}
@@ -53,4 +53,18 @@ public class VelocityPluginConfiguration implements PluginConfiguration {
}
throw new RuntimeException("Invalid integer value in time-between-commands");
}
@Override
public String getNotEnoughBalanceMessage() {
return null;
}
@Override
public boolean isUsingAlternativeApi() {
Object value = config.getConfig().getOrDefault("use-alternative-api", false);
if (value instanceof Boolean) {
return (boolean) value;
}
throw new RuntimeException("Invalid boolean value in use-alternative-api");
}
}
@@ -1,28 +1,27 @@
package net.craftingstore.velocity.command;
import com.google.inject.Inject;
import com.velocitypowered.api.command.Command;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import com.velocitypowered.api.proxy.ProxyServer;
import net.craftingstore.core.CraftingStore;
import net.craftingstore.velocity.CraftingStoreVelocity;
import net.craftingstore.velocity.annotation.Prefix;
import net.craftingstore.velocity.config.Config;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import net.kyori.text.format.TextDecoration;
import org.checkerframework.checker.nullness.qual.NonNull;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import java.util.concurrent.ExecutionException;
public class CraftingStoreCommand implements Command {
public class CraftingStoreCommand implements SimpleCommand {
@Inject
private CraftingStore craftingStore;
@Inject
@Prefix
private TextComponent prefix;
private Component prefix;
@Inject
private CraftingStoreVelocity velocityPlugin;
@@ -34,12 +33,14 @@ public class CraftingStoreCommand implements Command {
private ProxyServer proxyServer;
@Override
public void execute(CommandSource sender, @NonNull String[] args) {
public void execute(Invocation invocation) {
String[] args = invocation.arguments();
CommandSource sender = invocation.source();
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
craftingStore.reload();
sender.sendMessage(TextComponent.builder("")
sender.sendMessage(Component.text()
.append(prefix)
.append(TextComponent.of("The plugin is reloading!"))
.append(Component.text("The plugin is reloading!"))
.build());
return;
}
@@ -49,14 +50,14 @@ public class CraftingStoreCommand implements Command {
proxyServer.getScheduler().buildTask(velocityPlugin, () -> {
try {
if (craftingStore.reload().get()) {
sender.sendMessage(TextComponent.builder("")
sender.sendMessage(Component.text()
.append(prefix)
.append(TextComponent.of("The new API key has been set in the config, and the plugin has been reloaded."))
.append(Component.text("The new API key has been set in the config, and the plugin has been reloaded."))
.build());
} else {
sender.sendMessage(TextComponent.builder("")
sender.sendMessage(Component.text()
.append(prefix)
.append(TextComponent.of("The API key is invalid. The plugin will not work until you set a valid API key."))
.append(Component.text("The API key is invalid. The plugin will not work until you set a valid API key."))
.build());
}
} catch (InterruptedException | ExecutionException e) {
@@ -67,29 +68,29 @@ public class CraftingStoreCommand implements Command {
}
sender.sendMessage(
TextComponent.of("-----------------------", TextColor.GRAY).decoration(TextDecoration.STRIKETHROUGH, true)
Component.text("-----------------------", NamedTextColor.GRAY).decoration(TextDecoration.STRIKETHROUGH, true)
);
sender.sendMessage(TextComponent.builder("")
.append(TextComponent.of("> ", TextColor.DARK_GRAY))
.append(TextComponent.of("/csv reload", TextColor.GRAY))
.append(TextComponent.of(" -> ", TextColor.DARK_GRAY))
.append(TextComponent.of("Reload the config.", TextColor.GRAY))
sender.sendMessage(Component.text()
.append(Component.text("> ", NamedTextColor.DARK_GRAY))
.append(Component.text("/csv reload", NamedTextColor.GRAY))
.append(Component.text(" -> ", NamedTextColor.DARK_GRAY))
.append(Component.text("Reload the config.", NamedTextColor.GRAY))
.build()
);
sender.sendMessage(TextComponent.builder("")
.append(TextComponent.of("> ", TextColor.DARK_GRAY))
.append(TextComponent.of("/csv key <your key>", TextColor.GRAY))
.append(TextComponent.of(" -> ", TextColor.DARK_GRAY))
.append(TextComponent.of("Update the key.", TextColor.GRAY))
sender.sendMessage(Component.text()
.append(Component.text("> ", NamedTextColor.DARK_GRAY))
.append(Component.text("/csv key <your key>", NamedTextColor.GRAY))
.append(Component.text(" -> ", NamedTextColor.DARK_GRAY))
.append(Component.text("Update the key.", NamedTextColor.GRAY))
.build()
);
sender.sendMessage(
TextComponent.of("-----------------------", TextColor.GRAY).decoration(TextDecoration.STRIKETHROUGH, true)
Component.text("-----------------------", NamedTextColor.GRAY).decoration(TextDecoration.STRIKETHROUGH, true)
);
}
@Override
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
return source.hasPermission("craftingstore.admin");
public boolean hasPermission(Invocation invocation) {
return invocation.source().hasPermission("craftingstore.admin");
}
}
@@ -2,19 +2,19 @@ package net.craftingstore.velocity.module;
import com.google.inject.AbstractModule;
import net.craftingstore.core.CraftingStore;
import net.craftingstore.velocity.CraftingStoreVelocity;
import net.craftingstore.velocity.annotation.Prefix;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
public class CraftingStoreModule extends AbstractModule {
private CraftingStore craftingStore;
private TextComponent prefix = TextComponent.builder("")
.append(TextComponent.of("[", TextColor.GRAY))
.append(TextComponent.of("CraftingStore", TextColor.RED))
.append(TextComponent.of("] ", TextColor.GRAY))
.append(TextComponent.of("", TextColor.WHITE))
private TextComponent prefix = Component.text()
.append(Component.text("[", NamedTextColor.GRAY))
.append(Component.text("CraftingStore-OG", NamedTextColor.RED))
.append(Component.text("] ", NamedTextColor.GRAY))
.append(Component.text("", NamedTextColor.WHITE))
.build();
public CraftingStoreModule(CraftingStore craftingStore) {
@@ -23,6 +23,6 @@ public class CraftingStoreModule extends AbstractModule {
protected void configure() {
bind(CraftingStore.class).toInstance(craftingStore);
bind(TextComponent.class).annotatedWith(Prefix.class).toInstance(prefix);
bind(Component.class).annotatedWith(Prefix.class).toInstance(prefix);
}
}